结算管理修复
This commit is contained in:
parent
934c22bc47
commit
6b5ed38cbe
|
|
@ -212,7 +212,7 @@ public class PoiOutPage {
|
||||||
// 创建工作簿和工作表
|
// 创建工作簿和工作表
|
||||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||||
HSSFSheet sheet = workbook.createSheet();
|
HSSFSheet sheet = workbook.createSheet();
|
||||||
sheet.setDefaultColumnWidth(10); // 设置列宽
|
sheet.setDefaultColumnWidth(13); // 设置列宽
|
||||||
|
|
||||||
// 创建样式
|
// 创建样式
|
||||||
HSSFCellStyle titleStyle = createTitleStyle(workbook);
|
HSSFCellStyle titleStyle = createTitleStyle(workbook);
|
||||||
|
|
@ -853,13 +853,13 @@ public class PoiOutPage {
|
||||||
HSSFCell cell = row.createCell(0);
|
HSSFCell cell = row.createCell(0);
|
||||||
cell.setCellStyle(titleStyle);
|
cell.setCellStyle(titleStyle);
|
||||||
cell.setCellValue(filename);
|
cell.setCellValue(filename);
|
||||||
// 添加边框
|
// // 添加边框
|
||||||
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, rowNum - 1, (short) (nColumn - 1));
|
// CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, rowNum - 1, (short) (nColumn - 1));
|
||||||
// 设置边框样式
|
// // 设置边框样式
|
||||||
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet);
|
// RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet);
|
||||||
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet);
|
// RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet);
|
||||||
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet);
|
// RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet);
|
||||||
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet);
|
// RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet);
|
||||||
|
|
||||||
return rowNum;
|
return rowNum;
|
||||||
}
|
}
|
||||||
|
|
@ -919,7 +919,7 @@ public class PoiOutPage {
|
||||||
cell1.setCellStyle(titleStyle);
|
cell1.setCellStyle(titleStyle);
|
||||||
cell1.setCellValue("领用单位:");
|
cell1.setCellValue("领用单位:");
|
||||||
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1))); // unitName 占剩余的22
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 8))); // unitName 占剩余的22
|
||||||
HSSFCell cell2 = row1.createCell(2);
|
HSSFCell cell2 = row1.createCell(2);
|
||||||
cell2.setCellStyle(titleStyle);
|
cell2.setCellStyle(titleStyle);
|
||||||
cell2.setCellValue(unitName);
|
cell2.setCellValue(unitName);
|
||||||
|
|
@ -961,37 +961,37 @@ public class PoiOutPage {
|
||||||
|
|
||||||
|
|
||||||
// 添加边框
|
// 添加边框
|
||||||
CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 2, rowNum - 2, 0, 1);
|
// CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 2, rowNum - 2, 0, 1);
|
||||||
CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 2, rowNum - 2, 2, (short) (nColumn - 1));
|
// CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 2, rowNum - 2, 2, (short) (nColumn - 8));
|
||||||
CellRangeAddress cellRange3 = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1);
|
// CellRangeAddress cellRange3 = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1);
|
||||||
CellRangeAddress cellRange4 = new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 8));
|
// CellRangeAddress cellRange4 = new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 8));
|
||||||
CellRangeAddress cellRange5 = new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 7), (short) (nColumn - 6));
|
// CellRangeAddress cellRange5 = new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 7), (short) (nColumn - 6));
|
||||||
CellRangeAddress cellRange6 = new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 5), (short) (nColumn - 1));
|
// CellRangeAddress cellRange6 = new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 5), (short) (nColumn - 1));
|
||||||
// 设置边框样式
|
// 设置边框样式
|
||||||
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange1, sheet);
|
// RegionUtil.setBorderTop(BorderStyle.THIN, cellRange1, sheet);
|
||||||
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange1, sheet);
|
// RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange1, sheet);
|
||||||
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange1, sheet);
|
// RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange1, sheet);
|
||||||
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange1, sheet);
|
// RegionUtil.setBorderRight(BorderStyle.THIN, cellRange1, sheet);
|
||||||
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange2, sheet);
|
// RegionUtil.setBorderTop(BorderStyle.THIN, cellRange2, sheet);
|
||||||
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange2, sheet);
|
// RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange2, sheet);
|
||||||
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange2, sheet);
|
// RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange2, sheet);
|
||||||
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange2, sheet);
|
// RegionUtil.setBorderRight(BorderStyle.THIN, cellRange2, sheet);
|
||||||
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange3, sheet);
|
// RegionUtil.setBorderTop(BorderStyle.THIN, cellRange3, sheet);
|
||||||
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange3, sheet);
|
// RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange3, sheet);
|
||||||
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange3, sheet);
|
// RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange3, sheet);
|
||||||
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange3, sheet);
|
// RegionUtil.setBorderRight(BorderStyle.THIN, cellRange3, sheet);
|
||||||
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange4, sheet);
|
// RegionUtil.setBorderTop(BorderStyle.THIN, cellRange4, sheet);
|
||||||
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange4, sheet);
|
// RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange4, sheet);
|
||||||
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange4, sheet);
|
// RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange4, sheet);
|
||||||
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange4, sheet);
|
// RegionUtil.setBorderRight(BorderStyle.THIN, cellRange4, sheet);
|
||||||
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange5, sheet);
|
// RegionUtil.setBorderTop(BorderStyle.THIN, cellRange5, sheet);
|
||||||
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange5, sheet);
|
// RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange5, sheet);
|
||||||
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange5, sheet);
|
// RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange5, sheet);
|
||||||
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange5, sheet);
|
// RegionUtil.setBorderRight(BorderStyle.THIN, cellRange5, sheet);
|
||||||
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange6, sheet);
|
// RegionUtil.setBorderTop(BorderStyle.THIN, cellRange6, sheet);
|
||||||
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange6, sheet);
|
// RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange6, sheet);
|
||||||
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange6, sheet);
|
// RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange6, sheet);
|
||||||
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange6, sheet);
|
// RegionUtil.setBorderRight(BorderStyle.THIN, cellRange6, sheet);
|
||||||
|
|
||||||
return rowNum;
|
return rowNum;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,107 @@ public class SltAgreementInfoController extends BaseController {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租赁明细导出
|
||||||
|
*/
|
||||||
|
@Log(title = "月结明细导出", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/exportLeaseMonthZip")
|
||||||
|
// @RequiresPermissions("ndertake:export_1")
|
||||||
|
public void exportLeaseMonthZip(HttpServletResponse response, @RequestBody List<AgreementInfo> list) throws Exception {
|
||||||
|
// 创建临时文件夹
|
||||||
|
String tempDir = System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID();
|
||||||
|
new File(tempDir).mkdirs();
|
||||||
|
try {
|
||||||
|
String fileName = "重庆市送变电工程有限公司设备租赁台班费月结算单";
|
||||||
|
List<SltAgreementInfo> sltInfoMonth = sltAgreementInfoService.getSltInfoMonth(list);
|
||||||
|
String[] codeNums = list.get(0).getCodeNum().split(",");
|
||||||
|
for (SltAgreementInfo sltAgreementInfo : sltInfoMonth) {
|
||||||
|
for (String codeNum : codeNums) {
|
||||||
|
if (String.valueOf(sltAgreementInfo.getCodeNum()).equals(codeNum) && list.stream().anyMatch(info -> info.getAgreementId().toString().trim().equals(sltAgreementInfo.getAgreementId().toString().trim()))) {
|
||||||
|
List<SltAgreementInfo> 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<MonthRepairInfo> leaseInfoList = Convert.toList(MonthRepairInfo.class, explist);
|
||||||
|
if (sltAgreementInfo.getCostBearingParty().equals("01")) {
|
||||||
|
fileName = "费用承担方01_" + month + "_" + unitName + "_" + projectName + "_月结算单.xls";
|
||||||
|
// 导出单个Excel文件
|
||||||
|
String filePath = tempDir + File.separator + fileName;
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(filePath)) {
|
||||||
|
HSSFWorkbook workbook = PoiOutPage.excelForcheckTwoMonth(
|
||||||
|
leaseInfoList.stream()
|
||||||
|
.map(bean -> outReceiveDetailsBeanToMapMonth(bean, 1, 0))
|
||||||
|
.collect(Collectors.toList()),
|
||||||
|
receiveDetailsHeaderMonth(1),
|
||||||
|
"重庆市送变电工程有限公司设备租赁台班费月结算单",
|
||||||
|
projectName,
|
||||||
|
unitName,
|
||||||
|
totalCost,
|
||||||
|
totalCostReal,
|
||||||
|
1,
|
||||||
|
month
|
||||||
|
);
|
||||||
|
workbook.write(fos);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fileName = "费用承担方03_" + month + "_" + unitName + "_" + projectName + "_月结算单.xls";
|
||||||
|
// 导出单个Excel文件
|
||||||
|
String filePath = tempDir + File.separator + fileName;
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(filePath)) {
|
||||||
|
HSSFWorkbook workbook = PoiOutPage.excelForcheckTwoMonth(
|
||||||
|
leaseInfoList.stream()
|
||||||
|
.map(bean -> outReceiveDetailsBeanToMapMonth(bean, 3, 0))
|
||||||
|
.collect(Collectors.toList()),
|
||||||
|
receiveDetailsHeaderMonth(3),
|
||||||
|
"重庆市送变电工程有限公司设备租赁台班费月结算单",
|
||||||
|
projectName,
|
||||||
|
unitName,
|
||||||
|
totalCost,
|
||||||
|
totalCostReal,
|
||||||
|
3,
|
||||||
|
month
|
||||||
|
);
|
||||||
|
workbook.write(fos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建压缩包
|
||||||
|
String zipFileName = "月结算单_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip";
|
||||||
|
response.setContentType("application/zip");
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(zipFileName, "UTF-8"));
|
||||||
|
|
||||||
|
try (ZipOutputStream zipOut = new ZipOutputStream(response.getOutputStream())) {
|
||||||
|
File[] files = new File(tempDir).listFiles();
|
||||||
|
if (files != null) {
|
||||||
|
for (File file : files) {
|
||||||
|
zipOut.putNextEntry(new ZipEntry(file.getName()));
|
||||||
|
try (FileInputStream fis = new FileInputStream(file)) {
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int len;
|
||||||
|
while ((len = fis.read(buffer)) > 0) {
|
||||||
|
zipOut.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zipOut.closeEntry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// 删除临时文件夹
|
||||||
|
FileUtils.deleteDirectory(new File(tempDir));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调整天数
|
* 调整天数
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue