|
@@ -32,7 +32,7 @@ public class ControlUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public static JSONArray set(String userId, String userName, RepositoryImpl Repository, JSONArray path, JSONObject infoValueSet) throws Exception {
|
|
|
+ public static JSONArray set(String userId, String userName, RepositoryImpl Repository, JSONArray path, JSONObject infoValueSet,String controlReason) throws Exception {
|
|
|
JSONArray result;
|
|
|
Object valueObject = ComputeUtil.getValueObject(Repository, path);
|
|
|
List<SceneDataObject> sdoList = new CopyOnWriteArrayList<SceneDataObject>();
|
|
@@ -65,7 +65,8 @@ public class ControlUtil {
|
|
|
setControlValue(path, infoValueSet);
|
|
|
}
|
|
|
|
|
|
- ControlUtil.saveOperationLog(userId, userName, sdoList, infoValueSet, result);
|
|
|
+ ControlUtil.saveBatchOperationLog(userId, userName, sdoList, infoValueSet, result,controlReason,Repository);
|
|
|
+// ControlUtil.saveOperationLog(userId, userName, sdoList, infoValueSet, result);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
@@ -149,6 +150,85 @@ public class ControlUtil {
|
|
|
log.error(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
+ public static void saveBatchOperationLog(String userId, String userName, List<SceneDataObject> sdoList, JSONObject infoValueSet, JSONArray points,String controlReason,RepositoryImpl Repository) {
|
|
|
+ try {
|
|
|
+ JSONArray postParamArray=new JSONArray();
|
|
|
+ JSONObject postParam = new JSONObject();
|
|
|
+ for (int i = 0; i < sdoList.size();i++) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ {
|
|
|
+ SceneDataObject sdo=sdoList.get(i);
|
|
|
+ postParam.put("objId", sdo.get("id").value_prim.value);
|
|
|
+ Object objType = sdo.get("objType").value_prim.value;
|
|
|
+ Object objName = sdo.get("ibmsxianshimingcheng").value_prim.value;
|
|
|
+ Object systemCode = null;
|
|
|
+ String classCode = (String) sdo.get("classCode").value_prim.value;
|
|
|
+ Object belongSystem = sdo.get("所属场景").value_prim.value;
|
|
|
+ List<SceneDataObject> infoList = RepositoryContainer.instance.infoArrayDic.get(classCode).set;
|
|
|
+ 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);
|
|
|
+ SceneDataObject infoDef = null;
|
|
|
+ for (SceneDataObject infoDefInner : infoList) {
|
|
|
+ String code = (String) infoDefInner.get("code").value_prim.value;
|
|
|
+ if (code.equals(key)) {
|
|
|
+ infoDef = infoDefInner;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String infoName = key;
|
|
|
+ if (infoDef != null) {
|
|
|
+ infoName = (String) infoDef.get("name").value_prim.value;
|
|
|
+ infoValue = ControlUtil.value2CanRead(infoDef, infoValue);
|
|
|
+ }
|
|
|
+ sb.append("[" + infoName + "]" + "设为:" + "[" + infoValue + "]");
|
|
|
+ sb.append(";");
|
|
|
+ if(infoDef.get("code").value_prim.value.equals("manualAutoSet"))
|
|
|
+ {
|
|
|
+ sb.append("原因:"+controlReason+";");
|
|
|
+ }
|
|
|
+ String id = (String) sdo.get("id").value_prim.value;
|
|
|
+ JSONObject obj = Repository.id2object.get(id);
|
|
|
+ String objInfoValue = (String) obj.get(key);
|
|
|
+ if (objInfoValue != null && objInfoValue.length() > 0) {
|
|
|
+ int index_ = objInfoValue.lastIndexOf("-");
|
|
|
+ String meter = objInfoValue.substring(0, index_);
|
|
|
+ int funcid = Integer.parseInt(objInfoValue.substring(index_ + 1));
|
|
|
+ JSONObject point= (JSONObject) points.stream().filter(x->JSONObject.parseObject(x.toString()).get("meter").equals(meter)&&JSONObject.parseObject(x.toString()).get("funcid").equals(funcid)).findFirst().get();
|
|
|
+ String status = (String) point.get("status");
|
|
|
+ if (status.equals("finish:success")) {
|
|
|
+ sb.append("控制结果:成功;");
|
|
|
+ } else {
|
|
|
+ sb.append("控制结果:失败;");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ postParam.put("operateDetail", "【" + belongSystem + "】:" + objName + "-" + sb.toString());
|
|
|
+ postParam.put("sourceType", 1);
|
|
|
+ postParamArray.add(postParam);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ saveBatchOperationLog(postParamArray);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public static Object value2CanRead(SceneDataObject infoDef, Object infoValue) {
|
|
|
if (infoDef.containsKey("dataSource")) {
|
|
@@ -176,6 +256,13 @@ public class ControlUtil {
|
|
|
log.debug(result.toJSONString());
|
|
|
}
|
|
|
|
|
|
+ private static void saveBatchOperationLog(JSONArray postParam) throws Exception {
|
|
|
+ String post_url = Constant.zkt_control_url + "/operationLog/saveBatchOperationLog";
|
|
|
+ String post_result = HttpClientUtil.instance("zkt_control").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;
|