Browse Source

[性能验证]添加Excel报告文件下载

liyuan 2 years ago
parent
commit
f6d52acc27

+ 9 - 6
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelExportReportServer.java

@@ -40,6 +40,9 @@ public class PVExcelExportReportServer extends ExcelExportServer {
                 sheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), index,
                 sheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), index,
                         index + 1));
                         index + 1));
                 entity.setKey(getCellStyle(func));
                 entity.setKey(getCellStyle(func));
+                if (func.equals(FunctionEnum.TARGET)) {
+                    recordCalcVO.setTargetValue(item.getConfig().getTargetValue()[i]);
+                }
                 createStringCell(row, index++, getCalcValue(func, recordCalcVO), getStyles(false, entity), null);
                 createStringCell(row, index++, getCalcValue(func, recordCalcVO), getStyles(false, entity), null);
                 createStringCell(row, index++, "0", getStyles(false, entity), null);
                 createStringCell(row, index++, "0", getStyles(false, entity), null);
 
 
@@ -55,7 +58,7 @@ public class PVExcelExportReportServer extends ExcelExportServer {
         for (int i = 0; i < 3; i++) {
         for (int i = 0; i < 3; i++) {
             row = sheet.createRow(sheet.getLastRowNum() + 1);
             row = sheet.createRow(sheet.getLastRowNum() + 1);
             row.setHeight((short) (entity.getHeight() * 50));
             row.setHeight((short) (entity.getHeight() * 50));
-            createStringCell(row, 0, "结", getStyles(false, entity), null);
+            createStringCell(row, 0, "结果分析", getStyles(false, entity), null);
             createStringCell(row, 1, "", getStyles(false, entity), null);
             createStringCell(row, 1, "", getStyles(false, entity), null);
             createStringCell(row, 2, "PASS", getStyles(false, entity), null);
             createStringCell(row, 2, "PASS", getStyles(false, entity), null);
             for (int j = 3; j < index; j++) createStringCell(row, j, "", getStyles(false, entity), null);
             for (int j = 3; j < index; j++) createStringCell(row, j, "", getStyles(false, entity), null);
@@ -73,6 +76,10 @@ public class PVExcelExportReportServer extends ExcelExportServer {
                 return recordCalcVO.getSd().getStr();
                 return recordCalcVO.getSd().getStr();
             case AVERAGE:
             case AVERAGE:
                 return recordCalcVO.getAverage().getStr();
                 return recordCalcVO.getAverage().getStr();
+            case TARGET:
+                return recordCalcVO.getTargetValue().toString();
+            case ABSDEV:
+                return Double.toString(recordCalcVO.calcAbsoluteDeviation());
             default:
             default:
                 return "";
                 return "";
         }
         }
@@ -82,12 +89,8 @@ public class PVExcelExportReportServer extends ExcelExportServer {
         switch (func) {
         switch (func) {
             case CV:
             case CV:
                 return "statistic-percent";
                 return "statistic-percent";
-            case SD:
-                return "statistic-double";
-            case AVERAGE:
-                return "statistic-double";
             default:
             default:
-                return "";
+                return "statistic-double";
         }
         }
     }
     }
 
 

+ 11 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVTest.java

@@ -67,11 +67,21 @@ public class PVTest {
         FileInputStream in2 = new FileInputStream(file2);
         FileInputStream in2 = new FileInputStream(file2);
         item2.importExcelRecord(in2);
         item2.importExcelRecord(in2);
 
 
+        //正确度
+        InspectionConfigVO config3 = new InspectionConfigVO("正确度",5,2,
+                new String[]{"L2","L4"},2, LocalDate.now(),true);
+        config3.setFunc(new FunctionEnum[]{FunctionEnum.AVERAGE,FunctionEnum.TARGET,FunctionEnum.ABSDEV});
+        config3.setTargetValue(new double[]{6.32,4.32});
+        InspectionItemVO item3 = new InspectionItemVO(config3);
+        File file3 = new File(String.format("C:/tmp/%sdata.xlsx",config3.getName()));
+        FileInputStream in3 = new FileInputStream(file3);
+        item3.importExcelRecord(in3);
+
         InspectionVO vo = new InspectionVO();
         InspectionVO vo = new InspectionVO();
         vo.setName("TEST");
         vo.setName("TEST");
         vo.getItem().add(item);
         vo.getItem().add(item);
         vo.getItem().add(item2);
         vo.getItem().add(item2);
-
+        vo.getItem().add(item3);
         final Workbook workbook = vo.exportExcelReport();
         final Workbook workbook = vo.exportExcelReport();
         FileOutputStream fos = new FileOutputStream(String.format("C:/tmp/%s.xlsx",vo.getName()));
         FileOutputStream fos = new FileOutputStream(String.format("C:/tmp/%s.xlsx",vo.getName()));
         workbook.write(fos);
         workbook.write(fos);

+ 3 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model/FunctionEnum.java

@@ -3,7 +3,9 @@ package com.lc.ibps.components.verification.model;
 public enum FunctionEnum {
 public enum FunctionEnum {
     SD("SD值"),
     SD("SD值"),
     AVERAGE("均值"),
     AVERAGE("均值"),
-    CV("CV值");
+    CV("CV值"),
+    TARGET("靶值"),
+    ABSDEV("绝对偏差");
     private String text;
     private String text;
 
 
 
 

+ 10 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model/InspectionConfigVO.java

@@ -20,6 +20,8 @@ public class InspectionConfigVO {
 
 
     private FunctionEnum[] func;
     private FunctionEnum[] func;
 
 
+    private double[] targetValue;
+
     public InspectionConfigVO(String name, int days, int specimensNum, String[] specimensName,
     public InspectionConfigVO(String name, int days, int specimensNum, String[] specimensName,
                               int repeatNum, LocalDate startDate,boolean isConvert) {
                               int repeatNum, LocalDate startDate,boolean isConvert) {
         this.name = name;
         this.name = name;
@@ -97,4 +99,12 @@ public class InspectionConfigVO {
     public void setFunc(FunctionEnum[] func) {
     public void setFunc(FunctionEnum[] func) {
         this.func = func;
         this.func = func;
     }
     }
+
+    public double[] getTargetValue() {
+        return targetValue;
+    }
+
+    public void setTargetValue(double[] targetValue) {
+        this.targetValue = targetValue;
+    }
 }
 }

+ 1 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model/InspectionItemVO.java

@@ -24,7 +24,7 @@ public class InspectionItemVO {
     public static String DISPLAY_NUMBER = "次数";
     public static String DISPLAY_NUMBER = "次数";
     public static String DISPLAY_VALUE = "检测值";
     public static String DISPLAY_VALUE = "检测值";
 
 
-    public static String DISPLAY_LOG = "LOG 值";
+    public static String DISPLAY_LOG = "对数值";
 
 
     public static String DISPLAY_DATE = "实验日期";
     public static String DISPLAY_DATE = "实验日期";
 
 

+ 13 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model/RecordCalcVO.java

@@ -23,6 +23,7 @@ public class RecordCalcVO {
     private xValue sd;
     private xValue sd;
     //sd/average
     //sd/average
     private xValue cv;
     private xValue cv;
+    private Double targetValue;
 
 
     public RecordCalcVO(xValue[] data,boolean isConvert) {
     public RecordCalcVO(xValue[] data,boolean isConvert) {
         this.data = data;
         this.data = data;
@@ -53,7 +54,10 @@ public class RecordCalcVO {
         convertedData = xLog10.eval(data);
         convertedData = xLog10.eval(data);
     }
     }
 
 
-    public double calcAbsoluteDeviation(double targetValue){
+    public double calcAbsoluteDeviation(){
+        if(targetValue == null){
+            return 0;
+        }
         return targetValue - getAverage().getDoub();
         return targetValue - getAverage().getDoub();
     }
     }
 
 
@@ -64,4 +68,12 @@ public class RecordCalcVO {
     public xValue[] getConvertedData() {
     public xValue[] getConvertedData() {
         return convertedData;
         return convertedData;
     }
     }
+
+    public Double getTargetValue() {
+        return targetValue;
+    }
+
+    public void setTargetValue(Double targetValue) {
+        this.targetValue = targetValue;
+    }
 }
 }