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 4ab31f2a..31ef2ab8 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 @@ -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 rsLeaseList = new ArrayList<>(); + List rsLoseList = new ArrayList<>(); + + if(sltInfoVo.getLeaseList() != null && !sltInfoVo.getLeaseList().isEmpty()) { + List 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 filteredLeaseList = sltInfoVo.getLeaseList().stream() + if (!rsLeaseList.isEmpty()) { + List 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 filteredLoseList = sltInfoVo.getLoseList().stream() + if (!rsLoseList.isEmpty()) { + List filteredLoseList = rsLoseList.stream() .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) .collect(Collectors.toList()); if (!filteredLoseList.isEmpty()) { 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 02b9d2f4..06d7a012 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 @@ -25,18 +25,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - 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 - (#{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}) - 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 - (#{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}) @@ -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, diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml index b140602c..8ca8b8cd 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml @@ -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