Browse Source

sb逻辑编组

lirong 2 years ago
parent
commit
9fe3baed4a

+ 16 - 11
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDLoadUtil.java

@@ -973,9 +973,7 @@ public class RWDLoadUtil {
 
                 //根据回路编号分组,一个回路对应多个编组
                 Map<String, List<SceneDataObject>> groupByhuiluMap = huilu.set.stream().collect(Collectors.groupingBy(item -> item.get("回路编号").value_prim.value.toString()));
-
                 for (String id : groupByhuiluMap.keySet()) {
-//					String id = (String) sdo.get("回路编号").value_prim.value;
                     if (Repository.id2sdv.containsKey(id)) {
                         List<SceneDataObject> bianzu = groupByhuiluMap.get(id);
                         SceneDataObject equipment = Repository.id2sdv.get(id);
@@ -992,15 +990,17 @@ public class RWDLoadUtil {
                         SceneDataValue bianzuleixing = null;
                         SceneDataValue lcbianhao = null;
                         SceneDataValue lcName = null;
-                        JSONArray yijibianzu = new JSONArray();
-                        JSONArray erjibianzu = new JSONArray();
+                        StringBuffer sb_yjbz = new StringBuffer();
+                        StringBuffer sb_rjbz = new StringBuffer();
                         SceneDataValue yjbz = new SceneDataValue(null, null, null, null);
                         yjbz.finish = true;
                         yjbz.value_prim = new SceneDataPrimitive();
                         SceneDataValue ejbz = new SceneDataValue(null, null, null, null);
                         ejbz.finish = true;
                         ejbz.value_prim = new SceneDataPrimitive();
-                        for (SceneDataObject bz : bianzu) {
+                        bianzu.removeIf(x->x.size()<=1);
+                        for (int i = 0; i < bianzu.size(); i++) {
+                            SceneDataObject bz=bianzu.get(i);
                             if (bz.size() > 1) {
                                 mokuai = bz.containsKey("模块名称") ? bz.get("模块名称") : sdv_null;
                                 peidianxiangmingcheng = bz.containsKey("配电箱名称") ? bz.get("配电箱名称") : sdv_null;
@@ -1012,16 +1012,21 @@ public class RWDLoadUtil {
                                 bianzuleixing = bz.containsKey("编组类型") ? bz.get("编组类型") : sdv_null;
                                 lcbianhao = bz.containsKey("楼层编号") ? bz.get("楼层编号") : sdv_null;
                                 lcName = bz.containsKey("楼层名称") ? bz.get("楼层名称") : sdv_null;
-                                if (yijibianzuName.value_prim.value != null && !yijibianzu.contains(yijibianzuName.value_prim.value)) {
-                                    yijibianzu.add(yijibianzuName.value_prim.value);
+                                if (yijibianzuName.value_prim.value != null && !sb_yjbz.toString().contains(yijibianzuName.value_prim.value.toString())) {
+                                    sb_yjbz.append(""+yijibianzuName.value_prim.value+"");
+                                }
+                                if (erjibianzuName.value_prim.value != null && !sb_rjbz.toString().contains(erjibianzuName.value_prim.value.toString())) {
+                                    sb_rjbz.append(""+erjibianzuName.value_prim.value+"");
                                 }
-                                if (erjibianzuName.value_prim.value != null && !erjibianzu.contains(erjibianzuName.value_prim.value)) {
-                                    erjibianzu.add(erjibianzuName.value_prim.value);
+                                if(i<(bianzu.size()-1))
+                                {
+                                    sb_yjbz.append(",");
+                                    sb_rjbz.append(",");
                                 }
                             }
                         }
-                        yjbz.value_prim.value = yijibianzu;
-                        ejbz.value_prim.value = erjibianzu;
+                        yjbz.value_prim.value = sb_yjbz.toString();
+                        ejbz.value_prim.value = sb_rjbz.toString();
                         equipment.put("模块名称", mokuai);
                         equipment.put("配电箱名称", peidianxiangmingcheng);
                         equipment.put("配电箱编号", peidianxiangbianhao);