From 89a9ebdb94903ed1e5836e0fc256cda4b7a89519 Mon Sep 17 00:00:00 2001 From: mashuai Date: Mon, 18 Aug 2025 17:22:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8F=AD=E7=BB=84=E9=80=80=E6=96=99=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/BackApplyInfoServiceImpl.java | 105 ++++++++++++------ .../common/controller/SelectController.java | 13 +++ .../material/common/mapper/SelectMapper.java | 7 ++ .../common/service/SelectService.java | 7 ++ .../service/impl/SelectServiceImpl.java | 74 ++++++------ .../mapper/material/common/SelectMapper.xml | 25 ++++- 6 files changed, 158 insertions(+), 73 deletions(-) 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 2318d149..318ac249 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 @@ -2214,7 +2214,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { // 更新结算表 List allList = backApplyInfoMapper.selectBackDetails(backApplyInfo); if (CollectionUtils.isNotEmpty(allList)) { - int res = updateSlt4Bean(backApplyInfo, allList); + int res = updateBzSlt4Bean(backApplyInfo, allList); // 检查机具是否领料 if (res == 0) { throw new RuntimeException("该机具未被领料使用"); @@ -2270,46 +2270,13 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); } - /** - * 关键字搜索 - * - * @param item - * @param keyWord - * @return - */ - private boolean containsBackKeyword(BackApplyVo item, String keyWord) { - return (item.getTypeName() != null && item.getTypeName().contains(keyWord)) || - (item.getTypeModelName() != null && item.getTypeModelName().contains(keyWord)) || - (item.getBackPerson() != null && item.getBackPerson().contains(keyWord)) || - (item.getBackUnitName() != null && item.getBackUnitName().contains(keyWord)) || - (item.getBackProName() != null && item.getBackProName().contains(keyWord)) || - (item.getAgreementCode() != null && item.getAgreementCode().contains(keyWord)) || - (item.getBackCode() != null && item.getBackCode().contains(keyWord)) || - (item.getRepairCode() != null && item.getRepairCode().contains(keyWord)) || - (item.getMaCode() != null && item.getMaCode().contains(keyWord)); - } - - - /** - * 更新任务表及退料申请表状态 - * @param backApplyInfo - * @return - */ - private int updateTaskAndBackInfo(BackApplyInfo backApplyInfo) { - int result = backApplyInfoMapper.updateTaskStatus(backApplyInfo); - result += backApplyInfoMapper.updateBack(backApplyInfo); - result += backApplyInfoMapper.updateBackDetails(backApplyInfo); - return result; - } - - /** - * 更新结算表 + * 处理班组退料结算协议 * @param record * @param allList * @return */ - private int updateSlt4Bean(BackApplyInfo record, List allList) { + private int updateBzSlt4Bean(BackApplyInfo record, List allList) { for (BackApplyInfo bean : allList) { List infoList = backApplyInfoMapper.getStlInfo(bean); // 查询是否存在班组数据 @@ -2367,6 +2334,72 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { return 1; } + + /** + * 关键字搜索 + * + * @param item + * @param keyWord + * @return + */ + private boolean containsBackKeyword(BackApplyVo item, String keyWord) { + return (item.getTypeName() != null && item.getTypeName().contains(keyWord)) || + (item.getTypeModelName() != null && item.getTypeModelName().contains(keyWord)) || + (item.getBackPerson() != null && item.getBackPerson().contains(keyWord)) || + (item.getBackUnitName() != null && item.getBackUnitName().contains(keyWord)) || + (item.getBackProName() != null && item.getBackProName().contains(keyWord)) || + (item.getAgreementCode() != null && item.getAgreementCode().contains(keyWord)) || + (item.getBackCode() != null && item.getBackCode().contains(keyWord)) || + (item.getRepairCode() != null && item.getRepairCode().contains(keyWord)) || + (item.getMaCode() != null && item.getMaCode().contains(keyWord)); + } + + + /** + * 更新任务表及退料申请表状态 + * @param backApplyInfo + * @return + */ + private int updateTaskAndBackInfo(BackApplyInfo backApplyInfo) { + int result = backApplyInfoMapper.updateTaskStatus(backApplyInfo); + result += backApplyInfoMapper.updateBack(backApplyInfo); + result += backApplyInfoMapper.updateBackDetails(backApplyInfo); + return result; + } + + /** + * 更新结算表 + * @param record + * @param allList + * @return + */ + private int updateSlt4Bean(BackApplyInfo record, List allList) { + for (BackApplyInfo bean : allList) { + List infoList = backApplyInfoMapper.getStlInfo(bean); + if (infoList.size() > 0) { + BigDecimal backNum = bean.getBackNum(); + for (SltAgreementInfo info : infoList) { + BigDecimal num = info.getBackNum(); + if (backNum.compareTo(num) == 0) { + backApplyInfoMapper.updateStlInfo(info, record); + break; + } else if (backNum.compareTo(num) > 0) { + backNum = backNum.subtract(num); + backApplyInfoMapper.updateStlInfo(info, record); + } else { + BigDecimal many = num.subtract(backNum); + backApplyInfoMapper.updateStlInfoTwo(info, record, backNum); + backApplyInfoMapper.insStlInfoTwo(info, many); + break; + } + } + } else { + return 0; + } + } + return 1; + } + /** * 完成退料申请 * @param backApplyInfo diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java index 66ee0eb2..381c89c4 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java @@ -1,9 +1,11 @@ package com.bonus.material.common.controller; +import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.web.domain.AjaxResult; 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.common.domain.dto.SelectDto; import com.bonus.material.common.service.SelectService; import com.bonus.material.materialStation.domain.ProAuthorizeInfo; @@ -27,6 +29,9 @@ public class SelectController { @Resource(name = "SelectService") private SelectService service; + @Resource + private BmUnitMapper bmUnitMapper; + @ApiOperation(value = "往来单位下拉选") @PostMapping("getUnitList") public AjaxResult getUnitList(@RequestBody BmUnit bmUnit) { @@ -202,6 +207,14 @@ public class SelectController { @ApiOperation(value = "在用设备类型树") @PostMapping("/getUseTypeTree") public AjaxResult getUseTypeTree(@RequestBody BackApplyInfo bean) { + BmUnit queryUnitInfo = bmUnitMapper.selectBmUnitByUnitId(bean.getUnitId()); + if (queryUnitInfo != null && queryUnitInfo.getTypeId() == null) { + throw new ServiceException("单位类型为空"); + } + if (queryUnitInfo != null && queryUnitInfo.getTypeId() == 1731L) { + // 获取班组在用量 + return service.getBzUseTypeTree(bean); + } return service.getUseTypeTree(bean); } 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 efbb6428..852ffde7 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 @@ -292,4 +292,11 @@ public interface SelectMapper { * @return */ List getUseTypeClzTree(BackApplyInfo backApplyInfo); + + /** + * 获取班组在用量 + * @param bean + * @return + */ + List getBzUseTypeTreeL4(BackApplyInfo bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java index d332abbc..0153ca24 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java @@ -250,4 +250,11 @@ public interface SelectService { * @return */ AjaxResult getAgreementInfoByIdBack(SelectDto dto); + + /** + * 获取班组在用量 + * @param bean + * @return + */ + AjaxResult getBzUseTypeTree(BackApplyInfo bean); } 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 ee88e7a8..ed817614 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 @@ -366,6 +366,44 @@ public class SelectServiceImpl implements SelectService { return AjaxResult.success(vo); } + /** + * 获取班组在用量 + * @param bean + * @return + */ + @Override + public AjaxResult getBzUseTypeTree(BackApplyInfo bean) { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + List listL4 = new ArrayList<>(); + List listL3 = new ArrayList<>(); + List listL21 = new ArrayList<>(); + try { + // 先查第四层类型 + listL4 = mapper.getBzUseTypeTreeL4(bean); + if (CollectionUtils.isNotEmpty(listL4)) { + List list4ParentIds = listL4.stream().map(TypeTreeNode::getParentId).collect(Collectors.toList()); + // 根据第四层parentId 查第三层类型 + listL3 = mapper.getUseTypeTreeL3(list4ParentIds); + List list3ParentIds = listL3.stream().map(TypeTreeNode::getParentId).collect(Collectors.toList()); + // 根据第三层parentId 查第1.2层类型 + listL21 = mapper.getUseTypeTreeL21(list3ParentIds); + list.addAll(listL4); + list.addAll(listL3); + list.addAll(listL21); + } + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + TypeTreeBuild treeBuild = new TypeTreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + } catch (Exception e) { + AjaxResult.error("类型树-查询失败", e); + } + return AjaxResult.success(groupList); + } + @Override public AjaxResult getDeviceTypeTree(SelectDto dto) { List groupList = new ArrayList<>(); @@ -518,45 +556,9 @@ public class SelectServiceImpl implements SelectService { List listL3 = new ArrayList<>(); List listL21 = new ArrayList<>(); try { - // 判断单位是否为班组,如果为班组的话,把材料站的领用数据也查询出来 - if (bean.getUnitId() != null && bean.getProId() != null) { - BmUnit queryUnitInfo = bmUnitMapper.selectBmUnitByUnitId(bean.getUnitId()); - if (queryUnitInfo.getTypeId() == null) { - throw new ServiceException("单位类型为空"); - } - // 如果单位类型为班组,则查询该班在机具签署✍️的协议ID - if (queryUnitInfo.getTypeId() == 1731L) { - 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("该班组没有在机具签署✍️的协议"); - } - } - - } - Map mergedMap = new HashMap<>(); // 先查第四层类型 listL4 = mapper.getUseTypeTreeL4(bean); if (CollectionUtils.isNotEmpty(listL4)) { - // 将listL4中typeId相同数据进行合并,数量相加 - for (TypeTreeNode item : listL4) { - Long typeId = item.getTypeId(); - if (mergedMap.containsKey(typeId)) { - // 若存在,则将数量累加 - TypeTreeNode existingItem = mergedMap.get(typeId); - existingItem.setNum(existingItem.getNum().add(item.getNum())); - } else { - // 若不存在,则将当前对象放入Map - TypeTreeNode newItem = new TypeTreeNode(); - // 复制属性 - BeanUtil.copyProperties(item, newItem); - mergedMap.put(typeId, newItem); - } - } - // 将Map中的值转换为List - listL4 = new ArrayList<>(mergedMap.values()); List list4ParentIds = listL4.stream().map(TypeTreeNode::getParentId).collect(Collectors.toList()); // 根据第四层parentId 查第三层类型 listL3 = mapper.getUseTypeTreeL3(list4ParentIds); 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 da0780c0..02f39ee4 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 @@ -614,7 +614,7 @@ 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 = #{proId} AND status = '1' + WHERE unit_id = #{unitId} AND project_id = #{projectId} AND status = '1' + +