Browse Source

外部接口检测,存储结果修改

develop
王兴琳 7 days ago
parent
commit
c9e674b7de
  1. 46
      zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java

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

@ -414,8 +414,13 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
if (response.code() == UniversalEnum.TWO_HUNDRED.getNumber()) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber());
if (response.body() != null) {
JSONArray array = DcNmcController.parseHtmlContent(response.body().string());
externalInterfaceMonitoring.setOperationResult(JSON.toJSONString(array));
ResponseBody body = response.body();
// 存储 msg 和 code
JSONObject newJson = new JSONObject();
newJson.put("msg", response.message());
newJson.put("code", response.code());
// JSONArray array = DcNmcController.parseHtmlContent(response.body().string());
externalInterfaceMonitoring.setOperationResult(newJson.toJSONString());
}
} else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
@ -744,7 +749,9 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
} else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
}
externalInterfaceMonitoring.setOperationResult(JSON.toJSONString(jsonResult));
JSONObject newJson = new JSONObject();
newJson.put("code", jsonResult.get("retCode"));
externalInterfaceMonitoring.setOperationResult(newJson.toJSONString());
} else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
externalInterfaceMonitoring.setOperationResult(response.toString());
@ -766,11 +773,15 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
* 交通流结果处理
*/
public void trafficFlowResultProcessing(ExternalInterfaceMonitoring externalInterfaceMonitoring, Response response) throws Exception {
ResponseBody body = response.body();
if (response.code() == UniversalEnum.TWO_HUNDRED.getNumber()) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber());
// 存储 msg 和 code
JSONObject newJson = new JSONObject();
newJson.put("msg", response.message());
newJson.put("code",response.code());
externalInterfaceMonitoring.setOperationResult(newJson.toJSONString());
} else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
}
@ -785,11 +796,11 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
if (jsonElement.isJsonObject()) {
// 如果是对象,进行对象处理
jsonResult = jsonElement.getAsJsonObject();
if (!jsonResult.get("code").toString().equals(UniversalEnum.TWO_HUNDRED.getValue())) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
}
}
externalInterfaceMonitoring.setOperationResult(bodyString);
} else {
externalInterfaceMonitoring.setOperationResult(response.toString());
}
@ -805,7 +816,10 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
*/
public void insertIntoExternalInterface(ExternalInterfaceMonitoring externalInterfaceMonitoring, Response response) throws Exception {
ResponseBody body = response.body();
// 存储 msg 和 code
JSONObject newJson = new JSONObject();
newJson.put("msg", response.message());
newJson.put("code", response.code());
if (response.code() == UniversalEnum.TWO_HUNDRED.getNumber()) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber());
} else {
@ -813,9 +827,9 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
}
if (body != null) {
externalInterfaceMonitoring.setOperationResult(body.string());
externalInterfaceMonitoring.setOperationResult(newJson.toJSONString());
} else {
externalInterfaceMonitoring.setOperationResult(response.toString());
externalInterfaceMonitoring.setOperationResult(newJson.toJSONString());
}
externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID());
@ -834,12 +848,19 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
public void videoResultInsertInto(ExternalInterfaceMonitoring externalInterfaceMonitoring, Response response) throws Exception {
ResponseBody body = response.body();
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
if (body != null) {
JSONObject jsonResult = JSONObject.parseObject(body.string());
Object msg = jsonResult.get("msg");
Object code = jsonResult.get("code");
// 存储 msg 和 code
JSONObject newJson = new JSONObject();
newJson.put("msg", msg);
newJson.put("code", code);
if (jsonResult.containsKey("code") && jsonResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber());
}
externalInterfaceMonitoring.setOperationResult(JSON.toJSONString(jsonResult));
externalInterfaceMonitoring.setOperationResult(newJson.toJSONString());
} else {
externalInterfaceMonitoring.setOperationResult(response.toString());
}
@ -888,7 +909,10 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
public void resultAnalysis(AjaxResult ajaxResult, ExternalInterfaceMonitoring externalInterfaceMonitoring) {
if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber());
externalInterfaceMonitoring.setOperationResult(JSON.toJSONString(ajaxResult.get("data")));
JSONObject newJson = new JSONObject();
newJson.put("msg", ajaxResult.get("msg"));
newJson.put("code", ajaxResult.get("code"));
externalInterfaceMonitoring.setOperationResult(JSON.toJSONString(newJson.toJSONString()));
} else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
externalInterfaceMonitoring.setOperationResult(ajaxResult.get("msg").toString());

Loading…
Cancel
Save