|
@@ -315,7 +315,7 @@ public class RWDDownloadUtil {
|
|
|
log.debug("Download zkt physical world finish " + path);
|
|
|
|
|
|
{
|
|
|
- Map<String, Boolean> alarmTypeMap = new HashMap<String, Boolean>();
|
|
|
+ Map<String, String> alarmTypeMap = new HashMap<String, String>();
|
|
|
if (Constant.alarm_rest_get) {
|
|
|
for (int i = 0; i < classArray.size(); i++) {
|
|
|
JSONObject classItem = classArray.getJSONObject(i);
|
|
@@ -334,8 +334,9 @@ public class RWDDownloadUtil {
|
|
|
JSONArray Content = resultJSON.getJSONArray("Content");
|
|
|
for (int ii = 0; ii < Content.size(); ii++) {
|
|
|
JSONObject ContentItem = Content.getJSONObject(ii);
|
|
|
+ String itemCode = ContentItem.getString("itemCode");
|
|
|
String name = ContentItem.getString("name");
|
|
|
- alarmTypeMap.put(name, true);
|
|
|
+ alarmTypeMap.put(itemCode, name);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -349,8 +350,9 @@ public class RWDDownloadUtil {
|
|
|
JSONArray Content = resultJSON.getJSONArray("Content");
|
|
|
for (int ii = 0; ii < Content.size(); ii++) {
|
|
|
JSONObject ContentItem = Content.getJSONObject(ii);
|
|
|
+ String code = ContentItem.getString("code");
|
|
|
String name = ContentItem.getString("name");
|
|
|
- alarmTypeMap.put(name, true);
|
|
|
+ alarmTypeMap.put(code, name);
|
|
|
}
|
|
|
}
|
|
|
JSONArray alarmTypeArray = new JSONArray();
|
|
@@ -359,11 +361,59 @@ public class RWDDownloadUtil {
|
|
|
for (String key : alarmTypes) {
|
|
|
JSONObject item = new JSONObject();
|
|
|
item.put("code", key);
|
|
|
- item.put("name", key);
|
|
|
+ item.put("name", alarmTypeMap.get(key));
|
|
|
alarmTypeArray.add(item);
|
|
|
}
|
|
|
FileUtil.Save(path + Constant.getSeperator() + "alarmTypeArray.json", FastJsonUtil.toFormatString(alarmTypeArray));
|
|
|
}
|
|
|
+
|
|
|
+ {
|
|
|
+ JSONArray alarmConfigArray;
|
|
|
+ if (Constant.alarm_rest_get) {
|
|
|
+ alarmConfigArray = new JSONArray();
|
|
|
+ for (int i = 0; i < classArray.size(); i++) {
|
|
|
+ JSONObject classItem = classArray.getJSONObject(i);
|
|
|
+ String ibmsSceneCode = classItem.getString("ibmsSceneCode");
|
|
|
+ String ibmsClassCode = classItem.getString("ibmsClassCode");
|
|
|
+ String itemListResultString = HttpClientUtil
|
|
|
+ .get(Constant.alarm_rest + "alarm-config/itemList/" + ibmsSceneCode + "/" + ibmsClassCode, null);
|
|
|
+ JSONObject itemListResultJSON = JSON.parseObject(itemListResultString);
|
|
|
+ JSONArray itemListResultContent = itemListResultJSON.getJSONArray("Content");
|
|
|
+ for (int ii = 0; ii < itemListResultContent.size(); ii++) {
|
|
|
+ JSONObject itemAlarmType = itemListResultContent.getJSONObject(ii);
|
|
|
+ String itemId = itemAlarmType.getString("id");
|
|
|
+ String alarmDefineListString = HttpClientUtil
|
|
|
+ .get(Constant.alarm_rest + "alarm-config/configPage" + "?userId=systemId&appId=0" + "&projectId="
|
|
|
+ + RepositoryContainer.RepositoryBase.projectId + "&groupCode=" + RepositoryContainer.RepositoryBase.groupCode
|
|
|
+ + "&ibmsSceneCode=" + ibmsSceneCode + "&ibmsClassCode=" + ibmsClassCode + "&itemId=" + itemId, null);
|
|
|
+ JSONObject alarmDefineListJSON = JSON.parseObject(alarmDefineListString);
|
|
|
+ JSONArray alarmDefineListContent = alarmDefineListJSON.getJSONArray("Content");
|
|
|
+ for (int iii = 0; iii < alarmDefineListContent.size(); iii++) {
|
|
|
+ JSONObject alarmDefine = alarmDefineListContent.getJSONObject(iii);
|
|
|
+ if (alarmDefine.containsKey("condition")) {
|
|
|
+ Object condition = alarmDefine.get("condition");
|
|
|
+ if (condition != null && condition instanceof String) {
|
|
|
+ String conditionString = (String) condition;
|
|
|
+ JSONObject conditionJSON = JSON.parseObject(conditionString);
|
|
|
+ alarmDefine.put("condition", conditionJSON);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ alarmConfigArray.addAll(alarmDefineListContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("userId", "systemId");
|
|
|
+ param.put("appId", "datautils");
|
|
|
+ param.put("groupCode", RepositoryContainer.RepositoryBase.groupCode);
|
|
|
+ param.put("projectId", RepositoryContainer.RepositoryBase.projectId);
|
|
|
+ String post_result = HttpClientUtil.post(Constant.alarm_rest + "alarm/queryConfig", param.toJSONString());
|
|
|
+ JSONObject resultJSON = JSON.parseObject(post_result);
|
|
|
+ alarmConfigArray = resultJSON.getJSONArray("Content");
|
|
|
+ }
|
|
|
+ FileUtil.Save(path + Constant.getSeperator() + "zkt_alarm_config.json", FastJsonUtil.toFormatString(alarmConfigArray));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static boolean Process_ibms_physical_world() throws Exception {
|
|
@@ -515,88 +565,4 @@ public class RWDDownloadUtil {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public static void LoadZKTAlarmConfig(String path) throws Exception {
|
|
|
- FileUtil.deleteRecursive(new File(path));
|
|
|
- File root = new File(path);
|
|
|
- if (!root.exists()) {
|
|
|
- root.mkdir();
|
|
|
- }
|
|
|
- JSONArray alarmConfigArray = null;
|
|
|
- List<String> groupCodeList = new ArrayList<String>();
|
|
|
- groupCodeList.add(RepositoryContainer.RepositoryBase.groupCode);
|
|
|
- groupCodeList.add(RepositoryContainer.RepositoryBase.groupCode);
|
|
|
- groupCodeList.add("0");
|
|
|
- List<String> projectIdList = new ArrayList<String>();
|
|
|
- projectIdList.add(RepositoryContainer.RepositoryBase.projectId);
|
|
|
- projectIdList.add("0");
|
|
|
- projectIdList.add("0");
|
|
|
- for (int i = 0; i < groupCodeList.size(); i++) {
|
|
|
- String groupCode = groupCodeList.get(i);
|
|
|
- String projectId = projectIdList.get(i);
|
|
|
- JSONObject param = new JSONObject();
|
|
|
- param.put("userId", "systemId");
|
|
|
- param.put("appId", "datautils");
|
|
|
- param.put("groupCode", groupCode);
|
|
|
- param.put("projectId", projectId);
|
|
|
- String post_result = HttpClientUtil.post(Constant.alarm_rest + "alarm/queryConfig", param.toJSONString());
|
|
|
- JSONObject resultJSON = JSON.parseObject(post_result);
|
|
|
- alarmConfigArray = resultJSON.getJSONArray("Content");
|
|
|
- if (alarmConfigArray != null) {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (alarmConfigArray != null) {
|
|
|
- FileUtil.Save(path + Constant.getSeperator() + "zkt_alarm_config.json", FastJsonUtil.toFormatString(alarmConfigArray));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static boolean Process_zkt_alarm_config() throws Exception {
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
- String validPath = Constant.getLatestPath(Constant.zkt_alarm_config, true);
|
|
|
- // 存储临时文件
|
|
|
- File dir1;
|
|
|
- {
|
|
|
- String tmpPath = Constant.zkt_alarm_config + Constant.getSeperator() + "tmp1";
|
|
|
- dir1 = new File(tmpPath);
|
|
|
- RWDDownloadUtil.LoadZKTAlarmConfig(tmpPath);
|
|
|
- }
|
|
|
- File dir2;
|
|
|
- {
|
|
|
- String tmpPath = Constant.zkt_alarm_config + Constant.getSeperator() + "tmp2";
|
|
|
- dir2 = new File(tmpPath);
|
|
|
- RWDDownloadUtil.LoadZKTAlarmConfig(tmpPath);
|
|
|
- }
|
|
|
- // 检查一致性
|
|
|
- boolean compare = FileUtil.compareRecursive(dir1, dir2);
|
|
|
- log.debug("Compare tmp1" + (compare ? "==" : "!=") + "tmp2");
|
|
|
- boolean result;
|
|
|
- if (compare) {
|
|
|
- File valid = null;
|
|
|
- if (validPath != null) {
|
|
|
- valid = new File(validPath);
|
|
|
- }
|
|
|
- if (valid != null && valid.exists()) {
|
|
|
- boolean compare_valid = FileUtil.compareRecursive(valid, dir2);
|
|
|
- log.debug("Compare valid" + (compare_valid ? "==" : "!=") + "tmp2");
|
|
|
- if (compare_valid) {
|
|
|
- result = false;
|
|
|
- } else {
|
|
|
- // 移动tmp2
|
|
|
- Date currTime = new Date();
|
|
|
- dir2.renameTo(new File(Constant.zkt_alarm_config + Constant.getSeperator() + sdf.format(currTime)));
|
|
|
- result = true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 移动tmp2
|
|
|
- Date currTime = new Date();
|
|
|
- dir2.renameTo(new File(Constant.zkt_alarm_config + Constant.getSeperator() + sdf.format(currTime)));
|
|
|
- result = true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- result = false;
|
|
|
- }
|
|
|
- Clear(Constant.zkt_alarm_config, true);
|
|
|
- return result;
|
|
|
- }
|
|
|
}
|