From 4a71b8e6348ebd13ba0edf0f0a9d8000722bd0bb Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Mon, 29 Jul 2024 18:27:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E7=AE=97=E7=AE=A1=E7=90=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgzb/base/api/domain/LeaseOutDetails.java | 2 + .../base/api/domain/SltAgreementInfo.java | 18 ++ .../base/api/domain/SltAgreementRelation.java | 3 +- .../bonus/sgzb/base/api/domain/SltInfoVo.java | 5 +- .../com/bonus/sgzb/app/domain/TmTask.java | 1 + .../app/mapper/LeaseOutDetailsMapper.java | 4 + .../impl/LeaseOutDetailsServiceImpl.java | 4 + .../base/controller/MaPartTypeController.java | 7 +- .../mapper/app/LeaseOutDetailsMapper.xml | 25 +- .../resources/mapper/app/TmTaskMapper.xml | 1 + .../SltAgreementInfoController.java | 60 ++--- .../mapper/SltAgreementInfoMapper.java | 4 + .../service/SltAgreementInfoService.java | 5 +- .../impl/SltAgreementInfoServiceImpl.java | 246 +++++++++++++----- .../mapper/material/BackApplyMapper.xml | 2 +- .../material/SltAgreementInfoMapper.xml | 64 ++++- 16 files changed, 336 insertions(+), 115 deletions(-) diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java index 83663a78..97c5b8eb 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java @@ -157,5 +157,7 @@ public class LeaseOutDetails implements Serializable { private Integer manageType; @ApiModelProperty(value = "数量出库-出库数量") private Integer inputNum; + @ApiModelProperty(value = "0工程1长期") + private String leaseType; } \ No newline at end of file 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 168f4828..98cfbd6e 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 @@ -2,6 +2,8 @@ package com.bonus.sgzb.base.api.domain; import lombok.Data; +import java.math.BigDecimal; + /** * @author c liu * @date 2024/2/21 @@ -100,6 +102,10 @@ public class SltAgreementInfo { * 租赁费用 */ private String costs; + /** + * 真实租赁费用 + */ + private String realCosts; /** * 类型(0不收费,1收费) */ @@ -118,6 +124,18 @@ public class SltAgreementInfo { private String sltType; private String applyId; private String keyWord; + /** + * 费用承担方 + */ + private String costBearingParty; + /** + * 调整天数 + */ + private Integer trimDay; + /** + * 实际结算天数 + */ + private BigDecimal realDays; } 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 edb4ae98..a00a6316 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 @@ -44,7 +44,8 @@ public class SltAgreementRelation { private String status; String loseCost; - String leaseCost; + String leaseCostOne; + String leaseCostThree; String scrapCost; String repairCost; /** 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 fdfc6822..5a47bd85 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 @@ -11,9 +11,10 @@ import java.util.List; @Data public class SltInfoVo { /** - * 租赁费用列表 + * 租赁费用列表(01、03) */ - List leaseList; + List leaseListOne; + List leaseListThree; /** * 维修费用列表 */ diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/TmTask.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/TmTask.java index bead4480..cc1ea70f 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/TmTask.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/TmTask.java @@ -261,6 +261,7 @@ public class TmTask implements Serializable { private String manageType; private String maCode; private String maId; + private String status; private String maStatus; private String typeId; private Double partNum; diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java index 6dceec1d..a509fdaa 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java @@ -103,4 +103,8 @@ public interface LeaseOutDetailsMapper { int getmaChineByCt(LeaseOutDetails record); void updateMaTypeNum(LeaseApplyDetails leaseApplyDetails); + + LeaseApplyDetails getLeaseApplyDetails(@Param("record") LeaseOutDetails record); + + int updateLeaseApplyDetails(@Param("record") LeaseOutDetails record); } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java index cc533638..e7ee66dd 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java @@ -198,6 +198,10 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { int res = 0; // 首先更新领料任务详情表的领料数及状态(lease_apply_details) res = leaseOutDetailsMapper.updateLeaseApplyDetailsOutNum(record); + LeaseApplyDetails leaseApplyDetails = leaseOutDetailsMapper.getLeaseApplyDetails(record); + if (leaseApplyDetails.getPreNum().equals(leaseApplyDetails.getAlNum()) || leaseApplyDetails.getAuditNum().equals(leaseApplyDetails.getAlNum())) { + leaseOutDetailsMapper.updateLeaseApplyDetails(record); + } if (res > 0) { // 插入领料出库明细表(lease_out_details) res = leaseOutDetailsMapper.insertSelective(record); diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaPartTypeController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaPartTypeController.java index 9a175038..45ecd384 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaPartTypeController.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaPartTypeController.java @@ -14,13 +14,10 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.multipart.MultipartFile; +import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; @@ -43,7 +40,7 @@ public class MaPartTypeController extends BaseController { @Autowired private IPartTypeService maPartTypeService; - @Autowired + @Resource private ExcelService excelService; private static final String UPLOAD_DIR = "D:/work/wcy"; 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 fd1ad9dd..14eddf4d 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 @@ -186,7 +186,7 @@ update_by = #{record.updateBy}, update_time = now(), - status = '2' + status = '1' WHERE parennt_id = #{record.parentId} and type_id = #{record.typeId} @@ -315,6 +315,14 @@ WHERE type_id = #{typeId} + + UPDATE + lease_apply_details + SET + status = '2' + WHERE + parennt_id = #{record.parentId} and type_id = #{record.typeId} + insert into tm_task_agreement @@ -362,8 +370,8 @@ - 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}); + 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) + values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},'0',#{record.companyId},#{record.leaseType}); select num from ma_type WHERE type_id = #{typeId} + \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml index 7c8c11ff..eb028e92 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml @@ -1044,6 +1044,7 @@ lad.parennt_id as parentId, lad.pre_num - ifnull(lad.al_num,0) as outNum, lad.pre_num as preCountNum, + lad.status as status, ifnull(lad.al_num,0) as alNum, mt2.type_name as typeName, mt.type_name as typeModelName, 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 433035f4..7b3278aa 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 @@ -42,22 +42,12 @@ public class SltAgreementInfoController extends BaseController { @GetMapping("/getSltAgreementInfo") public TableDataInfo getSltAgreementInfo(AgreementInfo bean) { startPage(); - List list = new ArrayList<>(); - //逻辑需要确认,当往来单位id,工程标段ID,结算状态为空时是否返回异常,如果返回异常前端配合改造 - if (bean.getUnitId() == null && bean.getProjectId() == null && bean.getSltStatus()== null){ - - }else { - list = sltAgreementInfoService.getSltAgreementInfo(bean); - } - //上面代码可以改造为 - /*if(bean.getUnitId() != null || bean.getProjectId() != null || bean.getSltStatus()!= null){ - list = sltAgreementInfoService.getSltAgreementInfo(bean); - }*/ + List list = sltAgreementInfoService.getSltAgreementInfo(bean); return getDataTable(list); } /** - * 根据协议获取结算清单 + * 根据协议获取完工结算清单 */ @ApiOperation(value = "根据协议获取结算清单") @PostMapping("/getSltInfo") @@ -66,15 +56,27 @@ public class SltAgreementInfoController extends BaseController { return AjaxResult.success(bean); } + /** + * 调整天数 + */ + @ApiOperation(value = "调整天数") + @PostMapping("/updateTrimDay") + public AjaxResult updateTrimDay(@RequestBody List sltAgreementInfo) { + int bean = sltAgreementInfoService.updateTrimDay(sltAgreementInfo); + if (bean == 0){ + return AjaxResult.error("修改失败"); + } + return AjaxResult.success("修改成功"); + } + /** * 租赁明细导出 */ @Log(title = "租赁明细导出", businessType = BusinessType.EXPORT) @PostMapping("/exportLease") - public void exportLease(HttpServletResponse response,@RequestBody List list) - { + public void exportLease(HttpServletResponse response, @RequestBody List list) { List explist = sltAgreementInfoService.getLeaseList(list); - List leaseInfoList = Convert.toList(LeaseInfo.class,explist); + List leaseInfoList = Convert.toList(LeaseInfo.class, explist); ExcelUtil util = new ExcelUtil(LeaseInfo.class); util.exportExcel(response, leaseInfoList, "租赁明细导出"); } @@ -84,10 +86,9 @@ public class SltAgreementInfoController extends BaseController { */ @Log(title = "丢失明细导出", businessType = BusinessType.EXPORT) @PostMapping("/exportLose") - public void exportLose(HttpServletResponse response,@RequestBody List list) - { + public void exportLose(HttpServletResponse response, @RequestBody List list) { List explist = sltAgreementInfoService.getLoseList(list); - List leaseInfoList = Convert.toList(LoseInfo.class,explist); + List leaseInfoList = Convert.toList(LoseInfo.class, explist); ExcelUtil util = new ExcelUtil(LoseInfo.class); util.exportExcel(response, leaseInfoList, "丢失明细导出"); } @@ -97,10 +98,9 @@ public class SltAgreementInfoController extends BaseController { */ @Log(title = "维修明细导出", businessType = BusinessType.EXPORT) @PostMapping("/exportRepair") - public void exportRepair(HttpServletResponse response,@RequestBody List list) - { + public void exportRepair(HttpServletResponse response, @RequestBody List list) { List explist = sltAgreementInfoService.getRepairList(list); - List leaseInfoList = Convert.toList(LeaseInfo.class,explist); + List leaseInfoList = Convert.toList(LeaseInfo.class, explist); ExcelUtil util = new ExcelUtil(LeaseInfo.class); util.exportExcel(response, leaseInfoList, "维修明细导出"); } @@ -110,10 +110,9 @@ public class SltAgreementInfoController extends BaseController { */ @Log(title = "报废明细导出", businessType = BusinessType.EXPORT) @PostMapping("/exportScrap") - public void exportScrap(HttpServletResponse response,@RequestBody List list) - { + public void exportScrap(HttpServletResponse response, @RequestBody List list) { List explist = sltAgreementInfoService.getScrapList(list); - List leaseInfoList = Convert.toList(ScrapInfo.class,explist); + List leaseInfoList = Convert.toList(ScrapInfo.class, explist); ExcelUtil util = new ExcelUtil(ScrapInfo.class); util.exportExcel(response, leaseInfoList, "维修明细导出"); } @@ -123,8 +122,7 @@ public class SltAgreementInfoController extends BaseController { */ @ApiOperation(value = "费用结算提交") @PostMapping("/submitFee") - public AjaxResult submitFee(@RequestBody SltAgreementApply apply) - { + public AjaxResult submitFee(@RequestBody SltAgreementApply apply) { return sltAgreementInfoService.submitFee(apply); } @@ -133,8 +131,7 @@ public class SltAgreementInfoController extends BaseController { */ @ApiOperation(value = "获取结算审核列表") @GetMapping("/getSltExam") - public TableDataInfo getSltExam(AgreementInfo bean) - { + public TableDataInfo getSltExam(AgreementInfo bean) { startPage(); List list = sltAgreementInfoService.getSltExam(bean); return getDataTable(list); @@ -145,8 +142,7 @@ public class SltAgreementInfoController extends BaseController { */ @ApiOperation(value = "获取结算审核清单") @GetMapping("/getSltExamInfo") - public AjaxResult getSltExamInfo(SltAgreementApply apply) - { + public AjaxResult getSltExamInfo(SltAgreementApply apply) { SltInfoVo bean = sltAgreementInfoService.getSltExamInfo(apply); return AjaxResult.success(bean); } @@ -156,11 +152,9 @@ public class SltAgreementInfoController extends BaseController { */ @ApiOperation(value = "结算审核") @GetMapping("/settlementReview") - public AjaxResult settlementReview(SltAgreementApply apply) - { + public AjaxResult settlementReview(SltAgreementApply apply) { return toAjax(sltAgreementInfoService.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 598e2a8c..037e04f6 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 @@ -20,6 +20,8 @@ public interface SltAgreementInfoMapper { List getSltAgreementInfo(AgreementInfo bean); List getLeaseList(AgreementInfo bean); + List getLeaseListOne(AgreementInfo bean); + List getLeaseListThree(AgreementInfo bean); List getTaskList(@Param("bean") AgreementInfo bean, @Param("taskType")String taskType); @@ -50,4 +52,6 @@ public interface SltAgreementInfoMapper { int updateApply(SltAgreementApply apply); int updateMaStatus(SltAgreementInfo agreementInfo); + + int updateTrimDay(SltAgreementInfo sltAgreementInfo); } 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 b644af9c..986b4381 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 @@ -25,12 +25,15 @@ public interface SltAgreementInfoService { SltInfoVo getSltExamInfo(SltAgreementApply apply); int settlementReview(SltAgreementApply apply); - List getLeaseList(List list); + List getLeaseListOne(List list); + List getLeaseListThree(List list); List getLoseList(List list); List getRepairList(List list); List getScrapList(List list); + + int updateTrimDay(List sltAgreementInfo); } 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 82e7842b..76b829b1 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 @@ -35,7 +35,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { private SltAgreementInfoMapper sltAgreementInfoMapper; @Override - public List getSltAgreementInfo(AgreementInfo bean) { + public List getSltAgreementInfo(AgreementInfo bean) { return sltAgreementInfoMapper.getSltAgreementInfo(bean); } @@ -43,18 +43,21 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { public SltInfoVo getSltInfo(List list) { SltInfoVo sltInfoVo = new SltInfoVo(); //租赁费用列表 - List leaseList = getLeaseList(list); + List leaseListOne = getLeaseListOne(list); + + List leaseListThree = getLeaseListThree(list); //维修费用列表 List repairList = getRepairList(list); //报废费用列表 List scrapList = getScrapList(list); //丢失费用列表 List loseList = getLoseList(list); - sltInfoVo.setLeaseList(leaseList); + sltInfoVo.setLeaseListOne(leaseListOne); + sltInfoVo.setLeaseListThree(leaseListThree); sltInfoVo.setRepairList(repairList); sltInfoVo.setScrapList(scrapList); sltInfoVo.setLoseList(loseList); - List relations = getRelations(leaseList,repairList,scrapList,loseList,list); + List relations = getRelations(leaseListOne, leaseListThree, repairList, scrapList, loseList, list); sltInfoVo.setRelations(relations); return sltInfoVo; } @@ -66,16 +69,18 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { String cost = sltAgreementInfoMapper.getCost(apply); List relations = sltAgreementInfoMapper.getRelations(apply); sltInfoVo.setRelations(relations); - for (SltAgreementRelation relation : relations){ + for (SltAgreementRelation relation : relations) { AgreementInfo info = new AgreementInfo(); info.setAgreementId(Long.valueOf(relation.getAgreementId())); list.add(info); } - List leaseList = getLeaseList(list); + List leaseListOne = getLeaseListOne(list); + List leaseListThree = getLeaseListThree(list); List repairList = getRepairList(list); List scrapList = getScrapList(list); List loseList = getLoseList(list); - sltInfoVo.setLeaseList(leaseList); + sltInfoVo.setLeaseListOne(leaseListOne); + sltInfoVo.setLeaseListOne(leaseListThree); sltInfoVo.setRepairList(repairList); sltInfoVo.setScrapList(scrapList); sltInfoVo.setLoseList(loseList); @@ -90,64 +95,146 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { apply.setAuditor(String.valueOf(userid)); int i = sltAgreementInfoMapper.updateRelation(apply); int j = 0; - if (i > 0){ + if (i > 0) { List relations = sltAgreementInfoMapper.getRelations(apply); List infos = new ArrayList<>(); - for (SltAgreementRelation bean : relations){ + for (SltAgreementRelation bean : relations) { AgreementInfo info = new AgreementInfo(); info.setAgreementId(Long.valueOf(bean.getAgreementId())); infos.add(info); } List loseList = getLoseList(infos); - for (SltAgreementInfo agreementInfo : loseList){ - if (agreementInfo.getMaId() != null && agreementInfo.getMaId().isEmpty()){ + for (SltAgreementInfo agreementInfo : loseList) { + if (agreementInfo.getMaId() != null && agreementInfo.getMaId().isEmpty()) { sltAgreementInfoMapper.updateMaStatus(agreementInfo); } } j = sltAgreementInfoMapper.updateApply(apply); - }else { + } else { throw new ServiceException("结算审核失败"); //throw new ServiceException(ExceptionDict.SETTLEMENT_REVIEW_ERROR_MSG,ExceptionDict.SETTLEMENT_REVIEW_ERROR); } return j; } - private List getRelations(List leaseList, List repairList, List scrapList, List loseList, List list) { + @Override + public List getLeaseList(List list) { + List leaseList = new ArrayList<>(); + for (AgreementInfo bean : list) { + List oneOfList = sltAgreementInfoMapper.getLeaseList(bean); + leaseList.addAll(oneOfList); + } + for (SltAgreementInfo bean : leaseList) { + if (bean.getLeasePrice() == null) { + bean.setLeasePrice("0"); + } + if (bean.getNum() == null) { + bean.setNum("0"); + } + if (bean.getLeaseDays() == null) { + bean.setLeaseDays("0"); + } + BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); + BigDecimal num = new BigDecimal(bean.getNum()); + BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); + BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays); + bean.setCosts(String.valueOf(costs)); + /* BigDecimal costs = BigDecimal.ZERO; + //当单价,数量,租赁天数都不为空时计算总价 + if(bean.getLeasePrice() != null && bean.getNum() != null && bean.getLeaseDays() != null){ + BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); + BigDecimal num = new BigDecimal(bean.getNum()); + BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); + costs = leasePrice.multiply(num).multiply(leaseDays); + } + bean.setCosts(String.valueOf(costs));*/ + } + return leaseList; + } + + @Override + public List getLeaseListThree(List list) { + List leaseList = new ArrayList<>(); + for (AgreementInfo bean : list) { + List oneOfList = sltAgreementInfoMapper.getLeaseListThree(bean); + leaseList.addAll(oneOfList); + } + for (SltAgreementInfo bean : leaseList) { + if (bean.getLeasePrice() == null) { + bean.setLeasePrice("0"); + } + if (bean.getNum() == null) { + bean.setNum("0"); + } + if (bean.getLeaseDays() == null) { + bean.setLeaseDays("0"); + } + if (bean.getTrimDay() == null) { + bean.setTrimDay(0); + } + BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); + BigDecimal num = new BigDecimal(bean.getNum()); + BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); + // 实际结算天数(领料天数 + 调整天数(可以为负整数)) + BigDecimal realDays = leaseDays.add(new BigDecimal(bean.getTrimDay())); + // 实际结算金额 + BigDecimal realCosts = leasePrice.multiply(num).multiply(realDays); + // 应结算金额 + BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays); + bean.setCosts(String.valueOf(costs)); + bean.setRealDays(realDays); + bean.setRealCosts(String.valueOf(realCosts)); + } + return leaseList; + } + + private List getRelations(List leaseListOne, List leaseListThree, List repairList, List scrapList, List loseList, List list) { List relations = new ArrayList<>(); - for (AgreementInfo info : list){ + 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");*/ BigDecimal loseCost = BigDecimal.ZERO; - BigDecimal leaseCost = BigDecimal.ZERO; + BigDecimal leaseCostOne = BigDecimal.ZERO; + BigDecimal leaseCostThree = BigDecimal.ZERO; BigDecimal scrapCost = BigDecimal.ZERO; BigDecimal repairCost = BigDecimal.ZERO; - for (SltAgreementInfo lease : leaseList){ - if (lease.getAgreementId().equals(info.getAgreementId().toString())){ + for (SltAgreementInfo lease : leaseListOne) { + 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); + leaseCostOne = leaseCostOne.add(cost); } } - for (SltAgreementInfo repair : repairList){ - if (repair.getAgreementId().equals(info.getAgreementId().toString())){ + for (SltAgreementInfo lease : leaseListThree) { + 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()); + leaseCostThree = leaseCostThree.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())){ + 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())){ + for (SltAgreementInfo lose : loseList) { + if (lose.getAgreementId().equals(info.getAgreementId().toString())) { //TODO 上面已经set过值,这里为什么还要set值 relation.setAgreementId(lose.getAgreementId()); relation.setProjectName(lose.getProjectName()); @@ -157,7 +244,8 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { loseCost = loseCost.add(cost); } } - relation.setLeaseCost(leaseCost.toString()); + relation.setLeaseCostOne(leaseCostOne.toString()); + relation.setLeaseCostThree(leaseCostThree.toString()); relation.setRepairCost(repairCost.toString()); relation.setScrapCost(scrapCost.toString()); relation.setLoseCost(loseCost.toString()); @@ -177,24 +265,25 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { apply.setCode(code); apply.setCompanyId(relations.get(0).getCompanyId()); int i = sltAgreementInfoMapper.insApply(apply); - if (i > 0){ - for (SltAgreementRelation relation : relations){ + 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())); sltAgreementInfoMapper.updateInfoStatus(relation.getAgreementId()); int j = sltAgreementInfoMapper.insRelation(relation); - if (j < 0){ + if (j < 0) { throw new ServiceException("新增协议结算记录失败"); //throw new ServiceException(ExceptionDict.NEW_AGREEMENT_SETTLEMENT_ERROR_MSG,ExceptionDict.NEW_AGREEMENT_SETTLEMENT_ERROR); } } - List leaseList = getLeaseList(list); + List leaseListOne = getLeaseListOne(list); + List leaseListThree = getLeaseListThree(list); List repairList = getRepairList(list); List scrapList = getScrapList(list); List loseList = getLoseList(list); - for (SltAgreementInfo info : leaseList){ + for (SltAgreementInfo info : leaseListOne) { info.setSltType("1"); //info.setSltType(CostTypeEnum.LEASE_COST.getCode()); info.setApplyId(String.valueOf(apply.getId())); @@ -202,7 +291,15 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { //info.setPartType(PartTypeEnum.CHARGE.getCode()); sltAgreementInfoMapper.insDetails(info); } - for (SltAgreementInfo info : repairList){ + for (SltAgreementInfo info : leaseListThree) { + info.setSltType("1"); + //info.setSltType(CostTypeEnum.LEASE_COST.getCode()); + info.setApplyId(String.valueOf(apply.getId())); + info.setPartType("1"); + //info.setPartType(PartTypeEnum.CHARGE.getCode()); + sltAgreementInfoMapper.insDetails(info); + } + for (SltAgreementInfo info : repairList) { info.setSltType("3"); //info.setSltType(CostTypeEnum.MAINTENANCE_COST.getCode()); info.setApplyId(String.valueOf(apply.getId())); @@ -211,7 +308,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { info.setPartType(info.getPartType().equals("不收费") ? "0" : "1"); sltAgreementInfoMapper.insDetails(info); } - for (SltAgreementInfo info : scrapList){ + for (SltAgreementInfo info : scrapList) { info.setSltType("4"); //info.setSltType(CostTypeEnum.SCRAP_COST.getCode()); info.setApplyId(String.valueOf(apply.getId())); @@ -220,16 +317,16 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { info.setPartType(info.getScrapType().equals("自然") ? "0" : "1"); sltAgreementInfoMapper.insDetails(info); } - for (SltAgreementInfo info : loseList){ + for (SltAgreementInfo info : loseList) { info.setSltType("2"); //info.setSltType(CostTypeEnum.LOSE_COST.getCode()); info.setApplyId(String.valueOf(apply.getId())); - info.setPartType("1"); + info.setPartType("1"); //info.setPartType(PartTypeEnum.CHARGE.getCode()); sltAgreementInfoMapper.insDetails(info); } - }else { + } else { throw new ServiceException("新增结算单号失败"); //throw new ServiceException(ExceptionDict.NEW_SETTLEMENT_NUMBER_ERROR_MSG,ExceptionDict.NEW_SETTLEMENT_NUMBER_ERROR); } @@ -244,15 +341,15 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { public List getLoseList(List list) { List loseList = new ArrayList<>(); - for (AgreementInfo bean : list){ + for (AgreementInfo bean : list) { List oneOfList = sltAgreementInfoMapper.getLoseList(bean); loseList.addAll(oneOfList); } - for (SltAgreementInfo bean : loseList){ - if (bean.getBuyPrice() == null){ + for (SltAgreementInfo bean : loseList) { + if (bean.getBuyPrice() == null) { bean.setBuyPrice("0"); } - if (bean.getNum() == null){ + if (bean.getNum() == null) { bean.setNum("0"); } BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice()); @@ -274,20 +371,21 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { List scrapList = new ArrayList<>(); String taskType = "57"; //String taskType = TaskTypeEnum.SCRAP_TASK.getCode(); - for (AgreementInfo bean : list){ - List taskList = sltAgreementInfoMapper.getTaskList(bean,taskType); - if (taskList != null && taskList.size() > 0){ + for (AgreementInfo bean : list) { + List taskList = sltAgreementInfoMapper.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){ + if (scrapList != null && scrapList.size() > 0) { + for (SltAgreementInfo bean : scrapList) { + + if (bean.getBuyPrice() == null) { bean.setBuyPrice("0"); } - if (bean.getNum() == null){ + if (bean.getNum() == null) { bean.setNum("0"); } BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice()); @@ -307,13 +405,26 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { return scrapList; } + @Override + @Transactional + public int updateTrimDay(List sltAgreementInfo) { + int i = 0; + for (SltAgreementInfo agreementInfo : sltAgreementInfo) { + i = sltAgreementInfoMapper.updateTrimDay(agreementInfo); + if (i == 0) { + return i; + } + } + return i; + } + public List getRepairList(List list) { List repairList = new ArrayList<>(); String taskType = "41"; //String taskType = TaskTypeEnum.MAINTENANCE_TASK.getCode(); - for (AgreementInfo bean : list){ - List taskList = sltAgreementInfoMapper.getTaskList(bean,taskType); - if (taskList != null && taskList.size() > 0){ + for (AgreementInfo bean : list) { + List taskList = sltAgreementInfoMapper.getTaskList(bean, taskType); + if (taskList != null && taskList.size() > 0) { List repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(taskList); repairList.addAll(repairDetailsList); } @@ -321,41 +432,44 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { return repairList; } - public List getLeaseList(List list) { + public List getLeaseListOne(List list) { List leaseList = new ArrayList<>(); - for (AgreementInfo bean : list){ - List oneOfList = sltAgreementInfoMapper.getLeaseList(bean); + for (AgreementInfo bean : list) { + List oneOfList = sltAgreementInfoMapper.getLeaseListOne(bean); leaseList.addAll(oneOfList); } - for (SltAgreementInfo bean : leaseList){ - if (bean.getLeasePrice() == null){ + for (SltAgreementInfo bean : leaseList) { + if (bean.getLeasePrice() == null) { bean.setLeasePrice("0"); } - if (bean.getNum() == null){ + if (bean.getNum() == null) { bean.setNum("0"); } - if (bean.getLeaseDays() == null){ + if (bean.getLeaseDays() == null) { bean.setLeaseDays("0"); } + if (bean.getTrimDay() == null) { + bean.setTrimDay(0); + } BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); BigDecimal num = new BigDecimal(bean.getNum()); BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); + // 实际结算天数(领料天数 + 调整天数(可以为负整数)) + BigDecimal realDays = leaseDays.add(new BigDecimal(bean.getTrimDay())); + // 实际结算金额 + BigDecimal realCosts = leasePrice.multiply(num).multiply(realDays); + // 应结算金额 BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays); bean.setCosts(String.valueOf(costs)); - /* BigDecimal costs = BigDecimal.ZERO; - //当单价,数量,租赁天数都不为空时计算总价 - if(bean.getLeasePrice() != null && bean.getNum() != null && bean.getLeaseDays() != null){ - BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); - BigDecimal num = new BigDecimal(bean.getNum()); - BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); - costs = leasePrice.multiply(num).multiply(leaseDays); - } - bean.setCosts(String.valueOf(costs));*/ + bean.setRealDays(realDays); + bean.setRealCosts(String.valueOf(realCosts)); } return leaseList; } - /**结算单号编码生成规则*/ + /** + * 结算单号编码生成规则 + */ private String sltCodeRule(String code) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); Date nowDate = DateUtils.getNowDate(); diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml index ad51c347..a75411c5 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml @@ -585,7 +585,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ma_type mt LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id WHERE - EXISTS ( SELECT 1 FROM slt_agreement_info sai2 WHERE sai2.type_id = mt.type_id AND sai2.agreement_id = #{agreementId} AND sai2.STATUS = '0' ) + EXISTS ( SELECT 1 FROM slt_agreement_info sai2 WHERE sai2.type_id = mt.type_id AND sai2.agreement_id = #{agreementId} AND sai2.STATUS = '0' and sai.lease_type = 0) GROUP BY mt.type_id UNION ALL-- 递归情况:向上查找父级 SELECT 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 6baab781..b141bba3 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 @@ -85,6 +85,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" set ma_status = '103' where ma_id = #{maId} + + update slt_agreement_info + set trim_day = #{trimDay} + where agreement_id = #{agreementId} and type_id = #{typeId} + + and ma_id = #{maId} + + @@ -135,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" DATE(sai.end_time) as endTime, DATEDIFF(IF(sai.end_time is null,CURDATE(),sai.end_time), sai.start_time) + 1 as leaseDays from slt_agreement_info sai + LEFT JOIN lease_apply_info lai ON lai.id = sai.lease_id LEFT JOIN bm_agreement_info bai on sai.agreement_id = bai.agreement_id LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id @@ -284,4 +290,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from slt_agreement_apply where id = #{id} + + \ No newline at end of file