瀏覽代碼

公式相关:试验公式跳过textInfo()

yangyj 2 年之前
父節點
當前提交
77dc53f39b

+ 84 - 78
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -136,11 +136,13 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
     }
 
     public void textInfo(){
-        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(NodeTable::getPKeyId).map(Func::toStr).collect(Collectors.joining(","))+") and b.type=8 ");
-        if(Func.isNotEmpty(textInfoMap)){
-            Map<String,List<Map<String,Object>>> tmap = textInfoMap.stream().collect(Collectors.groupingBy(m->m.get("code").toString()));
-            tec.constantMap.put(TEXT_INFO_MAP,tmap);
+        if(ExecuteType.INSPECTION.equals(tec.getExecuteType())){
+            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(NodeTable::getPKeyId).map(Func::toStr).collect(Collectors.joining(","))+") and b.type=8 ");
+            if(Func.isNotEmpty(textInfoMap)){
+                Map<String,List<Map<String,Object>>> tmap = textInfoMap.stream().collect(Collectors.groupingBy(m->m.get("code").toString()));
+                tec.constantMap.put(TEXT_INFO_MAP,tmap);
+            }
         }
     }
 
@@ -551,14 +553,17 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         Optional<NodeTable> aop=tec.getTableAll().stream().filter(e->e.getNodeName().contains("A15")).findAny();
         if(aop.isPresent()){
             /*存在监表,则需要收集检查项目和检查时间等元素*/
-            List<String> wop=tec.getTableAll().stream().filter(e->e.getNodeName().contains("检验单")||e.getNodeName().contains("检验表")).map(NodeTable::getInitTableName).distinct().collect(Collectors.toList());
+            List<String> wop=tec.getTableAll().stream().filter(e->e.getTableType().equals(1)&&!e.getNodeName().contains("附表")).map(NodeTable::getInitTableName).distinct().collect(Collectors.toList());
             if(wop.size()>0){
                 /*存在检验表*/
                 tec.getKeyMappers().stream().filter(e->wop.contains(e.getTableName())&&tec.formDataMap.containsKey(e.getCode())).forEach(k->{
-                    if(k.getEName().contains("实测值")&&k.getEName().contains("偏差值")){
-                        tec.checkItems.add(tec.formDataMap.get(k.getCode()));
+                    /*包含的单元格超过三个就算实测项目*/
+                    /*k.getEName().contains("实测值")&&k.getEName().contains("偏差值")*/
+                    FormData ft=tec.formDataMap.get(k.getCode());
+                    if(ft.getCoordsList().size()>5){
+                        tec.checkItems.add(ft);
                     }else if(k.getEName().contains("检验日期")){
-                        tec.checkDate.add(tec.formDataMap.get(k.getCode()));
+                        tec.checkDate.add(ft);
                     }
                 });
             }else{
@@ -576,11 +581,10 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             }
         }
         if(tec.checkItems.size()>0){
-            /**排序*/
+            /*排序*/
             List<String> iniTableNames=tec.getTableAll().stream().map(NodeTable::getInitTableName).distinct().collect(Collectors.toList());
             tec.checkItems= tec.checkItems.stream().sorted(Comparator.comparingInt((FormData i)->iniTableNames.indexOf(i.getTableName())).thenComparingInt(FormData::getMaxRow)).collect(Collectors.toList());
         }
-        System.out.println();
 
     }
 
