Просмотр исходного кода

新增 创建告警配置查询设备类型列表接口

zhaiyifei 9 месяцев назад
Родитель
Сommit
fb07b8944a

+ 6 - 0
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/domain/IotSfElementfactorEditReqVo.java

@@ -35,6 +35,12 @@ public class IotSfElementfactorEditReqVo extends IotBaseEntity {
     /** 地址 */
     private String sfAddress;
 
+    /**
+     * 索引,前端排序后传给后端,后端根据索引排序
+     * 目前只针对灌区
+     */
+    private Integer index;
+
     private List<IotSfElementfactorEditReqVo> childrenList;
 
 }

+ 40 - 1
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/service/IIotSfCommService.java

@@ -321,6 +321,16 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
      */
     public int elementEdit(IotSfElementfactorEditReqVo reqVo) {
         String devBid = reqVo.getDevBid();
+        String sfType = reqVo.getSfType();
+        Integer index = reqVo.getIndex();
+
+        if(sfType == null){
+            throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"类型不能为空");
+        }
+
+        if(sfType.equals(EnumSfElementType.GROUP.getCode()) && index == null){
+            throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"排序索引不能为空");
+        }
 
         if (StringUtils.isEmpty(devBid)) {
             throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
@@ -348,13 +358,30 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
         selectReqVo.setSfBidList(sfBidLit);
         selectReqVo.setDevBid(devBid);
         List<IotSfElementfactor> factorList = iotSfElementfactorService.selectIotSfElementfactorList(selectReqVo);
+
         Map<String, IotSfElementfactor> factorMap = new HashMap<>();
         for (IotSfElementfactor factor : factorList) {
             factorMap.put(factor.getSfBid(), factor);
         }
 
+
+
+
+        List<IotSfElementfactor> groupList = new LinkedList<>();
+        if(Objects.equals(sfType, EnumSfElementType.GROUP.getCode())){
+            IotSfElementfactorListReqVo groupVo = new IotSfElementfactorListReqVo();
+            groupVo.setDevBid(devBid);
+            List<IotSfElementfactor> groupVoList = iotSfElementfactorService.selectIotSfElementfactorListByGroup(groupVo);
+            for (IotSfElementfactor group : groupVoList) {
+                if(!group.getSfBid().equals(reqVo.getSfBid())){
+                    groupList.add(group);
+                }
+            }
+        }
+
         String sfModifieddate = DateUtils.dateTimeNow();
         List<IotSfElementfactor> updateList = new ArrayList<>();
+
         for (IotSfElementfactorEditReqVo req : reqList) {
             if (StringUtils.isEmpty(req.getSfDisplayname())) {
                 throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "名称不能为空");
@@ -376,7 +403,19 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
             iotSfElementfactor.setSfModifieddate(sfModifieddate);
             iotSfElementfactor.setSfModifier(SecurityUtils.getUserId());
 
-            updateList.add(iotSfElementfactor);
+            if(Objects.equals(sfType, EnumSfElementType.GROUP.getCode())){
+                groupList.add(index, iotSfElementfactor);
+            }else{
+                updateList.add(iotSfElementfactor);
+            }
+        }
+
+        if(sfType.equals(EnumSfElementType.GROUP.getCode())){
+            for(int i = 0; i < groupList.size(); i++){
+                IotSfElementfactor factor = groupList.get(i);
+                factor.setSfSequence(i);
+                updateList.add(factor);
+            }
         }
 
         return iotSfElementfactorService.batchUpdateIotSfElementfactor(updateList);

+ 17 - 0
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/service/impl/myTest.java

@@ -0,0 +1,17 @@
+package com.yunfeiyun.agmp.iotm.device.sf.service.impl;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class myTest {
+    public static void main(String[] args) {
+        System.out.println("Hello, World!");
+        List<String> list = new LinkedList<>();
+        list.add("0");
+        list.add("1");
+        list.add("2");
+        System.out.println(list);
+        list.add(4, "3");
+        System.out.println(list);
+    }
+}