结算管理bug修复

This commit is contained in:
hongchao 2025-05-06 16:09:34 +08:00
parent d29393b664
commit 4fdd806585
4 changed files with 161 additions and 55 deletions

View File

@ -131,6 +131,7 @@ public class SltAgreementInfoController extends BaseController {
BigDecimal repairCost = BigDecimal.valueOf(0.00); BigDecimal repairCost = BigDecimal.valueOf(0.00);
BigDecimal scrapCost = BigDecimal.valueOf(0.00); BigDecimal scrapCost = BigDecimal.valueOf(0.00);
BigDecimal loseCost = BigDecimal.valueOf(0.00); BigDecimal loseCost = BigDecimal.valueOf(0.00);
BigDecimal reducCost = BigDecimal.valueOf(0.00);
//租赁费用列表 //租赁费用列表
List<SltAgreementInfo> leaseList = new ArrayList<>(); List<SltAgreementInfo> leaseList = new ArrayList<>();
//维修费用列表 //维修费用列表
@ -139,26 +140,32 @@ public class SltAgreementInfoController extends BaseController {
List<SltAgreementInfo> scrapList = new ArrayList<>(); List<SltAgreementInfo> scrapList = new ArrayList<>();
//丢失费用列表 //丢失费用列表
List<SltAgreementInfo> loseList = new ArrayList<>(); List<SltAgreementInfo> loseList = new ArrayList<>();
//减免费用列表
List<SltAgreementReduce> reductionList = new ArrayList<>();
List<SltAgreementRelation> relations = new ArrayList<>(); List<SltAgreementRelation> relations = new ArrayList<>();
for (SltInfoVo infoVo : list) { for (SltInfoVo infoVo : list) {
leaseCost = leaseCost.add(infoVo.getLeaseCost()); leaseCost = leaseCost.add(infoVo.getLeaseCost());
repairCost = repairCost.add(infoVo.getRepairCost()); repairCost = repairCost.add(infoVo.getRepairCost());
scrapCost = scrapCost.add(infoVo.getScrapCost()); scrapCost = scrapCost.add(infoVo.getScrapCost());
loseCost = loseCost.add(infoVo.getLoseCost()); loseCost = loseCost.add(infoVo.getLoseCost());
reducCost = reducCost.add(infoVo.getReductionCost());
leaseList.addAll(infoVo.getLeaseList()); leaseList.addAll(infoVo.getLeaseList());
repairList.addAll(infoVo.getRepairList()); repairList.addAll(infoVo.getRepairList());
scrapList.addAll(infoVo.getScrapList()); scrapList.addAll(infoVo.getScrapList());
loseList.addAll(infoVo.getLoseList()); loseList.addAll(infoVo.getLoseList());
reductionList.addAll(infoVo.getReductionList());
relations.addAll(infoVo.getRelations()); relations.addAll(infoVo.getRelations());
} }
vo.setLeaseList(leaseList); vo.setLeaseList(leaseList);
vo.setRepairList(repairList); vo.setRepairList(repairList);
vo.setScrapList(scrapList); vo.setScrapList(scrapList);
vo.setLoseList(loseList); vo.setLoseList(loseList);
vo.setReductionList(reductionList);
vo.setLeaseCost(leaseCost); vo.setLeaseCost(leaseCost);
vo.setRepairCost(repairCost); vo.setRepairCost(repairCost);
vo.setScrapCost(scrapCost); vo.setScrapCost(scrapCost);
vo.setLoseCost(loseCost); vo.setLoseCost(loseCost);
vo.setReductionCost(reducCost);
vo.setRelations(relations); vo.setRelations(relations);
return vo; return vo;
} }

View File

