瀏覽代碼

性能验证模块 开发 (二期) / 重构相关模块

liyuan 1 年之前
父節點
當前提交
2694fae404
共有 11 個文件被更改,包括 279 次插入253 次删除
  1. 17 107
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/LinearRangeAverageSlope.java
  2. 27 26
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/LinearRangeEP6A.java
  3. 6 6
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/LinearRangeRecoveryMethod.java
  4. 7 7
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/PVItemBuilder.java
  5. 82 4
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/PVModel.java
  6. 33 24
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/PrecisionEP15.java
  7. 6 6
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/PrecisionEP15Item.java
  8. 28 25
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/PrecisionRepeatability.java
  9. 32 13
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/TruenessBiasAssessment.java
  10. 21 16
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/TruenessEP15Patient.java
  11. 20 19
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/TruenessRefernece.java

+ 17 - 107
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/LinearRangeAverageSlope.java

@@ -4,13 +4,17 @@ import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.lc.ibps.components.verification.model.InspectionConfigVO;
 import com.lc.ibps.components.verification.regression.PolynomialRegression;
-import com.lc.ibps.components.verification.report.*;
+import com.lc.ibps.components.verification.report.ChartDTO;
+import com.lc.ibps.components.verification.report.ReportDataDTO;
+import com.lc.ibps.components.verification.report.TableDTO;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.math3.stat.StatUtils;
 import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
 
 import java.time.LocalDate;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 public class LinearRangeAverageSlope extends PVModel {
 
@@ -114,120 +118,26 @@ public class LinearRangeAverageSlope extends PVModel {
         return table;
     }
 
-    @Override
-    public SheetDTO[] buildSheetDTO() {
-        SheetDTO sheet = new SheetDTO("平均斜率");
-        sheet.setReportDataDTO(buildReportTableDTO());
-        sheet.setChartDataDTO(buildChartDTO());
-        return new SheetDTO[]{sheet};
-    }
-
     @Override
     public String generateResult() {
         return null;
     }
 
-    public Map<String, TableDTO> buildReportTableDTO() {
-        Map<String, TableDTO> reports = new HashMap<>();
-        reports.put("表1: 重复性差异检测结果", buildTable1DTO());
-        reports.put("表2: 多项式回归分析结果", buildTable2DTO());
-        reports.put("表3: 线性偏离计算结果", buildTable3DTO());
-        return reports;
-    }
-
-    public Map<String, ChartDTO> buildChartDTO() {
-        Map<String, ChartDTO> charts = new HashMap<>();
-        charts.put("图1: 线性实验", buildChart1DTO());
-        charts.put("图2: 线性评价差值点图", buildChart2DTO());
-        return charts;
-    }
-
-    private ChartDTO buildChart2DTO() {
-        ChartDTO chartDTO = new ChartDTO("linesForRange");
-        double[][] data = new double[targetValues.length][2];
-        for (int i = 0; i < data.length; i++) {
-            data[i] = new double[]{i + 1, diffs[1][i]};
-        }
-//        chartDTO.setData(data);
-        final HashMap<String, Object> config = new HashMap<>();
-        config.put("yAxisUp", 0.1);
-        config.put("yAxisLow", -0.1);
-        config.put("data", JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect));
-
-        chartDTO.setOption(EchartsFreemarkerUtils.generateChart("/scatter/linesForRange.ftl", config));
-        return chartDTO;
-    }
-
-    private ChartDTO buildChart1DTO() {
-        ChartDTO chartDTO = new ChartDTO("polynomialRegression");
-        double[][] data = new double[targetValues.length][2];
-        for (int i = 0; i < data.length; i++) {
-            data[i] = new double[]{targetValues[i], means[i]};
-        }
-//        chartDTO.setData(data);
-        Map<String, Object> map = new HashMap<>();
-        map.put("data", JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect));
-        chartDTO.setOption(EchartsFreemarkerUtils.generateChart("/scatter/polynomialRegression.ftl", map));
-        return chartDTO;
+    @Override
+    public String[] sheetNames() {
+        return new String[0];
     }
 
