Bladeren bron

[性能验证][task-1390] 各个指标中数据公式的计算和结论推导,线性范围

Li Yuan 2 jaren geleden
bovenliggende
commit
a343a01162

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

@@ -2,17 +2,15 @@ package com.lc.ibps.components.verification.excel;
 
 
 import com.lc.ibps.components.poi.excel.entity.params.ExcelExportEntity;
 import com.lc.ibps.components.poi.excel.entity.params.ExcelExportEntity;
 import com.lc.ibps.components.poi.excel.export.ExcelExportServer;
 import com.lc.ibps.components.poi.excel.export.ExcelExportServer;
-import com.lc.ibps.components.poi.util.PoiMergeCellUtil;
 import com.lc.ibps.components.verification.model.FunctionEnum;
 import com.lc.ibps.components.verification.model.FunctionEnum;
 import com.lc.ibps.components.verification.model.InspectionItemVO;
 import com.lc.ibps.components.verification.model.InspectionItemVO;
-import com.lc.ibps.components.verification.model.RecordCalcVO;
-import org.apache.poi.ss.usermodel.CellStyle;
+import com.lc.ibps.components.verification.model.ItemCalcVO;
+import com.lc.ibps.components.verification.model.SpecimensCalcVO;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellRangeAddress;
 
 
 import java.util.Collection;
 import java.util.Collection;
-import java.util.Set;
 
 
 public class PVExcelExportReportServer extends ExcelExportServer {
 public class PVExcelExportReportServer extends ExcelExportServer {
     private InspectionItemVO item;
     private InspectionItemVO item;
@@ -22,11 +20,10 @@ public class PVExcelExportReportServer extends ExcelExportServer {
 
 
         Row row = sheet.createRow(sheet.getLastRowNum() + 1);
         Row row = sheet.createRow(sheet.getLastRowNum() + 1);
         row.setHeight((short) (entity.getHeight() * 50));
         row.setHeight((short) (entity.getHeight() * 50));
-        int index = 0;
         for (FunctionEnum func : item.getConfig().getFunc()) {
         for (FunctionEnum func : item.getConfig().getFunc()) {
             row = sheet.createRow(sheet.getLastRowNum() + 1);
             row = sheet.createRow(sheet.getLastRowNum() + 1);
             row.setHeight((short) (entity.getHeight() * 50));
             row.setHeight((short) (entity.getHeight() * 50));
-            index = 0;
+            int index = 0;
             if (item.getConfig().isConvert()) {
             if (item.getConfig().isConvert()) {
                 sheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), index,
                 sheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), index,
                         index + 1));
                         index + 1));
@@ -34,22 +31,20 @@ public class PVExcelExportReportServer extends ExcelExportServer {
             entity.setKey("statistic");
             entity.setKey("statistic");
             createStringCell(row, index++, func.getText(), getStyles(false, entity), null);
             createStringCell(row, index++, func.getText(), getStyles(false, entity), null);
             createStringCell(row, index++, "", getStyles(false, entity), null);
             createStringCell(row, index++, "", getStyles(false, entity), null);
-            for (int i = 0; i < item.getConfig().getSpecimensNum(); i++) {
-                String s = item.getConfig().getSpecimensName()[i];
-                RecordCalcVO recordCalcVO = item.getRecord().get(s);
-                sheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), index,
-                        index + 1));
-                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++, "0", getStyles(false, entity), null);
-
+            if (func == FunctionEnum.LRE || func == FunctionEnum.R) {
+                createItemRow(sheet, entity, row, index, func);
+            } else {
+                createSpecimensRow(sheet, entity, row, index, func);
             }
             }
         }
         }
-//        row = sheet.createRow(sheet.getLastRowNum() + 1);
-//        row.setHeight((short) (entity.getHeight() * 50));
+        createResultRow(sheet, entity, row);
+    }
+
+    private void createResultRow(Sheet sheet, ExcelExportEntity entity, Row row) {
+        int index = item.getConfig().getSpecimensNum() + 2;
+        if (item.getConfig().isConvert()) {
+            index = item.getConfig().getSpecimensNum() * 2 + 2;
+        }
         entity.setKey("statistic");
         entity.setKey("statistic");
         sheet.addMergedRegion(new CellRangeAddress(row.getRowNum() + 1, row.getRowNum() + 3, 0,
         sheet.addMergedRegion(new CellRangeAddress(row.getRowNum() + 1, row.getRowNum() + 3, 0,
                 1));
                 1));
@@ -63,23 +58,65 @@ public class PVExcelExportReportServer extends ExcelExportServer {
             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);
         }
         }
