From 9f602eb07895d4735f1612b9a13b47ab6d12e706 Mon Sep 17 00:00:00 2001 From: syruan <15555146157@163.com> Date: Thu, 14 Aug 2025 18:36:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor(bonus-material):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=80=80=E6=96=99=E7=94=B3=E8=AF=B7=E5=92=8C=E7=A7=9F=E8=B5=81?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD-=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E7=B1=BB=E5=9E=8B=E5=88=A4=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E9=92=88=E5=AF=B9=E7=8F=AD=E7=BB=84=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=B7=BB=E5=8A=A0=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90=86?= =?UTF-8?q?=20-=20=E6=94=B9=E8=BF=9B=E5=8D=8F=E8=AE=AE=20ID=20=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E9=80=BB=E8=BE=91=EF=BC=8C=E6=94=AF=E6=8C=81=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E4=B8=8D=E5=90=8C=E6=96=B9=E5=BC=8F=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E4=BF=A1=E6=81=AF=20-=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20SQL=20=E6=9F=A5=E8=AF=A2=E8=AF=AD=E5=8F=A5=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E9=AB=98=E6=95=B0=E6=8D=AE=E6=9F=A5=E8=AF=A2=E6=95=88=E7=8E=87?= =?UTF-8?q?=20-=20=E9=87=8D=E6=9E=84=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=BB=93=E6=9E=84=EF=BC=8C=E6=8F=90=E5=8D=87=E5=8F=AF=E8=AF=BB?= =?UTF-8?q?=E6=80=A7=E5=92=8C=E5=8F=AF=E7=BB=B4=E6=8A=A4=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/domain/lease/LeaseOutDetails.java | 3 ++ .../impl/BackApplyInfoServiceImpl.java | 48 ++++++++++++++++++- .../material/common/mapper/SelectMapper.java | 2 + .../service/impl/SelectServiceImpl.java | 37 ++++++++++++-- .../lease/mapper/LeaseApplyInfoMapper.java | 3 +- .../impl/LeaseOutDetailsServiceImpl.java | 2 +- .../mapper/material/common/SelectMapper.xml | 12 ++++- .../material/lease/LeaseApplyInfoMapper.xml | 4 +- 8 files changed, 98 insertions(+), 13 deletions(-) diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java index dd36e9be..999fb461 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java @@ -114,6 +114,9 @@ public class LeaseOutDetails extends BaseEntity { @ApiModelProperty(value = "项目部协议id") private Long projectUnitAgreementId; + @ApiModelProperty(value = "项目部单位id") + private Long projectUnitId; + @ApiModelProperty(value = "是否完成 (0:未完成 1:已完成)") private Integer isFinished; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java index a117d35f..68c88ca1 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java @@ -23,6 +23,7 @@ import com.bonus.material.basic.domain.BmAgreementInfo; import com.bonus.material.basic.domain.BmUnit; import com.bonus.material.basic.mapper.BmAgreementInfoMapper; import com.bonus.material.basic.mapper.BmFileInfoMapper; +import com.bonus.material.basic.mapper.BmUnitMapper; import com.bonus.material.clz.domain.back.MaterialBackApplyDetails; import com.bonus.material.clz.domain.back.MaterialBackApplyInfo; import com.bonus.material.clz.mapper.MaterialBackInfoMapper; @@ -45,6 +46,7 @@ import com.bonus.material.back.service.IBackApplyInfoService; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import javax.validation.constraints.NotNull; /** * 退料任务Service业务层处理 @@ -89,6 +91,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { @Resource private BmAgreementInfoMapper bmAgreementInfoMapper; + @Resource + private BmUnitMapper bmUnitMapper; + /** * 查询退料任务 - 性能优化版 * @@ -923,7 +928,30 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { */ @Override @Transactional(rollbackFor = Exception.class) - public AjaxResult submitBackApply(BackApplyInfo backApplyInfo) { + public AjaxResult submitBackApply(@NotNull(message = "参数不能为空") BackApplyInfo backApplyInfo) { + if (backApplyInfo.getUnitId() == null || backApplyInfo.getProId() == null) { + return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "参数不能为空"); + } + BmUnit queryUnitInfo = bmUnitMapper.selectBmUnitByUnitId(backApplyInfo.getUnitId()); + if (queryUnitInfo.getTypeId() == null) { + throw new ServiceException("单位类型为空"); + } + // 如果单位类型为班组,则查询该班在机具签署✍️的协议ID + LeaseOutDetails leaseOutDetail = new LeaseOutDetails(); + if (queryUnitInfo.getTypeId() == 1731L) { + // 查询班组挂靠的项目部协议信息 + leaseOutDetail = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject( + Math.toIntExact(backApplyInfo.getUnitId()), + Math.toIntExact(backApplyInfo.getProId()) + ); + if (leaseOutDetail == null) { + throw new ServiceException("项目部协议信息查询为空"); + } + // 把后续流程设置为项目部的协议进行处理 + backApplyInfo.setAgreementId(leaseOutDetail.getProjectUnitAgreementId()); + backApplyInfo.setUnitId(leaseOutDetail.getProjectUnitAgreementId()); + } + List codeList = new ArrayList<>(); // 根据传入的id查询退料申请信息 List applyInfoList = backApplyInfoMapper.selectBackDetails(backApplyInfo); @@ -958,6 +986,14 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { Long agreementId = backApplyInfoMapper.selectAgreementId(backApplyInfo); // 先查第四层类型 backApplyInfo.setAgreementId(agreementId); + // 如果单位类型为班组,则查询该班在机具签署✍️的协议ID + if (queryUnitInfo.getTypeId() == 1731L) { + // 把后续流程设置为项目部的协议进行处理 + if (leaseOutDetail.getProjectUnitAgreementId() != null) { + backApplyInfo.setAgreementId(leaseOutDetail.getProjectUnitAgreementId()); + backApplyInfo.setUnitId(leaseOutDetail.getProjectUnitAgreementId()); + } + } List listL4 = mapper.getUseTypeTreeL4(backApplyInfo); if (CollectionUtils.isNotEmpty(applyDetails)) { for (BackApplyDetails applyDetail : applyDetails) { @@ -2202,7 +2238,15 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { // 查询是否存在班组数据 List tbList = backApplyInfoMapper.getTbList(bean); if (CollectionUtils.isEmpty(infoList)) { - return 0; + // 退料单位的协议ID如果查不到,就通过别的协议查(例如班组的协议查不到,可能是项目部去领用的) + if (!Objects.equals(record.getAgreementId(), bean.getAgreementId())) { + infoList = backApplyInfoMapper.getStlInfo(bean.setAgreementId(record.getAgreementId())); + if (CollectionUtils.isEmpty(infoList)) { + return 0; + } + } else { + return 0; + } } BigDecimal backNum = bean.getBackNum(); // 遍历每个typeId diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java index 1391e04c..efbb6428 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java @@ -263,6 +263,8 @@ public interface SelectMapper { */ List getAgreementInfoByIdBack(SelectDto dto); + List getMaterialAgreementInfoByIdBack(SelectDto dto); + /** * 获取无需授权的项目部和后勤单位 * @param bmUnit diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java index 79c29d66..070d96b7 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java @@ -3,11 +3,15 @@ package com.bonus.material.common.service.impl; import com.alibaba.nacos.common.utils.StringUtils; import com.bonus.common.biz.config.DateTimeHelper; import com.bonus.common.biz.domain.*; +import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; import com.bonus.material.back.domain.BackApplyInfo; import com.bonus.material.basic.domain.BmProject; import com.bonus.material.basic.domain.BmUnit; +import com.bonus.material.basic.mapper.BmUnitMapper; +import com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo; +import com.bonus.material.clz.service.MaterialLeaseInfoService; import com.bonus.material.common.domain.dto.SelectDto; import com.bonus.material.common.domain.vo.AgreementVo; import com.bonus.material.common.domain.vo.SelectVo; @@ -18,6 +22,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import javax.validation.constraints.NotNull; import java.util.*; import java.util.stream.Collectors; @@ -32,6 +37,12 @@ public class SelectServiceImpl implements SelectService { @Resource(name = "SelectMapper") private SelectMapper mapper; + @Resource + private BmUnitMapper bmUnitMapper; + + @Resource + private MaterialLeaseInfoService materialLeaseInfoService; + /** * 单位下拉类型树 * @param bmUnit @@ -264,7 +275,7 @@ public class SelectServiceImpl implements SelectService { * @return */ @Override - public AjaxResult getUnitListLease(BmUnit bmUnit) { + public AjaxResult getUnitListLease(@NotNull(message = "参数不能为空") BmUnit bmUnit) { // 获取登陆用户的组织ID Long thisLoginUserDeptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); if (null == thisLoginUserDeptId || 0 == thisLoginUserDeptId) { @@ -509,11 +520,27 @@ public class SelectServiceImpl implements SelectService { try { // 判断单位是否为班组,如果为班组的话,把材料站的领用数据也查询出来 if (bean.getUnitId() != null && bean.getProId() != null) { - List clzAgreementInfos = mapper.getAgreementInfoByIdBack(new SelectDto().setProId(bean.getProId()).setUnitId(Math.toIntExact(bean.getUnitId()))); - // 如果在材料站该单位有签署协议,说明该单位是班组 - if (CollectionUtils.isNotEmpty(clzAgreementInfos)) { - bean.setClzAgreementId(Long.valueOf(clzAgreementInfos.get(0).getAgreementId())); + BmUnit queryUnitInfo = bmUnitMapper.selectBmUnitByUnitId(bean.getUnitId()); + if (queryUnitInfo.getTypeId() == null) { + throw new ServiceException("单位类型为空"); } + // 如果单位类型为班组,则查询该班在机具签署✍️的协议ID + if (queryUnitInfo.getTypeId() == 1731L) { +// List agreementInfos = mapper.getMaterialAgreementInfoByIdBack(new SelectDto().setProId(bean.getProId()).setUnitId(Math.toIntExact(queryUnitInfo.getUnitId()))); +// if (CollectionUtils.isNotEmpty(agreementInfos)) { +// bean.setClzAgreementId(Long.valueOf(agreementInfos.get(0).getAgreementId())); +// } else { +// throw new ServiceException("该班组没有在机具签署✍️的协议"); +// } + List clzAgreementInfos = mapper.getAgreementInfoByIdBack(new SelectDto().setProId(bean.getProId()).setUnitId(Math.toIntExact(bean.getUnitId()))); + // 如果在材料站该单位有签署协议 + if (CollectionUtils.isNotEmpty(clzAgreementInfos)) { + bean.setClzAgreementId(Long.valueOf(clzAgreementInfos.get(0).getAgreementId())); + } else { + throw new ServiceException("该班组没有在机具签署✍️的协议"); + } + } + } // 先查第四层类型 listL4 = mapper.getUseTypeTreeL4(bean); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyInfoMapper.java index 00d02991..4bae96e3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyInfoMapper.java @@ -3,6 +3,7 @@ package com.bonus.material.lease.mapper; import java.util.List; import com.bonus.common.biz.domain.lease.LeaseApplyInfo; import com.bonus.common.biz.domain.lease.LeaseConfirmSign; +import com.bonus.common.biz.domain.lease.LeaseOutDetails; import com.bonus.common.biz.domain.lease.LeaseOutSign; import com.bonus.material.lease.domain.LeaseApplyDetails; import org.apache.ibatis.annotations.Param; @@ -99,7 +100,7 @@ public interface LeaseApplyInfoMapper { * @param projectId 工程id * @return 挂靠的项目部协议id */ - Long selectProjectUnitAgreementIdByTeamAndProject(@Param("teamId") Integer teamId, @Param("projectId") Integer projectId); + LeaseOutDetails selectProjectUnitAgreementIdByTeamAndProject(@Param("teamId") Integer teamId, @Param("projectId") Integer projectId); String getTaskId(Long parentId); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java index b8b60ff7..a3d37a90 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java @@ -222,7 +222,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { // 暂存现在出库的班组单位ID Integer thisOutId = record.getLeaseUnitId(); // 查询班组挂靠的项目部协议ID - Long projectUnitAgreementId = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject(record.getLeaseUnitId(), record.getLeaseProjectId()); + Long projectUnitAgreementId = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject(record.getLeaseUnitId(), record.getLeaseProjectId()).getProjectUnitAgreementId(); if (projectUnitAgreementId != null && projectUnitAgreementId > GlobalConstants.INT_0) { record.setProjectUnitAgreementId(projectUnitAgreementId); } else { diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml index 93ca793e..b17ee5a1 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml @@ -613,7 +613,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" agreement_code AS agreementCode, is_slt AS isSlt FROM clz_bm_agreement_info - WHERE unit_id = #{unitId} AND project_id = #{projectId} AND status = '1' + WHERE unit_id = #{unitId} AND project_id = #{proId} AND status = '1' + + + - SELECT - baii.agreement_id AS projectUnitAgreementId + baii.agreement_id AS projectUnitAgreementId, bai.project_unit_id AS projectUnitId FROM bm_agreement_info bai LEFT JOIN bm_agreement_info baii ON baii.unit_id = bai.project_unit_id AND baii.project_id = #{projectId}