Browse Source

增加获取设备类和报警系统接口

lixing 3 years ago
parent
commit
00b74d11e5

+ 34 - 0
src/main/java/com/persagy/apm/diagnose/service/NettyAlarmServiceImpl.java

@@ -1,9 +1,15 @@
 package com.persagy.apm.diagnose.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.persagy.apm.diagnose.utils.DmpResultUtil;
 import com.persagy.apm.energyalarmstarter.alarmdata.feign.AlarmUrlParam;
+import com.persagy.apm.energyalarmstarter.alarmdata.feign.DmpResult;
+import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmitem.QueryAlarmItemDTO;
+import com.persagy.apm.energyalarmstarter.alarmdata.model.vo.AlarmItem;
+import com.persagy.apm.energyalarmstarter.alarmdata.service.AlarmItemServiceImpl;
 import com.persagy.apm.energyalarmstarter.alarmengine.service.NettyAlarmService;
 import lombok.SneakyThrows;
+import org.assertj.core.util.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
@@ -17,6 +23,8 @@ public class NettyAlarmServiceImpl extends NettyAlarmService {
 
     @Autowired
     private CenterDataService centerDataService;
+    @Autowired
+    private AlarmItemServiceImpl alarmItemService;
 
     @Override
     public String getMeterId(String infoCode, String classCode) throws Exception {
@@ -65,4 +73,30 @@ public class NettyAlarmServiceImpl extends NettyAlarmService {
         return null;
     }
 
+    @SneakyThrows
+    @Override
+    protected String getAlarmCategory(AlarmUrlParam urlParam, String itemCode) {
+        QueryAlarmItemDTO queryAlarmItemDTO = new QueryAlarmItemDTO();
+        queryAlarmItemDTO.setCode(Lists.newArrayList(itemCode));
+        queryAlarmItemDTO.setGroupCode(urlParam.getGroupCode());
+        queryAlarmItemDTO.setProjectId(urlParam.getProjectId());
+        queryAlarmItemDTO.setUserId(urlParam.getUserId());
+        DmpResult<List<AlarmItem>> queryResult = alarmItemService.query(queryAlarmItemDTO);
+        List<AlarmItem> data = DmpResultUtil.getData(queryResult);
+        if (CollectionUtils.isEmpty(data)) {
+            return null;
+        }
+
+        return data.get(0).getCategory();
+    }
+
+    @SneakyThrows
+    @Override
+    protected String getObjClassCode(AlarmUrlParam urlParam, String objId) {
+        List<JSONObject> objectList = centerDataService.queryObjListByObjId(urlParam.getProjectId(), Arrays.asList(objId));
+        if (!CollectionUtils.isEmpty(objectList)) {
+            return objectList.get(0).getString("classCode");//设备类型编码
+        }
+        return null;
+    }
 }