+    }
 
 
+    private void createItemRow(Sheet sheet, ExcelExportEntity entity, Row row, int index, FunctionEnum func) {
+        int i = 0;
+        if (item.getConfig().isConvert()) {
+            i = index - 1 + item.getConfig().getSpecimensNum() * 2;
+            sheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), index, i));
+        } else {
+            i = index - 1 + item.getConfig().getSpecimensNum();
+            sheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), index, i));
+        }
+        entity.setKey(getCellStyle(func));
+        createStringCell(row, index++, getCalcValue(func, item.getItemCalcVO()), getStyles(false, entity), null);
+        for (int j = index; j <= i; j++) {
+            createStringCell(row, index++, "0", getStyles(false, entity), null);
+        }
+    }
 
 
-//        createStringCell(row, 0, "结论", getStyles(false, entity), null);
+    private void createSpecimensRow(Sheet sheet, ExcelExportEntity entity, Row row, int index, FunctionEnum func) {
+
+        for (int i = 0; i < item.getConfig().getSpecimensNum(); i++) {
+            String s = item.getConfig().getSpecimensName()[i];
+            SpecimensCalcVO specimensCalcVO = item.getRecord().get(s);
+            if (item.getConfig().isConvert()) {
+                sheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), index,
+                        index + 1));
+            }
+            entity.setKey(getCellStyle(func));
+            createStringCell(row, index++, getCalcValue(func, specimensCalcVO), getStyles(false, entity), null);
+            if (item.getConfig().isConvert()) {
+                createStringCell(row, index++, "0", getStyles(false, entity), null);
+            }
+
+        }
     }
     }
 
 