-    private TableDTO buildTable1DTO() {
-
-        TableDTO table = new TableDTO();
-        String[] header = {"标本号", "均值", "差值Diff", "Diff<sup>2</sup>/2", "%Diff", "%Diff<sup>2</sup>/2"};
-        table.buildHeader(header);
-
-
-        double[][] r = new double[specimensNum][6];
-        double[][] doubles = transposeMatrix(diffs);
-
-        for (int i = 0; i < doubles.length; i++) {
-            r[i] = ArrayUtils.add(doubles[i], 0, i + 1);
-        }
-        table.buildData(r, getScale());
-        return table;
+    @Override
+    public String[] tableNames() {
+        return new String[0];
     }
 
-    private TableDTO buildTable2DTO() {
-
-        TableDTO table = new TableDTO();
-        String[] header = {"阶别", "系数", "系数值", "SE<sub>i</sub>", "t 检验", "S<sub>y.x</sub>", "自由度"};
-        table.buildHeader(header);
-        table.getHeader()[0].put("merge", "true");
-        table.getHeader()[5].put("merge", "true");
-        table.getHeader()[6].put("merge", "true");
-        String[][] r = new String[9][7];
-        int i = 0;
-        for (int j = 0; j < pr1.getParameters().length; j++) {
-            r[i][0] = "1";
-            r[i][1] = String.format("b%d", j);
-            r[i][2] = format(pr1.getParameters()[j]);
-            r[i][3] = format(pr1.getStdErrors()[j]);
-            r[i][4] = format(pr1.gettValues()[j]);
-            r[i][5] = format((pr1.getStdError()));
-            r[i][6] = pr1.getDfDependent().toString();
-            i++;
-        }
-
-        table.buildData(r);
-        return table;
+    @Override
+    public String[] chartNames() {
+        return new String[0];
     }
 
-    private TableDTO buildTable3DTO() {
-
-        TableDTO table = new TableDTO();
-        String[] header = {"标本号", "x<sub>i</sub>", "p(x<sub>i</sub>)", "b<sub>0</sub>+b<sub>1</sub>x<sub>i</sub>", "DL<sub>i</sub>", "%DL<sub>i</sub>"};
-        table.buildHeader(header);
-
-        double[][] r = new double[specimensNum][6];
-        double[][] doubles = transposeMatrix(dli);
-
-        for (int i = 0; i < doubles.length; i++) {
-            r[i] = ArrayUtils.add(doubles[i], 0, i + 1);
-        }
-        table.buildData(r, getScale());
-        return table;
-    }
 
     public static void main(String[] args) {
         InspectionConfigVO config = new InspectionConfigVO("平均斜率", 1, 6,
@@ -236,8 +146,8 @@ public class LinearRangeAverageSlope extends PVModel {
         double[][] data = {{-0.01, -0.01}, {5.00, 4.99}, {10.18, 10.05}, {14.65, 14.65}, {19.57, 19.65}, {24.02, 24.09}};
         LinearRangeAverageSlope ep6 = new LinearRangeAverageSlope(data, config);
         TableDTO tableDTO = ep6.buildDataTableDTO();
-        Map<String, TableDTO> stringTableDTOMap = ep6.buildReportTableDTO();
-        final Map<String, ChartDTO> stringChartDTOMap = ep6.buildChartDTO();
+        Map<String, TableDTO> stringTableDTOMap = ep6.buildTableDTO(0);
+        final Map<String, ChartDTO> stringChartDTOMap = ep6.buildChartDTO(0);
         ReportDataDTO report = new ReportDataDTO();
 
 

+ 27 - 26
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/LinearRangeEP6A.java

@@ -4,7 +4,10 @@ import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.lc.ibps.components.verification.model.InspectionConfigVO;
 import com.lc.ibps.components.verification.regression.PolynomialRegression;
-import com.lc.ibps.components.verification.report.*;
+import com.lc.ibps.components.verification.report.ChartDTO;
+import com.lc.ibps.components.verification.report.EchartsFreemarkerUtils;
+import com.lc.ibps.components.verification.report.ReportDataDTO;
+import com.lc.ibps.components.verification.report.TableDTO;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.math3.stat.StatUtils;
 import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
@@ -146,35 +149,29 @@ public class LinearRangeEP6A extends PVModel {
         return table;
     }
 
-    @Override
-    public SheetDTO[] buildSheetDTO() {
-        SheetDTO sheet = new SheetDTO("EP6-A线性评价");
-        sheet.setReportDataDTO(buildReportTableDTO());
-        sheet.setChartDataDTO(buildChartDTO());
-        return new SheetDTO[]{sheet};
-    }
 
     @Override
     public String generateResult() {
         return null;
     }
 
-    public Map<String, TableDTO> buildReportTableDTO() {
-        Map<String, TableDTO> reports = new HashMap<>();
-        reports.put("表1: 重复性差异检测结果", buildTable1DTO());
-        reports.put("表2: 多项式回归分析结果", buildTable2DTO());
-        reports.put("表3: 线性偏离计算结果", buildTable3DTO());
-        return reports;
+    @Override
+    public String[] sheetNames() {
+        return new String[]{"EP6-A线性评价"};
+    }
+
+    @Override
+    public String[] tableNames() {
+        return new String[]{"表1: 重复性差异检测结果", "表2: 多项式回归分析结果", "表3: 线性偏离计算结果"};
     }
 
-    public Map<String, ChartDTO> buildChartDTO() {
-        Map<String, ChartDTO> charts = new HashMap<>();
-        charts.put("图1: 线性实验", buildChart1DTO());
-        charts.put("图2: 线性评价差值点图", buildChart2DTO());
-        return charts;
+    @Override
+    public String[] chartNames() {
+        return new String[]{"图1: 线性实验", "图2: 线性评价差值点图"};
     }
 
-    private ChartDTO buildChart2DTO() {
+    @Override
+    ChartDTO buildChart2DTO(int sheetIndex) {
         ChartDTO chartDTO = new ChartDTO("linesForRange");
         double[][] data = new double[targetValues.length][2];
         for (int i = 0; i < data.length; i++) {
@@ -190,7 +187,8 @@ public class LinearRangeEP6A extends PVModel {
         return chartDTO;
     }
 
-    private ChartDTO buildChart1DTO() {
+    @Override
+    ChartDTO buildChart1DTO(int sheetIndex) {
         ChartDTO chartDTO = new ChartDTO("polynomialRegression");
         double[][] data = new double[targetValues.length][2];
         for (int i = 0; i < data.length; i++) {
@@ -203,7 +201,8 @@ public class LinearRangeEP6A extends PVModel {
         return chartDTO;
     }
 
-    private TableDTO buildTable1DTO() {
+    @Override
+    TableDTO buildTable1DTO(int sheetIndex) {
 
         TableDTO table = new TableDTO();
         String[] header = {"标本号", "均值", "差值Diff", "Diff<sup>2</sup>/2", "%Diff", "%Diff<sup>2</sup>/2"};
@@ -220,7 +219,8 @@ public class LinearRangeEP6A extends PVModel {
         return table;
     }
 
-    private TableDTO buildTable2DTO() {
+    @Override
+    TableDTO buildTable2DTO(int sheetIndex) {
 
         TableDTO table = new TableDTO();
         String[] header = {"阶别", "系数", "系数值", "SE<sub>i</sub>", "t 检验", "S<sub>y.x</sub>", "自由度"};
@@ -264,7 +264,8 @@ public class LinearRangeEP6A extends PVModel {
         return table;
     }
 
-    private TableDTO buildTable3DTO() {
+    @Override
+    TableDTO buildTable3DTO(int sheetIndex) {
 
         TableDTO table = new TableDTO();
         String[] header = {"标本号", "x<sub>i</sub>", "p(x<sub>i</sub>)", "b<sub>0</sub>+b<sub>1</sub>x<sub>i</sub>", "DL<sub>i</sub>", "%DL<sub>i</sub>"};
@@ -287,8 +288,8 @@ public class LinearRangeEP6A extends PVModel {
         double[][] data = {{-0.01, -0.01}, {5.00, 4.99}, {10.18, 10.05}, {14.65, 14.65}, {19.57, 19.65}, {24.02, 24.09}};
         LinearRangeEP6A ep6 = new LinearRangeEP6A(data, config);
         TableDTO tableDTO = ep6.buildDataTableDTO();
-        Map<String, TableDTO> stringTableDTOMap = ep6.buildReportTableDTO();
-        final Map<String, ChartDTO> stringChartDTOMap = ep6.buildChartDTO();
+        Map<String, TableDTO> stringTableDTOMap = ep6.buildTableDTO(0);
+        final Map<String, ChartDTO> stringChartDTOMap = ep6.buildChartDTO(0);
         ReportDataDTO report = new ReportDataDTO();
 
 

+ 6 - 6
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/LinearRangeRecoveryMethod.java

@@ -3,14 +3,14 @@ package com.lc.ibps.components.verification.model2;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.lc.ibps.components.verification.model.InspectionConfigVO;
-import com.lc.ibps.components.verification.regression.PolynomialRegression;
-import com.lc.ibps.components.verification.report.*;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.math3.stat.StatUtils;
-import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
+import com.lc.ibps.components.verification.report.ChartDTO;
+import com.lc.ibps.components.verification.report.ReportDataDTO;
+import com.lc.ibps.components.verification.report.SheetDTO;
+import com.lc.ibps.components.verification.report.TableDTO;
 
 import java.time.LocalDate;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
 
 public class LinearRangeRecoveryMethod extends LinearRangeAverageSlope {
 

+ 7 - 7
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/PVItemBuilder.java

@@ -94,20 +94,20 @@ public class PVItemBuilder {
 //        PVModel pvModel;
         if (config.getKey().equals("精密度验证")) {
             pvModel = new PrecisionEP15(dataArrays, config);
-        }  else if (config.getKey().equals("重复性验证")) {
+        } else if (config.getKey().equals("重复性验证")) {
             pvModel = new PrecisionRepeatability(dataArrays, config);
         } else if (config.getKey().equals("使用定值参考物质验证")) {
             pvModel = new TruenessRefernece(dataArrays, config);
         } else if (config.getKey().equals("使用患者样品验证")) {
             pvModel = new TruenessEP15Patient(dataArrays, config);
-        } else if(config.getKey().equals("CNAS-GL037偏倚评估")){
-            pvModel = new TruenessBiasAssessment(dataArrays,config);
+        } else if (config.getKey().equals("CNAS-GL037偏倚评估")) {
+            pvModel = new TruenessBiasAssessment(dataArrays, config);
         } else if (config.getKey().equals("408线性评价")) {
             pvModel = new LinearRangeEP6A(dataArrays, config);
-        } else if(config.getKey().equals("平均斜率评价法")){
-            pvModel = new LinearRangeAverageSlope(dataArrays,config);
-        } else if(config.getKey().equals("线性稀释回收法")){
-            pvModel = new LinearRangeRecoveryMethod(dataArrays,config);
+        } else if (config.getKey().equals("平均斜率评价法")) {
+            pvModel = new LinearRangeAverageSlope(dataArrays, config);
+        } else if (config.getKey().equals("线性稀释回收法")) {
+            pvModel = new LinearRangeRecoveryMethod(dataArrays, config);
         } else {
             return null;
         }

+ 82 - 4
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/PVModel.java

@@ -1,12 +1,17 @@
 package com.lc.ibps.components.verification.model2;
 
-import com.lc.ibps.components.verification.funcs.xValue;
 import com.lc.ibps.components.verification.model.InspectionConfigVO;
+import com.lc.ibps.components.verification.report.ChartDTO;
 import com.lc.ibps.components.verification.report.SheetDTO;
 import com.lc.ibps.components.verification.report.TableDTO;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.math3.distribution.ChiSquaredDistribution;
 import org.apache.commons.math3.distribution.TDistribution;
 
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
 public abstract class PVModel {
 
     private int scale;
@@ -15,6 +20,7 @@ public abstract class PVModel {
     protected int specimensNum;
     protected int repeatNum;
     protected String[] specimensName;
+
     public PVModel(double[][] data, InspectionConfigVO configVO) {
         this.data = data;
         this.units = configVO.getUnits();
@@ -88,9 +94,9 @@ public abstract class PVModel {
         return after;
     }
 
-    public static String getTEaFormat(double value){
+    public static String getTEaFormat(double value) {
         String tea = "";
-        if(value == 0.5){
+        if (value == 0.5) {
             tea = "1/2TEa";
         } else if (value == 0.25) {
             tea = "1/4TEa";
@@ -103,9 +109,9 @@ public abstract class PVModel {
     }
 
     public abstract void calculate();
+
     public abstract TableDTO buildDataTableDTO();
 
-    public abstract SheetDTO[] buildSheetDTO();
 
     public abstract String generateResult();
 
@@ -125,5 +131,77 @@ public abstract class PVModel {
         this.units = units;
     }
 
+    public double[] array2DTo1D(double[][] source) {
+        return Arrays.stream(source)
+                .flatMapToDouble(Arrays::stream)
+                .toArray();
+    }
+
+    public abstract String[] sheetNames();
+
+    public abstract String[] tableNames();
+
+    public abstract String[] chartNames();
+
+    TableDTO buildTable1DTO(int sheetIndex) {
+        return null;
+    }
+
+    TableDTO buildTable2DTO(int sheetIndex) {
+        return null;
+    }
+
+    TableDTO buildTable3DTO(int sheetIndex) {
+        return null;
+    }
+
+    ChartDTO buildChart1DTO(int sheetIndex) {
+        return null;
+    }
+
+    ChartDTO buildChart2DTO(int sheetIndex) {
+        return null;
+    }
+
+    ChartDTO buildChart3DTO(int sheetIndex) {
+        return null;
+    }
+
+    public SheetDTO[] buildSheetDTO() {
+        final String[] sheetNames = sheetNames();
+        if (ArrayUtils.isEmpty(sheetNames)) return null;
+
+        SheetDTO[] sheets = new SheetDTO[sheetNames.length];
+        for (int i = 0; i < sheets.length; i++) {
+            SheetDTO sheet = new SheetDTO(sheetNames[i]);
+            sheet.setReportDataDTO(buildTableDTO(i));
+            sheet.setChartDataDTO(buildChartDTO(i));
+            sheets[i] = sheet;
+        }
 
+        return sheets;
+    }
+
+    public Map<String, TableDTO> buildTableDTO(int sheetIndex) {
+        final String[] tableNames = tableNames();
+        if (ArrayUtils.isEmpty(tableNames)) return null;
+        Map<String, TableDTO> reports = new HashMap<>();
+        TableDTO[] tables = new TableDTO[]{buildTable1DTO(sheetIndex), buildTable2DTO(sheetIndex), buildTable3DTO(sheetIndex)};
+        for (int i = 0; i < tableNames.length; i++) {
+            reports.put(tableNames[i], tables[i]);
+        }
+        return reports;
+    }
+
+
+    public Map<String, ChartDTO> buildChartDTO(int sheetIndex) {
+        final String[] chartNames = chartNames();
+        if (ArrayUtils.isEmpty(chartNames)) return null;
+        Map<String, ChartDTO> reports = new HashMap<>();
+        ChartDTO[] charts = new ChartDTO[]{buildChart1DTO(sheetIndex), buildChart2DTO(sheetIndex), buildChart3DTO(sheetIndex)};
+        for (int i = 0; i < chartNames.length; i++) {
+            reports.put(chartNames[i], charts[i]);
+        }
+        return reports;
+    }
 }

+ 33 - 24
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/PrecisionEP15.java

@@ -3,8 +3,10 @@ package com.lc.ibps.components.verification.model2;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.lc.ibps.components.verification.model.InspectionConfigVO;
-import com.lc.ibps.components.verification.report.*;
-import org.apache.commons.lang3.ArrayUtils;
+import com.lc.ibps.components.verification.report.EchartsFreemarkerUtils;
+import com.lc.ibps.components.verification.report.ReportDataDTO;
+import com.lc.ibps.components.verification.report.ReportFactory;
+import com.lc.ibps.components.verification.report.TableDTO;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.math3.linear.MatrixUtils;
 import org.apache.commons.math3.linear.RealMatrix;
@@ -29,13 +31,13 @@ public class PrecisionEP15 extends PVModel {
             items.add(new PrecisionEP15Item(specimensName[i], sub, configVO));
         }
     }
+
     @Override
     public void calculate() {
-        items.stream().forEach(i->i.calculate());
+        items.stream().forEach(i -> i.calculate());
     }
 
 
-
     @Override
     public TableDTO buildDataTableDTO() {
         String[] h = new String[specimensName.length + 1];
@@ -69,20 +71,28 @@ public class PrecisionEP15 extends PVModel {
     }
 
     @Override
-    public SheetDTO[] buildSheetDTO() {
-        SheetDTO sheet = new SheetDTO("精密度验证");
-        sheet.setReportDataDTO(buildReportTableDTO());
-        return new SheetDTO[]{sheet};
+    public String generateResult() {
+        return EchartsFreemarkerUtils.generate("/report/precisionEP15A2.ftl", this);
+
     }
 
     @Override
-    public String generateResult() {
-        return EchartsFreemarkerUtils.generate("/report/precisionEP15A2.ftl", this);
+    public String[] sheetNames() {
+        return new String[]{"精密度验证"};
+    }
 
+    @Override
+    public String[] tableNames() {
+        return new String[]{"表1: 精密度验证结果"};
     }
 
-    private Map<String, TableDTO> buildReportTableDTO() {
-        Map<String, TableDTO> reports = new HashMap<>();
+    @Override
+    public String[] chartNames() {
+        return new String[0];
+    }
+
+    @Override
+    TableDTO buildTable1DTO(int sheetIndex) {
         TableDTO table = new TableDTO();
 //        String[][] data = new String[8][2];
 //
@@ -97,26 +107,25 @@ public class PrecisionEP15 extends PVModel {
 //        table.buildData(data);
 //        reports.put(item.name, table);
 
-        String[] header = {"样本名", "总均值", "批内标准差S<sub>r</sub>", "批内CV<sub>r</sub>","验证值<sub>批内</sub>",
-                "批间方差 V<sub>b</sub>","室内标准差S<sub>l</sub>","室内CV<sub>l</sub>","验证值<sub>室内</sub>"};
+        String[] header = {"样本名", "总均值", "批内标准差S<sub>r</sub>", "批内CV<sub>r</sub>", "验证值<sub>批内</sub>",
+                "批间方差 V<sub>b</sub>", "室内标准差S<sub>l</sub>", "室内CV<sub>l</sub>", "验证值<sub>室内</sub>"};
         table.buildHeader(header);
         String[][] d = new String[specimensNum][9];
         for (int i = 0; i < d.length; i++) {
             String[] subData = new String[9];
             subData[0] = specimensName[i];
-            subData[1] =  format(items.get(i).getMean());
+            subData[1] = format(items.get(i).getMean());
             subData[2] = format(items.get(i).getSdr());
-            subData[3] =  format(items.get(i).getCvr());
+            subData[3] = format(items.get(i).getCvr());
             subData[4] = format(items.get(i).getVerR());
             subData[5] = format(items.get(i).getVb());
             subData[6] = format(items.get(i).getSdl());
-            subData[7] =  format(items.get(i).getCvl());
-            subData[8] = format(items.get(i).getVerL());;
+            subData[7] = format(items.get(i).getCvl());
+            subData[8] = format(items.get(i).getVerL());
             d[i] = subData;
         }
         table.buildData(d);
-        reports.put("表1: 精密度验证结果", table);
-        return reports;
+        return table;
     }
 
     public static void main(String[] args) {
@@ -129,15 +138,15 @@ public class PrecisionEP15 extends PVModel {
         config.setUnits("mmg/L");
         config.setKey("精密度验证");
         RandomUtils.nextDouble();
-        double[][] data = new double[config.getDays()][config.getRepeatNum()*config.getSpecimensNum()];
+        double[][] data = new double[config.getDays()][config.getRepeatNum() * config.getSpecimensNum()];
         for (int i = 0; i < config.getDays(); i++) {
-            for (int j = 0; j < config.getRepeatNum()*config.getSpecimensNum(); j++) {
-                data[i][j] = RandomUtils.nextDouble(3.12,3.45);
+            for (int j = 0; j < config.getRepeatNum() * config.getSpecimensNum(); j++) {
+                data[i][j] = RandomUtils.nextDouble(3.12, 3.45);
             }
         }
         RealMatrix matrix = MatrixUtils.createRealMatrix(data);
         RealMatrixFormat matrixFormat = new RealMatrixFormat("", "", "", "\n",
-                "", ",",new DecimalFormat( "0.00" ));
+                "", ",", new DecimalFormat("0.00"));
         System.out.println(matrixFormat.format(matrix));
 
         PVItemBuilder pvItemBuilder = PVItemBuilder.getInstance(config);

+ 6 - 6
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/PrecisionEP15Item.java

@@ -54,7 +54,7 @@ public class PrecisionEP15Item {
     private double verL;
     private double verR;
     private final int level;
-    private int df;
+    private final int df;
 
     private final double p;//0.01 or 0.05
 
@@ -74,7 +74,7 @@ public class PrecisionEP15Item {
         } else {
             this.p = 0.01;
         }
-        this.df = configVO.getDays() * (configVO.getRepeatNum()-1);
+        this.df = configVO.getDays() * (configVO.getRepeatNum() - 1);
     }
 
     public double getN() {
@@ -244,18 +244,18 @@ public class PrecisionEP15Item {
 
         cvr = (sdr / mean) * 100;
         cvl = (sdl / mean) * 100;
-        if(allowableSDl == 0) {
+        if (allowableSDl == 0) {
             //实验室允许不精密度
             allowableSDr = allowableCVr * mean / 100;
             allowableSDl = allowableCVl * mean / 100;
         } else if (allowableCVr == 0) {
-            allowableCVr = 100*(allowableSDr/mean);
-            allowableCVl = 100*(allowableSDl/mean);
+            allowableCVr = 100 * (allowableSDr / mean);
+            allowableCVl = 100 * (allowableSDl / mean);
         }
         double d = data.length;
 
 //        double cr = PVModel.getCValue(df, level, 0.05);
-        verR = allowableSDr * Math.sqrt(PVModel.getCValue(df, level, 0.05)/df);
+        verR = allowableSDr * Math.sqrt(PVModel.getCValue(df, level, 0.05) / df);
 
         //t=((((C14-1)*(C16^2))+(C14*M11))^2)/(((C14-1)/C13*(C16^4))+(((C14^2)*(M11^2))/(C13-1)))
         t = (Math.pow((((n - 1) * (Math.pow(sdr, 2))) + (n * vb)), 2)) / (((n - 1) / d * (Math.pow(sdr, 4))) + (((Math.pow(n, 2)) * (Math.pow(vb, 2))) / (d - 1)));

+ 28 - 25
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/PrecisionRepeatability.java

@@ -3,8 +3,10 @@ package com.lc.ibps.components.verification.model2;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.lc.ibps.components.verification.model.InspectionConfigVO;
-import com.lc.ibps.components.verification.report.*;
-import org.apache.commons.lang3.ArrayUtils;
+import com.lc.ibps.components.verification.report.EchartsFreemarkerUtils;
+import com.lc.ibps.components.verification.report.ReportDataDTO;
+import com.lc.ibps.components.verification.report.ReportFactory;
+import com.lc.ibps.components.verification.report.TableDTO;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.math3.linear.MatrixUtils;
 import org.apache.commons.math3.linear.RealMatrix;
@@ -14,14 +16,12 @@ import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
 import java.text.DecimalFormat;
 import java.time.LocalDate;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
-public class PrecisionRepeatability extends PVModel{
+public class PrecisionRepeatability extends PVModel {
     private double[] cvs;
-    private  double[] means;
-    private  double[] standardDeviations;
+    private double[] means;
+    private double[] standardDeviations;
     private double batchCVSValue;
     private String teaFormat;
 
@@ -41,7 +41,7 @@ public class PrecisionRepeatability extends PVModel{
             DescriptiveStatistics stat = new DescriptiveStatistics(data[i]);
             means[i] = stat.getMean();
             standardDeviations[i] = stat.getStandardDeviation();
-            cvs[i] = 100 * standardDeviations[i]/means[i];
+            cvs[i] = 100 * standardDeviations[i] / means[i];
         }
     }
 
@@ -70,22 +70,10 @@ public class PrecisionRepeatability extends PVModel{
     }
 
     @Override
-    public SheetDTO[] buildSheetDTO() {
-        SheetDTO sheet = new SheetDTO("重复性验证");
-        sheet.setReportDataDTO(buildReportTableDTO());
-        return new SheetDTO[]{sheet};
-    }
-
-    private Map<String, TableDTO> buildReportTableDTO() {
-        Map<String, TableDTO> reports = new HashMap<>();
-        reports.put("表1: 重复性验证结果", buildTable1DTO());
-        return reports;
-    }
-
-    private TableDTO buildTable1DTO() {
+    TableDTO buildTable1DTO(int sheetIndex) {
 
         TableDTO table = new TableDTO();
-        String[] header = {"样本名", "均值(mean)", "标准差(SD)", "%CV",teaFormat};
+        String[] header = {"样本名", "均值(mean)", "标准差(SD)", "%CV", teaFormat};
         table.buildHeader(header);
 
 
@@ -108,6 +96,21 @@ public class PrecisionRepeatability extends PVModel{
         return EchartsFreemarkerUtils.generate("/report/precisionRepeatability.ftl", this);
     }
 
+    @Override
+    public String[] sheetNames() {
+        return new String[]{"重复性验证"};
+    }
+
+    @Override
+    public String[] tableNames() {
+        return new String[]{"表1: 重复性验证结果"};
+    }
+
+    @Override
+    public String[] chartNames() {
+        return new String[0];
+    }
+
     public double[] getCvs() {
         return cvs;
     }
@@ -148,7 +151,7 @@ public class PrecisionRepeatability extends PVModel{
         this.teaFormat = teaFormat;
     }
 
-    public static void main(String[] args){
+    public static void main(String[] args) {
         InspectionConfigVO config = new InspectionConfigVO("test", 1, 2,
                 null, 10, LocalDate.now(), true);
         config.setBatchCVS(0.25);
@@ -160,12 +163,12 @@ public class PrecisionRepeatability extends PVModel{
         double[][] data = new double[config.getSpecimensNum()][config.getRepeatNum()];
         for (int i = 0; i < config.getSpecimensNum(); i++) {
             for (int j = 0; j < config.getRepeatNum(); j++) {
-                data[i][j] = RandomUtils.nextDouble(3.12,3.45);
+                data[i][j] = RandomUtils.nextDouble(3.12, 3.45);
             }
         }
         RealMatrix matrix = MatrixUtils.createRealMatrix(data);
         RealMatrixFormat matrixFormat = new RealMatrixFormat("", "", "", "\n",
-                "", ",",new DecimalFormat( "0.00" ));
+                "", ",", new DecimalFormat("0.00"));
         System.out.println(matrixFormat.format(matrix));
         PVItemBuilder pvItemBuilder = PVItemBuilder.getInstance(config);
         pvItemBuilder.buildPVModel(data);

+ 32 - 13
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/TruenessBiasAssessment.java

@@ -5,29 +5,38 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.lc.ibps.components.verification.model.InspectionConfigVO;
 import com.lc.ibps.components.verification.report.ReportDataDTO;
 import com.lc.ibps.components.verification.report.ReportFactory;
-import com.lc.ibps.components.verification.report.SheetDTO;
 import com.lc.ibps.components.verification.report.TableDTO;
-import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.math3.linear.MatrixUtils;
 import org.apache.commons.math3.linear.RealMatrix;
 import org.apache.commons.math3.linear.RealMatrixFormat;
+import org.apache.commons.math3.stat.StatUtils;
 
 import java.text.DecimalFormat;
 import java.time.LocalDate;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
 
-public class TruenessBiasAssessment extends PVModel{
+public class TruenessBiasAssessment extends PVModel {
     private double[] targetValues;
     private double tea;
     private double bias;
+    private final double[] means;
+
     public TruenessBiasAssessment(double[][] data, InspectionConfigVO configVO) {
         super(data, configVO);
+        this.means = new double[specimensNum];
     }
 
     @Override
     public void calculate() {
-
+        final RealMatrix realMatrix = MatrixUtils.createRealMatrix(data);
+        for (int i = 0; i < specimensName.length; i++) {
+            double[][] sub = new double[data.length][repeatNum];
+            realMatrix.copySubMatrix(0, data.length - 1,
+                    i * repeatNum, (i + 1) * repeatNum - 1, sub);
+            means[i] = StatUtils.mean(array2DTo1D(sub));
+        }
     }
 
     @Override
@@ -52,13 +61,23 @@ public class TruenessBiasAssessment extends PVModel{
     }
 
     @Override
-    public SheetDTO[] buildSheetDTO() {
-        return new SheetDTO[0];
+    public String generateResult() {
+        return null;
     }
 
     @Override
-    public String generateResult() {
-        return null;
+    public String[] sheetNames() {
+        return new String[0];
+    }
+
+    @Override
+    public String[] tableNames() {
+        return new String[0];
+    }
+
+    @Override
+    public String[] chartNames() {
+        return new String[0];
     }
 
     public static void main(String[] args) {
@@ -71,15 +90,15 @@ public class TruenessBiasAssessment extends PVModel{
         config.setUnits("mmg/L");
         config.setKey("CNAS-GL037偏倚评估");
         RandomUtils.nextDouble();
-        double[][] data = new double[config.getDays()][config.getRepeatNum()*config.getSpecimensNum()];
+        double[][] data = new double[config.getDays()][config.getRepeatNum() * config.getSpecimensNum()];
         for (int i = 0; i < config.getDays(); i++) {
-            for (int j = 0; j < config.getRepeatNum()*config.getSpecimensNum(); j++) {
-                data[i][j] = RandomUtils.nextDouble(3.12,3.45);
+            for (int j = 0; j < config.getRepeatNum() * config.getSpecimensNum(); j++) {
+                data[i][j] = RandomUtils.nextDouble(3.12, 3.45);
             }
         }
         RealMatrix matrix = MatrixUtils.createRealMatrix(data);
         RealMatrixFormat matrixFormat = new RealMatrixFormat("", "", "", "\n",
-                "", ",",new DecimalFormat( "0.00" ));
+                "", ",", new DecimalFormat("0.00"));
         System.out.println(matrixFormat.format(matrix));
         PVItemBuilder pvItemBuilder = PVItemBuilder.getInstance(config);
         pvItemBuilder.buildPVModel(data);

+ 21 - 16
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/TruenessEP15Patient.java

@@ -16,7 +16,6 @@ import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
 import java.text.DecimalFormat;
 import java.time.LocalDate;
 import java.util.HashMap;
-import java.util.Map;
 
 public class TruenessEP15Patient extends PVModel {
     //多个样本均值 y
@@ -53,6 +52,7 @@ public class TruenessEP15Patient extends PVModel {
         this.n = this.y.length;
         this.sdClaim = configVO.getClaimValue();
     }
+
     @Override
     public void calculate() {
 
@@ -186,8 +186,8 @@ public class TruenessEP15Patient extends PVModel {
         return table;
     }
 
-    public Map<String, TableDTO> buildReportTableDTO() {
-        Map<String, TableDTO> reports = new HashMap<>();
+    @Override
+    TableDTO buildTable1DTO(int sheetIndex) {
         TableDTO table = new TableDTO();
         String[][] data = new String[8][2];
 
@@ -208,26 +208,31 @@ public class TruenessEP15Patient extends PVModel {
 //        data[6] =new String[]{"实验室内标准差 (S<sub>1</sub>)" , format(item.s1)};
 //        data[7] =new String[]{"实验室变异系数 (CV)" , format(item.cv1)};
         table.buildData(data);
-        reports.put("表1", table);
-        return reports;
+        return table;
     }
 
     @Override
-    public SheetDTO[] buildSheetDTO() {
-        SheetDTO sheet = new SheetDTO("EP15-A方法学比对");
-        sheet.setReportDataDTO(buildReportTableDTO());
-        HashMap<String, ChartDTO> map = new HashMap<>();
-        map.put("图1: 对比数据的差值图", buildChart1DTO());
-        sheet.setChartDataDTO(map);
-        return new SheetDTO[]{sheet};
+    public String generateResult() {
+        return EchartsFreemarkerUtils.generate("/report/truesnessUsingPatient.ftl", this);
     }
 
     @Override
-    public String generateResult() {
-        return EchartsFreemarkerUtils.generate("/report/truesnessUsingPatient.ftl", this);
+    public String[] sheetNames() {
+        return new String[]{"EP15-A方法学比对"};
     }
 
-    private ChartDTO buildChart1DTO() {
+    @Override
+    public String[] tableNames() {
+        return new String[]{"表1"};
+    }
+
+    @Override
+    public String[] chartNames() {
+        return new String[]{"图1: 对比数据的差值图"};
+    }
+
+    @Override
+    ChartDTO buildChart1DTO(int sheetIndex) {
         ChartDTO chartDTO = new ChartDTO("linesForRange");
         double[][] data = new double[yx.length][2];
         for (int i = 0; i < data.length; i++) {
@@ -270,7 +275,7 @@ public class TruenessEP15Patient extends PVModel {
                 {435, 430}};
         RealMatrix matrix = MatrixUtils.createRealMatrix(data);
         RealMatrixFormat matrixFormat = new RealMatrixFormat("", "", "", "\n",
-                "", ",",new DecimalFormat( "0.00" ));
+                "", ",", new DecimalFormat("0.00"));
         System.out.println(matrixFormat.format(matrix));
         TruenessEP15Patient tr = new TruenessEP15Patient(transposeMatrix(data), config);
 

+ 20 - 19
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/TruenessRefernece.java

@@ -30,7 +30,7 @@ public class TruenessRefernece extends PVModel {
 
     @Override
     public void calculate() {
-        items.stream().forEach(i->i.calculate());
+        items.stream().forEach(i -> i.calculate());
     }
 
 
@@ -66,21 +66,8 @@ public class TruenessRefernece extends PVModel {
     }
 
     @Override
-    public SheetDTO[] buildSheetDTO() {
-        SheetDTO[] reports = new SheetDTO[items.size()];
-        for (int i = 0; i < items.size(); i++) {
-            final SheetDTO sheet = new SheetDTO(items.get(i).name);
-            Map<String, TableDTO> table = new HashMap<>();
-            table.putAll(buildTable1DTO(items.get(i)));
-            sheet.setReportDataDTO(table);
-            reports[i] = sheet;
-        }
-
-        return reports;
-    }
-
-    private Map<String, TableDTO> buildTable1DTO(TruenessReferneceItem item) {
-        Map<String, TableDTO> reports = new HashMap<>();
+    TableDTO buildTable1DTO(int index) {
+        final TruenessReferneceItem item = items.get(index);
         TableDTO table = new TableDTO();
         String[][] data = new String[6][2];
 
@@ -91,8 +78,7 @@ public class TruenessRefernece extends PVModel {
         data[4] = new String[]{"验证区间上限", format(item.getUvl())};
         data[5] = new String[]{"验证区间下限", format(item.getLvl())};
         table.buildData(data);
-        reports.put(item.name, table);
-        return reports;
+        return table;
     }
 
     @Override
@@ -101,6 +87,21 @@ public class TruenessRefernece extends PVModel {
         return EchartsFreemarkerUtils.generate("/report/truesnessUsingRefernece.ftl", this);
     }
 
+    @Override
+    public String[] sheetNames() {
+        return specimensName;
+    }
+
+    @Override
+    public String[] tableNames() {
+        return specimensName;
+    }
+
+    @Override
+    public String[] chartNames() {
+        return new String[0];
+    }
+
     public List<TruenessReferneceItem> getItems() {
         return items;
     }
@@ -131,7 +132,7 @@ public class TruenessRefernece extends PVModel {
                 {2.09, 2.04, 2.04, 2.09}};
         RealMatrix matrix = MatrixUtils.createRealMatrix(data);
         RealMatrixFormat matrixFormat = new RealMatrixFormat("", "", "", "\n",
-                "", ",",new DecimalFormat( "0.00" ));
+                "", ",", new DecimalFormat("0.00"));
         System.out.println(matrixFormat.format(matrix));
         TruenessRefernece tr = new TruenessRefernece(data, config);
         TableDTO tableDTO = tr.buildDataTableDTO();