11-24-修复
This commit is contained in:
@ -396,25 +396,10 @@ public class HseSafetyWeeklyReportServiceImpl extends ServiceImpl<HseSafetyWeekl
|
||||
File targetFile = null;
|
||||
|
||||
try {
|
||||
// // 1. 确定目标文件
|
||||
// if (outputFilePath != null && !outputFilePath.trim().isEmpty()) {
|
||||
// // 保存到指定路径
|
||||
// targetFile = new File(outputFilePath);
|
||||
// if (targetFile.exists()) {
|
||||
// if (!targetFile.delete()) {
|
||||
// throw new IOException("无法删除旧文件,请检查文件权限:" + outputFilePath);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// // 创建临时文件
|
||||
// targetFile = File.createTempFile("周报模板_", ".xlsx");
|
||||
// targetFile.deleteOnExit();
|
||||
// }
|
||||
targetFile = File.createTempFile("周报_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy_MM_dd_HH_mm_ss")), ".xlsx");
|
||||
|
||||
// 2. 使用POI直接创建复杂格式
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
// Sheet sheet = workbook.createSheet("9.13");
|
||||
Sheet sheet = workbook.createSheet(LocalDate.now().toString());
|
||||
|
||||
// 3. 构建完整模板结构
|
||||
@ -422,20 +407,17 @@ public class HseSafetyWeeklyReportServiceImpl extends ServiceImpl<HseSafetyWeekl
|
||||
buildTemplateFullStructure(sheet, workbook, report, weekOfYear); // 创建所有内容
|
||||
setKeyRowHeights(sheet); // 设置行高
|
||||
|
||||
// 4. 写入文件
|
||||
// 4. 设置条件格式 - 使用最简化版本确保能工作
|
||||
// setupMinimalConditionalFormatting(sheet);
|
||||
|
||||
// 5. 写入文件
|
||||
outputStream = new FileOutputStream(targetFile);
|
||||
workbook.write(outputStream);
|
||||
outputStream.flush();
|
||||
|
||||
// 5. 关闭资源
|
||||
// 6. 关闭资源
|
||||
workbook.close();
|
||||
|
||||
// if (outputFilePath != null) {
|
||||
// System.out.println("项目周报模板生成完成,文件路径:" + targetFile.getAbsolutePath());
|
||||
// } else {
|
||||
// System.out.println("项目周报模板生成完成,临时文件路径:" + targetFile.getAbsolutePath());
|
||||
// }
|
||||
|
||||
return targetFile;
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -890,7 +872,7 @@ public class HseSafetyWeeklyReportServiceImpl extends ServiceImpl<HseSafetyWeekl
|
||||
}
|
||||
|
||||
/**
|
||||
* 施工进度统计表(第11-18行)- 修正数据赋值问题
|
||||
* 施工进度统计表(第11-18行)- 修正数据赋值和条件格式准备
|
||||
*/
|
||||
private void createConstructionProgressTable(Sheet sheet, Workbook workbook, int startRow,
|
||||
CellStyle headerStyle, CellStyle contentStyle,
|
||||
@ -932,15 +914,15 @@ public class HseSafetyWeeklyReportServiceImpl extends ServiceImpl<HseSafetyWeekl
|
||||
l11Cell.setCellValue("备注");
|
||||
l11Cell.setCellStyle(tableHeaderStyle);
|
||||
|
||||
// 数据行(第12-18行,共7行)- 修正数据位置和赋值
|
||||
// 数据行(第12-18行,共7行)- 修正:确保I列(累计完成率)有数值数据用于数据条显示
|
||||
String[][] progressData = {
|
||||
{"基础", "光伏区", "个", "164728", "3955", "104434", "63.4%", "6000", "设计值为根据7.18日最新电子版图纸统计,包含未开工的五工区,总设计容量约为357.5Mpw。"},
|
||||
{"支架", "", "组", "20591", "644", "6412", "31.1%", "1050", ""},
|
||||
{"组件", "", "组", "20591", "409", "4902", "23.8%", "850", ""},
|
||||
{"清表", "", "亩", "4517", "0", "4104", "90.8%", "100", ""},
|
||||
{"塔基", "线路工程", "", "", "", "", "", "", ""},
|
||||
{"组塔", "", "", "", "", "", "", "", ""},
|
||||
{"放线", "", "", "", "", "", "", "", ""}
|
||||
{"基础", "光伏区", "个", "164728", "3955", "104434", "0.634", "6000", "设计值为根据7.18日最新电子版图纸统计,包含未开工的五工区,总设计容量约为357.5Mpw。"},
|
||||
{"支架", "", "组", "20591", "644", "6412", "0.311", "1050", ""},
|
||||
{"组件", "", "组", "20591", "409", "4902", "0.238", "850", ""},
|
||||
{"清表", "", "亩", "4517", "0", "4104", "0.908", "100", ""},
|
||||
{"塔基", "线路工程", "个", "1000", "50", "200", "0.200", "80", ""},
|
||||
{"组塔", "", "座", "500", "25", "100", "0.200", "40", ""},
|
||||
{"放线", "", "km", "200", "10", "40", "0.200", "15", ""}
|
||||
};
|
||||
|
||||
for (int i = 0; i < progressData.length; i++) {
|
||||
@ -953,8 +935,17 @@ public class HseSafetyWeeklyReportServiceImpl extends ServiceImpl<HseSafetyWeekl
|
||||
for (int j = 0; j < 7; j++) { // 只设置前7列数据(C-I列)
|
||||
Cell cell = row.createCell(j + 2); // C列开始
|
||||
if (j < progressData[i].length) {
|
||||
// 对于累计完成率列(I列,索引8),确保是数值格式
|
||||
if (j == 6 && !progressData[i][j].isEmpty()) {
|
||||
try {
|
||||
cell.setCellValue(Double.parseDouble(progressData[i][j]));
|
||||
} catch (NumberFormatException e) {
|
||||
cell.setCellValue(progressData[i][j]);
|
||||
}
|
||||
} else {
|
||||
cell.setCellValue(progressData[i][j]);
|
||||
}
|
||||
}
|
||||
cell.setCellStyle(contentStyle);
|
||||
}
|
||||
|
||||
@ -992,7 +983,7 @@ public class HseSafetyWeeklyReportServiceImpl extends ServiceImpl<HseSafetyWeekl
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备材料表格(第19-23行)- 修正数据赋值问题
|
||||
* 设备材料表格(第19-23行)- 修正数据赋值和条件格式准备
|
||||
*/
|
||||
private void createEquipmentMaterialTable(Sheet sheet, Workbook workbook, int startRow,
|
||||
CellStyle headerStyle, CellStyle contentStyle,
|
||||
@ -1034,12 +1025,12 @@ public class HseSafetyWeeklyReportServiceImpl extends ServiceImpl<HseSafetyWeekl
|
||||
l19Cell.setCellValue("备注");
|
||||
l19Cell.setCellStyle(tableHeaderStyle);
|
||||
|
||||
// 数据行 - 从第20行开始(共4行数据)- 修正数据位置和赋值
|
||||
// 数据行 - 从第20行开始(共4行数据)- 修正:确保I列(累计到货率)有数值数据用于数据条显示
|
||||
String[][] materialData = {
|
||||
{"檩条、斜撑", "", "根", "131728", "3752", "106745", "81.0%", "", ""},
|
||||
{"立杆", "", "根", "133841", "5549", "53372", "39.9%", "", ""},
|
||||
{"光伏组件", "", "块", "576548", "25880", "177360", "30.8%", "", ""},
|
||||
{"预埋件", "", "套", "164728", "0", "113000", "68.6%", "", ""}
|
||||
{"檩条、斜撑", "", "根", "131728", "3752", "106745", "0.810", "", ""},
|
||||
{"立杆", "", "根", "133841", "5549", "53372", "0.399", "", ""},
|
||||
{"光伏组件", "", "块", "576548", "25880", "177360", "0.308", "", ""},
|
||||
{"预埋件", "", "套", "164728", "0", "113000", "0.686", "", ""}
|
||||
};
|
||||
|
||||
for (int i = 0; i < materialData.length; i++) {
|
||||
@ -1052,8 +1043,17 @@ public class HseSafetyWeeklyReportServiceImpl extends ServiceImpl<HseSafetyWeekl
|
||||
for (int j = 0; j < 7; j++) { // 只设置前7列数据(C-I列)
|
||||
Cell cell = row.createCell(j + 2); // C列开始
|
||||
if (j < materialData[i].length) {
|
||||
// 对于累计到货率列(I列,索引6),确保是数值格式
|
||||
if (j == 6 && !materialData[i][j].isEmpty()) {
|
||||
try {
|
||||
cell.setCellValue(Double.parseDouble(materialData[i][j]));
|
||||
} catch (NumberFormatException e) {
|
||||
cell.setCellValue(materialData[i][j]);
|
||||
}
|
||||
} else {
|
||||
cell.setCellValue(materialData[i][j]);
|
||||
}
|
||||
}
|
||||
cell.setCellStyle(contentStyle);
|
||||
}
|
||||
|
||||
@ -1484,4 +1484,37 @@ public class HseSafetyWeeklyReportServiceImpl extends ServiceImpl<HseSafetyWeekl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 最简化的条件格式设置(确保能工作)
|
||||
*/
|
||||
private void setupMinimalConditionalFormatting(Sheet sheet) {
|
||||
try {
|
||||
SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
|
||||
|
||||
// 创建一个简单的条件格式规则
|
||||
ConditionalFormattingRule rule = sheetCF.createConditionalFormattingRule(
|
||||
"I12>=0" // 简单的条件
|
||||
);
|
||||
|
||||
// 设置填充颜色
|
||||
PatternFormatting fill = rule.createPatternFormatting();
|
||||
fill.setFillBackgroundColor(IndexedColors.LIGHT_BLUE.getIndex());
|
||||
fill.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
|
||||
|
||||
// 应用规则
|
||||
CellRangeAddress[] regions = {
|
||||
CellRangeAddress.valueOf("I12:I18"),
|
||||
CellRangeAddress.valueOf("I20:I23")
|
||||
};
|
||||
|
||||
sheetCF.addConditionalFormatting(regions, rule);
|
||||
System.out.println("最简化条件格式设置成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("最简化条件格式设置失败: " + e.getMessage());
|
||||
// 如果连这个都失败,可能是POI版本问题,跳过条件格式
|
||||
System.out.println("跳过条件格式设置");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -100,7 +100,8 @@ public class XzdContractAgreementServiceImpl extends ServiceImpl<XzdContractAgre
|
||||
private LambdaQueryWrapper<XzdContractAgreement> buildQueryWrapper(XzdContractAgreementBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<XzdContractAgreement> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByDesc(XzdContractAgreement::getId);
|
||||
lqw.orderByDesc(XzdContractAgreement::getCreateTime);
|
||||
lqw.eq(bo.getCompanyId() != null, XzdContractAgreement::getCompanyId, bo.getCompanyId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getContractCode()), XzdContractAgreement::getContractCode, bo.getContractCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getContractName()), XzdContractAgreement::getContractName, bo.getContractName());
|
||||
lqw.eq(bo.getDocumentDate() != null, XzdContractAgreement::getDocumentDate, bo.getDocumentDate());
|
||||
|
||||
Reference in New Issue
Block a user