From 1efb444bb208be5df298b5cd68c6bfef42aedbc6 Mon Sep 17 00:00:00 2001 From: hongchao <3228015117@qq.com> Date: Wed, 5 Nov 2025 18:03:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=AE=A1=E6=A0=B8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=AF=BC=E5=87=BA=EF=BC=8C?= =?UTF-8?q?=E7=9B=B4=E8=BD=AC=E5=AE=A1=E6=A0=B8=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ClzSltAgreementInfoController.java | 283 ++++++++++++++++++ .../clz/domain/direct/ClzDirectApplyInfo.java | 2 +- .../impl/ClzSltAgreementInfoServiceImpl.java | 9 +- .../material/clz/ClzAgreementInfoMapper.xml | 5 +- .../mapper/material/repair/RepairMapper.xml | 2 +- 5 files changed, 294 insertions(+), 7 deletions(-) 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 index cba8d63f..8c18eb42 100644 --- 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 @@ -1123,4 +1123,287 @@ public class ClzSltAgreementInfoController extends BaseController { } + /** + * 导出租赁明细 + */ + @ApiOperation(value = "导出材料站结算信息列表") + @PreventRepeatSubmit + @SysLog(title = "结算审核", businessType = OperaType.EXPORT, logType = 1,module = "结算管理->导出材料站租赁明细") + @PostMapping("/exportLeaseReview") + public void exportLeaseReview(HttpServletResponse response, @RequestParam("params") String params) { + try { + // 1. 修正:先将 params 解析为 JSON 对象(而非数组) + JSONObject paramObj = JSONObject.parseObject(params); + String sltApplyCode = paramObj.getString("sltApplyCode"); + // 2. 根据实际需求从 JSON 对象中提取数据(示例:提取 unitIds 和 projectId) + + Long unitId = paramObj.getLong("unitId"); + Long projectId = paramObj.getLong("projectId"); + List unitIds = Arrays.asList(Math.toIntExact(unitId)); + List leaseListAll = new ArrayList<>(); + BigDecimal totalCost = BigDecimal.valueOf(0.00); + List projectNames = new ArrayList<>(); + List unitNames = new ArrayList<>(); + List actualTimeAndNames = new ArrayList<>(); + + // 查询协议号 + List agreementInfos = clzSltAgreementInfoMapper.getAgreementInfoById(unitIds, Math.toIntExact(projectId)); + // 过滤异常数据 + agreementInfos.removeIf(Objects::isNull); + + // 查询每个协议的待结算明细 + if (CollectionUtils.isNotEmpty(agreementInfos)) { + for (AgreementVo agreementInfo : agreementInfos) { + // 数据检查 + if (agreementInfo.getAgreementId() == null || agreementInfo.getAgreementId() <= 0) { + throw new ServiceException("协议ID为空,请反馈至管理员!"); + } + if (org.apache.commons.lang3.StringUtils.isBlank(agreementInfo.getAgreementCode())) { + throw new ServiceException("协议号为空,请检查!"); + } + + // 进行Bean的类型转换,使其适配Mapper + MaterialSltAgreementInfo sltAgreementInfo = new MaterialSltAgreementInfo(); + BeanUtil.copyProperties(agreementInfo, sltAgreementInfo, true); + sltAgreementInfo.setSltApplyCode(sltApplyCode); + List oneOfList = clzSltAgreementInfoMapper.getSltLeaseList(sltAgreementInfo); + if(!oneOfList.isEmpty()){ + actualTimeAndNames.add(oneOfList.get(0).getUnitName() + "(" + oneOfList.get(0).getActualExitTime()+")"); + projectNames.add(oneOfList.get(0).getProjectName()); + unitNames.add(oneOfList.get(0).getUnitName()); + } + List leaseList = new ArrayList<>(oneOfList); + + for (MaterialSltAgreementInfo bean : leaseList) { + // 数据安全检查 + if (null == bean.getLeasePrice()) { + bean.setLeasePrice(BigDecimal.ZERO); + } else { + bean.setLeasePrice(bean.getLeasePrice().setScale(GlobalConstants.INT_2, RoundingMode.HALF_UP)); + } + if (Objects.isNull(bean.getNum())) { + bean.setNum(BigDecimal.ZERO); + } + if (Objects.isNull(bean.getLeaseDays())) { + bean.setLeaseDay(0L); + } + totalCost = totalCost.add(bean.getCosts()); + + leaseListAll.add(bean); + } + } + } + + String fileName = "租赁(超期)费用明细表"; + String projectName = handleData(projectNames); + String unitName = handleData(unitNames); + String actualTimeAndName = handleData(actualTimeAndNames); + + expOutExcel(response,leaseListAll,fileName,projectName,unitName,actualTimeAndName,totalCost,1); + } catch (Exception e) { + log.error(e.toString(), e); + } + } + + + /** + * 导出丢失明细 + */ + @ApiOperation(value = "导出材料站结算信息列表") + @PreventRepeatSubmit + @SysLog(title = "结算审核", businessType = OperaType.EXPORT, logType = 1,module = "结算管理->导出材料站丢失明细") + @PostMapping("/exportLoseReview") + public void exportLoseReview(HttpServletResponse response, @RequestParam("params") String params) { + try { + // 1. 修正:先将 params 解析为 JSON 对象(而非数组) + JSONObject paramObj = JSONObject.parseObject(params); + + String sltApplyCode = paramObj.getString("sltApplyCode"); + // 2. 根据实际需求从 JSON 对象中提取数据(示例:提取 unitIds 和 projectId) + + Long unitId = paramObj.getLong("unitId"); + Long projectId = paramObj.getLong("projectId"); + List unitIds = Arrays.asList(Math.toIntExact(unitId)); + List loseListAll = new ArrayList<>(); + BigDecimal totalCost = BigDecimal.valueOf(0.00); + List projectNames = new ArrayList<>(); + List unitNames = new ArrayList<>(); + List actualTimeAndNames = new ArrayList<>(); + + // 查询协议号 + List agreementInfos = clzSltAgreementInfoMapper.getAgreementInfoById(unitIds, Math.toIntExact(projectId)); + // 过滤异常数据 + agreementInfos.removeIf(Objects::isNull); + + // 查询每个协议的待结算明细 + if (CollectionUtils.isNotEmpty(agreementInfos)) { + for (AgreementVo agreementInfo : agreementInfos) { + // 数据检查 + if (agreementInfo.getAgreementId() == null || agreementInfo.getAgreementId() <= 0) { + throw new ServiceException("协议ID为空,请反馈至管理员!"); + } + if (org.apache.commons.lang3.StringUtils.isBlank(agreementInfo.getAgreementCode())) { + throw new ServiceException("协议号为空,请检查!"); + } + + // 进行Bean的类型转换,使其适配Mapper + MaterialSltAgreementInfo sltAgreementInfo = new MaterialSltAgreementInfo(); + BeanUtil.copyProperties(agreementInfo, sltAgreementInfo, true); + sltAgreementInfo.setSltApplyCode(sltApplyCode); + // 获取未退还的物资(原有逻辑) + List loseList = clzSltAgreementInfoMapper.getSltLoseList(sltAgreementInfo); + if(!loseList.isEmpty()){ + actualTimeAndNames.add(loseList.get(0).getUnitName() + "(" + loseList.get(0).getActualExitTime()+")"); + projectNames.add(loseList.get(0).getProjectName()); + unitNames.add(loseList.get(0).getUnitName()); + } + + for (MaterialSltAgreementInfo bean : loseList) { + if (Objects.isNull(bean.getBuyPrice())) { + bean.setBuyPrice(BigDecimal.ZERO); + } + if (Objects.isNull(bean.getNum())) { + bean.setNum(BigDecimal.ZERO); + } + totalCost = totalCost.add(bean.getCosts()); + loseListAll.add(bean); + } + } + } + + String fileName = "未归还费用明细表"; + String projectName = handleData(projectNames); + String unitName = handleData(unitNames); + String actualTimeAndName = handleData(actualTimeAndNames); + + expOutExcel(response,loseListAll,fileName,projectName,unitName,actualTimeAndName,totalCost,2); + } catch (Exception e) { + log.error(e.toString(), e); + } + } + + /** + * 导出结算信息列表--all + */ + @ApiOperation(value = "导出结算信息列表") + @PreventRepeatSubmit +// @RequiresPermissions("settlement:info:export") + @SysLog(title = "结算审核", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出全部费用明细") + @PostMapping("/exportAllReview") + public void exportAllReview(HttpServletResponse response, @RequestParam("params") String params) { + try { + String fileName = "结算费用明细"; + JSONObject paramObj = JSONObject.parseObject(params); + String sltApplyCode = paramObj.getString("sltApplyCode"); + + Long unitId = paramObj.getLong("unitId"); + Long projectId = paramObj.getLong("projectId"); + List unitIds = Arrays.asList(Math.toIntExact(unitId)); + List leaseListAll = new ArrayList<>(); + List loseListAll = new ArrayList<>(); + List repairListAll = new ArrayList<>(); + List scrapListAll = new ArrayList<>(); + List reductionListAll = new ArrayList<>(); + + List listAll = new ArrayList<>(); + + BigDecimal totalCost = BigDecimal.valueOf(0.00); + List projectNames = new ArrayList<>(); + List unitNames = new ArrayList<>(); + List actualTimeAndNames = new ArrayList<>(); + + //各费用明细 + BigDecimal totalCostLease = BigDecimal.valueOf(0.00); + BigDecimal totalCostLose = BigDecimal.valueOf(0.00); + BigDecimal totalCostRepair = BigDecimal.valueOf(0.00); + BigDecimal totalCostScrap = BigDecimal.valueOf(0.00); + BigDecimal totalCostReduction = BigDecimal.valueOf(0.00); + + // 查询协议号 + List agreementInfos = clzSltAgreementInfoMapper.getAgreementInfoById(unitIds, Math.toIntExact(projectId)); + // 过滤异常数据 + agreementInfos.removeIf(Objects::isNull); + + + // 查询每个协议的待结算明细 + if (CollectionUtils.isNotEmpty(agreementInfos)) { + for (AgreementVo agreementInfo : agreementInfos) { + // 数据检查 + if (agreementInfo.getAgreementId() == null || agreementInfo.getAgreementId() <= 0) { + throw new ServiceException("协议ID为空,请反馈至管理员!"); + } + if (org.apache.commons.lang3.StringUtils.isBlank(agreementInfo.getAgreementCode())) { + throw new ServiceException("协议号为空,请检查!"); + } + + //租赁 + // 进行Bean的类型转换,使其适配Mapper + MaterialSltAgreementInfo sltAgreementInfoLease = new MaterialSltAgreementInfo(); + BeanUtil.copyProperties(agreementInfo, sltAgreementInfoLease, true); + sltAgreementInfoLease.setSltApplyCode(sltApplyCode); + List oneOfListLease = clzSltAgreementInfoMapper.getSltLeaseList(sltAgreementInfoLease); + + if(!oneOfListLease.isEmpty()){ + actualTimeAndNames.add(oneOfListLease.get(0).getUnitName() + "(" + oneOfListLease.get(0).getActualExitTime()+")"); + projectNames.add(oneOfListLease.get(0).getProjectName()); + unitNames.add(oneOfListLease.get(0).getUnitName()); + } + + List leaseList = new ArrayList<>(oneOfListLease); + + + + for (MaterialSltAgreementInfo bean : leaseList) { + // 数据安全检查 + if (null == bean.getLeasePrice()) { + bean.setLeasePrice(BigDecimal.ZERO); + } else { + bean.setLeasePrice(bean.getLeasePrice().setScale(GlobalConstants.INT_2, RoundingMode.HALF_UP)); + } + if (Objects.isNull(bean.getNum())) { + bean.setNum(BigDecimal.ZERO); + } + if (Objects.isNull(bean.getLeaseDays())) { + bean.setLeaseDay(0L); + } + totalCostLease = totalCostLease.add(bean.getCosts()); + + leaseListAll.add(bean); + listAll.add(bean); + } + + //丢失 + // 进行Bean的类型转换,使其适配Mapper + MaterialSltAgreementInfo sltAgreementInfoLose = new MaterialSltAgreementInfo(); + BeanUtil.copyProperties(agreementInfo, sltAgreementInfoLose, true); + sltAgreementInfoLose.setSltApplyCode(sltApplyCode); + // 获取未退还的物资(原有逻辑) + List oneOfListLose = clzSltAgreementInfoMapper.getSltLoseList(sltAgreementInfoLose); + List loseList = new ArrayList<>(oneOfListLose); + + + for (MaterialSltAgreementInfo bean : loseList) { + if (Objects.isNull(bean.getBuyPrice())) { + bean.setBuyPrice(BigDecimal.ZERO); + } + if (Objects.isNull(bean.getNum())) { + bean.setNum(BigDecimal.ZERO); + } + + totalCostLose = totalCostLose.add(bean.getCosts()); + loseListAll.add(bean); + listAll.add(bean); + } + } + } + + + String projectName = handleData(projectNames); + String unitName = handleData(unitNames); + String actualTimeAndName = handleData(actualTimeAndNames); + expOutExcelAll(response,leaseListAll,loseListAll,repairListAll,scrapListAll,reductionListAll,fileName,projectName,unitName,actualTimeAndName,totalCostLease,totalCostLose,totalCostRepair,totalCostScrap,totalCostReduction); + } catch (Exception e) { + log.error(e.toString(), e); + } + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/direct/ClzDirectApplyInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/direct/ClzDirectApplyInfo.java index ae5ed79d..a1fa49eb 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/direct/ClzDirectApplyInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/direct/ClzDirectApplyInfo.java @@ -98,7 +98,7 @@ public class ClzDirectApplyInfo extends BaseEntity { @Excel(name = "物资类型") private String typeName; - @Excel(name = "状态", readConverterExp = "0=待审核,1=审核中,2=已完成,3=已驳回,4= 待提交") + @Excel(name = "状态", readConverterExp = "0=待审核,1=审核中,2=已完成,3=已驳回,4=待提交") private Integer status; @ApiModelProperty(value = "审核人") 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 index cae972d0..689af981 100644 --- 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 @@ -281,12 +281,15 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo(); - + if(!CollectionUtils.isEmpty(leaseList)){ + sltInfoVo.setActualExitTime(leaseList.get(0).getActualExitTime()); + } sltInfoVo.setLeaseList(leaseList); sltInfoVo.setRepairList(repairList); sltInfoVo.setScrapList(scrapList); sltInfoVo.setLoseList(loseList); - resultVoList.add(sltInfoVo); + // 给外层的单位名称/工程名称赋值 + extractInnerNameToOuter(resultVoList, sltInfoVo); // 查询各项费用列表 // List sltedList = clzSltAgreementInfoMapper.getSltedList(info); @@ -345,8 +348,6 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic // // resultVoList.add(sltInfoVo); // -// // 给外层的单位名称/工程名称赋值 -// extractInnerNameToOuter(resultVoList, sltInfoVo); // // }); // } 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 index cb290d21..19a1bf74 100644 --- 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 @@ -511,7 +511,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" saa.id as id, bai.agreement_id as agreementId, bai.agreement_code as agreementCode, saa.`code` as sltApplyCode, bui.unit_id as unitId, bui.unit_name as unitName, bp.pro_id as projectId, bp.pro_name as projectName, saa.remark, sad.money as costs, saa.audit_time as auditTime, sad.start_time as startTime, sad.end_time as endTime, - saa.`status` as sltStatus, sad.slt_type as sltType, sad.num, sad.price as leasePrice, + sad.out_time as actualExitTime, + saa.`status` as sltStatus, sad.slt_type as sltType, sad.num, sad.price as buyPrice, mt1.type_name as typeName, mt.type_name as modelName, mt.unit_name as mtUnitName FROM clz_slt_agreement_apply saa @@ -529,6 +530,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" saa.id as id, bai.agreement_id as agreementId, bai.agreement_code as agreementCode, saa.`code` as sltApplyCode, bui.unit_id as unitId, bui.unit_name as unitName, bp.pro_id as projectId, bp.pro_name as projectName, saa.remark, sad.money as costs, saa.audit_time as auditTime, sad.start_time as startTime, sad.end_time as endTime, + DATEDIFF(IF(sad.end_time is null,CURDATE(),sad.end_time), sad.start_time) + 1 as leaseDays,bp.external_id as wsProId, + sad.out_time as actualExitTime,sad.over_day as overDay,DATE_ADD(sad.out_time, INTERVAL 7 DAY) as overTime, saa.`status` as sltStatus, sad.slt_type as sltType, sad.num, sad.price as leasePrice, mt1.type_name as typeName, mt.type_name as modelName, mt.unit_name as mtUnitName FROM diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/repair/RepairMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/repair/RepairMapper.xml index 91e78a23..34f7eb0d 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/repair/RepairMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/repair/RepairMapper.xml @@ -1619,7 +1619,7 @@ left join bm_project bp on bp.pro_id = bai.project_id left join ma_type mt1 on mt1.type_id = rpd.type_id left join ma_type mt2 on mt2.type_id = mt1.parent_id - left join ma_machine mm on mm.ma_id = rpd.ma_id + left join ma_machine mm on mm.ma_id = rpd.ma_id and mt1.manage_type = 0 left join ma_part_type mpt1 on mpt1.pa_id = rpd.part_id left join ma_part_type mpt2 on mpt2.pa_id = mpt1.parent_id left join sys_user su on (