|
@@ -2242,14 +2242,51 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
@Override
|
|
|
public Map<String,Object> getElementInfoByCodes(String codes){
|
|
|
+ final String ekey="ekey";
|
|
|
+ String[] model = new String[]{BaseInfo.TBN,MeterPeriodInfo.TBN};
|
|
|
+ List<Map<String,Object>> mapList =new ArrayList<>();
|
|
|
if(StringUtils.isNotEmpty(codes)){
|
|
|
- String[] relyArr = codes.split(StringPool.COMMA);
|
|
|
- List<Map<String,Object>> mapList =this.jdbcTemplate.queryForList("select CONCAT(a.tab_en_name,':',b.e_key) ekey,a.tab_ch_name tableName,b.e_name ename ,b.e_length elength,c.dict_value type f" +
|
|
|
- "rom m_table_info a JOIN m_wbs_form_element b on a.id=b.f_id and b.is_deleted=0 " +
|
|
|
- "LEFT JOIN (select dict_key, dict_value from blade_dict where code ='data_type' and parent_id > 0 and is_sealed = 0 and is_deleted = 0 )c on b.e_type=c.dict_key" +
|
|
|
- " where a.tab_en_name in( "+ Arrays.stream(relyArr).map(e->e.split(StringPool.COLON)[0]).distinct().collect(Collectors.joining("','","'","'"))+")");
|
|
|
- if(ListUtils.isNotEmpty(mapList)){
|
|
|
- return mapList.stream().filter(e-> Arrays.stream(relyArr).anyMatch(c->StringUtils.isEquals(e.get("ekey"),c))).collect(Collectors.toMap(e->StringUtils.handleNull(e.get("ekey")), e->e));
|
|
|
+ String[] relyArr=codes.split(StringPool.COMMA);
|
|
|
+ List<String> codeList = new ArrayList<>(Arrays.asList(relyArr));
|
|
|
+ Predicate<String> isModel = code-> BaseUtils.inChain(model,code);
|
|
|
+ List<String> modelList= codeList.stream().filter(isModel).collect(Collectors.toList());
|
|
|
+ if(modelList.size()>0) {
|
|
|
+ codeList.removeIf(modelList::contains);
|
|
|
+ for(String code:modelList){
|
|
|
+ String tbn=code.split(StringPool.COLON)[0];
|
|
|
+ String tbnCh="";
|
|
|
+ List<WbsFormElementVO> elementVOS = null;
|
|
|
+ if(BaseInfo.TBN.equals(tbn)){
|
|
|
+ elementVOS=FormulaUtils.toElementVos(BaseInfo.class);
|
|
|
+ tbnCh=BaseInfo.TBN_CH;
|
|
|
+ }else if(MeterPeriodInfo.TBN.equals(tbn)){
|
|
|
+ elementVOS=FormulaUtils.toElementVos(MeterPeriodInfo.class);
|
|
|
+ tbnCh=MeterPeriodInfo.TBN_CH;
|
|
|
+ }
|
|
|
+ if(elementVOS!=null){
|
|
|
+ String finalTbnCh = tbnCh;
|
|
|
+ elementVOS.stream().filter(e->modelList.contains(e.getTableElementKey())).collect(Collectors.toList()).forEach(e->{
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put(ekey,e.getTableElementKey());
|
|
|
+ map.put("tableName", finalTbnCh);
|
|
|
+ map.put("ename", e.getEName());
|
|
|
+ mapList.add(map);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(codeList.size()>0) {
|
|
|
+ List<Map<String, Object>> tmpList = this.jdbcTemplate.queryForList("select CONCAT(a.tab_en_name,':',b.e_key) ekey,a.tab_ch_name tableName,b.e_name ename ,b.e_length elength,c.dict_value type f" +
|
|
|
+ "rom m_table_info a JOIN m_wbs_form_element b on a.id=b.f_id and b.is_deleted=0 " +
|
|
|
+ "LEFT JOIN (select dict_key, dict_value from blade_dict where code ='data_type' and parent_id > 0 and is_sealed = 0 and is_deleted = 0 )c on b.e_type=c.dict_key" +
|
|
|
+ " where a.tab_en_name in( " + codeList.stream().map(e -> e.split(StringPool.COLON)[0]).distinct().collect(Collectors.joining("','", "'", "'")) + ")");
|
|
|
+ if (tmpList.size() > 0) {
|
|
|
+ mapList.addAll(tmpList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(mapList.size()>0){
|
|
|
+ return mapList.stream().filter(e-> Arrays.stream(relyArr).anyMatch(c->StringUtils.isEquals(e.get(ekey),c))).collect(Collectors.toMap(e->StringUtils.handleNull(e.get(ekey)), e->e));
|
|
|
}
|
|
|
|
|
|
}
|