结算管理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 scrapCost = BigDecimal.valueOf(0.00);
BigDecimal loseCost = BigDecimal.valueOf(0.00);
BigDecimal reducCost = BigDecimal.valueOf(0.00);
//租赁费用列表
List<SltAgreementInfo> leaseList = new ArrayList<>();
//维修费用列表
@ -139,26 +140,32 @@ public class SltAgreementInfoController extends BaseController {
List<SltAgreementInfo> scrapList = new ArrayList<>();
//丢失费用列表
List<SltAgreementInfo> loseList = new ArrayList<>();
//减免费用列表
List<SltAgreementReduce> reductionList = new ArrayList<>();
List<SltAgreementRelation> 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;
}

View File

@ -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;

View File

@ -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<SltAgreementInfo> leaseList = getLeaseList(info);
//维修费用列表
@ -94,11 +96,13 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
List<SltAgreementInfo> scrapList = getScrapList(info);
//丢失费用列表
List<SltAgreementInfo> loseList = getLoseList(info);
List<SltAgreementReduce> 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<SltAgreementRelation> relations = getRelations(leaseList, repairList, scrapList, loseList, info);
sltInfoVo.setRelations(relations);
return sltInfoVo;
@ -396,12 +406,51 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
* @return 结果
*/
@Override
@Transactional
public int submitCosts(SltInfoVo sltInfoVo) {
try {
if(sltInfoVo.getAgreementIds()!=null) {
for (Long agreementId : sltInfoVo.getAgreementIds()) {
Long id = null;
sltInfoVo.setAgreementId(agreementId);
// 计算总成本
BigDecimal totalCost = BigDecimal.ZERO;
SltAgreementInfo info = new SltAgreementInfo();
info.setAgreementId(agreementId);
// 获取各项成本并累加
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) {
Long id = sltAgreementInfoMapper.getRejectId(sltInfoVo);
id = sltAgreementInfoMapper.getRejectId(sltInfoVo);
//修改
int countAgain = sltAgreementInfoMapper.updateRejectCount(sltInfoVo);
if (countAgain == 0) {
@ -413,19 +462,6 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
if (countTwo != 1) {
throw new ServiceException("bm_agreement_info修改失败");
}
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()));
@ -435,25 +471,83 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
throw new ServiceException("slt_agreement_apply新增失败");
}
// 插入成功后sltInfoVo id 属性将被自动设置为新生成的主键值
Long newId = sltInfoVo.getId();
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) {
sltAgreementInfoMapper.insertSltAgreementDetailLease(sltInfoVo.getLeaseList(),newId);
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) {
sltAgreementInfoMapper.insertSltAgreementDetailRepair(sltInfoVo.getRepairList(),newId);
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) {
sltAgreementInfoMapper.insertSltAgreementDetailScrap(sltInfoVo.getScrapList(),newId);
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) {
sltAgreementInfoMapper.insertSltAgreementDetailLose(sltInfoVo.getLoseList(),newId);
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;

View File

@ -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}