Browse Source

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

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

47
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.service.impl.DcTrafficStatisticsServiceImpl;
import com.zc.common.core.httpclient.OkHttp;
import com.zc.common.core.httpclient.exception.HttpException;
import com.zc.common.core.httpclient.request.RequestParams;
import io.swagger.annotations.Api;
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());
//边坡数据 获取边坡测点列表
Response response = getMeasurePointList();
getMeasure(response, "获取边坡测点列表");
getMeasurePointList();
//获取边坡历史数据
Response response1 = GetPointDataListAsync();
getMeasure(response1, "获取边坡历史数据");
GetPointDataListAsync();
// 全国气象数据 - 雷达数据
getRadarData();
@ -194,13 +192,13 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
}
//获取边坡历史数据
private Response getMeasurePointList() throws HttpException, IOException {
private void getMeasurePointList() {
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams();
requestParams.put("proCode", configService.selectConfigByKey("proCode"));
requestParams.put("unitCode", configService.selectConfigByKey("unitCode"));
try {
Object accessToken = redisCache.getCacheObject("accessToken");
if (accessToken == null) {
JSONObject authenticate = authenticate();
@ -211,13 +209,26 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
Map<String, String> header = new HashMap<>();
header.put("Authorization", "Bearer " + accessToken.toString());
Response response // 请求响应
= okHttp
.headers(header)
.url(configService.selectConfigByKey("GetMeasurePointListAPI")) // 请求地址
.data(requestParams) // 请求参数
.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);
}
}
/**
@ -914,14 +925,14 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
}
}
public Response GetPointDataListAsync() throws IOException, HttpException {
public void GetPointDataListAsync() {
//今天零点的时间戳
long todayStartTimestamp = getTodayStartTimestamp();
// 获取当前时间的时间戳(毫秒数)
long currentTimestamp = getCurrentTimestamp();
OkHttp okHttp = new OkHttp();
ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring();
try {
RequestParams requestParams = new RequestParams();
requestParams.put("projCode", configService.selectConfigByKey("proCode"));//项目编号 如 JHGKJ
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<>();
header.put("Authorization", "Bearer " + accessToken.toString());
Response response // 请求响应
= okHttp
.headers(header)
.url(configService.selectConfigByKey("GetPointDataListAsyncAPI")) // 请求地址
.data(requestParams) // 请求参数
.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