|
@@ -23,6 +23,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
@Slf4j
|
|
|
public class RWDAlarmUtil {
|
|
|
|
|
|
+ public static JSONArray history_alarm_path = new JSONArray();
|
|
|
+
|
|
|
static Map<Integer, String> statusMap = new HashMap<Integer, String>();
|
|
|
static Map<Integer, String> treatStateMap = new HashMap<Integer, String>();
|
|
|
static Map<String, String> levelMap = new HashMap<String, String>();
|
|
@@ -43,6 +45,107 @@ public class RWDAlarmUtil {
|
|
|
categoryMap.put("Sp", "空间报警");
|
|
|
}
|
|
|
|
|
|
+ public static String post_filter_and_page(JSONObject paramObject) {
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ try {
|
|
|
+ JSONObject params = (JSONObject) paramObject.get("params");
|
|
|
+ JSONArray Content;
|
|
|
+ if (Constant.alarm_rest_get) {
|
|
|
+ String get_url = Constant.alarm_rest + "/alarm-config/page?projectId=" + RepositoryContainer.RepositoryBase.projectId + "&groupCode="
|
|
|
+ + RepositoryContainer.RepositoryBase.groupCode;
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ sb.append("&userId=" + "systemId");
|
|
|
+ sb.append("&searchCount=" + "true");
|
|
|
+ if (params.containsKey("报警级别")) {
|
|
|
+ sb.append("&level=" + params.get("报警级别"));
|
|
|
+ }
|
|
|
+ if (params.containsKey("报警处理状态")) {
|
|
|
+ sb.append("&treatState=" + params.get("报警处理状态"));
|
|
|
+ } else {
|
|
|
+ sb.append("&treatState=" + 3);
|
|
|
+ }
|
|
|
+ if (params.containsKey("报警类型")) {
|
|
|
+ sb.append("&itemName=" + params.get("报警类型"));
|
|
|
+ }
|
|
|
+ if (params.containsKey("是否重点关注")) {
|
|
|
+ sb.append("&concern=" + params.get("是否重点关注"));
|
|
|
+ }
|
|
|
+ if (params.containsKey("搜索关键字")) {
|
|
|
+ sb.append("&keyWord=" + params.get("搜索关键字"));
|
|
|
+ }
|
|
|
+ if (params.containsKey("page")) {
|
|
|
+ boolean page = params.getBoolean("page");
|
|
|
+ if (page) {
|
|
|
+ int pageSize = params.getInteger("pageSize");
|
|
|
+ int pageIndex = params.getInteger("pageIndex");
|
|
|
+ sb.append("&size=" + pageSize);
|
|
|
+ sb.append("&page=" + pageIndex + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String getResultString = HttpClientUtil.get(get_url, null);
|
|
|
+ JSONObject getResult = JSON.parseObject(getResultString);
|
|
|
+ JSONObject con = getResult.getJSONObject("content");
|
|
|
+ result.put("count", con.get("total"));
|
|
|
+ Content = con.getJSONArray("records");
|
|
|
+ } 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);
|
|
|
+ if (params.containsKey("报警级别")) {
|
|
|
+ postParam.put("level", params.get("报警级别"));
|
|
|
+ }
|
|
|
+ if (params.containsKey("报警处理状态")) {
|
|
|
+ postParam.put("treatState", params.get("报警处理状态"));
|
|
|
+ } else {
|
|
|
+ postParam.put("treatState", 3);
|
|
|
+ }
|
|
|
+ if (params.containsKey("报警类型")) {
|
|
|
+ postParam.put("itemName", params.get("报警类型"));
|
|
|
+ }
|
|
|
+ if (params.containsKey("是否重点关注")) {
|
|
|
+ postParam.put("concern", params.get("是否重点关注"));
|
|
|
+ }
|
|
|
+ if (params.containsKey("搜索关键字")) {
|
|
|
+ postParam.put("keyWord", params.get("搜索关键字"));
|
|
|
+ }
|
|
|
+ if (params.containsKey("page")) {
|
|
|
+ boolean page = params.getBoolean("page");
|
|
|
+ if (page) {
|
|
|
+ int pageSize = params.getInteger("pageSize");
|
|
|
+ int pageIndex = params.getInteger("pageIndex");
|
|
|
+ postParam.put("size", pageSize);
|
|
|
+ postParam.put("page", pageIndex + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String postResultString = HttpClientUtil.post(post_url, postParam.toJSONString());
|
|
|
+ JSONObject postResult = JSON.parseObject(postResultString);
|
|
|
+ Content = (JSONArray) postResult.get("Content");
|
|
|
+ result.put("count", postResult.get("Count"));
|
|
|
+ }
|
|
|
+ for (int i = 0; i < Content.size(); i++) {
|
|
|
+ JSONObject alarm = Content.getJSONObject(i);
|
|
|
+ try {
|
|
|
+ RWDAlarmUtil.modify_alarm(alarm);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(LogUtil.GetExceptionStackTrace(e));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("content", Content);
|
|
|
+
|
|
|
+ result.put("result", "success");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ String message = LogUtil.GetExceptionStackTrace(e);
|
|
|
+ log.error(message);
|
|
|
+ result.put("result", "failure");
|
|
|
+ }
|
|
|
+ return result.toJSONString();
|
|
|
+ }
|
|
|
+
|
|
|
public static void modify_alarm(JSONObject alarm) throws Exception {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
SimpleDateFormat sdf_ = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
@@ -177,12 +280,6 @@ public class RWDAlarmUtil {
|
|
|
String id = (String) alarm.get("id");
|
|
|
String objId = (String) alarm.get("objId");
|
|
|
String treatState = alarm.get("treatState").toString();
|
|
|
- try {
|
|
|
- modify_alarm(alarm);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.error(LogUtil.GetExceptionStackTrace(e));
|
|
|
- }
|
|
|
{
|
|
|
SceneDataValue alarmList = RepositoryContainer.RepositoryBase.id2alarmList.get(objId);
|
|
|
SceneDataValue alarmCount = RepositoryContainer.RepositoryBase.id2alarmCount.get(objId);
|
|
@@ -268,7 +365,14 @@ public class RWDAlarmUtil {
|
|
|
Content = (JSONArray) postResult.get("Content");
|
|
|
}
|
|
|
for (int i = 0; i < Content.size(); i++) {
|
|
|
- RWDAlarmUtil.ProcessAlarm(Content.getJSONObject(i));
|
|
|
+ JSONObject alarm = Content.getJSONObject(i);
|
|
|
+ try {
|
|
|
+ RWDAlarmUtil.modify_alarm(alarm);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(LogUtil.GetExceptionStackTrace(e));
|
|
|
+ }
|
|
|
+ RWDAlarmUtil.ProcessAlarm(alarm);
|
|
|
}
|
|
|
return Content.size();
|
|
|
}
|