From 58d40d964a7c83ec3da5d07e77ae62e62b99aeec Mon Sep 17 00:00:00 2001 From: syruan <15555146157@163.com> Date: Wed, 30 Jul 2025 15:53:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor(bonus-material):=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E5=8D=8F=E8=AE=AE=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=92=8C=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 mergerData 和 handleData 方法从控制器移动到服务层 - 优化了数据合并和处理的逻辑 - 使用 StringUtils 和 Objects 类改进了字符串和对象的处理- 调整了方法参数和返回类型,提高了代码的可读性和可维护性 --- .../ClzSltAgreementInfoController.java | 58 +------- .../service/ClzSltAgreementInfoService.java | 4 + .../impl/ClzSltAgreementInfoServiceImpl.java | 126 ++++++++++++------ .../SltAgreementInfoController.java | 1 + 4 files changed, 89 insertions(+), 100 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java index f15a56e7..d3e1e224 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java @@ -60,7 +60,7 @@ public class ClzSltAgreementInfoController extends BaseController { @ApiOperation(value = "往来单位id和标段工程id获取协议信息") @PostMapping("getAgreementInfoById") - public AjaxResult getAgreementInfoById(@RequestBody SelectDto dto){ + public AjaxResult getAgreementInfoById(@RequestBody SelectDto dto) { return clzSltAgreementInfoService.getAgreementInfoById(dto); } @@ -79,7 +79,7 @@ public class ClzSltAgreementInfoController extends BaseController { dataList.add(vo); agreementId = info.getAgreementId(); } - bean = mergerData(bean, dataList,unitNames,projectNames); + bean = clzSltAgreementInfoService.mergerData(bean, dataList,unitNames,projectNames); // 根据协议id获取申请时间 TmTask tmTask = taskMapper.selectTaskByIdByCl(agreementId); if (tmTask != null) { @@ -88,60 +88,6 @@ public class ClzSltAgreementInfoController extends BaseController { return AjaxResult.success(bean); } - public MaterialSltInfoVo mergerData(MaterialSltInfoVo vo,List list,List unitNames,List projectNames){ - vo.setUnitName(handleData(unitNames)); - vo.setProjectName(handleData(projectNames)); - BigDecimal leaseCost = BigDecimal.valueOf(0.00); - BigDecimal repairCost = BigDecimal.valueOf(0.00); - BigDecimal scrapCost = BigDecimal.valueOf(0.00); - BigDecimal loseCost = BigDecimal.valueOf(0.00); - BigDecimal reducCost = BigDecimal.valueOf(0.00); - //租赁费用列表 - List leaseList = new ArrayList<>(); - //维修费用列表 - List repairList = new ArrayList<>(); - //报废费用列表 - List scrapList = new ArrayList<>(); - //丢失费用列表 - List loseList = new ArrayList<>(); - //减免费用列表 - List reductionList = new ArrayList<>(); - List relations = new ArrayList<>(); - for (MaterialSltInfoVo infoVo : list) { - leaseCost = leaseCost.add(infoVo.getLeaseCost()); - repairCost = repairCost.add(infoVo.getRepairCost()); - scrapCost = scrapCost.add(infoVo.getScrapCost()); - loseCost = loseCost.add(infoVo.getLoseCost()); - reducCost = reducCost.add(infoVo.getReductionCost()); - leaseList.addAll(infoVo.getLeaseList()); - repairList.addAll(infoVo.getRepairList()); - scrapList.addAll(infoVo.getScrapList()); - loseList.addAll(infoVo.getLoseList()); - reductionList.addAll(infoVo.getReductionList()); - relations.addAll(infoVo.getRelations()); - } - vo.setLeaseList(leaseList); - vo.setRepairList(repairList); - vo.setScrapList(scrapList); - vo.setLoseList(loseList); - vo.setReductionList(reductionList); - vo.setLeaseCost(leaseCost); - vo.setRepairCost(repairCost); - vo.setScrapCost(scrapCost); - vo.setLoseCost(loseCost); - vo.setReductionCost(reducCost); - vo.setRelations(relations); - return vo; - } - - public String handleData(List list){ - StringBuilder sb = new StringBuilder(); - Set set = new HashSet<>(list); - for (String str : set) { - sb.append(str).append("、"); - } - return StringUtils.removeEnd(sb.toString(), "、"); - } /** * 提交结算清单 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java index 45aae129..0fe8f76f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java @@ -28,6 +28,10 @@ public interface ClzSltAgreementInfoService { */ MaterialSltInfoVo getSltInfo(MaterialSltAgreementInfo info); + MaterialSltInfoVo mergerData(MaterialSltInfoVo vo, List list, List unitNames, List projectNames); + + String handleData(List list); + /** * 工程下拉框 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java index a43bf311..57579da1 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java @@ -16,6 +16,7 @@ import com.bonus.material.common.domain.vo.AgreementVo; import com.bonus.material.settlement.domain.SltAgreementReduce; import com.bonus.material.settlement.domain.SltAgreementRelation; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -36,8 +37,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic /** * 根据条件获取协议结算列表 - * @param bean - * @return + * @param bean 查询条件 */ @Override public List getSltAgreementInfo4Project(MaterialSltAgreementInfo bean) { @@ -79,16 +79,6 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic leaseCost = leaseCost.add(lease.getCosts()); } } - /*for (MaterialSltAgreementInfo repair : repairList) { - if(repair.getCosts()!=null && (repair.getPartType().equals("收费"))){ - repairCost = repairCost.add(repair.getCosts()); - } - } - for (MaterialSltAgreementInfo scrap : scrapList) { - if(scrap.getCosts()!=null && (scrap.getPartType().equals("收费"))){ - scrapCost = scrapCost.add(scrap.getCosts()); - } - }*/ for (MaterialSltAgreementInfo lose : loseList) { if(lose.getCosts()!=null){ loseCost = loseCost.add(lose.getCosts()); @@ -109,6 +99,63 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic return sltInfoVo; } + @Override + public MaterialSltInfoVo mergerData(MaterialSltInfoVo vo, List list, List unitNames, List projectNames) { + vo.setUnitName(handleData(unitNames)); + vo.setProjectName(handleData(projectNames)); + BigDecimal leaseCost = BigDecimal.valueOf(0.00); + BigDecimal repairCost = BigDecimal.valueOf(0.00); + BigDecimal scrapCost = BigDecimal.valueOf(0.00); + BigDecimal loseCost = BigDecimal.valueOf(0.00); + BigDecimal reducCost = BigDecimal.valueOf(0.00); + //租赁费用列表 + List leaseList = new ArrayList<>(); + //维修费用列表 + List repairList = new ArrayList<>(); + //报废费用列表 + List scrapList = new ArrayList<>(); + //丢失费用列表 + List loseList = new ArrayList<>(); + //减免费用列表 + List reductionList = new ArrayList<>(); + List relations = new ArrayList<>(); + for (MaterialSltInfoVo infoVo : list) { + leaseCost = leaseCost.add(infoVo.getLeaseCost()); + repairCost = repairCost.add(infoVo.getRepairCost()); + scrapCost = scrapCost.add(infoVo.getScrapCost()); + loseCost = loseCost.add(infoVo.getLoseCost()); + reducCost = reducCost.add(infoVo.getReductionCost()); + leaseList.addAll(infoVo.getLeaseList()); + repairList.addAll(infoVo.getRepairList()); + scrapList.addAll(infoVo.getScrapList()); + loseList.addAll(infoVo.getLoseList()); + reductionList.addAll(infoVo.getReductionList()); + relations.addAll(infoVo.getRelations()); + } + vo.setLeaseList(leaseList); + vo.setRepairList(repairList); + vo.setScrapList(scrapList); + vo.setLoseList(loseList); + vo.setReductionList(reductionList); + vo.setLeaseCost(leaseCost); + vo.setRepairCost(repairCost); + vo.setScrapCost(scrapCost); + vo.setLoseCost(loseCost); + vo.setReductionCost(reducCost); + vo.setRelations(relations); + return vo; + } + + @Override + public String handleData(List list) { + StringBuilder sb = new StringBuilder(); + Set set = new HashSet<>(list); + for (String str : set) { + sb.append(str).append("、"); + } + return StringUtils.removeEnd(sb.toString(), "、"); + } + /** * 工程下拉框 * @@ -169,7 +216,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic @Override public AjaxResult getAgreementInfoById(SelectDto dto) { - List vo = new ArrayList<>(); + List vo; try { List list = clzSltAgreementInfoMapper.getAgreementInfoById(dto.getUnitIds(), Integer.parseInt(dto.getProjectId())); if (CollectionUtils.isNotEmpty(list)) { @@ -191,7 +238,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic @Override public int submitCosts(MaterialSltInfoVo sltInfoVo) { try { - if(sltInfoVo.getAgreementIds()!=null) { + if (sltInfoVo.getAgreementIds() != null) { for (Long agreementId : sltInfoVo.getAgreementIds()) { Long id = null; @@ -260,7 +307,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic throw new ServiceException("bm_agreement_info修改失败"); }*/ } - if (sltInfoVo.getLeaseList().size() > 0) { + if (!sltInfoVo.getLeaseList().isEmpty()) { List filteredLeaseList = sltInfoVo.getLeaseList().stream() .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) .collect(Collectors.toList()); @@ -284,7 +331,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic clzSltAgreementInfoMapper.insertSltAgreementDetailScrap(filteredScrapList, id); } }*/ - if (sltInfoVo.getLoseList().size() > 0) { + if (!sltInfoVo.getLoseList().isEmpty()) { List filteredLoseList = sltInfoVo.getLoseList().stream() .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) .collect(Collectors.toList()); @@ -302,23 +349,22 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic /** * 获取结算关系列表 - * @param leaseList - * @param repairList - * @param scrapList - * @param loseList - * @param sltInfo - * @return + * @param leaseList 领料数据 + * @param repairList 维修数据 + * @param scrapList 报废数据 + * @param loseList 丢失数据 + * @param sltInfo 结算信息 + * @return 协议费用列表 */ private List getRelations(List leaseList, List repairList, List scrapList, List loseList, MaterialSltAgreementInfo sltInfo) { List relations = new ArrayList<>(); -// for (SltAgreementInfo info : list) { SltAgreementRelation relation = new SltAgreementRelation(); BigDecimal loseCost = BigDecimal.ZERO; BigDecimal leaseCost = BigDecimal.ZERO; BigDecimal scrapCost = BigDecimal.ZERO; BigDecimal repairCost = BigDecimal.ZERO; for (MaterialSltAgreementInfo lease : leaseList) { - if (lease.getAgreementId().equals(sltInfo.getAgreementId().toString())) { + if (lease.getAgreementId().equals(sltInfo.getAgreementId())) { relation.setAgreementId(String.valueOf(lease.getAgreementId())); relation.setProjectName(lease.getProjectName()); relation.setUnitName(lease.getUnitName()); @@ -328,19 +374,19 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic } } for (MaterialSltAgreementInfo repair : repairList) { - if (repair.getAgreementId().equals(sltInfo.getAgreementId().toString())) { + if (repair.getAgreementId().equals(sltInfo.getAgreementId())) { BigDecimal cost = repair.getCosts(); repairCost = repairCost.add(cost); } } for (MaterialSltAgreementInfo scrap : scrapList) { - if (scrap.getAgreementId().equals(sltInfo.getAgreementId().toString())) { + if (scrap.getAgreementId().equals(sltInfo.getAgreementId())) { BigDecimal cost = scrap.getCosts(); scrapCost = scrapCost.add(cost); } } for (MaterialSltAgreementInfo lose : loseList) { - if (lose.getAgreementId().equals(sltInfo.getAgreementId().toString())) { + if (lose.getAgreementId().equals(sltInfo.getAgreementId())) { //TODO 上面已经set过值,这里为什么还要set值 relation.setAgreementId(String.valueOf(lose.getAgreementId())); relation.setProjectName(lose.getProjectName()); @@ -355,14 +401,12 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic relation.setScrapCost(scrapCost); relation.setLoseCost(loseCost); relations.add(relation); -// } return relations; } /** * 获取减免费用列表 - * @param info - * @return + * @param info 信息表 */ private List getReductionList(MaterialSltAgreementInfo info) { SltAgreementReduce bean =new SltAgreementReduce(); @@ -372,20 +416,17 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic /** * 获取丢失费用列表 - * @param info - * @return + * @param info 信息表 */ private List getLoseList(MaterialSltAgreementInfo info) { - List loseList = new ArrayList<>(); - List oneOfList = clzSltAgreementInfoMapper.getLoseList(info); - loseList.addAll(oneOfList); + List loseList = new ArrayList<>(oneOfList); for (MaterialSltAgreementInfo bean : loseList) { - if (null == bean.getBuyPrice()) { + if (Objects.isNull(bean.getBuyPrice())) { bean.setBuyPrice(BigDecimal.valueOf(0.00)); } - if (null == bean.getNum()) { + if (Objects.isNull(bean.getNum())) { bean.setNum(BigDecimal.valueOf(0L)); } BigDecimal buyPrice = bean.getBuyPrice(); @@ -400,14 +441,11 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic /** * 获取租赁费用列表 - * @param info - * @return + * @param info 获取租赁费用列表参数 */ private List getLeaseList(MaterialSltAgreementInfo info) { - List leaseList = new ArrayList<>(); - List oneOfList = clzSltAgreementInfoMapper.getLeaseList(info); - leaseList.addAll(oneOfList); + List leaseList = new ArrayList<>(oneOfList); for (MaterialSltAgreementInfo bean : leaseList) { if (null == bean.getLeasePrice()) { @@ -415,10 +453,10 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic }else{ bean.setLeasePrice(bean.getLeasePrice().setScale(2, RoundingMode.HALF_UP)); } - if (null == bean.getNum()) { + if (Objects.isNull(bean.getNum())) { bean.setNum(BigDecimal.valueOf(0L)); } - if (null == bean.getLeaseDays()) { + if (Objects.isNull(bean.getLeaseDays())) { bean.setLeaseDay(0L); } BigDecimal leasePrice = bean.getLeasePrice(); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java index 5e2f2396..2c190960 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java @@ -129,6 +129,7 @@ public class SltAgreementInfoController extends BaseController { } return AjaxResult.success(bean); } + public SltInfoVo mergerData(SltInfoVo vo,List list,List unitNames,List projectNames){ vo.setUnitName(handleData(unitNames)); vo.setProjectName(handleData(projectNames)); From 86ad36e74d4155191fba7f40b4ad798f134880cc Mon Sep 17 00:00:00 2001 From: hongchao <3228015117@qq.com> Date: Wed, 30 Jul 2025 17:42:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=80=80=E6=96=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BackApplyInfoController.java | 19 ++++- .../back/domain/BackApplyDetails.java | 1 + .../back/service/IBackApplyInfoService.java | 7 +- .../impl/BackApplyInfoServiceImpl.java | 77 +++++++++++++++---- .../common/controller/SelectController.java | 6 ++ .../material/common/mapper/SelectMapper.java | 5 ++ .../common/service/SelectService.java | 2 + .../service/impl/SelectServiceImpl.java | 62 +++++++++++++++ .../material/back/BackApplyInfoMapper.xml | 9 +++ .../mapper/material/common/SelectMapper.xml | 53 +++++++++++++ 10 files changed, 216 insertions(+), 25 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java index 4e7407c9..24057479 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java @@ -16,10 +16,7 @@ import com.bonus.material.archives.service.ArchivesService; import com.bonus.material.back.domain.BackApplyDetails; import com.bonus.material.back.domain.HandlingOrder; import com.bonus.material.back.domain.MaCode; -import com.bonus.material.back.domain.vo.BackAppRequestVo; -import com.bonus.material.back.domain.vo.BackApplyInfoVo; -import com.bonus.material.back.domain.vo.BackApplyRequestVo; -import com.bonus.material.back.domain.vo.BackApplyVo; +import com.bonus.material.back.domain.vo.*; import com.bonus.material.common.annotation.PreventRepeatSubmit; import com.bonus.system.api.RemoteFileService; import io.swagger.annotations.Api; @@ -207,6 +204,20 @@ public class BackApplyInfoController extends BaseController { return backApplyInfoService.selectMachineById(dto); } + /** + * 根据typeId查询领料机具列表 + * @param dto + * @return + */ + @ApiOperation(value = "根据typeId查询领料机具列表") + @GetMapping("/selectMachineByIdList") + public AjaxResult selectMachineByIdList(BackApplyInfo dto){ + Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1); + Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10); + List list = backApplyInfoService.selectMachineByIdList(dto); + return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list)); + } + /** * app根据设备编码去检索领料详情 * @param dto diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java index 8c6748b8..66d5ee88 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java @@ -129,4 +129,5 @@ public class BackApplyDetails extends BaseEntity { @ApiModelProperty(value = "一级类型id") private Long firstId; + List maVos; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java index d2780643..5fa6cb9c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java @@ -7,10 +7,7 @@ import com.bonus.material.back.domain.BackApplyDetails; import com.bonus.material.back.domain.BackApplyInfo; import com.bonus.material.back.domain.HandlingOrder; import com.bonus.material.back.domain.MaCode; -import com.bonus.material.back.domain.vo.BackAppRequestVo; -import com.bonus.material.back.domain.vo.BackApplyInfoVo; -import com.bonus.material.back.domain.vo.BackApplyRequestVo; -import com.bonus.material.back.domain.vo.BackApplyVo; +import com.bonus.material.back.domain.vo.*; /** * 退料任务Service接口 @@ -160,6 +157,8 @@ public interface IBackApplyInfoService { */ AjaxResult selectMachineById(BackApplyInfo dto); + List selectMachineByIdList(BackApplyInfo dto); + /** * APP删除退料任务 * @param id 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 e6b82520..779a1cc9 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 @@ -1200,7 +1200,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { BackApplyDetails details = dto.getBackApplyDetails(); details.setCode(dto.getBackApplyInfo().getCode()); details.setParentId(dto.getBackApplyInfo().getId()); - details.setPreNum(BigDecimal.valueOf(1)); + details.setPreNum(BigDecimal.valueOf(dto.getBackApplyDetails().getMaVos().size())); details.setAuditNum(details.getPreNum()); details.setNum(BigDecimal.valueOf(num)); details.setGoodNum(details.getGoodNum()); @@ -1221,25 +1221,42 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { setCommonFields(details, dto.getBackApplyInfo().getId()); // 插入 CheckDetails //根据id查询back_check_details表,看数据是否存在,存在则对数量进行更新,不存在则插入 - BackApplyDetails checkDetails = backApplyInfoMapper.selectCheckDetails(details); - if (checkDetails != null) { - checkDetails.setId(checkDetails.getId()); - result += backApplyInfoMapper.updateCheck(checkDetails); - } else { - result += backApplyInfoMapper.insertCheckDetails(details); + for(MaCodeDto maCodeDto : details.getMaVos()){ + BackApplyDetails backInfo = new BackApplyDetails(); + backInfo = details; + backInfo.setMaId(maCodeDto.getMaId()); + backInfo.setMaCode(maCodeDto.getMaCode()); + BackApplyDetails checkDetails = backApplyInfoMapper.selectCheckDetails(details); + if (checkDetails != null) { + checkDetails.setId(checkDetails.getId()); + result += backApplyInfoMapper.updateCheck(checkDetails); + } else { + result += backApplyInfoMapper.insertCheckDetails(details); + } + if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) { + for (BmFileInfo bmFileInfo : details.getBmFileInfos()) { + bmFileInfo.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName()); + bmFileInfo.setCreateTime(DateUtils.getNowDate()); + bmFileInfo.setTaskId(details.getId()); + bmFileInfo.setTaskType(3); + bmFileInfo.setModelId(backInfo.getMaId()); + result += bmFileInfoMapper.insertBmFileInfo(bmFileInfo); + } + } } //更新ma_machine表状态为3(退料检修) // result += machineMapper.updateStatus(details.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus()); - if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) { - for (BmFileInfo bmFileInfo : details.getBmFileInfos()) { - bmFileInfo.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName()); - bmFileInfo.setCreateTime(DateUtils.getNowDate()); - bmFileInfo.setTaskId(details.getId()); - bmFileInfo.setTaskType(3); - bmFileInfo.setModelId(details.getMaId()); - result += bmFileInfoMapper.insertBmFileInfo(bmFileInfo); - } - } +// if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) { +// for (BmFileInfo bmFileInfo : details.getBmFileInfos()) { +// bmFileInfo.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName()); +// bmFileInfo.setCreateTime(DateUtils.getNowDate()); +// bmFileInfo.setTaskId(details.getId()); +// bmFileInfo.setTaskType(3); +// bmFileInfo.setModelId(details.getMaId()); +// result += bmFileInfoMapper.insertBmFileInfo(bmFileInfo); +// } +// } + return result; } @@ -1354,10 +1371,18 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { } //判断输入或者编码识别或者二维码识别是否为领料工程和单位对应 List list = new ArrayList<>(); + dto.setUserId(SecurityUtils.getLoginUser().getUserid()); if (dto.getMaCode() != null) { list = backApplyInfoMapper.getMachine(dto); + if (CollectionUtils.isEmpty(list)) { + return AjaxResult.error("该编码非您负责的设备,请重新选择"); + } } else if (dto.getQrCode() != null) { + list = backApplyInfoMapper.getMachineByQrCode(dto); + if (CollectionUtils.isEmpty(list)) { + return AjaxResult.error("该编码非您负责的设备,请重新选择"); + } } if (CollectionUtils.isNotEmpty(list)) { for (MaCodeVo maCodeVo : list) { @@ -1632,6 +1657,24 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { return AjaxResult.success(list); } + @Override + public List selectMachineByIdList(BackApplyInfo dto) { + List list = backApplyInfoMapper.getMachineById(dto); + if (CollectionUtils.isNotEmpty(list)) { + // 根据id查询该单据可能存在的设备编码 + List maCodeVos = backApplyInfoMapper.selectByCode(dto.getId()); + if (CollectionUtils.isNotEmpty(maCodeVos)) { + // 获取maCodeVos中的编码 + List maCodes = maCodeVos.stream().map(MaCodeVo::getMaCode).collect(Collectors.toList()); + // 将maCodes中存在于list集合中的编码,把数据从list集合中去除 + list = list.stream(). + filter(info -> !maCodes.contains(info.getMaCode())). + collect(Collectors.toList()); + } + } + return list; + } + /** * APP删除退料任务 * @param id 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 47836761..66ee0eb2 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 @@ -139,6 +139,12 @@ public class SelectController { return service.getDeviceTypeTree(dto); } + @ApiOperation(value = "退料设备类型树") + @PostMapping("getBackDeviceTypeTree") + public AjaxResult getBackDeviceTypeTree(@RequestBody SelectDto dto){ + return service.getBackDeviceTypeTree(dto); + } + @ApiOperation(value = "资产属性") @PostMapping("getAssetAttributesCbx") public AjaxResult getAssetAttributesCbx(@RequestBody SelectDto dto){ 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 63371e04..70416f04 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 @@ -61,6 +61,8 @@ public interface SelectMapper { */ List getDeviceTypeTree(SelectDto dto); + List getBackDeviceTypeTree(SelectDto dto); + /** * 资产属性 * @param dto @@ -126,6 +128,8 @@ public interface SelectMapper { */ List getUseTypeTreeL4(BackApplyInfo bean); + List getUseTypeTreeL4Back(SelectDto bean); + /** * 在用设备类型树3级 * @param list @@ -133,6 +137,7 @@ public interface SelectMapper { */ List getUseTypeTreeL3(List list); + /** * 在用设备类型树2级 * @param list 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 f1486309..d332abbc 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 @@ -103,6 +103,8 @@ public interface SelectService { */ AjaxResult getDeviceTypeTree(SelectDto dto); + AjaxResult getBackDeviceTypeTree(SelectDto dto); + /** * 资产属性 * @param dto 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 89843627..dc3f073f 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 @@ -343,6 +343,68 @@ public class SelectServiceImpl implements SelectService { return AjaxResult.success(groupList); } + @Override + public AjaxResult getBackDeviceTypeTree(SelectDto dto) { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + List listL4 = new ArrayList<>(); + List listL3 = new ArrayList<>(); + List listL21 = new ArrayList<>(); + try { + // 先查第四层类型 + listL4 = mapper.getUseTypeTreeL4Back(dto); + if (CollectionUtils.isNotEmpty(listL4)) { + List list4ParentIds = listL4.stream().map(o -> o.getParentId()).collect(Collectors.toList()); + // 根据第四层parentId 查第三层类型 + listL3 = mapper.getUseTypeTreeL3(list4ParentIds); + List list3ParentIds = listL3.stream().map(o -> o.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); + + + + + + + + + + + + + + + +// List groupList = new ArrayList<>(); +// List list = new ArrayList<>(); +// try { +// list = mapper.getBackDeviceTypeTree(dto); +// if (CollectionUtils.isNotEmpty(list)) { +// // 创建树形结构(数据集合作为参数) +// TreeBuild treeBuild = new TreeBuild(list); +// // 原查询结果转换树形结构 +// groupList = treeBuild.buildTree(); +// } +// } catch (Exception e) { +// log.error("单位树/归属部门/所属上级-查询失败", e); +// } +// return AjaxResult.success(groupList); + } + @Override public AjaxResult getAssetAttributesCbx(SelectDto dto) { List list = new ArrayList<>(); diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml index cfcbe122..d8337ec8 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml @@ -141,6 +141,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and mm.type_id = #{typeId} + + and ( + mm.ma_code like concat('%', #{keyWord}, '%') + ) + GROUP BY mm.ma_code @@ -337,6 +342,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ba.agreement_id AS agreementId FROM slt_agreement_info sai LEFT JOIN ma_machine mm ON sai.ma_id = mm.ma_id + LEFT JOIN ma_type_repair mtr ON mm.type_id = mtr.type_id LEFT JOIN ma_type mt ON mm.type_id = mt.type_id AND mt.del_flag = '0' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id @@ -350,6 +356,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN bm_unit bu on bu.unit_id = ba.unit_id AND bu.del_flag = '0' WHERE sai.`status`=0 and mm.ma_status = '2' + and mtr.user_id = #{userId} and mm.ma_code = #{maCode} AND ba.unit_id = #{unitId} AND ba.project_id = #{proId} @@ -428,6 +435,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM slt_agreement_info sai LEFT JOIN ma_machine mm ON sai.ma_id = mm.ma_id + LEFT JOIN ma_type_repair mtr ON mm.type_id = mtr.type_id LEFT JOIN ma_type mt ON mm.type_id = mt.type_id AND mt.del_flag = '0' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id @@ -442,6 +450,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND bu.del_flag = '0' WHERE sai.`status`=0 and mm.qr_code = #{qrCode} + and mtr.user_id = #{userId} AND ba.unit_id = #{unitId} 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 2a6e9a64..93db0e06 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 @@ -585,4 +585,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM clz_bm_agreement_info WHERE unit_id = #{unitId} AND project_id = #{projectId} AND status = '1' + + From 81c964be5aee4fa6bdce2966af26116973e2a980 Mon Sep 17 00:00:00 2001 From: hayu <1604366271@qq.com> Date: Wed, 30 Jul 2025 18:12:00 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../material/back/domain/HandlingOrder.java | 4 +- .../impl/BackApplyInfoServiceImpl.java | 46 +++++++++++-------- .../material/back/BackApplyInfoMapper.xml | 9 ++-- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/HandlingOrder.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/HandlingOrder.java index 9d8e5233..b345c3ca 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/HandlingOrder.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/HandlingOrder.java @@ -39,7 +39,7 @@ public class HandlingOrder implements Serializable { private String phone; @ApiModelProperty(value = "排序") - private Integer sort; + private String sort; /** * 创建人 @@ -79,4 +79,6 @@ public class HandlingOrder implements Serializable { private String endTime; + private String signUrl; + } 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 779a1cc9..91dea426 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 @@ -1724,7 +1724,15 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { @Override public List getHandlingOrderList(HandlingOrder bean) { - return backApplyInfoMapper.getHandlingOrderList(bean); + List list = backApplyInfoMapper.getHandlingOrderList(bean); + if (list.size()>0){ + for (HandlingOrder handlingOrder : list){ + if (StringUtils.isNotBlank(handlingOrder.getSignUrl())) { + handlingOrder.setSignUrl("data:image/png;base64," + handlingOrder.getSignUrl()); + } + } + } + return list; } @Override @@ -1736,6 +1744,8 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { if (re > 0) { return AjaxResult.error("今日该号已存在"); } + Long userId = SecurityUtils.getLoginUser().getUserid(); + bean.setUpdateBy(userId.toString()); int res = backApplyInfoMapper.uploadSort(bean); if (res > 0) { return AjaxResult.success("排号成功"); @@ -1841,23 +1851,23 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { HandlingOrder beans = new HandlingOrder(); String timeTypes = ""; try { - //判断现在是上午还是下午,上午为A,下午为B - Calendar calendar = Calendar.getInstance(); - int hour = calendar.get(Calendar.HOUR_OF_DAY); - String timeType = (hour < 12) ? "A" : "B"; - timeTypes = timeType; - bean.setTimeType(timeType); - bean.setReserveDate(DateUtils.getDate()); - //查询当前的排号 - HandlingOrder bean1 = backApplyInfoMapper.getSort(bean); - if (bean1 != null && bean1.getSort() != null) { - Integer sort = bean1.getSort() + 1; - beans.setSort(sort); - beans.setTimeType(timeType); - } else { - beans.setTimeType(timeType); - beans.setSort(1); - } +// //判断现在是上午还是下午,上午为A,下午为B +// Calendar calendar = Calendar.getInstance(); +// int hour = calendar.get(Calendar.HOUR_OF_DAY); +// String timeType = (hour < 12) ? "A" : "B"; +// timeTypes = timeType; +// bean.setTimeType(timeType); +// bean.setReserveDate(DateUtils.getDate()); +// //查询当前的排号 +// HandlingOrder bean1 = backApplyInfoMapper.getSort(bean); +// if (bean1 != null && bean1.getSort() != null) { +// Integer sort = bean1.getSort() + 1; +// beans.setSort(sort); +// beans.setTimeType(timeType); +// } else { +// beans.setTimeType(timeType); +// beans.setSort(1); +// } return AjaxResult.success(beans); } catch (Exception e) { log.error("获取排号失败", e); diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml index d8337ec8..eb12a8f3 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml @@ -822,7 +822,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update bm_handling_order - set sort = #{sort},time_type = #{timeType},queue_date=#{reserveDate} + set sort = #{sort},time_type = #{timeType},queue_date=#{reserveDate},update_time = now(),update_by = #{updateBy} where id = #{id} @@ -1068,9 +1068,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bho.time_type as timeType, bho.sort, bho.type, - bho.reserve_date as reserveDate + bho.reserve_date as reserveDate, + su.sign_url as signUrl FROM bm_handling_order bho LEFT JOIN bm_project bp on bp.pro_id = bho.pro_id + LEFT JOIN sys_user su on su.user_id=bho.update_by WHERE bho.is_active = '1' and bho.reserve_date BETWEEN #{startTime} AND #{endTime} @@ -1083,13 +1085,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bho.type like concat('%',#{keyWord},'%') ) - + ORDER BY bho.update_time desc,bho.sort desc