wangchenghong пре 3 година
родитељ
комит
5192c9c519

+ 57 - 0
AlarmDataStarter/src/main/java/com/persagy/apm/energyalarmstarter/alarmdata/model/dto/alarmconfig/UpdateAlarmConfigDTO.java

@@ -0,0 +1,57 @@
+package com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmconfig;
+
+import com.persagy.apm.energyalarmstarter.alarmdata.feign.AlarmUrlParam;
+import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.AlarmCondition;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * 创建报警定义dto
+ *
+ * @author lixing
+ * @version V1.0 2021/9/15 9:10 下午
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class UpdateAlarmConfigDTO extends AlarmUrlParam {
+    /**
+     * 报警对象id
+     */
+    private String objId;
+    /**
+     * 设备类编码
+     */
+    private String classCode;
+    /**
+     * 报警类型编码
+     */
+    private String itemCode;
+    /**
+     * 报警系统编码
+     */
+    private String category;
+    /**
+     * 报警等级
+     */
+    private String level;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 报警条件
+     */
+    private AlarmCondition condition;
+    /**
+     * 屏蔽状态 1-open、0- 屏蔽
+     */
+    private Integer open;
+    /**
+     * 是否自定义 1-自定义、0-自动生成
+     */
+    private Integer userDefined;
+}

+ 12 - 0
AlarmDataStarter/src/main/java/com/persagy/apm/energyalarmstarter/alarmdata/service/AlarmConfigServiceImpl.java

@@ -42,6 +42,12 @@ public class AlarmConfigServiceImpl {
         return DmpResultUtil.singleConvert(alarmConfig, DmpUpsertVO.class);
     }
 
+    public DmpResult<DmpUpsertVO> update(UpdateAlarmConfigDTO updateAlarmConfigDTO) throws Exception{
+        JSONObject jsonObject = Obj2JSONObject.convert(updateAlarmConfigDTO);
+        DmpResult<JSONObject> alarmConfig = alarmClient.updateAlarmConfig(updateAlarmConfigDTO.fetchParams(), jsonObject);
+        return DmpResultUtil.singleConvert(alarmConfig, DmpUpsertVO.class);
+    }
+
     /**
      * 查询报警条件
      *
@@ -72,6 +78,12 @@ public class AlarmConfigServiceImpl {
         return DmpResultUtil.multiConvert(result, AlarmConfigItem.class);
     }
 
+    public DmpResult<DmpUpsertVO> update(AddAlarmConfigDTO addAlarmConfigDTO) throws Exception{
+        JSONObject jsonObject = Obj2JSONObject.convert(addAlarmConfigDTO);
+        DmpResult<JSONObject> alarmConfig = alarmClient.createAlarmConfig(addAlarmConfigDTO.fetchParams(), jsonObject);
+        return DmpResultUtil.singleConvert(alarmConfig, DmpUpsertVO.class);
+    }
+
     public static void main(String[] args) throws Exception{
         AddAlarmConfigDTO addAlarmConfigDTO = new AddAlarmConfigDTO();
         addAlarmConfigDTO.setObjId("1");