Kaynağa Gözat

设备维保和更换建议

miaolijing 3 yıl önce
ebeveyn
işleme
9455fd91a7
24 değiştirilmiş dosya ile 1921 ekleme ve 15 silme
  1. 6 5
      src/main/java/com/persagy/apm/diagnose/feign/client/AlarmServiceClient.java
  2. 21 0
      src/main/java/com/persagy/apm/diagnose/feign/client/SaasClient.java
  3. 59 0
      src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumAlarmCategory.java
  4. 48 0
      src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumAlarmItem.java
  5. 47 0
      src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumAlarmLevel.java
  6. 47 0
      src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumAlarmState.java
  7. 49 0
      src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumAlarmTreatState.java
  8. 49 0
      src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumCoolTowerPointNameType.java
  9. 53 0
      src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumCoolWaterPointNameType.java
  10. 67 0
      src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumMaintenanceIndicatorType.java
  11. 35 0
      src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumRunStatusType.java
  12. 33 0
      src/main/java/com/persagy/apm/diagnose/maintenance/model/dto/AlarmCondition.java
  13. 30 0
      src/main/java/com/persagy/apm/diagnose/maintenance/model/dto/CalculateMethodDTO.java
  14. 20 0
      src/main/java/com/persagy/apm/diagnose/maintenance/model/dto/Formula.java
  15. 18 0
      src/main/java/com/persagy/apm/diagnose/maintenance/service/IProjectDataRecordService.java
  16. 1024 0
      src/main/java/com/persagy/apm/diagnose/maintenance/service/impl/ProjectDataRecordServiceImpl.java
  17. 44 9
      src/main/java/com/persagy/apm/diagnose/service/EnergyAlarmServiceImpl.java
  18. 111 0
      src/main/java/com/persagy/apm/diagnose/service/MaintenanceDataService.java
  19. 59 0
      src/main/java/com/persagy/apm/diagnose/service/SaasService.java
  20. 5 1
      src/main/java/com/persagy/apm/diagnose/service/SaasWebServiceImpl.java
  21. 23 0
      src/main/java/com/persagy/apm/diagnose/service/dto/QueryAlarmConditionByObjDTO.java
  22. 33 0
      src/main/java/com/persagy/apm/diagnose/service/schedule/ComputeMaintenanceData.java
  23. 32 0
      src/main/java/com/persagy/apm/diagnose/service/schedule/SyncCheckGoingDestroyEquip.java
  24. 8 0
      src/main/java/com/persagy/apm/diagnose/utils/DmpResultUtil.java

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

@@ -2,10 +2,7 @@ package com.persagy.apm.diagnose.feign.client;
 
 import com.alibaba.fastjson.JSONObject;
 import com.persagy.apm.diagnose.feign.AlarmResult;
