Преглед изворни кода

1、保存系统运行日志
2、修复获取控制值

lirong пре 3 година
родитељ
комит
46a124eccb

+ 28 - 11
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/ControlUtil.java

@@ -47,7 +47,7 @@ public class ControlUtil {
 		Map<String, Boolean> all_info_code = new ConcurrentHashMap<String, Boolean>();
 		for (SceneDataObject object : sdoList) {
 			String id = (String) object.get("id").value_prim.value;
-			if (RepositoryContainer.RepositoryProject.ObjCtrlValueMap.contains(id)) {
+			if (RepositoryContainer.RepositoryProject.ObjCtrlValueMap.containsKey(id)) {
 				JSONObject infoValueSet = RepositoryContainer.RepositoryProject.ObjCtrlValueMap.get(id);
 				for (String info_code : infoValueSet.keySet()) {
 					all_info_code.putIfAbsent(info_code, true);
@@ -57,13 +57,13 @@ public class ControlUtil {
 		for (String info_code : all_info_code.keySet()) {
 			boolean all_exist = true;
 			boolean all_equal = true;
-			Object first_info_value = null;
+			Integer first_info_value = null;
 			for (SceneDataObject object : sdoList) {
 				if (!object.containsKey(info_code)) {
 					all_exist = false;
 					break;
 				}
-				Object info_value = object.get(info_code);
+				int info_value = (int) object.get(info_code).value_prim.value;
 				if (first_info_value == null) {
 					first_info_value = info_value;
 				} else {
@@ -190,8 +190,10 @@ public class ControlUtil {
 			String controlReason, RepositoryImpl Repository) {
 		try {
 			JSONArray postParamArray = new JSONArray();
-			JSONObject postParam = new JSONObject();
 			for (int i = 0; i < sdoList.size(); i++) {
+				JSONObject postParam;
+                 postParam = new JSONObject();
+				 JSONObject postParam2=new JSONObject();
 				postParam.put("groupCode", RepositoryContainer.RepositoryProject.groupCode);
 				postParam.put("projectId", RepositoryContainer.RepositoryProject.projectId);
 				if (userId == null || userId.length() == 0) {
@@ -204,18 +206,20 @@ public class ControlUtil {
 				} 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 localId = sdo.get("localId").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("localId", localId);
 					postParam.put("systemCode", systemCode);
+					postParam.put("systemName", belongSystem);
 					postParam.put("classCode", classCode);
 					postParam.put("functionType", "remoteControl");
 					StringBuffer sb = new StringBuffer();
@@ -236,8 +240,11 @@ public class ControlUtil {
 						}
 						sb.append("[" + infoName + "]" + "设为:" + "[" + infoValue + "]");
 						sb.append(";");
-						if (infoDef.get("code").value_prim.value.equals("manualAutoSet")) {
-							sb.append("原因:" + controlReason + ";");
+						if(!controlReason.isEmpty())
+						{
+							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);
@@ -258,10 +265,20 @@ public class ControlUtil {
 							}
 						}
 					}
-					postParam.put("operateDetail", "【" + belongSystem + "】:" + objName + "-" + sb.toString());
-					postParam.put("sourceType", 1);
-					postParamArray.add(postParam);
-				}
+					for (int j=1;j<=2;j++){
+						postParam2=JSONObject.parseObject(postParam.toJSONString());
+						if(j==1)
+						{
+							postParam2.put("operateDetail", "【" + belongSystem + "】:" + objName + "-" + sb.toString());
+							postParam2.put("sourceType", j);
+						}
+						else
+						{
+							postParam2.put("operateDetail", sb.toString());
+							postParam2.put("sourceType", j);
+						}
+						postParamArray.add(postParam2);
+					}
 			}
 			saveBatchOperationLog(postParamArray);
 		} catch (Exception e) {