Procházet zdrojové kódy

日志中加入耗时字段,开始测试

wuxw7 před 7 roky
rodič
revize
12b3cd9bac

+ 29 - 20
CenterService/src/main/java/com/java110/center/smo/impl/CenterServiceSMOImpl.java

@@ -133,21 +133,19 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
                 //添加耗时
                 //添加耗时
                 //DataFlowFactory.addCostTime(dataFlow, "service", "业务处理总耗时", dataFlow.getStartDate(), dataFlow.getEndDate());
                 //DataFlowFactory.addCostTime(dataFlow, "service", "业务处理总耗时", dataFlow.getStartDate(), dataFlow.getEndDate());
 
 
-                //这里保存耗时,以及日志
-                saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestHeaders(),dataFlow.getReqJson().toJSONString()),
-                        LogAgent.createLogMessage(dataFlow.getResponseHeaders(),dataFlow.getResJson().toJSONString()));
+
 
 
                 //保存耗时
                 //保存耗时
                 //saveCostTimeLogMessage(dataFlow);
                 //saveCostTimeLogMessage(dataFlow);
                 //处理返回报文鉴权
                 //处理返回报文鉴权
                 AuthenticationFactory.putSign(dataFlow, responseJson);
                 AuthenticationFactory.putSign(dataFlow, responseJson);
+                saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestHeaders(),dataFlow.getReqJson().toJSONString()),
+                        LogAgent.createLogMessage(dataFlow.getResponseHeaders(),dataFlow.getResJson().toJSONString()),endDate.getTime()-dataFlow.getStartDate().getTime());
 
 
             }
             }
             resJson = encrypt(responseJson.toJSONString(),headers);
             resJson = encrypt(responseJson.toJSONString(),headers);
-            /*LogAgent.sendLog(dataFlow.reBuilder(dataFlow.getTransactionId(),
-                            LogAgent.LOG_TYPE_C,DataTransactionFactory.isSuccessBusiness(responseJson)?
-                            LogAgent.LOG_STATUS_S:LogAgent.LOG_STATUS_F,
-                    dataFlow.getRequestURL(),responseJson.toJSONString(),headers));*/
+            //这里保存耗时,以及日志
+
             return resJson;
             return resJson;
 
 
         }
         }
@@ -216,7 +214,7 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
 
 
                 //这里保存耗时,以及日志
                 //这里保存耗时,以及日志
                 saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestHeaders(),dataFlow.getReqJson().toJSONString()),
                 saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestHeaders(),dataFlow.getReqJson().toJSONString()),
-                        LogAgent.createLogMessage(dataFlow.getResponseHeaders(),dataFlow.getResJson().toJSONString()));
+                        LogAgent.createLogMessage(dataFlow.getResponseHeaders(),dataFlow.getResJson().toJSONString()),endDate.getTime()-dataFlow.getStartDate().getTime());
 
 
                 //保存耗时
                 //保存耗时
                 saveCostTimeLogMessage(dataFlow);
                 saveCostTimeLogMessage(dataFlow);
@@ -581,13 +579,15 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
         for(AppRoute appRoute :dataFlow.getAppRoutes()){
         for(AppRoute appRoute :dataFlow.getAppRoutes()){
             for(Map completedBusiness : completedBusinesses){
             for(Map completedBusiness : completedBusinesses){
                 if(completedBusiness.get("business_type_cd").equals(appRoute.getAppService().getBusinessTypeCd())){
                 if(completedBusiness.get("business_type_cd").equals(appRoute.getAppService().getBusinessTypeCd())){
+                    long startTime = DateUtil.getCurrentDate().getTime();
                     //发起撤单
                     //发起撤单
                     KafkaFactory.sendKafkaMessage(appRoute.getAppService().getMessageQueueName(),"",
                     KafkaFactory.sendKafkaMessage(appRoute.getAppService().getMessageQueueName(),"",
                             DataFlowFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness,appRoute.getAppService()).toJSONString());
                             DataFlowFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness,appRoute.getAppService()).toJSONString());
                     //saveLogMessage(DataFlowFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness,appRoute.getAppService()),null);
                     //saveLogMessage(DataFlowFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness,appRoute.getAppService()),null);
 
 
                     saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),DataFlowFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness,appRoute.getAppService()).toJSONString()),
                     saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),DataFlowFactory.getDeleteInstanceTableJson(dataFlow,completedBusiness,appRoute.getAppService()).toJSONString()),
