diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/ApplyRelation.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/ApplyRelation.java new file mode 100644 index 0000000..3d23d9c --- /dev/null +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/ApplyRelation.java @@ -0,0 +1,27 @@ +package com.bonus.sgzb.base.api.domain; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author:liang.chao + * @Date:2024/9/27 - 9:44 + */ +@Data +public class ApplyRelation { + /** + * 费用描述 + */ + private String costRemark; + /** + * 费用价格 + */ + private BigDecimal addCost; + + /** + * 协议id + */ + private String agreementId; + +} diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java index 8eabb3b..aecdae2 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java @@ -65,7 +65,7 @@ public class SltAgreementInfo { @ExcelProperty(index = 6, value = "开始日期") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date startTime; + private String startTime; /** * 退料时间 */ @@ -73,7 +73,7 @@ public class SltAgreementInfo { @ExcelProperty(index = 7, value = "结算日期") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date endTime; + private String endTime; /** * 0在用1退回 */ diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java index a0e0e78..4dc446b 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java @@ -65,4 +65,5 @@ public class SltAgreementRelation { *数据所属 */ private String companyId; + private List applyRelation; } diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltInfoVo.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltInfoVo.java index 8898b87..ea88ea4 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltInfoVo.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltInfoVo.java @@ -32,6 +32,10 @@ public class SltInfoVo { * 丢失费用列表 */ List loseList; + /** + * 额外增加费用明细 + */ + List addCostList; List relations; diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjUsingRecord.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjUsingRecord.java index 156a728..e6e790c 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjUsingRecord.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjUsingRecord.java @@ -210,4 +210,10 @@ public class ProjUsingRecord { @ApiModelProperty(value = "实时库存") private Integer num; + /** + * 在用标识 + */ + @ApiModelProperty(value = "在用标识") + private Integer useFlag; + } \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java index 27e131f..0542f57 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java @@ -34,13 +34,13 @@ public class ProjectMonthDetail { */ @DateTimeFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") - private Date startTime; + private String startTime; /** * 结束日期 */ @DateTimeFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") - private Date endTime; + private String endTime; /** * 结算天数 */ diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java index bc1700d..c61b549 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java @@ -1,5 +1,6 @@ package com.bonus.sgzb.material.mapper; +import com.bonus.sgzb.base.api.domain.ApplyRelation; import com.bonus.sgzb.base.api.domain.SltAgreementApply; import com.bonus.sgzb.base.api.domain.SltAgreementInfo; import com.bonus.sgzb.base.api.domain.SltAgreementRelation; @@ -72,4 +73,8 @@ public interface SltAgreementInfoMapper { int updateBmAgreementInfo(@Param("agreementId") String agreementId); int updateRecodeIsSlt(String id); + + int insertApplyRelation(ApplyRelation applyRelation1); + + List getAddLoseList(AgreementInfo bean); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java index 9dc6c3e..d796b0a 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java @@ -2,10 +2,7 @@ package com.bonus.sgzb.material.service.impl; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.write.metadata.WriteSheet; -import com.bonus.sgzb.base.api.domain.SltAgreementApply; -import com.bonus.sgzb.base.api.domain.SltAgreementInfo; -import com.bonus.sgzb.base.api.domain.SltAgreementRelation; -import com.bonus.sgzb.base.api.domain.SltInfoVo; +import com.bonus.sgzb.base.api.domain.*; import com.bonus.sgzb.common.core.exception.ServiceException; import com.bonus.sgzb.common.core.utils.DateTimeHelper; @@ -64,17 +61,29 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { List preScrapList = getPreScrapList(list); //丢失费用列表 List loseList = getLoseList(list); + //额外增加费用 + List addCostList = getAddLoseList(list); sltInfoVo.setLeaseListOne(leaseListOne); sltInfoVo.setLeaseListThree(leaseListThree); sltInfoVo.setRepairList(repairList); sltInfoVo.setScrapList(scrapList); sltInfoVo.setPreScrapList(preScrapList); sltInfoVo.setLoseList(loseList); - List relations = getRelations(leaseListOne, leaseListThree, repairList, scrapList, preScrapList, loseList, list); + sltInfoVo.setAddCostList(addCostList); + List relations = getRelations(leaseListOne, leaseListThree, repairList, scrapList, preScrapList, loseList, addCostList, list); sltInfoVo.setRelations(relations); return sltInfoVo; } + private List getAddLoseList(List list) { + List applyRelations = new ArrayList<>(); + for (AgreementInfo bean : list) { + List addLoseList = sltAgreementInfoMapper.getAddLoseList(bean); + applyRelations.addAll(addLoseList); + } + return applyRelations; + } + @Override public List getPreScrapList(List list) { List scrapList = new ArrayList<>(); @@ -214,7 +223,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { return leaseList; } - private List getRelations(List leaseListOne, List leaseListThree, List repairList, List scrapList, List preScrapList, List loseList, List list) { + private List getRelations(List leaseListOne, List leaseListThree, List repairList, List scrapList, List preScrapList, List loseList, List addCostList, List list) { List relations = new ArrayList<>(); for (AgreementInfo info : list) { SltAgreementRelation relation = new SltAgreementRelation(); @@ -224,6 +233,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { BigDecimal scrapCost = BigDecimal.ZERO; BigDecimal preScrapCost = BigDecimal.ZERO; BigDecimal repairCost = BigDecimal.ZERO; + BigDecimal addCost = BigDecimal.ZERO; for (SltAgreementInfo lease : leaseListOne) { if (lease.getAgreementId().equals(info.getAgreementId().toString())) { relation.setAgreementId(lease.getAgreementId()); @@ -274,6 +284,13 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { loseCost = loseCost.add(cost); } } + + for (ApplyRelation applyRelation : addCostList) { + if (applyRelation.getAgreementId().equals(info.getAgreementId().toString())) { + BigDecimal cost = applyRelation.getAddCost(); + addCost = addCost.add(cost); + } + } // 判断是否已经结算(01承担方) boolean b = leaseListOne.stream().allMatch(t -> "1".equals(t.getIsSlt())); if (b) { @@ -294,6 +311,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { relation.setScrapCost(scrapCost); relation.setPreScrapCost(preScrapCost); relation.setLoseCost(loseCost); + relation.setAddCost(addCost); relations.add(relation); } return relations; @@ -303,6 +321,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { @Transactional public AjaxResult submitFee(SltAgreementApply apply) { SltAgreementRelation relation = apply.getRelation(); + BigDecimal addPrice = new BigDecimal(0); if (StringUtils.isNotBlank(apply.getRepairIds())) { for (String id : apply.getRepairIds().split(",")) { sltAgreementInfoMapper.updateRecodeIsSlt(id); @@ -311,6 +330,15 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { sltAgreementInfoMapper.updateInfoStatus(apply.getAgreementId()); sltAgreementInfoMapper.updateBmAgreementInfo(apply.getAgreementId()); relation.setAgreementId(apply.getAgreementId()); + List applyRelation = relation.getApplyRelation(); + if (applyRelation != null && applyRelation.size() > 0) { + for (ApplyRelation applyRelation1 : applyRelation) { + addPrice = addPrice.add(applyRelation1.getAddCost()); + applyRelation1.setAgreementId(apply.getAgreementId()); + sltAgreementInfoMapper.insertApplyRelation(applyRelation1); + } + } + relation.setAddCost(addPrice); int i = sltAgreementInfoMapper.insRelation(relation); if (i > 0) { return AjaxResult.success("结算成功"); diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/ProjUsingRecordMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/ProjUsingRecordMapper.xml index f076899..7c413eb 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/ProjUsingRecordMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/ProjUsingRecordMapper.xml @@ -122,5 +122,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" GROUP BY bai.agreement_id, mt.type_id) AS subquery2 ON subquery1.type_id = subquery2.type_id AND subquery1.agreement_id = subquery2.agreement_id + + WHERE IFNULL(subquery1.outNum, 0) - IFNULL(subquery2.backNum, 0) > 0 + \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml index 5b2accf..26f236a 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml @@ -61,11 +61,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{partType}, + + insert into slt_agreement_add_cost (cost_remark,add_cost,agreement_id) + values (#{costRemark},#{addCost},#{agreementId}) + update slt_agreement_info set is_slt = '1', slt_time = now(), - update_time = now(), + update_time = now() where agreement_id = #{agreementId} @@ -591,4 +595,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" group by sad.type_id,sad.ma_id,sad.scrap_type + \ No newline at end of file