|
@@ -58,6 +58,50 @@ public class RWDAlarmUtil {
|
|
|
categoryMap.put("Sp", "空间报警");
|
|
|
}
|
|
|
|
|
|
+ public static JSONObject get_alarm_detail(JSONObject paramObject) {
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ String alarmId = (String) paramObject.get("alarmId");
|
|
|
+ try {
|
|
|
+ if (Constant.alarm_rest_get) {
|
|
|
+ String get_url = Constant.alarm_rest_url + "/alarm-record/query";
|
|
|
+ String getResultString = HttpClientUtil.get(get_url + "/" + alarmId, null);
|
|
|
+ JSONObject getResult = JSON.parseObject(getResultString);
|
|
|
+ JSONObject Item = getResult.getJSONObject("Item");
|
|
|
+ modify_alarm(Item);
|
|
|
+ if (Item.containsKey("treatMode")) {
|
|
|
+ int treatMode = Item.getIntValue("treatMode");
|
|
|
+ if (treatMode == 2) {
|
|
|
+ JSONObject postParamInner = new JSONObject();
|
|
|
+ postParamInner.put("appId", "0");
|
|
|
+ postParamInner.put("userId", "systemId");
|
|
|
+ postParamInner.put("projectId", RepositoryContainer.RepositoryBase.projectId);
|
|
|
+ postParamInner.put("groupCode", RepositoryContainer.RepositoryBase.groupCode);
|
|
|
+ JSONArray ids = new JSONArray();
|
|
|
+ ids.add(alarmId);
|
|
|
+ postParamInner.put("ids", ids);
|
|
|
+ String post_url = Constant.alarm_rest_url + "/alarmToWorkOrder/queryOrderStateByAlarmIds";
|
|
|
+ String postResultString = HttpClientUtil.post(post_url, postParamInner.toJSONString());
|
|
|
+ JSONObject postResult = JSON.parseObject(postResultString);
|
|
|
+ JSONArray Content = (JSONArray) postResult.get("Content");
|
|
|
+ if (Content != null && Content.size() == 1) {
|
|
|
+ JSONObject ContentItem = Content.getJSONObject(0);
|
|
|
+ Item.put("orderStateDesc", ContentItem.get("orderStateDesc"));
|
|
|
+ Item.put("orderId", ContentItem.get("orderId"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("content", Item);
|
|
|
+ result.put("result", "success");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ String message = LogUtil.GetExceptionStackTrace(e);
|
|
|
+ log.error(message);
|
|
|
+ result.put("result", "failure");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public static JSONObject post_filter_and_page(JSONObject paramObject) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
try {
|
|
@@ -262,6 +306,22 @@ public class RWDAlarmUtil {
|
|
|
alarm.put("category_name", categoryMap.get(alarm.get("category")));
|
|
|
alarm.put("categoryName", categoryMap.get(alarm.get("category")));
|
|
|
}
|
|
|
+ Object commentObject = alarm.get("comment");
|
|
|
+ if (commentObject == null) {
|
|
|
+ alarm.put("comments", new JSONArray());
|
|
|
+ } else {
|
|
|
+ if (commentObject instanceof String) {
|
|
|
+ JSONArray comments = JSON.parseArray((String) commentObject);
|
|
|
+ for (int i = 0; i < comments.size(); i++) {
|
|
|
+ JSONObject one_comment = comments.getJSONObject(i);
|
|
|
+ String commentTime = one_comment.getString("commentTime");
|
|
|
+ if (commentTime != null) {
|
|
|
+ one_comment.put("commentTime", sdf.format(sdf_.parse(commentTime)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ alarm.put("comments", comments);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if (alarm.containsKey("triggerTime")) {
|
|
|
Object object = alarm.get("triggerTime");
|
|
@@ -364,6 +424,20 @@ public class RWDAlarmUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static synchronized void ProcessAlarm_comment(String id, JSONObject dtoJSON) {
|
|
|
+ SceneDataSet alarmList = RepositoryContainer.RepositoryBase.alarmArray;
|
|
|
+ for (int i = 0; i < alarmList.set.size(); i++) {
|
|
|
+ SceneDataObject sdoInner = (SceneDataObject) alarmList.set.get(i);
|
|
|
+ String idInner = (String) sdoInner.get("id").value_prim.value;
|
|
|
+ if (idInner.equals(id)) {
|
|
|
+ SceneDataValue sdvInner = sdoInner.get("comments");
|
|
|
+ JSONArray comments = (JSONArray) sdvInner.value_prim.value;
|
|
|
+ comments.add(dtoJSON);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static synchronized void ProcessAlarm(JSONObject alarm) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
Date currentTime = new Date();
|
|
@@ -427,10 +501,14 @@ public class RWDAlarmUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static synchronized void ProcessOrderDesc(String id, String orderStateDesc) {
|
|
|
+ public static synchronized void ProcessOrderDesc(String id, String orderId, String orderStateDesc) {
|
|
|
for (SceneDataObject sdo : RepositoryContainer.RepositoryBase.alarmArray.set) {
|
|
|
String idInner = (String) sdo.get("id").value_prim.value;
|
|
|
if (idInner.equals(id)) {
|
|
|
+ SceneDataValue orderIdInner = sdo.get("orderId");
|
|
|
+ if (orderIdInner != null) {
|
|
|
+ orderIdInner.value_prim.value = orderId;
|
|
|
+ }
|
|
|
SceneDataValue orderStateDescInner = sdo.get("orderStateDesc");
|
|
|
if (orderStateDescInner != null) {
|
|
|
orderStateDescInner.value_prim.value = orderStateDesc;
|
|
@@ -459,6 +537,38 @@ public class RWDAlarmUtil {
|
|
|
String getResultString = HttpClientUtil.get(get_url, null);
|
|
|
JSONObject getResult = JSON.parseObject(getResultString);
|
|
|
JSONArray ContentInner = (JSONArray) getResult.get("Content");
|
|
|
+ JSONArray ids = new JSONArray();
|
|
|
+ Map<String, JSONObject> alarmMap = new HashMap<String, JSONObject>();
|
|
|
+ for (int i = 0; i < ContentInner.size(); i++) {
|
|
|
+ JSONObject alarm = ContentInner.getJSONObject(i);
|
|
|
+ if (alarm.containsKey("treatMode")) {
|
|
|
+ String id = (String) alarm.get("id");
|
|
|
+ int treatMode = alarm.getIntValue("treatMode");
|
|
|
+ if (treatMode == 2) {
|
|
|
+ ids.add(id);
|
|
|
+ alarmMap.put(id, alarm);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ids.size() > 0) {
|
|
|
+ JSONObject postParamInner = new JSONObject();
|
|
|
+ postParamInner.put("appId", "0");
|
|
|
+ postParamInner.put("userId", "systemId");
|
|
|
+ postParamInner.put("projectId", RepositoryContainer.RepositoryBase.projectId);
|
|
|
+ postParamInner.put("groupCode", RepositoryContainer.RepositoryBase.groupCode);
|
|
|
+ postParamInner.put("ids", ids);
|
|
|
+ String post_url = Constant.alarm_rest_url + "/alarmToWorkOrder/queryOrderStateByAlarmIds";
|
|
|
+ String postResultString = HttpClientUtil.post(post_url, postParamInner.toJSONString());
|
|
|
+ JSONObject postResult = JSON.parseObject(postResultString);
|
|
|
+ JSONArray ContentOrderState = (JSONArray) postResult.get("Content");
|
|
|
+ for (int i = 0; i < ContentOrderState.size(); i++) {
|
|
|
+ JSONObject orderStateItem = ContentOrderState.getJSONObject(i);
|
|
|
+ String alarmId = (String) orderStateItem.get("alarmId");
|
|
|
+ JSONObject alarm = alarmMap.get(alarmId);
|
|
|
+ alarm.put("orderId", orderStateItem.get("orderId"));
|
|
|
+ alarm.put("orderStateDesc", orderStateItem.get("orderStateDesc"));
|
|
|
+ }
|
|
|
+ }
|
|
|
Content.addAll(ContentInner);
|
|
|
}
|
|
|
} else {
|
|
@@ -492,6 +602,7 @@ public class RWDAlarmUtil {
|
|
|
JSONObject result = new JSONObject();
|
|
|
try {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ SimpleDateFormat sdf_ = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
Date currTime = new Date();
|
|
|
JSONObject paramJSON = JSON.parseObject(param);
|
|
|
if (Constant.alarm_rest_get) {
|
|
@@ -519,6 +630,8 @@ public class RWDAlarmUtil {
|
|
|
commentJSON.put("id", paramJSON.get("id"));
|
|
|
commentJSON.put("alarmRecordCommentDto", dtoJSON);
|
|
|
HttpClientUtil.put(Constant.alarm_rest_url + "/alarm-record/updateComment", commentJSON.toJSONString());
|
|
|
+ dtoJSON.put("commentTime", sdf_.format(currTime));
|
|
|
+ ProcessAlarm_comment((String) paramJSON.get("id"), dtoJSON);
|
|
|
}
|
|
|
} else {
|
|
|
// TODO
|
|
@@ -538,6 +651,7 @@ public class RWDAlarmUtil {
|
|
|
JSONObject result = new JSONObject();
|
|
|
try {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ SimpleDateFormat sdf_ = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
Date currTime = new Date();
|
|
|
JSONObject paramJSON = JSON.parseObject(param);
|
|
|
if (Constant.alarm_rest_get) {
|
|
@@ -569,6 +683,9 @@ public class RWDAlarmUtil {
|
|
|
commentJSON.put("id", paramJSON.get("id"));
|
|
|
commentJSON.put("alarmRecordCommentDto", dtoJSON);
|
|
|
HttpClientUtil.put(Constant.alarm_rest_url + "/alarm-record/updateComment", commentJSON.toJSONString());
|
|
|
+
|
|
|
+ dtoJSON.put("commentTime", sdf_.format(currTime));
|
|
|
+ ProcessAlarm_comment((String) paramJSON.get("id"), dtoJSON);
|
|
|
}
|
|
|
} else {
|
|
|
// TODO
|