-                            LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_SUCCESS));
+                            LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_SUCCESS),
+                            DateUtil.getCurrentDate().getTime() - startTime);
                 }
                 }
             }
             }
         }
         }
@@ -725,7 +725,8 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
         }finally{
         }finally{
             DataFlowFactory.addCostTime(dataFlow, "receiveBusinessSystemNotifyMessage", "接受业务系统通知消息耗时", startDate);
             DataFlowFactory.addCostTime(dataFlow, "receiveBusinessSystemNotifyMessage", "接受业务系统通知消息耗时", startDate);
             saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),dataFlow.getReqJson().toJSONString()),
             saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),dataFlow.getReqJson().toJSONString()),
-                    LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_SUCCESS));
+                    LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_SUCCESS),
+                    DateUtil.getCurrentDate().getTime() - dataFlow.getStartDate().getTime());
         }
         }
     }
     }
 
 
@@ -869,12 +870,14 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
      */
      */
     private void notifyBusinessSystemSuccessMessage(DataFlow dataFlow) throws Exception{
     private void notifyBusinessSystemSuccessMessage(DataFlow dataFlow) throws Exception{
 
 
+        long startTime = DateUtil.getCurrentDate().getTime();
         //拼装报文通知业务系统
         //拼装报文通知业务系统
         KafkaFactory.sendKafkaMessage(
         KafkaFactory.sendKafkaMessage(
                 DataFlowFactory.getService(dataFlow,dataFlow.getBusinesses().get(0).getServiceCode()).getMessageQueueName(),"",DataFlowFactory.getNotifyBusinessSuccessJson(dataFlow).toJSONString());
                 DataFlowFactory.getService(dataFlow,dataFlow.getBusinesses().get(0).getServiceCode()).getMessageQueueName(),"",DataFlowFactory.getNotifyBusinessSuccessJson(dataFlow).toJSONString());
 
 
         saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),DataFlowFactory.getNotifyBusinessSuccessJson(dataFlow).toJSONString()),
         saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),DataFlowFactory.getNotifyBusinessSuccessJson(dataFlow).toJSONString()),
-                LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_SUCCESS));
+                LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_SUCCESS),
+                DateUtil.getCurrentDate().getTime() - startTime);
     }
     }
 
 
     /**
     /**
@@ -883,13 +886,14 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
      * @param dataFlow
      * @param dataFlow
      */
      */
     private void notifyBusinessSystemErrorMessage(DataFlow dataFlow) throws Exception{
     private void notifyBusinessSystemErrorMessage(DataFlow dataFlow) throws Exception{
-
+        long startTime = DateUtil.getCurrentDate().getTime();
         //拼装报文通知业务系统
         //拼装报文通知业务系统
         KafkaFactory.sendKafkaMessage(
         KafkaFactory.sendKafkaMessage(
                 DataFlowFactory.getService(dataFlow,dataFlow.getBusinesses().get(0).getServiceCode()).getMessageQueueName(),"",
                 DataFlowFactory.getService(dataFlow,dataFlow.getBusinesses().get(0).getServiceCode()).getMessageQueueName(),"",
                 DataFlowFactory.getNotifyBusinessErrorJson(dataFlow).toJSONString());
                 DataFlowFactory.getNotifyBusinessErrorJson(dataFlow).toJSONString());
         saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),DataFlowFactory.getNotifyBusinessErrorJson(dataFlow).toJSONString()),
         saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),DataFlowFactory.getNotifyBusinessErrorJson(dataFlow).toJSONString()),
