diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java index 93ad426..cbae4b6 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java @@ -568,7 +568,7 @@ public class BackReceiveServiceImpl implements BackReceiveService { applyInfo.setUnitNames(typeTreeNode.getUnitNames()); applyInfo.setTypeId(String.valueOf(typeTreeNode.getTypeId())); applyInfo.setUseNum(typeTreeNode.getNum()); - applyInfo.setBackNum(applyInfo.getPreNum()); + applyInfo.setBackNum(applyInfo.getInCompletedBackNum()); foundMatch = true; break; } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/PoiOutPage.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/PoiOutPage.java index 20f2005..3a1883f 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/PoiOutPage.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/PoiOutPage.java @@ -9,7 +9,10 @@ import org.apache.poi.ss.util.RegionUtil; import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; @@ -264,6 +267,65 @@ public class PoiOutPage { return workbook; } + public static HSSFWorkbook excelForcheckTwoMonth(List> result, List list, String filename, String projectName, String unit, BigDecimal totalCost,BigDecimal totalCostReal,int type,String month) { + // 创建工作簿和工作表 + HSSFWorkbook workbook = new HSSFWorkbook(); + HSSFSheet sheet = workbook.createSheet(); + sheet.setDefaultColumnWidth(16); // 设置列宽 + + // 创建样式 + HSSFCellStyle titleStyle = createTitleStyle(workbook); + HSSFCellStyle headerStyle = createHeaderStyle(workbook); + HSSFCellStyle contentStyle = createCellStyleCost(workbook); + HSSFCellStyle headerStyleNoSide = createHeaderStyleNoSide(workbook); + + // 设置工作簿名称 + workbook.setSheetName(0, filename); + + // 填充标题行 + int rowNum = 0; + rowNum = createTitleRowStyleMonth(sheet, rowNum, filename, titleStyle, list.size()); + rowNum = createProjectAndUnitRowMonth(sheet, rowNum, projectName, unit, titleStyle, list.size(),type,month); + + // 填充表头 + rowNum = createHeaderRowMonth(sheet, rowNum, list, headerStyle); + + // 填充数据行 + if (result != null && !result.isEmpty()) { + rowNum = createDataRowsMonth(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 = createTotalRowMonth(sheet, rowNum, list, totalCost,totalCostReal, headerStyle); + HSSFRow row = sheet.createRow(rowNum++); + row.setHeightInPoints(30); + HSSFCell cell1 = row.createCell(1); + cell1.setCellStyle(headerStyleNoSide); + cell1.setCellValue("主管:"); + + HSSFCell cell2 = row.createCell(4); + cell2.setCellStyle(headerStyleNoSide); + cell2.setCellValue("审核:"); + + HSSFCell cell3 = row.createCell(7); + cell3.setCellStyle(headerStyleNoSide); + cell3.setCellValue("经办人:"); + return workbook; + } + public static HSSFWorkbook excelForcheckAll(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, BigDecimal totalCostLease, BigDecimal totalCostLose, BigDecimal totalCostRepair, BigDecimal totalCostScrap,BigDecimal totalCostReduction) { @@ -681,6 +743,62 @@ public class PoiOutPage { RegionUtil.setBorderRight(BorderStyle.THIN, cellRange2, sheet); return rowNum; } + + /** + * 在month数据的最后一行添加费用小计 + * + * @param sheet 工作表 + * @param rowNum 当前行号 + * @param list 列名列表 + * @param totalCost 总费用 + * @param headerStyle 表头样式 + */ + private static int createTotalRowMonth(HSSFSheet sheet, int rowNum, List list, BigDecimal totalCost,BigDecimal totalCostReal, HSSFCellStyle headerStyle) { + HSSFRow row = sheet.createRow(rowNum++); + row.setHeightInPoints(30); + sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 0, 1)); + HSSFCell cell = row.createCell(0); + cell.setCellStyle(headerStyle); + cell.setCellValue("合计"); + // 设置边框样式,覆盖整个合并区域 + CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 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); + + sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 2, (short) (list.size() - 4))); + CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (list.size() - 4)); + // 设置边框样式 + 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() - 3; + HSSFCell cell1 = row.createCell(totalCostColumnIndex); + cell1.setCellStyle(headerStyle); + cell1.setCellValue(String.format("%.2f", totalCost)); + // 设置边框样式,覆盖整个合并区域 + CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 1, rowNum - 1, list.size() - 3, list.size() - 2); // 修改为包含至少两个单元格 + RegionUtil.setBorderTop(BorderStyle.THIN, cellRange2, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange2, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange2, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cellRange2, sheet); + + + int totalCostColumnIndexTwo = list.size() - 2; + HSSFCell cell2 = row.createCell(totalCostColumnIndexTwo); + cell2.setCellStyle(headerStyle); + cell2.setCellValue(String.format("%.2f", totalCostReal)); + + + int totalCostColumnIndexThree = list.size() - 1; + HSSFCell cellThree = row.createCell(totalCostColumnIndexThree); + cellThree.setCellStyle(headerStyle); + return rowNum; + } /** * 在数据的最后一行添加合计费用 * @@ -746,6 +864,27 @@ public class PoiOutPage { return rowNum; } + /** + * 创建月结标题行以及样式 + */ + private static int createTitleRowStyleMonth(HSSFSheet sheet, int rowNum, String filename, HSSFCellStyle titleStyle, int nColumn) { + HSSFRow row = sheet.createRow(rowNum++); + row.setHeightInPoints(40); + 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 */ @@ -857,6 +996,124 @@ public class PoiOutPage { return rowNum; } + /** + * 创建结算单位和结算工程行 + */ + private static int createProjectAndUnitRowMonth(HSSFSheet sheet, int rowNum, String projectName, String unitName,HSSFCellStyle titleStyle, int nColumn,int type,String month) { + // 第一行:结算单位 + 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 - 6))); // unitName 占剩余的22 + HSSFCell cell2 = row1.createCell(2); + cell2.setCellStyle(titleStyle); + cell2.setCellValue(unitName); + + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 5), (short) (nColumn - 4))); // 月结月份: 占8 + HSSFCell cellMonth = row1.createCell(6); + cellMonth.setCellStyle(titleStyle); + cellMonth.setCellValue("月结月份:"); + + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 3), (short) (nColumn - 1))); // 月份值 占剩余的22 + HSSFCell cellMonthTwo = row1.createCell(8); + cellMonthTwo.setCellStyle(titleStyle); + try { + SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM"); + SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy年M月"); + Date date = inputFormat.parse(month); + cellMonthTwo.setCellValue(outputFormat.format(date)); + } catch (ParseException e) { + // 如果解析失败,直接使用原始值 + cellMonthTwo.setCellValue(month); + } + + // 第二行:结算工程 + 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 - 6))); // projectName 占剩余的22 + HSSFCell cell4 = row2.createCell(2); + cell4.setCellStyle(titleStyle); + cell4.setCellValue(projectName); + + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 5), (short) (nColumn - 4))); // 费用承担方: 占8 + HSSFCell cell5 = row2.createCell(6); + cell5.setCellStyle(titleStyle); + cell5.setCellValue("费用承担方:"); + + sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 3), (short) (nColumn - 1))); // 费用承担方值 占剩余的22 + HSSFCell cell6 = row2.createCell(8); + // 创建红色字体样式 + HSSFCellStyle redStyle = sheet.getWorkbook().createCellStyle(); + redStyle.cloneStyleFrom(titleStyle); // 复制原有样式 + HSSFFont font = sheet.getWorkbook().createFont(); + font.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex()); // 设置字体颜色为红色 + font.setFontHeightInPoints((short) 12); + redStyle.setFont(font); + + cell6.setCellStyle(redStyle); // 应用红色字体样式 + if(type==1){ + cell6.setCellValue("01(项目)"); + }else{ + cell6.setCellValue("03(分包)"); + } + + + // 添加边框 + CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 2, rowNum - 2, 0, 1); + CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 2, rowNum - 2, 2, (short) (nColumn - 6)); + CellRangeAddress cellRangeMonthOne = new CellRangeAddress(rowNum - 2, rowNum - 2, (short) (nColumn - 5), (short) (nColumn - 4)); + CellRangeAddress cellRangeMonthTwo = new CellRangeAddress(rowNum -2, rowNum - 2, (short) (nColumn - 3), (short) (nColumn - 1)); + CellRangeAddress cellRange3 = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1); + CellRangeAddress cellRange4 = new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 6)); + CellRangeAddress cellRange5 = new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 5), (short) (nColumn - 4)); + CellRangeAddress cellRange6 = new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 3), (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, cellRangeMonthOne, sheet); +// RegionUtil.setBorderBottom(BorderStyle.THIN, cellRangeMonthOne, sheet); +// RegionUtil.setBorderLeft(BorderStyle.THIN, cellRangeMonthOne, sheet); +// RegionUtil.setBorderRight(BorderStyle.THIN, cellRangeMonthOne, sheet); +// RegionUtil.setBorderTop(BorderStyle.THIN, cellRangeMonthTwo, sheet); +// RegionUtil.setBorderBottom(BorderStyle.THIN, cellRangeMonthTwo, sheet); +// RegionUtil.setBorderLeft(BorderStyle.THIN, cellRangeMonthTwo, sheet); +// RegionUtil.setBorderRight(BorderStyle.THIN, cellRangeMonthTwo, 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; + } + /** * 创建结算单位和结算工程行 */ @@ -981,6 +1238,21 @@ public class PoiOutPage { return rowNum; } + /** + * 创建表头行 + */ + private static int createHeaderRowMonth(HSSFSheet sheet, int rowNum, List list, HSSFCellStyle headerStyle) { + HSSFRow row = sheet.createRow(rowNum++); + row.setHeightInPoints(40); + for (int j = 0; j < list.size(); j++) { + HSSFCell cell = row.createCell(j); + String header = list.get(j); + cell.setCellStyle(headerStyle); + cell.setCellValue(header != null ? header : ""); + } + return rowNum; + } + private static int createHeaderRowTwo(HSSFSheet sheet, int rowNum, List list, HSSFCellStyle headerStyle) { HSSFRow row = sheet.createRow(rowNum++); row.setHeightInPoints(20); @@ -1024,6 +1296,23 @@ public class PoiOutPage { return rowNum; } + private static int createDataRowsMonth(HSSFSheet sheet, int rowNum, List> result, + HSSFCellStyle contentStyle, int nColumn) { + for (Map resultRow : result) { + HSSFRow row = sheet.createRow(rowNum++); + row.setHeightInPoints(15); + List rowData = map2List(resultRow); + + for (int j = 0; j < nColumn; j++) { + HSSFCell cell = row.createCell(j); + Object data = rowData.get(j); + cell.setCellStyle(contentStyle); + setCellData(cell, data, contentStyle); + } + } + return rowNum; + } + /** * 设置单元格数据,并自动判断数据类型 */ diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java index bb6a94f..58d98b6 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java @@ -56,11 +56,11 @@ public class SltAgreementInfoController extends BaseController { @Resource private SltAgreementInfoService sltAgreementInfoService; -// @Autowired -// private CalcMonthlyService calcMonthlyService; -// -// @Value("${sgzb.job.settlementJobDay}") -// private String settlementJobDay; + @Autowired + private CalcMonthlyService calcMonthlyService; + + @Value("${sgzb.job.settlementJobDay}") + private String settlementJobDay; @ApiOperation(value = "工程下拉选") @GetMapping("getProjectListByUnitIds") @@ -113,36 +113,71 @@ public class SltAgreementInfoController extends BaseController { } // @RequiresPermissions("cost:settlement:export") - @ApiOperation(value = "月结明细导出") +// @ApiOperation(value = "月结明细导出") +// @PostMapping("/exportSltInfoMonth") +// public void exportSltInfoMonth(HttpServletResponse response, @RequestBody List list) throws IOException { +// List sltInfoMonth = sltAgreementInfoService.getSltInfoMonth(list); +// List> allLists = new ArrayList<>(); +// for (AgreementInfo agreementInfo : list) { +// List list1 = new ArrayList<>(); +// for (SltAgreementInfo sltAgreementInfo : sltInfoMonth) { +// // 单个协议导出 +// if (StringUtils.isNotBlank(agreementInfo.getCodeNum())) { +// String[] split = agreementInfo.getCodeNum().split(","); +// for (String s : split) { +// if (s.equals(sltAgreementInfo.getCodeNum().toString())) { +// List node = sltAgreementInfo.getNode(); +// List leaseInfoList = Convert.toList(MonthRepairInfo.class, node); +// list1.addAll(leaseInfoList); +// } +// } +// } else { +// if (String.valueOf(agreementInfo.getAgreementId()).equals(sltAgreementInfo.getAgreementId())){ +// // 多个协议导出 +// List node = sltAgreementInfo.getNode(); +// List leaseInfoList = Convert.toList(MonthRepairInfo.class, node); +// list1.addAll(leaseInfoList); +// } +// } +// } +// allLists.add(list1); +// } +// exportMultipleLists(allLists, response); +// } + + /** + * 租赁明细导出 + */ + @Log(title = "月结明细导出", businessType = BusinessType.EXPORT) @PostMapping("/exportSltInfoMonth") - public void exportSltInfoMonth(HttpServletResponse response, @RequestBody List list) throws IOException { +// @RequiresPermissions("ndertake:export_1") + public void exportLeaseMonth(HttpServletResponse response, @RequestBody List list) throws Exception { + String fileName = "重庆市送变电工程有限公司设备租赁台班费月结算单"; List sltInfoMonth = sltAgreementInfoService.getSltInfoMonth(list); - List> allLists = new ArrayList<>(); - for (AgreementInfo agreementInfo : list) { - List list1 = new ArrayList<>(); - for (SltAgreementInfo sltAgreementInfo : sltInfoMonth) { - // 单个协议导出 - if (StringUtils.isNotBlank(agreementInfo.getCodeNum())) { - String[] split = agreementInfo.getCodeNum().split(","); - for (String s : split) { - if (s.equals(sltAgreementInfo.getCodeNum().toString())) { - List node = sltAgreementInfo.getNode(); - List leaseInfoList = Convert.toList(MonthRepairInfo.class, node); - list1.addAll(leaseInfoList); - } - } - } else { - if (String.valueOf(agreementInfo.getAgreementId()).equals(sltAgreementInfo.getAgreementId())){ - // 多个协议导出 - List node = sltAgreementInfo.getNode(); - List leaseInfoList = Convert.toList(MonthRepairInfo.class, node); - list1.addAll(leaseInfoList); - } + for (SltAgreementInfo sltAgreementInfo : sltInfoMonth) { + if(String.valueOf(sltAgreementInfo.getCodeNum()).equals(list.get(0).getCodeNum())){ + List explist = sltAgreementInfo.getNode(); + String projectName = sltAgreementInfo.getProjectName(); + String unitName = sltAgreementInfo.getUnitName(); + String month = sltAgreementInfo.getMonth(); + BigDecimal totalCost = BigDecimal.valueOf(0.00); + BigDecimal totalCostReal = BigDecimal.valueOf(0.00); + for (SltAgreementInfo sltAgreementInfoOne : explist) { + totalCost = totalCost.add(sltAgreementInfoOne.getCosts()); + totalCostReal = totalCostReal.add(sltAgreementInfoOne.getRealCosts()); } + List leaseInfoList = Convert.toList(MonthRepairInfo.class, explist); + if(sltAgreementInfo.getCostBearingParty().equals("01")){ + expOutExcelMonth(response,leaseInfoList,fileName,projectName,unitName,totalCost,totalCostReal,1,month); + }else{ + expOutExcelMonth(response,leaseInfoList,fileName,projectName,unitName,totalCost,totalCostReal,3,month); + } + + ExcelUtil util = new ExcelUtil(MonthRepairInfo.class); + util.exportExcel(response, leaseInfoList, "月结明细导出"); } - allLists.add(list1); - } - exportMultipleLists(allLists, response); + + }; } /** @@ -410,6 +445,51 @@ public class SltAgreementInfoController extends BaseController { } } + /** + * 导出结算单 + * @param response + * @param list + * @param filename + + * @throws Exception + */ + private void expOutExcelMonth(HttpServletResponse response, List list, String filename,String projectName,String unitName,BigDecimal totalCost,BigDecimal totalCostReal,int type,String month) + throws Exception { + if (list != null) { + List> results = new ArrayList>(); + int size = list.size(); + for (int i = 0; i < size; i++) { + MonthRepairInfo bean = list.get(i); + Map maps = outReceiveDetailsBeanToMapMonth(bean,type,0); + results.add(maps); + } + List headers = receiveDetailsHeaderMonth(type); + HSSFWorkbook workbook = PoiOutPage.excelForcheckTwoMonth(results, headers, filename,projectName,unitName,totalCost,totalCostReal,type,month); + 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 = receiveDetailsHeaderMonth(type); + 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(); + } + } + /** * 租赁费用单数据转换 * @param bean @@ -457,6 +537,51 @@ public class SltAgreementInfoController extends BaseController { return maps; } + /** + * 租赁费用单数据转换 + * @param bean + * @return + */ + private Map outReceiveDetailsBeanToMapMonth(MonthRepairInfo bean,int type,int flag) { + // 创建一个SimpleDateFormat对象,定义日期格式 + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Map maps = new LinkedHashMap(); +// maps.put("unitName", bean.getUnitName()); +// maps.put("projectName", bean.getProjectName()); + maps.put("typeName", bean.getTypeName()); + maps.put("modelName", bean.getModelName()); + maps.put("nuitName", bean.getNuitName()); + maps.put("num", bean.getNum()); + maps.put("leasePrice", bean.getLeasePrice()); + maps.put("startTime", bean.getStartTime()); + maps.put("endTime", bean.getEndTime()); + maps.put("leaseDays", bean.getLeaseDays()); + maps.put("costs", bean.getCosts().setScale(2, RoundingMode.HALF_UP)); + maps.put("realCosts", bean.getRealCosts().setScale(2, RoundingMode.HALF_UP)); + maps.put("remark",bean.getRemark()); + return maps; + } + + /** + * 月结费用单表头 + * @return + */ + private List receiveDetailsHeaderMonth(int type) { + ArrayList list = new ArrayList(); + list.add("设备名称"); + list.add("规格型号"); + list.add("单位"); + list.add("数量"); + list.add("台班费单价(元/天)"); + list.add("起租日期"); + list.add("结算日期"); + list.add("结算天数"); + list.add("结算金额(元)"); + list.add("本次暂记金额(元)"); + list.add("备注"); + return list; + } + /** * 租赁费用单表头 * @return diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MonthRepairInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MonthRepairInfo.java index a992750..ed26b27 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MonthRepairInfo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MonthRepairInfo.java @@ -131,6 +131,14 @@ public class MonthRepairInfo { this.month = month; } + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + /** * 领料时间 */ @@ -212,4 +220,9 @@ public class MonthRepairInfo { // @Excel(name = "月份") @ExcelProperty(value = "月份") private String month; + + /** + * 备注 + */ + private String remark; } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java index 0542f57..739c668 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java @@ -77,4 +77,8 @@ public class ProjectMonthDetail { private String nuitName; private BigDecimal costs; private BigDecimal realCosts; + /** + * 备注 + */ + private String remark; } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java index 6a01e93..3bb21cf 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java @@ -187,6 +187,7 @@ public class CalcMonthlyServiceImp implements CalcMonthlyService { projectMonthDetail.setSltCosts(bean.getCosts()); projectMonthDetail.setMonthTemporarilyCosts(bean.getRealCosts()); projectMonthDetail.setProMonthCostId(pmcId); + projectMonthDetail.setRemark(bean.getRemark()); calMonthlyMapper.insertProjectMonthDetail(projectMonthDetail); } sltAgreementInfo.setCosts(leaseCostOne); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java index 93df114..87ebdd5 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java @@ -565,11 +565,11 @@ public class BackApplyServiceImpl implements BackApplyService { if (bean == null || bean.getBackApplyInfo() == null || CollectionUtils.isEmpty(bean.getBackApplyDetails())) { return AjaxResult.error("退料申请数据不能为空"); } - for (BackApplyInfo backApplyDetail : bean.getBackApplyDetails()) { - if (backApplyDetail.getBackNum() != null && backApplyDetail.getUseNum() != null && backApplyDetail.getBackNum() > Integer.parseInt(backApplyDetail.getUseNum())){ - return AjaxResult.error("退料数不能超过在用数"); - } - } +// for (BackApplyInfo backApplyDetail : bean.getBackApplyDetails()) { +// if (backApplyDetail.getBackNum() != null && backApplyDetail.getUseNum() != null && backApplyDetail.getBackNum() > Integer.parseInt(backApplyDetail.getUseNum())){ +// return AjaxResult.error("退料数不能超过在用数"); +// } +// } String backTime = null; if(bean.getBackApplyInfo().getBackTime()!=null){ backTime = bean.getBackApplyInfo().getBackTime(); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java index 8c2672d..be8bd07 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java @@ -677,7 +677,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { Map mergedMap = new HashMap<>(); for (SltAgreementInfo info : leaseList) { String key = info.getTypeId(); - if (info.getStartTime() != null && info.getEndTime() != null) { + if (info.getStartTime() != null || info.getEndTime() != null) { key += "_" + info.getStartTime() + "_" + info.getEndTime(); } if (mergedMap.containsKey(key)) { diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml index 062acc7..6a49406 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml @@ -13,9 +13,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" (#{agreementId},#{taskId},#{unitId},#{projectId},#{month},#{costBearingParty},now()) - insert into project_month_detail (type_id,ma_id,unit,start_time,end_time,slt_days,slt_costs,month_temporarily_costs,pro_month_cost_id,num,lease_price,create_time) + insert into project_month_detail (type_id,ma_id,unit,start_time,end_time,slt_days,slt_costs,month_temporarily_costs,pro_month_cost_id,num,lease_price,create_time,remark) values - (#{typeId},#{maId},#{unit},#{startTime},#{endTime},#{sltDays},#{sltCosts},#{monthTemporarilyCosts},#{proMonthCostId},#{num},#{leasePrice},now()) + (#{typeId},#{maId},#{unit},#{startTime},#{endTime},#{sltDays},#{sltCosts},#{monthTemporarilyCosts},#{proMonthCostId},#{num},#{leasePrice},now(),#{remark}) update project_month_costs set costs = #{costs},update_time = now() where id = #{id} @@ -66,7 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" DATE_FORMAT( pmd.end_time, '%Y-%m-%d' ) as endTime, pmd.slt_days as leaseDays, pmd.slt_costs as costs, - pmd.month_temporarily_costs as realCosts + pmd.month_temporarily_costs as realCosts, + pmd.remark as remark FROM project_month_detail pmd LEFT JOIN project_month_costs pmc ON pmd.pro_month_cost_id = pmc.id diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml index 7a6ad29..507dbcc 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml @@ -445,6 +445,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sai.is_slt AS isSlt, lai.cost_bearing_party AS costBearingParty, sai.trim_day AS trimDay, + IF ( + sai.replace_type_id > 0, + '以大代小', + '' + ) AS remark, DATE(#{bean.startTime}) AS startTime, DATE(#{bean.endTime}) AS endTime, DATEDIFF(#{bean.endTime}, #{bean.startTime}) + 1 AS leaseDays @@ -596,6 +601,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bp.lot_id AS lotId, DATE( sai.start_time ) AS startTime, lai.cost_bearing_party AS costBearingParty, + IF ( + sai.replace_type_id > 0, + '以大代小', + '' + ) AS remark, DATE( COALESCE ( sai.end_time, CURDATE() ) ) AS endTime FROM slt_agreement_info sai