材料站提交结算接口修改

This commit is contained in:
bonus 2025-10-21 16:46:51 +08:00
parent 11301dbf40
commit e6c43863d3
3 changed files with 47 additions and 11 deletions

View File

@ -27,6 +27,7 @@ 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.apache.poi.hpsf.Decimal;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -577,6 +578,9 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
public int submitCosts(MaterialSltInfoVo sltInfoVo) {
try {
if (sltInfoVo.getAgreementIds() != null && sltInfoVo.getAgreementIds().length > 0) {
// 生成uuid使其成为一个批次
String fastUUID = IdUtil.fastUUID();
for (Long agreementId : sltInfoVo.getAgreementIds()) {
@ -587,13 +591,42 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
MaterialSltAgreementInfo info = new MaterialSltAgreementInfo();
info.setAgreementId(agreementId);
//重构出新的leaseList和lostList计算出超期归还的租赁费用和超期未归还的丢失费用
List<MaterialSltAgreementInfo> rsLeaseList = new ArrayList<>();
List<MaterialSltAgreementInfo> rsLoseList = new ArrayList<>();
if(sltInfoVo.getLeaseList() != null && !sltInfoVo.getLeaseList().isEmpty()) {
List<MaterialSltAgreementInfo> leaseList = sltInfoVo.getLeaseList();
for(MaterialSltAgreementInfo leaseInfo : leaseList) {
//超期天数小于7且归还日期不为空
if(leaseInfo.getEndTime()!=null){
rsLeaseList.add(leaseInfo);
}else{
MaterialSltAgreementInfo lose = new MaterialSltAgreementInfo();
BigDecimal cost = leaseInfo.getNum().multiply(leaseInfo.getBuyPrice());
lose.setNum(leaseInfo.getNum());
lose.setTypeId(leaseInfo.getTypeId());
lose.setMaId(leaseInfo.getMaId());
lose.setCosts(cost);
lose.setBuyPrice(leaseInfo.getBuyPrice());
lose.setOverDay(leaseInfo.getOverDay());
lose.setActualExitTime(leaseInfo.getActualExitTime());
lose.setAgreementId(leaseInfo.getAgreementId());
rsLoseList.add(lose);
}
}
}
// 获取各项成本并累加
totalCost = totalCost.add(getLeaseList(info).stream()
totalCost = totalCost.add(rsLeaseList.stream()
.map(MaterialSltAgreementInfo::getCosts)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add));
totalCost = totalCost.add(getLoseList(info).stream()
totalCost = totalCost.add(rsLoseList.stream()
.map(MaterialSltAgreementInfo::getCosts)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add));
@ -632,8 +665,8 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
}
// 插入结算明细表 -- 租赁
if (!sltInfoVo.getLeaseList().isEmpty()) {
List<MaterialSltAgreementInfo> filteredLeaseList = sltInfoVo.getLeaseList().stream()
if (!rsLeaseList.isEmpty()) {
List<MaterialSltAgreementInfo> filteredLeaseList = rsLeaseList.stream()
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
.collect(Collectors.toList());
if (!filteredLeaseList.isEmpty()) {
@ -641,8 +674,8 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
}
}
// 插入结算明细表 -- 丢失
if (!sltInfoVo.getLoseList().isEmpty()) {
List<MaterialSltAgreementInfo> filteredLoseList = sltInfoVo.getLoseList().stream()
if (!rsLoseList.isEmpty()) {
List<MaterialSltAgreementInfo> filteredLoseList = rsLoseList.stream()
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
.collect(Collectors.toList());
if (!filteredLoseList.isEmpty()) {

View File

@ -25,18 +25,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<insert id="insertSltAgreementDetailLease">
insert into clz_slt_agreement_details (apply_id, type_id,ma_id,slt_type,num,start_time,end_time,price,money)
insert into clz_slt_agreement_details (apply_id, type_id,ma_id,slt_type,num,start_time,end_time,out_time,over_day,price,money)
values
<foreach collection="list" item="item" separator=",">
(#{id}, #{item.typeId}, #{item.maId},1,#{item.num},#{item.startTime},#{item.endTime},#{item.leasePrice},#{item.costs})
(#{id}, #{item.typeId}, #{item.maId},1,#{item.num},#{item.startTime},#{item.endTime},#{item.actualExitTime},#{item.overDay},#{item.leasePrice},#{item.costs})
</foreach>
</insert>
<insert id="insertSltAgreementDetailLose">
insert into clz_slt_agreement_details (apply_id, type_id,ma_id,slt_type,num,money)
insert into clz_slt_agreement_details (apply_id, type_id,ma_id,slt_type,num,out_time,over_day,price,money)
values
<foreach collection="list" item="item" separator=",">
(#{id}, #{item.typeId}, #{item.maId},2,#{item.num},#{item.costs})
(#{id}, #{item.typeId}, #{item.maId},2,#{item.num},#{item.actualExitTime},#{item.overDay},#{item.buyPrice},#{item.costs})
</foreach>
</insert>
@ -115,6 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
res.typeName,
res.modelName,
res.mtUnitName,
res.buyPrice,
ROUND(res.leasePrice, 2) as leasePrice,
CASE
WHEN res.unitValue = 0 THEN CAST(SUM(res.num) AS UNSIGNED) -- unitValue=0 转为整数
@ -139,6 +140,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt1.type_name as typeName,
mt.type_name as modelName,
mt.unit_name as mtUnitName,
ifnull(mt.buy_price,0) as buyPrice,
sai.lease_price as leasePrice,
sai.num as num,
DATE(sai.start_time) as startTime,

View File

@ -48,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bma.agreement_code AS agreementCode, bma.is_slt AS isSettlement, pmc.TYPE AS settlementType,
bp.pro_name AS projectName, bu.unit_name AS unitName,cpm.id as taskId,
ROUND(
SUM(ifnull( pmc.LEASE_MONEY, 0 )+ ifnull( pmc.LOST_MONEY, 0 )+ ifnull( pmc.REPAIR_MONEY, 0 )+ ifnull( pmc.SCRAP_MONEY, 0 )), 2
ifnull( pmc.LEASE_MONEY, 0 )+ ifnull( pmc.LOST_MONEY, 0 )+ ifnull( pmc.REPAIR_MONEY, 0 )+ ifnull( pmc.SCRAP_MONEY, 0 ), 2
) AS money,
a.pushStatus AS pushStatus,
a.pushRemark AS pushRemark