-                LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_ERROR));
+                LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),ResponseConstant.RESULT_CODE_ERROR),
+                DateUtil.getCurrentDate().getTime() - startTime);
     }
     }
 
 
     /**
     /**
@@ -982,7 +986,8 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
 
 
             DataFlowFactory.addCostTime(dataFlow, business.getServiceCode(), "调用"+business.getServiceName()+"-doComplete耗时", businessStartDate);
             DataFlowFactory.addCostTime(dataFlow, business.getServiceCode(), "调用"+business.getServiceName()+"-doComplete耗时", businessStartDate);
             saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()),
             saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()),
-                    LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()));
+                    LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()),
+                    DateUtil.getCurrentDate().getTime() - businessStartDate.getTime());
         }
         }
 
 
     }
     }
@@ -1012,7 +1017,8 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
             updateBusinessStatusCdByBId(business.getbId(),StatusConstant.STATUS_CD_COMPLETE);
             updateBusinessStatusCdByBId(business.getbId(),StatusConstant.STATUS_CD_COMPLETE);
             DataFlowFactory.addCostTime(dataFlow, business.getServiceCode(), "调用"+business.getServiceName()+"耗时", businessStartDate);
             DataFlowFactory.addCostTime(dataFlow, business.getServiceCode(), "调用"+business.getServiceName()+"耗时", businessStartDate);
             saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()),
             saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()),
-                    LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()));
+                    LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()),
+                    DateUtil.getCurrentDate().getTime() - businessStartDate.getTime());
         }
         }
 
 
         if(dataFlow.getCurrentBusiness() == null){
         if(dataFlow.getCurrentBusiness() == null){
@@ -1043,7 +1049,8 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
             JSONObject responseJson = doRequestBusinessSystem(dataFlow, service, requestBusinessJson);
             JSONObject responseJson = doRequestBusinessSystem(dataFlow, service, requestBusinessJson);
             DataFlowFactory.addCostTime(dataFlow, business.getServiceCode(), "调用"+business.getServiceName()+"-撤单 耗时", businessStartDate);
             DataFlowFactory.addCostTime(dataFlow, business.getServiceCode(), "调用"+business.getServiceName()+"-撤单 耗时", businessStartDate);
             saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()),
             saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),requestBusinessJson.toJSONString()),
-                    LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()));
+                    LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),responseJson.toJSONString()),
+                    DateUtil.getCurrentDate().getTime() - businessStartDate.getTime());
         }
         }
     }
     }
 
 
@@ -1124,7 +1131,8 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
 
 
             DataFlowFactory.addCostTime(dataFlow, business.getServiceCode(), "调用"+business.getServiceName()+"耗时", businessStartDate);
             DataFlowFactory.addCostTime(dataFlow, business.getServiceCode(), "调用"+business.getServiceName()+"耗时", businessStartDate);
             saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),dataFlow.getRequestBusinessJson().toJSONString()),
             saveLogMessage(dataFlow,LogAgent.createLogMessage(dataFlow.getRequestCurrentHeaders(),dataFlow.getRequestBusinessJson().toJSONString()),
-                    LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),dataFlow.getResponseBusinessJson().toJSONString()));
+                    LogAgent.createLogMessage(dataFlow.getResponseCurrentHeaders(),dataFlow.getResponseBusinessJson().toJSONString()),
+                    DateUtil.getCurrentDate().getTime()-businessStartDate.getTime());
         }
         }
     }
     }
 
 
@@ -1156,7 +1164,8 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
         dataFlow.setResponseBusinessJson(DataTransactionFactory.createOrderResponseJson(dataFlow.getTransactionId(),
         dataFlow.setResponseBusinessJson(DataTransactionFactory.createOrderResponseJson(dataFlow.getTransactionId(),
                  ResponseConstant.RESULT_CODE_SUCCESS, "成功"));
                  ResponseConstant.RESULT_CODE_SUCCESS, "成功"));
         DataFlowFactory.addCostTime(dataFlow, "doSynchronousBusinesses", "异步调用业务系统总耗时", startDate);
         DataFlowFactory.addCostTime(dataFlow, "doSynchronousBusinesses", "异步调用业务系统总耗时", startDate);
-        saveLogMessage(dataFlow,dataFlow.getRequestBusinessJson(),dataFlow.getResponseBusinessJson());
+        saveLogMessage(dataFlow,dataFlow.getRequestBusinessJson(),dataFlow.getResponseBusinessJson(),
+                DateUtil.getCurrentDate().getTime()-startDate.getTime());
     }
     }
 
 
 
 
@@ -1173,8 +1182,8 @@ public class CenterServiceSMOImpl extends LoggerEngine implements ICenterService
      *                     "body":""
      *                     "body":""
      *                     }
      *                     }
      */
      */
