Browse Source

fix : 台账管理--设备台账--所属系统实例删除功能无效,且报错“ 必填项:EquipId(设备id)、sysIdList(系统id列表)”
支持删除系统和设备关系

lvxianyun 3 years ago
parent
commit
b3512d64b3

+ 13 - 9
src/main/java/com/persagy/proxy/relation/controller/RelationSyEqController.java

@@ -133,8 +133,8 @@ public class RelationSyEqController {
     public AdmResponse createDistinctEq(@RequestBody JSONObject param) throws Exception {
         String equipId = param.getString("equipId");
         JSONArray sysIdList = param.getJSONArray("sysIdList");
-        if(StringUtils.isEmpty(equipId) || CollUtil.isEmpty(sysIdList)) {
-            return AdmResponse.failure("必填项:EquipId(设备id)、sysIdList(系统id列表)");
+        if(StringUtils.isEmpty(equipId)) {
+            return AdmResponse.failure("必填项:EquipId(设备id)");
         }
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         QueryCriteria queryRequest = new QueryCriteria();
@@ -142,15 +142,19 @@ public class RelationSyEqController {
         node.put("graphCode", "MechSubset");
         node.put("relCode", "Sy2Eq");
         node.put("objTo", equipId);
+        //删除关系
         queryRequest.setCriteria(node);
         service.doDelete(context,queryRequest);
-        // 创建关系对象
-        List<RelationDTO> voList = new ArrayList<>();
-        sysIdList.forEach(item->{
-            voList.add(new RelationDTO(null, "MechSubset", "Sy2Eq", null, item.toString() , equipId));
-        });
-        // 组装上下文条件
-        service.doSave(context, voList);
+        if(!CollUtil.isEmpty(sysIdList)){
+            // 创建关系对象
+            List<RelationDTO> voList = new ArrayList<>();
+            sysIdList.forEach(item->{
+                voList.add(new RelationDTO(null, "MechSubset", "Sy2Eq", null, item.toString() , equipId));
+            });
+            // 组装上下文条件
+            service.doSave(context, voList);
+        }
+
         return AdmResponse.success();
     }