Browse Source

实时报警分类搞定

menglu 3 years ago
parent
commit
464a9a93e6

+ 44 - 37
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDAlarmUtil.java

@@ -118,6 +118,8 @@ public class RWDAlarmUtil {
 			JSONArray Content;
 			if (Constant.alarm_service_name.equalsIgnoreCase("ibms-alarm")) {
 				String get_url = Constant.alarm_url + "/alarm-record/page";
+				Content = new JSONArray();
+				int count = 0;
 				StringBuffer sb = new StringBuffer();
 				sb.append("?appId=" + "0" + "&userId=" + "systemId" + "&projectId=" + RepositoryContainer.RepositoryProject.projectId + "&groupCode="
 						+ RepositoryContainer.RepositoryProject.groupCode);
@@ -156,8 +158,10 @@ public class RWDAlarmUtil {
 
 				String getResultString = HttpClientUtil.get(get_url + sb.toString());
 				JSONObject getResult = JSON.parseObject(getResultString);
-				Content = getResult.getJSONArray("Content");
-				result.put("count", getResult.get("Count"));
+				JSONArray ContentInner = getResult.getJSONArray("Content");
+				Content.addAll(ContentInner);
+				count += getResult.getIntValue("Count");
+				result.put("count", count);
 			} else {
 				String post_url = Constant.alarm_url + "/alarm/queryAlarmList";
 				JSONObject postParam = new JSONObject();
@@ -633,45 +637,48 @@ public class RWDAlarmUtil {
 		JSONArray Content;
 		if (Constant.alarm_service_name.equalsIgnoreCase("ibms-alarm")) {
 			Content = new JSONArray();
-			String get_url = Constant.alarm_url + "/alarm-record/page" + "?appId=" + "0" + "&userId=" + "systemId" + "&projectId="
-					+ RepositoryContainer.RepositoryProject.projectId + "&groupCode=" + RepositoryContainer.RepositoryProject.groupCode
-					+ "&size=65535&current=1&dealType=0";
-			String getResultString = HttpClientUtil.get(get_url);
-			JSONObject getResult = JSON.parseObject(getResultString);
-			JSONArray ContentInner = (JSONArray) getResult.get("Content");
-			JSONArray ids = new JSONArray();
-			Map<String, JSONObject> alarmMap = new ConcurrentHashMap<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);
+			int[] statusArray = { 0, 1, 2 };
+			for (int status : statusArray) {
+				String get_url = Constant.alarm_url + "/alarm-record/page" + "?appId=" + "0" + "&userId=" + "systemId" + "&projectId="
+						+ RepositoryContainer.RepositoryProject.projectId + "&groupCode=" + RepositoryContainer.RepositoryProject.groupCode
+						+ "&size=65535&current=1&status=" + status;
+				String getResultString = HttpClientUtil.get(get_url);
+				JSONObject getResult = JSON.parseObject(getResultString);
+				JSONArray ContentInner = (JSONArray) getResult.get("Content");
+				JSONArray ids = new JSONArray();
+				Map<String, JSONObject> alarmMap = new ConcurrentHashMap<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.RepositoryProject.projectId);
-				postParamInner.put("groupCode", RepositoryContainer.RepositoryProject.groupCode);
-				postParamInner.put("ids", ids);
-				String post_url = Constant.alarm_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"));
+				if (ids.size() > 0) {
+					JSONObject postParamInner = new JSONObject();
+					postParamInner.put("appId", "0");
+					postParamInner.put("userId", "systemId");
+					postParamInner.put("projectId", RepositoryContainer.RepositoryProject.projectId);
+					postParamInner.put("groupCode", RepositoryContainer.RepositoryProject.groupCode);
+					postParamInner.put("ids", ids);
+					String post_url = Constant.alarm_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);
 			}
-			Content.addAll(ContentInner);
 		} else {
 			String post_url = Constant.alarm_url + "/alarm/queryAlarmList";
 			JSONObject postParam = new JSONObject();