|
|
@ -7,6 +7,9 @@ import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
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.domain.AjaxResult; |
|
|
|
import com.ruoyi.common.core.page.TableDataInfo; |
|
|
@ -71,8 +74,7 @@ public class ExternalInterfaceMonitoringTask extends BaseController { |
|
|
|
*/ |
|
|
|
@ApiOperation("外部接口监控信息列表") |
|
|
|
@GetMapping("/list") |
|
|
|
public TableDataInfo list(ExternalInterfaceMonitoring externalInterfaceMonitoring) |
|
|
|
{ |
|
|
|
public TableDataInfo list(ExternalInterfaceMonitoring externalInterfaceMonitoring) { |
|
|
|
startPage(); |
|
|
|
LambdaQueryWrapper<ExternalInterfaceMonitoring> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
if (externalInterfaceMonitoring.getInterfaceOwnership() != null) { |
|
|
@ -578,10 +580,10 @@ public class ExternalInterfaceMonitoringTask extends BaseController { |
|
|
|
externalInterfaceMonitoring.setOperationResult(response.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
}catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); |
|
|
|
externalInterfaceMonitoring.setOperationResult(e.toString()); |
|
|
|
}finally { |
|
|
|
} finally { |
|
|
|
externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); |
|
|
|
externalInterfaceMonitoring.setOperatorName("系统"); |
|
|
|
externalInterfaceMonitoring.setOperationTime(new Date()); |
|
|
@ -594,15 +596,30 @@ public class ExternalInterfaceMonitoringTask extends BaseController { |
|
|
|
* 交通流结果处理 |
|
|
|
*/ |
|
|
|
public void trafficFlowResultProcessing(ExternalInterfaceMonitoring externalInterfaceMonitoring, Response response) throws Exception { |
|
|
|
|
|
|
|
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) { |
|
|
|
JSONObject jsonResult = JSONObject.parseObject(body.string()); |
|
|
|
if (jsonResult.containsKey("code") && jsonResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) { |
|
|
|
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber()); |
|
|
|
String bodyString = body.string(); |
|
|
|
JsonObject jsonResult = null; |
|
|
|
// 使用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 { |
|
|
|
externalInterfaceMonitoring.setOperationResult(response.toString()); |
|
|
|
} |
|
|
|