|
@@ -3,11 +3,14 @@ package com.persagy.ibms.data.sdk.util;
|
|
|
import java.io.File;
|
|
|
import java.io.FileFilter;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.persagy.ibms.core.data.SceneDataObject;
|
|
@@ -810,4 +813,94 @@ public class RWDLoadUtil {
|
|
|
Repository.alarmConfigTrigger = alarmConfigTrigger;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public static void LoadCalendar(RepositoryImpl Repository) throws Exception {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(new Date());
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
+ String projectId = RepositoryContainer.RepositoryBase.projectId;
|
|
|
+ Map<String, String> modelMap = new HashMap<String, String>();
|
|
|
+ {
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("userId", "0");
|
|
|
+ param.put("appId", "0");
|
|
|
+ param.put("projectId", projectId);
|
|
|
+ String post_result = HttpClientUtil.post(Constant.zkt_control_url + "tab/model/query", param.toJSONString());
|
|
|
+ JSONObject resultJSON = JSON.parseObject(post_result);
|
|
|
+ JSONArray Content = (JSONArray) resultJSON.get("Content");
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ for (int i = 0; i < Content.size(); i++) {
|
|
|
+ JSONObject ContentItem = (JSONObject) Content.get(i);
|
|
|
+ int tabId = ContentItem.getInteger("tabId");
|
|
|
+ String tabName = ContentItem.getString("tabName");
|
|
|
+ JSONArray modelList = (JSONArray) ContentItem.get("modelList");
|
|
|
+ for (int ii = 0; ii < modelList.size(); ii++) {
|
|
|
+ JSONObject arrayItem = modelList.getJSONObject(ii);
|
|
|
+ arrayItem.put("tabId", tabId);
|
|
|
+ arrayItem.put("tabName", tabName);
|
|
|
+ array.add(arrayItem);
|
|
|
+ String modelId = arrayItem.getString("modelId");
|
|
|
+ String modelName = arrayItem.getString("modelName");
|
|
|
+ modelMap.put(modelId, modelName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Repository.IBMSCalendarModel.setRowChange(true);
|
|
|
+ Repository.IBMSCalendarModel.set = RWDUtil.array2SDOList(array);
|
|
|
+ }
|
|
|
+ {
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("userId", "0");
|
|
|
+ param.put("appId", "0");
|
|
|
+ param.put("projectId", projectId);
|
|
|
+ param.put("year", "" + year);
|
|
|
+ String post_result = HttpClientUtil.post(Constant.zkt_control_url + "calendar/binding/query", param.toJSONString());
|
|
|
+ JSONObject resultJSON = JSON.parseObject(post_result);
|
|
|
+ JSONObject Item = (JSONObject) resultJSON.get("Item");
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ for (Object value : Item.values()) {
|
|
|
+ JSONArray dayArray = (JSONArray) value;
|
|
|
+ for (int i = 0; i < dayArray.size(); i++) {
|
|
|
+ JSONObject dayItem = dayArray.getJSONObject(i);
|
|
|
+ String date = dayItem.getString("date");
|
|
|
+ JSONArray controlModel = dayItem.getJSONArray("controlModel");
|
|
|
+ for (int ii = 0; ii < controlModel.size(); ii++) {
|
|
|
+ JSONObject controlItem = controlModel.getJSONObject(ii);
|
|
|
+ controlItem.put("date", date);
|
|
|
+ String modelId = controlItem.getString("modelId");
|
|
|
+ controlItem.put("modelName", modelMap.get(modelId));
|
|
|
+ array.add(controlItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Repository.IBMSCalendarBinding.setRowChange(true);
|
|
|
+ Repository.IBMSCalendarBinding.set = RWDUtil.array2SDOList(array);
|
|
|
+ }
|
|
|
+
|
|
|
+ String validPath = Constant.getLatestPath(Constant.zkt_alarm_config, true);
|
|
|
+ {
|
|
|
+ JSONArray alarmConfigArray = FastJsonReaderUtil.Instance()
|
|
|
+ .ReadJSONArray(new File(validPath + Constant.getSeperator() + "zkt_alarm_config.json"));
|
|
|
+ {
|
|
|
+ SceneDataSet SceneDataSet = new SceneDataSet(false);
|
|
|
+ SceneDataSet.set = RWDUtil.array2SDOList(alarmConfigArray);
|
|
|
+ Repository.alarmConfigArray = SceneDataSet;
|
|
|
+ }
|
|
|
+ JSONArray alarmConfigTriggerArray = new JSONArray();
|
|
|
+ for (int i = 0; i < alarmConfigArray.size(); i++) {
|
|
|
+ JSONObject alarmConfigItem = (JSONObject) alarmConfigArray.get(i);
|
|
|
+ String objId = (String) alarmConfigItem.get("objId");
|
|
|
+ JSONObject condition = (JSONObject) alarmConfigItem.get("condition");
|
|
|
+ JSONObject configs = (JSONObject) condition.get("configs");
|
|
|
+ JSONArray trigger = (JSONArray) configs.get("trigger");
|
|
|
+ if (trigger != null) {
|
|
|
+ JSONObject item = (JSONObject) trigger.get(0);
|
|
|
+ item.put("objId", objId);
|
|
|
+ alarmConfigTriggerArray.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SceneDataSet alarmConfigTrigger = new SceneDataSet(false);
|
|
|
+ alarmConfigTrigger.set = RWDUtil.array2SDOList(alarmConfigTriggerArray);
|
|
|
+ Repository.alarmConfigTrigger = alarmConfigTrigger;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|