diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java index d2e3b93e..c97fc192 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java @@ -18,6 +18,14 @@ public class SltAgreementApply { *协议id */ private String agreementId; + /** + * 项目名称 + */ + private String unitName; + /** + * 工程名称 + */ + private String projectName; /** *结算单号 */ @@ -29,7 +37,7 @@ public class SltAgreementApply { /** *创建时间 */ - private String create_time; + private String createTime; /** *审核人 */ @@ -37,20 +45,21 @@ public class SltAgreementApply { /** *审核时间 */ - private String audit_time; + private String audiTime; /** *状态0待审核1审核通过2审核驳回 */ private String status; + private String remark; /** *数据所属 */ - private String company_id; + private String companyId; /** *结算总费用 */ private String cost; - private List agreementIds; + private List relations; } diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementDetails.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementDetails.java index 4c41bce4..49054f44 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementDetails.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementDetails.java @@ -17,19 +17,19 @@ public class SltAgreementDetails { /** *申请id */ - private String apply_id; + private String applyId; /** *机具规格id */ - private String type_id; + private String typeId; /** *机具id */ - private String ma_id; + private String maId; /** *费用类型:1租赁2丢失3维修4报废 */ - private String slt_type; + private String sltType; /** *数量 */ @@ -37,11 +37,11 @@ public class SltAgreementDetails { /** *开始时间 */ - private String start_time; + private String startTime; /** *结束时间 */ - private String end_time; + private String endTime; /** *单价 */ @@ -53,6 +53,6 @@ public class SltAgreementDetails { /** *是否收费 */ - private String is_charge; + private String isCharge; } 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 fa9f2b03..879b846b 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 @@ -100,6 +100,11 @@ public class SltAgreementInfo { * (0自然,1人为) */ private String scrapType; + /** + * 费用类型:1租赁2丢失3维修4报废 + */ + private String sltType; + private String applyId; } 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 new file mode 100644 index 00000000..edb4ae98 --- /dev/null +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java @@ -0,0 +1,63 @@ +package com.bonus.sgzb.base.api.domain; + +import lombok.Data; + +import java.util.List; + +/** + * @author c liu + * @date 2024/2/21 + */ +@Data +public class SltAgreementRelation { + /** + * + */ + private Long id; + /** + *结算id + */ + private String applyId; + /** + *协议id + */ + private String agreementId; + /** + *增加费用 + */ + private String addCost; + /** + *减免费用 + */ + private String subCost; + /** + *增减原因 + */ + private String remark; + /** + *结算总费用 + */ + private String cost; + /** + *状态0待审核1审核通过2审核驳回 + */ + private String status; + + String loseCost; + String leaseCost; + String scrapCost; + String repairCost; + /** + * 项目名称 + */ + private String unitName; + /** + * 工程名称 + */ + private String projectName; + + /** + *数据所属 + */ + private String companyId; +} 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 1d0bf5c5..fdfc6822 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 @@ -26,9 +26,9 @@ public class SltInfoVo { * 丢失费用列表 */ List loseList; - String loseCost; - String leaseCost; - String scrapCost; - String repairCost; + + List relations; + + String cost; } diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml index 304c8a6e..a9eb290b 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml @@ -542,8 +542,8 @@ ) - insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,company_id) - values (#{info.agreementId},#{info.typeId},#{info.maId},#{many},#{info.startTime},#{info.status},#{info.leaseId},#{info.leasePrice},#{info.buyPrice},#{info.companyId}); + 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) + values (#{info.agreementId},#{info.typeId},#{info.maId},#{many},#{info.startTime},#{info.status},#{info.leaseId},#{info.leasePrice},#{info.buyPrice},'0',#{info.companyId}); diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml index f47690b3..1b08f78c 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml @@ -342,7 +342,7 @@ - insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,company_id) - values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},#{record.companyId}); + 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) + values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},'0',#{record.companyId}); \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java index f8e99880..6f079142 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java @@ -59,8 +59,40 @@ public class SltAgreementInfoController extends BaseController { @PostMapping("/submitFee") public AjaxResult submitFee(@RequestBody SltAgreementApply apply) { - AjaxResult res = service.submitFee(apply); - return res; + return service.submitFee(apply); + } + + /** + * 获取结算审核列表 + */ + @ApiOperation(value = "获取结算审核列表") + @GetMapping("/getSltExam") + public TableDataInfo getSltExam(AgreementInfo bean) + { + startPage(); + List list = service.getSltExam(bean); + return getDataTable(list); + } + + /** + * 获取结算审核清单 + */ + @ApiOperation(value = "获取结算审核清单") + @GetMapping("/getSltExamInfo") + public AjaxResult getSltExamInfo(SltAgreementApply apply) + { + SltInfoVo bean = service.getSltExamInfo(apply); + return AjaxResult.success(bean); + } + + /** + * 结算审核 + */ + @ApiOperation(value = "结算审核") + @GetMapping("/settlementReview") + public AjaxResult settlementReview(SltAgreementApply apply) + { + return toAjax(service.settlementReview(apply)); } } 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 1667e4d3..342f78da 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,6 +1,8 @@ package com.bonus.sgzb.material.mapper; +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.material.domain.AgreementInfo; import com.bonus.sgzb.material.domain.RepairTaskDetails; import com.bonus.sgzb.material.domain.ScrapApplyDetails; @@ -8,6 +10,7 @@ import com.bonus.sgzb.material.domain.TmTask; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.Date; import java.util.List; /** @@ -27,4 +30,26 @@ public interface SltAgreementInfoMapper { List getScrapDetailsList(@Param("taskList") List taskList); List getLoseList(AgreementInfo bean); + + int selectNumByDate(Date nowDate); + + int insApply(SltAgreementApply apply); + + int insRelation(SltAgreementRelation relation); + + int insDetails(SltAgreementInfo info); + + List getSltExam(AgreementInfo bean); + + List getRelations(SltAgreementApply apply); + + String getCost(SltAgreementApply apply); + + int updateInfoStatus(String agreementId); + + int updateRelation(SltAgreementApply apply); + + int updateApply(SltAgreementApply apply); + + } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SltAgreementInfoService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SltAgreementInfoService.java index aaf5c081..6d1f23ad 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SltAgreementInfoService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SltAgreementInfoService.java @@ -18,4 +18,10 @@ public interface SltAgreementInfoService { SltInfoVo getSltInfo(List list); AjaxResult submitFee(SltAgreementApply apply); + + List getSltExam(AgreementInfo bean); + + SltInfoVo getSltExamInfo(SltAgreementApply apply); + + int settlementReview(SltAgreementApply apply); } 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 b9762bcc..97bb84b0 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,19 +2,27 @@ package com.bonus.sgzb.material.service.impl; 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.common.core.exception.ServiceException; +import com.bonus.sgzb.common.core.utils.DateUtils; import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import com.bonus.sgzb.common.security.utils.SecurityUtils; import com.bonus.sgzb.material.domain.AgreementInfo; import com.bonus.sgzb.material.domain.RepairTaskDetails; import com.bonus.sgzb.material.domain.ScrapApplyDetails; import com.bonus.sgzb.material.domain.TmTask; import com.bonus.sgzb.material.mapper.SltAgreementInfoMapper; import com.bonus.sgzb.material.service.SltAgreementInfoService; +import com.bonus.sgzb.material.vo.GlobalContants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -42,23 +50,162 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { sltInfoVo.setRepairList(repairList); sltInfoVo.setScrapList(scrapList); sltInfoVo.setLoseList(loseList); + List relations = getRelations(leaseList,repairList,scrapList,loseList,list); + sltInfoVo.setRelations(relations); return sltInfoVo; } @Override - public AjaxResult submitFee(SltAgreementApply apply) { - List agreementIds = apply.getAgreementIds(); + public SltInfoVo getSltExamInfo(SltAgreementApply apply) { + SltInfoVo sltInfoVo = new SltInfoVo(); List list = new ArrayList<>(); - for (String agreementId : agreementIds){ + String cost = mapper.getCost(apply); + List relations = mapper.getRelations(apply); + sltInfoVo.setRelations(relations); + for (SltAgreementRelation relation : relations){ AgreementInfo info = new AgreementInfo(); - info.setAgreementId(Long.valueOf(agreementId)); + info.setAgreementId(Long.valueOf(relation.getAgreementId())); list.add(info); } - - - return null; + 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); + sltInfoVo.setCost(cost); + return sltInfoVo; } + @Override + @Transactional + public int settlementReview(SltAgreementApply apply) { + Long userid = SecurityUtils.getLoginUser().getUserid(); + apply.setAuditor(String.valueOf(userid)); + int i = mapper.updateRelation(apply); + int j = 0; + if (i > 0){ + j = mapper.updateApply(apply); + }else { + throw new ServiceException("结算审核失败"); + } + return j; + } + + private List getRelations(List leaseList, List repairList, List scrapList, List loseList, List list) { + List relations = new ArrayList<>(); + for (AgreementInfo info : list){ + SltAgreementRelation relation = new SltAgreementRelation(); + BigDecimal loseCost = new BigDecimal("0"); + BigDecimal leaseCost = new BigDecimal("0"); + BigDecimal scrapCost = new BigDecimal("0"); + BigDecimal repairCost = new BigDecimal("0"); + for (SltAgreementInfo lease : leaseList){ + if (lease.getAgreementId().equals(info.getAgreementId().toString())){ + relation.setAgreementId(lease.getAgreementId()); + relation.setProjectName(lease.getProjectName()); + relation.setUnitName(lease.getUnitName()); + relation.setCompanyId(lease.getCompanyId()); + BigDecimal cost = new BigDecimal(lease.getCosts()); + leaseCost = leaseCost.add(cost); + } + } + for (SltAgreementInfo repair : repairList){ + if (repair.getAgreementId().equals(info.getAgreementId().toString())){ + BigDecimal cost = new BigDecimal(repair.getCosts()); + repairCost = repairCost.add(cost); + } + } + for (SltAgreementInfo scrap : scrapList){ + if (scrap.getAgreementId().equals(info.getAgreementId().toString())){ + BigDecimal cost = new BigDecimal(scrap.getCosts()); + scrapCost = scrapCost.add(cost); + } + } + for (SltAgreementInfo lose : loseList){ + if (lose.getAgreementId().equals(info.getAgreementId().toString())){ + relation.setAgreementId(lose.getAgreementId()); + relation.setProjectName(lose.getProjectName()); + relation.setUnitName(lose.getUnitName()); + relation.setCompanyId(lose.getCompanyId()); + BigDecimal cost = new BigDecimal(lose.getCosts()); + loseCost = loseCost.add(cost); + } + } + relation.setLeaseCost(leaseCost.toString()); + relation.setRepairCost(repairCost.toString()); + relation.setScrapCost(scrapCost.toString()); + relation.setLoseCost(loseCost.toString()); + relations.add(relation); + } + return relations; + } + + @Override + @Transactional + public AjaxResult submitFee(SltAgreementApply apply) { + List relations = apply.getRelations(); + List list = new ArrayList<>(); + Long userid = SecurityUtils.getLoginUser().getUserid(); + String code = sltCodeRule("JS"); + apply.setCreator(String.valueOf(userid)); + apply.setCode(code); + apply.setCompanyId(relations.get(0).getCompanyId()); + int i = mapper.insApply(apply); + if (i > 0){ + for (SltAgreementRelation relation : relations){ + AgreementInfo info = new AgreementInfo(); + info.setAgreementId(Long.valueOf(relation.getAgreementId())); + list.add(info); + relation.setApplyId(String.valueOf(apply.getId())); + mapper.updateInfoStatus(relation.getAgreementId()); + int j = mapper.insRelation(relation); + if (j < 0){ + throw new ServiceException("新增协议结算记录失败"); + } + } + List leaseList = getLeaseList(list); + List repairList = getRepairList(list); + List scrapList = getScrapList(list); + List loseList = getLoseList(list); + for (SltAgreementInfo info : leaseList){ + info.setSltType("1"); + info.setApplyId(String.valueOf(apply.getId())); + info.setPartType("1"); + mapper.insDetails(info); + } + for (SltAgreementInfo info : repairList){ + info.setSltType("3"); + info.setApplyId(String.valueOf(apply.getId())); + mapper.insDetails(info); + } + for (SltAgreementInfo info : scrapList){ + info.setSltType("4"); + info.setApplyId(String.valueOf(apply.getId())); + info.setPartType(info.getScrapType()); + mapper.insDetails(info); + } + for (SltAgreementInfo info : loseList){ + info.setSltType("2"); + info.setApplyId(String.valueOf(apply.getId())); + info.setPartType("1"); + mapper.insDetails(info); + } + + }else { + throw new ServiceException("新增结算单号失败"); + } + return AjaxResult.success(); + } + + @Override + public List getSltExam(AgreementInfo bean) { + return mapper.getSltExam(bean); + } + + private List getLoseList(List list) { List loseList = new ArrayList<>(); for (AgreementInfo bean : list){ @@ -145,4 +292,21 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { } return leaseList; } + + /**结算单号编码生成规则*/ + private String sltCodeRule(String code) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + Date nowDate = DateUtils.getNowDate(); + String format = dateFormat.format(nowDate); + int taskNum = mapper.selectNumByDate(nowDate) + 1; + String codeNum = ""; + if (taskNum > GlobalContants.NUM1 && taskNum < GlobalContants.NUM2) { + codeNum = code + format + "-00" + taskNum; + } else if (taskNum > GlobalContants.NUM3 && taskNum < GlobalContants.NUM4) { + codeNum = code + format + "-0" + taskNum; + } else { + codeNum = code + format + "-000" + taskNum; + } + return codeNum; + } } 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 2ea18fcb..e61e804d 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 @@ -26,7 +26,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + insert into slt_agreement_apply (code,creator,create_time,status,company_id,cost) + values (#{code},#{creator},now(),'0',#{companyId},#{cost}); + + + insert into slt_agreement_relation (apply_id,agreement_id,add_cost,sub_cost,remark,cost,status) + values (#{applyId},#{agreementId},#{addCost},#{subCost},#{remark},#{cost},'0'); + + + insert into slt_agreement_details + + apply_id, + type_id, + ma_id, + slt_type, + num, + start_time, + end_time, + price, + money, + is_charge, + + + #{applyId}, + #{typeId}, + #{maId}, + #{sltType}, + #{num}, + #{startTime}, + #{endTime}, + #{leasePrice}, + #{costs}, + #{partType}, + + + + update slt_agreement_info + set is_slt = '1', + slt_time = now() + where agreement_id = #{agreementId} + + + update slt_agreement_relation + set status = #{status} + where apply_id = #{id} + + + update slt_agreement_apply + set status = #{status}, + auditor = #{auditor}, + audit_time = now(), + remark = #{remark} + where id = #{id} + - + + + + \ No newline at end of file