Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
zhaoxianglong 9 months ago
parent
commit
41a0e06999
  1. 2
      zc-business/src/main/java/com/zc/business/domain/ExternalInterfaceMonitoring.java
  2. 280
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java
  3. 35
      zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java
  4. 2
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

2
zc-business/src/main/java/com/zc/business/domain/ExternalInterfaceMonitoring.java

@ -1,5 +1,6 @@
package com.zc.business.domain; package com.zc.business.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -41,6 +42,7 @@ public class ExternalInterfaceMonitoring {
@ApiModelProperty("操作结果") @ApiModelProperty("操作结果")
private String operationResult; private String operationResult;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
@ApiModelProperty("操作时间") @ApiModelProperty("操作时间")
private Date operationTime; private Date operationTime;
} }

280
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java

@ -5,17 +5,16 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.common.utils.spring.SpringUtils;
import com.sun.xml.bind.v2.TODO;
import com.zc.business.constant.RedisKeyConstants; import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.domain.*; import com.zc.business.domain.DcCongestionSection;
import com.zc.business.domain.DcFacility;
import com.zc.business.domain.DcRoadSection;
import com.zc.business.domain.DcRoadSectionCongestion;
import com.zc.business.enums.StakeMarkRange; import com.zc.business.enums.StakeMarkRange;
import com.zc.business.enums.UniversalEnum; import com.zc.business.enums.UniversalEnum;
import com.zc.business.service.IDcFacilityService; import com.zc.business.service.IDcFacilityService;
import com.zc.business.service.IDcRoadConditionInformationService;
import com.zc.business.service.IDcRoadSectionService; import com.zc.business.service.IDcRoadSectionService;
import com.zc.business.service.IDcTrafficStatisticsService; import com.zc.business.service.IDcTrafficStatisticsService;
import com.zc.business.utils.StakeMarkUtils; import com.zc.business.utils.StakeMarkUtils;
@ -28,7 +27,6 @@ import okhttp3.Response;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@ -119,7 +117,6 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
} }
*/ */
public static CompletableFuture<String> refreshAccessToken() { public static CompletableFuture<String> refreshAccessToken() {
CompletableFuture<String> future = new CompletableFuture<>(); CompletableFuture<String> future = new CompletableFuture<>();
OkHttp okHttp = new OkHttp(); OkHttp okHttp = new OkHttp();
@ -208,7 +205,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
ResponseBody body = response.body(); ResponseBody body = response.body();
if (body != null) { if (body != null) {
return JSON.parseArray(body.string()); String jsonString = body.string();
if (JSON.isValidArray(jsonString)) {
return JSON.parseArray(jsonString);
} else {
return new JSONArray();
}
} }
return new JSONArray(); return new JSONArray();
@ -241,7 +243,10 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
JSONArray jsonArray = null; JSONArray jsonArray = null;
if (body != null) { if (body != null) {
jsonArray = JSON.parseArray(body.string()); String jsonString = body.string();
if (JSON.isValidArray(jsonString)) {
jsonArray = JSON.parseArray(jsonString);
}
} }
Map<String, Integer> map = new HashMap<>(); Map<String, Integer> map = new HashMap<>();
@ -318,7 +323,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
ResponseBody body = response.body(); ResponseBody body = response.body();
if (body != null) { if (body != null) {
return JSON.parseArray(body.string()); String jsonString = body.string();
if (JSON.isValidArray(jsonString)) {
return JSON.parseArray(jsonString);
} else {
return new JSONArray();
}
} }
return new JSONArray(); return new JSONArray();
} }
@ -563,7 +573,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
ResponseBody body = response.body(); ResponseBody body = response.body();
if (body != null) { if (body != null) {
return JSON.parseArray(body.string()); String jsonString = body.string();
if (JSON.isValidArray(jsonString)) {
return JSON.parseArray(jsonString);
} else {
return new JSONArray();
}
} }
return new JSONArray(); return new JSONArray();
@ -604,7 +619,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
ResponseBody body = response.body(); ResponseBody body = response.body();
if (body != null) { if (body != null) {
return JSON.parseArray(body.string()); String jsonString = body.string();
if (JSON.isValidArray(jsonString)) {
return JSON.parseArray(jsonString);
} else {
return new JSONArray();
}
} }
return new JSONArray(); return new JSONArray();
@ -642,7 +662,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
ResponseBody body = response.body(); ResponseBody body = response.body();
if (body != null) { if (body != null) {
return JSON.parseArray(body.string()); String jsonString = body.string();
if (JSON.isValidArray(jsonString)) {
return JSON.parseArray(jsonString);
}else {
return new JSONArray();
}
} }
return new JSONArray(); return new JSONArray();
@ -682,37 +707,39 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
ResponseBody body = response.body(); ResponseBody body = response.body();
if (body != null) { if (body != null) {
JSONArray jsonArray = JSON.parseArray(body.string()); String jsonString = body.string();
Map<String, Integer> sumByName = new LinkedHashMap<>(); if (JSON.isValidArray(jsonString)) {
Integer totalFlow1=0; JSONArray jsonArray = JSON.parseArray(jsonString);
List<Map<String, String>> list = new ArrayList(); Map<String, Integer> sumByName = new LinkedHashMap<>();
for (Object item : jsonArray) { // 这里做了微调,直接遍历jsonArray的Object Integer totalFlow1 = 0;
JSONObject jsonObject = (JSONObject) item; List<Map<String, String>> list = new ArrayList();
for (Object item : jsonArray) { // 这里做了微调,直接遍历jsonArray的Object
totalFlow1=totalFlow1+ jsonObject.getInteger("total_flow"); JSONObject jsonObject = (JSONObject) item;
// 获取当前时间 totalFlow1 = totalFlow1 + jsonObject.getInteger("total_flow");
LocalTime now = LocalTime.now();
// 获取当前小时数(24小时制) // 获取当前时间
int currentHour = now.getHour(); LocalTime now = LocalTime.now();
if (jsonObject.getInteger("data_hour") == currentHour) { // 获取当前小时数(24小时制)
String name = jsonObject.getString("ts_name"); // 更安全的取值方式 int currentHour = now.getHour();
int totalFlow = jsonObject.getInteger("total_flow"); // 专门针对Integer类型 if (jsonObject.getInteger("data_hour") == currentHour) {
String name = jsonObject.getString("ts_name"); // 更安全的取值方式
sumByName.put(name, totalFlow); int totalFlow = jsonObject.getInteger("total_flow"); // 专门针对Integer类型
sumByName.put(name, totalFlow);
}
} }
System.out.println("总数===:" + totalFlow1);
// 正确创建新的映射对象并添加到list中
for (Map.Entry<String, Integer> entry : sumByName.entrySet()) {
Map<String, String> singleResult = new LinkedHashMap<>(); // 每次循环都创建一个新的映射
singleResult.put("name", entry.getKey());
singleResult.put("value", entry.getValue().toString());
list.add(singleResult);
}
return list;
} }
System.out.println("总数===:"+totalFlow1);
// 正确创建新的映射对象并添加到list中
for (Map.Entry<String, Integer> entry : sumByName.entrySet()) {
Map<String, String> singleResult = new LinkedHashMap<>(); // 每次循环都创建一个新的映射
singleResult.put("name", entry.getKey());
singleResult.put("value", entry.getValue().toString());
list.add(singleResult);
}
return list;
} }
return new ArrayList(); return new ArrayList();
} }
@ -746,7 +773,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
ResponseBody body = response.body(); ResponseBody body = response.body();
if (body != null) { if (body != null) {
return JSON.parseArray(body.string()); String jsonString = body.string();
if (JSON.isValidArray(jsonString)) {
return JSON.parseArray(jsonString);
}else {
return new JSONArray();
}
} }
return new JSONArray(); return new JSONArray();
@ -866,8 +898,15 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
.data(requestParams) // 请求参数 .data(requestParams) // 请求参数
.post(); // 请求方法 .post(); // 请求方法
ResponseBody body = response.body(); ResponseBody body = response.body();
JSONArray jsonArray = JSON.parseArray(body.string()); if (body != null) {
return jsonArray; String jsonString = body.string();
if (JSON.isValidArray(jsonString)) {
return JSON.parseArray(jsonString);
}else {
return new JSONArray();
}
}
return new JSONArray();
} }
//格式化桩号 //格式化桩号
@ -933,8 +972,9 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
ResponseBody body = response.body(); ResponseBody body = response.body();
if (body != null) { if (body != null) {
JSONArray jsonArray = JSON.parseArray(body.string()); String jsonString = body.string();
System.out.println(jsonArray); if (JSON.isValidArray(jsonString)) {
JSONArray jsonArray = JSON.parseArray(jsonString);
for (Object item : jsonArray) { for (Object item : jsonArray) {
JSONObject jsonObject = (JSONObject) item; JSONObject jsonObject = (JSONObject) item;
if (jsonObject.getString("gantry_id").equals(nearestFacility.getFacilityCode())) { if (jsonObject.getString("gantry_id").equals(nearestFacility.getFacilityCode())) {
@ -946,7 +986,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
mapList.add(map); mapList.add(map);
} }
} }
}
// 输出结果 // 输出结果
return mapList; return mapList;
@ -982,100 +1022,110 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
ResponseBody body = response.body(); ResponseBody body = response.body();
if (body != null) { if (body != null) {
JSONArray jsonArray = JSON.parseArray(body.string()); String jsonString = body.string();
for (Object object : jsonArray) { if (JSON.isValidArray(jsonString)) {
JSONObject jsonObject = (JSONObject) object; JSONArray jsonArray = JSON.parseArray(jsonString);
Integer asOneRoad = jsonObject.getInteger("as_one_road"); for (Object object : jsonArray) {
if (jsonObject.getDouble("end_pile_no")!=null){ JSONObject jsonObject = (JSONObject) object;
double endPileNo = jsonObject.getDouble("end_pile_no"); Integer asOneRoad = jsonObject.getInteger("as_one_road");
String endMark = formatNumber(endPileNo); if (jsonObject.getDouble("end_pile_no") != null) {
jsonObject.put("endMark", endMark);//结束桩号 double endPileNo = jsonObject.getDouble("end_pile_no");
} String endMark = formatNumber(endPileNo);
double startPileNo = jsonObject.getDouble("start_pile_no"); jsonObject.put("endMark", endMark);//结束桩号
String stakeMark = formatNumber(startPileNo); }
jsonObject.put("stakeMark", stakeMark);// double startPileNo = jsonObject.getDouble("start_pile_no");
String stakeMark = formatNumber(startPileNo);
//as_one_road jsonObject.put("stakeMark", stakeMark);//
//是否为同一条路,1-是,0-否
if (asOneRoad == UniversalEnum.ZERO.getNumber()) { //as_one_road
//是否为同一条路,1-是,0-否
String string = jsonObject.getString("list_link_info"); if (asOneRoad == UniversalEnum.ZERO.getNumber()) {
JSONArray jsonlist = JSON.parseArray(string);
JSONObject o = (JSONObject) jsonlist.get(UniversalEnum.ZERO.getNumber()); String string = jsonObject.getString("list_link_info");
JSONArray jsonlist = JSON.parseArray(string);
String string1 = o.getString("firstPoint"); JSONObject o = (JSONObject) jsonlist.get(UniversalEnum.ZERO.getNumber());
String string2 = o.getString("lastPoint");
String lngLats = o.getString("lngLats"); String string1 = o.getString("firstPoint");
String[] lngLatsString = lngLats.split(";"); String string2 = o.getString("lastPoint");
double s = Double.parseDouble(lngLatsString[UniversalEnum.ZERO.getNumber()].split(",")[UniversalEnum.ZERO.getNumber()]); String lngLats = o.getString("lngLats");
double s2 = Double.parseDouble(lngLatsString[UniversalEnum.ZERO.getNumber()].split(",")[UniversalEnum.ONE.getNumber()]); String[] lngLatsString = lngLats.split(";");
double s3 = Double.parseDouble(lngLatsString[lngLatsString.length - UniversalEnum.ONE.getNumber()].split(",")[UniversalEnum.ZERO.getNumber()]); double s = Double.parseDouble(lngLatsString[UniversalEnum.ZERO.getNumber()].split(",")[UniversalEnum.ZERO.getNumber()]);
double s4 = Double.parseDouble(lngLatsString[lngLatsString.length - UniversalEnum.ONE.getNumber()].split(",")[UniversalEnum.ONE.getNumber()]); double s2 = Double.parseDouble(lngLatsString[UniversalEnum.ZERO.getNumber()].split(",")[UniversalEnum.ONE.getNumber()]);
double distanceM = calculateDistance(s2, s, s4, s3); double s3 = Double.parseDouble(lngLatsString[lngLatsString.length - UniversalEnum.ONE.getNumber()].split(",")[UniversalEnum.ZERO.getNumber()]);
// System.out.printf("最大距离为: %.2f 米%n", distanceM); double s4 = Double.parseDouble(lngLatsString[lngLatsString.length - UniversalEnum.ONE.getNumber()].split(",")[UniversalEnum.ONE.getNumber()]);
jsonObject.put("max_jam_dist", distanceM);//最大拥堵距离 double distanceM = calculateDistance(s2, s, s4, s3);
double endMake = startPileNo +Double.parseDouble(String.format("%.3f", distanceM)); // System.out.printf("最大距离为: %.2f 米%n", distanceM);
String endmark = formatNumber(endMake); jsonObject.put("max_jam_dist", distanceM);//最大拥堵距离
jsonObject.put("endMark", endmark);//结束桩号 double endMake = startPileNo + Double.parseDouble(String.format("%.3f", distanceM));
String endmark = formatNumber(endMake);
String[] split = string1.split(","); jsonObject.put("endMark", endmark);//结束桩号
double firstLon = Double.parseDouble(split[UniversalEnum.ZERO.getNumber()]);
double firstLat = Double.parseDouble(split[UniversalEnum.ONE.getNumber()]); String[] split = string1.split(",");
String[] split2 = string2.split(","); double firstLon = Double.parseDouble(split[UniversalEnum.ZERO.getNumber()]);
double lastLon = Double.parseDouble(split2[UniversalEnum.ZERO.getNumber()]); double firstLat = Double.parseDouble(split[UniversalEnum.ONE.getNumber()]);
double lastLat = Double.parseDouble(split2[UniversalEnum.ONE.getNumber()]); String[] split2 = string2.split(",");
//double firstLat = 35.38524527319016; double lastLon = Double.parseDouble(split2[UniversalEnum.ZERO.getNumber()]);
// double firstLon = 118.39808642864227; double lastLat = Double.parseDouble(split2[UniversalEnum.ONE.getNumber()]);
//double lastLat = 35.386351346969604; //double firstLat = 35.38524527319016;
// double lastLon = 118.4038907289505; // double firstLon = 118.39808642864227;
double distanceKm = calculateDistance(firstLat, firstLon, lastLat, lastLon); //double lastLat = 35.386351346969604;
double distanceMeters = distanceKm * UniversalEnum.THOUSAND.getNumber(); // 将距离转换为米 // double lastLon = 118.4038907289505;
//System.out.printf("两点之间的距离为: %.2f 米%n", distanceMeters); double distanceKm = calculateDistance(firstLat, firstLon, lastLat, lastLon);
jsonObject.put("jam_dist", distanceMeters);//当前拥堵距离 double distanceMeters = distanceKm * UniversalEnum.THOUSAND.getNumber(); // 将距离转换为米
//System.out.printf("两点之间的距离为: %.2f 米%n", distanceMeters);
jsonObject.put("jam_dist", distanceMeters);//当前拥堵距离
}
} }
}
return jsonArray;
return jsonArray;
}
} }
return new JSONArray(); return new JSONArray();
} }
/** /**
* 各收费站日累计车流辆 * 各收费站日累计车流辆
*
* @return * @return
*/ */
@Override @Override
public int trafficFlowAtToll()throws HttpException, IOException { public int trafficFlowAtToll() throws HttpException, IOException {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue());
LocalDate currentDate = LocalDate.now(); LocalDate currentDate = LocalDate.now();
String startDate = currentDate.format(formatter); String startDate = currentDate.format(formatter);
Response response = getResponseTrafficFlowAtToll(startDate,UniversalEnum.ONE.getValue()); Response response = getResponseTrafficFlowAtToll(startDate, UniversalEnum.ONE.getValue());
Response responseTwo = getResponseTrafficFlowAtToll(startDate,UniversalEnum.TWO.getValue()); Response responseTwo = getResponseTrafficFlowAtToll(startDate, UniversalEnum.TWO.getValue());
ResponseBody body = response.body(); ResponseBody body = response.body();
ResponseBody bodyTwo = responseTwo.body(); ResponseBody bodyTwo = responseTwo.body();
Integer totalFlow1=UniversalEnum.ZERO.getNumber(); Integer totalFlow1 = UniversalEnum.ZERO.getNumber();
Integer totalFlow2=UniversalEnum.ZERO.getNumber(); Integer totalFlow2 = UniversalEnum.ZERO.getNumber();
if (body != null) { if (body != null) {
JSONArray jsonArray = JSON.parseArray(body.string()); String jsonString = body.string();
for (Object item : jsonArray) { if (JSON.isValidArray(jsonString)) {
JSONObject jsonObject = (JSONObject) item; JSONArray jsonArray = JSON.parseArray(jsonString);
totalFlow1=totalFlow1+ jsonObject.getInteger("total_flow"); for (Object item : jsonArray) {
JSONObject jsonObject = (JSONObject) item;
totalFlow1 = totalFlow1 + jsonObject.getInteger("total_flow");
}
} }
} }
if (bodyTwo != null) { if (bodyTwo != null) {
JSONArray jsonArray = JSON.parseArray(bodyTwo.string()); String jsonString = bodyTwo.string();
for (Object item : jsonArray) { if (JSON.isValidArray(jsonString)) {
JSONObject jsonObject = (JSONObject) item; JSONArray jsonArray = JSON.parseArray(jsonString);
totalFlow2=totalFlow2+ jsonObject.getInteger("total_flow"); for (Object item : jsonArray) {
JSONObject jsonObject = (JSONObject) item;
totalFlow2 = totalFlow2 + jsonObject.getInteger("total_flow");
}
} }
} }
return totalFlow1+totalFlow2; return totalFlow1 + totalFlow2;
} }
private Response getResponseTrafficFlowAtToll(String startDate,String stationType) throws HttpException, IOException { private Response getResponseTrafficFlowAtToll(String startDate, String stationType) throws HttpException, IOException {
OkHttp okHttp = new OkHttp(); OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams(); RequestParams requestParams = new RequestParams();

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

@ -7,6 +7,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
@ -71,8 +74,7 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
*/ */
@ApiOperation("外部接口监控信息列表") @ApiOperation("外部接口监控信息列表")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(ExternalInterfaceMonitoring externalInterfaceMonitoring) public TableDataInfo list(ExternalInterfaceMonitoring externalInterfaceMonitoring) {
{
startPage(); startPage();
LambdaQueryWrapper<ExternalInterfaceMonitoring> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ExternalInterfaceMonitoring> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if (externalInterfaceMonitoring.getInterfaceOwnership() != null) { if (externalInterfaceMonitoring.getInterfaceOwnership() != null) {
@ -578,10 +580,10 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
externalInterfaceMonitoring.setOperationResult(response.toString()); externalInterfaceMonitoring.setOperationResult(response.toString());
} }
}catch (Exception e) { } catch (Exception e) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
externalInterfaceMonitoring.setOperationResult(e.toString()); externalInterfaceMonitoring.setOperationResult(e.toString());
}finally { } finally {
externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID());
externalInterfaceMonitoring.setOperatorName("系统"); externalInterfaceMonitoring.setOperatorName("系统");
externalInterfaceMonitoring.setOperationTime(new Date()); externalInterfaceMonitoring.setOperationTime(new Date());
@ -594,15 +596,30 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
* 交通流结果处理 * 交通流结果处理
*/ */
public void trafficFlowResultProcessing(ExternalInterfaceMonitoring externalInterfaceMonitoring, Response response) throws Exception { public void trafficFlowResultProcessing(ExternalInterfaceMonitoring externalInterfaceMonitoring, Response response) throws Exception {
ResponseBody body = response.body(); ResponseBody body = response.body();
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); if (response.code() == UniversalEnum.TWO_HUNDRED.getNumber()) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber());
} else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
}
if (body != null) { if (body != null) {
JSONObject jsonResult = JSONObject.parseObject(body.string()); String bodyString = body.string();
if (jsonResult.containsKey("code") && jsonResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) { JsonObject jsonResult = null;
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber()); // 使用JsonElement解析数据
JsonElement jsonElement = JsonParser.parseString(bodyString);
// 检查数据类型并相应处理
if (jsonElement.isJsonObject()) {
// 如果是对象,进行对象处理
jsonResult = jsonElement.getAsJsonObject();
if (!jsonResult.get("code").toString().equals(UniversalEnum.TWO_HUNDRED.getValue())) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
}
} }
externalInterfaceMonitoring.setOperationResult(body.string()); externalInterfaceMonitoring.setOperationResult(bodyString);
} else { } else {
externalInterfaceMonitoring.setOperationResult(response.toString()); externalInterfaceMonitoring.setOperationResult(response.toString());
} }

2
zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

@ -158,7 +158,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
<if test="deviceState != null and deviceState != ''">and device_state = #{deviceState}</if> <if test="deviceState != null and deviceState != ''">and device_state = #{deviceState}</if>
<if test="deviceName != null and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')</if> <if test="deviceName != null and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')</if>
<if test="deviceType != null and deviceType != ''">and device_type = #{deviceType}</if> <if test="deviceType != null and deviceType != ''">and device_type = #{deviceType} and iot_device_id is not null</if>
<if test="deviceType == null || deviceType == ''"> <if test="deviceType == null || deviceType == ''">
and (device_type=3||device_type=13||device_type=15||device_type=16) and iot_device_id is not null and (device_type=3||device_type=13||device_type=15||device_type=16) and iot_device_id is not null
</if> </if>

Loading…
Cancel
Save