Quellcode durchsuchen

检验时间,检验内容

yangyj vor 2 Jahren
Ursprung
Commit
6c17b27831

+ 59 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -36,6 +36,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -132,7 +133,17 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         /*通过判断元素名称来确定,加入汇总公式延后执行*/
         this.constantMap.put("tableNames",tableList.stream().filter(e->StringUtils.isEquals(e.getIsBussShow(),1)).map(WbsTreeContract::getFullName).collect(Collectors.toList()));
         /*检查是否有跨节点数据*/
+        /*获取type=1的检验单或者type=4的监表*/
+        List<Map<String,Object>>  inspectionElementMaps = new ArrayList<>();
+        Optional<AppWbsTreeContractVO> wop=tableList.stream().filter(e->e.getTableType()==1).findAny();
+        if(wop.isPresent()){
+            /*检验单或者监表的*/
+            inspectionElementMaps=  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=" + wop.get().getPKeyId());
+        }
         List<String> missingList = new ArrayList<>();
+        List<Map<String, Object>> finalInspectionElementMaps = inspectionElementMaps;
+        List<String> cki =new ArrayList<>();
+        AtomicReference<String> ckd= new AtomicReference<>("");
         this.formDataList.forEach(fd->{
             if(fd.executable()){
                 relyParse(fd.getFormula());
@@ -145,12 +156,60 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                         }
                     });
                 }
+                if(StringUtils.isEquals("CKI",f.getNumber())){
+                    finalInspectionElementMaps.forEach(m->{
+                        String name = StringUtils.handleNull(m.get("name"));
+                        if(name.contains("实测值")&&name.contains("偏差值")){
+                            String ekey = StringUtils.handleNull(m.get("tableName"))+":"+StringUtils.handleNull(m.get("ekey"));
+                            if(this.formDataMap.values().stream().map(FormData::getCode).noneMatch(k->StringUtils.isEquals(k,ekey))){
+                                cki.add(ekey);
+                                missingList.add(ekey);
+                            }
+                        }
+                    });
+                    f.setFormula("CKI");
+                }else  if(StringUtils.isEquals("CKD",f.getNumber())){
+                    finalInspectionElementMaps.forEach(m->{
+                        String name = StringUtils.handleNull(m.get("name"));
+                        if(name.contains("检验日期")){
+                            String ekey = StringUtils.handleNull(m.get("tableName"))+":"+StringUtils.handleNull(m.get("ekey"));
+                            if(!this.formDataMap.containsKey(ekey)&&this.formDataMap.values().stream().map(FormData::getCode).noneMatch(k->StringUtils.isEquals(k,ekey))){
+                                ckd.set(ekey);
+                                missingList.add(ekey);
+                            }
+                        }
+                    });
+                    f.setFormula("CKD");
+                }
+
             }
         });
+
         missingFill(missingList);
         if(Func.isNotEmpty(missingList)){
             this.tec.getLog().append("无法识别的依赖:").append(missingList.stream().map(e->e.replaceAll("'","")).collect(Collectors.joining(",")));
         }
+        if(Func.isNotEmpty(cki)){
+           /*检验内容*/
+            StringBuilder sb = new StringBuilder();
+            for(String s:cki){
+                FormData fdTmp=this.formDataMap.get(s);
+                if(fdTmp!=null&&fdTmp.getValues().stream().anyMatch(e->StringUtils.isNotEmpty(e)&&StringUtils.isEquals("/",e))){
+                    sb.append(fdTmp.getEName().split("\\(.+\\)")[0]).append(",");
+                }
+            }
+            if(sb.length()>1){
+                this.constantMap.put(CHECK_ITEMS,sb.toString());
+            }
+        }
+        if(Func.isNotBlank(ckd.get())){
+            /*检验时间*/
+            FormData fdTmp =   this.formDataMap.get(ckd.get());
+            if(fdTmp!=null){
+                this.constantMap.put("CKD",fdTmp.getValues().stream().map(ElementData::stringValue).collect(Collectors.joining(",")));
+            }
+        }
+
         /*实测值参数*/
         List<Map<String,Object>>  textInfoMap= this.jdbcTemplate.queryForList("SELECT b.tab_id pkId,b.col_name val ,CONCAT(a.init_table_name,':',b.col_key)code from m_wbs_tree_contract a inner join m_textdict_info b on a.p_key_id=b.tab_id   " +
                 "where a.p_key_id in("+this.tec.getTableAll().stream().map(AppWbsTreeContractVO::getPKeyId).map(Func::toStr).collect(Collectors.joining(","))+") and b.type=8 ");
@@ -378,12 +437,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                         tmp = tmp.replace(am.group(),am.group(1)+"['"+am.group(2)+"']");
                     }
                 }
-                if(CHECK_ITEMS.equals(tmp)){
-                    /*获取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();
-                    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);
             }
@@ -756,9 +809,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                              data.put(eNames.get(i),values.get(i));
                          }
                          f=f.replace(m.group(),putDataWithKey(data));
-                         if(f.contains("ENAME")){
-                             f=f.replace("ENAME",putDataWithKey(target.stream().map(FormData::getEName).collect(Collectors.toList())));
-                         }
                      }
                  }
                  if(f.contains(".option")){