|
@@ -0,0 +1,97 @@
|
|
|
+package com.persagy.ibms.data.sdk.service.rest;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
+import com.persagy.ibms.core.data.SceneDataSet;
|
|
|
+import com.persagy.ibms.core.util.LogUtil;
|
|
|
+import com.persagy.ibms.core.util.QueryAssist;
|
|
|
+import com.persagy.ibms.core.util.QueryUtil;
|
|
|
+import com.persagy.ibms.data.sdk.util.Constant;
|
|
|
+import com.persagy.ibms.data.sdk.util.HttpClientUtil;
|
|
|
+import com.persagy.ibms.data.sdk.util.RepositoryContainer;
|
|
|
+import com.persagy.ibms.data.sdk.util.RepositoryImpl;
|
|
|
+
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+public class LightingUtil {
|
|
|
+ public static String light_time_table(String param) {
|
|
|
+ RepositoryImpl Repository = RepositoryContainer.instance;
|
|
|
+
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ try {
|
|
|
+ JSONObject paramJSON = JSON.parseObject(param);
|
|
|
+ String logicalGroupId = paramJSON.getString("logicalGroupId");
|
|
|
+
|
|
|
+ String ibmsSceneCode;
|
|
|
+ String tabName;
|
|
|
+ {
|
|
|
+ JSONObject sql_json = new JSONObject();
|
|
|
+ sql_json.put("QueryType", "select");
|
|
|
+ JSONObject Target = new JSONObject();
|
|
|
+ Target.put("Source", "ibms-group");
|
|
|
+ sql_json.put("Target", Target);
|
|
|
+ JSONObject Criteria = new JSONObject();
|
|
|
+ sql_json.put("Criteria", Criteria);
|
|
|
+ SceneDataSet SceneDataSet = (SceneDataSet) QueryUtil.query(Repository, null, sql_json, new QueryAssist());
|
|
|
+ JSONArray queryResult = SceneDataSet.toJSON(1);
|
|
|
+ if (queryResult.size() == 0) {
|
|
|
+ result.put("Result", "failure");
|
|
|
+ result.put("ResultMsg", "编组不存在");
|
|
|
+ result.put("ResultCode", 250);
|
|
|
+ return JSONObject.toJSONString(result, SerializerFeature.WriteMapNullValue);
|
|
|
+ }
|
|
|
+ JSONObject item = (JSONObject) queryResult.get(0);
|
|
|
+ ibmsSceneCode = item.getString("ibmsSceneCode");
|
|
|
+ tabName = Constant.SceneCode2TabName.get(ibmsSceneCode);
|
|
|
+ if (tabName == null) {
|
|
|
+ result.put("Result", "failure");
|
|
|
+ result.put("ResultMsg", "SceneCode cant find tabName: " + ibmsSceneCode);
|
|
|
+ result.put("ResultCode", 250);
|
|
|
+ return JSONObject.toJSONString(result, SerializerFeature.WriteMapNullValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String modelId;
|
|
|
+ {
|
|
|
+ JSONObject sql_json = new JSONObject();
|
|
|
+ sql_json.put("QueryType", "select");
|
|
|
+ JSONObject Target = new JSONObject();
|
|
|
+ Target.put("Source", "ibms-calendar");
|
|
|
+ sql_json.put("Target", Target);
|
|
|
+ JSONObject Criteria = new JSONObject();
|
|
|
+ Criteria.put("tabName", tabName);
|
|
|
+ sql_json.put("Criteria", Criteria);
|
|
|
+ SceneDataSet SceneDataSet = (SceneDataSet) QueryUtil.query(Repository, null, sql_json, new QueryAssist());
|
|
|
+ JSONArray queryResult = SceneDataSet.toJSON(1);
|
|
|
+ if (queryResult.size() == 0) {
|
|
|
+ result.put("Result", "failure");
|
|
|
+ result.put("ResultMsg", tabName + " 没有绑定模式");
|
|
|
+ result.put("ResultCode", 250);
|
|
|
+ return JSONObject.toJSONString(result, SerializerFeature.WriteMapNullValue);
|
|
|
+ }
|
|
|
+ JSONObject item = (JSONObject) queryResult.get(0);
|
|
|
+ modelId = item.getString("modelId");
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject postBody = new JSONObject();
|
|
|
+ postBody.put("projectId", RepositoryContainer.RepositoryBase.projectId);
|
|
|
+ postBody.put("groupCode", RepositoryContainer.RepositoryBase.groupCode);
|
|
|
+ postBody.put("logicalGroupId", logicalGroupId);
|
|
|
+ postBody.put("modelId", modelId);
|
|
|
+
|
|
|
+ String url = Constant.zkt_control_url + "/control/lighting/console/query";
|
|
|
+ String postResult = HttpClientUtil.post(url, JSONObject.toJSONString(postBody, SerializerFeature.WriteMapNullValue));
|
|
|
+ return postResult;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取数据失败", e);
|
|
|
+ result.put("Result", "failure");
|
|
|
+ String message = LogUtil.GetExceptionStackTrace(e);
|
|
|
+ result.put("ResultMsg", message);
|
|
|
+ result.put("ResultCode", 250);
|
|
|
+ return JSONObject.toJSONString(result, SerializerFeature.WriteMapNullValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|