瀏覽代碼

公式相关:评定汇总

yangyj 2 年之前
父節點
當前提交
1f7dfd719c

+ 3 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/ItemBlock.java

@@ -16,6 +16,8 @@ import java.util.stream.Collectors;
 public class ItemBlock {
     @JSONField(serialize = false)
     private String code;
+    @JSONField(serialize = false)
+    private String key;
     /**对应工序流水号*/
     @JSONField(name="p")
     private Long pkeyId;
@@ -45,6 +47,7 @@ public class ItemBlock {
         }
     }
 
+    @JSONField(serialize = false)
     public String getKey(){
         return code+":"+pkeyId;
     }

+ 37 - 22
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -224,21 +224,36 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                 if(itemsMap.size()>0){
                     AtomicBoolean update= new AtomicBoolean(false);
                     itemsMap.values().stream().filter(Measurement::isMatching).forEach(t->{
-                        elementBlockList.stream().filter(w->FormulaUtils.similarity(w.getEName(),t.getPoint())>0.6).reduce((a, b) -> Comparator.<Double>reverseOrder().compare(FormulaUtils.similarity(a.getEName(),t.getPoint()), FormulaUtils.similarity(b.getEName(),t.getPoint())) <= 0 ? a : b).ifPresent(g->{
-                              List<ItemBlock> itemBlockList =g.getList();
-                               int originSize=itemBlockList.size();
-                               List<Long> ids = this.jdbcTemplate.queryForList("select b.p_key_id from m_wbs_tree_contract a join m_wbs_tree_contract b on (a.parent_id=b.parent_id and a.contract_id=b.contract_id) where a.p_key_id="+tec.getCurrentNode().getPkId()+" and b.is_deleted=0 and b.node_type=6",Long.class);
-                               itemBlockList.removeIf(ik->!ids.contains(ik.getPkeyId()));
-                               if(itemBlockList.size()>0){
-                                   int total=itemBlockList.stream().mapToInt(ItemBlock::getSubTotal).sum();
-                                   int passNum=itemBlockList.stream().mapToInt(ItemBlock::getSubPass).sum();
-                                   double passRate=100*(double)passNum/(double) total;
-                                   FormulaUtils.write(t.getPass(),StringUtils.number2String(passRate,1),null);
-                                   if(passRate>=60){
-                                       FormulaUtils.write(t.getJudge(),"合格",null);
-                                   }
-                                   itemBlockList.sort(Comparator.comparingInt(a->ids.indexOf(a.getPkeyId())));
-                                   FormulaUtils.write(t.getValue(),itemBlockList.stream().map(ItemBlock::getData).flatMap(v->v.stream().flatMap(Collection::stream)).collect(Collectors.toList()),true);
+                        ElementBlock g=null;
+                        FormData vfd=t.getValue();
+                        if(vfd.executable()&&vfd.getFormula().getRelyList()!=null){
+                            List<String> relyList = vfd.getFormula().getRelyList();
+                           Optional<ElementBlock> op= elementBlockList.stream().filter(e->relyList.contains(e.getCode())).findAny();
+                           if(op.isPresent()){
+                               g=op.get();
+                           }
+                        }
+                        if(g==null){
+                            Optional<ElementBlock> op=   elementBlockList.stream().filter(w->FormulaUtils.similarity(w.getEName(),t.getPoint())>0.6).reduce((a, b) -> Comparator.<Double>reverseOrder().compare(FormulaUtils.similarity(a.getEName(),t.getPoint()), FormulaUtils.similarity(b.getEName(),t.getPoint())) <= 0 ? a : b);
+                            if(op.isPresent()){
+                                g=op.get();
+                            }
+                        }
+                        if(g!=null){
+                            List<ItemBlock> itemBlockList =g.getList();
+                            int originSize=itemBlockList.size();
+                            List<Long> ids = this.jdbcTemplate.queryForList("select b.p_key_id from m_wbs_tree_contract a join m_wbs_tree_contract b on (a.parent_id=b.parent_id and a.contract_id=b.contract_id) where a.p_key_id="+tec.getCurrentNode().getPkId()+" and b.is_deleted=0 and b.node_type=6",Long.class);
+                            itemBlockList.removeIf(ik->!ids.contains(ik.getPkeyId()));
+                            if(itemBlockList.size()>0){
+                                int total=itemBlockList.stream().mapToInt(ItemBlock::getSubTotal).sum();
+                                int passNum=itemBlockList.stream().mapToInt(ItemBlock::getSubPass).sum();
+                                double passRate=100*(double)passNum/(double) total;
+                                FormulaUtils.write(t.getPass(),StringUtils.number2String(passRate,1),null);
+                                if(passRate>=60){
+                                    FormulaUtils.write(t.getJudge(),"合格",null);
+                                }
+                                itemBlockList.sort(Comparator.comparingInt(a->ids.indexOf(a.getPkeyId())));
+                                FormulaUtils.write(t.getValue(),itemBlockList.stream().map(ItemBlock::getData).flatMap(v->v.stream().flatMap(Collection::stream)).collect(Collectors.toList()),true);
 
 //                                   if(t.getValue().getEName().contains("±")){
 //                                       /*存在偏差范围则获取的是偏差值:实测-设计*/
@@ -256,13 +271,13 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
 //                                   }else{
 //                                      FormulaUtils.write(t.getValue(),itemBlockList.stream().map(ItemBlock::getData).flatMap(v->v.stream().flatMap(Collection::stream)).collect(Collectors.toList()),true);
 //                                   }
-                               }
-                               t.flush();
-                               if(originSize>0&&originSize!=itemBlockList.size()){
-                                   g.setList(itemBlockList);
-                                   update.set(true);
-                               }
-                        });
+                            }
+                            t.flush();
+                            if(originSize>0&&originSize!=itemBlockList.size()){
+                                g.setList(itemBlockList);
+                                update.set(true);
+                            }
+                        }
                     });
                     if(update.get()){
                         this.formulaDataBlockService.saveOrUpdate(fdb);