From 37a460026363c28634c465248e6d3a6ce424ecf8 Mon Sep 17 00:00:00 2001 From: hongchao <3228015117@qq.com> Date: Mon, 13 Oct 2025 21:37:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E7=AE=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/common/biz/config/PoiOutPage.java | 298 +++++++ .../ClzSltAgreementInfoController.java | 827 +++++++++++++++++- .../domain/vo/MaterialSltAgreementInfo.java | 15 + .../sltAgreementInfo/MaterialSltInfoVo.java | 5 + .../clz/mapper/ClzSltAgreementInfoMapper.java | 5 + .../service/ClzSltAgreementInfoService.java | 15 + .../impl/ClzSltAgreementInfoServiceImpl.java | 61 ++ .../material/clz/ClzAgreementInfoMapper.xml | 196 +++-- 8 files changed, 1369 insertions(+), 53 deletions(-) diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/config/PoiOutPage.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/config/PoiOutPage.java index 0ac59f15..166e5426 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/config/PoiOutPage.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/config/PoiOutPage.java @@ -250,6 +250,51 @@ public class PoiOutPage { return workbook; } + public static HSSFWorkbook excelForcheckClz(List> result, List list, String filename, String projectName, String unit, String actualTimeAndName, BigDecimal totalCost) { + // 创建工作簿和工作表 + HSSFWorkbook workbook = new HSSFWorkbook(); + HSSFSheet sheet = workbook.createSheet(); + sheet.setDefaultColumnWidth(15); // 设置列宽 + + // 创建样式 + HSSFCellStyle titleStyle = createTitleStyle(workbook); + HSSFCellStyle headerStyle = createHeaderStyle(workbook); + HSSFCellStyle contentStyle = createCellStyle(workbook); + + // 设置工作簿名称 + workbook.setSheetName(0, filename); + + // 填充标题行 + int rowNum = 0; + rowNum = createTitleRowStyle(sheet, rowNum, filename, titleStyle, list.size()); + rowNum = createProjectAndUnitRowClz(sheet, rowNum, projectName, unit,actualTimeAndName, titleStyle, list.size()); + + // 填充表头 + rowNum = createHeaderRow(sheet, rowNum, list, headerStyle); + + // 填充数据行 + if (result != null && !result.isEmpty()) { + rowNum = createDataRows(sheet, rowNum, result, contentStyle, list.size()); + } else { + // 如果没有数据,则仅显示表头 +// rowNum++; +// rowNum = createDataRows(sheet, rowNum, result, contentStyle, list.size()); + HSSFRow row = sheet.createRow(rowNum++); + HSSFCell cell = row.createCell(0); + cell.setCellStyle(headerStyle); + cell.setCellValue("暂无数据"); + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (list.size() - 1))); + CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (list.size() - 1)); + // 设置边框样式 + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet); + } + rowNum = createTotalRow(sheet, rowNum, list, totalCost, headerStyle); + return workbook; + } + public static HSSFWorkbook excelForcheckLeaseOut(List> result, List list, String filename) { // 创建工作簿和工作表 HSSFWorkbook workbook = new HSSFWorkbook(); @@ -455,6 +500,175 @@ public class PoiOutPage { return workbook; } + public static HSSFWorkbook excelForcheckAllClz(List> resultLease,List> resultLose,List> resultRepair,List> resultScrap,List> resultsReduction, + List listLease,List listLose,List listRepair,List listScrap,List listReduction, String filename, String projectName, String unit,String actualTimeAndName, + BigDecimal totalCostLease, BigDecimal totalCostLose, BigDecimal totalCostRepair, BigDecimal totalCostScrap,BigDecimal totalCostReduction) { + // 创建工作簿和工作表 + HSSFWorkbook workbook = new HSSFWorkbook(); + HSSFSheet sheet = workbook.createSheet(); + sheet.setDefaultColumnWidth(15); // 设置列宽 + + // 创建样式 + HSSFCellStyle titleStyle = createTitleStyle(workbook); + HSSFCellStyle headerStyle = createHeaderStyle(workbook); + HSSFCellStyle contentStyle = createCellStyle(workbook); + + // 设置工作簿名称 + workbook.setSheetName(0, filename); + + // 填充标题行 + int rowNum = 0; + rowNum = createTitleRowStyle(sheet, rowNum, filename, titleStyle, listLease.size()); + rowNum = createProjectAndUnitRowClz(sheet, rowNum, projectName, unit,actualTimeAndName, titleStyle, listLease.size()); + + /** + * 租赁费用明细 + */ + rowNum = createTitleRowStyleCost(sheet, rowNum, "租赁费用明细", titleStyle, listLease.size()); + // 填充表头 + rowNum = createHeaderRow(sheet, rowNum, listLease, headerStyle); + + // 填充数据行 + if (resultLease != null && !resultLease.isEmpty()) { + rowNum = createDataRows(sheet, rowNum, resultLease, contentStyle, listLease.size()); + } else { + // 如果没有数据,则仅显示表头 +// rowNum++; +// rowNum = createDataRows(sheet, rowNum, resultLease, contentStyle, listLease.size()); + HSSFRow row = sheet.createRow(rowNum++); + HSSFCell cell = row.createCell(0); + cell.setCellStyle(headerStyle); + cell.setCellValue("暂无数据"); + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listLease.size() - 1))); + CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listLease.size() - 1)); + // 设置边框样式 + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet); + } + rowNum = createTotalRow(sheet, rowNum, listLease, totalCostLease, headerStyle); + + /** + * 维修费用明细 + */ + // 填充标题行 + rowNum = createTitleRowStyleCost(sheet, rowNum, "维修费用明细", titleStyle, listRepair.size()); + // 填充表头 + rowNum = createHeaderRow(sheet, rowNum, listRepair, headerStyle); + // 填充数据行 + if (resultRepair!= null &&!resultRepair.isEmpty()) { + rowNum = createDataRows(sheet, rowNum, resultRepair, contentStyle, listRepair.size()); + } else { + // 如果没有数据,则仅显示表头 +// rowNum++; +// rowNum = createDataRows(sheet, rowNum, resultRepair, contentStyle, listRepair.size()); + HSSFRow row = sheet.createRow(rowNum++); + HSSFCell cell = row.createCell(0); + cell.setCellStyle(headerStyle); + cell.setCellValue("暂无数据"); + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listRepair.size() - 1))); + CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listRepair.size() - 1)); + // 设置边框样式 + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet); + } + rowNum = createTotalRow(sheet, rowNum, listRepair, totalCostRepair, headerStyle); + + /** + * 丢失费用明细 + */ + // 填充标题行 + rowNum = createTitleRowStyleCost(sheet, rowNum, "丢失费用明细", titleStyle, listLose.size()); + // 填充表头 + rowNum = createHeaderRow(sheet, rowNum, listLose, headerStyle); + // 填充数据行 + if (resultLose!= null &&!resultLose.isEmpty()) { + rowNum = createDataRows(sheet, rowNum, resultLose, contentStyle, listLose.size()); + } else { + // 如果没有数据,则仅显示表头 +// rowNum++; +// rowNum = createDataRows(sheet, rowNum, resultLose, contentStyle, listLose.size()); + HSSFRow row = sheet.createRow(rowNum++); + HSSFCell cell = row.createCell(0); + cell.setCellStyle(headerStyle); + cell.setCellValue("暂无数据"); + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listLose.size() - 1))); + CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listLose.size() - 1)); + // 设置边框样式 + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet); + } + rowNum = createTotalRow(sheet, rowNum, listLose, totalCostLose, headerStyle); + + /** + * 报废费用明细 + */ + // 填充标题行 + rowNum = createTitleRowStyleCost(sheet, rowNum, "报废费用明细", titleStyle, listScrap.size()); + // 填充表头 + rowNum = createHeaderRow(sheet, rowNum, listScrap, headerStyle); + // 填充数据行 + if (resultScrap!= null &&!resultScrap.isEmpty()) { + rowNum = createDataRows(sheet, rowNum, resultScrap, contentStyle, listScrap.size()); + } else { + // 如果没有数据,则仅显示表头 +// rowNum++; +// rowNum = createDataRows(sheet, rowNum, resultScrap, contentStyle, listScrap.size()); + HSSFRow row = sheet.createRow(rowNum++); + HSSFCell cell = row.createCell(0); + cell.setCellStyle(headerStyle); + cell.setCellValue("暂无数据"); + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listScrap.size() - 1))); + CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listScrap.size() - 1)); + // 设置边框样式 + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet); + } + rowNum = createTotalRow(sheet, rowNum, listScrap, totalCostScrap, headerStyle); + + /** + * 减免费用明细 + */ + // 填充标题行 + rowNum = createTitleRowStyleCost(sheet, rowNum, "减免费用明细", titleStyle, listReduction.size()); + // 填充表头 + rowNum = createHeaderRow(sheet, rowNum, listReduction, headerStyle); + // 填充数据行 + if (resultsReduction != null && !resultsReduction.isEmpty()) { + rowNum = createDataRows(sheet, rowNum, resultsReduction, contentStyle, listReduction.size()); + } else { + // 如果没有数据,则仅显示表头 +// rowNum++; +// rowNum = createDataRows(sheet, rowNum, resultLease, contentStyle, listLease.size()); + HSSFRow row = sheet.createRow(rowNum++); + HSSFCell cell = row.createCell(0); + cell.setCellStyle(headerStyle); + cell.setCellValue("暂无数据"); + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listReduction.size() - 1))); + CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listReduction.size() - 1)); + // 设置边框样式 + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet); + } + rowNum = createTotalRow(sheet, rowNum, listReduction, totalCostReduction, headerStyle); + + + //合计 + BigDecimal totalCostAll = totalCostLease.add(totalCostLose).add(totalCostRepair).add(totalCostScrap).add(totalCostReduction); + rowNum = createTotalRowAll(sheet, rowNum, listScrap, totalCostAll, headerStyle); + + return workbook; + } + public static void excelForcheckEach(HSSFWorkbook workbook,HSSFSheet sheet,List> resultLease,List> resultLose,List> resultRepair,List> resultScrap,List> resultsReduction, List listLease,List listLose,List listRepair,List listScrap,List listReduction, String projectName, String unit, BigDecimal totalCostLease, BigDecimal totalCostLose, BigDecimal totalCostRepair, BigDecimal totalCostScrap,BigDecimal totalCostReduction) { @@ -975,6 +1189,88 @@ public class PoiOutPage { RegionUtil.setBorderRight(BorderStyle.THIN, cellRange4, sheet); + return rowNum; + } + + private static int createProjectAndUnitRowClz(HSSFSheet sheet, int rowNum, String projectName, String unitName,String actualTimeAndName,HSSFCellStyle titleStyle, int nColumn) { + // 第一行:结算单位 + HSSFRow row1 = sheet.createRow(rowNum++); + row1.setHeightInPoints(30); + // bug修复:修改合并单元格区域,确保包含两个或以上单元格 + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1)); // 结算单位: 占8 + HSSFCell cell1 = row1.createCell(0); + cell1.setCellStyle(titleStyle); + cell1.setCellValue("结算单位:"); + + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1))); // unitName 占剩余的22 + HSSFCell cell2 = row1.createCell(2); + cell2.setCellStyle(titleStyle); + cell2.setCellValue(unitName); + + // 第二行:结算工程 + HSSFRow row2 = sheet.createRow(rowNum++); + row2.setHeightInPoints(30); + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1)); // 结算工程: 占8 + HSSFCell cell3 = row2.createCell(0); + cell3.setCellStyle(titleStyle); + cell3.setCellValue("结算工程:"); + + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1))); // projectName 占剩余的22 + HSSFCell cell4 = row2.createCell(2); + cell4.setCellStyle(titleStyle); + cell4.setCellValue(projectName); + + // 第二行:结算工程 + HSSFRow row3 = sheet.createRow(rowNum++); + row3.setHeightInPoints(30); + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1)); // 结算工程: 占8 + HSSFCell cell5 = row3.createCell(0); + cell5.setCellStyle(titleStyle); + cell5.setCellValue("出场时间:"); + + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1))); + HSSFCell cell6 = row3.createCell(2); + cell6.setCellStyle(titleStyle); + cell6.setCellValue(actualTimeAndName); + + + + // 添加边框 + CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 3, rowNum - 3, 0, 1); + CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 3, rowNum - 3, 2, (short) (nColumn - 1)); + CellRangeAddress cellRange3 = new CellRangeAddress(rowNum - 2, rowNum - 2, 0, 1); + CellRangeAddress cellRange4 = new CellRangeAddress(rowNum - 2, rowNum - 2, 2, (short) (nColumn - 1)); + CellRangeAddress cellRange5 = new CellRangeAddress(rowNum - 1 ,rowNum - 1 , 0, 1); + CellRangeAddress cellRange6 = new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1)); + + // 设置边框样式 + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange1, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange1, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange1, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange1, sheet); + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange2, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange2, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange2, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange2, sheet); + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange3, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange3, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange3, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange3, sheet); + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange4, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange4, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange4, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange4, sheet); + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange5, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange5, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange5, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange5, sheet); + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange6, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange6, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange6, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange6, sheet); + + + return rowNum; } @@ -1255,4 +1551,6 @@ public class PoiOutPage { return style; } + + } 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 df9293bd..aa07d7e1 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 @@ -1,26 +1,49 @@ package com.bonus.material.clz.controller; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.convert.Convert; +import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.common.utils.StringUtils; +import com.bonus.common.biz.config.PoiOutPage; +import com.bonus.common.biz.constant.GlobalConstants; import com.bonus.common.core.exception.ServiceException; 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.common.log.annotation.SysLog; +import com.bonus.common.log.enums.OperaType; import com.bonus.material.basic.domain.BmProject; import com.bonus.material.clz.domain.ClzSltApplyDTO; +import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo; 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.common.annotation.PreventRepeatSubmit; import com.bonus.material.common.domain.dto.SelectDto; +import com.bonus.material.common.domain.vo.AgreementVo; import com.bonus.material.settlement.domain.SltAgreementApply; import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.settlement.domain.SltAgreementReduce; +import com.bonus.material.settlement.domain.SltAgreementRelation; +import com.bonus.material.settlement.domain.vo.SltLeaseInfo; +import com.bonus.material.task.domain.TmTask; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.util.List; +import javax.servlet.http.HttpServletResponse; +import java.io.OutputStream; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.*; @Api(tags = "材料站结算申请接口") @RestController @@ -31,6 +54,35 @@ public class ClzSltAgreementInfoController extends BaseController { @Resource private ClzSltAgreementInfoService clzSltAgreementInfoService; + @Resource + private ClzSltAgreementInfoMapper clzSltAgreementInfoMapper; + + + + /** + * 获取材料站结算申请工程下拉选 + * @param bean + * @return + */ + @ApiOperation(value = "获取材料站结算申请工程下拉选") + @GetMapping("/getClzProjectList") + public AjaxResult getClzProjectList(MaterialRetainedEquipmentInfo bean) { + List list = clzSltAgreementInfoService.getClzProjectList(bean); + return AjaxResult.success(list); + } + + /** + * 获取材料站结算申请班组下拉选 + * @param bean + * @return + */ + @ApiOperation(value = "获取材料站结算申请班组下拉选") + @GetMapping("/getClzTeamList") + public AjaxResult getClzTeamList(MaterialSltAgreementInfo bean) { + List list = clzSltAgreementInfoService.getClzTeamList(bean); + return AjaxResult.success(list); + } + /** * 查询协议结算列表 */ @@ -86,6 +138,779 @@ public class ClzSltAgreementInfoController extends BaseController { return AjaxResult.success(resultList); } + /** + * 导出租赁明细 + */ + @ApiOperation(value = "导出材料站结算信息列表") + @PreventRepeatSubmit + @SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "结算管理->导出材料站租赁明细") + @PostMapping("/exportLease") + public void exportLease(HttpServletResponse response, @RequestParam("params") String params) { + try { + // 1. 修正:先将 params 解析为 JSON 对象(而非数组) + JSONObject paramObj = JSONObject.parseObject(params); + + // 2. 根据实际需求从 JSON 对象中提取数据(示例:提取 unitIds 和 projectId) + List unitIds = paramObj.getJSONArray("unitIds").toJavaList(Integer.class); + Long projectId = paramObj.getLong("projectId"); + 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); + + List oneOfList = clzSltAgreementInfoMapper.getLeaseList(sltAgreementInfo); + //设定班组实际出场时间 + if(!oneOfList.isEmpty()){ + String date = clzSltAgreementInfoMapper.getTeamOutTime(oneOfList.get(0)); + if(date!=null && !date.isEmpty()){ + oneOfList.get(0).setActualExitTime(date); + } + 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); + } + + BigDecimal leasePrice = bean.getLeasePrice(); + BigDecimal num = bean.getNum(); + // 根据班组退场时间计算租赁费用 + BigDecimal costs = calculateRentalCostByTeamExitTime(bean, leasePrice, num); + bean.setCosts(costs); + if(costs!=null){ + totalCost = totalCost.add(costs); + } + 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("/exportLose") + public void exportLose(HttpServletResponse response, @RequestParam("params") String params) { + try { + // 1. 修正:先将 params 解析为 JSON 对象(而非数组) + JSONObject paramObj = JSONObject.parseObject(params); + + // 2. 根据实际需求从 JSON 对象中提取数据(示例:提取 unitIds 和 projectId) + List unitIds = paramObj.getJSONArray("unitIds").toJavaList(Integer.class); + Long projectId = paramObj.getLong("projectId"); + 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); + + // 获取未退还的物资(原有逻辑) + List oneOfList = clzSltAgreementInfoMapper.getLoseList(sltAgreementInfo); + List loseList = new ArrayList<>(oneOfList); + + // 获取已退还但超期16天以上的物资 + List overdueReturnedList = getOverdueReturnedMaterials(sltAgreementInfo); + loseList.addAll(overdueReturnedList); + //设定班组实际出场时间 + if(!loseList.isEmpty()){ + String date = clzSltAgreementInfoMapper.getTeamOutTime(loseList.get(0)); + if(date!=null && !date.isEmpty()){ + loseList.get(0).setActualExitTime(date); + } + 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); + } + BigDecimal buyPrice = bean.getBuyPrice(); + BigDecimal num = bean.getNum(); + // 原价 x 数量 + BigDecimal costs = buyPrice.multiply(num); + //计算租赁费用 + bean.setCosts(costs); + if(costs!=null){ + totalCost = totalCost.add(costs); + } + 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("/exportAll") + public void exportAll(HttpServletResponse response, @RequestParam("params") String params) { + try { + String fileName = "结算费用明细"; + JSONObject paramObj = JSONObject.parseObject(params); + List unitIds = paramObj.getJSONArray("unitIds").toJavaList(Integer.class); + Long projectId = paramObj.getLong("projectId"); + 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); + + List oneOfListLease = clzSltAgreementInfoMapper.getLeaseList(sltAgreementInfoLease); + + 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); + } + + BigDecimal leasePrice = bean.getLeasePrice(); + BigDecimal num = bean.getNum(); + // 根据班组退场时间计算租赁费用 + BigDecimal costs = calculateRentalCostByTeamExitTime(bean, leasePrice, num); + bean.setCosts(costs); + if(costs!=null){ + totalCostLease = totalCostLease.add(costs); + } + leaseListAll.add(bean); + listAll.add(bean); + } + + //丢失 + // 进行Bean的类型转换,使其适配Mapper + MaterialSltAgreementInfo sltAgreementInfoLose = new MaterialSltAgreementInfo(); + BeanUtil.copyProperties(agreementInfo, sltAgreementInfoLose, true); + + // 获取未退还的物资(原有逻辑) + List oneOfListLose = clzSltAgreementInfoMapper.getLoseList(sltAgreementInfoLose); + List loseList = new ArrayList<>(oneOfListLose); + + // 获取已退还但超期16天以上的物资 + List overdueReturnedList = getOverdueReturnedMaterials(sltAgreementInfoLose); + loseList.addAll(overdueReturnedList); + + + for (MaterialSltAgreementInfo bean : loseList) { + if (Objects.isNull(bean.getBuyPrice())) { + bean.setBuyPrice(BigDecimal.ZERO); + } + if (Objects.isNull(bean.getNum())) { + bean.setNum(BigDecimal.ZERO); + } + BigDecimal buyPrice = bean.getBuyPrice(); + BigDecimal num = bean.getNum(); + // 原价 x 数量 + BigDecimal costs = buyPrice.multiply(num); + //计算租赁费用 + bean.setCosts(costs); + if(costs!=null){ + totalCostLose = totalCostLose.add(costs); + } + loseListAll.add(bean); + listAll.add(bean); + } + //设定班组实际出场时间 + if(!listAll.isEmpty()){ + String date = clzSltAgreementInfoMapper.getTeamOutTime(listAll.get(0)); + if(date!=null && !date.isEmpty()){ + listAll.get(0).setActualExitTime(date); + } + projectNames.add(listAll.get(0).getProjectName()); + unitNames.add(listAll.get(0).getUnitName()); + actualTimeAndNames.add(listAll.get(0).getUnitName() + "(" + listAll.get(0).getActualExitTime()+")"); + listAll = new ArrayList<>(); + } + } + } + + + 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); + } + } + + /** + * 导出结算单--all + * @throws Exception 异常信息 + */ + private void expOutExcelAll(HttpServletResponse response, List lease,List lose,List repair,List scrap,List reduction, + String filename,String projectName,String unitName,String actualTimeAndName,BigDecimal totalCostLease,BigDecimal totalCostLose,BigDecimal totalCostRepair,BigDecimal totalCostScrap,BigDecimal totalCostReduction) + throws Exception { + List> resultsLease = new ArrayList<>(); + List> resultsLose = new ArrayList<>(); + List> resultsRepair = new ArrayList<>(); + List> resultsScrap = new ArrayList<>(); + List> resultsReduction = new ArrayList<>(); + if (lease!= null) { + for (MaterialSltAgreementInfo bean : lease) { + Map maps = outReceiveDetailsBeanToMap(bean, 1, 1); + resultsLease.add(maps); + } + } + if (lose!= null) { + for (MaterialSltAgreementInfo bean : lose) { + Map maps = outReceiveDetailsBeanToMap(bean, 2, 1); + resultsLose.add(maps); + } + } + if (repair!= null) { + for (MaterialSltAgreementInfo bean : repair) { + Map maps = outReceiveDetailsBeanToMap(bean, 3, 1); + resultsRepair.add(maps); + } + } + if (scrap!= null) { + for (MaterialSltAgreementInfo bean : scrap) { + Map maps = outReceiveDetailsBeanToMap(bean, 4, 1); + resultsScrap.add(maps); + } + } + if (reduction!= null) { + for (MaterialSltAgreementInfo bean : reduction) { + Map maps = outReceiveDetailsBeanToMap(bean, 5, 1); + resultsReduction.add(maps); + } + } + + List headersLease = receiveDetailsHeader(1,1); + List headersLose = receiveDetailsHeader(2,1); + List headersRepair = receiveDetailsHeader(3,1); + List headersScrap = receiveDetailsHeader(4,1); + List headersReduction = receiveDetailsHeader(5,1); + HSSFWorkbook workbook = PoiOutPage.excelForcheckAllClz(resultsLease,resultsLose,resultsRepair,resultsScrap,resultsReduction, headersLease,headersLose,headersRepair,headersScrap,headersReduction, filename,projectName,unitName,actualTimeAndName,totalCostLease,totalCostLose,totalCostRepair,totalCostScrap,totalCostReduction); + OutputStream out = null; + response.setContentType("application/vnd.ms-excel;charset=UTF-8"); + response.addHeader("Content-Disposition", + "attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".xls"); + response.setHeader("Pragma", "No-cache"); + out = response.getOutputStream(); + workbook.write(out); + out.flush(); + out.close(); + } + + /** + * 获取已退还但超期16天以上的物资(计为丢失) + * @param info 信息表 + */ + private List getOverdueReturnedMaterials(MaterialSltAgreementInfo info) { + // 获取所有已退还的物资 + List returnedList = clzSltAgreementInfoMapper.getLeaseList(info); + List overdueList = new ArrayList<>(); + + Date teamExitTime = simulateTeamExitTime(); + + for (MaterialSltAgreementInfo bean : returnedList) { + // 只处理已退还的物资 + if (bean.getEndTime() != null) { + long overdueDays = calculateOverdueDays(bean.getEndTime(), teamExitTime); + if (overdueDays >= 16) { + // 超期16天以上计为丢失 + overdueList.add(bean); + } + } + } + + return overdueList; + } + + private BigDecimal calculateRentalCostByTeamExitTime(MaterialSltAgreementInfo bean, BigDecimal leasePrice, BigDecimal num) { + // 模拟班组退场时间(后续会通过参数传入) + Date teamExitTime = simulateTeamExitTime(); + + // 物资是否已退还(根据endTime字段判断) + boolean isReturned = bean.getEndTime() != null; + + if (!isReturned) { + // 1.4 如果当前领用物资还未退还,不收取任何租赁费用,直接计作丢失,收取物资原值 不在租赁费用中体现 + return BigDecimal.ZERO; + } + + // 物资已退还,按照天数来计算费用 + Date materialReturnTime = bean.getEndTime(); + + // 计算超期天数 + long overdueDays = calculateOverdueDays(materialReturnTime, teamExitTime); + + if (overdueDays <= 0) { + // 1.3 在班组退场之前归还的物资不收费 + return BigDecimal.ZERO; + } else if (overdueDays >= 16) { + // 1.2 超期15天以上也就是16天及以上计为丢失,算作丢失的话直接收取原值、所有租赁费用不收费了 + // 注意:丢失费用应该在getLoseList中处理,这里不收费 + return BigDecimal.ZERO; + } else { + // 计算超期费用 + return calculateOverdueCost(bean, leasePrice, num, overdueDays); + } + } + + /** + * 计算超期费用(新逻辑:前7天不收费,第8天开始双倍收费) + */ + private BigDecimal calculateOverdueCost(MaterialSltAgreementInfo bean, BigDecimal leasePrice, BigDecimal num, long overdueDays) { + BigDecimal overdueCost = BigDecimal.ZERO; + + if (overdueDays <= 7) { + // 超期1~7天不收费 + overdueCost = BigDecimal.ZERO; + } else if (overdueDays <= 15) { + // 超期第8天~第15天双倍计费 + // 前7天不收费,只计算第8天开始的双倍费用 + long doubleBillingDays = overdueDays - 7; + overdueCost = leasePrice.multiply(num).multiply(new BigDecimal(doubleBillingDays)).multiply(new BigDecimal(2)); + } + + return overdueCost.setScale(GlobalConstants.INT_2, RoundingMode.HALF_UP); + } + + /** + * 计算超期天数(只关注日期,不考虑时分秒) + */ + private long calculateOverdueDays(Date materialReturnTime, Date teamExitTime) { + if (materialReturnTime == null || teamExitTime == null) { + return 0; + } + + Calendar returnCal = Calendar.getInstance(); + returnCal.setTime(materialReturnTime); + resetTimeToZero(returnCal); + + Calendar exitCal = Calendar.getInstance(); + exitCal.setTime(teamExitTime); + resetTimeToZero(exitCal); + + long diffInMillies = returnCal.getTimeInMillis() - exitCal.getTimeInMillis(); + return diffInMillies / (24 * 60 * 60 * 1000); + } + + private void resetTimeToZero(Calendar calendar) { + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + } + + private Date simulateTeamExitTime() { + // 模拟班组退场时间为30天前 + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH, -30); + return calendar.getTime(); + } + + public String handleData(List list){ + StringBuilder sb = new StringBuilder(); + Set set = new HashSet<>(list); + for (String str : set) { + sb.append(str).append("、"); + } + return org.apache.commons.lang3.StringUtils.removeEnd(sb.toString(), "、"); + } + + /** + * 导出结算单 + * @throws Exception 异常 + */ + private void expOutExcel(HttpServletResponse response, List list, String filename,String projectName,String unitName,String actualTimeAndName,BigDecimal totalCost,int type) throws Exception { + if (list != null) { + List> results = new ArrayList<>(); + for (MaterialSltAgreementInfo bean : list) { + Map maps = outReceiveDetailsBeanToMap(bean, type, 0); + results.add(maps); + } + List headers = receiveDetailsHeader(type,0); + HSSFWorkbook workbook = PoiOutPage.excelForcheckClz(results, headers, filename,projectName,unitName,actualTimeAndName,totalCost); + OutputStream out = null; + response.setContentType("application/vnd.ms-excel;charset=UTF-8"); + response.addHeader("Content-Disposition", + "attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".xls"); + response.setHeader("Pragma", "No-cache"); + out = response.getOutputStream(); + workbook.write(out); + out.flush(); + out.close(); + }else{ + List> results = new ArrayList<>(); + List headers = receiveDetailsHeader(type,0); + HSSFWorkbook workbook = PoiOutPage.excel(results, headers, filename); + OutputStream out = null; + response.setContentType("application/vnd.ms-excel;charset=UTF-8"); + response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".xls"); + response.setHeader("Pragma", "No-cache"); + out = response.getOutputStream(); + workbook.write(out); + out.flush(); + out.close(); + } + } + + /** + * 租赁费用单数据转换 + */ + private Map outReceiveDetailsBeanToMap(MaterialSltAgreementInfo bean,int type,int flag) { + // 创建一个SimpleDateFormat对象,定义日期格式 + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Map maps = new LinkedHashMap<>(); + if(type==1){ +// maps.put("unitName", bean.getUnitName()); +// maps.put("projectName", bean.getProjectName()); + if (flag==0){ + maps.put("unitName", bean.getUnitName()); + maps.put("typeName", bean.getTypeName()); + maps.put("modelName", bean.getModelName()); + maps.put("mtUnitName", bean.getMtUnitName()); + maps.put("leasePrice", bean.getLeasePrice()); + maps.put("num", bean.getNum()); + maps.put("startTime", bean.getStartTime()==null ? null:dateFormat.format(bean.getStartTime())); + maps.put("endTime", bean.getEndTime()==null ? null:dateFormat.format(bean.getEndTime())); + maps.put("leaseDays", bean.getLeaseDays()); + maps.put("costs", bean.getCosts().setScale(2, RoundingMode.HALF_UP)); + }else { + maps.put("unitName", bean.getUnitName()); + maps.put("typeName", bean.getTypeName()); + maps.put("modelName", bean.getModelName()); + maps.put("mtUnitName", bean.getMtUnitName()); + maps.put("leasePrice", bean.getLeasePrice()); + maps.put("num", bean.getNum()); + maps.put("startTime", bean.getStartTime()==null ? null:dateFormat.format(bean.getStartTime())); + maps.put("endTime", bean.getEndTime()==null ? null:dateFormat.format(bean.getEndTime())); + maps.put("leaseDays", bean.getLeaseDays()); + maps.put("costs", bean.getCosts().setScale(2, RoundingMode.HALF_UP)); + maps.put("t1", ""); + } + }else if(type==2) { + if(flag==0){ + maps.put("unitName", bean.getUnitName()); + maps.put("typeName", bean.getTypeName()); + maps.put("modelName", bean.getModelName()); + maps.put("mtUnitName", bean.getMtUnitName()); + maps.put("num", bean.getNum()); + maps.put("costs", bean.getCosts()); + }else{ + maps.put("unitName", bean.getUnitName()); + maps.put("typeName", bean.getTypeName()); + maps.put("modelName", bean.getModelName()); + maps.put("mtUnitName", bean.getMtUnitName()); + maps.put("num", bean.getNum()); + maps.put("costs", bean.getCosts()); + maps.put("t1", ""); + maps.put("t2", ""); + maps.put("t3", ""); + maps.put("t4", ""); + maps.put("t5", ""); + } + }else if(type==3){ + if(flag==0){ + maps.put("unitName", bean.getUnitName()); + maps.put("typeName", bean.getTypeName()); + maps.put("modelName", bean.getModelName()); + maps.put("mtUnitName", bean.getMtUnitName()); + maps.put("num", bean.getNum()); + maps.put("partType", bean.getPartType()); + maps.put("costs", bean.getCosts()); + }else{ + maps.put("unitName", bean.getUnitName()); + maps.put("typeName", bean.getTypeName()); + maps.put("modelName", bean.getModelName()); + maps.put("mtUnitName", bean.getMtUnitName()); + maps.put("num", bean.getNum()); + maps.put("partType", bean.getPartType()); + maps.put("costs", bean.getCosts()); + maps.put("t1", ""); + maps.put("t2", ""); + maps.put("t3", ""); + maps.put("t4", ""); + } + }else if(type==4){ + if(flag==0){ + maps.put("unitName", bean.getUnitName()); + maps.put("typeName", bean.getTypeName()); + maps.put("modelName", bean.getModelName()); + maps.put("mtUnitName", bean.getMtUnitName()); + maps.put("num", bean.getNum()); + maps.put("partType", bean.getPartType()); + maps.put("costs", bean.getCosts()); + }else{ + maps.put("unitName", bean.getUnitName()); + maps.put("typeName", bean.getTypeName()); + maps.put("modelName", bean.getModelName()); + maps.put("mtUnitName", bean.getMtUnitName()); + maps.put("num", bean.getNum()); + maps.put("partType", bean.getPartType()); + maps.put("costs", bean.getCosts()); + maps.put("t1", ""); + maps.put("t2", ""); + maps.put("t3", ""); + maps.put("t4", ""); + } + } + else if(type==5){ + maps.put("unitName", bean.getUnitName()); + maps.put("typeName", bean.getTypeName()); + maps.put("modelName", bean.getModelName()); + maps.put("mtUnitName", bean.getUnitName()); + maps.put("leasePrice", bean.getLeasePrice()); + maps.put("num", bean.getReduceNum()); + maps.put("startTime", bean.getStartTime()==null ? null:dateFormat.format(bean.getStartTime())); + maps.put("endTime", bean.getEndTime()==null ? null:dateFormat.format(bean.getEndTime())); + maps.put("leaseDays", bean.getLeaseDays()); + maps.put("remark", bean.getRemark()); + maps.put("costs", bean.getCosts()); + } + return maps; + } + + /** + * 租赁费用单表头 + * @return + */ + private List receiveDetailsHeader(int type,int flag) { + ArrayList list = new ArrayList(); + if(type==1){ +// list.add("结算单位"); +// list.add("结算工程"); + + if (flag==0){ + list.add("单位名称"); + list.add("设备名称"); + list.add("规格型号"); + list.add("计量单位"); + list.add("租赁单价"); + list.add("租赁数量"); + list.add("租赁日期"); + list.add("归还日期"); + list.add("租赁天数"); + list.add("租赁费用(元)"); + }else { + list.add("单位名称"); + list.add("设备名称"); + list.add("规格型号"); + list.add("计量单位"); + list.add("租赁单价"); + list.add("租赁数量"); + list.add("租赁日期"); + list.add("归还日期"); + list.add("租赁天数"); + list.add("租赁费用(元)"); + list.add(" "); + } + }else if(type==2){ + if(flag==0){ + list.add("单位名称"); + list.add("设备名称"); + list.add("规格型号"); + list.add("计量单位"); + list.add("丢失数量"); + list.add("丢失费用(元)"); + }else{ + list.add("单位名称"); + list.add("设备名称"); + list.add("规格型号"); + list.add("计量单位"); + list.add("丢失数量"); + list.add("丢失费用(元)"); + list.add(" "); + list.add(" "); + list.add(" "); + list.add(" "); + list.add(" "); + } + + }else if(type==3){ + if(flag==0){ + list.add("单位名称"); + list.add("设备名称"); + list.add("规格型号"); + list.add("计量单位"); + list.add("维修数量"); + list.add("是否收费"); + list.add("维修费用(元)"); + }else{ + list.add("单位名称"); + list.add("设备名称"); + list.add("规格型号"); + list.add("计量单位"); + list.add("维修数量"); + list.add("是否收费"); + list.add("维修费用(元)"); + list.add(""); + list.add(""); + list.add(""); + list.add(" "); + } + }else if(type==4){ + if(flag==0){ + list.add("单位名称"); + list.add("设备名称"); + list.add("规格型号"); + list.add("计量单位"); + list.add("报废数量"); + list.add("是否收费"); + list.add("报废费用(元)"); + }else{ + list.add("单位名称"); + list.add("设备名称"); + list.add("规格型号"); + list.add("计量单位"); + list.add("报废数量"); + list.add("是否收费"); + list.add("报废费用(元)"); + list.add(""); + list.add(""); + list.add(""); + list.add(" "); + } + }else if (type==5){ + list.add("单位名称"); + list.add("设备名称"); + list.add("规格型号"); + list.add("单位"); + list.add("租赁单价"); + list.add("减免数量"); + list.add("减免开始日期"); + list.add("减免结束日期"); + list.add("减免天数"); + list.add("减免原因"); + list.add("减免费用(元)"); + } + return list; + } + /** * 进行结算审批 */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialSltAgreementInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialSltAgreementInfo.java index 48cf1e55..fa34e812 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialSltAgreementInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialSltAgreementInfo.java @@ -54,6 +54,8 @@ public class MaterialSltAgreementInfo extends BaseEntity { @ApiModelProperty(value = "机具规格id") private Long typeId; + @ApiModelProperty(value = "是否是整数") + private Integer unitValue; /** * 设备名称 */ @@ -181,6 +183,12 @@ public class MaterialSltAgreementInfo extends BaseEntity { @ApiModelProperty(value = "工程标段ID") private Long projectId; + /** + * i8工程工程ID + */ + @ApiModelProperty(value = "i8工程工程ID") + private String proId; + @ApiModelProperty(value = "结算状态") private String sltStatus; @@ -244,4 +252,11 @@ public class MaterialSltAgreementInfo extends BaseEntity { //结算费用 private BigDecimal totalCostAll; + + /** + * 实际出场时间 + */ + private String actualExitTime; + + private BigDecimal reduceNum; } 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 index ffde166e..fa94da44 100644 --- 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 @@ -129,4 +129,9 @@ public class MaterialSltInfoVo { @JsonFormat(pattern = "yyyy-MM-dd") private Date applyTime; + /** + * 实际出场时间 + */ + @Excel(name = "实际出场时间") + private String actualExitTime; } 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 index 0a8f9105..916eabb5 100644 --- 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 @@ -1,6 +1,7 @@ package com.bonus.material.clz.mapper; import com.bonus.common.biz.domain.ProjectTreeNode; +import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo; import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; import com.bonus.material.common.domain.vo.AgreementVo; @@ -118,4 +119,8 @@ public interface ClzSltAgreementInfoMapper { * 插入协议申请详情 -- 丢失 */ int insertSltAgreementDetailLose(@Param("list") List list, @Param("id") Long id); + + List getClzTeamList(MaterialSltAgreementInfo bean); + + String getTeamOutTime(MaterialSltAgreementInfo materialSltAgreementInfo); } 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 index 563342a5..7ea7fa21 100644 --- 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 @@ -3,6 +3,7 @@ package com.bonus.material.clz.service; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.basic.domain.BmProject; import com.bonus.material.clz.domain.ClzSltApplyDTO; +import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo; import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; import com.bonus.material.common.domain.dto.SelectDto; @@ -22,6 +23,20 @@ public interface ClzSltAgreementInfoService { */ AjaxResult costExamine(SltAgreementApply sltAgreementApply); + /** + * 获取材料站结算申请工程下拉选 + * @param bean + * @return + */ + List getClzProjectList(MaterialRetainedEquipmentInfo bean); + + /** + * 获取材料站结算申请班组下拉选 + * @param bean + * @return + */ + List getClzTeamList(MaterialSltAgreementInfo bean); + /** * 根据条件获取协议结算列表 */ 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 a03188b2..1746a9b9 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 @@ -11,12 +11,15 @@ import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; import com.bonus.material.basic.domain.BmProject; import com.bonus.material.clz.domain.ClzSltApplyDTO; +import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo; 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.mapper.MaterialMachineMapper; import com.bonus.material.clz.service.ClzSltAgreementInfoService; import com.bonus.material.common.domain.dto.SelectDto; import com.bonus.material.common.domain.vo.AgreementVo; +import com.bonus.material.common.mapper.SelectMapper; import com.bonus.material.settlement.domain.SltAgreementApply; import com.bonus.material.settlement.domain.SltAgreementInfo; import com.bonus.material.settlement.domain.SltAgreementReduce; @@ -48,6 +51,12 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic @Resource private ClzSltAgreementInfoMapper clzSltAgreementInfoMapper; + @Resource + private MaterialMachineMapper materialMachineMapper; + + @Resource + private SelectMapper mapper; + /** * 进行结算审批 * @@ -100,6 +109,46 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic } } + /** + * 获取材料站结算申请工程下拉选 + * @param bean + * @return + */ + @Override + public List getClzProjectList(MaterialRetainedEquipmentInfo bean) { + List list = materialMachineMapper.getProjectList(bean); + if (list.size()>0){ + // 查询所有未结算的工程 + List projectIdList = mapper.getUnsettledProId(); + // 使用 HashSet 来加速查找过程 + Set unsettledProjectIds = new HashSet<>(projectIdList); + // 过滤掉不在未结算工程集合内的工程 + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + MaterialRetainedEquipmentInfo info = iterator.next(); + String proId = info.getProId() != null ? + info.getProId().toString() : null; + + if (proId == null || !unsettledProjectIds.contains(proId)) { + iterator.remove(); + } + } + } + return list; + } + + /** + * 获取材料站结算申请班组下拉选 + * @param bean + * @return + */ + @Override + public List getClzTeamList(MaterialSltAgreementInfo bean) { + List teamList = clzSltAgreementInfoMapper.getClzTeamList(bean); + return teamList; + } + + /** * 根据条件获取协议结算列表 * @param bean 查询条件 @@ -168,6 +217,9 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic List reductionList = getReductionList(info); sltInfoVo.setLeaseList(leaseList); + if(!CollectionUtils.isEmpty(leaseList)){ + sltInfoVo.setActualExitTime(leaseList.get(0).getActualExitTime()); + } sltInfoVo.setRepairList(repairList); sltInfoVo.setScrapList(scrapList); sltInfoVo.setLoseList(loseList); @@ -308,6 +360,8 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic sltInfoVo.setUnitName(sltInfoVo.getScrapList().get(0).getUnitName()); } + + // 合计一下总费用 sltInfoVo.setTotalCostAll(Optional.ofNullable(sltInfoVo.getLeaseCost()).orElse(BigDecimal.ZERO) .add(Optional.ofNullable(sltInfoVo.getRepairCost()).orElse(BigDecimal.ZERO)) @@ -721,6 +775,13 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic */ private List getLeaseList(MaterialSltAgreementInfo info) { List oneOfList = clzSltAgreementInfoMapper.getLeaseList(info); + //设定班组实际出场时间 + if(!oneOfList.isEmpty()){ + String date = clzSltAgreementInfoMapper.getTeamOutTime(oneOfList.get(0)); + if(date!=null && !date.isEmpty()){ + oneOfList.get(0).setActualExitTime(date); + } + } List leaseList = new ArrayList<>(oneOfList); for (MaterialSltAgreementInfo bean : 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 index 744479d4..490a3d85 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 @@ -94,20 +94,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + update clz_bm_agreement_info