From 264061c917935adf1f56e5fb00eec996671a14b4 Mon Sep 17 00:00:00 2001 From: mashuai Date: Sat, 26 Jul 2025 12:51:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/domain/lease/LeaseApplyInfo.java | 3 ++ .../lease/mapper/LeaseApplyInfoMapper.java | 7 +++ .../impl/LeaseApplyInfoServiceImpl.java | 39 +++++++++++++++-- .../impl/LeaseOutDetailsServiceImpl.java | 24 +---------- .../service/impl/LeaseTaskServiceImpl.java | 18 +++++++- .../ma/controller/MachineController.java | 4 +- .../material/lease/LeaseApplyInfoMapper.xml | 43 ++++++++++++------- .../mapper/material/lease/LeaseTaskMapper.xml | 2 +- .../mapper/material/ma/MachineMapper.xml | 3 ++ 9 files changed, 96 insertions(+), 47 deletions(-) diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java index a0abc3ec..5567299e 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java @@ -333,4 +333,7 @@ public class LeaseApplyInfo extends BaseEntity{ @ApiModelProperty(value = "查询类型") private String queryType; + @ApiModelProperty(value = "发布人id") + private Long publisher; + } 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 762b4481..2ce7d2bf 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 @@ -169,4 +169,11 @@ public interface LeaseApplyInfoMapper { * @return */ List selectPublish(LeaseApplyInfo leaseApplyInfo); + + /** + * 根据id去查询出库数量 + * @param applyInfo + * @return + */ + LeaseApplyInfo getOutList(LeaseApplyInfo applyInfo); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java index e0ee8c30..fee5fd88 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java @@ -283,6 +283,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { } // 提取details中的signType和signUrl,单独作为一个集合,并去重 List approveSignList = details.stream() + .filter(detail -> detail.getSignUrl() != null) .map(detail -> new LeaseOutSign(detail.getSignType(), detail.getSignUrl())) .distinct() .collect(Collectors.toList()); @@ -495,6 +496,19 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { // 领用数据 List leaseApplyOutList = leaseApplyInfoMapper.selectPublish(leaseApplyInfo); if (!CollectionUtils.isEmpty(leaseApplyOutList)) { + for (LeaseApplyInfo applyInfo : leaseApplyOutList) { + // 根据id去查询出库数量 + LeaseApplyInfo outList = leaseApplyInfoMapper.getOutList(applyInfo); + if (outList != null) { + if (applyInfo.getPreCountNum().compareTo(outList.getAlNum()) == 0) { + applyInfo.setIsConfirm(2); + } else { + applyInfo.setIsConfirm(1); + } + } else { + applyInfo.setIsConfirm(1); + } + } list.addAll(leaseApplyOutList); } //材料站权限过滤 @@ -577,9 +591,26 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { @Override public List getConfirmTaskList(LeaseApplyInfo leaseApplyInfo) { leaseApplyInfo.setUserId(SecurityUtils.getLoginUser().getUserid()); - + // 领料数据 List list = leaseApplyInfoMapper.selectCompleteOutList(leaseApplyInfo); - + // 领用数据 + List leaseApplyOutList = leaseApplyInfoMapper.selectPublish(leaseApplyInfo); + if (!CollectionUtils.isEmpty(leaseApplyOutList)) { + for (LeaseApplyInfo applyInfo : leaseApplyOutList) { + // 根据id去查询出库数量 + LeaseApplyInfo outList = leaseApplyInfoMapper.getOutList(applyInfo); + if (outList != null) { + if (applyInfo.getPreCountNum().compareTo(outList.getAlNum()) == 0) { + applyInfo.setIsConfirm(2); + } else { + applyInfo.setIsConfirm(1); + } + } else { + applyInfo.setIsConfirm(1); + } + } + list.addAll(leaseApplyOutList); + } if (leaseApplyInfo.getIsConfirm()!=null) { if (leaseApplyInfo.getIsConfirm() == 2) { @@ -856,7 +887,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { } try { leaseApplyInfo.setReleaseTime(DateUtils.getTime()); - leaseApplyInfo.setUpdateBy(SecurityUtils.getLoginUser().getUserid().toString()); + leaseApplyInfo.setPublisher(SecurityUtils.getLoginUser().getUserid()); int result = leaseApplyInfoMapper.updateLeaseApplyInfo(leaseApplyInfo); if (result > 0) { // 同步修改tm_task任务状态, 如果不需要审核,改成 LEASE_TASK_IN_PROGRESS, 如果需要审核,改成 LEASE_TASK_TO_AUDIT @@ -966,7 +997,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { Date nowDate = DateUtils.getNowDate(); String format = dateFormat.format(nowDate); String result = format.replace("-", ""); - return MaterialConstants.LEASE_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1); + return MaterialConstants.LEASE_TASK_TYPE_LABEL + result + String.format("-%05d", thisMonthMaxOrder + 1); } /** 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 f391b856..047396f9 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 @@ -447,29 +447,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { int res = 0; // 领用任务单独判断 if (StringUtils.isNotBlank(record.getPublishTask())) { - LeaseApplyInfo applyInfo = new LeaseApplyInfo(); - applyInfo.setPublishTask(record.getPublishTask()); - // 根据领用批次查询领用详情 - boolean isFinished = true; - List details = leaseApplyDetailsMapper.getDetailsPublish(applyInfo); - if (!CollectionUtils.isEmpty(details)) { - for (LeaseApplyDetails bean : details) { - if (bean.getAlNum().compareTo(bean.getPreNum()) != 0) { - isFinished = false; - break; - } - } - } - if (isFinished) { - String taskId = leaseApplyInfoMapper.getTaskId(record.getParentId()); - // 领用任务状态改为已完成 - res = tmTaskMapper.updateTaskStatus(taskId, LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus()); - if (res == 0) { - throw new RuntimeException("领用任务状态修改失败"); - } - } - res = 1; - return res; + return 1; } // 进行状态判断 List leaseApplyDetailsList = leaseApplyDetailsMapper.getByParentId(record.getParentId()); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java index ed1ef55f..422e04d0 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java @@ -18,7 +18,9 @@ import com.bonus.common.core.utils.bean.BeanUtils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; import com.bonus.material.back.domain.vo.MaCodeVo; +import com.bonus.material.basic.domain.BmAgreementInfo; import com.bonus.material.basic.domain.dto.SysUserRoleVo; +import com.bonus.material.basic.mapper.BmAgreementInfoMapper; import com.bonus.material.basic.mapper.BmFileInfoMapper; import com.bonus.material.basic.mapper.BmUserRoleMapper; import com.bonus.material.lease.domain.LeaseApplyDetails; @@ -38,7 +40,6 @@ import com.bonus.material.task.mapper.TmTaskMapper; import com.bonus.material.work.domain.SysWorkflowConfig; import com.bonus.material.work.domain.SysWorkflowNode; import com.bonus.material.work.domain.SysWorkflowRecordHistory; -import com.bonus.material.work.domain.SysWorkflowType; import com.bonus.material.work.mapper.*; import com.bonus.material.work.service.SysWorkflowRecordService; import com.bonus.system.api.domain.SysUser; @@ -96,6 +97,9 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService { @Resource private BmUserRoleMapper bmUserRoleMapper; + @Resource + private BmAgreementInfoMapper bmAgreementInfoMapper; + /** * 新增领用任务 @@ -176,7 +180,17 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService { tmTaskMapper.insertTmTask(tmTask); leaseApplyInfo.setTaskId(tmTask.getTaskId()); leaseApplyInfo.setCode(taskCode); - + BmAgreementInfo bmAgreementInfo = new BmAgreementInfo(); + bmAgreementInfo.setUnitId(leaseApplyInfo.getUnitId()); + bmAgreementInfo.setProjectId(leaseApplyInfo.getProjectId()); + List bmAgreementInfos = bmAgreementInfoMapper.selectBmAgreementInfoList(bmAgreementInfo); + if (!CollectionUtils.isEmpty(bmAgreementInfos)) { + bmAgreementInfo = bmAgreementInfos.get(0); + TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), bmAgreementInfo.getAgreementId()); + tmTaskAgreement.setCreateTime(DateUtils.getNowDate()); + tmTaskAgreement.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName()); + tmTaskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement); + } // 设置审批人为默认的董班长 Long peopleId = leaseApplyInfoMapper.getDirectAuditBy(); leaseApplyInfo.setDirectAuditBy(peopleId); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java index 089d73c6..947646e2 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java @@ -312,7 +312,9 @@ public class MachineController extends BaseController { @GetMapping(value = "/getInfoByTypeId") public AjaxResult getInfoByTypeId(Machine machine) { try { - return AjaxResult.success(machineService.getInfoByTypeId(machine)); + startPage(); + List list = machineService.getInfoByTypeId(machine); + return AjaxResult.success(getDataTable(list)); } catch (Exception e) { return error("查询失败,请联系管理员"); } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml index fd3c1603..4a97e9ba 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml @@ -261,7 +261,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" estimate_lease_time = #{estimateLeaseTime}, release_time = now(), cost_bearing_party = #{costBearingParty}, - publisher = #{updateBy}, + publisher = #{publisher}, where id = #{id} @@ -351,7 +351,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" lease_publish_details lpd LEFT JOIN lease_apply_info lai ON lai.id = lpd.parent_id LEFT JOIN tm_task tt ON lai.task_id = tt.task_id - LEFT JOIN (SELECT IFNULL( sum(out_num ), 0) AS num, parent_id, publish_task from lease_out_details + LEFT JOIN (SELECT IFNULL( sum(out_num ), 0) AS num, parent_id, publish_task from lease_out_details a + + JOIN ma_type_keeper mtk ON mtk.type_id = a.type_id AND mtk.user_id = #{userId} + GROUP BY parent_id, publish_task) lod ON lpd.parent_id = lod.parent_id AND lpd.publish_task = lod.publish_task LEFT JOIN bm_unit bu ON bu.unit_id = lpd.unit_id @@ -401,6 +404,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where lod.out_num >0 and lod.lease_sign_id is not null and bp.external_id is not null + and tt.task_type = 2 and lai.code = #{code} and lai.task_id = #{taskId} and lai.lease_person = #{leasePerson} @@ -450,7 +454,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" su.nick_name as confirmPerson, lod.confirm_remark as confirmRemark, GROUP_CONCAT(DISTINCT mt2.type_name) as maTypeNames, - lod.lease_sign_id as leaseSignId + lod.lease_sign_id as leaseSignId, + lod.publish_task as publishTask from lease_out_details lod left join ma_type mt1 on lod.type_id = mt1.type_id left join ma_type mt2 on mt1.parent_id = mt2.type_id @@ -711,7 +716,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bu.unit_name AS unitName, bp.pro_name AS projectName, bai.agreement_code AS agreementCode, - IFNULL( sum( lpd.num ), 0 ) AS preCountNum, + IFNULL( lad.num, 0) AS preCountNum, IFNULL(lod.num, 0) AS alNum, GROUP_CONCAT( DISTINCT mt1.type_name ) AS maTypeNames, lpd.publish_task AS publishTask, @@ -724,19 +729,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" lod.confirm_remark AS confirmRemark, mt3.type_id AS firstId, lpd.create_time AS releaseTime, - bp.external_id as externalId, - CASE - WHEN IFNULL(sum(lad.pre_num),0) = SUM(CASE WHEN lod.is_confirm = 2 THEN lod.num ELSE 0 END) THEN 2 - ELSE 1 - END as isConfirm + bp.external_id as externalId FROM - lease_publish_details lpd - LEFT JOIN lease_apply_info lai ON lai.id = lpd.parent_id - LEFT JOIN lease_apply_details lad ON lai.id = lad.parent_id + lease_apply_info lai + LEFT JOIN (SELECT parent_id, SUM(pre_num) as num FROM lease_apply_details GROUP BY parent_id) lad ON lai.id = lad.parent_id LEFT JOIN tm_task tt ON lai.task_id = tt.task_id + LEFT JOIN lease_publish_details lpd ON lai.id = lpd.parent_id LEFT JOIN (SELECT IFNULL( sum(out_num ), 0) AS num, parent_id, publish_task, is_confirm, confirm_remark, confirm_time, lease_sign_id from lease_out_details - GROUP BY parent_id, publish_task) lod ON lpd.parent_id = lod.parent_id - AND lpd.publish_task = lod.publish_task + GROUP BY parent_id) lod ON lpd.parent_id = lod.parent_id LEFT JOIN bm_unit bu ON bu.unit_id = lpd.unit_id LEFT JOIN bm_project bp ON bp.pro_id = lpd.project_id LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit @@ -750,7 +750,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND lpd.project_id = bai.project_id left join sys_user su on lpd.create_by = su.user_id where - lod.lease_sign_id is not null and bp.external_id is not null + lod.lease_sign_id is not null and bp.external_id is not null and tt.task_type = '19' @@ -761,11 +761,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND lpd.publish_task = #{publishTask} GROUP BY - lpd.publish_task + lai.id ORDER BY lpd.create_time DESC + + update lease_out_details diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml index c598c70e..257632ab 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml @@ -804,8 +804,8 @@ case tt.task_status when 1 then '未完成' - when 4 then '已完成' when 3 then '已完成' + when 4 then '已完成' when 5 then '已终止' end as taskStatusName, IFNULL(sum(lad.pre_num),0) as preCountNum, diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml index 3cb23141..09e2a0c1 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml @@ -771,5 +771,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and wsi.model_id = #{typeId} + + and wsi.ma_code LIKE CONCAT('%',#{maCode},'%') +