-    private void saveLogMessage(DataFlow dataFlow,JSONObject requestJson,JSONObject responseJson){
-            LogAgent.sendLog(dataFlow,requestJson,responseJson);
+    private void saveLogMessage(DataFlow dataFlow,JSONObject requestJson,JSONObject responseJson,long costTime){
+            LogAgent.sendLog(dataFlow,requestJson,responseJson,costTime);
     }
     }
 
 
     /**
     /**

+ 1 - 0
java110-config/db/LogService/create_table.db

@@ -13,6 +13,7 @@ create table l_transaction_log(
     service_code varchar(50) comment '服务编码',
     service_code varchar(50) comment '服务编码',
     service_name varchar(50) comment '服务名称',
     service_name varchar(50) comment '服务名称',
     timestamp TIMESTAMP NOT NULL comment '日志交互时间,时间戳',
     timestamp TIMESTAMP NOT NULL comment '日志交互时间,时间戳',
+    cost_time int not null default 0 comment '耗时',
     status_cd varchar(2) not null comment '交互状态 S 成功 F 失败',
     status_cd varchar(2) not null comment '交互状态 S 成功 F 失败',
     month INT NOT NULL default month(CURRENT_DATE) comment '月份',
     month INT NOT NULL default month(CURRENT_DATE) comment '月份',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',

+ 2 - 2
java110-config/src/main/resources/mapper/log/LogServiceDaoImplMapper.xml

@@ -7,9 +7,9 @@
     <!--保存日志-->
     <!--保存日志-->
     <insert id="saveTransactionLog" parameterType="java.util.HashMap" >
     <insert id="saveTransactionLog" parameterType="java.util.HashMap" >
         insert into l_transaction_log
         insert into l_transaction_log
-        (log_id,transaction_id,contract_id,ip,port,src_ip,src_port,app_id,user_id,service_code,service_name,timestamp,status_cd)
+        (log_id,transaction_id,contract_id,ip,port,src_ip,src_port,app_id,user_id,service_code,service_name,cost_time,timestamp,status_cd)
         values
         values
-        (#{logId},#{transactionId},#{dataFlowId},#{ip},#{port},#{srcIp},#{srcPort},#{appId},#{userId},#{serviceCode},#{serviceName},#{timestamp},#{logStatus})
+        (#{logId},#{transactionId},#{dataFlowId},#{ip},#{port},#{srcIp},#{srcPort},#{appId},#{userId},#{serviceCode},#{serviceName},#{costTime},#{timestamp},#{logStatus})
     </insert>
     </insert>
 
 
     <!--保存日志(交互报文)-->
     <!--保存日志(交互报文)-->

+ 11 - 3
java110-core/src/main/java/com/java110/core/context/AbstractTransactionLog.java

@@ -26,6 +26,8 @@ public abstract class AbstractTransactionLog  implements TransactionLog {
 
 
     private String requestMessage;
     private String requestMessage;
 
 
+    private long costTime;
+
     private String responseMessage;
     private String responseMessage;
 
 
     public String getHostIp() {
     public String getHostIp() {
@@ -61,6 +63,10 @@ public abstract class AbstractTransactionLog  implements TransactionLog {
         return responseMessage;
         return responseMessage;
     }
     }
 
 
+    public long getCostTime() {
+        return costTime;
+    }
+
     @Override
     @Override
     public String getPort() {
     public String getPort() {
         return port;
         return port;
@@ -83,12 +89,12 @@ public abstract class AbstractTransactionLog  implements TransactionLog {
      * 重新构建 TransactionLog 对象 主要用于服务调用方
      * 重新构建 TransactionLog 对象 主要用于服务调用方
      * @return
      * @return
      */
      */
