Browse Source

修改交通流监测相关代码

develop
Mr.Wang 5 months ago
parent
commit
058c64257f
  1. 2
      zc-business/src/main/java/com/zc/business/domain/ExternalInterfaceMonitoring.java
  2. 29
      zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java

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;
} }

29
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) {
@ -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();
if (response.code() == UniversalEnum.TWO_HUNDRED.getNumber()) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber());
} else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); 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());
} }

Loading…
Cancel
Save