|
@@ -205,6 +205,9 @@ public class RWDAlarmUtil {
|
|
if (alarm.containsKey("level")) {
|
|
if (alarm.containsKey("level")) {
|
|
alarm.put("level_name", levelMap.get(alarm.get("level")));
|
|
alarm.put("level_name", levelMap.get(alarm.get("level")));
|
|
}
|
|
}
|
|
|
|
+ if (alarm.containsKey("objType")) {
|
|
|
|
+ alarm.put("category", alarm.get("objType"));
|
|
|
|
+ }
|
|
if (alarm.containsKey("category")) {
|
|
if (alarm.containsKey("category")) {
|
|
alarm.put("category_name", categoryMap.get(alarm.get("category")));
|
|
alarm.put("category_name", categoryMap.get(alarm.get("category")));
|
|
}
|
|
}
|
|
@@ -217,7 +220,11 @@ public class RWDAlarmUtil {
|
|
alarm.put("triggerTime", sdf.format(new Date(timeLong)));
|
|
alarm.put("triggerTime", sdf.format(new Date(timeLong)));
|
|
} else if (object instanceof String) {
|
|
} else if (object instanceof String) {
|
|
String timeString = (String) object;
|
|
String timeString = (String) object;
|
|
- alarm.put("triggerTime", sdf.format(sdf_.parse(timeString)));
|
|
|
|
|
|
+ try {
|
|
|
|
+ alarm.put("triggerTime", sdf.format(sdf_.parse(timeString)));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // e.printStackTrace();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -379,11 +386,17 @@ public class RWDAlarmUtil {
|
|
|
|
|
|
JSONArray Content;
|
|
JSONArray Content;
|
|
if (Constant.alarm_rest_get) {
|
|
if (Constant.alarm_rest_get) {
|
|
- String get_url = Constant.alarm_rest_url + "/alarm-record/list" + "?appId=" + "0" + "&userId=" + "systemId" + "&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");
|
|
|
|
|
|
+ Content = new JSONArray();
|
|
|
|
+ int[] treatState_array = { 1, 2 };
|
|
|
|
+ for (int treatState : treatState_array) {
|
|
|
|
+ String get_url = Constant.alarm_rest_url + "/alarm-record/page" + "?appId=" + "0" + "&userId=" + "systemId" + "&projectId="
|
|
|
|
+ + RepositoryContainer.RepositoryBase.projectId + "&groupCode=" + RepositoryContainer.RepositoryBase.groupCode
|
|
|
|
+ + "&size=65535¤t=1&treatState=" + treatState;
|
|
|
|
+ String getResultString = HttpClientUtil.get(get_url, null);
|
|
|
|
+ JSONObject getResult = JSON.parseObject(getResultString);
|
|
|
|
+ JSONArray ContentInner = (JSONArray) getResult.get("Content");
|
|
|
|
+ Content.addAll(ContentInner);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
String post_url = Constant.alarm_rest_url + "/alarm/queryAlarmList";
|
|
String post_url = Constant.alarm_rest_url + "/alarm/queryAlarmList";
|
|
JSONObject postParam = new JSONObject();
|
|
JSONObject postParam = new JSONObject();
|
|
@@ -411,6 +424,95 @@ public class RWDAlarmUtil {
|
|
return Content.size();
|
|
return Content.size();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static String handleAlarm(String param) {
|
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
|
+ try {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
+ Date currTime = new Date();
|
|
|
|
+ JSONObject paramJSON = JSON.parseObject(param);
|
|
|
|
+ if (Constant.alarm_rest_get) {
|
|
|
|
+ {
|
|
|
|
+ JSONObject handleJSON = new JSONObject();
|
|
|
|
+ handleJSON.put("id", paramJSON.get("id"));
|
|
|
|
+ handleJSON.put("treatMode", paramJSON.get("treatMode"));
|
|
|
|
+ handleJSON.put("treatState", paramJSON.get("treatState"));
|
|
|
|
+ String post_result = HttpClientUtil.put(Constant.alarm_rest_url + "/alarm-record/handleAlarm", handleJSON.toJSONString());
|
|
|
|
+ result = JSON.parseObject(post_result);
|
|
|
|
+ }
|
|
|
|
+ if (paramJSON.containsKey("comment") && paramJSON.containsKey("userId")) {
|
|
|
|
+ JSONObject commentJSON = new JSONObject();
|
|
|
|
+ JSONObject dtoJSON = new JSONObject();
|
|
|
|
+ dtoJSON.put("userId", paramJSON.get("userId"));
|
|
|
|
+ dtoJSON.put("content", paramJSON.get("comment"));
|
|
|
|
+ dtoJSON.put("commentTime", sdf.format(currTime));
|
|
|
|
+ commentJSON.put("id", paramJSON.get("id"));
|
|
|
|
+ commentJSON.put("alarmRecordCommentDto", dtoJSON);
|
|
|
|
+ HttpClientUtil.put(Constant.alarm_rest_url + "/alarm-record/updateComment", commentJSON.toJSONString());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // TODO
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ String message = LogUtil.GetExceptionStackTrace(e);
|
|
|
|
+ log.error(message);
|
|
|
|
+ result.put("Result", "failure");
|
|
|
|
+ result.put("ResultCode", -1);
|
|
|
|
+ result.put("ResultMsg", message);
|
|
|
|
+ }
|
|
|
|
+ return result.toJSONString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static String alarmToWorkOrder(String param) {
|
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
|
+ try {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
+ Date currTime = new Date();
|
|
|
|
+ JSONObject paramJSON = JSON.parseObject(param);
|
|
|
|
+ if (Constant.alarm_rest_get) {
|
|
|
|
+ {
|
|
|
|
+ JSONObject handleJSON = new JSONObject();
|
|
|
|
+ handleJSON.put("groupCode", RepositoryContainer.RepositoryBase.groupCode);
|
|
|
|
+ handleJSON.put("projectId", RepositoryContainer.RepositoryBase.projectId);
|
|
|
|
+ handleJSON.put("appId", "systemId");
|
|
|
|
+ handleJSON.put("userId", paramJSON.get("userId"));
|
|
|
|
+ handleJSON.put("id", paramJSON.get("id"));
|
|
|
|
+ handleJSON.put("alarmDescribe", "null");
|
|
|
|
+ String post_result = HttpClientUtil.post(Constant.alarm_rest_url + "/alarmToWorkOrder/transfer", handleJSON.toJSONString());
|
|
|
|
+ result = JSON.parseObject(post_result);
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ JSONObject handleJSON = new JSONObject();
|
|
|
|
+ handleJSON.put("id", paramJSON.get("id"));
|
|
|
|
+ handleJSON.put("treatMode", 2);
|
|
|
|
+ handleJSON.put("treatState", 2);
|
|
|
|
+ String post_result = HttpClientUtil.put(Constant.alarm_rest_url + "/alarm-record/handleAlarm", handleJSON.toJSONString());
|
|
|
|
+ result = JSON.parseObject(post_result);
|
|
|
|
+ }
|
|
|
|
+ if (paramJSON.containsKey("comment") && paramJSON.containsKey("userId")) {
|
|
|
|
+ JSONObject commentJSON = new JSONObject();
|
|
|
|
+ JSONObject dtoJSON = new JSONObject();
|
|
|
|
+ dtoJSON.put("userId", paramJSON.get("userId"));
|
|
|
|
+ dtoJSON.put("content", paramJSON.get("comment"));
|
|
|
|
+ dtoJSON.put("commentTime", sdf.format(currTime));
|
|
|
|
+ commentJSON.put("id", paramJSON.get("id"));
|
|
|
|
+ commentJSON.put("alarmRecordCommentDto", dtoJSON);
|
|
|
|
+ HttpClientUtil.put(Constant.alarm_rest_url + "/alarm-record/updateComment", commentJSON.toJSONString());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // TODO
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ String message = LogUtil.GetExceptionStackTrace(e);
|
|
|
|
+ log.error(message);
|
|
|
|
+ result.put("Result", "failure");
|
|
|
|
+ result.put("ResultCode", -1);
|
|
|
|
+ result.put("ResultMsg", message);
|
|
|
|
+ }
|
|
|
|
+ return result.toJSONString();
|
|
|
|
+ }
|
|
|
|
+
|
|
// 获取时间差方法
|
|
// 获取时间差方法
|
|
public static String getTimeDiff(Date startDate, Date endDate) {
|
|
public static String getTimeDiff(Date startDate, Date endDate) {
|
|
long diffMS = endDate.getTime() - startDate.getTime();
|
|
long diffMS = endDate.getTime() - startDate.getTime();
|