From a26d40d9ea8f7df0ce5e9f975a295102fd9cd233 Mon Sep 17 00:00:00 2001 From: bonus <1203338439@qq.com> Date: Wed, 22 Oct 2025 16:32:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=90=E6=96=99=E7=AB=99=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clz/mapper/ClzSltAgreementInfoMapper.java | 9 + .../impl/ClzSltAgreementInfoServiceImpl.java | 207 ++++++++++-------- .../material/clz/ClzAgreementInfoMapper.xml | 124 ++++++++++- 3 files changed, 238 insertions(+), 102 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java index 328ae46d..31f746f2 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java @@ -125,4 +125,13 @@ public interface ClzSltAgreementInfoMapper { String getTeamOutTime(MaterialSltAgreementInfo materialSltAgreementInfo); String getTeamSjOutTime(MaterialSltAgreementInfo materialSltAgreementInfo); + + + List getSltLeaseList(MaterialSltAgreementInfo info); + + List getSltRepairList(MaterialSltAgreementInfo info); + + List getSltScrapList(MaterialSltAgreementInfo info); + + List getSltLoseList(MaterialSltAgreementInfo info); } 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 31ef2ab8..cae972d0 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 @@ -181,30 +181,30 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic List resultVo = new ArrayList<>(); // 查询数据库 List list = clzSltAgreementInfoMapper.getSltList(bean); - if (CollectionUtils.isNotEmpty(list)) { - // 按照结算单号分组 - Map> sltListByCodeMap = list.stream().collect(Collectors.groupingBy(SltAgreementInfo::getSltApplyCode)); - // 遍历Map - sltListByCodeMap.forEach((s, sltAgreementInfoList) -> { - if (CollectionUtils.isNotEmpty(sltAgreementInfoList)) { - // 定义初始化对象 - SltAgreementInfo obj = new SltAgreementInfo(); - BeanUtil.copyProperties(sltAgreementInfoList.get(0), obj, true); +// if (CollectionUtils.isNotEmpty(list)) { +// // 按照结算单号分组 +// Map> sltListByCodeMap = list.stream().collect(Collectors.groupingBy(SltAgreementInfo::getSltApplyCode)); +// // 遍历Map +// sltListByCodeMap.forEach((s, sltAgreementInfoList) -> { +// if (CollectionUtils.isNotEmpty(sltAgreementInfoList)) { +// // 定义初始化对象 +// SltAgreementInfo obj = new SltAgreementInfo(); +// BeanUtil.copyProperties(sltAgreementInfoList.get(0), obj, true); +// +// // 合并结算单中的多个单位名称及费用 +// String unitNames = sltAgreementInfoList.stream().map(SltAgreementInfo::getUnitName).collect(Collectors.joining(",")); +// BigDecimal costsSum = sltAgreementInfoList.stream().map(SltAgreementInfo::getCosts).reduce(BigDecimal.ZERO, BigDecimal::add); +// obj.setUnitName(unitNames); +// obj.setCosts(costsSum); +// +// resultVo.add(obj); +// } +// }); +// } else { +// throw new ServiceException("数据库未查询到结算信息!"); +// } - // 合并结算单中的多个单位名称及费用 - String unitNames = sltAgreementInfoList.stream().map(SltAgreementInfo::getUnitName).collect(Collectors.joining(",")); - BigDecimal costsSum = sltAgreementInfoList.stream().map(SltAgreementInfo::getCosts).reduce(BigDecimal.ZERO, BigDecimal::add); - obj.setUnitName(unitNames); - obj.setCosts(costsSum); - - resultVo.add(obj); - } - }); - } else { - throw new ServiceException("数据库未查询到结算信息!"); - } - - return resultVo; + return list; } /** @@ -267,83 +267,104 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic * 获取已结算清单 */ private List getSettledInfo(MaterialSltAgreementInfo info) { - // 查询各项费用列表 - List sltedList = clzSltAgreementInfoMapper.getSltedList(info); - - if (CollectionUtils.isEmpty(sltedList)) { - throw new ServiceException("未查询到已结算信息!"); - } - - // 定义遍历集合 - Map> materialSltInfoResultMap = sltedList.stream().collect(Collectors.groupingBy(MaterialSltAgreementInfo::getAgreementId)); - // 定义返回对象 List resultVoList = new ArrayList<>(); - for (List key : materialSltInfoResultMap.values()) { - if (CollectionUtils.isEmpty(key)) { - throw new ServiceException("已结算信息异常,请联系管理员!"); - } + //租赁费用列表 + List leaseList = clzSltAgreementInfoMapper.getSltLeaseList(info); + //维修费用列表 + List repairList = clzSltAgreementInfoMapper.getSltRepairList(info); + //报废费用列表 + List scrapList = clzSltAgreementInfoMapper.getSltScrapList(info); + //丢失费用列表 + ListloseList =clzSltAgreementInfoMapper.getSltLoseList(info); - key.forEach((item) -> { - MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo(); - BigDecimal leaseCost = BigDecimal.ZERO, repairCost = BigDecimal.ZERO, scrapCost = BigDecimal.ZERO; - BigDecimal loseCost = BigDecimal.ZERO, reducCost = BigDecimal.ZERO; - //租赁费用列表 - List leaseList = key.stream().filter(slt -> slt.getSltType() == 1).collect(Collectors.toList()); - //维修费用列表 - List repairList = key.stream().filter(slt -> slt.getSltType() == 3).collect(Collectors.toList()); - //报废费用列表 - List scrapList = key.stream().filter(slt -> slt.getSltType() == 4).collect(Collectors.toList()); - //丢失费用列表 - List loseList = key.stream().filter(slt -> slt.getSltType() == 2).collect(Collectors.toList()); + MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo(); - sltInfoVo.setLeaseList(leaseList); - sltInfoVo.setRepairList(repairList); - sltInfoVo.setScrapList(scrapList); - sltInfoVo.setLoseList(loseList); - sltInfoVo.setReductionList(Collections.emptyList()); - for (MaterialSltAgreementInfo lease : leaseList) { - if (lease.getCosts() != null) { - leaseCost = leaseCost.add(lease.getCosts()); - } - } - for (MaterialSltAgreementInfo lose : loseList) { - if (lose.getCosts() != null) { - loseCost = loseCost.add(lose.getCosts()); - } - } + sltInfoVo.setLeaseList(leaseList); + sltInfoVo.setRepairList(repairList); + sltInfoVo.setScrapList(scrapList); + sltInfoVo.setLoseList(loseList); + resultVoList.add(sltInfoVo); + // 查询各项费用列表 + // List sltedList = clzSltAgreementInfoMapper.getSltedList(info); - sltInfoVo.setLeaseCost(leaseCost); - sltInfoVo.setRepairCost(repairCost); - sltInfoVo.setScrapCost(scrapCost); - sltInfoVo.setLoseCost(loseCost); - sltInfoVo.setReductionCost(reducCost); - List relations = getRelations(leaseList, repairList, scrapList, loseList, info); - sltInfoVo.setRelations(relations); - - resultVoList.add(sltInfoVo); - - // 给外层的单位名称/工程名称赋值 - extractInnerNameToOuter(resultVoList, sltInfoVo); - - }); - } - - // 返回之前对集合做去重处理,根据外层的单位名称去重,保留每个单位名称的第一个 - Set seen = new HashSet<>(); - List dedup = new ArrayList<>(resultVoList.size()); - for (MaterialSltInfoVo it : resultVoList) { - if (it == null) continue; - String key = normalize(it.getUnitName()); - if (key == null) continue; - if (seen.add(key)) { - dedup.add(it); // 第一次见到该单位名 -> 保留 - } - } - - return dedup; +// if (CollectionUtils.isEmpty(sltedList)) { +// throw new ServiceException("未查询到已结算信息!"); +// } +// +// // 定义遍历集合 +// Map> materialSltInfoResultMap = sltedList.stream().collect(Collectors.groupingBy(MaterialSltAgreementInfo::getAgreementId)); +// +// // 定义返回对象 +// List resultVoList = new ArrayList<>(); +// +// for (List key : materialSltInfoResultMap.values()) { +// if (CollectionUtils.isEmpty(key)) { +// throw new ServiceException("已结算信息异常,请联系管理员!"); +// } +// +// key.forEach((item) -> { +// MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo(); +// BigDecimal leaseCost = BigDecimal.ZERO, repairCost = BigDecimal.ZERO, scrapCost = BigDecimal.ZERO; +// BigDecimal loseCost = BigDecimal.ZERO, reducCost = BigDecimal.ZERO; +// +// //租赁费用列表 +// List leaseList = key.stream().filter(slt -> slt.getSltType() == 1).collect(Collectors.toList()); +// //维修费用列表 +// List repairList = key.stream().filter(slt -> slt.getSltType() == 3).collect(Collectors.toList()); +// //报废费用列表 +// List scrapList = key.stream().filter(slt -> slt.getSltType() == 4).collect(Collectors.toList()); +// //丢失费用列表 +// List loseList = key.stream().filter(slt -> slt.getSltType() == 2).collect(Collectors.toList()); +// +// sltInfoVo.setLeaseList(leaseList); +// sltInfoVo.setRepairList(repairList); +// sltInfoVo.setScrapList(scrapList); +// sltInfoVo.setLoseList(loseList); +// sltInfoVo.setReductionList(Collections.emptyList()); +// for (MaterialSltAgreementInfo lease : leaseList) { +// if (lease.getCosts() != null) { +// leaseCost = leaseCost.add(lease.getCosts()); +// } +// } +// for (MaterialSltAgreementInfo lose : loseList) { +// if (lose.getCosts() != null) { +// loseCost = loseCost.add(lose.getCosts()); +// } +// } +// +// sltInfoVo.setLeaseCost(leaseCost); +// sltInfoVo.setRepairCost(repairCost); +// sltInfoVo.setScrapCost(scrapCost); +// sltInfoVo.setLoseCost(loseCost); +// sltInfoVo.setReductionCost(reducCost); +// List relations = getRelations(leaseList, repairList, scrapList, loseList, info); +// sltInfoVo.setRelations(relations); +// +// resultVoList.add(sltInfoVo); +// +// // 给外层的单位名称/工程名称赋值 +// extractInnerNameToOuter(resultVoList, sltInfoVo); +// +// }); +// } +// +// // 返回之前对集合做去重处理,根据外层的单位名称去重,保留每个单位名称的第一个 +// Set seen = new HashSet<>(); +// List dedup = new ArrayList<>(resultVoList.size()); +// for (MaterialSltInfoVo it : resultVoList) { +// if (it == null) continue; +// String key = normalize(it.getUnitName()); +// if (key == null) continue; +// if (seen.add(key)) { +// dedup.add(it); // 第一次见到该单位名 -> 保留 +// } +// } +// +// return dedup; + return resultVoList; } /** diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml index 06d7a012..cb290d21 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml @@ -345,24 +345,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + update clz_bm_agreement_info set is_slt = 1, update_time = now()