材料站提交结算接口修改
This commit is contained in:
parent
11301dbf40
commit
e6c43863d3
|
|
@ -27,6 +27,7 @@ import com.bonus.material.settlement.domain.SltAgreementReduce;
|
||||||
import com.bonus.material.settlement.domain.SltAgreementRelation;
|
import com.bonus.material.settlement.domain.SltAgreementRelation;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.poi.hpsf.Decimal;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
|
@ -577,6 +578,9 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
||||||
public int submitCosts(MaterialSltInfoVo sltInfoVo) {
|
public int submitCosts(MaterialSltInfoVo sltInfoVo) {
|
||||||
try {
|
try {
|
||||||
if (sltInfoVo.getAgreementIds() != null && sltInfoVo.getAgreementIds().length > 0) {
|
if (sltInfoVo.getAgreementIds() != null && sltInfoVo.getAgreementIds().length > 0) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 生成uuid,使其成为一个批次
|
// 生成uuid,使其成为一个批次
|
||||||
String fastUUID = IdUtil.fastUUID();
|
String fastUUID = IdUtil.fastUUID();
|
||||||
for (Long agreementId : sltInfoVo.getAgreementIds()) {
|
for (Long agreementId : sltInfoVo.getAgreementIds()) {
|
||||||
|
|
@ -587,13 +591,42 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
||||||
MaterialSltAgreementInfo info = new MaterialSltAgreementInfo();
|
MaterialSltAgreementInfo info = new MaterialSltAgreementInfo();
|
||||||
info.setAgreementId(agreementId);
|
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)
|
.map(MaterialSltAgreementInfo::getCosts)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||||
|
|
||||||
totalCost = totalCost.add(getLoseList(info).stream()
|
totalCost = totalCost.add(rsLoseList.stream()
|
||||||
.map(MaterialSltAgreementInfo::getCosts)
|
.map(MaterialSltAgreementInfo::getCosts)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||||
|
|
@ -632,8 +665,8 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
||||||
}
|
}
|
||||||
|
|
||||||
// 插入结算明细表 -- 租赁
|
// 插入结算明细表 -- 租赁
|
||||||
if (!sltInfoVo.getLeaseList().isEmpty()) {
|
if (!rsLeaseList.isEmpty()) {
|
||||||
List<MaterialSltAgreementInfo> filteredLeaseList = sltInfoVo.getLeaseList().stream()
|
List<MaterialSltAgreementInfo> filteredLeaseList = rsLeaseList.stream()
|
||||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (!filteredLeaseList.isEmpty()) {
|
if (!filteredLeaseList.isEmpty()) {
|
||||||
|
|
@ -641,8 +674,8 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 插入结算明细表 -- 丢失
|
// 插入结算明细表 -- 丢失
|
||||||
if (!sltInfoVo.getLoseList().isEmpty()) {
|
if (!rsLoseList.isEmpty()) {
|
||||||
List<MaterialSltAgreementInfo> filteredLoseList = sltInfoVo.getLoseList().stream()
|
List<MaterialSltAgreementInfo> filteredLoseList = rsLoseList.stream()
|
||||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (!filteredLoseList.isEmpty()) {
|
if (!filteredLoseList.isEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -25,18 +25,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="insertSltAgreementDetailLease">
|
<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
|
values
|
||||||
<foreach collection="list" item="item" separator=",">
|
<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>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="insertSltAgreementDetailLose">
|
<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
|
values
|
||||||
<foreach collection="list" item="item" separator=",">
|
<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>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
@ -115,6 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
res.typeName,
|
res.typeName,
|
||||||
res.modelName,
|
res.modelName,
|
||||||
res.mtUnitName,
|
res.mtUnitName,
|
||||||
|
res.buyPrice,
|
||||||
ROUND(res.leasePrice, 2) as leasePrice,
|
ROUND(res.leasePrice, 2) as leasePrice,
|
||||||
CASE
|
CASE
|
||||||
WHEN res.unitValue = 0 THEN CAST(SUM(res.num) AS UNSIGNED) -- unitValue=0 转为整数
|
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,
|
mt1.type_name as typeName,
|
||||||
mt.type_name as modelName,
|
mt.type_name as modelName,
|
||||||
mt.unit_name as mtUnitName,
|
mt.unit_name as mtUnitName,
|
||||||
|
ifnull(mt.buy_price,0) as buyPrice,
|
||||||
|
|
||||||
sai.lease_price as leasePrice,
|
sai.lease_price as leasePrice,
|
||||||
sai.num as num,
|
sai.num as num,
|
||||||
DATE(sai.start_time) as startTime,
|
DATE(sai.start_time) as startTime,
|
||||||
|
|
|
||||||
|
|
@ -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,
|
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,
|
bp.pro_name AS projectName, bu.unit_name AS unitName,cpm.id as taskId,
|
||||||
ROUND(
|
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,
|
) AS money,
|
||||||
a.pushStatus AS pushStatus,
|
a.pushStatus AS pushStatus,
|
||||||
a.pushRemark AS pushRemark
|
a.pushRemark AS pushRemark
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue