瀏覽代碼

公式相关:非数值类型的实测内容合格率计算

yangyj 2 年之前
父節點
當前提交
526a540a51

+ 4 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/FormData.java

@@ -216,5 +216,9 @@ public class FormData {
         return !(Func.isNotEmpty(this.values) && this.values.stream().map(ElementData::getValue).anyMatch(Func::isNotEmpty));
     }
 
+    public List<Object> getRawValue(){
+        return this.values.stream().map(ElementData::getValue).collect(Collectors.toList());
+    }
+
 
 }

+ 5 - 0
blade-service/blade-manager/src/main/java/com/mixsmart/utils/CustomFunction.java

@@ -1592,6 +1592,11 @@ public class CustomFunction {
                 min = designD - devD;
                 max = designD + devD;
             }
+            if(min>max){
+                double tmp=max;
+                max=min;
+                min=tmp;
+            }
             result[0] = min;
             result[1] = max;
             return result;

+ 6 - 7
blade-service/blade-manager/src/main/java/com/mixsmart/utils/StringUtils.java

@@ -939,13 +939,12 @@ public class StringUtils {
 
 
     /**
-     * 判断是否为数字,包括小数、负数
-     *
-     * @param value
-     * @return
-     * @author:rock
-     * @time:2020年4月15日 上午10:46:15
-     */
+     * @Description 是否数字
+     * @Param [value]
+     * @return boolean
+     * @Author yangyj
+     * @Date 2022.06.02 14:54
+     **/
     public static boolean isNumber(Object value) {
         if (isEmpty(value)) {
             return false;

+ 17 - 11
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -1549,7 +1549,7 @@ public  List<ElementData> setScale(Integer scale,List<ElementData> data){
                              FormData dataFd=tec.formDataMap.get(codeList.get(0));
                              String designStr=codeList.get(1);
                              FormData designFd=tec.formDataMap.get(designStr);
-                             String devStr=StringUtils.isEmpty(formula.getDev())?formula.getDev():fd.getEAllowDeviation();
+                             String devStr=StringUtils.isNotEmpty(formula.getDev())?formula.getDev():fd.getEAllowDeviation();
                              if(StringUtils.isEmpty(devStr)){
                                  /*数据库找不到的情况就读取Excel*/
                                  if(tec.wkbMap.isEmpty()){
@@ -1602,17 +1602,23 @@ public  List<ElementData> setScale(Integer scale,List<ElementData> data){
                                  devStr="±100000";
                              }
                              /*设计值可以是数值类型,或空(等效0)*/
-                             if(dataFd!=null&&designFd!=null){
-                                 if(dataFd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isNotEmpty)&&(designFd.getValues().size()>1||designFd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isEmpty))){
-                                     /*多少个设计值暂时默认全部合格,满足绝大部分结果*/
-                                     data=dataFd.getValues().stream().map(ElementData::getValue).filter(StringUtils::isNotEmpty).count();
-                                 }else{
-                                     List<Object>  result =  CustomFunction.b445check(dataFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()),designFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()),devStr,1 );
-                                     data=result.get(1);
+                             if(dataFd!=null){
+                                    List<Object> values= dataFd.getRawValue();
+                                    boolean nonNumeric=values.stream().filter(StringUtils::isNotEmpty).anyMatch(e->!StringUtils.isNumber(e));
+                                 if(nonNumeric){
+                                   data=values.stream().filter(StringUtils::isNotEmpty).count();
+                                 }else if(designFd!=null){
+                                     if(dataFd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isNotEmpty)&&(designFd.getValues().size()>1||designFd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isEmpty))){
+                                         /*多少个设计值暂时默认全部合格,满足绝大部分结果*/
+                                         data=dataFd.getValues().stream().map(ElementData::getValue).filter(StringUtils::isNotEmpty).count();
+                                     }else{
+                                         List<Object>  result =  CustomFunction.b445check(dataFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()),designFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()),devStr,1 );
+                                         data=result.get(1);
+                                     }
+                                 }else if(BaseUtils.isNumber(designStr)) {
+                                     List<Object> result = CustomFunction.b445check(dataFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()), 0, devStr, 1);
+                                     data = result.get(1);
                                  }
-                             }else if(dataFd!=null&& BaseUtils.isNumber(designStr)){
-                                     List<Object>  result =  CustomFunction.b445check(dataFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()),0,devStr,1 );
-                                     data=result.get(1);
                              }
                          }
                          f = f.replace(m.group(),putDataWithKey(BaseUtils.isNumber(data)?Double.parseDouble(data.toString()):data));