@ -111,6 +111,11 @@ public class SltInfoVo {
@ApiModelProperty(value = "协议编号") @ApiModelProperty(value = "协议编号")
private String agreementCode; private String agreementCode;
/** 协议 ids */
@ApiModelProperty(value = "协议ids")
private Long[] agreementIds;
private Long id; //申请id private Long id; //申请id
String cost; String cost;

View File

@ -2,6 +2,7 @@ package com.bonus.material.settlement.service.impl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import com.bonus.common.biz.domain.ProjectTreeBuild; import com.bonus.common.biz.domain.ProjectTreeBuild;
import com.bonus.common.biz.domain.ProjectTreeNode; import com.bonus.common.biz.domain.ProjectTreeNode;
@ -86,6 +87,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
BigDecimal repairCost = BigDecimal.valueOf(0.00); BigDecimal repairCost = BigDecimal.valueOf(0.00);
BigDecimal scrapCost = BigDecimal.valueOf(0.00); BigDecimal scrapCost = BigDecimal.valueOf(0.00);
BigDecimal loseCost = BigDecimal.valueOf(0.00); BigDecimal loseCost = BigDecimal.valueOf(0.00);
BigDecimal reducCost = BigDecimal.valueOf(0.00);
//租赁费用列表 //租赁费用列表
List<SltAgreementInfo> leaseList = getLeaseList(info); List<SltAgreementInfo> leaseList = getLeaseList(info);
//维修费用列表 //维修费用列表
@ -94,11 +96,13 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
List<SltAgreementInfo> scrapList = getScrapList(info); List<SltAgreementInfo> scrapList = getScrapList(info);
//丢失费用列表 //丢失费用列表
List<SltAgreementInfo> loseList = getLoseList(info); List<SltAgreementInfo> loseList = getLoseList(info);
List<SltAgreementReduce> reductionList = getReductionList(info);
sltInfoVo.setLeaseList(leaseList); sltInfoVo.setLeaseList(leaseList);
sltInfoVo.setRepairList(repairList); sltInfoVo.setRepairList(repairList);
sltInfoVo.setScrapList(scrapList); sltInfoVo.setScrapList(scrapList);
sltInfoVo.setLoseList(loseList); sltInfoVo.setLoseList(loseList);
sltInfoVo.setReductionList(reductionList);
for (SltAgreementInfo lease : leaseList) { for (SltAgreementInfo lease : leaseList) {
if(lease.getCosts()!=null){ if(lease.getCosts()!=null){
leaseCost = leaseCost.add(lease.getCosts()); leaseCost = leaseCost.add(lease.getCosts());
@ -119,10 +123,16 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
loseCost = loseCost.add(lose.getCosts()); loseCost = loseCost.add(lose.getCosts());
} }
} }
for (SltAgreementReduce reduction : reductionList) {
if(reduction.getReduceLeaseMoney()!=null){
reducCost = reducCost.add(reduction.getReduceLeaseMoney());
}
}
sltInfoVo.setLeaseCost(leaseCost); sltInfoVo.setLeaseCost(leaseCost);
sltInfoVo.setRepairCost(repairCost); sltInfoVo.setRepairCost(repairCost);
sltInfoVo.setScrapCost(scrapCost); sltInfoVo.setScrapCost(scrapCost);
sltInfoVo.setLoseCost(loseCost); sltInfoVo.setLoseCost(loseCost);
sltInfoVo.setReductionCost(reducCost);
List<SltAgreementRelation> relations = getRelations(leaseList, repairList, scrapList, loseList, info); List<SltAgreementRelation> relations = getRelations(leaseList, repairList, scrapList, loseList, info);
sltInfoVo.setRelations(relations); sltInfoVo.setRelations(relations);
return sltInfoVo; return sltInfoVo;
@ -396,64 +406,148 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public int submitCosts(SltInfoVo sltInfoVo) { public int submitCosts(SltInfoVo sltInfoVo) {
try { try {
//查找是否驳回 if(sltInfoVo.getAgreementIds()!=null) {
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.getLeaseList().size()>0){ for (Long agreementId : sltInfoVo.getAgreementIds()) {
sltAgreementInfoMapper.insertSltAgreementDetailLease(sltInfoVo.getLeaseList(),id); Long id = null;
} sltInfoVo.setAgreementId(agreementId);
if(sltInfoVo.getRepairList().size()>0){ // 计算总成本
sltAgreementInfoMapper.insertSltAgreementDetailRepair(sltInfoVo.getRepairList(),id); BigDecimal totalCost = BigDecimal.ZERO;
} SltAgreementInfo info = new SltAgreementInfo();
if(sltInfoVo.getScrapList().size()>0){ info.setAgreementId(agreementId);
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修改失败");
}
if(sltInfoVo.getLeaseList().size()>0){ // 获取各项成本并累加
sltAgreementInfoMapper.insertSltAgreementDetailLease(sltInfoVo.getLeaseList(),newId); totalCost = totalCost.add(getLeaseList(info).stream()
} .map(SltAgreementInfo::getCosts)
if(sltInfoVo.getRepairList().size()>0){ .filter(Objects::nonNull)
sltAgreementInfoMapper.insertSltAgreementDetailRepair(sltInfoVo.getRepairList(),newId); .reduce(BigDecimal.ZERO, BigDecimal::add));
}
if(sltInfoVo.getScrapList().size()>0){ totalCost = totalCost.add(getRepairList(info).stream()
sltAgreementInfoMapper.insertSltAgreementDetailScrap(sltInfoVo.getScrapList(),newId); .map(SltAgreementInfo::getCosts)
} .filter(Objects::nonNull)
if(sltInfoVo.getLoseList().size()>0){ .reduce(BigDecimal.ZERO, BigDecimal::add));
sltAgreementInfoMapper.insertSltAgreementDetailLose(sltInfoVo.getLoseList(),newId);
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<SltAgreementInfo> 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<SltAgreementInfo> 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<SltAgreementInfo> 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<SltAgreementInfo> 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; return 1;

View File

@ -280,7 +280,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
srd.lease_money as leaseMoney, srd.lease_money as leaseMoney,
sra.remark sra.remark
FROM slt_reduce_apply sra 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 mt on mt.type_id = srd.type_id
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
WHERE sra.agreement_id = #{agreementId} WHERE sra.agreement_id = #{agreementId}