Browse Source

修改获取监测指标的处理逻辑

lixing 3 years ago
parent
commit
b71bf2efe8

+ 2 - 2
src/main/java/com/persagy/apm/diagnose/feign/client/AlarmServiceClient.java

@@ -8,8 +8,8 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 
 
-//@FeignClient(name = "energy-alarm-service",url = "http://develop.persagy.com/energy-alarm-service")
-@FeignClient(name = "energy-alarm-service")
+@FeignClient(name = "energy-alarm-service",url = "http://localhost:9977")
+//@FeignClient(name = "energy-alarm-service")
 public interface AlarmServiceClient {
 
 

+ 9 - 0
src/main/java/com/persagy/apm/diagnose/indicatorrecord/controller/MonitorIndicatorRecordController.java

@@ -9,6 +9,7 @@ import com.persagy.apm.diagnose.indicatorrecord.model.dto.*;
 import com.persagy.apm.diagnose.indicatorrecord.model.vo.MonitorIndicatorRecordItemVO;
 import com.persagy.apm.diagnose.indicatorrecord.model.vo.MonitorIndicatorRecordListItemVO;
 import com.persagy.apm.diagnose.indicatorrecord.service.IMonitorIndicatorRecordService;
+import com.persagy.apm.diagnose.service.EnergyAlarmServiceImpl;
 import com.persagy.framework.ems.data.pojo.hbase.MonitorIndicatorRecord;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -59,5 +60,13 @@ public class MonitorIndicatorRecordController {
         monitorIndicatorRecordService.cleanAlarmConfigSendTime(cleanAlarmConfigDTO);
         return ResultHelper.success();
     }
+
+    @Autowired
+    EnergyAlarmServiceImpl energyAlarmService;
+
+    @PostMapping("/test")
+    public void test() throws Exception {
+        String methodId = energyAlarmService.queryObjIndicatorMethodId("Pj1101060001", "Eq1101060001297dc3087a254b0abf1e0e49748f368b", "ACATFU_RunStatus");
+    }
 }
 

+ 8 - 13
src/main/java/com/persagy/apm/diagnose/service/EnergyAlarmServiceImpl.java

@@ -2,12 +2,13 @@ package com.persagy.apm.diagnose.service;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.persagy.apm.common.model.vo.SimpleObjVO;
 import com.persagy.apm.diagnose.feign.AlarmResult;
 import com.persagy.apm.diagnose.feign.client.AlarmServiceClient;
 import com.persagy.apm.diagnose.indicatorrecord.service.impl.MonitorIndicatorRecordServiceImpl;
-import com.persagy.apm.diagnose.maintenance.constant.EnumAlarmItem;
 import com.persagy.apm.diagnose.maintenance.model.dto.AlarmCondition;
 import com.persagy.apm.diagnose.service.dto.*;
+import com.persagy.apm.diagnose.service.vo.MonitorIndicatorConfigVO;
 import com.persagy.apm.diagnose.utils.AlarmResultUtil;
 import com.persagy.apm.diagnose.utils.RedisUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -128,24 +129,18 @@ public class EnergyAlarmServiceImpl {
     public String queryObjIndicatorMethodId(String projectId,String objId, String indicatorId) throws Exception {
         MonitorIndicatorConfigByEquipDTO build = MonitorIndicatorConfigByEquipDTO.builder().projectId(projectId).objId(objId).monitorIndicatorId(Arrays.asList(indicatorId)).groupCode(systemCode).userId("test").pd("wwwwwwwwww").build();
         AlarmResult<JSONObject> result = alarmServiceClient.query_by_equip(build);
-        JSONObject content = result.getContent();
-        if (content == null) {
-            return null;
-        }
-        JSONArray records = content.getJSONArray("records");
-        if (records == null) {
-            return null;
-        }
-        if(CollectionUtils.isEmpty(records)){
+
+        List<MonitorIndicatorConfigVO> records = AlarmResultUtil.getRecords(result, MonitorIndicatorConfigVO.class);
+        if (CollectionUtils.isEmpty(records)) {
             return null;
         }
-        JSONObject recordObj = (JSONObject)records.get(0);
+        MonitorIndicatorConfigVO recordObj = records.get(0);
 
-        JSONObject calculateMethod = recordObj.getJSONObject("calculateMethod");
+        SimpleObjVO calculateMethod = recordObj.getCalculateMethod();
         if (calculateMethod == null) {
             return null;
         }
-        return calculateMethod.getString("id");
+        return calculateMethod.getId();
     }
 
 

+ 28 - 0
src/main/java/com/persagy/apm/diagnose/service/vo/MonitorIndicatorConfigVO.java

@@ -0,0 +1,28 @@
+package com.persagy.apm.diagnose.service.vo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.persagy.apm.common.model.vo.SimpleObjVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-09-08 22:46:56
+ */
+@Data
+@ApiModel(value = "项目监测指标配置列表返回结果参数")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class MonitorIndicatorConfigVO {
+    @ApiModelProperty("主键")
+    private String id;
+    
+    @ApiModelProperty("监测对象")
+    private SimpleObjVO obj;
+    
+    @ApiModelProperty("监测指标")
+    private SimpleObjVO monitorIndicator;
+    
+    @ApiModelProperty("计算方式")
+    private SimpleObjVO calculateMethod;
+}

+ 5 - 0
src/main/resources/bootstrap.yml

@@ -27,6 +27,10 @@ spring:
         reactive:
           connection-timeout: 5000
 
+# 日志管理方式使用集成框架的logback
+logging:
+  config: classpath:logback-spring.xml
+
 EUREKA_CLIENT_DEFAULT_ZONE: http://frame:123456@develop.persagy.com/integrated-eureka/eureka/
 
 mybatis-plus:
@@ -50,3 +54,4 @@ dmp:
     routingKey: routing-dmp-alarm     #报警定义变化路由键
     queue: eq-run-diagnose-alarm-queue              #中控订阅报警定义变化队列
 
+