| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.smo.IApiServiceSMO; |
| | | import com.java110.api.smo.ISaveTransactionLogSMO; |
| | | import com.java110.core.client.RestTemplate; |
| | | import com.java110.core.context.ApiDataFlow; |
| | | import com.java110.core.context.DataFlow; |
| | |
| | | import com.java110.entity.center.AppRoute; |
| | | import com.java110.entity.center.AppService; |
| | | import com.java110.entity.center.DataFlowLinksCost; |
| | | import com.java110.intf.common.ITransactionLogInnerServiceSMO; |
| | | import com.java110.po.transactionLog.TransactionLogPo; |
| | | import com.java110.utils.cache.AppRouteCache; |
| | | import com.java110.utils.cache.CommonCache; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.constant.KafkaConstant; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | |
| | | private RestTemplate outRestTemplate; |
| | | |
| | | @Autowired |
| | | private ITransactionLogInnerServiceSMO transactionLogInnerServiceSMOImpl; |
| | | private ISaveTransactionLogSMO saveTransactionLogSMOImpl; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | String logServiceCode = MappingCache.getValue(MappingCache.LOG_SERVICE_CODE); |
| | | |
| | | //日志查询不记录 |
| | | if ("/transactionLog/queryTransactionLog".equals(serviceCode) |
| | | || "/transactionLog/queryTransactionLogMessage".equals(serviceCode) |
| | | || "file.getFile".equals(serviceCode) |
| | | || "file.getFileByObjId".equals(serviceCode) |
| | | ) { |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isEmpty(logServiceCode)) { |
| | | return; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @Async |
| | | |
| | | private void doSaveLog(ApiDataFlow dataFlow, Date startDate, Date endDate, String serviceCode, String reqJson, ResponseEntity<String> responseEntity) { |
| | | |
| | | TransactionLogPo transactionLogPo = new TransactionLogPo(); |
| | |
| | | transactionLogPo.setIp(""); |
| | | transactionLogPo.setServiceCode(serviceCode); |
| | | transactionLogPo.setSrcIp(dataFlow.getRequestHeaders().get(CommonConstant.HTTP_SRC_IP)); |
| | | transactionLogPo.setState(responseEntity.getStatusCode() != HttpStatus.OK ? "S" : "F"); |
| | | transactionLogPo.setState(responseEntity.getStatusCode() != HttpStatus.OK ? "F" : "S"); |
| | | transactionLogPo.setTimestamp(dataFlow.getRequestTime()); |
| | | transactionLogPo.setUserId(dataFlow.getUserId()); |
| | | transactionLogPo.setTransactionId(dataFlow.getTransactionId()); |
| | |
| | | transactionLogPo.setResponseHeader(responseEntity.getHeaders().toSingleValueMap().toString()); |
| | | transactionLogPo.setRequestMessage(reqJson); |
| | | transactionLogPo.setResponseMessage(responseEntity.getBody()); |
| | | transactionLogInnerServiceSMOImpl.saveTransactionLog(transactionLogPo); |
| | | saveTransactionLogSMOImpl.saveLog(transactionLogPo); |
| | | } |
| | | |
| | | |