-    public TransactionLog reBuilder(String requestMessage,String responseMessage,String logStatus){
+    public TransactionLog reBuilder(String requestMessage,String responseMessage,String logStatus,long costTime){
 
 
         this.logStatus = logStatus;
         this.logStatus = logStatus;
         this.requestMessage = requestMessage;
         this.requestMessage = requestMessage;
         this.responseMessage = responseMessage;
         this.responseMessage = responseMessage;
-
+        this.costTime = costTime;
         return this;
         return this;
     }
     }
 
 
@@ -96,13 +102,14 @@ public abstract class AbstractTransactionLog  implements TransactionLog {
      * 重新构建 TransactionLog 对象 主要用于服务提供方
      * 重新构建 TransactionLog 对象 主要用于服务提供方
      * @return
      * @return
      */
      */
-    public TransactionLog reBuilder(String appId,String userId,String requestMessage,String responseMessage,String logStatus){
+    public TransactionLog reBuilder(String appId,String userId,String requestMessage,String responseMessage,String logStatus,long costTime){
 
 
         this.logStatus = logStatus;
         this.logStatus = logStatus;
         this.requestMessage = requestMessage;
         this.requestMessage = requestMessage;
         this.responseMessage = responseMessage;
         this.responseMessage = responseMessage;
         this.setAppId(appId);
         this.setAppId(appId);
         this.setUserId(userId);
         this.setUserId(userId);
+        this.costTime = costTime;
         return this;
         return this;
     }
     }
 
 
@@ -121,6 +128,7 @@ public abstract class AbstractTransactionLog  implements TransactionLog {
         logMessage.put("serviceName",getServiceName());
         logMessage.put("serviceName",getServiceName());
         logMessage.put("timestamp",getTimestamp());
         logMessage.put("timestamp",getTimestamp());
         logMessage.put("logStatus",getLogStatus());
         logMessage.put("logStatus",getLogStatus());
+        logMessage.put("costTime",costTime);
         logMessage.put("requestMessage",getRequestMessage());
         logMessage.put("requestMessage",getRequestMessage());
         logMessage.put("responseMessage",getResponseMessage());
         logMessage.put("responseMessage",getResponseMessage());
         return logMessage.toJSONString(logMessage,SerializerFeature.WriteNullStringAsEmpty);
         return logMessage.toJSONString(logMessage,SerializerFeature.WriteNullStringAsEmpty);

+ 8 - 2
java110-core/src/main/java/com/java110/core/context/TransactionLog.java

@@ -64,6 +64,12 @@ public interface TransactionLog extends Serializable {
      */
      */
     public String getLogStatus();
     public String getLogStatus();
 
 
+    /**
+     * 耗时
+     * @return
+     */
+    public long getCostTime();
+
     /**
     /**
      * 接口请求消息
      * 接口请求消息
      * @return
      * @return
@@ -77,7 +83,7 @@ public interface TransactionLog extends Serializable {
      * 重新构建 TransactionLog 对象 主要用于服务调用方
      * 重新构建 TransactionLog 对象 主要用于服务调用方
      * @return
      * @return
      */
      */
-    public TransactionLog reBuilder(String appId,String userId,String requestMessage,String responseMessage,String logStatus);
+    public TransactionLog reBuilder(String appId,String userId,String requestMessage,String responseMessage,String logStatus,long costTime);
 
 
     /**
     /**
      * 重新构建 TransactionLog 对象 主要用于服务提供方
      * 重新构建 TransactionLog 对象 主要用于服务提供方
@@ -86,7 +92,7 @@ public interface TransactionLog extends Serializable {
      * @param logStatus 数据交互状态
      * @param logStatus 数据交互状态
      * @return
      * @return
      */
      */
-    public TransactionLog reBuilder(String requestMessage,String responseMessage,String logStatus);
+    public TransactionLog reBuilder(String requestMessage,String responseMessage,String logStatus,long costTime);
 
 
     /**
     /**
      * 转换成json模式
      * 转换成json模式

+ 7 - 7
java110-logAgent/src/main/java/com/java110/log/agent/LogAgent.java

@@ -53,8 +53,8 @@ public class LogAgent extends LoggerEngine{
      * @param logStatus 日志状态
      * @param logStatus 日志状态
      * @return
      * @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 @@ public class LogAgent extends LoggerEngine{
      * @param responseMessage 返回数据
      * @param responseMessage 返回数据
      * @return
      * @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());
         Assert.hasKey(responseMessage,"body","返回报文不满足 日志协议要求"+responseMessage.toJSONString());
 
 
         String body = responseMessage.getString("body");
         String body = responseMessage.getString("body");
@@ -82,21 +82,21 @@ public class LogAgent extends LoggerEngine{
             if(codeNode != null && ResponseConstant.RESULT_CODE_SUCCESS.equals(codeNode.toString())){
             if(codeNode != null && ResponseConstant.RESULT_CODE_SUCCESS.equals(codeNode.toString())){
                 //判断业务是否受理成功个,如果有一个业务受理失败,则认为失败
                 //判断业务是否受理成功个,如果有一个业务受理失败,则认为失败
                 if(!bodyObj.containsKey("business")){
                 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){
                 if(bodyObj.get("business") instanceof JSONObject){
                     JSONObject businessObj = bodyObj.getJSONObject("business");
                     JSONObject businessObj = bodyObj.getJSONObject("business");
                     if(businessObj.containsKey("response")&&
                     if(businessObj.containsKey("response")&&
                             ResponseConstant.RESULT_CODE_SUCCESS.equals(businessObj.getJSONObject("response").getString("code"))){
                             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){
                 if(bodyObj.get("business") instanceof JSONArray){
                     JSONArray businessArrays = bodyObj.getJSONArray("business");
                     JSONArray businessArrays = bodyObj.getJSONArray("business");
                     if(businessArrays == null || businessArrays.size() == 0){
                     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;
                     logStatus = LOG_STATUS_S;
@@ -116,7 +116,7 @@ public class LogAgent extends LoggerEngine{
         if(ResponseConstant.RESULT_CODE_SUCCESS.equals(body)){
         if(ResponseConstant.RESULT_CODE_SUCCESS.equals(body)){
             logStatus = LOG_STATUS_S;
             logStatus = LOG_STATUS_S;
         }
         }
-        return sendLog(dataFlow,requestMessage.toJSONString(),responseMessage.toJSONString(),logStatus);
+        return sendLog(dataFlow,requestMessage.toJSONString(),responseMessage.toJSONString(),logStatus,costTime);
     }
     }
 
 
 
 

+ 1 - 1
java110-logAgent/src/test/java/com/java110/AppTest.java

@@ -26,7 +26,7 @@ public class AppTest
     @Test
     @Test
     public void testDataFlow(){
     public void testDataFlow(){
         TransactionLog transactionLog = new DataFlow(new Date(),"0000");
         TransactionLog transactionLog = new DataFlow(new Date(),"0000");
-        transactionLog.reBuilder("234","234324","F");
+        transactionLog.reBuilder("234","234324","F",0);
 
 
         System.out.println(transactionLog.toString());
         System.out.println(transactionLog.toString());
     }
     }