From 4fdd8065854134a5713870b38f87c2c89f967947 Mon Sep 17 00:00:00 2001 From: hongchao <3228015117@qq.com> Date: Tue, 6 May 2025 16:09:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E7=AE=97=E7=AE=A1=E7=90=86bug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SltAgreementInfoController.java | 7 + .../settlement/domain/vo/SltInfoVo.java | 5 + .../impl/SltAgreementInfoServiceImpl.java | 202 +++++++++++++----- .../settlement/SltAgreementReduceMapper.xml | 2 +- 4 files changed, 161 insertions(+), 55 deletions(-) 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 aed36019..2d6231f9 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 @@ -131,6 +131,7 @@ public class SltAgreementInfoController extends BaseController { 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<>(); //维修费用列表 @@ -139,26 +140,32 @@ public class SltAgreementInfoController extends BaseController { List scrapList = new ArrayList<>(); //丢失费用列表 List loseList = new ArrayList<>(); + //减免费用列表 + List reductionList = new ArrayList<>(); List relations = new ArrayList<>(); for (SltInfoVo 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; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java index 5357f02a..07461cae 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java @@ -111,6 +111,11 @@ public class SltInfoVo { @ApiModelProperty(value = "协议编号") private String agreementCode; + /** 协议 ids */ + + @ApiModelProperty(value = "协议ids") + private Long[] agreementIds; + private Long id; //申请id String cost; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java index 42fff7e6..02a82145 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java @@ -2,6 +2,7 @@ package com.bonus.material.settlement.service.impl; import java.math.BigDecimal; import java.util.*; +import java.util.stream.Collectors; import com.bonus.common.biz.domain.ProjectTreeBuild; import com.bonus.common.biz.domain.ProjectTreeNode; @@ -86,6 +87,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { 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 = getLeaseList(info); //维修费用列表 @@ -94,11 +96,13 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { List scrapList = getScrapList(info); //丢失费用列表 List loseList = getLoseList(info); + + List reductionList = getReductionList(info); sltInfoVo.setLeaseList(leaseList); sltInfoVo.setRepairList(repairList); sltInfoVo.setScrapList(scrapList); sltInfoVo.setLoseList(loseList); - + sltInfoVo.setReductionList(reductionList); for (SltAgreementInfo lease : leaseList) { if(lease.getCosts()!=null){ leaseCost = leaseCost.add(lease.getCosts()); @@ -119,10 +123,16 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { loseCost = loseCost.add(lose.getCosts()); } } + for (SltAgreementReduce reduction : reductionList) { + if(reduction.getReduceLeaseMoney()!=null){ + reducCost = reducCost.add(reduction.getReduceLeaseMoney()); + } + } 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); return sltInfoVo; @@ -396,64 +406,148 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { * @return 结果 */ @Override + @Transactional public int submitCosts(SltInfoVo sltInfoVo) { try { - //查找是否驳回 - int countReject = sltAgreementInfoMapper.getRejectCount(sltInfoVo); - if(countReject>0){ - Long id = sltAgreementInfoMapper.getRejectId(sltInfoVo); - //修改 - int countAgain = sltAgreementInfoMapper.updateRejectCount(sltInfoVo); - if(countAgain==0){ - throw new ServiceException("slt_agreement_apply修改失败"); - } - sltInfoVo.setUpdateTime(DateUtils.getNowDate()); - sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getUserId())); - int countTwo = sltAgreementInfoMapper.updateBmAgreementStatus(sltInfoVo); - if(countTwo!=1){ - throw new ServiceException("bm_agreement_info修改失败"); - } + if(sltInfoVo.getAgreementIds()!=null) { - if(sltInfoVo.getLeaseList().size()>0){ - sltAgreementInfoMapper.insertSltAgreementDetailLease(sltInfoVo.getLeaseList(),id); - } - if(sltInfoVo.getRepairList().size()>0){ - sltAgreementInfoMapper.insertSltAgreementDetailRepair(sltInfoVo.getRepairList(),id); - } - if(sltInfoVo.getScrapList().size()>0){ - sltAgreementInfoMapper.insertSltAgreementDetailScrap(sltInfoVo.getScrapList(),id); - } - if(sltInfoVo.getLoseList().size()>0){ - sltAgreementInfoMapper.insertSltAgreementDetailLose(sltInfoVo.getLoseList(),id); - } - }else{ - sltInfoVo.setCreateTime(DateUtils.getNowDate()); - sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getUserId())); - //新增 - int countOne = sltAgreementInfoMapper.insertSltAgreementApply(sltInfoVo); - if(countOne!=1){ - throw new ServiceException("slt_agreement_apply新增失败"); - } - // 插入成功后,sltInfoVo 的 id 属性将被自动设置为新生成的主键值 - Long newId = sltInfoVo.getId(); - sltInfoVo.setUpdateTime(DateUtils.getNowDate()); - int countTwo = sltAgreementInfoMapper.updateBmAgreementStatus(sltInfoVo); - if(countTwo!=1){ - throw new ServiceException("bm_agreement_info修改失败"); - } + for (Long agreementId : sltInfoVo.getAgreementIds()) { + Long id = null; + sltInfoVo.setAgreementId(agreementId); + // 计算总成本 + BigDecimal totalCost = BigDecimal.ZERO; + SltAgreementInfo info = new SltAgreementInfo(); + info.setAgreementId(agreementId); - if(sltInfoVo.getLeaseList().size()>0){ - sltAgreementInfoMapper.insertSltAgreementDetailLease(sltInfoVo.getLeaseList(),newId); - } - if(sltInfoVo.getRepairList().size()>0){ - sltAgreementInfoMapper.insertSltAgreementDetailRepair(sltInfoVo.getRepairList(),newId); - } - if(sltInfoVo.getScrapList().size()>0){ - sltAgreementInfoMapper.insertSltAgreementDetailScrap(sltInfoVo.getScrapList(),newId); - } - if(sltInfoVo.getLoseList().size()>0){ - sltAgreementInfoMapper.insertSltAgreementDetailLose(sltInfoVo.getLoseList(),newId); + // 获取各项成本并累加 + totalCost = totalCost.add(getLeaseList(info).stream() + .map(SltAgreementInfo::getCosts) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add)); + + totalCost = totalCost.add(getRepairList(info).stream() + .map(SltAgreementInfo::getCosts) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add)); + + totalCost = totalCost.add(getScrapList(info).stream() + .map(SltAgreementInfo::getCosts) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add)); + + totalCost = totalCost.add(getLoseList(info).stream() + .map(SltAgreementInfo::getCosts) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add)); + + totalCost = totalCost.subtract(getReductionList(info).stream() + .map(SltAgreementReduce::getLeaseMoney) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add)); + + // 设置总成本 + sltInfoVo.setTotalCostAll(totalCost); + //查找是否驳回 + int countReject = sltAgreementInfoMapper.getRejectCount(sltInfoVo); + if (countReject > 0) { + id = sltAgreementInfoMapper.getRejectId(sltInfoVo); + //修改 + int countAgain = sltAgreementInfoMapper.updateRejectCount(sltInfoVo); + if (countAgain == 0) { + throw new ServiceException("slt_agreement_apply修改失败"); + } + sltInfoVo.setUpdateTime(DateUtils.getNowDate()); + sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getUserId())); + int countTwo = sltAgreementInfoMapper.updateBmAgreementStatus(sltInfoVo); + if (countTwo != 1) { + throw new ServiceException("bm_agreement_info修改失败"); + } + } else { + sltInfoVo.setCreateTime(DateUtils.getNowDate()); + sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getUserId())); + //新增 + int countOne = sltAgreementInfoMapper.insertSltAgreementApply(sltInfoVo); + if (countOne != 1) { + throw new ServiceException("slt_agreement_apply新增失败"); + } + // 插入成功后,sltInfoVo 的 id 属性将被自动设置为新生成的主键值 + id = sltInfoVo.getId(); + sltInfoVo.setUpdateTime(DateUtils.getNowDate()); + int countTwo = sltAgreementInfoMapper.updateBmAgreementStatus(sltInfoVo); + if (countTwo != 1) { + throw new ServiceException("bm_agreement_info修改失败"); + } + } +// if (sltInfoVo.getLeaseList().size() > 0) { +// sltAgreementInfoMapper.insertSltAgreementDetailLease(sltInfoVo.getLeaseList(), id); +// } + if (sltInfoVo.getLeaseList().size() > 0) { + List filteredLeaseList = sltInfoVo.getLeaseList().stream() + .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) + .collect(Collectors.toList()); + if (!filteredLeaseList.isEmpty()) { + sltAgreementInfoMapper.insertSltAgreementDetailLease(filteredLeaseList, id); + } + + } + if (sltInfoVo.getRepairList().size() > 0) { + List filteredRepairList = sltInfoVo.getRepairList().stream() + .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) + .collect(Collectors.toList()); + if (!filteredRepairList.isEmpty()) { + sltAgreementInfoMapper.insertSltAgreementDetailRepair(filteredRepairList, id); + } +// sltAgreementInfoMapper.insertSltAgreementDetailRepair(sltInfoVo.getRepairList(),id); + } + if (sltInfoVo.getScrapList().size() > 0) { + List filteredScrapList = sltInfoVo.getScrapList().stream() + .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) + .collect(Collectors.toList()); + if (!filteredScrapList.isEmpty()) { + sltAgreementInfoMapper.insertSltAgreementDetailScrap(filteredScrapList, id); + } +// sltAgreementInfoMapper.insertSltAgreementDetailScrap(sltInfoVo.getScrapList(),id); + } + if (sltInfoVo.getLoseList().size() > 0) { + List filteredLoseList = sltInfoVo.getLoseList().stream() + .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) + .collect(Collectors.toList()); + if (!filteredLoseList.isEmpty()) { + sltAgreementInfoMapper.insertSltAgreementDetailLose(filteredLoseList, id); + } +// sltAgreementInfoMapper.insertSltAgreementDetailLose(sltInfoVo.getLoseList(),id); + } } +// else{ +// sltInfoVo.setCreateTime(DateUtils.getNowDate()); +// sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getUserId())); +// //新增 +// int countOne = sltAgreementInfoMapper.insertSltAgreementApply(sltInfoVo); +// if(countOne!=1){ +// throw new ServiceException("slt_agreement_apply新增失败"); +// } +// // 插入成功后,sltInfoVo 的 id 属性将被自动设置为新生成的主键值 +// Long newId = sltInfoVo.getId(); +// sltInfoVo.setUpdateTime(DateUtils.getNowDate()); +// int countTwo = sltAgreementInfoMapper.updateBmAgreementStatus(sltInfoVo); +// if(countTwo!=1){ +// throw new ServiceException("bm_agreement_info修改失败"); +// } +// +// if(sltInfoVo.getLeaseList().size()>0){ +// sltAgreementInfoMapper.insertSltAgreementDetailLease(sltInfoVo.getLeaseList(),newId); +// } +// if(sltInfoVo.getRepairList().size()>0){ +// sltAgreementInfoMapper.insertSltAgreementDetailRepair(sltInfoVo.getRepairList(),newId); +// } +// if(sltInfoVo.getScrapList().size()>0){ +// sltAgreementInfoMapper.insertSltAgreementDetailScrap(sltInfoVo.getScrapList(),newId); +// } +// if(sltInfoVo.getLoseList().size()>0){ +// sltAgreementInfoMapper.insertSltAgreementDetailLose(sltInfoVo.getLoseList(),newId); +// } +// } + } return 1; diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementReduceMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementReduceMapper.xml index b0814288..11c97607 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementReduceMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementReduceMapper.xml @@ -280,7 +280,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" srd.lease_money as leaseMoney, sra.remark FROM slt_reduce_apply sra - LEFT JOIN slt_reduce_details srd on sra.id = srd.apply_id + INNER JOIN slt_reduce_details srd on sra.id = srd.apply_id LEFT JOIN ma_type mt on mt.type_id = srd.type_id LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id WHERE sra.agreement_id = #{agreementId}