|
@@ -271,6 +271,46 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
FormulaDataBlock fdb = findFdb(tec);
|
|
|
if (!StringUtils.isEquals("[]", fdb.getVal())) {
|
|
|
List<ElementBlock> elementBlockList = JSON.parseArray(fdb.getVal(), ElementBlock.class);
|
|
|
+ Map<String,Map<String,Set<Long>>> traceMap= new HashMap<>();
|
|
|
+ Map<String,List<ElementBlock>> tableElmentMap= new HashMap<>();
|
|
|
+ elementBlockList.forEach(e->{
|
|
|
+ if(e.getList().stream().flatMap(it->it.getData().stream().flatMap(Collection::stream)).anyMatch(Objects::isNull)){
|
|
|
+ String[] codeArr= e.getCode().split(":");
|
|
|
+ Map<String,Set<Long>> tmp = traceMap.computeIfAbsent(codeArr[0],k->new HashMap<>());
|
|
|
+ tmp.put(codeArr[1],e.getList().stream().map(ItemBlock::getPkeyId).collect(Collectors.toSet()));
|
|
|
+ List<ElementBlock> teList = tableElmentMap.computeIfAbsent(codeArr[0],k->new ArrayList<>());
|
|
|
+ teList.add(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ /*如果检测到存在无效值null则需要溯源获取原始实测值*/
|
|
|
+ if(traceMap.size()>0){
|
|
|
+ /* String sqlTemplate ="select $1 from $2 where p_key_id in ($3)";*/
|
|
|
+ String sqlTemplate ="select $1 from m_wbs_tree_contract a join m_wbs_tree_contract b on (a.id=b.parent_id and a.contract_id=b.contract_id) join $2 c on b.p_key_id=c.p_key_id where a.p_key_id in($3) and b.is_deleted=0";
|
|
|
+ traceMap.forEach((initTableName,kkMap)->{
|
|
|
+ String keys = "c."+String.join(",c.", kkMap.keySet())+",a.p_key_id";
|
|
|
+ String pkeyIds= kkMap.values().stream().flatMap(set->set.stream().map(Objects::toString)).distinct().collect(Collectors.joining(","));
|
|
|
+ String sql =sqlTemplate.replace("$1",keys).replace("$2",initTableName).replace("$3",pkeyIds);
|
|
|
+ List<Map<String,Object>> dataList =this.jdbcTemplate.queryForList(sql);
|
|
|
+ if(dataList.size()>0){
|
|
|
+ Map<Long,Map<String,Object>> group =dataList.stream().collect(Collectors.toMap(m->Long.parseLong(m.get("p_key_id").toString()),m->m,(v1,v2)->v1));
|
|
|
+ List<ElementBlock> teList = tableElmentMap.get(initTableName);
|
|
|
+ teList.forEach(it->{
|
|
|
+ List<ItemBlock> itemBlockList= it.getList();
|
|
|
+ String ekey=it.getCode().split(":")[1];
|
|
|
+ itemBlockList.forEach(ib->{
|
|
|
+ /*指定节点的指定元素内容,替换当前*/
|
|
|
+ Map<String,Object> tmp= group.get(ib.getPkeyId());
|
|
|
+ if(tmp!=null) {
|
|
|
+ String value = StringUtils.handleNull(tmp.get(ekey));
|
|
|
+ if (value.length() > 0) {
|
|
|
+ ib.setData(Collections.singletonList(Arrays.stream(value.split("☆")).map(s -> s.split("_\\^_")[0]).collect(Collectors.toList())));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
Map<String, Measurement> itemsMap = new HashMap<>();
|
|
|
tec.formDataMap.values().stream().filter(FormData::getIsCurrentNodeElement).forEach(e -> {
|
|
|
String eName = e.getEName();
|
|
@@ -1427,7 +1467,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
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();
|
|
|
- if (targetItem.getDesigns()!=null&&targetItem.getDesigns().size()>0) {
|
|
|
+ if (targetItem.getDesigns()!=null&&targetItem.getDesigns().size()>1) {
|
|
|
int len = targetItem.getDesigns().size();
|
|
|
targetItem.setData(new ArrayList<>(list.stream().collect(Collectors.groupingBy(k -> index.getAndIncrement() / len, LinkedHashMap::new, Collectors.toList())).values()));
|
|
|
} else {
|