Browse Source

设备维保和更换建议 自测修复

miaolijing 3 years ago
parent
commit
efe37de708

+ 10 - 0
src/main/java/com/persagy/apm/diagnose/config/ThreadPoolExecutorConfig.java

@@ -91,6 +91,16 @@ public class ThreadPoolExecutorConfig {
         });
     }
 
+    @Bean("asyncSendMaintenanceDataExecutor")
+    public Executor asyncSendMaintenanceDataExecutor() {
+        return new ThreadPoolExecutorExtend(corePoolSize, maxPoolSize,
+                5, TimeUnit.SECONDS,
+                new LinkedBlockingQueue<>(queueCapacity),
+                threadFactory, (r, executor) -> {
+            log.info("asyncSendMaintenanceDataExecutor is rejected");
+        });
+    }
+
     @Bean("asyncGoingDestroyEquipExecutor")
     public Executor asyncGoingDestroyEquipExecutor() {
         return new ThreadPoolExecutorExtend(corePoolSize, maxPoolSize,

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

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

+ 1 - 1
src/main/java/com/persagy/apm/diagnose/maintenance/service/IProjectDataRecordService.java

@@ -11,7 +11,7 @@ public interface IProjectDataRecordService {
 
     Future<String> computeMaintenanceData(Date todayDate,String projectId,CountDownLatch latch) throws Exception;
 
-//    Future<String> sendMaintenanceData(Date todayDate,String projectId, CountDownLatch latch) throws Exception;
+    Future<String> sendMaintenanceData(Date todayDate,String projectId, CountDownLatch latch) throws Exception;
 
     Future<String> syncGoingDestroyEquip(String projectId, CountDownLatch latch) throws Exception;
 

+ 145 - 70
src/main/java/com/persagy/apm/diagnose/maintenance/service/impl/ProjectDataRecordServiceImpl.java

@@ -3,7 +3,10 @@ package com.persagy.apm.diagnose.maintenance.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.persagy.apm.diagnose.config.ComputePropertiesConfig;
+import com.persagy.apm.diagnose.constant.DiAgnoseConst;
 import com.persagy.apm.diagnose.constant.EnumDataTimeType;
+import com.persagy.apm.diagnose.indicatorrecord.model.dto.ConfigItemDataSendTimeDTO;
 import com.persagy.apm.diagnose.indicatorrecord.model.dto.QueryMonitorIndicatorRecordDTO;
 import com.persagy.apm.diagnose.indicatorrecord.service.IMonitorIndicatorRecordService;
 import com.persagy.apm.diagnose.maintenance.constant.*;
@@ -13,6 +16,7 @@ import com.persagy.apm.diagnose.service.CenterDataService;
 import com.persagy.apm.diagnose.service.EnergyAlarmServiceImpl;
 import com.persagy.apm.diagnose.service.SaasService;
 import com.persagy.apm.diagnose.service.dto.AlarmRuleDTO;
+import com.persagy.apm.diagnose.service.dto.ProjectDTO;
 import com.persagy.apm.diagnose.service.dto.TimeDataDTO;
 import com.persagy.apm.diagnose.timerecord.model.CalculateTimeRecord;
 import com.persagy.apm.diagnose.timerecord.service.ICalculateTimeRecordService;
@@ -23,9 +27,12 @@ import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.AddAla
 import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.BatchUpdateAlarmRecordDTO;
 import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.QueryAlarmRecordDTO;
 import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.UpdateAlarmRecordDTO;
+import com.persagy.apm.energyalarmstarter.alarmdata.model.vo.AlarmConfigItem;
 import com.persagy.apm.energyalarmstarter.alarmdata.model.vo.AlarmRecordItem;
 import com.persagy.apm.energyalarmstarter.alarmdata.service.AlarmConfigServiceImpl;
 import com.persagy.apm.energyalarmstarter.alarmdata.service.AlarmRecordServiceImpl;
+import com.persagy.apm.energyalarmstarter.collectdata.websocket.AlarmWebSocketServer;
+import com.persagy.framework.ems.data.core.enumeration.SpecialOperator;
 import com.persagy.framework.ems.data.mvc.dao.CoreDao;
 import com.persagy.framework.ems.data.pojo.hbase.MonitorIndicatorRecord;
 import lombok.extern.slf4j.Slf4j;
@@ -73,10 +80,14 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
     private RedisLock lockUtil;
     @Autowired
     private RedisUtil redisUtil;
-
+    @Autowired
+    private ComputePropertiesConfig computePropertiesConfig;
     @Autowired
     private EnergyAlarmServiceImpl energyAlarmService;
 
+    @Resource(name = "ZillionDao")
+    private CoreDao coredao;
+
     @Override
     @Async("asyncComputeMaintenanceDataExecutor")
     public Future<String> computeMaintenanceData(Date todayDate, String projectId, CountDownLatch latch) throws Exception {
@@ -102,25 +113,25 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
     }
 
 
-//    @Override
-//    @Async("asyncSendMaintenanceDataExecutor")
-//    public Future<String> sendMaintenanceData(Date todayDate, String projectId, CountDownLatch latch) throws Exception {
-//        long time = System.currentTimeMillis() + (20 * 1000);
-//        try {
-//            if (!lockUtil.lock(projectId + "_sendMaintenance", String.valueOf(time))) {
-//                // 获取不到锁,略过
-//                return new AsyncResult<>("【监测维保数据推送线程】:项目:" + projectId + "被占用");
-//            }
-//
-//            long start = System.currentTimeMillis();
-//            sendProjectMaintenanceData(todayDate, projectId);
-//            long end = System.currentTimeMillis();
-//            return new AsyncResult<>("【监测维保数据推送线程】推送项目维保数据用时:" + projectId + ";" + (end - start));
-//        } finally {
-//            lockUtil.unlock(projectId + "_sendMaintenance", String.valueOf(time));
-//            latch.countDown();
-//        }
-//    }
+    @Override
+    @Async("asyncSendMaintenanceDataExecutor")
+    public Future<String> sendMaintenanceData(Date todayDate, String projectId, CountDownLatch latch) throws Exception {
+        long time = System.currentTimeMillis() + (20 * 1000);
+        try {
+            if (!lockUtil.lock(projectId + "_sendMaintenance", String.valueOf(time))) {
+                // 获取不到锁,略过
+                return new AsyncResult<>("【监测维保数据推送线程】:项目:" + projectId + "被占用");
+            }
+
+            long start = System.currentTimeMillis();
+            sendProjectMaintenanceData(todayDate, projectId);
+            long end = System.currentTimeMillis();
+            return new AsyncResult<>("【监测维保数据推送线程】推送项目维保数据用时:" + projectId + ";" + (end - start));
+        } finally {
+            lockUtil.unlock(projectId + "_sendMaintenance", String.valueOf(time));
+            latch.countDown();
+        }
+    }
 
     @Override
     @Async("asyncGoingDestroyEquipExecutor")
@@ -247,54 +258,118 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
     /**
      * 推送维保数据
      */
-//    private void sendProjectMaintenanceData(Date todayDate, String projectId) throws Exception {
-//        //默认从昨日开始 TODO 方便测试
-////      Date yesterdayDate = com.persagy.apm.energyalarmstarter.alarmdata.utils.DateUtils.str2Date("2021-09-17 00:00:00", com.persagy.apm.energyalarmstarter.alarmdata.utils.DateUtils.SDF_SECOND);
-//        Date yesterdayDate = DateUtils.addDays(todayDate, -1);
-//        //通过报警服务查询报警配置
-//        List<AlarmConfigItem> configItemList = getAlarmConfigItemList(projectId);
-//        if (CollectionUtils.isEmpty(configItemList)) {
-//            log.error("【监测维保数据推送线程】当前项目:" + projectId + "未查询到报警条件");
-//            return;
-//        }
-//
-//        for (AlarmConfigItem alarmConfigItem : configItemList) {
-//            AlarmCondition condition = alarmConfigItem.getCondition();
-//            if (condition == null) {
-//                continue;
-//            }
-//            List<String> infoCodes = condition.getInfoCode();
-//            if (CollectionUtils.isEmpty(infoCodes)) {
-//                continue;
-//            }
-//            ConfigItemDataSendTimeDTO configItemSendTimeDTO = getConfigItemSendTimeDTO(projectId, alarmConfigItem, yesterdayDate);
-//            Date lastSendTime = configItemSendTimeDTO.getLastSendTime();
-//
-//            List<MonitorIndicatorRecord> list =  getMonitorIndicatorRecordsGtLte(projectId, alarmConfigItem.getObjId(), lastSendTime, getIndicatorIdListFromInfoCodes(infoCodes), todayDate);
-//            if (CollectionUtils.isEmpty(list)) {
-//                continue;
-//            }
-//
-//            Map<String, List<MonitorIndicatorRecord>> timeKeyAndRecordList = new LinkedHashMap<>();
-//            for (MonitorIndicatorRecord record : list) {
-//                String timeKey = com.persagy.apm.diagnose.utils.DateUtils.date2Str(record.getDate(), com.persagy.apm.diagnose.utils.DateUtils.SDF_SECOND);
-//                if (!timeKeyAndRecordList.containsKey(timeKey)) {
-//                    timeKeyAndRecordList.put(timeKey, new ArrayList<>());
-//                }
-//                timeKeyAndRecordList.get(timeKey).add(record);
-//            }
-//            for (Map.Entry<String, List<MonitorIndicatorRecord>> dateListEntry : timeKeyAndRecordList.entrySet()) {
-//                List<MonitorIndicatorRecord> value = dateListEntry.getValue();
-//                if (CollectionUtils.isEmpty(value) || value.size() != infoCodes.size()) {
-//                    continue;
-//                }
-//                AlarmWebSocketServer.sendMsgToClients(projectId, CollectDataUtil.buildSendParam(value));
-//                todayDate = com.persagy.apm.diagnose.utils.DateUtils.str2Date(dateListEntry.getKey(), com.persagy.apm.diagnose.utils.DateUtils.SDF_SECOND);
-//            }
-//            configItemSendTimeDTO.setLastSendTime(todayDate);
-//            updateRedisConfigItemSendTimeDTO(projectId, configItemSendTimeDTO);
-//        }
-//    }
+    private void sendProjectMaintenanceData(Date todayDate, String projectId) throws Exception {
+        List<String> itemCodeList = new ArrayList<>();
+        itemCodeList.add(EnumAlarmItem.CondAbnormal.getCode());
+        itemCodeList.add(EnumAlarmItem.EvapAbnormal.getCode());
+        itemCodeList.add(EnumAlarmItem.CoolTowerApproachTempAbnormal.getCode());
+        //通过报警服务查询报警规则
+        List<AlarmRuleDTO> projectAlarmRules = energyAlarmService.getProjectAlarmRules(projectId,itemCodeList);
+        if (CollectionUtils.isEmpty(projectAlarmRules)) {
+            return;
+        }
+        //根据报警规则,获取对象id_报警类型及设备监控点位list
+        Map<String, List<String>> objIdAlarmItemCodeAndInfoCodes = getObjIdAlarmItemCodeAndInfoCodes(projectAlarmRules);
+
+        for (Map.Entry<String, List<String>> entry : objIdAlarmItemCodeAndInfoCodes.entrySet()) {
+            String objIdAndAlarmItemCode = entry.getKey();
+
+            int indexOf = objIdAndAlarmItemCode.indexOf("_");
+            String objId = objIdAndAlarmItemCode.substring(0, indexOf);
+            String alarmItemCode = objIdAndAlarmItemCode.substring(indexOf + 1);
+
+            List<String> infCodeList = entry.getValue();
+
+            //通过redis查询对象该报警类型下的发数截止时间
+            ConfigItemDataSendTimeDTO configItemSendTimeDTO = getConfigItemSendTimeDTO(projectId, objIdAndAlarmItemCode);
+
+            Date lastSendTime = configItemSendTimeDTO.getLastSendTime();
+            Date endTime = todayDate;
+
+            List<MonitorIndicatorRecord> list = getMonitorIndicatorRecordsGtLte(projectId, objId, lastSendTime, infCodeList, endTime);
+            if (CollectionUtils.isEmpty(list)) {
+                continue;
+            }
+            Map<String, List<MonitorIndicatorRecord>> timeKeyAndRecordList = new LinkedHashMap<>();
+            for (MonitorIndicatorRecord record : list) {
+                String timeKey = com.persagy.apm.diagnose.utils.DateUtils.date2Str(record.getDataTime(), com.persagy.apm.diagnose.utils.DateUtils.SDF_SECOND);
+                if (!timeKeyAndRecordList.containsKey(timeKey)) {
+                    timeKeyAndRecordList.put(timeKey, new ArrayList<>());
+                }
+                timeKeyAndRecordList.get(timeKey).add(record);
+            }
+            for (Map.Entry<String, List<MonitorIndicatorRecord>> dateListEntry : timeKeyAndRecordList.entrySet()) {
+                List<MonitorIndicatorRecord> value = dateListEntry.getValue();
+                if (CollectionUtils.isEmpty(value) || value.size() != infCodeList.size()) {
+                    continue;
+                }
+                String sentValue = CollectDataUtil.buildSendParam(value,alarmItemCode);
+                AlarmWebSocketServer.sendMsgToClients(projectId, CollectDataUtil.buildSendParam(value,alarmItemCode));
+                log.info("设备维保发送数据服务数据:" + projectId+";"+ sentValue);
+                endTime = com.persagy.apm.diagnose.utils.DateUtils.str2Date(dateListEntry.getKey(), com.persagy.apm.diagnose.utils.DateUtils.SDF_SECOND);
+            }
+            configItemSendTimeDTO.setLastSendTime(endTime);
+            configItemSendTimeDTO.setUpdateTime(new Date());
+            updateRedisConfigItemSendTimeDTO(projectId, objIdAndAlarmItemCode, configItemSendTimeDTO);
+        }
+    }
+
+    private void updateRedisConfigItemSendTimeDTO(String projectId, String objIdAndAlarmItemCode, ConfigItemDataSendTimeDTO sendTimeDTO) {
+        redisUtil.set(getRedisSendDataKey(projectId, objIdAndAlarmItemCode), sendTimeDTO, SendDataTimeKeyTime);
+    }
+
+    private List<MonitorIndicatorRecord> getMonitorIndicatorRecordsGtLte(String projectId, String objId, Date lastSendTime, List<String> infoCodes, Date endTime) throws Exception {
+        MonitorIndicatorRecord monitorIndicatorRecord = new MonitorIndicatorRecord();
+        monitorIndicatorRecord.setProject(projectId);
+        monitorIndicatorRecord.setObjId(objId);
+//        monitorIndicatorRecord.setSplitTimeType(EnumTimeType.MIN15.getCode());
+        monitorIndicatorRecord.setSpecialOperation("monitorIndicatorId", SpecialOperator.$in, infoCodes);
+        monitorIndicatorRecord.setSpecialOperation("dataTime", SpecialOperator.$gte, lastSendTime);
+        monitorIndicatorRecord.setSpecialOperation("dataTime", SpecialOperator.$lt, endTime);
+
+        return coredao.query(monitorIndicatorRecord);
+    }
+
+    private Map<String, List<String>> getObjIdAlarmItemCodeAndInfoCodes(List<AlarmRuleDTO> projectAlarmRules) {
+        Map<String, List<String>> objIdAlarmItemCodeAndInfoCodes = new HashMap<>();
+        for (AlarmRuleDTO projectAlarmRule : projectAlarmRules) {
+            String alarmItemCode = projectAlarmRule.getAlarmItemCode();
+            List<String> objIds = projectAlarmRule.getObjIds();
+            List<String> infoCodes = projectAlarmRule.getInfoCodes();
+            for (String infoCode : infoCodes) {
+                for (String objId : objIds) {
+                    String key = objId + "_" + alarmItemCode;
+                    if (!objIdAlarmItemCodeAndInfoCodes.containsKey(key)) {
+                        objIdAlarmItemCodeAndInfoCodes.put(key, new ArrayList<String>());
+                    }
+                    objIdAlarmItemCodeAndInfoCodes.get(key).add(infoCode);
+                }
+            }
+        }
+        return objIdAlarmItemCodeAndInfoCodes;
+    }
+
+    private ConfigItemDataSendTimeDTO getConfigItemSendTimeDTO(String projectId, String objIdAndAlarmItemCode) throws Exception {
+        ConfigItemDataSendTimeDTO sendTimeDTO = (ConfigItemDataSendTimeDTO) redisUtil.get(getRedisSendDataKey(projectId, objIdAndAlarmItemCode));
+        if (sendTimeDTO == null) {
+            sendTimeDTO = ConfigItemDataSendTimeDTO.builder().lastSendTime(getDefultStartTime()).build();
+        }
+        return sendTimeDTO;
+    }
+
+    private Date getDefultStartTime() throws Exception {
+        Date lastComputeTime;
+        if (org.apache.commons.lang.StringUtils.isBlank(computePropertiesConfig.getDStartTime())) {
+            lastComputeTime = new Date();
+        } else {
+            lastComputeTime = com.persagy.apm.diagnose.utils.DateUtils.str2Date(computePropertiesConfig.getDStartTime(), com.persagy.apm.diagnose.utils.DateUtils.SDF_SECOND);
+        }
+        return lastComputeTime;
+    }
+
+    private String getRedisSendDataKey(String projectId, String objIdAndAlarmItemCode) {
+        return DiAgnoseConst.RedisConstants.PROJECT_ITEM_SEND_TIME + ":" + projectId + ":" + objIdAndAlarmItemCode;
+    }
 
     /**
      * 计算维保数据
@@ -339,7 +414,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
                     if (!CollectionUtils.isEmpty(calculateMethodDTOLists)){
                         for (List<CalculateMethodDTO> dtoList:calculateMethodDTOLists) {
                             for (CalculateMethodDTO dto:dtoList) {
-                                monitorIndicatorMap.put(dto.getMonitorIndicatorName(),dto);
+                                monitorIndicatorMap.put(dto.getMonitorIndicatorId(),dto);
                             }
                         }
                     }
@@ -458,7 +533,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
                     }
                     //构造实体对象
                     MonitorIndicatorRecord monitorIndicatorRecord = new MonitorIndicatorRecord();
-                    monitorIndicatorRecord.setMonitorIndicatorId(indicatorType.getCode());
+                    monitorIndicatorRecord.setMonitorIndicatorId(saveIndicatorType.getCode());
                     monitorIndicatorRecord.setDataTime(start);
                     monitorIndicatorRecord.setObjId(objId);
                     monitorIndicatorRecord.setProject(projectId);

+ 5 - 0
src/main/java/com/persagy/apm/diagnose/service/EnergyAlarmServiceImpl.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 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.utils.AlarmResultUtil;
@@ -198,6 +199,10 @@ public class EnergyAlarmServiceImpl {
         QueryAlarmConditionByObjDTO selDTO = new QueryAlarmConditionByObjDTO();
         selDTO.setObjId(objId);
         selDTO.setItemCode(itemCode);
+        selDTO.setProjectId(projectId);
+        selDTO.setGroupCode(systemCode);
+        selDTO.setPd("asdasdasda");
+        selDTO.setUserId("test");
         AlarmResult<JSONObject> result = alarmServiceClient.queryByObjAndItemCode(selDTO);
         return AlarmResultUtil.getRecords(result, AlarmCondition.class);
     }

+ 27 - 27
src/main/java/com/persagy/apm/diagnose/service/MaintenanceDataService.java

@@ -54,33 +54,33 @@ public class MaintenanceDataService {
         });
     }
 
-//    /**
-//     * 发送数据
-//     */
-//    public void sendMaintenanceData() throws Exception {
-//        //查询项目列表
-//        List<ProjectDTO> projectDTOList = saasWebServiceImpl.queryProjectDTOList(null);
-//        if (CollectionUtils.isEmpty(projectDTOList)) {
-//            return;
-//        }
-//        //获取当日日期
-//        Date todayDate = DateUtils.truncate(new Date(), Calendar.DATE);
-////        projectDataRecordService.sendMaintenanceData(todayDate,"Pj1101060001",null);
-//        List<Future<String>> futureList = new ArrayList<>();
-//        CountDownLatch latch = new CountDownLatch(projectDTOList.size());
-//        for (ProjectDTO projectDTO : projectDTOList) {
-//            futureList.add(projectDataRecordService.sendMaintenanceData(todayDate,projectDTO.getProjectId(),latch));
-//        }
-//        //等待所有任务执行完
-//        latch.await();
-//        futureList.forEach(future -> {
-//            try {
-//                log.info(future.get());
-//            } catch (Exception e) {
-//                log.error("发送指标数据错误:" + CommonUtils.getExceptionStackTrace(e));
-//            }
-//        });
-//    }
+    /**
+     * 发送数据
+     */
+    public void sendMaintenanceData() throws Exception {
+        //查询项目列表
+        List<ProjectDTO> projectDTOList = saasWebServiceImpl.queryProjectDTOList(null);
+        if (CollectionUtils.isEmpty(projectDTOList)) {
+            return;
+        }
+        //获取当日日期
+        Date todayDate = DateUtils.truncate(new Date(), Calendar.DATE);
+//        projectDataRecordService.sendMaintenanceData(todayDate,"Pj1101060001",null);
+        List<Future<String>> futureList = new ArrayList<>();
+        CountDownLatch latch = new CountDownLatch(projectDTOList.size());
+        for (ProjectDTO projectDTO : projectDTOList) {
+            futureList.add(projectDataRecordService.sendMaintenanceData(todayDate,projectDTO.getProjectId(),latch));
+        }
+        //等待所有任务执行完
+        latch.await();
+        futureList.forEach(future -> {
+            try {
+                log.info(future.get());
+            } catch (Exception e) {
+                log.error("发送指标数据错误:" + CommonUtils.getExceptionStackTrace(e));
+            }
+        });
+    }
 
     /**
      * 同步即将报废设备

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

@@ -1,6 +1,8 @@
 package com.persagy.apm.diagnose.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.persagy.apm.diagnose.maintenance.constant.EnumAlarmCategory;
+import com.persagy.apm.diagnose.maintenance.constant.EnumAlarmItem;
 import com.persagy.apm.energyalarmstarter.alarmdata.feign.AlarmUrlParam;
 import com.persagy.apm.energyalarmstarter.alarmengine.service.NettyAlarmService;
 import lombok.SneakyThrows;
@@ -56,12 +58,28 @@ public class NettyAlarmServiceImpl extends NettyAlarmService {
         JSONObject supplement = new JSONObject();
         if (!CollectionUtils.isEmpty(objectList)) {
             supplement.put("alarm_obj_name", objectList.get(0).get("localName"));
+            //TODO 维保
+            String category = alarmRecord.getString("category");
+            if (EnumAlarmCategory.EQWB.equals(category)){//报警分类
+//                supplement.put("classCode",object.getString("classCode"));//设备类型编码
+                supplement.put("specification",objectList.get(0).getString("specification"));//设备型号
+                supplement.put("equip_local_id",objectList.get(0).getString("localId"));//设备本地编码
+                supplement.put("equip_local_name",objectList.get(0).getString("localName"));//设备本地名称
+            }
         }
         return supplement;
     }
 
     @Override
     public String getAlarmRemark(AlarmUrlParam data, String objId, String itemCode) {
+        //维保
+        if (EnumAlarmItem.CondAbnormal.getCode().equals(itemCode)) {// 冷凝器异常
+            return "检查冷凝器脏堵情况,并酌情进行清洗。";
+        }else if (EnumAlarmItem.EvapAbnormal.getCode().equals(itemCode)){// 蒸发器异常
+            return "检查蒸发器脏堵情况,并酌情进行清洗。";
+        }else if (EnumAlarmItem.CoolTowerApproachTempAbnormal.getCode().equals(itemCode)){// 冷却塔逼近温度异常
+            return "检查冷却水加药装置运行是否正常;检查冷却塔填料破损和脏堵情况,并酌情安排维护或清洗。";
+        }
         return null;
     }
 

+ 14 - 12
src/main/java/com/persagy/apm/diagnose/service/dto/QueryAlarmConditionByObjDTO.java

@@ -1,23 +1,25 @@
 package com.persagy.apm.diagnose.service.dto;
 
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
-import javax.validation.constraints.NotBlank;
 
-/**
- * @author lixing
- * @version V1.0 2021-09-08 22:30:38
- */
 @Data
-@ApiModel(value = "根据设备id查询报警条件入参")
+@Builder(toBuilder=true)
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonInclude(JsonInclude.Include.NON_NULL)
 public class QueryAlarmConditionByObjDTO {
-    @ApiModelProperty(value = "设备id", required = true)
-    @NotBlank(message = "设备id不能为空")
     private String objId;
 
-    @ApiModelProperty(value = "报警类型编码", required = true)
-    @NotBlank(message = "报警类型编码不能为空")
     private String itemCode;
+
+    private String projectId;
+
+    private String groupCode;
+    private String userId;
+    private String pd;
 }

+ 32 - 32
src/main/java/com/persagy/apm/diagnose/service/schedule/SendMaintenanceData.java

@@ -1,32 +1,32 @@
-//package com.persagy.apm.diagnose.service.schedule;
-//
-//import com.persagy.apm.diagnose.service.MaintenanceDataService;
-//import lombok.extern.slf4j.Slf4j;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.beans.factory.annotation.Value;
-//import org.springframework.scheduling.annotation.Scheduled;
-//import org.springframework.stereotype.Service;
-//
-///**
-// * 发送 设备维保日维度数据
-// */
-//@Slf4j
-//@Service
-//public class SendMaintenanceData {
-//
-//    @Value("${send.maintenance.data.enable:false}")
-//    private boolean enable;
-//
-//    @Autowired
-//    private MaintenanceDataService maintenanceDataService;
-//
-//    @Scheduled(cron="${send.maintenance.data.cron:0 10 4 * * ?}")
-//    public void sendMaintenanceData() throws Exception {
-//        if (!enable) {
-//            //发送未开启
-//            return;
-//        }
-//        log.info("【发送设备维保日维度平均值数据线程】:发送数据开始.......");
-//        maintenanceDataService.sendMaintenanceData();
-//    }
-//}
+package com.persagy.apm.diagnose.service.schedule;
+
+import com.persagy.apm.diagnose.service.MaintenanceDataService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+/**
+ * 发送 设备维保日维度数据
+ */
+@Slf4j
+@Service
+public class SendMaintenanceData {
+
+    @Value("${send.maintenance.data.enable:false}")
+    private boolean enable;
+
+    @Autowired
+    private MaintenanceDataService maintenanceDataService;
+
+    @Scheduled(cron="${send.maintenance.data.cron:0 10 4 * * ?}")
+    public void sendMaintenanceData() throws Exception {
+        if (!enable) {
+            //发送未开启
+            return;
+        }
+        log.info("【发送设备维保日维度平均值数据线程】:发送数据开始.......");
+        maintenanceDataService.sendMaintenanceData();
+    }
+}