|
@@ -3,6 +3,7 @@ package com.sundata.product.rwa.calc.service;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.date.TimeInterval;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.sundata.common.util.DBExecutor;
|
|
|
import com.sundata.common.util.FileUtil;
|
|
@@ -143,7 +144,14 @@ public class ReportCalcService {
|
|
|
switch (tempCell.getCellType()) {
|
|
|
case STRING -> mainTmpCell.setCellValue(tempCell.getStringCellValue());
|
|
|
case NUMERIC -> mainTmpCell.setCellValue(tempCell.getNumericCellValue());
|
|
|
- case FORMULA -> mainTmpCell.setCellFormula(tempCell.getCellFormula());
|
|
|
+ case FORMULA -> {
|
|
|
+ if (StrUtil.isEmpty(tempCell.getCellFormula())) {
|
|
|
+ mainTmpCell.setCellFormula("");
|
|
|
+ }else {
|
|
|
+ mainTmpCell.setCellFormula(tempCell.getCellFormula());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
default -> mainTmpCell.setCellValue("");
|
|
|
}
|
|
|
}
|
|
@@ -313,25 +321,22 @@ public class ReportCalcService {
|
|
|
if (sheet == null) {
|
|
|
sheet = workbook.createSheet();
|
|
|
}
|
|
|
- Row row = sheet.getRow(reportCalculationModel.getReportUnitRow());
|
|
|
- if (row == null) {
|
|
|
- row = sheet.createRow(reportCalculationModel.getReportUnitRow());
|
|
|
- }
|
|
|
- Cell cell = row.createCell(reportCalculationModel.getReportUnitCell());
|
|
|
- if (cell == null) {
|
|
|
- cell = row.createCell(reportCalculationModel.getReportUnitCell());
|
|
|
- }
|
|
|
- if ("1".equals(reportCalculationModel.getUnitType())) {
|
|
|
+ Row row = CellUtil.getRow(reportCalculationModel.getReportUnitRow(),sheet);
|
|
|
+ Cell cell = CellUtil.getCell(row,reportCalculationModel.getReportUnitCell());
|
|
|
+ if ("1".equals(reportCalculationModel.getUnitStyleType())) {
|
|
|
// 如果单元格类型是公式
|
|
|
cell.setCellFormula(reportCalculationModel.getUnitCalcInfo());
|
|
|
- } else if ("2".equals(reportCalculationModel.getUnitType())) {
|
|
|
+ } else if ("2".equals(reportCalculationModel.getUnitStyleType())) {
|
|
|
// 如果单元格类型是字符串
|
|
|
cell.setCellValue(String.valueOf(reportUnitParamCalcModel.getValue()));
|
|
|
- } else if ("3".equals(reportCalculationModel.getUnitType())) {
|
|
|
+ } else if ("3".equals(reportCalculationModel.getUnitStyleType())) {
|
|
|
// 如果单元格类型是数字
|
|
|
cell.setCellValue((Double) DataUtil.getDataDefault(reportUnitParamCalcModel.getValue(), Double.class));
|
|
|
+ } else {
|
|
|
+ cell.setCellValue("");
|
|
|
}
|
|
|
}
|
|
|
+ workbook.getCreationHelper().createFormulaEvaluator().evaluateAll();
|
|
|
workbook.write(Files.newOutputStream(tempTmpFilePath.toPath()));
|
|
|
workbook.close();
|
|
|
} catch (IOException e) {
|