Browse Source

Merge branch 'v2.0.0' of http://39.106.8.246:3003/apm/energy-eq-run-diagnose into v2.0.0

shaohongbo 3 years ago
parent
commit
647ae1e480

+ 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;
+    }
 }

+ 0 - 120
src/main/resources/logback-diagnose.xml

@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration>
-    <contextName>${APP_NAME}</contextName>
-    <springProperty name="APP_NAME" scope="context" source="spring.application.name"/>
-    <springProperty name="LOG_FILE" scope="context" source="logging.file" defaultValue="../logs/${APP_NAME}/application"/>
-    <springProperty name="LOG_POINT_FILE" scope="context" source="logging.file" defaultValue="../logs/${APP_NAME}/point"/>
-    <springProperty name="LOG_AUDIT_FILE" scope="context" source="logging.file" defaultValue="../logs/${APP_NAME}/audit"/>
-    <springProperty name="LOG_MAXFILESIZE" scope="context" source="logback.filesize" defaultValue="100MB"/>
-    <springProperty name="LOG_FILEMAXDAY" scope="context" source="logback.filemaxday" defaultValue="7"/>
-    <springProperty name="LOG_TOTALSIZE" scope="context" source="logback.totalsize" defaultValue="1GB"/>
-    <springProperty name="ServerIP" scope="context" source="spring.cloud.client.ip-address" defaultValue="0.0.0.0"/>
-    <springProperty name="ServerPort" scope="context" source="server.port" defaultValue="0000"/>
-
-    <!-- 彩色日志 -->
-    <!-- 彩色日志依赖的渲染类 -->
-    <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
-    <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
-    <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
-
-    <!-- 彩色日志格式 -->
-    <property name="CONSOLE_LOG_PATTERN"
-              value="[${APP_NAME}:${ServerIP}:${ServerPort}] %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%level){blue} %clr(${PID}){magenta} %clr([%X{traceId}]){yellow} %clr([%thread]){orange} %clr(%logger){cyan} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}" />
-    <property name="CONSOLE_LOG_PATTERN_NO_COLOR" value="[${APP_NAME}:${ServerIP}:${ServerPort}] %d{yyyy-MM-dd HH:mm:ss.SSS} %level ${PID} [%X{traceId}] [%thread] %logger %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}" />
-
-    <!-- 控制台日志 -->
-    <appender name="StdoutAppender" class="ch.qos.logback.core.ConsoleAppender">
-        <withJansi>true</withJansi>
-        <encoder>
-            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
-            <charset>UTF-8</charset>
-        </encoder>
-    </appender>
-    <!-- 按照每天生成常规日志文件 -->
-    <appender name="FileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${LOG_FILE}/${APP_NAME}.log</file>
-        <encoder>
-            <pattern>${CONSOLE_LOG_PATTERN_NO_COLOR}</pattern>
-            <charset>UTF-8</charset>
-        </encoder>
-        <!-- 基于时间的分包策略 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
-			<fileNamePattern>${LOG_FILE}/${APP_NAME}.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
-			<!--单文件最大限制-->
-			<maxFileSize>${LOG_MAXFILESIZE}</maxFileSize>
-            <!--保留时间,单位:天-->
-            <maxHistory>${LOG_FILEMAXDAY}</maxHistory>
-            <!-- 日志总大小 -->
-            <totalSizeCap>${LOG_TOTALSIZE}</totalSizeCap>
-        </rollingPolicy>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <level>INFO</level>
-        </filter>
-    </appender>
-
-    <appender name="point_log" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${LOG_POINT_FILE}/point.log</file>
-        <encoder>
-            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS}|${APP_NAME}|%msg%n</pattern>
-            <charset>UTF-8</charset>
-        </encoder>
-        <!-- 基于时间的分包策略 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
-			<fileNamePattern>${LOG_POINT_FILE}/point.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
-			<!--单文件最大限制-->
-			<maxFileSize>${LOG_MAXFILESIZE}</maxFileSize>
-            <!--保留时间,单位:天-->
-            <maxHistory>${LOG_FILEMAXDAY}</maxHistory>
-            <!-- 日志总大小 -->
-            <totalSizeCap>${LOG_TOTALSIZE}</totalSizeCap>
-        </rollingPolicy>
-    </appender>
-
-    <appender name="audit_log" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${LOG_AUDIT_FILE}/audit.log</file>
-        <encoder>
-            <pattern>%msg%n</pattern>
-            <charset>UTF-8</charset>
-        </encoder>
-        <!-- 基于时间的分包策略 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
-			<fileNamePattern>${LOG_AUDIT_FILE}/audit.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
-			<!--单文件最大限制-->
-			<maxFileSize>${LOG_MAXFILESIZE}</maxFileSize>
-            <!--保留时间,单位:天-->
-            <maxHistory>${LOG_FILEMAXDAY}</maxHistory>
-            <!-- 日志总大小 -->
-            <totalSizeCap>${LOG_TOTALSIZE}</totalSizeCap>
-        </rollingPolicy>
-    </appender>
-
-    <appender name="file_async" class="ch.qos.logback.classic.AsyncAppender">
-        <discardingThreshold>0</discardingThreshold>
-        <appender-ref ref="FileAppender"/>
-    </appender>
-    <appender name="point_log_async" class="ch.qos.logback.classic.AsyncAppender">
-        <discardingThreshold>0</discardingThreshold>
-        <appender-ref ref="point_log"/>
-    </appender>
-    <logger name="com.persagy.log.util.PointUtil" level="info" addtivity="false">
-        <appender-ref ref="point_log_async" />
-    </logger>
-    <appender name="audit_log_async" class="ch.qos.logback.classic.AsyncAppender">
-        <discardingThreshold>0</discardingThreshold>
-        <appender-ref ref="audit_log"/>
-    </appender>
-    <logger name="com.persagy.log.service.impl.LoggerAuditServiceImpl" level="debug" addtivity="false">
-        <appender-ref ref="audit_log_async" />
-    </logger>
-	<!-- 剔除eureka client心跳日志 -->
-	<logger name="com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver" level="WARN" />
-	
-<!--    <root level="INFO">-->
-<!--        <appender-ref ref="StdoutAppender"/>-->
-<!--        <appender-ref ref="file_async"/>-->
-<!--    </root>-->
-<!--    <root level="ERROR">-->
-<!--        <appender-ref ref="StdoutAppender"/>-->
-<!--        <appender-ref ref="file_async"/>-->
-<!--    </root>-->
-</configuration>