From 91426aaa7d2827f91cc4aba584f26bb2ba017aee Mon Sep 17 00:00:00 2001 From: mashuai Date: Tue, 15 Jul 2025 16:46:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=90=E6=96=99=E7=AB=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ClzSltAgreementInfoController.java | 144 +++++++ .../sltAgreementInfo/MaterialSltInfoVo.java | 127 +++++++ .../clz/mapper/ClzSltAgreementInfoMapper.java | 86 +++++ .../service/ClzSltAgreementInfoService.java | 34 ++ .../impl/ClzSltAgreementInfoServiceImpl.java | 352 ++++++++++++++++++ .../material/clz/ClzAgreementInfoMapper.xml | 176 +++++++++ 6 files changed, 919 insertions(+) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/sltAgreementInfo/MaterialSltInfoVo.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java create mode 100644 bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java new file mode 100644 index 00000000..cf3c06b7 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java @@ -0,0 +1,144 @@ +package com.bonus.material.clz.controller; + +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; +import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; +import com.bonus.material.clz.service.ClzSltAgreementInfoService; +import com.bonus.material.settlement.domain.SltAgreementReduce; +import com.bonus.material.settlement.domain.SltAgreementRelation; +import com.bonus.material.task.domain.TmTask; +import com.bonus.material.task.mapper.TmTaskMapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @Author ma_sh + * @create 2025/6/27 15:18 + */ +@Api(tags = "材料站结算申请接口") +@RestController +@RequestMapping("/material_sltAgreementInfo") +@Slf4j +public class ClzSltAgreementInfoController extends BaseController { + + @Resource + private ClzSltAgreementInfoService clzSltAgreementInfoService; + + @Resource + private TmTaskMapper taskMapper; + + /** + * 根据条件获取协议结算列表 + */ + @ApiOperation(value = "根据条件获取协议结算列表") + @GetMapping("/getSltAgreementInfo4Project") + public TableDataInfo getSltAgreementInfo4Project(MaterialSltAgreementInfo bean) { + startPage(); + List list = clzSltAgreementInfoService.getSltAgreementInfo4Project(bean); + return getDataTable(list); + } + + @ApiOperation(value = "根据协议获取结算清单") + @PostMapping("/getSltInfo") + public AjaxResult getSltInfo(@RequestBody List list) { + List unitNames = new ArrayList<>(); + List projectNames = new ArrayList<>(); + List dataList = new ArrayList<>(); + MaterialSltInfoVo bean = new MaterialSltInfoVo(); + Long agreementId = null; + for (MaterialSltAgreementInfo info : list) { + unitNames.add(info.getUnitName()); + projectNames.add(info.getProjectName()); + MaterialSltInfoVo vo = clzSltAgreementInfoService.getSltInfo(info); + dataList.add(vo); + agreementId = info.getAgreementId(); + } + bean = mergerData(bean, dataList,unitNames,projectNames); + // 根据协议id获取申请时间 + TmTask tmTask = taskMapper.selectTaskByIdByCl(agreementId); + if (tmTask != null) { + bean.setApplyTime(tmTask.getCreateTime()); + } + return AjaxResult.success(bean); + } + + public MaterialSltInfoVo mergerData(MaterialSltInfoVo vo,List list,List unitNames,List projectNames){ + vo.setUnitName(handleData(unitNames)); + vo.setProjectName(handleData(projectNames)); + BigDecimal leaseCost = BigDecimal.valueOf(0.00); + BigDecimal repairCost = BigDecimal.valueOf(0.00); + BigDecimal scrapCost = BigDecimal.valueOf(0.00); + BigDecimal loseCost = BigDecimal.valueOf(0.00); + BigDecimal reducCost = BigDecimal.valueOf(0.00); + //租赁费用列表 + List leaseList = new ArrayList<>(); + //维修费用列表 + List repairList = new ArrayList<>(); + //报废费用列表 + List scrapList = new ArrayList<>(); + //丢失费用列表 + List loseList = new ArrayList<>(); + //减免费用列表 + List reductionList = new ArrayList<>(); + List relations = new ArrayList<>(); + for (MaterialSltInfoVo infoVo : list) { + leaseCost = leaseCost.add(infoVo.getLeaseCost()); + repairCost = repairCost.add(infoVo.getRepairCost()); + scrapCost = scrapCost.add(infoVo.getScrapCost()); + loseCost = loseCost.add(infoVo.getLoseCost()); + reducCost = reducCost.add(infoVo.getReductionCost()); + leaseList.addAll(infoVo.getLeaseList()); + repairList.addAll(infoVo.getRepairList()); + scrapList.addAll(infoVo.getScrapList()); + loseList.addAll(infoVo.getLoseList()); + reductionList.addAll(infoVo.getReductionList()); + relations.addAll(infoVo.getRelations()); + } + vo.setLeaseList(leaseList); + vo.setRepairList(repairList); + vo.setScrapList(scrapList); + vo.setLoseList(loseList); + vo.setReductionList(reductionList); + vo.setLeaseCost(leaseCost); + vo.setRepairCost(repairCost); + vo.setScrapCost(scrapCost); + vo.setLoseCost(loseCost); + vo.setReductionCost(reducCost); + vo.setRelations(relations); + return vo; + } + + public String handleData(List list){ + StringBuilder sb = new StringBuilder(); + Set set = new HashSet<>(list); + for (String str : set) { + sb.append(str).append("、"); + } + return StringUtils.removeEnd(sb.toString(), "、"); + } + + /** + * 提交结算清单 + */ + @ApiOperation(value = "提交结算清单") + @PostMapping("/submitCosts") + public AjaxResult submitCosts(@RequestBody MaterialSltInfoVo sltInfoVo) { + try { + return toAjax(clzSltAgreementInfoService.submitCosts(sltInfoVo)); + } catch (Exception e) { + return error("系统错误, " + e.getMessage()); + } + } +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/sltAgreementInfo/MaterialSltInfoVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/sltAgreementInfo/MaterialSltInfoVo.java new file mode 100644 index 00000000..8ec3a40c --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/sltAgreementInfo/MaterialSltInfoVo.java @@ -0,0 +1,127 @@ +package com.bonus.material.clz.domain.vo.sltAgreementInfo; + +import com.bonus.common.core.annotation.Excel; +import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; +import com.bonus.material.settlement.domain.SltAgreementReduce; +import com.bonus.material.settlement.domain.SltAgreementRelation; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author c liu + * @date 2024/2/23 + */ +@Data +public class MaterialSltInfoVo { + + /** + * 结算单位 + */ + private String unitName; + /** + * 结算工程 + */ + private String projectName; + /** + * 租赁费用列表 + */ + List leaseList; + /** + * 维修费用列表 + */ + List repairList; + /** + * 报废费用列表 + */ + List scrapList; + /** + * 丢失费用列表 + */ + List loseList; + + /** + * 减免费用列表 + */ + List reductionList; + + List relations; + + /** + * 租赁费用小计 + */ + @ApiModelProperty(value = "租赁费用小计") + private BigDecimal leaseCost; + + /** + * 维修费用小计 + */ + @ApiModelProperty(value = "维修费用小计") + private BigDecimal repairCost; + + /** + * 报废费用小计 + */ + @ApiModelProperty(value = "报废费用小计") + private BigDecimal scrapCost; + + /** + * 丢失费用小计 + */ + @ApiModelProperty(value = "丢失费用小计") + private BigDecimal loseCost; + + /** + * 减免费用小计 + */ + @ApiModelProperty(value = "减免费用小计") + private BigDecimal reductionCost; + + /** + * 合计 + */ + @ApiModelProperty(value = "合计") + private BigDecimal totalCostAll; + + @Excel(name = "创建人") + private String createBy; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + private String updateBy; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + /** 协议id */ + + @ApiModelProperty(value = "协议id") + private Long agreementId; + + /** + * 协议编号 + */ + + @ApiModelProperty(value = "协议编号") + private String agreementCode; + + /** 协议 ids */ + + @ApiModelProperty(value = "协议ids") + private Long[] agreementIds; + + private Long id; //申请id + + String cost; + + @ApiModelProperty(value = "申请时间") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date applyTime; + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java new file mode 100644 index 00000000..cbab6cb9 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java @@ -0,0 +1,86 @@ +package com.bonus.material.clz.mapper; + +import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; +import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; +import com.bonus.material.settlement.domain.SltAgreementReduce; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author ma_sh + * @create 2025/6/27 15:21 + */ +public interface ClzSltAgreementInfoMapper { + + /** + * 获取协议结算列表 + * @param bean + * @return + */ + List getSltAgreementInfo4Project(MaterialSltAgreementInfo bean); + + /** + * 获取租赁列表 + * @param info + * @return + */ + List getLeaseList(MaterialSltAgreementInfo info); + + /** + * 获取丢失列表 + * @param info + * @return + */ + List getLoseList(MaterialSltAgreementInfo info); + + /** + * 获取减免费用列表 + * @param bean + * @return + */ + List getReductionList(SltAgreementReduce bean); + + /** + * 获取驳回数量 + * @param sltInfoVo + * @return + */ + int getRejectCount(MaterialSltInfoVo sltInfoVo); + + /** + * 获取驳回id + * @param sltInfoVo + * @return + */ + Long getRejectId(MaterialSltInfoVo sltInfoVo); + + /** + * 更新驳回数量 + * @param sltInfoVo + * @return + */ + int updateRejectCount(MaterialSltInfoVo sltInfoVo); + + /** + * 插入协议申请 + * @param sltInfoVo + * @return + */ + int insertSltAgreementApply(MaterialSltInfoVo sltInfoVo); + + /** + * 插入协议申请详情 + * @param list + * @param id + */ + int insertSltAgreementDetailLease(@Param("list") List list, @Param("id") Long id); + + /** + * 插入协议申请详情 + * @param list + * @param id + * @return + */ + int insertSltAgreementDetailLose(@Param("list") List list, @Param("id") Long id); +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java new file mode 100644 index 00000000..f33c8eea --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java @@ -0,0 +1,34 @@ +package com.bonus.material.clz.service; + +import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; +import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; + +import java.util.List; + +/** + * @Author ma_sh + * @create 2025/6/27 15:20 + */ +public interface ClzSltAgreementInfoService { + + /** + * 根据条件获取协议结算列表 + * @param bean + * @return + */ + List getSltAgreementInfo4Project(MaterialSltAgreementInfo bean); + + /** + * 获取结算清单 + * @param info + * @return + */ + MaterialSltInfoVo getSltInfo(MaterialSltAgreementInfo info); + + /** + * 提交结算清单 + * @param sltInfoVo + * @return + */ + int submitCosts(MaterialSltInfoVo sltInfoVo); +} 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 new file mode 100644 index 00000000..d4d8389c --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java @@ -0,0 +1,352 @@ +package com.bonus.material.clz.service.impl; + +import com.bonus.common.core.exception.ServiceException; +import com.bonus.common.core.utils.DateUtils; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; +import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; +import com.bonus.material.clz.mapper.ClzSltAgreementInfoMapper; +import com.bonus.material.clz.service.ClzSltAgreementInfoService; +import com.bonus.material.settlement.domain.SltAgreementReduce; +import com.bonus.material.settlement.domain.SltAgreementRelation; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @Author ma_sh + * @create 2025/6/27 15:20 + */ +@Service +public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoService { + + @Resource + private ClzSltAgreementInfoMapper clzSltAgreementInfoMapper; + + /** + * 根据条件获取协议结算列表 + * @param bean + * @return + */ + @Override + public List getSltAgreementInfo4Project(MaterialSltAgreementInfo bean) { + return clzSltAgreementInfoMapper.getSltAgreementInfo4Project(bean); + } + + /** + * 获取结算清单 + * @param info + * @return + */ + @Override + public MaterialSltInfoVo getSltInfo(MaterialSltAgreementInfo info) { + MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo(); + sltInfoVo.setUnitName(info.getUnitName()); + sltInfoVo.setProjectName(info.getProjectName()); + BigDecimal leaseCost = BigDecimal.valueOf(0.00); + BigDecimal repairCost = BigDecimal.valueOf(0.00); + BigDecimal scrapCost = BigDecimal.valueOf(0.00); + BigDecimal loseCost = BigDecimal.valueOf(0.00); + BigDecimal reducCost = BigDecimal.valueOf(0.00); + //租赁费用列表 + List leaseList = getLeaseList(info); + //维修费用列表 + List repairList = new ArrayList<>(); + //报废费用列表 + List scrapList = new ArrayList<>(); + //丢失费用列表 + List loseList = getLoseList(info); + + List reductionList = getReductionList(info); + sltInfoVo.setLeaseList(leaseList); + sltInfoVo.setRepairList(repairList); + sltInfoVo.setScrapList(scrapList); + sltInfoVo.setLoseList(loseList); + sltInfoVo.setReductionList(reductionList); + for (MaterialSltAgreementInfo lease : leaseList) { + if(lease.getCosts()!=null){ + leaseCost = leaseCost.add(lease.getCosts()); + } + } + /*for (MaterialSltAgreementInfo repair : repairList) { + if(repair.getCosts()!=null && (repair.getPartType().equals("收费"))){ + repairCost = repairCost.add(repair.getCosts()); + } + } + for (MaterialSltAgreementInfo scrap : scrapList) { + if(scrap.getCosts()!=null && (scrap.getPartType().equals("收费"))){ + scrapCost = scrapCost.add(scrap.getCosts()); + } + }*/ + for (MaterialSltAgreementInfo lose : loseList) { + if(lose.getCosts()!=null){ + loseCost = loseCost.add(lose.getCosts()); + } + } + for (SltAgreementReduce reduction : reductionList) { + if(reduction.getReduceLeaseMoney()!=null){ + reducCost = reducCost.add(reduction.getReduceLeaseMoney()); + } + } + sltInfoVo.setLeaseCost(leaseCost); + sltInfoVo.setRepairCost(repairCost); + sltInfoVo.setScrapCost(scrapCost); + sltInfoVo.setLoseCost(loseCost); + sltInfoVo.setReductionCost(reducCost); + List relations = getRelations(leaseList, repairList, scrapList, loseList, info); + sltInfoVo.setRelations(relations); + return sltInfoVo; + } + + /** + * 提交结算清单 + * @param sltInfoVo + * @return + */ + @Override + public int submitCosts(MaterialSltInfoVo sltInfoVo) { + try { + if(sltInfoVo.getAgreementIds()!=null) { + + for (Long agreementId : sltInfoVo.getAgreementIds()) { + Long id = null; + sltInfoVo.setAgreementId(agreementId); + // 计算总成本 + BigDecimal totalCost = BigDecimal.ZERO; + MaterialSltAgreementInfo info = new MaterialSltAgreementInfo(); + info.setAgreementId(agreementId); + + // 获取各项成本并累加 + totalCost = totalCost.add(getLeaseList(info).stream() + .map(MaterialSltAgreementInfo::getCosts) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add)); + + /*totalCost = totalCost.add(getRepairList(info).stream() + .map(SltAgreementInfo::getCosts) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add)); + + totalCost = totalCost.add(getScrapList(info).stream() + .map(SltAgreementInfo::getCosts) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add));*/ + + totalCost = totalCost.add(getLoseList(info).stream() + .map(MaterialSltAgreementInfo::getCosts) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add)); + + totalCost = totalCost.subtract(getReductionList(info).stream() + .map(SltAgreementReduce::getLeaseMoney) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add)); + + // 设置总成本 + sltInfoVo.setTotalCostAll(totalCost); + //查找是否驳回 + int countReject = clzSltAgreementInfoMapper.getRejectCount(sltInfoVo); + if (countReject > 0) { + id = clzSltAgreementInfoMapper.getRejectId(sltInfoVo); + //修改 + int countAgain = clzSltAgreementInfoMapper.updateRejectCount(sltInfoVo); + if (countAgain == 0) { + throw new ServiceException("slt_agreement_apply修改失败"); + } + sltInfoVo.setUpdateTime(DateUtils.getNowDate()); + sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid())); + /*int countTwo = clzSltAgreementInfoMapper.updateBmAgreementStatus(sltInfoVo); + if (countTwo != 1) { + throw new ServiceException("bm_agreement_info修改失败"); + }*/ + } else { + sltInfoVo.setCreateTime(DateUtils.getNowDate()); + sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid())); + //新增 + int countOne = clzSltAgreementInfoMapper.insertSltAgreementApply(sltInfoVo); + if (countOne != 1) { + throw new ServiceException("slt_agreement_apply新增失败"); + } + // 插入成功后,sltInfoVo 的 id 属性将被自动设置为新生成的主键值 + id = sltInfoVo.getId(); + sltInfoVo.setUpdateTime(DateUtils.getNowDate()); + /*int countTwo = clzSltAgreementInfoMapper.updateBmAgreementStatus(sltInfoVo); + if (countTwo != 1) { + throw new ServiceException("bm_agreement_info修改失败"); + }*/ + } + if (sltInfoVo.getLeaseList().size() > 0) { + List filteredLeaseList = sltInfoVo.getLeaseList().stream() + .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) + .collect(Collectors.toList()); + if (!filteredLeaseList.isEmpty()) { + clzSltAgreementInfoMapper.insertSltAgreementDetailLease(filteredLeaseList, id); + } + } + /*if (sltInfoVo.getRepairList().size() > 0) { + List filteredRepairList = sltInfoVo.getRepairList().stream() + .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) + .collect(Collectors.toList()); + if (!filteredRepairList.isEmpty()) { + clzSltAgreementInfoMapper.insertSltAgreementDetailRepair(filteredRepairList, id); + } + } + if (sltInfoVo.getScrapList().size() > 0) { + List filteredScrapList = sltInfoVo.getScrapList().stream() + .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) + .collect(Collectors.toList()); + if (!filteredScrapList.isEmpty()) { + clzSltAgreementInfoMapper.insertSltAgreementDetailScrap(filteredScrapList, id); + } + }*/ + if (sltInfoVo.getLoseList().size() > 0) { + List filteredLoseList = sltInfoVo.getLoseList().stream() + .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) + .collect(Collectors.toList()); + if (!filteredLoseList.isEmpty()) { + clzSltAgreementInfoMapper.insertSltAgreementDetailLose(filteredLoseList, id); + } + } + } + } + return 1; + } catch (Exception e) { + throw new ServiceException("错误信息描述"); + } + } + + /** + * 获取结算关系列表 + * @param leaseList + * @param repairList + * @param scrapList + * @param loseList + * @param sltInfo + * @return + */ + private List getRelations(List leaseList, List repairList, List scrapList, List loseList, MaterialSltAgreementInfo sltInfo) { + 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 (MaterialSltAgreementInfo lease : leaseList) { + if (lease.getAgreementId().equals(sltInfo.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 (MaterialSltAgreementInfo repair : repairList) { + if (repair.getAgreementId().equals(sltInfo.getAgreementId().toString())) { + BigDecimal cost = repair.getCosts(); + repairCost = repairCost.add(cost); + } + } + for (MaterialSltAgreementInfo scrap : scrapList) { + if (scrap.getAgreementId().equals(sltInfo.getAgreementId().toString())) { + BigDecimal cost = scrap.getCosts(); + scrapCost = scrapCost.add(cost); + } + } + for (MaterialSltAgreementInfo lose : loseList) { + if (lose.getAgreementId().equals(sltInfo.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; + } + + /** + * 获取减免费用列表 + * @param info + * @return + */ + private List getReductionList(MaterialSltAgreementInfo info) { + SltAgreementReduce bean =new SltAgreementReduce(); + bean.setAgreementId(info.getAgreementId()); + return clzSltAgreementInfoMapper.getReductionList(bean); + } + + /** + * 获取丢失费用列表 + * @param info + * @return + */ + private List getLoseList(MaterialSltAgreementInfo info) { + List loseList = new ArrayList<>(); + + List oneOfList = clzSltAgreementInfoMapper.getLoseList(info); + loseList.addAll(oneOfList); + + for (MaterialSltAgreementInfo bean : loseList) { + if (null == bean.getBuyPrice()) { + bean.setBuyPrice(BigDecimal.valueOf(0.00)); + } + if (null == bean.getNum()) { + bean.setNum(BigDecimal.valueOf(0L)); + } + BigDecimal buyPrice = bean.getBuyPrice(); + BigDecimal num = bean.getNum(); + // 原价 x 数量 + BigDecimal costs = buyPrice.multiply(num); + //计算租赁费用 + bean.setCosts(costs); + } + return loseList; + } + + /** + * 获取租赁费用列表 + * @param info + * @return + */ + private List getLeaseList(MaterialSltAgreementInfo info) { + List leaseList = new ArrayList<>(); + + List oneOfList = clzSltAgreementInfoMapper.getLeaseList(info); + leaseList.addAll(oneOfList); + + for (MaterialSltAgreementInfo bean : leaseList) { + if (null == bean.getLeasePrice()) { + bean.setLeasePrice(BigDecimal.valueOf(0.00)); + }else{ + bean.setLeasePrice(bean.getLeasePrice().setScale(2, BigDecimal.ROUND_HALF_UP)); + } + if (null == bean.getNum()) { + bean.setNum(BigDecimal.valueOf(0L)); + } + if (null == bean.getLeaseDays()) { + bean.setLeaseDay(0L); + } + BigDecimal leasePrice = bean.getLeasePrice(); + BigDecimal num = bean.getNum(); + BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); + BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(2, BigDecimal.ROUND_HALF_UP); + bean.setCosts(costs); + } + return leaseList; + } +} 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 new file mode 100644 index 00000000..3a447bb5 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml @@ -0,0 +1,176 @@ + + + + + insert into clz_slt_agreement_apply + + agreement_id, + code, + creator, + create_time, + status, + cost, + + + #{agreementId}, + #{agreementCode}, + #{createBy}, + #{createTime}, + 1, + #{totalCostAll}, + + + + + insert into clz_slt_agreement_details (apply_id, type_id,ma_id,slt_type,num,start_time,end_time,price,money) + values + + (#{id}, #{item.typeId}, #{item.maId},1,#{item.num},#{item.startTime},#{item.endTime},#{item.leasePrice},#{item.costs}) + + + + + insert into clz_slt_agreement_details (apply_id, type_id,ma_id,slt_type,num,money) + values + + (#{id}, #{item.typeId}, #{item.maId},2,#{item.num},#{item.costs}) + + + + + update clz_slt_agreement_apply + set status = '1', + update_time = now(), + audit_Time = null, + auditor = null, + remark = null, + cost = #{totalCostAll} + where agreement_id = #{agreementId} + + + + + + + + + + + + + + \ No newline at end of file