-    public String getCalcValue(FunctionEnum func, RecordCalcVO recordCalcVO) {
+    public String getCalcValue(FunctionEnum func, SpecimensCalcVO specimensCalcVO) {
         switch (func) {
         switch (func) {
             case CV:
             case CV:
-                return recordCalcVO.getCv().getStr();
+                return specimensCalcVO.getCv().getStr();
             case SD:
             case SD:
-                return recordCalcVO.getSd().getStr();
+                return specimensCalcVO.getSd().getStr();
             case AVERAGE:
             case AVERAGE:
-                return recordCalcVO.getAverage().getStr();
+                return specimensCalcVO.getAverage().getStr();
             case TARGET:
             case TARGET:
-                return recordCalcVO.getTargetValue().toString();
+                return specimensCalcVO.getTargetValue().toString();
             case ABSDEV:
             case ABSDEV:
-                return Double.toString(recordCalcVO.calcAbsoluteDeviation());
+                return Double.toString(specimensCalcVO.calcAbsoluteDeviation());
+            default:
+                return "";
+        }
+    }
+
+    public String getCalcValue(FunctionEnum func, ItemCalcVO itemCalcVO) {
+        switch (func) {
+            case R:
+                return itemCalcVO.getR().getStr();
+            case LRE:
+                return itemCalcVO.getLRE();
             default:
             default:
                 return "";
                 return "";
         }
         }
@@ -89,6 +126,10 @@ public class PVExcelExportReportServer extends ExcelExportServer {
         switch (func) {
         switch (func) {
             case CV:
             case CV:
                 return "statistic-percent";
                 return "statistic-percent";
+            case R:
+                return "statistic-double4";
+            case LRE:
+                return "statistic";
             default:
             default:
                 return "statistic-double";
                 return "statistic-double";
         }
         }

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

@@ -14,6 +14,7 @@ public class PVExcelExportStyler extends ExcelExportStylerBorderImpl {
     protected CellStyle statisticDoubleNumberStyle;
     protected CellStyle statisticDoubleNumberStyle;
 
 
     protected  CellStyle statisticPercentNumberStyle;
     protected  CellStyle statisticPercentNumberStyle;
+    protected  CellStyle statisticDouble4NumberStyle;
 
 
     public PVExcelExportStyler(Workbook workbook) {
     public PVExcelExportStyler(Workbook workbook) {
         super(workbook);
         super(workbook);
@@ -23,6 +24,7 @@ public class PVExcelExportStyler extends ExcelExportStylerBorderImpl {
         statisticNumberStyle = statisticNumberStyle(workbook);
         statisticNumberStyle = statisticNumberStyle(workbook);
         statisticDoubleNumberStyle = statisticDoubleNumberStyle(workbook);
         statisticDoubleNumberStyle = statisticDoubleNumberStyle(workbook);
         statisticPercentNumberStyle = statisticPercentNumberStyle(workbook);
         statisticPercentNumberStyle = statisticPercentNumberStyle(workbook);
+        statisticDouble4NumberStyle = statisticDouble4NumberStyle(workbook);
     }
     }
 
 
 
 
@@ -34,6 +36,7 @@ public class PVExcelExportStyler extends ExcelExportStylerBorderImpl {
             if("log".equals(entity.getKey())) return doubleNumberStyle;
             if("log".equals(entity.getKey())) return doubleNumberStyle;
             if("statistic".equals(entity.getKey())) return statisticNumberStyle;
             if("statistic".equals(entity.getKey())) return statisticNumberStyle;
             if("statistic-double".equals(entity.getKey())) return statisticDoubleNumberStyle;
             if("statistic-double".equals(entity.getKey())) return statisticDoubleNumberStyle;
+            if("statistic-double4".equals(entity.getKey())) {return statisticDouble4NumberStyle;}
             if("statistic-percent".equals(entity.getKey())) return statisticPercentNumberStyle;
             if("statistic-percent".equals(entity.getKey())) return statisticPercentNumberStyle;
         }
         }
         return super.getStyles(noneStyler, entity);
         return super.getStyles(noneStyler, entity);
@@ -78,6 +81,12 @@ public class PVExcelExportStyler extends ExcelExportStylerBorderImpl {
         return style;
         return style;
     }
     }
 
 
+    private CellStyle statisticDouble4NumberStyle(Workbook workbook) {
+        CellStyle style = statisticNumberStyle(workbook);
+        style.setDataFormat(workbook.createDataFormat().getFormat("0.0000"));
+        return style;
+    }
+
     private  CellStyle createCellStyle(Workbook workbook){
     private  CellStyle createCellStyle(Workbook workbook){
         CellStyle style = workbook.createCellStyle();
         CellStyle style = workbook.createCellStyle();
         style.setBorderLeft(BorderStyle.THIN); // 左边框
         style.setBorderLeft(BorderStyle.THIN); // 左边框

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

@@ -37,8 +37,11 @@ public class PVTest {
 //        InspectionConfigVO config = new InspectionConfigVO("批内精密度",1,2,
 //        InspectionConfigVO config = new InspectionConfigVO("批内精密度",1,2,
 //                new String[]{"高溶度(R1)","低浓度(R2)"},10, LocalDate.now(),true);
 //                new String[]{"高溶度(R1)","低浓度(R2)"},10, LocalDate.now(),true);
 
 
-        InspectionConfigVO config = new InspectionConfigVO("正确度",5,2,
-                new String[]{"L2","L4"},2, LocalDate.now(),true);
+//        InspectionConfigVO config = new InspectionConfigVO("正确度",5,2,
+//                new String[]{"L2","L4"},2, LocalDate.now(),true);
+
+        InspectionConfigVO config = new InspectionConfigVO("线性范围",1,7,
+                new String[]{"E8","E7","E6","E5","E4","E3","E2"},3, LocalDate.now(),true);
 
 
         InspectionItemVO item = new InspectionItemVO(config);
         InspectionItemVO item = new InspectionItemVO(config);
         Workbook workbook = item.exportExcelTemplate();
         Workbook workbook = item.exportExcelTemplate();
@@ -51,37 +54,51 @@ public class PVTest {
     public void testExcelReportExport() throws IOException {
     public void testExcelReportExport() throws IOException {
 
 
         //批间精密度
         //批间精密度
-        InspectionConfigVO config = new InspectionConfigVO("批间精密度",5,2,
-                new String[]{"高溶度(R1)","低浓度(R2)"},3, LocalDate.now(),true);
-        config.setFunc(new FunctionEnum[]{FunctionEnum.AVERAGE,FunctionEnum.SD,FunctionEnum.CV});
-        InspectionItemVO item = new InspectionItemVO(config);
-        File file = new File(String.format("C:/tmp/%sdata.xlsx",config.getName()));
-        FileInputStream in = new FileInputStream(file);
-        item.importExcelRecord(in);
+//        InspectionConfigVO config = new InspectionConfigVO("批间精密度",5,2,
+//                new String[]{"高溶度(R1)","低浓度(R2)"},3, LocalDate.now(),true);
+//        config.setFunc(new FunctionEnum[]{FunctionEnum.AVERAGE,FunctionEnum.SD,FunctionEnum.CV});
+//        InspectionItemVO item = new InspectionItemVO(config);
+//        File file = new File(String.format("C:/tmp/%sdata.xlsx",config.getName()));
+//        FileInputStream in = new FileInputStream(file);
+//        item.importExcelRecord(in);
         //批内精密度
         //批内精密度
-        InspectionConfigVO config2 = new InspectionConfigVO("批内精密度",1,2,
-                new String[]{"高溶度(R1)","低浓度(R2)"},10, LocalDate.now(),true);
-        config2.setFunc(new FunctionEnum[]{FunctionEnum.AVERAGE,FunctionEnum.SD,FunctionEnum.CV});
-        InspectionItemVO item2 = new InspectionItemVO(config2);
-        File file2 = new File(String.format("C:/tmp/%sdata.xlsx",config2.getName()));
-        FileInputStream in2 = new FileInputStream(file2);
-        item2.importExcelRecord(in2);
+//        InspectionConfigVO config2 = new InspectionConfigVO("批内精密度",1,2,
+//                new String[]{"高溶度(R1)","低浓度(R2)"},10, LocalDate.now(),true);
+//        config2.setFunc(new FunctionEnum[]{FunctionEnum.AVERAGE,FunctionEnum.SD,FunctionEnum.CV});
+//        InspectionItemVO item2 = new InspectionItemVO(config2);
+//        File file2 = new File(String.format("C:/tmp/%sdata.xlsx",config2.getName()));
+//        FileInputStream in2 = new FileInputStream(file2);
+//        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);
+//        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);
+
+        //线性范围
+        InspectionConfigVO config4 = new InspectionConfigVO("线性范围",1,7,
+                new String[]{"E8","E7","E6","E5","E4","E3","E2"},3, LocalDate.now(),true);
+
+        config4.setFunc(new FunctionEnum[]{FunctionEnum.AVERAGE,FunctionEnum.TARGET,FunctionEnum.LRE,FunctionEnum.R});
+        config4.setTargetValue(new double[]{8.48,7.48,6.48,5.48,4.48,3.48,2.48});
+        InspectionItemVO item4 = new InspectionItemVO(config4);
+        File file4 = new File(String.format("C:/tmp/%sdata.xlsx",config4.getName()));
+        FileInputStream in4 = new FileInputStream(file4);
+        item4.importExcelRecord(in4);
+
 
 
         InspectionVO vo = new InspectionVO();
         InspectionVO vo = new InspectionVO();
         vo.setName("TEST");
         vo.setName("TEST");
-        vo.getItem().add(item);
-        vo.getItem().add(item2);
-        vo.getItem().add(item3);
+//        vo.getItem().add(item);
+//        vo.getItem().add(item2);
+//        vo.getItem().add(item3);
+        vo.getItem().add(item4);
+
         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);

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

@@ -42,7 +42,8 @@ public class ExcelSheetRecord {
         for (int i = 0; i < config.getRepeatNum(); i++) {
         for (int i = 0; i < config.getRepeatNum(); i++) {
             Map<String, Object> map = data.get(i);
             Map<String, Object> map = data.get(i);
             for (String sName : config.getSpecimensName()) {
             for (String sName : config.getSpecimensName()) {
-                Object val = map.get(sName + "_" + InspectionItemVO.DISPLAY_VALUE);
+//                Object val = map.get(sName + "_" + InspectionItemVO.DISPLAY_VALUE);
+                Object val = map.get(sName);
                 xValue value = new xValue(val);
                 xValue value = new xValue(val);
                 if(value.isBlank()){
                 if(value.isBlank()){
                     errors.add(String.format(ExcelParserErrorEnum.ValueBlank.getText(),sName,i+1));
                     errors.add(String.format(ExcelParserErrorEnum.ValueBlank.getText(),sName,i+1));

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

@@ -1,14 +1,17 @@
 package com.lc.ibps.components.verification.model;
 package com.lc.ibps.components.verification.model;
 
 
 public enum FunctionEnum {
 public enum FunctionEnum {
-    SD("SD值"),
+    SD("标准差(SD)"),
     AVERAGE("均值"),
     AVERAGE("均值"),
-    CV("CV值"),
+    CV("变异系数(CV)"),
     TARGET("靶值"),
     TARGET("靶值"),
-    ABSDEV("绝对偏差");
+    ABSDEV("绝对偏差"),
+    A("截距(a)"),
+    B("斜率(b)"),
+    R("相关系数(r)"),
+    LRE("线性回归方程");
     private String text;
     private String text;
 
 
-
     FunctionEnum(String text) {
     FunctionEnum(String text) {
         this.text = text;
         this.text = text;
     }
     }

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

@@ -12,7 +12,6 @@ import com.lc.ibps.components.verification.funcs.xValue;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.Workbook;
 
 
 import java.io.InputStream;
 import java.io.InputStream;
-import java.text.DecimalFormat;
 import java.time.LocalDate;
 import java.time.LocalDate;
 import java.util.*;
 import java.util.*;
 
 
@@ -31,7 +30,9 @@ public class InspectionItemVO {
     private InspectionConfigVO config;
     private InspectionConfigVO config;
 
 
     //样本名 : 检查数据
     //样本名 : 检查数据
-    private Map<String, RecordCalcVO> record;
+    private Map<String, SpecimensCalcVO> record;
+
+    private ItemCalcVO itemCalcVO;
 
 
     private boolean dataPass = false;
     private boolean dataPass = false;
     private Map<String, List<String>> errorMessage = new HashMap<>();
     private Map<String, List<String>> errorMessage = new HashMap<>();
@@ -45,16 +46,18 @@ public class InspectionItemVO {
 
 
         List<ExcelExportEntity> temp = new ArrayList<ExcelExportEntity>();
         List<ExcelExportEntity> temp = new ArrayList<ExcelExportEntity>();
         ExcelExportEntity e1 = new ExcelExportEntity(DISPLAY_NUMBER, "number");
         ExcelExportEntity e1 = new ExcelExportEntity(DISPLAY_NUMBER, "number");
+//        e1.setMergeVertical(true);
         e1.setType(BaseEntityTypeConstants.DoubleType);
         e1.setType(BaseEntityTypeConstants.DoubleType);
-        temp.add(e1);
-        ExcelExportEntity e2 = new ExcelExportEntity(DISPLAY_VALUE, "input");
-        temp.add(e2);
+        entity.add(e1);
+
 
 
         for (int i = 0; i < config.getSpecimensNum(); i++) {
         for (int i = 0; i < config.getSpecimensNum(); i++) {
-            ExcelExportEntity excelEntity = new ExcelExportEntity(config.getSpecimensName()[i], "inspection");
-            excelEntity.setList(temp);
-            entity.add(excelEntity);
+            ExcelExportEntity e2 = new ExcelExportEntity(config.getSpecimensName()[i], "input");
+            entity.add(e2);
         }
         }
+//        ExcelExportEntity excelEntity = new ExcelExportEntity("", "inspection");
+//        excelEntity.setList(temp);
+//        entity.add(excelEntity);
         List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
         List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
         Map<String, Object> map;
         Map<String, Object> map;
         for (int i = 1; i <= config.getRepeatNum(); i++) {
         for (int i = 1; i <= config.getRepeatNum(); i++) {
@@ -62,9 +65,9 @@ public class InspectionItemVO {
             map.put("number", i);
             map.put("number", i);
 //            map.put("value", "");
 //            map.put("value", "");
 
 
-            List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
-            tempList.add(map);
-            map.put("inspection", tempList);
+//            List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
+//            tempList.add(map);
+//            map.put("inspection", tempList);
 
 
             list.add(map);
             list.add(map);
         }
         }
@@ -127,14 +130,14 @@ public class InspectionItemVO {
                 item.put("number", j + 1);
                 item.put("number", j + 1);
                 for (int k = 0; k < config.getSpecimensNum(); k++) {
                 for (int k = 0; k < config.getSpecimensNum(); k++) {
                     List<Map<String, Object>> sItem = new ArrayList<>();
                     List<Map<String, Object>> sItem = new ArrayList<>();
-                    final RecordCalcVO recordCalcVO = record.get(config.getSpecimensName()[k]);
+                    final SpecimensCalcVO specimensCalcVO = record.get(config.getSpecimensName()[k]);
                     Map<String, Object> sValue = new HashMap<>();
                     Map<String, Object> sValue = new HashMap<>();
-                    double d = recordCalcVO.getData()[i * config.getRepeatNum() + j].getDoub();
+                    double d = specimensCalcVO.getData()[i * config.getRepeatNum() + j].getDoub();
 //                    DecimalFormat decimalFormat=new DecimalFormat("0.##E0");//格式化设置
 //                    DecimalFormat decimalFormat=new DecimalFormat("0.##E0");//格式化设置
 //                    String s = decimalFormat.format(d);
 //                    String s = decimalFormat.format(d);
                     sValue.put("value", d);
                     sValue.put("value", d);
                     if (config.isConvert()) {
                     if (config.isConvert()) {
-                        sValue.put("log", recordCalcVO.getConvertedData()[i * config.getRepeatNum() + j].getDoub());
+                        sValue.put("log", specimensCalcVO.getConvertedData()[i * config.getRepeatNum() + j].getDoub());
                     }
                     }
                     sItem.add(sValue);
                     sItem.add(sValue);
                     item.put("inspection" + k, sItem);
                     item.put("inspection" + k, sItem);
@@ -152,7 +155,7 @@ public class InspectionItemVO {
     public void importExcelRecord(InputStream inputstream) {
     public void importExcelRecord(InputStream inputstream) {
         ImportParams params = new ImportParams();
         ImportParams params = new ImportParams();
         params.setTitleRows(2);
         params.setTitleRows(2);
-        params.setHeadRows(2);
+        params.setHeadRows(1);
         params.setSheetNum(config.getDays());
         params.setSheetNum(config.getDays());
         List<ExcelSheetRecord> list = PVExcelUtil.importExcel(inputstream, Map.class, params);
         List<ExcelSheetRecord> list = PVExcelUtil.importExcel(inputstream, Map.class, params);
         LocalDate startDate = config.getStartDate();
         LocalDate startDate = config.getStartDate();
@@ -177,16 +180,30 @@ public class InspectionItemVO {
                     total[j * xValues.length + k] = xValues[k];
                     total[j * xValues.length + k] = xValues[k];
                 }
                 }
             }
             }
-            record.put(sName, new RecordCalcVO(total, config.isConvert()));
+            record.put(sName, new SpecimensCalcVO(total, config.isConvert()));
         }
         }
+        buildItemCalcVO();
+    }
 
 
+    private void buildItemCalcVO() {
+        if(config.getTargetValue() == null) return;
+
+        xValue[] specimens = new xValue[config.getSpecimensNum()];
+        xValue[] target = new xValue[config.getSpecimensNum()];
+        for (int i = 0; i < config.getSpecimensNum(); i++) {
+            String sName = config.getSpecimensName()[i];
+            record.get(sName).setTargetValue(config.getTargetValue()[i]);
+            specimens[i] = record.get(sName).getAverage();
+            target[i] = new xValue(config.getTargetValue()[i]);
+        }
+        itemCalcVO = new ItemCalcVO(specimens,target);
     }
     }
 
 
-    public Map<String, RecordCalcVO> getRecord() {
+    public Map<String, SpecimensCalcVO> getRecord() {
         return record;
         return record;
     }
     }
 
 
-    public void setRecord(Map<String, RecordCalcVO> record) {
+    public void setRecord(Map<String, SpecimensCalcVO> record) {
         this.record = record;
         this.record = record;
     }
     }
 
 
@@ -205,4 +222,8 @@ public class InspectionItemVO {
     public Map<String, List<String>> getErrorMessage() {
     public Map<String, List<String>> getErrorMessage() {
         return errorMessage;
         return errorMessage;
     }
     }
+
+    public ItemCalcVO getItemCalcVO() {
+        return itemCalcVO;
+    }
 }
 }

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

@@ -0,0 +1,55 @@
+package com.lc.ibps.components.verification.model;
+
+import com.lc.ibps.components.verification.funcs.xFuncArray2Args;
+import com.lc.ibps.components.verification.funcs.xValue;
+
+//多个标本之间的对比计算
+public class ItemCalcVO {
+    //多个样本均值 y
+    private xValue[] specimensValue;
+    //样本的标示值/理论值 x
+    private xValue[] targetValue;
+    //截距(a)
+    private xValue a;
+    //斜率(b)
+    private xValue b;
+    //相关系数r
+    private xValue r;
+
+    public ItemCalcVO(xValue[] specimensValue, xValue[] targetValue) {
+        this.specimensValue = specimensValue;
+        this.targetValue = targetValue;
+        b = xFuncArray2Args.evalArgs(specimensValue, targetValue, xFuncArray2Args.iSLOPE);
+        a = xFuncArray2Args.evalArgs(specimensValue, targetValue, xFuncArray2Args.iINTERCEPT);
+        r = xFuncArray2Args.evalArgs(specimensValue, targetValue, xFuncArray2Args.iCORREL);
+    }
+
+    public xValue[] getSpecimensValue() {
+        return specimensValue;
+    }
+
+    public xValue[] getTargetValue() {
+        return targetValue;
+    }
+
+    public xValue getA() {
+        return a;
+    }
+
+    public xValue getB() {
+        return b;
+    }
+
+    public xValue getR() {
+        return r;
+    }
+
+    public String getLRE() {
+        //y = bx + a
+        return String.format("y = %.4fx + %.4f", b.getDoub(), a.getDoub());
+    }
+
+    public static void main(String[] args) {
+        System.out.println(String.format("y = %.4fx + %.4f", 1.3454523, 0.234556));
+    }
+}

+ 20 - 19
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model/RecordCalcVO.java → ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model/SpecimensCalcVO.java

@@ -8,54 +8,55 @@ import com.lc.ibps.components.verification.funcs.xValue;
 /**
 /**
  * 单列数据计算
  * 单列数据计算
  */
  */
-public class RecordCalcVO {
+public class SpecimensCalcVO {
 
 
     private xValue[] data;
     private xValue[] data;
 
 
-    private boolean isConvert = false;
+
 
 
     private xValue[] convertedData;
     private xValue[] convertedData;
 
 
-    private String[] validatorResult;
 
 
     ////////////////////
     ////////////////////
+    //均值
     private xValue average;
     private xValue average;
+    //标准差
     private xValue sd;
     private xValue sd;
-    //sd/average
+    //变异系数百分比 = sd/average
     private xValue cv;
     private xValue cv;
+    //靶值
     private Double targetValue;
     private Double targetValue;
 
 
-    public RecordCalcVO(xValue[] data,boolean isConvert) {
+    public SpecimensCalcVO(xValue[] data, boolean isConvert) {
         this.data = data;
         this.data = data;
-        this.isConvert = isConvert;
-        if(!isConvert) convertedData = data;
+        if (!isConvert) convertedData = data;
         else convert();
         else convert();
     }
     }
 
 
-    public xValue getAverage(){
-        if(average == null) average = xAverage.eval(convertedData);
+    public xValue getAverage() {
+        if (average == null) average = xAverage.eval(convertedData);
         return average;
         return average;
     }
     }
 
 
-    public xValue getSd(){
-        if(sd == null) sd =  xFuncStdevVar.evalArgs(convertedData,xFuncStdevVar.iSTDEV);
+    public xValue getSd() {
+        if (sd == null) sd = xFuncStdevVar.evalArgs(convertedData, xFuncStdevVar.iSTDEV);
         return sd;
         return sd;
     }
     }
 
 
-    public xValue getCv(){
-        if(cv != null) return cv;
+    public xValue getCv() {
+        if (cv != null) return cv;
         cv = new xValue();
         cv = new xValue();
-        if(getSd().isErr() || getAverage().isErr()) cv.setErrNa();
+        if (getSd().isErr() || getAverage().isErr()) cv.setErrNa();
         else cv.setVal(sd.getDoub() / average.getDoub());
         else cv.setVal(sd.getDoub() / average.getDoub());
-        return  cv;
+        return cv;
     }
     }
 
 
-    private void convert(){
-        convertedData = xLog10.eval(data);
+    private void convert() {
+            convertedData = xLog10.eval(data);
     }
     }
 
 
-    public double calcAbsoluteDeviation(){
-        if(targetValue == null){
+    public double calcAbsoluteDeviation() {
+        if (targetValue == null) {
             return 0;
             return 0;
         }
         }
         return targetValue - getAverage().getDoub();
         return targetValue - getAverage().getDoub();