|
|
@ -1248,10 +1248,8 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int trafficFlowAtToll() throws HttpException, IOException { |
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); |
|
|
|
LocalDate currentDate = LocalDate.now(); |
|
|
|
String startDate = currentDate.format(formatter); |
|
|
|
public int trafficFlowAtToll(String startDate) throws HttpException, IOException { |
|
|
|
|
|
|
|
try { |
|
|
|
Response response = getResponseTrafficFlowAtToll(startDate, UniversalEnum.ONE.getValue()); |
|
|
|
Response responseTwo = getResponseTrafficFlowAtToll(startDate, UniversalEnum.TWO.getValue()); |
|
|
@ -1290,6 +1288,52 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 昨日车流量 |
|
|
|
* @param startDate |
|
|
|
* @return |
|
|
|
* @throws HttpException |
|
|
|
* @throws IOException |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int yesterdayTrafficFlowAtToll(String startDate) throws HttpException, IOException { |
|
|
|
try { |
|
|
|
Response response = getResponseTrafficFlowAtToll(startDate, UniversalEnum.ONE.getValue()); |
|
|
|
Response responseTwo = getResponseTrafficFlowAtToll(startDate, UniversalEnum.TWO.getValue()); |
|
|
|
ResponseBody body = response.body(); |
|
|
|
ResponseBody bodyTwo = responseTwo.body(); |
|
|
|
Integer totalFlow1 = UniversalEnum.ZERO.getNumber(); |
|
|
|
Integer totalFlow2 = UniversalEnum.ZERO.getNumber(); |
|
|
|
if (body != null) { |
|
|
|
String jsonString = body.string(); |
|
|
|
if (JSON.isValidArray(jsonString)) { |
|
|
|
JSONArray jsonArray = JSON.parseArray(jsonString); |
|
|
|
for (Object item : jsonArray) { |
|
|
|
JSONObject jsonObject = (JSONObject) item; |
|
|
|
totalFlow1 = totalFlow1 + jsonObject.getInteger("total_flow"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (bodyTwo != null) { |
|
|
|
String jsonString = bodyTwo.string(); |
|
|
|
if (JSON.isValidArray(jsonString)) { |
|
|
|
JSONArray jsonArray = JSON.parseArray(jsonString); |
|
|
|
for (Object item : jsonArray) { |
|
|
|
JSONObject jsonObject = (JSONObject) item; |
|
|
|
totalFlow2 = totalFlow2 + jsonObject.getInteger("total_flow"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return totalFlow1 + totalFlow2; |
|
|
|
} catch (IOException e) { |
|
|
|
// 处理异常
|
|
|
|
e.printStackTrace(); |
|
|
|
return UniversalEnum.ZERO.getNumber(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private Response getResponseTrafficFlowAtToll(String startDate, String stationType) throws HttpException, IOException { |
|
|
|
// 创建OkHttpClient.Builder实例
|
|
|
|
OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder(); |
|
|
|