浏览代码

公式相关

yangyj 2 年之前
父节点
当前提交
6295fe3133

+ 66 - 1
blade-service/blade-manager/src/main/java/com/mixsmart/utils/CustomFunction.java

@@ -462,6 +462,13 @@ public class CustomFunction {
 	}
 
 
+	/**
+	 * @Description 优良占比
+	 * @Param [data, cp]
+	 * @return java.lang.Object
+	 * @Author yangyj
+	 * @Date 2022.12.21 12:00
+	 **/
 	public static  Object proportion(List<Object> data ,String cp){
 		if(Func.isNotEmpty(data)&&Func.isNotBlank(cp)){
 		  data=	data.stream().filter(Func::isNotEmpty).map(e->e.toString().replaceAll("\\s+","")).collect(Collectors.toList());
@@ -470,6 +477,21 @@ public class CustomFunction {
          return "";
 	}
 
+
+    public static  Object goodSize(List<Object> data ,String cp){
+        if(Func.isNotEmpty(data)&&Func.isNotBlank(cp)){
+            data=data.stream().filter(Func::isNotEmpty).map(e->e.toString().replaceAll("\\s+","")).collect(Collectors.toList());
+            return data.stream().filter(e->StringUtils.isEquals(e,cp)).count();
+        }
+        return "";
+    }
+	/**
+	 * @Description 阶梯合格率
+	 * @Param [data]
+	 * @return java.lang.Object
+	 * @Author yangyj
+	 * @Date 2022.12.21 11:59
+	 **/
 	public static  Object ladder(List<Object> data){
 	     if(Func.isNotEmpty(data)){
 	       OptionalDouble op=data.stream().map(StringUtils::handleNull).filter(StringUtils::isNumber).mapToDouble(Double::parseDouble).min();
@@ -480,8 +502,51 @@ public class CustomFunction {
 		return "";
 	}
 
-
 	/**
+	 * @Description 主要工序质量等级
+	 * @Param [data]
+	 * @return java.lang.Object
+	 * @Author yangyj
+	 * @Date 2022.12.21 14:18
+	 **/
+	public static  Object major(List<Object> data){
+		if(Func.isNotEmpty(data)&&data.stream().anyMatch(StringUtils::isNotEmpty)){
+			return data.stream().map(StringUtils::handleNull).distinct().collect(Collectors.toList()).stream().anyMatch(e->e.contains("合格"))?"合格":"优良";
+		}
+		return "";
+	}
+    /**
+     * @Description 单元工程质量等级评定
+     * @Param [rate, level]
+     * @return java.lang.Object
+     * @Author yangyj
+     * @Date 2022.12.21 14:33
+     **/
+    public static  Object unit(Object rate ,Object level){
+
+         if(StringUtils.isNotEmpty(rate,level)){
+             return StringUtils.obj2Double(rate.toString())>50&&"优良".equals(level.toString())?"优良":"合格";
+         }
+        return "";
+    }
+    /**
+     * @Description 主控项目数量
+     * @Param [data]
+     * @return java.lang.Object
+     * @Author yangyj
+     * @Date 2022.12.21 15:37
+     **/
+    public static  Object reasonable(List<Object> data){
+
+        if(ListUtils.isNotEmpty(data)){
+           return data.stream().map(e->StringUtils.handleNull(e).replace("/","")).filter(StringUtils::isNotEmpty).count();
+        }
+        return "";
+    }
+
+
+
+    /**
 	 * @Description 时间比较获取
 	 * @Param [list:时间集合, comparator 比较器 ]
 	 * @return cn.hutool.core.date.DateTime

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

@@ -262,9 +262,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                    /*获取type=1的检验单或者type=4的监表*/
                    List<WbsTreeContract> tableList= (List<WbsTreeContract>) this.constantMap.get(TABLE_LIST);
                    Optional<WbsTreeContract> wop=tableList.stream().filter(e->e.getTableType()==1||e.getTableType()==4).findAny();
-                   if(wop.isPresent()){
-                      this.jdbcTemplate.queryForList("select c.e_name name ,c.init_table_name tableName,c.e_key ekey from m_wbs_tree_contract a INNER JOIN m_wbs_tree b on (a.id=b.id or a.old_id=b.id) INNER join m_wbs_form_element c on b.init_table_id=c.f_id where a.id={}  \n");
-                   }
+                    wop.ifPresent(wbsTreeContract -> this.jdbcTemplate.queryForList("select c.e_name name ,c.init_table_name tableName,c.e_key ekey from m_wbs_tree_contract a INNER JOIN m_wbs_tree b on (a.id=b.id or a.old_id=b.id) INNER join m_wbs_form_element c on b.init_table_id=c.f_id where a.id=" + wbsTreeContract.getPKeyId()));
                 }
                 fd.getFormula().setFormula(tmp);
                 this.formDataMap.put(fd.getCode(),fd);
@@ -545,44 +543,36 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                                 this.constantMap.put(key,data);
                                 f = f.replace(CustomFunction.CLASS_CALL + m.group(), key);
                                 fd.getFormula().setFormula(f);
-                                /*更新依赖*/
-                                relyParse(fd.getFormula());
                             }
-                        }else if(f.contains(".proportion(")){
-                           String tf=f.replace(CustomFunction.CLASS_CALL+"proportion","").replaceAll("[()]","");
-                            String[] tfa=tf.split(",");
+                        }else if(f.contains(CustomFunction.CLASS_CALL+"proportion(")||f.contains(CustomFunction.CLASS_CALL+"ladder(")||f.contains(CustomFunction.CLASS_CALL+"major(")||f.contains(CustomFunction.CLASS_CALL+"reasonable(")
+                                ||f.contains(CustomFunction.CLASS_CALL+"goodSize(")){
+                            String tf=f.replaceAll("^T\\(com.mixsmart.utils.CustomFunction\\)\\.\\w+\\(","").replaceAll("[)]$","");
                             List<FormData> target = new ArrayList<>();
-                            for(String code:tfa){
-                                code=code.replace("E['","").replace("']","");
-                                target.add(this.formDataMap.get(code));
-                            }
-                            if(Func.isNotEmpty(target)){
-                                Object data= CustomFunction.proportion(target.stream().map(FormData::getValues).filter(Func::isNotEmpty).map(e->e.get(0)).collect(Collectors.toList()), "优良");
-                                String key ="HA"+HashUtil.identityHashCode(data);
-                                this.constantMap.put(key,data);
-                                fd.getFormula().setFormula(key);
-                            }else{
-                                fd.getFormula().setFormula(StringPool.EMPTY);
-                            }
-                            relyParse(fd.getFormula());
-                        }else if(f.contains(".ladder(")){
-                            String tf=f.replace(CustomFunction.CLASS_CALL+"ladder","").replaceAll("[()]","");
                             String[] tfa=tf.split(",");
-                            List<FormData> target = new ArrayList<>();
                             for(String code:tfa){
                                 code=code.replace("E['","").replace("']","");
                                 target.add(this.formDataMap.get(code));
                             }
                             if(Func.isNotEmpty(target)){
-                                Object data= CustomFunction.ladder(target.stream().map(FormData::getValues).filter(Func::isNotEmpty).map(e->e.get(0)).collect(Collectors.toList()));
+                                Object data=null;
+                                if(f.contains("proportion")){
+                                    data= CustomFunction.proportion(target.stream().map(FormData::getValues).filter(Func::isNotEmpty).map(e->e.get(0)).collect(Collectors.toList()), "优良");
+                                }else if(f.contains("ladder")){
+                                    data= CustomFunction.ladder(target.stream().map(FormData::getValues).filter(Func::isNotEmpty).map(e->e.get(0)).collect(Collectors.toList()));
+                                }else if(f.contains("major")){
+                                    data= CustomFunction.major(target.stream().map(FormData::getValues).filter(Func::isNotEmpty).map(e->e.get(0)).collect(Collectors.toList()));
+                                }else if(f.contains("reasonable")){
+                                    data= CustomFunction.reasonable(target.stream().map(FormData::getValues).filter(Func::isNotEmpty).map(e->e.get(0)).collect(Collectors.toList()));
+                                }else if(f.contains("goodSize")){
+                                    data= CustomFunction.goodSize(target.stream().map(FormData::getValues).filter(Func::isNotEmpty).map(e->e.get(0)).collect(Collectors.toList()),"优良");
+                                }
                                 String key ="HA"+HashUtil.identityHashCode(data);
                                 this.constantMap.put(key,data);
-                                fd.getFormula().setFormula(key);
                             }else{
                                 fd.getFormula().setFormula(StringPool.EMPTY);
                             }
-                            relyParse(fd.getFormula());
                         }
+                        relyParse(fd.getFormula());
                         System.out.println("聚合处理");
                     }
                 }catch (Exception e){
@@ -592,8 +582,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         }
     }
 
-
-
 }