|
@@ -1,5 +1,6 @@
|
|
package com.persagy.ibms.data.sdk.util;
|
|
package com.persagy.ibms.data.sdk.util;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -31,23 +32,23 @@ public class ControlUtil {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- public static JSONArray set(RepositoryImpl Repository, JSONArray path, JSONObject infoValueSet) throws Exception {
|
|
|
|
-
|
|
|
|
|
|
+ public static JSONArray set(String userId, String userName, RepositoryImpl Repository, JSONArray path, JSONObject infoValueSet) throws Exception {
|
|
JSONArray result;
|
|
JSONArray result;
|
|
Object valueObject = ComputeUtil.getValueObject(Repository, path);
|
|
Object valueObject = ComputeUtil.getValueObject(Repository, path);
|
|
|
|
+ List<SceneDataObject> sdoList = new ArrayList<SceneDataObject>();
|
|
if (valueObject instanceof SceneDataValue) {
|
|
if (valueObject instanceof SceneDataValue) {
|
|
SceneDataValue currData = (SceneDataValue) valueObject;
|
|
SceneDataValue currData = (SceneDataValue) valueObject;
|
|
if (currData.value_array != null) {
|
|
if (currData.value_array != null) {
|
|
SceneDataValue detail = currData.parentObjectData.get("详情");
|
|
SceneDataValue detail = currData.parentObjectData.get("详情");
|
|
- result = setInner(Repository, detail, currData.value_array.set, infoValueSet);
|
|
|
|
|
|
+ result = setInner(Repository, detail, currData.value_array.set, infoValueSet, sdoList);
|
|
} else if (currData.value_object != null) {
|
|
} else if (currData.value_object != null) {
|
|
- result = set(Repository, currData.value_object, infoValueSet);
|
|
|
|
|
|
+ result = set(Repository, currData.value_object, infoValueSet, sdoList);
|
|
} else {
|
|
} else {
|
|
throw new Exception();
|
|
throw new Exception();
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
SceneDataObject currData = (SceneDataObject) valueObject;
|
|
SceneDataObject currData = (SceneDataObject) valueObject;
|
|
- result = set(Repository, currData, infoValueSet);
|
|
|
|
|
|
+ result = set(Repository, currData, infoValueSet, sdoList);
|
|
}
|
|
}
|
|
|
|
|
|
boolean all_success = true;
|
|
boolean all_success = true;
|
|
@@ -63,37 +64,116 @@ public class ControlUtil {
|
|
if (all_success) {
|
|
if (all_success) {
|
|
setControlValue(path, infoValueSet);
|
|
setControlValue(path, infoValueSet);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ ControlUtil.saveOperationLog(userId, userName, sdoList, infoValueSet, result);
|
|
|
|
+
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- private static JSONArray set(RepositoryImpl Repository, SceneDataObject object, JSONObject infoValueSet) throws Exception {
|
|
|
|
|
|
+ public static void saveOperationLog(String userId, String userName, List<SceneDataObject> sdoList, JSONObject infoValueSet, JSONArray points) {
|
|
|
|
+ try {
|
|
|
|
+ JSONObject postParam = new JSONObject();
|
|
|
|
+ postParam.put("groupCode", RepositoryContainer.RepositoryProject.groupCode);
|
|
|
|
+ postParam.put("projectId", RepositoryContainer.RepositoryProject.projectId);
|
|
|
|
+ if (userId == null || userId.length() == 0) {
|
|
|
|
+ postParam.put("userId", "systemId");
|
|
|
|
+ } else {
|
|
|
|
+ postParam.put("userId", userId);
|
|
|
|
+ }
|
|
|
|
+ if (userName == null || userName.length() == 0) {
|
|
|
|
+ postParam.put("userName", "系统");
|
|
|
|
+ } else {
|
|
|
|
+ postParam.put("userName", userName);
|
|
|
|
+ }
|
|
|
|
+ if (sdoList.size() == 1) {
|
|
|
|
+ SceneDataObject sdo = sdoList.get(0);
|
|
|
|
+ postParam.put("objId", sdo.get("id").value_prim.value);
|
|
|
|
+ } else {
|
|
|
|
+ JSONArray objs = new JSONArray();
|
|
|
|
+ for (SceneDataObject sdo : sdoList) {
|
|
|
|
+ objs.add(sdo.get("id").value_prim.value);
|
|
|
|
+ }
|
|
|
|
+ postParam.put("objs", objs);
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ SceneDataObject sdo = sdoList.get(0);
|
|
|
|
+ Object objType = sdo.get("objType").value_prim.value;
|
|
|
|
+ Object objName = sdo.get("ibmsxianshimingcheng").value_prim.value;
|
|
|
|
+ Object systemCode = null;
|
|
|
|
+ Object classCode = sdo.get("classCode").value_prim.value;
|
|
|
|
+ Object belongSystem = sdo.get("所属场景").value_prim.value;
|
|
|
|
+
|
|
|
|
+ postParam.put("objType", objType);
|
|
|
|
+ postParam.put("objName", objName);
|
|
|
|
+ postParam.put("systemCode", systemCode);
|
|
|
|
+ postParam.put("classCode", classCode);
|
|
|
|
+ postParam.put("functionType", "remoteControl");
|
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
|
+ for (String key : infoValueSet.keySet()) {
|
|
|
|
+ Object infoValue = infoValueSet.get(key);
|
|
|
|
+ sb.append(key + "设为:" + infoValue);
|
|
|
|
+ sb.append(";");
|
|
|
|
+ }
|
|
|
|
+ JSONArray success_points = new JSONArray();
|
|
|
|
+ JSONArray failure_points = new JSONArray();
|
|
|
|
+ for (int i = 0; i < points.size(); i++) {
|
|
|
|
+ JSONObject point = points.getJSONObject(i);
|
|
|
|
+ String status = (String) point.get("status");
|
|
|
|
+ if (status.equals("finish:success")) {
|
|
|
|
+ success_points.add(point);
|
|
|
|
+ } else {
|
|
|
|
+ failure_points.add(point);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ sb.append("控制结果:"+points.size()+"个控制指令," + success_points.size() + "个成功," + failure_points.size() + "个失败");
|
|
|
|
+ postParam.put("operateDetail", "【" + belongSystem + "】:" + objName + "-" + sb.toString());
|
|
|
|
+ postParam.put("sourceType", 1);
|
|
|
|
+ }
|
|
|
|
+ saveOperationLog(postParam);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static void saveOperationLog(JSONObject postParam) throws Exception {
|
|
|
|
+ String post_url = Constant.zkt_control_url + "/operationLog/saveOperationLog";
|
|
|
|
+ String post_result = HttpClientUtil.post(post_url, postParam.toJSONString());
|
|
|
|
+ JSONObject result = JSON.parseObject(post_result);
|
|
|
|
+ log.debug(result.toJSONString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static JSONArray set(RepositoryImpl Repository, SceneDataObject object, JSONObject infoValueSet, List<SceneDataObject> sdoList)
|
|
|
|
+ throws Exception {
|
|
JSONArray result;
|
|
JSONArray result;
|
|
if (object.containsKey("清单")) {
|
|
if (object.containsKey("清单")) {
|
|
SceneDataValue list = object.get("清单");
|
|
SceneDataValue list = object.get("清单");
|
|
SceneDataValue detail = object.get("详情");
|
|
SceneDataValue detail = object.get("详情");
|
|
- result = setInner(Repository, detail, list.value_array.set, infoValueSet);
|
|
|
|
|
|
+ result = setInner(Repository, detail, list.value_array.set, infoValueSet, sdoList);
|
|
} else {
|
|
} else {
|
|
- result = setInner(Repository, object, infoValueSet);
|
|
|
|
|
|
+ result = setInner(Repository, object, infoValueSet, sdoList);
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- private static JSONArray setInner(RepositoryImpl Repository, SceneDataObject object, JSONObject infoValueSet) throws Exception {
|
|
|
|
|
|
+ private static JSONArray setInner(RepositoryImpl Repository, SceneDataObject object, JSONObject infoValueSet, List<SceneDataObject> sdoList)
|
|
|
|
+ throws Exception {
|
|
JSONArray points = new JSONArray();
|
|
JSONArray points = new JSONArray();
|
|
build_points(Repository, object, infoValueSet, points);
|
|
build_points(Repository, object, infoValueSet, points);
|
|
|
|
+ sdoList.add(object);
|
|
build_object(object, infoValueSet);
|
|
build_object(object, infoValueSet);
|
|
JSONArray result = post(points);
|
|
JSONArray result = post(points);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- private static JSONArray setInner(RepositoryImpl Repository, SceneDataValue detail, List<SceneDataObject> objectArray, JSONObject infoValueSet)
|
|
|
|
- throws Exception {
|
|
|
|
|
|
+ private static JSONArray setInner(RepositoryImpl Repository, SceneDataValue detail, List<SceneDataObject> objectArray, JSONObject infoValueSet,
|
|
|
|
+ List<SceneDataObject> sdoList) throws Exception {
|
|
if (detail != null) {
|
|
if (detail != null) {
|
|
build_object(detail.value_object, infoValueSet);
|
|
build_object(detail.value_object, infoValueSet);
|
|
}
|
|
}
|
|
JSONArray points = new JSONArray();
|
|
JSONArray points = new JSONArray();
|
|
for (SceneDataObject object : objectArray) {
|
|
for (SceneDataObject object : objectArray) {
|
|
build_points(Repository, (SceneDataObject) object, infoValueSet, points);
|
|
build_points(Repository, (SceneDataObject) object, infoValueSet, points);
|
|
|
|
+ sdoList.add(object);
|
|
build_object((SceneDataObject) object, infoValueSet);
|
|
build_object((SceneDataObject) object, infoValueSet);
|
|
}
|
|
}
|
|
JSONArray result = post(points);
|
|
JSONArray result = post(points);
|