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 e8d64caa..c3e2fe5b 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 @@ -8,6 +8,7 @@ import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.RegionUtil; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -205,6 +206,193 @@ public class PoiOutPage { return workbook; } + public static HSSFWorkbook excelForcheckTwo(List> result, List list, String filename, String unit, String projectName, 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 = createProjectAndUnitRow(sheet, rowNum, projectName, unit, 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 = createTotalRow(sheet, rowNum, list, totalCost, headerStyle); + return workbook; + } + + public static HSSFWorkbook excelForcheckAll(List> resultLease,List> resultLose,List> resultRepair,List> resultScrap, + List listLease,List listLose,List listRepair,List listScrap, String filename, String unit, String projectName, + BigDecimal totalCostLease, BigDecimal totalCostLose, BigDecimal totalCostRepair, BigDecimal totalCostScrap) { + // 创建工作簿和工作表 + 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 = createProjectAndUnitRow(sheet, rowNum, projectName, unit, 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 = createTotalRow(sheet, rowNum, listLease, totalCostLease, 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 = createTotalRow(sheet, rowNum, listLose, totalCostLose, 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 = createTotalRow(sheet, rowNum, listRepair, totalCostRepair, 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 = createTotalRow(sheet, rowNum, listScrap, totalCostScrap, headerStyle); + + //合计 + BigDecimal totalCostAll = totalCostLease.add(totalCostLose).add(totalCostRepair).add(totalCostScrap); + rowNum = createTotalRowAll(sheet, rowNum, listScrap, totalCostAll, headerStyle); + + return workbook; + } + + + /** + * 在数据的最后一行添加费用小计 + * + * @param sheet 工作表 + * @param rowNum 当前行号 + * @param list 列名列表 + * @param totalCost 总费用 + * @param headerStyle 表头样式 + */ + private static int createTotalRow(HSSFSheet sheet, int rowNum, List list, BigDecimal totalCost, HSSFCellStyle headerStyle) { + HSSFRow row = sheet.createRow(rowNum++); + HSSFCell cell = row.createCell(0); + cell.setCellStyle(headerStyle); + cell.setCellValue("费用小计:"); + + sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, (short) (list.size() - 2))); + CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 1, (short) (list.size() - 2)); + // 设置边框样式 + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet); + // 假设总费用应该放在最后一列 + int totalCostColumnIndex = list.size() - 1; + cell = row.createCell(totalCostColumnIndex); + cell.setCellStyle(headerStyle); + cell.setCellValue(String.format("%.2f", totalCost)); + + return rowNum; + } + /** + * 在数据的最后一行添加合计费用 + * + * @param sheet 工作表 + * @param rowNum 当前行号 + * @param list 列名列表 + * @param totalCost 总费用 + * @param headerStyle 表头样式 + */ + private static int createTotalRowAll(HSSFSheet sheet, int rowNum, List list, BigDecimal totalCost, HSSFCellStyle headerStyle) { + HSSFRow row = sheet.createRow(rowNum++); + HSSFCell cell = row.createCell(0); + cell.setCellStyle(headerStyle); + cell.setCellValue("合计:"); + + sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, (short) (list.size() - 2))); + CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 1, (short) (list.size() - 2)); + // 设置边框样式 + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet); + // 假设总费用应该放在最后一列 + int totalCostColumnIndex = list.size() - 1; + cell = row.createCell(totalCostColumnIndex); + cell.setCellStyle(headerStyle); + cell.setCellValue(String.format("%.2f", totalCost)); + + return rowNum; + } + /** * 创建标题行 */ @@ -218,6 +406,107 @@ public class PoiOutPage { return rowNum; } + /** + * 创建标题行以及样式 + */ + private static int createTitleRowStyle(HSSFSheet sheet, int rowNum, String filename, HSSFCellStyle titleStyle, int nColumn) { + HSSFRow row = sheet.createRow(rowNum++); + row.setHeightInPoints(30); + sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, (short) (nColumn - 1))); + HSSFCell cell = row.createCell(0); + cell.setCellStyle(titleStyle); + cell.setCellValue(filename); + // 添加边框 + CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, rowNum - 1, (short) (nColumn - 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); + + return rowNum; + } + + /** + * 创建标题行以及样式--all + */ + private static int createTitleRowStyleCost(HSSFSheet sheet, int rowNum, String filename, HSSFCellStyle titleStyle, int nColumn) { + HSSFRow row = sheet.createRow(rowNum++); + row.setHeightInPoints(30); + sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 0, (short) (nColumn - 1))); + HSSFCell cell = row.createCell(0); + cell.setCellStyle(titleStyle); + cell.setCellValue(filename); + // 添加边框 + CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (nColumn - 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); + + return rowNum; + } + + /** + * 创建结算单位和结算工程行 + */ + private static int createProjectAndUnitRow(HSSFSheet sheet, int rowNum, String projectName, String unitName,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); + + + // 添加边框 + CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 2, rowNum - 2, 0, 1); + CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 2, rowNum - 2, 2, (short) (nColumn - 1)); + CellRangeAddress cellRange3 = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1); + CellRangeAddress cellRange4 = 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); + + + return rowNum; + } + /** * 创建项目名称和单位信息行 */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java index 76f48ada..73f0bf1e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java @@ -1,13 +1,32 @@ package com.bonus.material.settlement.controller; +import java.io.OutputStream; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.servlet.http.HttpServletResponse; + +import cn.hutool.core.convert.Convert; +import com.bonus.common.biz.config.PoiOutPage; +import com.bonus.common.biz.enums.TmTaskTypeEnum; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; +import com.bonus.material.lease.domain.vo.LeaseOutVo; import com.bonus.material.settlement.domain.SltAgreementApply; import com.bonus.material.settlement.domain.vo.SltInfoVo; +import com.bonus.material.settlement.domain.vo.SltLeaseInfo; +import com.bonus.material.settlement.mapper.SltAgreementInfoMapper; +import com.bonus.material.task.domain.TmTask; +import com.bonus.material.task.mapper.TmTaskMapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -35,11 +54,18 @@ import com.bonus.common.core.web.page.TableDataInfo; @Api(tags = "结算信息接口") @RestController @RequestMapping("/slt_agreement_info") +@Slf4j public class SltAgreementInfoController extends BaseController { @Autowired private ISltAgreementInfoService sltAgreementInfoService; + @Autowired + private SltAgreementInfoMapper sltAgreementInfoMapper; + + @Autowired + private TmTaskMapper taskMapper; + /** * 查询结算信息列表 */ @@ -114,6 +140,430 @@ public class SltAgreementInfoController extends BaseController { util.exportExcel(response, list, "结算信息数据"); } + /** + * 导出结算单 + * @param response + * @param list + * @param filename + + * @throws Exception + */ + private void expOutExcel(HttpServletResponse response, List list, String filename,String projectName,String unitName,BigDecimal totalCost,int type) + throws Exception { + if (list != null) { + List> results = new ArrayList>(); + int size = list.size(); + for (int i = 0; i < size; i++) { + SltLeaseInfo bean = list.get(i); + Map maps = outReceiveDetailsBeanToMap(bean,type,0); + results.add(maps); + } + List headers = receiveDetailsHeader(type,0); + HSSFWorkbook workbook = PoiOutPage.excelForcheckTwo(results, headers, filename,projectName,unitName,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(); + } + } + /** + * 导出结算单--all + * @throws Exception + */ + private void expOutExcelAll(HttpServletResponse response, List lease,List lose,List repair,List scrap, + String filename,String projectName,String unitName,BigDecimal totalCostLease,BigDecimal totalCostLose,BigDecimal totalCostRepair,BigDecimal totalCostScrap) + throws Exception { + List> resultsLease = new ArrayList>(); + List> resultsLose = new ArrayList>(); + List> resultsRepair = new ArrayList>(); + List> resultsScrap = new ArrayList>(); + + if (lease!= null) { + int sizeLease = lease.size(); + for (int i = 0; i < sizeLease; i++) { + SltLeaseInfo bean = lease.get(i); + Map maps = outReceiveDetailsBeanToMap(bean,1,1); + resultsLease.add(maps); + } + } + if (lose!= null) { + int sizeLose = lose.size(); + for (int i = 0; i < sizeLose; i++) { + SltLeaseInfo bean = lose.get(i); + Map maps = outReceiveDetailsBeanToMap(bean,2,1); + resultsLose.add(maps); + } + } + if (repair!= null) { + int sizeRepair = repair.size(); + for (int i = 0; i < sizeRepair; i++) { + SltLeaseInfo bean = repair.get(i); + Map maps = outReceiveDetailsBeanToMap(bean,3,1); + resultsRepair.add(maps); + } + } + if (scrap!= null) { + int sizeScrap = scrap.size(); + for (int i = 0; i < sizeScrap; i++) { + SltLeaseInfo bean = scrap.get(i); + Map maps = outReceiveDetailsBeanToMap(bean,4,1); + resultsScrap.add(maps); + } + } + + List headersLease = receiveDetailsHeader(1,1); + List headersLose = receiveDetailsHeader(2,1); + List headersRepair = receiveDetailsHeader(3,1); + List headersScrap = receiveDetailsHeader(4,1); + HSSFWorkbook workbook = PoiOutPage.excelForcheckAll(resultsLease,resultsLose,resultsRepair,resultsScrap, headersLease,headersLose,headersRepair,headersScrap, filename,projectName,unitName,totalCostLease,totalCostLose,totalCostRepair,totalCostScrap); + 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(); + + } + + /** + * 租赁费用单数据转换 + * @param bean + * @return + */ + private Map outReceiveDetailsBeanToMap(SltLeaseInfo 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()); + 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 if(type==2) { + if(flag==0){ + 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("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", ""); + } + }else if(type==3){ + if(flag==0){ + 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("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", ""); + } + }else if(type==4){ + if(flag==0){ + 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("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", ""); + } + } + return maps; + } + + /** + * 租赁费用单表头 + * @return + */ + private List receiveDetailsHeader(int type,int flag) { + ArrayList list = new ArrayList(); + if(type==1){ +// 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("丢失费用(元)"); + }else{ + 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("维修费用(元)"); + }else{ + 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("报废费用(元)"); + }else{ + list.add("设备名称"); + list.add("规格型号"); + list.add("计量单位"); + list.add("报废数量"); + list.add("是否收费"); + list.add("报废费用(元)"); + list.add(""); + list.add(""); + list.add(""); + } + } + return list; + } + + /** + * 导出租赁明细 + */ + @ApiOperation(value = "导出结算信息列表") + @PreventRepeatSubmit +// @RequiresPermissions("settlement:info:export") + @SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出租赁明细") + @PostMapping("/exportLease") + public void exportLease(HttpServletResponse response, SltAgreementInfo sltAgreementInfo) { + try { + String fileName = "租赁费用明细表"; + String projectName = sltAgreementInfo.getProjectName(); + String unitName = sltAgreementInfo.getUnitName(); + BigDecimal totalCost = BigDecimal.valueOf(0.00); + List leaseList = new ArrayList<>(); + + List oneOfList = sltAgreementInfoMapper.getLeaseList(sltAgreementInfo); + leaseList.addAll(oneOfList); + for (SltAgreementInfo bean : leaseList) { + if (null == bean.getLeasePrice()) { + bean.setLeasePrice(BigDecimal.valueOf(0.00)); + }else{ + bean.setLeasePrice(bean.getLeasePrice().setScale(2, BigDecimal.ROUND_HALF_UP)); + } + + if (null == bean.getNum()) { + bean.setNum(BigDecimal.valueOf(0L)); + } + if (null == bean.getLeaseDays()) { + bean.setLeaseDay(0L); + } + BigDecimal leasePrice = bean.getLeasePrice(); + BigDecimal num = bean.getNum(); + BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); + BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(2, BigDecimal.ROUND_HALF_UP); + if(costs!=null){ + totalCost = totalCost.add(costs); + } + bean.setCosts(costs); + } + List lease = Convert.toList(SltLeaseInfo.class, leaseList); + expOutExcel(response,lease,fileName,projectName,unitName,totalCost,1); + } catch (Exception e) { + log.error(e.toString(), e); + } + } + + /** + * 导出丢失费用明细 + */ + @ApiOperation(value = "导出结算信息列表") + @PreventRepeatSubmit +// @RequiresPermissions("settlement:info:export") + @SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出丢失费用明细") + @PostMapping("/exportLose") + public void exportLose(HttpServletResponse response, SltAgreementInfo sltAgreementInfo) { + try { + String fileName = "丢失费用明细表"; + String projectName = sltAgreementInfo.getProjectName(); + String unitName = sltAgreementInfo.getUnitName(); + BigDecimal totalCost = BigDecimal.valueOf(0.00); + List loseList = new ArrayList<>(); + + List oneOfList = sltAgreementInfoMapper.getLoseList(sltAgreementInfo); + loseList.addAll(oneOfList); + for (SltAgreementInfo bean : loseList) { + if (null == bean.getBuyPrice()) { + bean.setBuyPrice(BigDecimal.valueOf(0.00)); + } + if (null == bean.getNum()) { + bean.setNum(BigDecimal.valueOf(0L)); + } + BigDecimal buyPrice = bean.getBuyPrice(); + BigDecimal num = bean.getNum(); + // 原价 x 数量 + BigDecimal costs = buyPrice.multiply(num); + if(costs!=null){ + totalCost = totalCost.add(costs); + } + //计算租赁费用 + bean.setCosts(costs); + } + List lose = Convert.toList(SltLeaseInfo.class, loseList); + expOutExcel(response,lose,fileName,projectName,unitName,totalCost,2); + } catch (Exception e) { + log.error(e.toString(), e); + } + } + + /** + * 导出维修费用明细 + */ + @ApiOperation(value = "导出结算信息列表") + @PreventRepeatSubmit +// @RequiresPermissions("settlement:info:export") + @SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出维修费用明细") + @PostMapping("/exportRepair") + public void exportRepair(HttpServletResponse response, SltAgreementInfo sltAgreementInfo) { + try { + String fileName = "维修费用明细表"; + String projectName = sltAgreementInfo.getProjectName(); + String unitName = sltAgreementInfo.getUnitName(); + BigDecimal totalCost = BigDecimal.valueOf(0.00); + List repairList = new ArrayList<>(); + + List taskList = taskMapper.getTaskIdList(sltAgreementInfo); + if (null != taskList && !taskList.isEmpty()) { + List repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(taskList); + repairList.addAll(repairDetailsList); + } + for (SltAgreementInfo bean : repairList) { + if (bean.getCosts()!=null && (bean.getPartType().equals("收费"))) { + totalCost = totalCost.add(bean.getCosts()); + } + } + List repair = Convert.toList(SltLeaseInfo.class, repairList); + expOutExcel(response,repair,fileName,projectName,unitName,totalCost,3); + } catch (Exception e) { + log.error(e.toString(), e); + } + } + + /** + * 导出报废费用明细 + */ + @ApiOperation(value = "导出结算信息列表") + @PreventRepeatSubmit +// @RequiresPermissions("settlement:info:export") + @SysLog(title = "报废信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出报废费用明细") + @PostMapping("/exportScrap") + public void exportScrap(HttpServletResponse response, SltAgreementInfo sltAgreementInfo) { + try { + String fileName = "报废费用明细表"; + String projectName = sltAgreementInfo.getProjectName(); + String unitName = sltAgreementInfo.getUnitName(); + BigDecimal totalCost = BigDecimal.valueOf(0.00); + + List scrapList = new ArrayList<>(); + List taskList = taskMapper.getTaskIdList(sltAgreementInfo); + if (null != taskList && !taskList.isEmpty()) { + List scrapDetailsList = sltAgreementInfoMapper.getScrapDetailsList(taskList); + scrapList.addAll(scrapDetailsList); + } + for (SltAgreementInfo bean : scrapList) { + if (bean.getCosts()!=null && (bean.getPartType().equals("收费"))) { + totalCost = totalCost.add(bean.getCosts()); + } + } + List scrap = Convert.toList(SltLeaseInfo.class, scrapList); + expOutExcel(response,scrap,fileName,projectName,unitName,totalCost,4); + } catch (Exception e) { + log.error(e.toString(), e); + } + } + /** * 获取结算信息详细信息 */ @@ -140,6 +590,107 @@ public class SltAgreementInfoController extends BaseController { } } + /** + * 导出结算信息列表--all + */ + @ApiOperation(value = "导出结算信息列表") + @PreventRepeatSubmit +// @RequiresPermissions("settlement:info:export") + @SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出租赁明细") + @PostMapping("/exportAll") + public void exportAll(HttpServletResponse response, SltAgreementInfo sltAgreementInfo) { + try { + String fileName = "结算明细"; + String projectName = sltAgreementInfo.getProjectName(); + String unitName = sltAgreementInfo.getUnitName(); + + //租赁费用明细 + BigDecimal totalCostLease = BigDecimal.valueOf(0.00); + List leaseList = new ArrayList<>(); + List oneOfListLease = sltAgreementInfoMapper.getLeaseList(sltAgreementInfo); + leaseList.addAll(oneOfListLease); + for (SltAgreementInfo bean : leaseList) { + if (null == bean.getLeasePrice()) { + bean.setLeasePrice(BigDecimal.valueOf(0.00)); + } + if (null == bean.getNum()) { + bean.setNum(BigDecimal.valueOf(0L)); + } + if (null == bean.getLeaseDays()) { + bean.setLeaseDay(0L); + } + BigDecimal leasePrice = bean.getLeasePrice(); + BigDecimal num = bean.getNum(); + BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); + BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays); + if(costs!=null){ + totalCostLease = totalCostLease.add(costs); + } + bean.setCosts(costs); + } + List lease = Convert.toList(SltLeaseInfo.class, leaseList); + + //丢失费用明细 + BigDecimal totalCostLose = BigDecimal.valueOf(0.00); + List loseList = new ArrayList<>(); + + List oneOfListLose = sltAgreementInfoMapper.getLoseList(sltAgreementInfo); + loseList.addAll(oneOfListLose); + for (SltAgreementInfo bean : loseList) { + if (null == bean.getBuyPrice()) { + bean.setBuyPrice(BigDecimal.valueOf(0.00)); + } + if (null == bean.getNum()) { + bean.setNum(BigDecimal.valueOf(0L)); + } + BigDecimal buyPrice = bean.getBuyPrice(); + BigDecimal num = bean.getNum(); + // 原价 x 数量 + BigDecimal costs = buyPrice.multiply(num); + if(costs!=null){ + totalCostLose = totalCostLose.add(costs); + } + //计算租赁费用 + bean.setCosts(costs); + } + List lose = Convert.toList(SltLeaseInfo.class, loseList); + + //维修费用明细 + BigDecimal totalCostRepair = BigDecimal.valueOf(0.00); + List repairList = new ArrayList<>(); + List taskListRepair = taskMapper.getTaskIdList(sltAgreementInfo); + if (null != taskListRepair && !taskListRepair.isEmpty()) { + List repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(taskListRepair); + repairList.addAll(repairDetailsList); + } + for (SltAgreementInfo bean : repairList) { + if (bean.getCosts()!=null && (bean.getPartType().equals("收费"))) { + totalCostRepair = totalCostRepair.add(bean.getCosts()); + } + } + List repair = Convert.toList(SltLeaseInfo.class, repairList); + + //报废费用明细 + BigDecimal totalCostScrap = BigDecimal.valueOf(0.00); + List scrapList = new ArrayList<>(); + List taskListScrap = taskMapper.getTaskIdList(sltAgreementInfo); + if (null != taskListScrap && !taskListScrap.isEmpty()) { + List scrapDetailsList = sltAgreementInfoMapper.getScrapDetailsList(taskListScrap); + scrapList.addAll(scrapDetailsList); + } + for (SltAgreementInfo bean : scrapList) { + if (bean.getCosts()!=null && (bean.getPartType().equals("收费"))) { + totalCostScrap = totalCostScrap.add(bean.getCosts()); + } + } + List scrap = Convert.toList(SltLeaseInfo.class, scrapList); + + expOutExcelAll(response,lease,lose,repair,scrap,fileName,projectName,unitName,totalCostLease,totalCostLose,totalCostRepair,totalCostScrap); + } catch (Exception e) { + log.error(e.toString(), e); + } + } + /** * 修改结算信息 */ @@ -167,4 +718,15 @@ public class SltAgreementInfoController extends BaseController { public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(sltAgreementInfoService.deleteSltAgreementInfoByIds(ids)); } + + + @ApiOperation(value = "提交结算清单") + @PostMapping("/submitCosts") + public AjaxResult submitCosts(@RequestBody SltInfoVo sltInfoVo) { + try { + return toAjax(sltAgreementInfoService.submitCosts(sltInfoVo)); + } catch (Exception e) { + return error("系统错误, " + e.getMessage()); + } + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java index 6bb8b0c8..dea65138 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java @@ -169,6 +169,26 @@ public class SltAgreementInfo extends BaseEntity { @ApiModelProperty(value = "结算状态") private String sltStatus; + /** + * 维修类型 + */ + private String repairType; + + /** + * 是否收费 + */ + private String partType; + + /** + * 费用id + */ + private Long costId; + + /** + * 维修状态 + */ + private String repairStatus; + private String typeModelName; private String maCode; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java index 6fc4b71c..27919272 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltInfoVo.java @@ -1,9 +1,14 @@ package com.bonus.material.settlement.domain.vo; +import com.bonus.common.core.annotation.Excel; import com.bonus.material.settlement.domain.SltAgreementInfo; import com.bonus.material.settlement.domain.SltAgreementRelation; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.math.BigDecimal; +import java.util.Date; import java.util.List; /** @@ -12,6 +17,15 @@ import java.util.List; */ @Data public class SltInfoVo { + + /** + * 结算单位 + */ + private String unitName; + /** + * 结算工程 + */ + private String projectName; /** * 租赁费用列表 */ @@ -31,6 +45,62 @@ public class SltInfoVo { List relations; + /** + * 租赁费用小计 + */ + @ApiModelProperty(value = "租赁费用小计") + private BigDecimal leaseCost; + + /** + * 维修费用小计 + */ + @ApiModelProperty(value = "维修费用小计") + private BigDecimal repairCost; + + /** + * 报废费用小计 + */ + @ApiModelProperty(value = "报废费用小计") + private BigDecimal scrapCost; + + /** + * 丢失费用小计 + */ + @ApiModelProperty(value = "丢失费用小计") + private BigDecimal loseCost; + + /** + * 合计 + */ + @ApiModelProperty(value = "合计") + private BigDecimal totalCostAll; + + @Excel(name = "创建人") + private String createBy; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + private String updateBy; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + /** 协议id */ + + @ApiModelProperty(value = "协议id") + private Long agreementId; + + /** + * 协议编号 + */ + + @ApiModelProperty(value = "协议编号") + private String agreementCode; + + private Long id; //申请id + String cost; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltLeaseInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltLeaseInfo.java new file mode 100644 index 00000000..a2fbeaa2 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/SltLeaseInfo.java @@ -0,0 +1,209 @@ +package com.bonus.material.settlement.domain.vo; + +import com.bonus.common.core.annotation.Excel; +import com.bonus.common.core.web.domain.BaseEntity; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 结算信息对象 slt_agreement_info + * + * @author xsheng + * @date 2024-10-16 + */ + + +@Data +@ToString +public class SltLeaseInfo extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** ID */ + private Long id; + + /** 协议id */ + + @ApiModelProperty(value = "协议id") + private Long agreementId; + + /** + * 协议编号 + */ + + @ApiModelProperty(value = "协议编号") + private String agreementCode; + + /** + * 项目名称 + */ + @Excel(name = "结算单位") + private String unitName; + /** + * 工程名称 + */ + @Excel(name = "结算工程") + private String projectName; + + /** 机具规格id */ + + @ApiModelProperty(value = "机具规格id") + private Long typeId; + + /** + * 设备名称 + */ + @Excel(name = "设备名称") + private String typeName; + /** + * 规格型号 + */ + @Excel(name = "规格型号") + private String modelName; + + /** + * 计量单位 + */ + @Excel(name = "计量单位") + private String mtUnitName; + + /** 租赁单价 */ + @Excel(name = "租赁单价") + @ApiModelProperty(value = "租赁单价") + private BigDecimal leasePrice; + + /** 租赁数量 */ + @Excel(name = "租赁数量") + @ApiModelProperty(value = "领料数量") + private BigDecimal num; + + /** 领料时间 */ + @ApiModelProperty(value = "租赁日期") + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "租赁日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + /** 退料时间 */ + @ApiModelProperty(value = "归还日期") + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "归还日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + /** + * 租赁天数 + */ + @Excel(name = "租赁天数") + private String leaseDays; + + /** + * 租赁费用 + */ + @Excel(name = "租赁费用") + @ApiModelProperty(value = "租赁费用") + private BigDecimal costs; + + /** 机具id */ + + @ApiModelProperty(value = "机具id") + private Long maId; + + + private Integer backNum; + + + /** 0在用1退回 */ + + @ApiModelProperty(value = "0在用1退回") + private String status; + + /** 领料id */ + + @ApiModelProperty(value = "领料id") + private Long leaseId; + + /** 退料id */ + + @ApiModelProperty(value = "退料id") + private Long backId; + + + /** 原值 */ + @ApiModelProperty(value = "原值") + private BigDecimal buyPrice; + + /** 是否结算 */ + + @ApiModelProperty(value = "是否结算") + private String isSlt; + + /** 结算时间 */ + @ApiModelProperty(value = "结算时间") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date sltTime; + + /** $column.columnComment */ + + private Long companyId; + + /** 领用类型(0工程1长期) */ + + private String leaseType; + + /** 调整天数 */ + + @ApiModelProperty(value = "调整天数") + private Long trimDay; + + /** + * 租赁天数 + */ + + @ApiModelProperty(value = "租赁天数") + private Long leaseDay; + + + @ApiModelProperty(value = "往来单位id") + private Long unitId; + + /** + * 工程标段ID + */ + @ApiModelProperty(value = "工程标段ID") + private Long projectId; + + @ApiModelProperty(value = "结算状态") + private String sltStatus; + + /** + * 维修类型 + */ + private String repairType; + + /** + * 是否收费 + */ + private String partType; + + /** + * 费用id + */ + private Long costId; + + /** + * 维修状态 + */ + private String repairStatus; + + private String typeModelName; + + private String maCode; + + private Double useNum; + + private String keyWord; + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java index a0b84d0d..ace92692 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java @@ -7,6 +7,7 @@ import com.bonus.material.ma.domain.Type; import com.bonus.material.settlement.domain.SltAgreementApply; import com.bonus.material.settlement.domain.SltAgreementInfo; import com.bonus.material.settlement.domain.SltAgreementRelation; +import com.bonus.material.settlement.domain.vo.SltInfoVo; import com.bonus.material.task.domain.TmTask; import org.apache.ibatis.annotations.Param; @@ -104,4 +105,52 @@ public interface SltAgreementInfoMapper { * @return */ int deleteSltInfo(@Param("record") LeaseOutDetails leaseOutDetails); + + /** + * 新增结算审核信息 + * + * @param sltInfoVo 结算信息 + * @return 结果 + */ + public int insertSltAgreementApply(SltInfoVo sltInfoVo); + + /** + * 修改结算审核信息 + * + * @param sltInfoVo 结算信息 + * @return 结果 + */ + public int updateBmAgreementStatus(SltInfoVo sltInfoVo); + + /** + * 新增租赁结算明细 + * @param list + * @param id + * @return + */ + int insertSltAgreementDetailLease(@Param("list") List list,@Param("id") Long id); + + /** + * 新增维修结算明细 + * @param list + * @param id + * @return + */ + int insertSltAgreementDetailRepair(@Param("list") List list,@Param("id") Long id); + + /** + * 新增报废结算明细 + * @param list + * @param id + * @return + */ + int insertSltAgreementDetailScrap(@Param("list") List list,@Param("id") Long id); + + /** + * 新增丢失结算明细 + * @param list + * @param id + * @return + */ + int insertSltAgreementDetailLose(@Param("list") List list,@Param("id") Long id); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java index d6529a16..15db82e3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java @@ -70,4 +70,13 @@ public interface ISltAgreementInfoService { * @return 结果 */ public int deleteSltAgreementInfoById(Long id); + + + /** + * 提交结算信息 + * + * @param sltInfoVo 结算信息 + * @return 结果 + */ + public int submitCosts(SltInfoVo sltInfoVo); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java index 260da4d0..074ec99c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java @@ -66,6 +66,12 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { @Override public SltInfoVo getSltInfo(List list) { SltInfoVo sltInfoVo = new SltInfoVo(); + sltInfoVo.setUnitName(list.get(0).getUnitName()); + sltInfoVo.setProjectName(list.get(0).getProjectName()); + BigDecimal leaseCost = BigDecimal.valueOf(0.00); + BigDecimal repairCost = BigDecimal.valueOf(0.00); + BigDecimal scrapCost = BigDecimal.valueOf(0.00); + BigDecimal loseCost = BigDecimal.valueOf(0.00); //租赁费用列表 List leaseList = getLeaseList(list); //维修费用列表 @@ -78,6 +84,31 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { sltInfoVo.setRepairList(repairList); sltInfoVo.setScrapList(scrapList); sltInfoVo.setLoseList(loseList); + + for (SltAgreementInfo lease : leaseList) { + if(lease.getCosts()!=null){ + leaseCost = leaseCost.add(lease.getCosts()); + } + } + for (SltAgreementInfo repair : repairList) { + if(repair.getCosts()!=null && (repair.getPartType().equals("收费"))){ + repairCost = repairCost.add(repair.getCosts()); + } + } + for (SltAgreementInfo scrap : scrapList) { + if(scrap.getCosts()!=null && (scrap.getPartType().equals("收费"))){ + scrapCost = scrapCost.add(scrap.getCosts()); + } + } + for (SltAgreementInfo lose : loseList) { + if(lose.getCosts()!=null){ + loseCost = loseCost.add(lose.getCosts()); + } + } + sltInfoVo.setLeaseCost(leaseCost); + sltInfoVo.setRepairCost(repairCost); + sltInfoVo.setScrapCost(scrapCost); + sltInfoVo.setLoseCost(loseCost); List relations = getRelations(leaseList, repairList, scrapList, loseList, list); sltInfoVo.setRelations(relations); return sltInfoVo; @@ -212,17 +243,19 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { for (SltAgreementInfo bean : leaseList) { if (null == bean.getLeasePrice()) { bean.setLeasePrice(BigDecimal.valueOf(0.00)); + }else{ + bean.setLeasePrice(bean.getLeasePrice().setScale(2, BigDecimal.ROUND_HALF_UP)); } if (null == bean.getNum()) { bean.setNum(BigDecimal.valueOf(0L)); } - if (null == bean.getLeaseDay()) { + if (null == bean.getLeaseDays()) { bean.setLeaseDay(0L); } BigDecimal leasePrice = bean.getLeasePrice(); BigDecimal num = bean.getNum(); - BigDecimal leaseDays = new BigDecimal(bean.getLeaseDay()); - BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays); + BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); + BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(2, BigDecimal.ROUND_HALF_UP); bean.setCosts(costs); } return leaseList; @@ -230,10 +263,17 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { public List getRepairList(List list) { List repairList = new ArrayList<>(); - Integer taskType = TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId(); - for (SltAgreementInfo bean : list) { - List taskList = taskMapper.getTaskList(bean, taskType); - if (null != taskList && !taskList.isEmpty()) { +// Integer taskType = TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId(); +// for (SltAgreementInfo bean : list) { +// List taskList = taskMapper.getTaskList(bean, taskType); +// if (null != taskList && !taskList.isEmpty()) { +// List repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(taskList); +// repairList.addAll(repairDetailsList); +// } +// } + for(SltAgreementInfo bean : list){ + List taskList = taskMapper.getTaskIdList(bean); + if (null!= taskList &&!taskList.isEmpty()) { List repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(taskList); repairList.addAll(repairDetailsList); } @@ -243,29 +283,13 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { public List getScrapList(List list) { List scrapList = new ArrayList<>(); - Integer taskType = TmTaskTypeEnum.TM_TASK_SCRAP.getTaskTypeId(); for (SltAgreementInfo bean : list) { - List taskList = taskMapper.getTaskList(bean, taskType); + List taskList = taskMapper.getTaskIdList(bean); if (null != taskList && !taskList.isEmpty()) { List scrapDetailsList = sltAgreementInfoMapper.getScrapDetailsList(taskList); scrapList.addAll(scrapDetailsList); } } - if (!scrapList.isEmpty()) { - for (SltAgreementInfo bean : scrapList) { - if (null == bean.getBuyPrice()) { - bean.setBuyPrice(BigDecimal.valueOf(0.00)); - } - if (null == bean.getNum()) { - bean.setNum(BigDecimal.valueOf(0L)); - } - BigDecimal buyPrice = bean.getBuyPrice(); - BigDecimal num = bean.getNum(); - BigDecimal costs = buyPrice.multiply(num); - //计算总金额 - bean.setCosts(costs); - } - } return scrapList; } @@ -343,4 +367,35 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { } return relations; } + + /** + * 提交结算信息 + * + * @param sltInfoVo 结算信息 + * @return 结果 + */ + @Override + public int submitCosts(SltInfoVo sltInfoVo) { + sltInfoVo.setCreateTime(DateUtils.getNowDate()); + sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getUserId())); + try { + int countOne = sltAgreementInfoMapper.insertSltAgreementApply(sltInfoVo); + if(countOne!=1){ + throw new ServiceException("slt_agreement_apply新增失败"); + } + // 插入成功后,sltInfoVo 的 id 属性将被自动设置为新生成的主键值 + Long newId = sltInfoVo.getId(); + int countTwo = sltAgreementInfoMapper.updateBmAgreementStatus(sltInfoVo); + if(countTwo!=1){ + throw new ServiceException("bm_agreement_info修改失败"); + } + sltAgreementInfoMapper.insertSltAgreementDetailLease(sltInfoVo.getLeaseList(),newId); + sltAgreementInfoMapper.insertSltAgreementDetailRepair(sltInfoVo.getRepairList(),newId); + sltAgreementInfoMapper.insertSltAgreementDetailScrap(sltInfoVo.getScrapList(),newId); + return sltAgreementInfoMapper.insertSltAgreementDetailLose(sltInfoVo.getLoseList(),newId); + + } catch (Exception e) { + throw new ServiceException("错误信息描述"); + } + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskMapper.java index 91ee1eb8..3df8488f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/task/mapper/TmTaskMapper.java @@ -90,4 +90,6 @@ public interface TmTaskMapper { List getTaskList(@Param("bean") SltAgreementInfo bean, @Param("taskType")Integer taskType); + List getTaskIdList(SltAgreementInfo bean); + } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml index 7972c8b8..cdf3f721 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml @@ -176,8 +176,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select tta.agreement_id as agreementId, - bui.unit_name as unitName, - bp.pro_name as projectName, - sad.type_id as typeId, - sad.ma_id as maId, - mt1.type_name as typeName, - mt.type_name as modelName, - mt.unit_name as mtUnitName, - sum(sad.scrap_num) as num, - mt.buy_price as buyPrice, - case sad.scrap_type when '0' then '自然' when '1' then '人为' else '' end as scrapType, - sad.company_id as companyId - from scrap_apply_details sad - left join tm_task_agreement tta on sad.task_id = tta.task_id - LEFT JOIN bm_agreement_info bai on tta.agreement_id = bai.agreement_id - LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id - LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id - left join ma_type mt on sad.type_id = mt.type_id - left join ma_type mt1 on mt.parent_id = mt1.type_id - where sad.status in ('0','1') + bui.unit_name as unitName, + bp.pro_name as projectName, + rc.id as costId, + rc.type_id as typeId, + rc.ma_id as maId, + mt1.type_name as typeName, + mt.type_name as modelName, + mt.unit_name as mtUnitName, + rc.repair_num as num, + rc.costs as costs, + case rc.part_type when '0' then '不收费' when '1' then '收费' else '' end as partType, + case rc.repair_type when '1' then '内部维修' when '2' then '返厂维修' else '' end as repairType, + rc.company_id as companyId, + case rc.status when '0' then '未审核' when '1' then '已审核' when '2' then '已驳回' else '' end as repairStatus + from repair_cost rc + LEFT JOIN tm_task_agreement tta on rc.task_id = tta.task_id + LEFT JOIN tm_task tt on rc.task_id = tt.task_id + LEFT JOIN bm_agreement_info bai on tta.agreement_id = bai.agreement_id + LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id + LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id + left join ma_type mt on rc.type_id = mt.type_id + left join ma_type mt1 on mt.parent_id = mt1.type_id + where rc.status in ('0','1') and rc.repair_type = '3' - and sad.task_id in + and rc.task_id in #{task.taskId} - group by sad.type_id,sad.ma_id,sad.scrap_type + + \ No newline at end of file