From 39ceed7f60905297629a45978cc29b6fe8bd05d8 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期六, 20 七月 2019 17:52:33 +0800
Subject: [PATCH] 优化服务绑定功能

---
 java110-logAgent/src/main/java/com/java110/log/agent/LogAgent.java |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/java110-logAgent/src/main/java/com/java110/log/agent/LogAgent.java b/java110-logAgent/src/main/java/com/java110/log/agent/LogAgent.java
index d24fc31..a70bd5c 100644
--- a/java110-logAgent/src/main/java/com/java110/log/agent/LogAgent.java
+++ b/java110-logAgent/src/main/java/com/java110/log/agent/LogAgent.java
@@ -53,8 +53,8 @@
      * @param logStatus 鏃ュ織鐘舵��
      * @return
      */
-    public static boolean sendLog(DataFlow dataFlow,String requestMessage,String responseMessage,String logStatus){
-        return sendLog(dataFlow.reBuilder(requestMessage,responseMessage,logStatus));
+    public static boolean sendLog(DataFlow dataFlow,String requestMessage,String responseMessage,String logStatus,long costTime){
+        return sendLog(dataFlow.reBuilder(requestMessage,responseMessage,logStatus,costTime));
     }
 
     /**
@@ -68,7 +68,7 @@
      * @param responseMessage 杩斿洖鏁版嵁
      * @return
      */
-    public static boolean sendLog(DataFlow dataFlow, JSONObject requestMessage, JSONObject responseMessage){
+    public static boolean sendLog(DataFlow dataFlow, JSONObject requestMessage, JSONObject responseMessage,long costTime){
         Assert.hasKey(responseMessage,"body","杩斿洖鎶ユ枃涓嶆弧瓒� 鏃ュ織鍗忚瑕佹眰"+responseMessage.toJSONString());
 
         String body = responseMessage.getString("body");
@@ -77,26 +77,26 @@
         if(Assert.isJsonObject(body)){
             JSONObject bodyObj = JSONObject.parseObject(body);
 
-            Object codeNode = JSONPath.eval(body,"$.orders.response.code");
+            Object codeNode = JSONPath.eval(bodyObj,"$.orders.response.code");
             //鍒ゆ柇璁㈠崟鏄惁鎴愬姛
             if(codeNode != null && ResponseConstant.RESULT_CODE_SUCCESS.equals(codeNode.toString())){
                 //鍒ゆ柇涓氬姟鏄惁鍙楃悊鎴愬姛涓紝濡傛灉鏈変竴涓笟鍔″彈鐞嗗け璐ワ紝鍒欒涓哄け璐�
                 if(!bodyObj.containsKey("business")){
-                    return sendLog(dataFlow,requestMessage.toJSONString(),responseMessage.toJSONString(),LOG_STATUS_S);
+                    return sendLog(dataFlow,requestMessage.toJSONString(),responseMessage.toJSONString(),LOG_STATUS_S,costTime);
                 }
 
                 if(bodyObj.get("business") instanceof JSONObject){
                     JSONObject businessObj = bodyObj.getJSONObject("business");
                     if(businessObj.containsKey("response")&&
                             ResponseConstant.RESULT_CODE_SUCCESS.equals(businessObj.getJSONObject("response").getString("code"))){
-                        return sendLog(dataFlow,requestMessage.toJSONString(),responseMessage.toJSONString(),LOG_STATUS_S);
+                        return sendLog(dataFlow,requestMessage.toJSONString(),responseMessage.toJSONString(),LOG_STATUS_S,costTime);
                     }
                 }
 
                 if(bodyObj.get("business") instanceof JSONArray){
                     JSONArray businessArrays = bodyObj.getJSONArray("business");
                     if(businessArrays == null || businessArrays.size() == 0){
-                        return sendLog(dataFlow,requestMessage.toJSONString(),responseMessage.toJSONString(),LOG_STATUS_S);
+                        return sendLog(dataFlow,requestMessage.toJSONString(),responseMessage.toJSONString(),LOG_STATUS_S,costTime);
                     }
 
                     logStatus = LOG_STATUS_S;
@@ -116,7 +116,7 @@
         if(ResponseConstant.RESULT_CODE_SUCCESS.equals(body)){
             logStatus = LOG_STATUS_S;
         }
-        return sendLog(dataFlow,requestMessage.toJSONString(),responseMessage.toJSONString(),logStatus);
+        return sendLog(dataFlow,requestMessage.toJSONString(),responseMessage.toJSONString(),logStatus,costTime);
     }
 
 

--
Gitblit v1.8.0