Преглед изворни кода

[task-1766] 性能验证模块 开发 (二期) / 【后端】验证报告的接口开发

Li Yuan пре 1 година
родитељ
комит
45789c93e5

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

@@ -11,7 +11,7 @@ import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
 
 import java.util.*;
 
-public class EP6ALinearRangeVO extends CalcVO {
+public class LinearRangeEP6A extends CalcVO {
 
     private double[][] data;
 
@@ -38,7 +38,7 @@ public class EP6ALinearRangeVO extends CalcVO {
     private double sdr;
     private double cvr;
 
-    public EP6ALinearRangeVO(double[][] data, double[] targetValues, double claimValue,int scale){
+    public LinearRangeEP6A(double[][] data, double[] targetValues, double claimValue, int scale){
         this.data = data;
         this.setScale(scale);
         this.specimensNum = data.length;
@@ -190,7 +190,7 @@ public class EP6ALinearRangeVO extends CalcVO {
             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.gettValue()[j]);
+            r[i][4] = format(pr1.gettValues()[j]);
             r[i][5] = format((pr1.getStdError()));
             r[i][6] = pr1.getDfDependent().toString();
             i++;
@@ -200,7 +200,7 @@ public class EP6ALinearRangeVO extends CalcVO {
             r[i][1] = String.format("b%d",j);
             r[i][2] = format(pr2.getParameters()[j]);
             r[i][3] = format(pr2.getStdErrors()[j]);
-            r[i][4] = format(pr2.gettValue()[j]);
+            r[i][4] = format(pr2.gettValues()[j]);
             r[i][5] = format((pr2.getStdError()));
             r[i][6] = pr2.getDfDependent().toString();
             i++;
@@ -210,7 +210,7 @@ public class EP6ALinearRangeVO extends CalcVO {
             r[i][1] = String.format("b%d",j);
             r[i][2] = format(pr3.getParameters()[j]);
             r[i][3] = format(pr3.getStdErrors()[j]);
-            r[i][4] = format(pr3.gettValue()[j]);
+            r[i][4] = format(pr3.gettValues()[j]);
             r[i][5] = format((pr3.getStdError()));
             r[i][6] = pr3.getDfDependent().toString();
             i++;
@@ -236,7 +236,7 @@ public class EP6ALinearRangeVO extends CalcVO {
 
     public static void main(String[] args){
         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}};
-        EP6ALinearRangeVO ep6 = new EP6ALinearRangeVO(data, new double[]{0,24.09},1,3);
+        LinearRangeEP6A ep6 = new LinearRangeEP6A(data, new double[]{0,24.09},1,3);
         TableDTO tableDTO = ep6.buildDataTableDTO();
         Map<String, TableDTO> stringTableDTOMap = ep6.buildReportTableDTO();
         ReportDataDTO report = new ReportDataDTO();

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

@@ -109,7 +109,7 @@ public class PVItemBuilder {
                 for (int j = 0; j < list.size(); j++) {
                     data[j] = CalcVO.transposeXValue(list.get(j).getConvertedData().get(sName));
                 }
-                calcMap.put(sName, new EP15PrecisionVO(data,config.getBatchCVSValue(),config.getDailyCVSValue(),config.getDecimal()));
+                calcMap.put(sName, new PrecisionEP15(data,config.getBatchCVSValue(),config.getDailyCVSValue(),config.getDecimal()));
             }
         }else if(config.getName().equals("定值参考物质验证")){
             for (String sName : config.getSpecimensName()) {
@@ -120,16 +120,16 @@ public class PVItemBuilder {
                         total[j * xValues.length + k] = xValues[k];
                     }
                 }
-                calcMap.put(sName, new EP15TruenessReferneceVO(CalcVO.transposeXValue(total), config.getTargetValue()[0],config.getClaimValue(),0));
+                calcMap.put(sName, new TruenessRefernece(CalcVO.transposeXValue(total), config.getTargetValue()[0],config.getClaimValue(),0));
             }
         }else if(config.getName().equals("EP15-A方法学比对")){
 
-            calcVO = new EP15TruenessPatientVO(dataArrays, config.getClaimValue(),0);
+            calcVO = new TruenessEP15Patient(dataArrays, config.getClaimValue(),0);
 
         }
         else if(config.getName().equals("EP6-A线性评价")){
 
-            calcVO = new EP6ALinearRangeVO(dataArrays, config.getTargetValue(),config.getClaimValue(),config.getDecimal());
+            calcVO = new LinearRangeEP6A(dataArrays, config.getTargetValue(),config.getClaimValue(),config.getDecimal());
 
         }
 

+ 4 - 11
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/EP15PrecisionVO.java → ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/PrecisionEP15.java

@@ -1,16 +1,9 @@
 package com.lc.ibps.components.verification.model2;
 
-import com.lc.ibps.components.verification.funcs.xAverage;
-import com.lc.ibps.components.verification.funcs.xFuncStdevVar;
-import com.lc.ibps.components.verification.funcs.xValue;
-import com.lc.ibps.components.verification.model.SpecimensCalcVO;
-import com.lc.ibps.components.verification.model2.CalcVO;
 import org.apache.commons.math3.stat.StatUtils;
 import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
 
-import java.util.Arrays;
-
-public class EP15PrecisionVO extends CalcVO {
+public class PrecisionEP15 extends CalcVO {
 
     private double[][] data;
 
@@ -51,7 +44,7 @@ public class EP15PrecisionVO extends CalcVO {
     private double allowableSr;
     private double allowableS1;
 
-    public EP15PrecisionVO(double[][] data, double allowableCvr, double allowableCv1, int decimal) {
+    public PrecisionEP15(double[][] data, double allowableCvr, double allowableCv1, int decimal) {
         this.data = data;
         this.n = data[0].length;
         this.allowableCvr = allowableCvr;
@@ -188,8 +181,8 @@ public class EP15PrecisionVO extends CalcVO {
 
     public static void main(String[] args) {
         double[][] data = {{3.3, 3.23, 3.43}, {3.21, 3.45, 3.42}, {3.21, 3.24, 3.45}, {3.5, 3.45, 3.51}, {3.33, 3.45, 3.32}};
-        EP15PrecisionVO ep15PrecisionVO = new EP15PrecisionVO(data, 0, 0, 3);
+        PrecisionEP15 precisionEP15 = new PrecisionEP15(data, 0, 0, 3);
 
-        System.out.println(ep15PrecisionVO);
+        System.out.println(precisionEP15);
     }
 }

+ 14 - 12
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/EP15TruenessPatientVO.java → ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/TruenessEP15Patient.java

@@ -4,14 +4,15 @@ import com.lc.ibps.components.verification.funcs.xAverage;
 import com.lc.ibps.components.verification.funcs.xFuncStdevVar;
 import com.lc.ibps.components.verification.funcs.xValue;
 import org.apache.commons.math3.stat.StatUtils;
+import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
 
-public class EP15TruenessPatientVO extends CalcVO {
+public class TruenessEP15Patient extends CalcVO {
     //多个样本均值 y
     private double[] y;
     //样本的标示值/理论值 x
     private double[] x;
-    private xValue[] yx;
-    private xValue[] yxb;
+    private double[] yx;
+    private double[] yxb;
 
     private double meanX;
     private double meanY;
@@ -26,7 +27,7 @@ public class EP15TruenessPatientVO extends CalcVO {
     private double lvl;//Lower verification limit
     private double sdClaim;//SD assigned value
 
-    public EP15TruenessPatientVO(double[][] data, double sdClaim, double t) {
+    public TruenessEP15Patient(double[][] data, double sdClaim, double t) {
         this.y = data[0];
         this.x = data[1];
         meanX = StatUtils.mean(x);
@@ -43,16 +44,17 @@ public class EP15TruenessPatientVO extends CalcVO {
 
     public void calculate() {
 
-        yx = new xValue[y.length];
-        yxb = new xValue[y.length];
+        yx = new double[y.length];
+        yxb = new double[y.length];
         for (int i = 0; i < y.length; i++) {
-            yx[i] = new xValue(y[i] - x[i]);
+            yx[i] = y[i] - x[i];
         }
-        bias = xAverage.eval(yx).getDoub();
+        bias = StatUtils.mean(yx);
         for (int i = 0; i < y.length; i++) {
-            yxb[i] = new xValue(y[i] - x[i] - bias);
+            yxb[i] = y[i] - x[i] - bias;
         }
-        sdDiff = xFuncStdevVar.evalArgs(yxb,xFuncStdevVar.iSTDEV).getDoub();
+        DescriptiveStatistics stat = new DescriptiveStatistics(yxb);
+        sdDiff = stat.getStandardDeviation();
 
         double sqrtN = Math.sqrt(n);
         ucl = bias + t * sdDiff / sqrtN;
@@ -155,8 +157,8 @@ public class EP15TruenessPatientVO extends CalcVO {
         for (int i = 0; i<y.length;i++){
             d[i][0] = y[i];
             d[i][1] = x[i];
-            d[i][2] = yx[i].getDoub();
-            d[i][3] = yxb[i].getDoub();
+            d[i][2] = yx[i];
+            d[i][3] = yxb[i];
         }
         return d;
     }

+ 2 - 7
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/EP15TruenessReferneceVO.java → ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/TruenessRefernece.java

@@ -1,13 +1,8 @@
 package com.lc.ibps.components.verification.model2;
 
-import com.lc.ibps.components.verification.funcs.xAverage;
-import com.lc.ibps.components.verification.funcs.xFuncStdevVar;
-import com.lc.ibps.components.verification.funcs.xValue;
-import com.lc.ibps.components.verification.model2.CalcVO;
-import org.apache.commons.math3.stat.StatUtils;
 import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
 
-public class EP15TruenessReferneceVO extends CalcVO {
+public class TruenessRefernece extends CalcVO {
 
     private double[] data;
 
@@ -23,7 +18,7 @@ public class EP15TruenessReferneceVO extends CalcVO {
     private double t;//t critical
     private double sdClaim;//SD assigned value
 
-    public EP15TruenessReferneceVO(double[] data, double target, double sdClaim, double t){
+    public TruenessRefernece(double[] data, double target, double sdClaim, double t){
         this.data = data;
         this.target = target;
         this.sdClaim = sdClaim;

+ 12 - 11
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/regression/PolynomialRegression.java

@@ -10,9 +10,10 @@ public class PolynomialRegression extends Regression{
 
     private final OLSMultipleLinearRegression ols;
 
-    private double[] tValue;
+    private double[] tValues;
 
     private boolean isNonlinear = false;
+    private double t;
 
 
     public PolynomialRegression() {
@@ -42,20 +43,20 @@ public class PolynomialRegression extends Regression{
     }
 
     private void generateTValue(){
-        tValue = new double[getParameters().length];
+        tValues = new double[getParameters().length];
         for (int i = 0; i < getParameters().length; i++) {
-            tValue[i] = getParameters()[i] / getStdErrors()[i];
+            tValues[i] = getParameters()[i] / getStdErrors()[i];
         }
+        t = CalcVO.getT(getDfDependent(), 0.05);
         if (getParameters().length >2) {
-            double target = CalcVO.getT(getDfDependent(), 0.05);
             for (int i = 2; i < getParameters().length; i++) {
-                if(tValue[i] > 0){
-                    if(tValue[i] > target) {
+                if(tValues[i] > 0){
+                    if(tValues[i] > t) {
                         isNonlinear = true;
                         break;
                     }
                 } else{
-                    if(tValue[i] < -target){
+                    if(tValues[i] < -t){
                         isNonlinear = true;
                         break;
                     }
@@ -121,11 +122,11 @@ public class PolynomialRegression extends Regression{
         isNonlinear = nonlinear;
     }
 
-    public double[] gettValue() {
-        return tValue;
+    public double[] gettValues() {
+        return tValues;
     }
 
-    public void settValue(double[] tValue) {
-        this.tValue = tValue;
+    public void settValues(double[] tValues) {
+        this.tValues = tValues;
     }
 }