Browse Source

修改完成,但是必须明确的将单元格上的公式去除

CodeLife Leno 2 months ago
parent
commit
2d0a945d1f

+ 1 - 1
Procedure/backend/project/src/main/java/com/sundata/product/rwa/calc/controllers/CalcRunningController.java

@@ -77,7 +77,7 @@ public class CalcRunningController extends BaseAction {
     public CalcTaskResult startReportInit(@RequestBody CalcInterfaceParam calcInterfaceParam) {
         Map<String, Object> context = new HashMap<>();
         context.put("dataDate", calcInterfaceParam.getDataDate());
-        return calcRunningService.startCalc(calcInterfaceParam.getCalculateInstanceNumber(), new ReportInitUnit(calcInterfaceParam.getCalculateInstanceNumber(), calcInterfaceParam.getCalcCode(), 0, null), context);
+        return calcRunningService.startCalc(calcInterfaceParam.getCalculateInstanceNumber(), new ReportInitUnit(calcInterfaceParam.getCalcCode(), calcInterfaceParam.getCalcCode(), 0, null), context);
     }
 
 

+ 17 - 12
Procedure/backend/project/src/main/java/com/sundata/product/rwa/calc/service/ReportCalcService.java

@@ -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) {

+ 2 - 0
Procedure/backend/project/src/main/java/com/sundata/product/rwa/calc/service/ReportUnitParamCalcService.java

@@ -68,6 +68,8 @@ public class ReportUnitParamCalcService {
             paramCalcModel.setValue(model.getValue());
             models.add(paramCalcModel);
 
+            String delete  = "delete from RWA_SYSTEM_REPORT_PROCESS_TABLEUNIT where CALCINDEX = :CALCINDEX";
+            jdbcTemplate.update(delete, sqlParam);
             String sql = "INSERT INTO RWA_SYSTEM_REPORT_PROCESS_TABLEUNIT(CALCINDEX, SDATE, EDATE, TERM, DATA_DATE, REPORT_RESULT_NO, REPORT_NO, REPORT_UNIT_NO, CALC_TOOK, REPORT_UNIT_STR_TIME, REPORT_UNIT_END_TIME) VALUES (:CALCINDEX, :SDATE, :EDATE, :TERM, :DATA_DATE, :REPORT_RESULT_NO, :REPORT_NO, :REPORT_UNIT_NO, :CALC_TOOK, :REPORT_UNIT_STR_TIME, :REPORT_UNIT_END_TIME)";
 
             sqlParam.addValue("REPORT_UNIT_NO", reportCalculationModel.getReportUnitNo());