Parcourir la source

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

Li Yuan il y a 2 ans
Parent
commit
e5cd765625

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

@@ -46,7 +46,7 @@ public class xValue implements Serializable {
                 this.iType = iDOUBLE;
                 this.valDoub = ((Number) valObj).doubleValue();
             }
-            setValFormat(valObj.toString());
+            setValFormat(valObj.toString(),true);
         }
     }
     public xValue(double valDoub) {

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

@@ -0,0 +1,23 @@
+package com.lc.ibps.components.verification.model;
+
+import com.lc.ibps.api.base.constants.ServiceContants;
+
+public enum ExcelParserErrorEnum {
+    IncorrectSheetName("未找到此工作表。"),
+    RowLess("工作表中数据条数不够。"),
+    ValueNotDouble("%s: 第%s次检测数据不是数字类型。"),
+    ValueBlank("%s: 第%s次检测数据为空。");
+    private String text;
+
+    ExcelParserErrorEnum(String text) {
+        this.text = text;
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+}

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

@@ -2,6 +2,7 @@ package com.lc.ibps.components.verification.model;
 
 import com.lc.ibps.components.verification.funcs.xValue;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -10,27 +11,13 @@ public class ExcelSheetRecord {
 
     private String sheetName;
     private List<Map> data;
-
+    //标本名称:检测值
     private Map<String, xValue[]> convertedData;
 
-    public ExcelSheetRecord(String sheetName, List<Map> data) {
-        this.sheetName = sheetName;
-        this.data = data;
-    }
+    private List<String> errors = new ArrayList<>();
 
-    public String getSheetName() {
-        return sheetName;
-    }
-
-    public void setSheetName(String sheetName) {
+    public ExcelSheetRecord(String sheetName, List<Map> data) {
         this.sheetName = sheetName;
-    }
-
-    public List<Map> getData() {
-        return data;
-    }
-
-    public void setData(List<Map> data) {
         this.data = data;
     }
 
@@ -38,23 +25,42 @@ public class ExcelSheetRecord {
         return convertedData;
     }
 
-    public void setConvertedData(Map<String, xValue[]> convertedData) {
-        this.convertedData = convertedData;
-    }
-
-    public void convert(InspectionConfigVO config) {
+    public void convert(InspectionConfigVO config, String configSheetName) {
         convertedData = new HashMap<>();
+
+        if(!configSheetName.equals(sheetName)){
+            errors.add(ExcelParserErrorEnum.IncorrectSheetName.getText());
+            return;
+        }
+        if (data.size() < config.getRepeatNum()) {
+            errors.add(ExcelParserErrorEnum.RowLess.getText());
+            return;
+        }
         for (String sName : config.getSpecimensName()) {
             convertedData.put(sName, new xValue[config.getRepeatNum()]);
         }
-        for (int i = 0; i < data.size(); i++) {
+        for (int i = 0; i < config.getRepeatNum(); i++) {
             Map<String, Object> map = data.get(i);
             for (String sName : config.getSpecimensName()) {
                 Object val = map.get(sName + "_" + InspectionItemVO.DISPLAY_VALUE);
-
-                convertedData.get(sName)[i] = new xValue(val);
+                xValue value = new xValue(val);
+                if(value.isBlank()){
+                    errors.add(String.format(ExcelParserErrorEnum.ValueBlank.getText(),sName,i+1));
+                }else if(!value.isDoub()){
+                    errors.add(String.format(ExcelParserErrorEnum.ValueNotDouble.getText(),sName,i+1));
+                }else {
+                    convertedData.get(sName)[i] = value;
+                }
             }
         }
     }
+
+    public List<String> getErrors() {
+        return errors;
+    }
+
+    public String getSheetName() {
+        return sheetName;
+    }
 }
 

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

@@ -33,6 +33,9 @@ public class InspectionItemVO {
     //样本名 : 检查数据
     private Map<String, RecordCalcVO> record;
 
+    private boolean dataPass = false;
+    private Map<String, List<String>> errorMessage = new HashMap<>();
+
     public InspectionItemVO(InspectionConfigVO config) {
         this.config = config;
     }
@@ -141,7 +144,7 @@ public class InspectionItemVO {
             date = date.plusDays(1);
         }
         map.put("data", data);
-        map.put("item",this);
+        map.put("item", this);
 
         return map;
     }
@@ -152,10 +155,18 @@ public class InspectionItemVO {
         params.setHeadRows(2);
         params.setSheetNum(config.getDays());
         List<ExcelSheetRecord> list = PVExcelUtil.importExcel(inputstream, Map.class, params);
-
-        for (ExcelSheetRecord record :
-                list) {
-            record.convert(config);
+        LocalDate startDate = config.getStartDate();
+        for (ExcelSheetRecord record : list) {
+            record.convert(config,startDate.toString());
+            if (record.getErrors().size() > 0) {
+                errorMessage.put(startDate.toString(), record.getErrors());
+            }
+            startDate = startDate.plusDays(1);
+        }
+        if (errorMessage.size() > 0) {
+            return;
+        } else {
+            dataPass = true;
         }
         record = new HashMap<>();
         for (String sName : config.getSpecimensName()) {
@@ -186,4 +197,12 @@ public class InspectionItemVO {
     public void setConfig(InspectionConfigVO config) {
         this.config = config;
     }
+
+    public boolean isDataPass() {
+        return dataPass;
+    }
+
+    public Map<String, List<String>> getErrorMessage() {
+        return errorMessage;
+    }
 }