Browse Source

修改外部接口监测-边坡接口异常处理

develop
Mr.Wang 4 months ago
parent
commit
c2046766ed
  1. 53
      zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java

53
zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java

@ -25,7 +25,6 @@ import com.zc.business.enums.UniversalEnum;
import com.zc.business.mapper.ExternalInterfaceMonitoringMapper; import com.zc.business.mapper.ExternalInterfaceMonitoringMapper;
import com.zc.business.service.impl.DcTrafficStatisticsServiceImpl; import com.zc.business.service.impl.DcTrafficStatisticsServiceImpl;
import com.zc.common.core.httpclient.OkHttp; import com.zc.common.core.httpclient.OkHttp;
import com.zc.common.core.httpclient.exception.HttpException;
import com.zc.common.core.httpclient.request.RequestParams; import com.zc.common.core.httpclient.request.RequestParams;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -151,12 +150,11 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
dcTrafficStatisticsCurrencyTollStation(UniversalEnum.EACH_TOLL_STATION_ENTRANCE_BY_TYPE_OF_HOURLY_TRAFFIC_FLOW.getValue(), "各收费站入口分车型", UniversalEnum.ONE.getValue()); dcTrafficStatisticsCurrencyTollStation(UniversalEnum.EACH_TOLL_STATION_ENTRANCE_BY_TYPE_OF_HOURLY_TRAFFIC_FLOW.getValue(), "各收费站入口分车型", UniversalEnum.ONE.getValue());
//边坡数据 获取边坡测点列表 //边坡数据 获取边坡测点列表
Response response = getMeasurePointList(); getMeasurePointList();
getMeasure(response, "获取边坡测点列表");
//获取边坡历史数据 //获取边坡历史数据
Response response1 = GetPointDataListAsync(); GetPointDataListAsync();
getMeasure(response1, "获取边坡历史数据");
// 全国气象数据 - 雷达数据 // 全国气象数据 - 雷达数据
getRadarData(); getRadarData();
@ -194,13 +192,13 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
} }
//获取边坡历史数据 //获取边坡历史数据
private Response getMeasurePointList() throws HttpException, IOException { private void getMeasurePointList() {
OkHttp okHttp = new OkHttp(); OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams(); RequestParams requestParams = new RequestParams();
requestParams.put("proCode", configService.selectConfigByKey("proCode")); requestParams.put("proCode", configService.selectConfigByKey("proCode"));
requestParams.put("unitCode", configService.selectConfigByKey("unitCode")); requestParams.put("unitCode", configService.selectConfigByKey("unitCode"));
try {
Object accessToken = redisCache.getCacheObject("accessToken"); Object accessToken = redisCache.getCacheObject("accessToken");
if (accessToken == null) { if (accessToken == null) {
JSONObject authenticate = authenticate(); JSONObject authenticate = authenticate();
@ -211,13 +209,26 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
header.put("Authorization", "Bearer " + accessToken.toString()); header.put("Authorization", "Bearer " + accessToken.toString());
Response response // 请求响应 Response response // 请求响应
= okHttp = okHttp
.headers(header) .headers(header)
.url(configService.selectConfigByKey("GetMeasurePointListAPI")) // 请求地址 .url(configService.selectConfigByKey("GetMeasurePointListAPI")) // 请求地址
.data(requestParams) // 请求参数 .data(requestParams) // 请求参数
.get(); // 请求方法 .get(); // 请求方法
return response; getMeasure(response, "获取边坡测点列表");
} catch (Exception e) {
ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring();
externalInterfaceMonitoring.setOperationResult(e.getMessage());
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID());
externalInterfaceMonitoring.setOperatorName("系统");
externalInterfaceMonitoring.setOperationTime(new Date());
externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.SIDE_SLOPE.getCode());
externalInterfaceMonitoring.setInterfaceName("获取边坡测点列表");
externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring);
}
} }
/** /**
@ -240,7 +251,7 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
Response response = postRequestByHeadersAndParams(headers, url, requestParams); Response response = postRequestByHeadersAndParams(headers, url, requestParams);
// 插入 // 插入
trafficFlowResultProcessing(externalInterfaceMonitoring, response); trafficFlowResultProcessing(externalInterfaceMonitoring, response);
}catch (Exception e) { } catch (Exception e) {
externalInterfaceMonitoring.setOperationResult(e.getMessage()); externalInterfaceMonitoring.setOperationResult(e.getMessage());
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID());
@ -413,7 +424,7 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
} catch (Exception e) { } catch (Exception e) {
externalInterfaceMonitoring.setOperationResult(e.getMessage()); externalInterfaceMonitoring.setOperationResult(e.getMessage());
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
}finally { } finally {
externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID());
externalInterfaceMonitoring.setOperatorName("系统"); externalInterfaceMonitoring.setOperatorName("系统");
externalInterfaceMonitoring.setOperationTime(new Date()); externalInterfaceMonitoring.setOperationTime(new Date());
@ -471,7 +482,7 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
} catch (Exception e) { } catch (Exception e) {
externalInterfaceMonitoring.setOperationResult(e.getMessage()); externalInterfaceMonitoring.setOperationResult(e.getMessage());
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
}finally { } finally {
externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring);
} }
} }
@ -914,14 +925,14 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
} }
} }
public Response GetPointDataListAsync() throws IOException, HttpException { public void GetPointDataListAsync() {
//今天零点的时间戳 //今天零点的时间戳
long todayStartTimestamp = getTodayStartTimestamp(); long todayStartTimestamp = getTodayStartTimestamp();
// 获取当前时间的时间戳(毫秒数) // 获取当前时间的时间戳(毫秒数)
long currentTimestamp = getCurrentTimestamp(); long currentTimestamp = getCurrentTimestamp();
OkHttp okHttp = new OkHttp(); OkHttp okHttp = new OkHttp();
ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring();
try {
RequestParams requestParams = new RequestParams(); RequestParams requestParams = new RequestParams();
requestParams.put("projCode", configService.selectConfigByKey("proCode"));//项目编号 如 JHGKJ requestParams.put("projCode", configService.selectConfigByKey("proCode"));//项目编号 如 JHGKJ
requestParams.put("unitCode", configService.selectConfigByKey("unitCode"));//项目单位工程编号 如 60-01.0002.00.00 requestParams.put("unitCode", configService.selectConfigByKey("unitCode"));//项目单位工程编号 如 60-01.0002.00.00
@ -939,15 +950,25 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
header.put("Authorization", "Bearer " + accessToken.toString()); header.put("Authorization", "Bearer " + accessToken.toString());
Response response // 请求响应 Response response // 请求响应
= okHttp = okHttp
.headers(header) .headers(header)
.url(configService.selectConfigByKey("GetPointDataListAsyncAPI")) // 请求地址 .url(configService.selectConfigByKey("GetPointDataListAsyncAPI")) // 请求地址
.data(requestParams) // 请求参数 .data(requestParams) // 请求参数
.get(); // 请求方法 .get(); // 请求方法
getMeasure(response, "获取边坡历史数据");
} catch (Exception e) {
externalInterfaceMonitoring.setOperationResult(e.getMessage());
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID());
externalInterfaceMonitoring.setOperatorName("系统");
externalInterfaceMonitoring.setOperationTime(new Date());
externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.SIDE_SLOPE.getCode());
externalInterfaceMonitoring.setInterfaceName("获取边坡历史数据");
externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring);
}
// 正确解析响应体中的JSON数据
return response;
} }
// 获取今天零点的时间戳(毫秒数) // 获取今天零点的时间戳(毫秒数)

Loading…
Cancel
Save