|
@@ -2,6 +2,7 @@ package com.persagy.apm.energyalarmstarter.alarmdata.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Sets;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.feign.DmpResult;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.feign.client.AlarmClient;
|
|
@@ -34,6 +35,22 @@ public class AlarmRecordServiceImpl {
|
|
|
AlarmClient alarmClient;
|
|
|
|
|
|
/**
|
|
|
+ * 查询报警记录条数
|
|
|
+ * @param queryAlarmRecordDTO 入参
|
|
|
+ * @return 报警记录列表
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public Integer queryCount(QueryAlarmRecordDTO queryAlarmRecordDTO) throws Exception {
|
|
|
+ QueryDTO<QueryAlarmRecordDTO> queryDTO = new QueryDTO<>();
|
|
|
+ queryDTO.setOnlyCount(true);
|
|
|
+ queryDTO.setCriteria(queryAlarmRecordDTO);
|
|
|
+
|
|
|
+ DmpResult<List<AlarmRecordItem>> dmpResult = query(queryDTO);
|
|
|
+ return dmpResult.getCount();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* 查询报警记录
|
|
|
* @param queryAlarmRecordDTO 入参
|
|
|
* @return 报警记录列表
|
|
@@ -42,11 +59,21 @@ public class AlarmRecordServiceImpl {
|
|
|
public DmpResult<List<AlarmRecordItem>> query(QueryAlarmRecordDTO queryAlarmRecordDTO) throws Exception {
|
|
|
QueryDTO<QueryAlarmRecordDTO> queryDTO = new QueryDTO<>();
|
|
|
queryDTO.setCriteria(queryAlarmRecordDTO);
|
|
|
+ return query(queryDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询报警记录
|
|
|
+ * @param queryDTO 入参
|
|
|
+ * @return 报警记录列表
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public DmpResult<List<AlarmRecordItem>> query(QueryDTO<QueryAlarmRecordDTO> queryDTO) throws Exception {
|
|
|
// 查询结果中带上忽略时间和处理结束时间
|
|
|
Set<String> withColumns = Sets.newHashSet("ignoreTime", "treatEndTime");
|
|
|
queryDTO.setWithColumns(withColumns);
|
|
|
JSONObject jsonObject = Obj2JSONObject.convert(queryDTO);
|
|
|
- DmpResult<JSONArray> result = alarmClient.queryAlarmRecord(queryAlarmRecordDTO.fetchParams(), jsonObject);
|
|
|
+ DmpResult<JSONArray> result = alarmClient.queryAlarmRecord(queryDTO.fetchParams(), jsonObject);
|
|
|
return DmpResultUtil.multiConvert(result, AlarmRecordItem.class);
|
|
|
}
|
|
|
|
|
@@ -86,17 +113,15 @@ public class AlarmRecordServiceImpl {
|
|
|
return DmpResultUtil.singleConvert(result, DmpBatchUpsertVO.class);
|
|
|
}
|
|
|
|
|
|
-// public static void main(String[] args) {
|
|
|
-// AddAlarmRecordDTO addAlarmRecordDTO = new AddAlarmRecordDTO();
|
|
|
-// JSONObject jsonObject = new JSONObject();
|
|
|
-// jsonObject.put("any", "sss");
|
|
|
-// addAlarmRecordDTO.setSupplement(jsonObject);
|
|
|
-// try {
|
|
|
-// JSONObject convert = Obj2JSONObject.convert(addAlarmRecordDTO);
|
|
|
-// System.out.println(convert);
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
+ public static void main(String[] args) {
|
|
|
+ QueryAlarmRecordDTO addAlarmRecordDTO = new QueryAlarmRecordDTO();
|
|
|
+ List<String> projectIds = Lists.newArrayList("1", "2", "3");
|
|
|
+ addAlarmRecordDTO.setProjectIds(projectIds);
|
|
|
+ try {
|
|
|
+ JSONObject convert = Obj2JSONObject.convert(addAlarmRecordDTO);
|
|
|
+ System.out.println(convert);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|