| | |
| | | |
| | | String serviceCode = dataFlow.getRequestHeaders().get(CommonConstant.HTTP_SERVICE); |
| | | |
| | | String logServiceCode = MappingCache.getValue(MappingConstant.DOMAIN_SYSTEM_SWITCH,MappingCache.LOG_SERVICE_CODE); |
| | | String logServiceCode = MappingCache.getValue(MappingConstant.DOMAIN_SYSTEM_SWITCH, MappingCache.LOG_SERVICE_CODE); |
| | | |
| | | //日志查询不记录 |
| | | if ("/transactionLog/queryTransactionLog".equals(serviceCode) |
| | |
| | | || "file.getFile".equals(serviceCode) |
| | | || "file.getFileByObjId".equals(serviceCode) |
| | | || "/machine/heartbeat".equals(serviceCode) // 心跳也不记录 |
| | | ) { |
| | | ) { |
| | | return; |
| | | } |
| | | |
| | |
| | | throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "TRANSACTION_ID 不能为空"); |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrNone(dataFlow.getAppRoutes().get(0).getSecurityCode())) { |
| | | String sign = AuthenticationFactory.apiDataFlowMd5(dataFlow); |
| | | if (StringUtil.isEmpty(dataFlow.getReqSign()) || !sign.equals(dataFlow.getReqSign().toLowerCase())) { |
| | | throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "签名失败"); |
| | | } |
| | | } |
| | | // if (!StringUtil.isNullOrNone(dataFlow.getAppRoutes().get(0).getSecurityCode())) { |
| | | // String sign = AuthenticationFactory.apiDataFlowMd5(dataFlow); |
| | | // if (StringUtil.isEmpty(dataFlow.getReqSign()) || !sign.equals(dataFlow.getReqSign().toLowerCase())) { |
| | | // throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "签名失败"); |
| | | // } |
| | | // } |
| | | |
| | | if (StringUtil.isNullOrNone(dataFlow.getRequestTime()) || !DateUtil.judgeDate(dataFlow.getRequestTime(), DateUtil.DATE_FORMATE_STRING_DEFAULT)) { |
| | | //添加耗时 |
| | |
| | | |
| | | ResponseEntity responseEntity = null; |
| | | //配置c_service 时请注意 如果是以out 开头的调用外部的地址 |
| | | RestTemplate restTemplate ; |
| | | RestTemplate restTemplate; |
| | | if (Environment.isStartBootWay()) { |
| | | restTemplate = ApplicationContextFactory.getBean("outRestTemplate", RestTemplate.class); |
| | | } else { |
| | |
| | | requestUrl = service.getUrl() + "?" + param; |
| | | } |
| | | } |
| | | |
| | | requestUrl = BootReplaceUtil.replaceServiceName(requestUrl); |
| | | if (Environment.isStartBootWay()) { |
| | | requestUrl = BootReplaceUtil.replaceServiceName(requestUrl); |
| | | } |
| | | |
| | | responseEntity = restTemplate.exchange(requestUrl, HttpMethod.GET, httpEntity, String.class); |
| | | } else if (CommonConstant.HTTP_METHOD_PUT.equals(service.getMethod())) { |
| | |
| | | |
| | | //String requestUrl = "http://127.0.0.1:8008" + serviceCode; |
| | | String requestUrl = serviceCode; |
| | | RestTemplate restTemplate ; |
| | | RestTemplate restTemplate; |
| | | if (Environment.isStartBootWay()) { |
| | | requestUrl = Environment.BOOT_PATH + requestUrl; |
| | | restTemplate = ApplicationContextFactory.getBean("outRestTemplate", RestTemplate.class); |
| | |
| | | |
| | | /** |
| | | * 开始调度微服务 |
| | | * |
| | | * @param appService |
| | | * @param dataFlow |
| | | * @param reqJson |
| | |
| | | HttpHeaders header = new HttpHeaders(); |
| | | //todo 对头信息重新包装 |
| | | for (String key : dataFlow.getRequestCurrentHeaders().keySet()) { |
| | | if("userName".equals(key) || "user-name".equals(key)){ |
| | | if ("userName".equals(key) || "user-name".equals(key)) { |
| | | header.add(key, "-"); |
| | | continue; |
| | | } |
| | |
| | | private void saveLogMessage(String requestJson, String responseJson) { |
| | | |
| | | try { |
| | | if (MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.DOMAIN_SYSTEM_SWITCH,MappingConstant.KEY_LOG_ON_OFF))) { |
| | | if (MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.DOMAIN_SYSTEM_SWITCH, MappingConstant.KEY_LOG_ON_OFF))) { |
| | | JSONObject log = new JSONObject(); |
| | | log.put("request", requestJson); |
| | | log.put("response", responseJson); |
| | |
| | | */ |
| | | private void saveCostTimeLogMessage(DataFlow dataFlow) { |
| | | try { |
| | | if (MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.DOMAIN_SYSTEM_SWITCH,MappingConstant.KEY_COST_TIME_ON_OFF))) { |
| | | if (MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.DOMAIN_SYSTEM_SWITCH, MappingConstant.KEY_COST_TIME_ON_OFF))) { |
| | | List<DataFlowLinksCost> dataFlowLinksCosts = dataFlow.getLinksCostDates(); |
| | | JSONObject costDate = new JSONObject(); |
| | | JSONArray costDates = new JSONArray(); |