2 커밋 b33c125a2d ... f27c5d5a35

작성자 SHA1 메시지 날짜
  lirong f27c5d5a35 修改控制 2 년 전
  lirong a0cee8fb5e request获取token 2 년 전

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

@@ -104,10 +104,7 @@ public class ControlUtil {
             SceneDataObject currData = (SceneDataObject) valueObject;
             result = set(Repository, currData, infoValueSet, sdoList);
         }
-
         ControlUtil.saveBatchOperationLog(userId, userName,ipAddress,sdoList, infoValueSet, result, controlReason, Repository, request);
-        // ControlUtil.saveOperationLog(userId, userName, sdoList, infoValueSet, result);
-
         return result;
     }
 
@@ -201,18 +198,17 @@ public class ControlUtil {
             Date date = new Date();
             SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             String currentTime=dateFormat.format(date);
+            //控制中心保存指令
+            commandRecordParam.put("groupCode", RepositoryContainer.RepositoryProject.groupCode);
+            commandRecordParam.put("projectId", RepositoryContainer.RepositoryProject.projectId);
+            commandRecordParam.put("executeTime",currentTime);
+            commandRecordParam.put("commandType",2);
             for (int i = 0; i < sdoList.size(); i++) {
-                JSONObject postParam;
-                postParam = new JSONObject();
+                JSONObject postParam=new JSONObject();
                 JSONObject postParam2 = new JSONObject();
                 postParam.put("ipAddress", ipAddress);
                 postParam.put("groupCode", RepositoryContainer.RepositoryProject.groupCode);
                 postParam.put("projectId", RepositoryContainer.RepositoryProject.projectId);
-                //控制中心保存指令
-                commandRecordParam.put("groupCode", RepositoryContainer.RepositoryProject.groupCode);
-                commandRecordParam.put("projectId", RepositoryContainer.RepositoryProject.projectId);
-                commandRecordParam.put("executeTime",currentTime);
-                commandRecordParam.put("commandType",2);
                 if (userId != null) {
                     postParam.put("userId", userId);
                     commandRecordParam.put("userId", userId);
@@ -293,8 +289,7 @@ public class ControlUtil {
                             sb.append(",切换原因:" + controlReason + "");
                         }
                     }
-                    String id = (String) sdo.get("id").value_prim.value;
-                    JSONObject obj = Repository.id2object.get(id);
+                    JSONObject obj = Repository.id2object.get(objectId);
                     String objInfoValue = (String) obj.get(key);
                     if (objInfoValue != null && objInfoValue.length() > 0) {
                         int index_ = objInfoValue.lastIndexOf("-");
@@ -315,10 +310,8 @@ public class ControlUtil {
                             commandRecordParam.put("executeStatus",2);
                         }
                     }
-//                    if (i < sdoList.size() - 1) {
-//                        sb.append(",");
-//                    }
                 }
+                createCommandRecord(commandRecordParam);
                 for (int j = 1; j <= 2; j++) {
                     postParam2 = JSONObject.parseObject(postParam.toJSONString());
                     if (j == 1) {
@@ -331,8 +324,7 @@ public class ControlUtil {
                     postParamArray.add(postParam2);
                 }
             }
-            createCommandRecord(commandRecordParam);
-            saveBatchOperationLog(postParamArray);
+            saveBatchOperationLog(postParamArray,request);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
@@ -367,11 +359,9 @@ public class ControlUtil {
     }
 
     //批量保存日志
-    private static void saveBatchOperationLog(JSONArray postParam) throws Exception {
+    private static void saveBatchOperationLog(JSONArray postParam,HttpServletRequest request) throws Exception {
         String post_url = Constant.zkt_monitor_url + "/operatorLog/saveBatch";
-        System.out.println("保存日志url:" + post_url);
-        System.out.println("保存日志boby:" + postParam.toJSONString());
-        String post_result = HttpClientUtil.instance("zkt_monitor").post(post_url, postParam.toJSONString());
+        String post_result = HttpClientUtil.instance("zkt_monitor").post(post_url, postParam.toJSONString(),request);
         JSONObject result = JSON.parseObject(post_result);
         log.debug(result.toJSONString());
     }
@@ -379,8 +369,6 @@ public class ControlUtil {
     //控制中心保存控制命令
     private static void createCommandRecord(JSONObject postParam) throws Exception {
         String post_url = Constant.zkt_control_url + "/commandRecord/createCommandRecord";
-        System.out.println("保存控制指令url:" + post_url);
-        System.out.println("控制指令boby:" + postParam.toJSONString());
         String post_result = HttpClientUtil.instance("zkt_control").post(post_url, postParam.toJSONString());
         JSONObject result = JSON.parseObject(post_result);
         log.debug(result.toJSONString());

+ 4 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/HttpClientUtil.java

@@ -146,6 +146,10 @@ public class HttpClientUtil {
         String result = post(url, content, 300000, null, null, null);
         return result;
     }
+    public synchronized String post(String url, String content, HttpServletRequest request) throws Exception {
+        String result = post(url, content, 300000, null, null, request);
+        return result;
+    }
 
     public synchronized String post(String url, String content, HttpServletResponse response) throws Exception {
         String result = post(url, content, 300000, null, response, null);