-import com.persagy.apm.diagnose.service.dto.AlarmRuleDTO;
-import com.persagy.apm.diagnose.service.dto.CalculateMethodDTO;
-import com.persagy.apm.diagnose.service.dto.MonitorIndicatorConfigByEquipDTO;
-import com.persagy.apm.diagnose.service.dto.MonitorIndicatorConfigDTO;
+import com.persagy.apm.diagnose.service.dto.*;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -15,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 @FeignClient(name = "energy-alarm-service")
 public interface AlarmServiceClient {
 
+
     @PostMapping("/projectAlarmRuleObjRels/query")
     AlarmResult<JSONObject> query(@RequestBody MonitorIndicatorConfigDTO queryMonitorIndicatorConfigDTO) throws Exception;
 
@@ -23,11 +21,14 @@ public interface AlarmServiceClient {
     AlarmResult<JSONObject> queryCalculateMethods(@RequestBody CalculateMethodDTO calculateMethodDTO) throws Exception;
 
 
-
     @PostMapping("/projectMonitorIndicatorConfigs/query_by_equip")
     AlarmResult<JSONObject> query_by_equip(@RequestBody MonitorIndicatorConfigByEquipDTO monitorIndicatorConfigByEquipDTO) throws Exception;
 
 
     @PostMapping("projectAlarmRules/query_with_indicators_objs")
     AlarmResult<JSONObject> queryProjectAlarmRules(@RequestBody AlarmRuleDTO alarmRuleDTO) throws Exception;
+
+
+    @PostMapping("/alarmConditions/query_by_obj_and_itemcode")
+    AlarmResult<JSONObject> queryByObjAndItemCode(@RequestBody QueryAlarmConditionByObjDTO queryAlarmConditionByObjDTO) throws Exception;
 }

+ 21 - 0
src/main/java/com/persagy/apm/diagnose/feign/client/SaasClient.java

@@ -0,0 +1,21 @@
+package com.persagy.apm.diagnose.feign.client;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.Map;
+
+/**
+ * SAAS服务
+ */
+//@FeignClient(name = "saas",url = "http://47.117.93.148")
+@FeignClient(name = "SAAS")
+public interface SaasClient {
+
+	/**
+	 * 获取 即将报废设备列表
+	 */
+	@PostMapping("/restEquipService/queryGoingDestroyEquipList")
+	String queryGoingDestroyEquipList(@RequestBody Map<String, Object> requestMap);
+}

+ 59 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumAlarmCategory.java

@@ -0,0 +1,59 @@
+package com.persagy.apm.diagnose.maintenance.constant;
+
+import com.alibaba.druid.util.StringUtils;
+
+/**
+ * 报警条目
+ */
+public enum EnumAlarmCategory {
+
+    EQWB("Eqwb", "设备维保报警"),
+    EQGH("Eqgh", "设备更换报警"),
+    EQ("Eq", "设备报警"),
+    SP("Sp", "空间报警"),
+    SY("Sy", "系统报警"),
+    SAFE("Safe", "安全报警"),
+    RUN("Run", "高效运行报警"),
+    ENV("Env", "环境报警"),
+    ENERGY("Energy", "能源报警"),
+    TENANT("Tenant", "租户报警"),
+    ELECTRIC("Electric", "配电报警"),
+    CS("CS", "冷站能效报警"),
+    IOT("iot", "数据质量报警"),
+    BIM("Bim", "BIM报警"),
+    EQDX("Eqdx", "设备运行诊断报警");
+
+    private String code;
+    private String name;
+
+    EnumAlarmCategory(String code, String name){
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+    public String getName() {
+        return name;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public static EnumAlarmCategory getEnumAlarmLevel(String code) {
+        if(StringUtils.isEmpty(code)) {
+            return null;
+        }
+        for(EnumAlarmCategory item : EnumAlarmCategory.values()) {
+            if(item.getCode().equals(code)) {
+                return item;
+            }
+        }
+        return null;
+    }
+}

+ 48 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumAlarmItem.java

@@ -0,0 +1,48 @@
+package com.persagy.apm.diagnose.maintenance.constant;
+
+import com.alibaba.druid.util.StringUtils;
+
+/**
+ * 报警条目
+ */
+public enum EnumAlarmItem {
+
+    EquipmentReplace("Eqgh001", "更换"),
+    CondAbnormal("Eqwb001", "冷凝器异常"),
+    EvapAbnormal("Eqwb002", "蒸发器异常"),
+    CoolTowerApproachTempAbnormal("Eqwb003", "冷却塔逼近温度异常");
+
+    private String code;
+    private String name;
+
+    EnumAlarmItem(String code, String name){
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+    public String getName() {
+        return name;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public static EnumAlarmItem getEnumAlarmLevel(String code) {
+        if(StringUtils.isEmpty(code)) {
+            return null;
+        }
+        for(EnumAlarmItem item : EnumAlarmItem.values()) {
+            if(item.getCode().equals(code)) {
+                return item;
+            }
+        }
+        return null;
+    }
+}

+ 47 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumAlarmLevel.java

@@ -0,0 +1,47 @@
+package com.persagy.apm.diagnose.maintenance.constant;
+
+import com.alibaba.druid.util.StringUtils;
+
+/**
+ * 报警状态
+ */
+public enum EnumAlarmLevel {
+
+    S("1", "高"),
+    A("2", "中"),
+    B("3", "低");
+
+    private String code;
+    private String name;
+
+    EnumAlarmLevel(String code, String name){
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+    public String getName() {
+        return name;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public static EnumAlarmLevel getEnumAlarmLevel(String code) {
+        if(StringUtils.isEmpty(code)) {
+            return null;
+        }
+        for(EnumAlarmLevel item : EnumAlarmLevel.values()) {
+            if(item.getCode().equals(code)) {
+                return item;
+            }
+        }
+        return null;
+    }
+}

+ 47 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumAlarmState.java

@@ -0,0 +1,47 @@
+package com.persagy.apm.diagnose.maintenance.constant;
+
+import com.alibaba.druid.util.StringUtils;
+
+/**
+ * 报警状态
+ */
+public enum EnumAlarmState {
+
+    UN_HANDLE(1, "未恢复"),
+    END(2, "已恢复"),
+    EXPIRE(3, "已过期");
+
+    private Integer code;
+    private String name;
+
+    EnumAlarmState(Integer code, String name){
+        this.code = code;
+        this.name = name;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+    public String getName() {
+        return name;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public static EnumAlarmState getEnumAlarmState(String code) {
+        if(StringUtils.isEmpty(code)) {
+            return null;
+        }
+        for(EnumAlarmState item : EnumAlarmState.values()) {
+            if(item.getCode().equals(code)) {
+                return item;
+            }
+        }
+        return null;
+    }
+}

+ 49 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumAlarmTreatState.java

@@ -0,0 +1,49 @@
+package com.persagy.apm.diagnose.maintenance.constant;
+
+import com.alibaba.druid.util.StringUtils;
+
+/**
+ * 报警状态
+ */
+public enum EnumAlarmTreatState {
+
+    UN_HANDLE(1, "未处理"),
+    HANDLING(2, "处理中"),
+    DONE(3, "处理完成"),
+    // 用于兼容子系统业务,后期会移除该状态
+    IGNORE(4, "已忽略");
+
+    private Integer code;
+    private String name;
+
+    EnumAlarmTreatState(Integer code, String name){
+        this.code = code;
+        this.name = name;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+    public String getName() {
+        return name;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public static EnumAlarmTreatState getEnumAlarmTreatState(String code) {
+        if(StringUtils.isEmpty(code)) {
+            return null;
+        }
+        for(EnumAlarmTreatState item : EnumAlarmTreatState.values()) {
+            if(item.getCode().equals(code)) {
+                return item;
+            }
+        }
+        return null;
+    }
+}

+ 49 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumCoolTowerPointNameType.java

@@ -0,0 +1,49 @@
+package com.persagy.apm.diagnose.maintenance.constant;
+
+import com.alibaba.druid.util.StringUtils;
+
+/**
+ * 维保 冷却塔设备类型编码集合
+ */
+public enum EnumCoolTowerPointNameType {
+
+    RunStatus("runStatus","运行状态"),
+//    CoolWaterMainReturnTemp("returnAirTemp","冷却水回水干管温度"),
+//    Twb("supplyAirTemp","室外湿球温度");
+    CoolWaterMainReturnTemp("coolWaterMainReturnTemp","冷却水回水干管温度"),
+    Twb("twb","室外湿球温度");
+
+    private String code;
+    private String name;
+
+    EnumCoolTowerPointNameType(String code, String name){
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+    public String getName() {
+        return name;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public static EnumCoolTowerPointNameType getEnumMaintenanceDataType(String code) {
+        if(StringUtils.isEmpty(code)) {
+            return null;
+        }
+        for(EnumCoolTowerPointNameType item : EnumCoolTowerPointNameType.values()) {
+            if(item.getCode().equals(code)) {
+                return item;
+            }
+        }
+        return null;
+    }
+}

+ 53 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumCoolWaterPointNameType.java

@@ -0,0 +1,53 @@
+package com.persagy.apm.diagnose.maintenance.constant;
+
+import com.alibaba.druid.util.StringUtils;
+
+/**
+ * 维保 冷水机组设备类型编码集合
+ */
+public enum EnumCoolWaterPointNameType {
+
+    RunStatus("runStatus","运行状态"),//1开启 0关闭
+//    CondTemp("returnAirTemp","冷凝温度"),
+//    CondWaterOutTemp("supplyAirTemp","冷凝器出口水温"),
+//    EvapTemp("supplyAirTemp","蒸发温度"),
+//    EvapWaterOutTemp("returnAirTemp","蒸发器出口水温");
+    CondTemp("condTemp","冷凝温度"),
+    CondWaterOutTemp("condWaterOutTemp","冷凝器出口水温"),
+    EvapTemp("evapTemp","蒸发温度"),
+    EvapWaterOutTemp("evapWaterOutTemp","蒸发器出口水温");
+
+    private String code;
+    private String name;
+
+    EnumCoolWaterPointNameType(String code,String name){
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+    public String getName() {
+        return name;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public static EnumCoolWaterPointNameType getEnumMaintenanceDataType(String code) {
+        if(StringUtils.isEmpty(code)) {
+            return null;
+        }
+        for(EnumCoolWaterPointNameType item : EnumCoolWaterPointNameType.values()) {
+            if(item.getCode().equals(code)) {
+                return item;
+            }
+        }
+        return null;
+    }
+}

+ 67 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumMaintenanceIndicatorType.java

@@ -0,0 +1,67 @@
+package com.persagy.apm.diagnose.maintenance.constant;
+
+import com.alibaba.druid.util.StringUtils;
+
+/**
+ * 维保 冷水机组设备类型编码集合
+ */
+public enum EnumMaintenanceIndicatorType {
+    //冷却塔
+    ACCCOT_DayAvg("ACCCOT_ApproachTempDayAvg","冷却塔换热端差日维度平均值"),
+    ACCCOT_ContinuousOperation("ACCCOT_ApproachTempContinuousOperation","冷却塔持续运行时间"),
+    //冷水机组
+    ACCCCC_CondHeatTransferDayAvg("ACCCCC_CondHeatTransferDayAvg","冷凝器换热端差日维度平均值阈值"),
+    ACCCCC_CondContinuousOperation("ACCCCC_CondContinuousOperation","冷凝器运行持续时间"),
+    ACCCCC_EvapHeatTransferDayAvg("ACCCCC_EvapHeatTransferDayAvg","蒸发器换热端差日维度平均值阈值"),
+    ACCCCC_EvapContinuousOperation("ACCCCC_EvapContinuousOperation","蒸发器运行持续时间"),
+
+
+    ACCCSC_CondHeatTransferDayAvg("ACCCSC_CondHeatTransferDayAvg","冷凝器换热端差日维度平均值阈值"),
+    ACCCSC_CondContinuousOperation("ACCCSC_CondContinuousOperation","冷凝器运行持续时间"),
+    ACCCSC_EvapHeatTransferDayAvg("ACCCSC_EvapHeatTransferDayAvg","蒸发器换热端差日维度平均值阈值"),
+    ACCCSC_EvapContinuousOperation("ACCCSC_EvapContinuousOperation","蒸发器运行持续时间"),
+
+    ACCCPC_CondHeatTransferDayAvg("ACCCPC_CondHeatTransferDayAvg","冷凝器换热端差日维度平均值阈值"),
+    ACCCPC_CondContinuousOperation("ACCCPC_CondContinuousOperation","冷凝器运行持续时间"),
+    ACCCPC_EvapHeatTransferDayAvg("ACCCPC_EvapHeatTransferDayAvg","蒸发器换热端差日维度平均值阈值"),
+    ACCCPC_EvapContinuousOperation("ACCCPC_EvapContinuousOperation","蒸发器运行持续时间"),
+
+    ACCCAC_CondHeatTransferDayAvg("ACCCAC_CondHeatTransferDayAvg","冷凝器换热端差日维度平均值阈值"),
+    ACCCAC_CondContinuousOperation("ACCCAC_CondContinuousOperation","冷凝器运行持续时间"),
+    ACCCAC_EvapHeatTransferDayAvg("ACCCAC_EvapHeatTransferDayAvg","蒸发器换热端差日维度平均值阈值"),
+    ACCCAC_EvapContinuousOperation("ACCCAC_EvapContinuousOperation","蒸发器运行持续时间");
+
+    private String code;
+    private String name;
+
+    EnumMaintenanceIndicatorType(String code, String name){
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+    public String getName() {
+        return name;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public static EnumMaintenanceIndicatorType getEnumMaintenanceDataType(String code) {
+        if(StringUtils.isEmpty(code)) {
+            return null;
+        }
+        for(EnumMaintenanceIndicatorType item : EnumMaintenanceIndicatorType.values()) {
+            if(item.getCode().equals(code)) {
+                return item;
+            }
+        }
+        return null;
+    }
+}

+ 35 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/constant/EnumRunStatusType.java

@@ -0,0 +1,35 @@
+package com.persagy.apm.diagnose.maintenance.constant;
+
+/**
+ * 维保 运行状态
+ */
+public enum EnumRunStatusType {
+
+    Open(1.0),Close(0.0);
+
+    private Double code;
+
+    EnumRunStatusType(Double code){
+        this.code = code;
+    }
+
+    public Double getCode() {
+        return code;
+    }
+
+    public void setCode(Double code) {
+        this.code = code;
+    }
+
+    public static EnumRunStatusType getEnumMaintenanceDataType(Double code) {
+        if(null == code) {
+            return null;
+        }
+        for(EnumRunStatusType item : EnumRunStatusType.values()) {
+            if(item.getCode().equals(code)) {
+                return item;
+            }
+        }
+        return null;
+    }
+}

+ 33 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/model/dto/AlarmCondition.java

@@ -0,0 +1,33 @@
+package com.persagy.apm.diagnose.maintenance.model.dto;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.json.JSONObject;
+
+import java.util.List;
+
+/**
+ * 条件
+ */
+@Data
+@Builder(toBuilder = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class AlarmCondition {
+    private List<String> infoCodes;
+    private List<List<CalculateMethodDTO>> triggerFrontend;
+    private String triggerBackend;
+    private Integer triggerUphold;
+    private String alarmLevel;
+    private Integer endUphold;
+    private List<String> triggerRules;
+    private List<List<CalculateMethodDTO>> endFrontend;
+    private String endBackend;
+    private List<String> endRules;
+    private String effectTimeType;
+    private JSONObject effectTimeDetail;
+}

+ 30 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/model/dto/CalculateMethodDTO.java

@@ -0,0 +1,30 @@
+package com.persagy.apm.diagnose.maintenance.model.dto;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import java.util.List;
+
+/**
+ * 条件
+ */
+@Data
+@Builder(toBuilder = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CalculateMethodDTO {
+    private String operator;
+
+    private List<Formula> formula;
+
+    private String monitorIndicatorId;
+
+    private String monitorIndicatorName;
+
+    private Integer isDefault;
+
+    private String tempFormula;
+}

+ 20 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/model/dto/Formula.java

@@ -0,0 +1,20 @@
+package com.persagy.apm.diagnose.maintenance.model.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 报警条件(AlarmCondition)实体类
+ * @author lixing
+ * @version V1.0 2021-09-08 22:30:38
+ */
+@Data
+public class Formula implements Serializable {
+    private static final long serialVersionUID = 268657175929005281L;
+
+    private String key;
+    private String label;
+    private String value;
+
+}

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

@@ -0,0 +1,18 @@
+package com.persagy.apm.diagnose.maintenance.service;
+
+import java.util.Date;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Future;
+
+/**
+ * service接口 项目数据记录
+ */
+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> syncGoingDestroyEquip(String projectId, CountDownLatch latch) throws Exception;
+
+}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1024 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/service/impl/ProjectDataRecordServiceImpl.java


+ 44 - 9
src/main/java/com/persagy/apm/diagnose/service/EnergyAlarmServiceImpl.java

@@ -5,14 +5,12 @@ 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.model.dto.AlarmCondition;
 import com.persagy.apm.diagnose.service.dto.*;
 import com.persagy.apm.diagnose.utils.AlarmResultUtil;
-import com.persagy.apm.diagnose.utils.DmpResultUtil;
 import com.persagy.apm.diagnose.utils.RedisUtil;
-import com.persagy.apm.energyalarmstarter.alarmdata.feign.DmpResult;
-import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmconfig.QueryAlarmConfigDTO;
-import com.persagy.apm.energyalarmstarter.alarmdata.model.vo.AlarmConfigItem;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
@@ -30,6 +28,8 @@ import java.util.stream.Collectors;
 @Service
 public class EnergyAlarmServiceImpl {
 
+    @Value(value = "${energy.eq.run.system.code}")
+    private String systemCode;
     @Autowired
     AlarmServiceClient alarmServiceClient;
     @Autowired
@@ -47,7 +47,7 @@ public class EnergyAlarmServiceImpl {
     public List<MonitorIndicatorConfigDTO> queryMonitorIndicatorConfigDTOList(String projectId) throws Exception {
         MonitorIndicatorConfigDTO monitorIndicatorConfigDTO = MonitorIndicatorConfigDTO.builder().build();
         monitorIndicatorConfigDTO.setProjectId(projectId);
-        monitorIndicatorConfigDTO.setGroupCode("WD");
+        monitorIndicatorConfigDTO.setGroupCode(systemCode);
         monitorIndicatorConfigDTO.setPd("asdasdasda");
         monitorIndicatorConfigDTO.setUserId("test");
         AlarmResult<JSONObject> result = alarmServiceClient.query(monitorIndicatorConfigDTO);
@@ -64,7 +64,7 @@ public class EnergyAlarmServiceImpl {
      * @return: java.util.Map<java.lang.String, com.persagy.apm.diagnose.service.dto.CalculateMethodDTO>
      */
     public Map<String, CalculateMethodDTO> queryCalculateMethods() throws Exception {
-        AlarmResult<JSONObject> result = alarmServiceClient.queryCalculateMethods(CalculateMethodDTO.builder().groupCode("WD").userId("test").pd("asdasdasdasdadsdasdasdasdasdasd").build());
+        AlarmResult<JSONObject> result = alarmServiceClient.queryCalculateMethods(CalculateMethodDTO.builder().groupCode(systemCode).userId("test").pd("asdasdasdasdadsdasdasdasdasdasd").build());
         List<CalculateMethodDTO> records = AlarmResultUtil.getRecords(result, CalculateMethodDTO.class);
         return records.stream().collect(Collectors.toMap(CalculateMethodDTO::getId, Function.identity(), (key1, key2) -> key2));
     }
@@ -79,7 +79,7 @@ public class EnergyAlarmServiceImpl {
      * @updateTime 2021/9/27 11:54
      */
     public Map<String, String> queryObjId_indicatorAndMethodId(String projectId,String objId, List<String> indicatorIdList) throws Exception {
-        MonitorIndicatorConfigByEquipDTO build = MonitorIndicatorConfigByEquipDTO.builder().projectId(projectId).objId(objId).monitorIndicatorId(indicatorIdList).groupCode("WD").userId("test").pd("wwwwwwwwww").build();
+        MonitorIndicatorConfigByEquipDTO build = MonitorIndicatorConfigByEquipDTO.builder().projectId(projectId).objId(objId).monitorIndicatorId(indicatorIdList).groupCode(systemCode).userId("test").pd("wwwwwwwwww").build();
         AlarmResult<JSONObject> result = alarmServiceClient.query_by_equip(build);
         JSONObject content = result.getContent();
         if (content == null) {
@@ -125,7 +125,7 @@ public class EnergyAlarmServiceImpl {
      * @updateTime 2021/9/27 11:54
      */
     public String queryObjIndicatorMethodId(String projectId,String objId, String indicatorId) throws Exception {
-        MonitorIndicatorConfigByEquipDTO build = MonitorIndicatorConfigByEquipDTO.builder().projectId(projectId).objId(objId).monitorIndicatorId(Arrays.asList(indicatorId)).groupCode("WD").userId("test").pd("wwwwwwwwww").build();
+        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) {
@@ -160,10 +160,45 @@ public class EnergyAlarmServiceImpl {
     public List<AlarmRuleDTO> getProjectAlarmRules(String projectId) throws Exception {
         AlarmRuleDTO alarmRuleDTO = AlarmRuleDTO.builder().build();
         alarmRuleDTO.setProjectId(projectId);
-        alarmRuleDTO.setGroupCode("WD");
+        alarmRuleDTO.setGroupCode(systemCode);
         alarmRuleDTO.setPd("asdasdasda");
         alarmRuleDTO.setUserId("test");
         AlarmResult<JSONObject> result = alarmServiceClient.queryProjectAlarmRules(alarmRuleDTO);
         return AlarmResultUtil.getRecords(result, AlarmRuleDTO.class);
     }
+
+    /**
+     * @throws
+     * @title queryMonitorIndicatorConfigDTOList
+     * @description 查询监控指标配置
+     * @author leifeng
+     * @param: projectId
+     * @updateTime 2021/9/23 20:29
+     * @return: java.util.List<com.persagy.apm.diagnose.service.dto.MonitorIndicatorConfigDTO>
+     */
+    public List<AlarmRuleDTO> getProjectAlarmRules(String projectId,List<String> alarmItemCodeList) throws Exception {
+        List<AlarmRuleDTO> allAlarmRuleDTOList = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(alarmItemCodeList)){
+            for (String code:alarmItemCodeList) {
+                AlarmRuleDTO alarmRuleDTO = AlarmRuleDTO.builder().build();
+                alarmRuleDTO.setProjectId(projectId);
+                alarmRuleDTO.setGroupCode(systemCode);
+                alarmRuleDTO.setPd("asdasdasda");
+                alarmRuleDTO.setUserId("test");
+                alarmRuleDTO.setAlarmItemCode(code);
+                AlarmResult<JSONObject> result = alarmServiceClient.queryProjectAlarmRules(alarmRuleDTO);
+                List<AlarmRuleDTO> alarmRuleDTOList =  AlarmResultUtil.getRecords(result, AlarmRuleDTO.class);
+                allAlarmRuleDTOList.addAll(alarmRuleDTOList);
+            }
+        }
+        return allAlarmRuleDTOList;
+    }
+
+    public List<AlarmCondition> getProjectAlarmCondition(String projectId,String objId,String itemCode)throws Exception{
+        QueryAlarmConditionByObjDTO selDTO = new QueryAlarmConditionByObjDTO();
+        selDTO.setObjId(objId);
+        selDTO.setItemCode(itemCode);
+        AlarmResult<JSONObject> result = alarmServiceClient.queryByObjAndItemCode(selDTO);
+        return AlarmResultUtil.getRecords(result, AlarmCondition.class);
+    }
 }

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

@@ -0,0 +1,111 @@
+package com.persagy.apm.diagnose.service;
+
+import com.persagy.apm.diagnose.maintenance.service.IProjectDataRecordService;
+import com.persagy.apm.diagnose.service.dto.ProjectDTO;
+import com.persagy.apm.diagnose.utils.CommonUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.time.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Future;
+
+/**
+ * 设备维保数据 计算与发送
+ */
+@Slf4j
+@Service
+public class MaintenanceDataService {
+
+    @Autowired
+    private SaasWebServiceImpl saasWebServiceImpl;
+    @Autowired
+    private IProjectDataRecordService projectDataRecordService;
+
+    /**
+     * 计算 数据
+     */
+    public void computeMaintenanceData() throws Exception {
+
+        //查询项目列表
+        List<ProjectDTO> projectDTOList = saasWebServiceImpl.queryProjectDTOList(null);
+        if (CollectionUtils.isEmpty(projectDTOList)) {
+            return;
+        }
+        //获取当日日期
+        Date todayDate = DateUtils.truncate(new Date(), Calendar.DATE);
+//        projectDataRecordService.computeMaintenanceData(todayDate,"Pj1101060001", null);
+        List<Future<String>> futureList = new ArrayList<>();
+        CountDownLatch latch = new CountDownLatch(projectDTOList.size());
+        for (ProjectDTO projectDTO : projectDTOList) {
+            futureList.add(projectDataRecordService.computeMaintenanceData(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));
+//            }
+//        });
+//    }
+
+    /**
+     * 同步即将报废设备
+     */
+    public void syncCheckGoingDestroyEquip() throws Exception {
+//        projectDataRecordService.syncGoingDestroyEquip("Pj1101060001",null);
+        //查询项目列表
+        List<ProjectDTO> projectDTOList = saasWebServiceImpl.queryProjectDTOList(null);
+        if (CollectionUtils.isEmpty(projectDTOList)) {
+            return;
+        }
+        List<Future<String>> futureList = new ArrayList<>();
+        CountDownLatch latch = new CountDownLatch(projectDTOList.size());
+        for (ProjectDTO projectDTO : projectDTOList) {
+            futureList.add(projectDataRecordService.syncGoingDestroyEquip(projectDTO.getProjectId(),latch));
+        }
+        //等待所有任务执行完
+        latch.await();
+        futureList.forEach(future -> {
+            try {
+                log.info(future.get());
+            } catch (Exception e) {
+                log.error("同步检查即将报废设备错误:" + CommonUtils.getExceptionStackTrace(e));
+            }
+        });
+    }
+
+}

+ 59 - 0
src/main/java/com/persagy/apm/diagnose/service/SaasService.java

@@ -0,0 +1,59 @@
+package com.persagy.apm.diagnose.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.persagy.apm.diagnose.feign.client.SaasClient;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Service
+@Slf4j
+public class SaasService {
+
+    private final static String USERID = "systemId";
+    private static final String SUCCESS = "success";
+
+    @Autowired
+    private SaasClient saasClient;
+
+    public JSONArray getGoingDestroyEquipList(String projectId) throws Exception {
+        JSONArray resultArray = new JSONArray();
+        Map<String, Object> requestMap = new HashMap<>();
+        try {
+            requestMap.put("project_id", projectId);
+            requestMap.put("user_id", USERID);
+            String result = saasClient.queryGoingDestroyEquipList(requestMap);
+            resultArray = handleDataResult(result);
+        } catch (Exception e) {
+            log.error("获取类型对象列表数据错误,错误原因:" + e);
+            log.error("查询数据中台queryObject参数:" + requestMap);
+            throw e;
+        }
+        return resultArray;
+    }
+
+
+    private JSONArray handleDataResult(String result) throws Exception {
+        if (org.springframework.util.StringUtils.isEmpty(result)) {
+            throw new Exception("查询SAAS服务报错,无返回值");
+        }
+
+        JSONObject parseJsonObject = JSONObject.parseObject(result);
+        if (null != parseJsonObject && !parseJsonObject.isEmpty()
+                && SUCCESS.equals(parseJsonObject.getString("Result"))) {
+            if (parseJsonObject.getJSONArray("Content") != null) {
+                return parseJsonObject.getJSONArray("Content");
+            } else {
+                return new JSONArray();
+            }
+        } else {
+            throw new Exception("查询SAAS服务报错:");
+        }
+    }
+
+
+}

+ 5 - 1
src/main/java/com/persagy/apm/diagnose/service/SaasWebServiceImpl.java

@@ -6,6 +6,7 @@ import com.persagy.apm.diagnose.feign.client.SaasWebClient;
 import com.persagy.apm.diagnose.service.dto.ProjectDTO;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -25,6 +26,9 @@ public class SaasWebServiceImpl {
     private final static String LOGINDEVICE = "PC";
     public static final String DEFAULT_PD = "123456";
 
+    @Value(value = "${energy.eq.run.system.code}")
+    private String systemCode;
+
     @Autowired
     SaasWebClient saasWebClient;
 
@@ -43,7 +47,7 @@ public class SaasWebServiceImpl {
         puser.put("userId", USERID);
         puser.put("loginDevice", LOGINDEVICE);
         param.put("puser", puser);
-        param.put("groupCode","WD");
+        param.put("groupCode",systemCode);
         if (!CollectionUtils.isEmpty(projectIdList)) {
             param.put("projectIds", projectIdList);
         }

+ 23 - 0
src/main/java/com/persagy/apm/diagnose/service/dto/QueryAlarmConditionByObjDTO.java

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

+ 33 - 0
src/main/java/com/persagy/apm/diagnose/service/schedule/ComputeMaintenanceData.java

@@ -0,0 +1,33 @@
+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 ComputeMaintenanceData {
+
+    @Value("${compute.maintenance.data.enable:false}")
+    private boolean enable;
+
+    @Autowired
+    private MaintenanceDataService maintenanceDataService;
+
+    @Scheduled(cron="${compute.maintenance.data.cron:0 10 0 * * ?}")
+    public void computeMaintenanceData() throws Exception {
+        if (!enable) {
+            //计算未开启
+            return;
+        }
+        log.info("【计算设备维保日维度平均值数据线程】:计算数据开始.......");
+        maintenanceDataService.computeMaintenanceData();
+    }
+}

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

@@ -0,0 +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 SyncCheckGoingDestroyEquip {
+
+    @Value("${sync.check.going.destroy.equip.enable:false}")
+    private boolean enable;
+
+    @Autowired
+    private MaintenanceDataService maintenanceDataService;
+
+    @Scheduled(cron="${sync.check.going.destroy.equip.cron:0 10 0 * * ?}")
+    public void syncCheckGoingDestroyEquip() throws Exception {
+        if (!enable) {
+            //同步未开启
+            return;
+        }
+        log.info("【同步检查即将报废设备线程】:同步检查即将报废设备开始.......");
+        maintenanceDataService.syncCheckGoingDestroyEquip();
+    }
+}

+ 8 - 0
src/main/java/com/persagy/apm/diagnose/utils/DmpResultUtil.java

@@ -23,4 +23,12 @@ public class DmpResultUtil {
         }
         return configItem.getData();
     }
+
+    public static <T>  T getRecordData(DmpResult<T> recordItem) {
+        String result = recordItem.getResult();
+        if(StringUtil.isBlank(result)||!result.equals(DmpResult.SUCCESS)){
+            return  null;
+        }
+        return recordItem.getData();
+    }
 }