@@ -936,69 +940,70 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
 
     /**分项汇总数据*/
     public void   doForDataBlock(){
-        try {
-            FormulaDataBlock fdb=findFdb();
-            List<ElementBlock> elementBlockList=new ArrayList<>();
-            Map<String,ElementBlock> elementBlockMap =new HashMap<>();
-            Map<String,ItemBlock>itemBlockMap =new HashMap<>();
-            if(Func.isNotBlank(fdb.getVal())) {
-                elementBlockList = JSON.parseArray(fdb.getVal(), ElementBlock.class);
-                elementBlockList.forEach(eb->{
-                    elementBlockMap.put(eb.getCode(),eb);
-                    List<ItemBlock> itemBlockList =eb.getList();
-                    if(itemBlockList.size()>0){
-                        itemBlockList.forEach(ib->{
-                            ib.setCode(eb.getCode());
-                            itemBlockMap.put(ib.getKey(),ib);
-                        });
+        if(ExecuteType.INSPECTION.equals(tec.getExecuteType())) {
+            try {
+                FormulaDataBlock fdb = findFdb();
+                List<ElementBlock> elementBlockList = new ArrayList<>();
+                Map<String, ElementBlock> elementBlockMap = new HashMap<>();
+                Map<String, ItemBlock> itemBlockMap = new HashMap<>();
+                if (Func.isNotBlank(fdb.getVal())) {
+                    elementBlockList = JSON.parseArray(fdb.getVal(), ElementBlock.class);
+                    elementBlockList.forEach(eb -> {
+                        elementBlockMap.put(eb.getCode(), eb);
+                        List<ItemBlock> itemBlockList = eb.getList();
+                        if (itemBlockList.size() > 0) {
+                            itemBlockList.forEach(ib -> {
+                                ib.setCode(eb.getCode());
+                                itemBlockMap.put(ib.getKey(), ib);
+                            });
+                        }
+                    });
+                }
+                List<ElementBlock> finalElementBlockList = elementBlockList;
+                tec.checkItems.stream().filter(e -> !e.empty()).forEach(c -> {
+                    ElementBlock eb = elementBlockMap.get(c.getCode());
+                    ItemBlock targetItem = itemBlockMap.get(c.getCode() + ":" + tec.getCurrentNode().getPkId());
+                    List<Object> list = c.getValues().stream().map(ElementData::getValue).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
+                    /*1.无任何记录,当前页无数据,则不需要处理 2.存在记录当前无数据,则要消除 3.没有记录当前有数据,则需要增加 4.有记录有当前记录,则需更新*/
+                    if (Func.isNotEmpty(list) || targetItem != null) {
+                        FormData designList = itemMatch(c, 0);
+                        FormData pass = itemMatch(c, 1);
+                        if (targetItem == null) {
+                            if (eb == null) {
+                                eb = new ElementBlock();
+                                eb.setCode(c.getCode());
+                                eb.setEName(c.getEName());
+                                eb.setList(new ArrayList<>());
+                                finalElementBlockList.add(eb);
+                                elementBlockMap.put(eb.getCode(), eb);
+                            }
+                            targetItem = new ItemBlock();
+                            targetItem.setCode(c.getCode());
+                            targetItem.setPkeyId(tec.getCurrentNode().getPkId());
+                            eb.getList().add(targetItem);
+                            itemBlockMap.put(targetItem.getKey(), targetItem);
+                        }
+                        if (Func.isNotEmpty(list)) {
+                            targetItem.setSubTotal(list.size());
+                            if (Func.isNotEmpty(designList)) {
+                                targetItem.setDesigns(designList.getValues().stream().map(ElementData::getValue).flatMap(e -> CustomFunction.obj2ListNe(e).stream()).filter(StringUtils::isNumber).map(StringUtils::obj2Double).collect(Collectors.toList()));
+                            }
+                            AtomicInteger index = new AtomicInteger();
+                            int len = targetItem.getDesigns().size();
+                            if (len > 0) {
+                                targetItem.setData(new ArrayList<>(list.stream().map(StringUtils::obj2Double).collect(Collectors.groupingBy(k -> index.getAndIncrement() / len, LinkedHashMap::new, Collectors.toList())).values()));
+                            } else {
+                                targetItem.setData(Collections.singletonList(list.stream().map(StringUtils::obj2Double).collect(Collectors.toList())));
+                            }
+                            if (pass != null && !pass.empty()) {
+                                targetItem.setSubPass((int) Math.round(list.size() * StringUtils.obj2Double(pass.getValues().get(0).getValue()) / 100));
+                            } else {
+                                targetItem.setSubPass(list.size());
+                            }
+                        } else {
+                            eb.getList().remove(targetItem);
+                        }
                     }
-                });
-            }
-            List<ElementBlock> finalElementBlockList = elementBlockList;
-            tec.checkItems.stream().filter(e->!e.empty()).forEach(c->{
-                     ElementBlock eb =elementBlockMap.get(c.getCode());
-                     ItemBlock targetItem=itemBlockMap.get(c.getCode()+":"+tec.getCurrentNode().getPkId());
-                     List<Object> list = c.getValues().stream().map(ElementData::getValue).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
-                     /*1.无任何记录,当前页无数据,则不需要处理 2.存在记录当前无数据,则要消除 3.没有记录当前有数据,则需要增加 4.有记录有当前记录,则需更新*/
-                     if(Func.isNotEmpty(list)||targetItem!=null){
-                         FormData designList=itemMatch(c,0);
-                         FormData pass=itemMatch(c,1);
-                         if(targetItem==null){
-                             if(eb==null){
-                                 eb=new ElementBlock();
-                                 eb.setCode(c.getCode());
-                                 eb.setEName(c.getEName());
-                                 eb.setList(new ArrayList<>());
-                                 finalElementBlockList.add(eb);
-                                 elementBlockMap.put(eb.getCode(),eb);
-                             }
-                             targetItem = new ItemBlock();
-                             targetItem.setCode(c.getCode());
-                             targetItem.setPkeyId(tec.getCurrentNode().getPkId());
-                             eb.getList().add(targetItem);
-                             itemBlockMap.put(targetItem.getKey(),targetItem);
-                         }
-                         if(Func.isNotEmpty(list)){
-                             targetItem.setSubTotal(list.size());
-                             if(Func.isNotEmpty(designList)) {
-                                 targetItem.setDesigns(designList.getValues().stream().map(ElementData::getValue).flatMap(e -> CustomFunction.obj2ListNe(e).stream()).filter(StringUtils::isNumber).map(StringUtils::obj2Double).collect(Collectors.toList()));
-                             }
-                             AtomicInteger index= new AtomicInteger();
-                             int len=targetItem.getDesigns().size();
-                             if(len>0){
-                                 targetItem.setData(new ArrayList<>(list.stream().map(StringUtils::obj2Double).collect(Collectors.groupingBy(k -> index.getAndIncrement() / len,LinkedHashMap::new,Collectors.toList())).values()));
-                             }else{
-                                 targetItem.setData(Collections.singletonList(list.stream().map(StringUtils::obj2Double).collect(Collectors.toList())));
-                             }
-                             if(pass!=null&&!pass.empty()){
-                                 targetItem.setSubPass((int)Math.round(list.size()*StringUtils.obj2Double(pass.getValues().get(0).getValue())/100));
-                             }else{
-                                 targetItem.setSubPass(list.size());
-                             }
-                         }else{
-                             eb.getList().remove(targetItem);
-                         }
-                     }
 //                if(c.executable()){
 //                    /*主要是获取实测值,合格率,合格数量*/
 //                    List<String> relyCode = c.getFormula().getRelyList();
@@ -1010,11 +1015,12 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
 //                        }
 //                    }
 //                }
-            });
-            fdb.setVal(JSON.toJSONString(elementBlockList));
-            this.formulaDataBlockService.saveOrUpdate(fdb);
-        }catch (Exception e){
-            e.printStackTrace();
+                });
+                fdb.setVal(JSON.toJSONString(elementBlockList));
+                this.formulaDataBlockService.saveOrUpdate(fdb);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
         }
     }