|
@@ -1,6 +1,8 @@
|
|
package com.persagy.ibms.data.sdk.util;
|
|
package com.persagy.ibms.data.sdk.util;
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -82,6 +84,7 @@ public class RWDAlarmUtil {
|
|
}
|
|
}
|
|
|
|
|
|
public static synchronized int refresh() throws Exception {
|
|
public static synchronized int refresh() throws Exception {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
RepositoryContainer.RepositoryBase.alarmArray.set.clear();
|
|
RepositoryContainer.RepositoryBase.alarmArray.set.clear();
|
|
String[] objIds = RepositoryContainer.RepositoryBase.id2alarmList.keySet().toArray(new String[0]);
|
|
String[] objIds = RepositoryContainer.RepositoryBase.id2alarmList.keySet().toArray(new String[0]);
|
|
for (String objId : objIds) {
|
|
for (String objId : objIds) {
|
|
@@ -89,18 +92,59 @@ public class RWDAlarmUtil {
|
|
RepositoryContainer.RepositoryBase.id2alarmCount.get(objId).value_prim.value = 0;
|
|
RepositoryContainer.RepositoryBase.id2alarmCount.get(objId).value_prim.value = 0;
|
|
}
|
|
}
|
|
|
|
|
|
- String post_url = Constant.alarm_rest + "/alarm/queryAlarmList";
|
|
|
|
- JSONObject postParam = new JSONObject();
|
|
|
|
- postParam.put("userId", "systemId");
|
|
|
|
- postParam.put("groupCode", RepositoryContainer.RepositoryBase.groupCode);
|
|
|
|
- postParam.put("projectId", RepositoryContainer.RepositoryBase.projectId);
|
|
|
|
- JSONArray treatState = new JSONArray();
|
|
|
|
- treatState.add(1);
|
|
|
|
- treatState.add(2);
|
|
|
|
- postParam.put("treatState", treatState);
|
|
|
|
- String postResultString = HttpClientUtil.post(post_url, postParam.toJSONString());
|
|
|
|
- JSONObject postResult = JSON.parseObject(postResultString);
|
|
|
|
- JSONArray Content = (JSONArray) postResult.get("Content");
|
|
|
|
|
|
+ JSONArray Content;
|
|
|
|
+ if (Constant.alarm_rest_get) {
|
|
|
|
+ String get_url = Constant.alarm_rest + "/alarm-config/list?projectId=" + RepositoryContainer.RepositoryBase.projectId + "&groupCode="
|
|
|
|
+ + RepositoryContainer.RepositoryBase.groupCode;
|
|
|
|
+ String getResultString = HttpClientUtil.get(get_url, null);
|
|
|
|
+ JSONObject getResult = JSON.parseObject(getResultString);
|
|
|
|
+ Content = (JSONArray) getResult.get("Item");
|
|
|
|
+ // triggerInfo
|
|
|
|
+ // triggerTime
|
|
|
|
+ for (int i = 0; i < Content.size(); i++) {
|
|
|
|
+ JSONObject ContentItem = Content.getJSONObject(i);
|
|
|
|
+ if (ContentItem.containsKey("triggerInfo")) {
|
|
|
|
+ String triggerInfoString = ContentItem.getString("triggerInfo");
|
|
|
|
+ JSONObject triggerInfo = JSON.parseObject(triggerInfoString);
|
|
|
|
+ ContentItem.put("triggerInfo", triggerInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (ContentItem.containsKey("triggerTime")) {
|
|
|
|
+ String triggerTimeString = ContentItem.getString("triggerTime");
|
|
|
|
+ Date triggerTime = sdf.parse(triggerTimeString);
|
|
|
|
+ ContentItem.put("triggerTime", triggerTime.getTime());
|
|
|
|
+ }
|
|
|
|
+ if (ContentItem.containsKey("endTime")) {
|
|
|
|
+ String endTimeString = ContentItem.getString("endTime");
|
|
|
|
+ Date endTime = sdf.parse(endTimeString);
|
|
|
|
+ ContentItem.put("endTime", endTime.getTime());
|
|
|
|
+ }
|
|
|
|
+ if (ContentItem.containsKey("createTime")) {
|
|
|
|
+ String createTimeString = ContentItem.getString("createTime");
|
|
|
|
+ Date createTime = sdf.parse(createTimeString);
|
|
|
|
+ ContentItem.put("createTime", createTime.getTime());
|
|
|
|
+ }
|
|
|
|
+ if (ContentItem.containsKey("updateTime")) {
|
|
|
|
+ String updateTimeString = ContentItem.getString("updateTime");
|
|
|
|
+ Date updateTime = sdf.parse(updateTimeString);
|
|
|
|
+ ContentItem.put("updateTime", updateTime.getTime());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ String post_url = Constant.alarm_rest + "/alarm/queryAlarmList";
|
|
|
|
+ JSONObject postParam = new JSONObject();
|
|
|
|
+ postParam.put("userId", "systemId");
|
|
|
|
+ postParam.put("groupCode", RepositoryContainer.RepositoryBase.groupCode);
|
|
|
|
+ postParam.put("projectId", RepositoryContainer.RepositoryBase.projectId);
|
|
|
|
+ JSONArray treatState = new JSONArray();
|
|
|
|
+ treatState.add(1);
|
|
|
|
+ treatState.add(2);
|
|
|
|
+ postParam.put("treatState", treatState);
|
|
|
|
+ String postResultString = HttpClientUtil.post(post_url, postParam.toJSONString());
|
|
|
|
+ JSONObject postResult = JSON.parseObject(postResultString);
|
|
|
|
+ Content = (JSONArray) postResult.get("Content");
|
|
|
|
+ }
|
|
for (int i = 0; i < Content.size(); i++) {
|
|
for (int i = 0; i < Content.size(); i++) {
|
|
RWDAlarmUtil.ProcessAlarm(Content.getJSONObject(i));
|
|
RWDAlarmUtil.ProcessAlarm(Content.getJSONObject(i));
|
|
}
|
|
}
|