From 31b04c5e6a54caf3a9bba02aabd606813438681c Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Thu, 5 Dec 2024 12:46:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=B7=A5=E7=A8=8B=E7=BB=93?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SltAgreementInfoController.java | 8 + .../settlement/domain/SltAgreementInfo.java | 22 ++ .../domain/SltAgreementRelation.java | 18 ++ .../settlement/domain/vo/SltInfoVo.java | 36 ++++ .../mapper/SltAgreementInfoMapper.java | 9 + .../service/ISltAgreementInfoService.java | 3 + .../impl/SltAgreementInfoServiceImpl.java | 189 ++++++++++++++++++ .../task/mapper/TmTaskAgreementMapper.java | 4 + .../material/task/mapper/TmTaskMapper.java | 4 + .../settlement/SltAgreementInfoMapper.xml | 110 ++++++++++ .../mapper/material/task/TmTaskMapper.xml | 6 + 11 files changed, 409 insertions(+) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java index 337f7386..cad97caa 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java @@ -4,6 +4,7 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; +import com.bonus.material.settlement.domain.vo.SltInfoVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -49,6 +50,13 @@ public class SltAgreementInfoController extends BaseController { return getDataTable(list); } + @ApiOperation(value = "根据协议获取结算清单") + @PostMapping("/getSltInfo") + public AjaxResult getSltInfo(@RequestBody List list) { + SltInfoVo bean = sltAgreementInfoService.getSltInfo(list); + return AjaxResult.success(bean); + } + /** * 导出结算信息列表 */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java index ffd2f25d..bfe00cf3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java @@ -108,5 +108,27 @@ public class SltAgreementInfo extends BaseEntity { @ApiModelProperty(value = "调整天数") private Long trimDay; + /** + * 租赁天数 + */ + @Excel(name = "租赁天数") + @ApiModelProperty(value = "租赁天数") + private Long leaseDay; + /** + * 租赁费用 + */ + @Excel(name = "租赁费用") + @ApiModelProperty(value = "租赁费用") + private BigDecimal costs; + + + /** + * 项目名称 + */ + private String unitName; + /** + * 工程名称 + */ + private String projectName; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementRelation.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementRelation.java index 413fdf3b..cc405090 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementRelation.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementRelation.java @@ -33,6 +33,19 @@ public class SltAgreementRelation extends BaseEntity { @ApiModelProperty(value = "协议id") private String agreementId; + /** + * 项目名称 + */ + private String unitName; + /** + * 工程名称 + */ + private String projectName; + /** + * 公司ID + */ + private Long companyId; + /** 增加费用 */ @Excel(name = "增加费用") @ApiModelProperty(value = "增加费用") @@ -43,6 +56,11 @@ public class SltAgreementRelation extends BaseEntity { @ApiModelProperty(value = "减免费用") private BigDecimal subCost; + /** 租赁费用 */ + @Excel(name = "租赁费用") + @ApiModelProperty(value = "租赁费用") + private BigDecimal leaseCost; + /** 费用承担方1费用 */ @Excel(name = "费用承担方1费用") @ApiModelProperty(value = "费用承担方1费用") diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java new file mode 100644 index 00000000..6fc4b71c --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java @@ -0,0 +1,36 @@ +package com.bonus.material.settlement.domain.vo; + +import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.settlement.domain.SltAgreementRelation; +import lombok.Data; + +import java.util.List; + +/** + * @author c liu + * @date 2024/2/23 + */ +@Data +public class SltInfoVo { + /** + * 租赁费用列表 + */ + List leaseList; + /** + * 维修费用列表 + */ + List repairList; + /** + * 报废费用列表 + */ + List scrapList; + /** + * 丢失费用列表 + */ + List loseList; + + List relations; + + String cost; + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java index a23c4aef..7d7f5c05 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java @@ -5,6 +5,7 @@ import java.util.List; import com.bonus.material.lease.domain.LeaseOutDetails; import com.bonus.material.ma.domain.Type; import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.task.domain.TmTask; import org.apache.ibatis.annotations.Param; /** @@ -67,4 +68,12 @@ public interface SltAgreementInfoMapper { int updSltInfo(SltAgreementInfo sltAgreementInfo); int insSltInfo(@Param("record") LeaseOutDetails record, @Param("agreementId")String agreementId, @Param("ma") Type ma); + + List getLeaseList(SltAgreementInfo bean); + + List getRepairDetailsList(@Param("taskList") List taskList); + + List getScrapDetailsList(@Param("taskList") List taskList); + + List getLoseList(SltAgreementInfo bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java index da13ac60..738f50ad 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java @@ -2,6 +2,7 @@ package com.bonus.material.settlement.service; import java.util.List; import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.settlement.domain.vo.SltInfoVo; /** * 结算信息Service接口 @@ -26,6 +27,8 @@ public interface ISltAgreementInfoService { */ public List selectSltAgreementInfoList(SltAgreementInfo sltAgreementInfo); + public SltInfoVo getSltInfo(List list); + /** * 新增结算信息 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java index 8a660d22..ae8f10b5 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java @@ -1,14 +1,24 @@ package com.bonus.material.settlement.service.impl; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; + +import com.bonus.common.biz.enums.TmTaskTypeEnum; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; +import com.bonus.material.settlement.domain.SltAgreementRelation; +import com.bonus.material.settlement.domain.vo.SltInfoVo; +import com.bonus.material.task.domain.TmTask; +import com.bonus.material.task.mapper.TmTaskMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.bonus.material.settlement.mapper.SltAgreementInfoMapper; import com.bonus.material.settlement.domain.SltAgreementInfo; import com.bonus.material.settlement.service.ISltAgreementInfoService; +import javax.annotation.Resource; + /** * 结算信息Service业务层处理 * @@ -20,6 +30,9 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { @Autowired private SltAgreementInfoMapper sltAgreementInfoMapper; + @Autowired + private TmTaskMapper taskMapper; + /** * 查询结算信息 * @@ -42,6 +55,26 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { return sltAgreementInfoMapper.selectSltAgreementInfoList(sltAgreementInfo); } + @Override + public SltInfoVo getSltInfo(List list) { + SltInfoVo sltInfoVo = new SltInfoVo(); + //租赁费用列表 + List leaseList = getLeaseList(list); + //维修费用列表 + List repairList = getRepairList(list); + //报废费用列表 + List scrapList = getScrapList(list); + //丢失费用列表 + List loseList = getLoseList(list); + sltInfoVo.setLeaseList(leaseList); + sltInfoVo.setRepairList(repairList); + sltInfoVo.setScrapList(scrapList); + sltInfoVo.setLoseList(loseList); + List relations = getRelations(leaseList, repairList, scrapList, loseList, list); + sltInfoVo.setRelations(relations); + return sltInfoVo; + } + /** * 新增结算信息 * @@ -95,4 +128,160 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { public int deleteSltAgreementInfoById(Long id) { return sltAgreementInfoMapper.deleteSltAgreementInfoById(id); } + + public List getLeaseList(List list) { + List leaseList = new ArrayList<>(); + for (SltAgreementInfo bean : list) { + List oneOfList = sltAgreementInfoMapper.getLeaseList(bean); + leaseList.addAll(oneOfList); + } + for (SltAgreementInfo bean : leaseList) { + if (bean.getLeasePrice() == null) { + bean.setLeasePrice(BigDecimal.valueOf(0.00)); + } + if (bean.getNum() == null) { + bean.setNum(0L); + } + if (bean.getLeaseDay() == null) { + bean.setLeaseDay(0L); + } + BigDecimal leasePrice = bean.getLeasePrice(); + BigDecimal num = new BigDecimal(bean.getNum()); + BigDecimal leaseDays = new BigDecimal(bean.getLeaseDay()); + BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays); + bean.setCosts(costs); + } + return leaseList; + } + + public List getRepairList(List list) { + List repairList = new ArrayList<>(); + Integer taskType = TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId(); + //String taskType = TaskTypeEnum.MAINTENANCE_TASK.getCode(); + for (SltAgreementInfo bean : list) { + List taskList = taskMapper.getTaskList(bean, taskType); + if (taskList != null && taskList.size() > 0) { + List repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(taskList); + repairList.addAll(repairDetailsList); + } + } + return repairList; + } + + public List getScrapList(List list) { + List scrapList = new ArrayList<>(); + Integer taskType = TmTaskTypeEnum.TM_TASK_SCRAP.getTaskTypeId(); + //String taskType = TaskTypeEnum.SCRAP_TASK.getCode(); + for (SltAgreementInfo bean : list) { + List taskList = taskMapper.getTaskList(bean, taskType); + if (taskList != null && taskList.size() > 0) { + List scrapDetailsList = sltAgreementInfoMapper.getScrapDetailsList(taskList); + scrapList.addAll(scrapDetailsList); + } + } + if (scrapList != null && scrapList.size() > 0) { + for (SltAgreementInfo bean : scrapList) { + + if (bean.getBuyPrice() == null) { + bean.setBuyPrice(BigDecimal.valueOf(0.00)); + } + if (bean.getNum() == null) { + bean.setNum(0L); + } + BigDecimal buyPrice = bean.getBuyPrice(); + BigDecimal num = new BigDecimal(bean.getNum()); + BigDecimal costs = buyPrice.multiply(num); + //计算总金额 + /*BigDecimal costs = BigDecimal.ZERO; + if (bean.getBuyPrice() != null && bean.getBuyPrice() != null){ + BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice()); + BigDecimal num = new BigDecimal(bean.getNum()); + costs = buyPrice.multiply(num); + }*/ + bean.setCosts(costs); + } + } + return scrapList; + } + + public List getLoseList(List list) { + List loseList = new ArrayList<>(); + for (SltAgreementInfo bean : list) { + List oneOfList = sltAgreementInfoMapper.getLoseList(bean); + loseList.addAll(oneOfList); + } + for (SltAgreementInfo bean : loseList) { + if (bean.getBuyPrice() == null) { + bean.setBuyPrice(BigDecimal.valueOf(0.00)); + } + if (bean.getNum() == null) { + bean.setNum(0L); + } + BigDecimal buyPrice = bean.getBuyPrice(); + BigDecimal num = new BigDecimal(bean.getNum()); + // 原价 x 数量 + BigDecimal costs = buyPrice.multiply(num); + //计算租赁费用 + /*BigDecimal costs = BigDecimal.ZERO; + if (bean.getBuyPrice() != null && bean.getNum() != null){ + BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice()); + BigDecimal num = new BigDecimal(bean.getNum()); + costs = buyPrice.multiply(num); + }*/ + bean.setCosts(costs); + } + return loseList; + } + + private List getRelations(List leaseList, List repairList, + List scrapList, List loseList, + List list) { + List relations = new ArrayList<>(); + for (SltAgreementInfo info : list) { + SltAgreementRelation relation = new SltAgreementRelation(); + BigDecimal loseCost = BigDecimal.ZERO; + BigDecimal leaseCost = BigDecimal.ZERO; + BigDecimal scrapCost = BigDecimal.ZERO; + BigDecimal repairCost = BigDecimal.ZERO; + for (SltAgreementInfo lease : leaseList) { + if (lease.getAgreementId().equals(info.getAgreementId().toString())) { + relation.setAgreementId(String.valueOf(lease.getAgreementId())); + relation.setProjectName(lease.getProjectName()); + relation.setUnitName(lease.getUnitName()); + relation.setCompanyId(lease.getCompanyId()); + BigDecimal cost = lease.getCosts(); + leaseCost = leaseCost.add(cost); + } + } + for (SltAgreementInfo repair : repairList) { + if (repair.getAgreementId().equals(info.getAgreementId().toString())) { + BigDecimal cost = repair.getCosts(); + repairCost = repairCost.add(cost); + } + } + for (SltAgreementInfo scrap : scrapList) { + if (scrap.getAgreementId().equals(info.getAgreementId().toString())) { + BigDecimal cost = scrap.getCosts(); + scrapCost = scrapCost.add(cost); + } + } + for (SltAgreementInfo lose : loseList) { + if (lose.getAgreementId().equals(info.getAgreementId().toString())) { + //TODO 上面已经set过值,这里为什么还要set值 + relation.setAgreementId(String.valueOf(lose.getAgreementId())); + relation.setProjectName(lose.getProjectName()); + relation.setUnitName(lose.getUnitName()); + relation.setCompanyId(lose.getCompanyId()); + BigDecimal cost = lose.getCosts(); + loseCost = loseCost.add(cost); + } + } + relation.setLeaseCost(leaseCost); + relation.setRepairCost(repairCost); + relation.setScrapCost(scrapCost); + relation.setLoseCost(loseCost); + relations.add(relation); + } + return relations; + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskAgreementMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskAgreementMapper.java index a1720202..a0f9c3cb 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskAgreementMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskAgreementMapper.java @@ -1,7 +1,11 @@ package com.bonus.material.task.mapper; import java.util.List; + +import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.task.domain.TmTask; import com.bonus.material.task.domain.TmTaskAgreement; +import org.apache.ibatis.annotations.Param; /** * 任务Mapper接口 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskMapper.java index 0bbb8c7b..59c49258 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskMapper.java @@ -2,6 +2,8 @@ package com.bonus.material.task.mapper; import java.util.Date; import java.util.List; + +import com.bonus.material.settlement.domain.SltAgreementInfo; import com.bonus.material.task.domain.TmTask; import org.apache.ibatis.annotations.Param; @@ -86,4 +88,6 @@ public interface TmTaskMapper { */ String selectTaskNumByMonths(Date nowDate, Integer taskType); + List getTaskList(@Param("bean") SltAgreementInfo bean, @Param("taskType")Integer taskType); + } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml index 06ca0284..63f0bd0b 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml @@ -176,4 +176,114 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id,lease_type,create_time) values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},'0',#{record.companyId},#{record.leaseType},now()); + + + + + + + + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskMapper.xml index 7258090e..4a44a3ef 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskMapper.xml @@ -130,4 +130,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ORDER BY create_time DESC LIMIT 1 + \ No newline at end of file