Browse Source

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

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

48
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()) { if (response.code() == UniversalEnum.TWO_HUNDRED.getNumber()) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber());
if (response.body() != null) { if (response.body() != null) {
JSONArray array = DcNmcController.parseHtmlContent(response.body().string()); ResponseBody body = response.body();
externalInterfaceMonitoring.setOperationResult(JSON.toJSONString(array)); // 存储 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 { } else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
@ -657,7 +662,7 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
Response response = getRequestByHeadersByParam(header, Response response = getRequestByHeadersByParam(header,
cameraInfo.getString("URL") + UniversalEnum.GET_CAMERA_INFORMATION_BY_ORGANIZATION.getValue(), cameraInfo.getString("URL") + UniversalEnum.GET_CAMERA_INFORMATION_BY_ORGANIZATION.getValue(),
requestParams); requestParams);
//插入 //插入
videoResultInsertInto(externalInterfaceMonitoring, response); videoResultInsertInto(externalInterfaceMonitoring, response);
} catch (Exception e) { } catch (Exception e) {
externalInterfaceMonitoring.setOperationResult(e.getMessage()); externalInterfaceMonitoring.setOperationResult(e.getMessage());
@ -744,7 +749,9 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
} else { } else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); 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 { } else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
externalInterfaceMonitoring.setOperationResult(response.toString()); externalInterfaceMonitoring.setOperationResult(response.toString());
@ -766,11 +773,15 @@ 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()) { if (response.code() == UniversalEnum.TWO_HUNDRED.getNumber()) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.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 { } else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
} }
@ -785,11 +796,11 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
if (jsonElement.isJsonObject()) { if (jsonElement.isJsonObject()) {
// 如果是对象,进行对象处理 // 如果是对象,进行对象处理
jsonResult = jsonElement.getAsJsonObject(); jsonResult = jsonElement.getAsJsonObject();
if (!jsonResult.get("code").toString().equals(UniversalEnum.TWO_HUNDRED.getValue())) { if (!jsonResult.get("code").toString().equals(UniversalEnum.TWO_HUNDRED.getValue())) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
} }
} }
externalInterfaceMonitoring.setOperationResult(bodyString);
} else { } else {
externalInterfaceMonitoring.setOperationResult(response.toString()); externalInterfaceMonitoring.setOperationResult(response.toString());
} }
@ -805,7 +816,10 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
*/ */
public void insertIntoExternalInterface(ExternalInterfaceMonitoring externalInterfaceMonitoring, Response response) throws Exception { public void insertIntoExternalInterface(ExternalInterfaceMonitoring externalInterfaceMonitoring, Response response) throws Exception {
ResponseBody body = response.body(); 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()) { if (response.code() == UniversalEnum.TWO_HUNDRED.getNumber()) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber());
} else { } else {
@ -813,9 +827,9 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
} }
if (body != null) { if (body != null) {
externalInterfaceMonitoring.setOperationResult(body.string()); externalInterfaceMonitoring.setOperationResult(newJson.toJSONString());
} else { } else {
externalInterfaceMonitoring.setOperationResult(response.toString()); externalInterfaceMonitoring.setOperationResult(newJson.toJSONString());
} }
externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID());
@ -834,12 +848,19 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
public void videoResultInsertInto(ExternalInterfaceMonitoring externalInterfaceMonitoring, Response response) throws Exception { public void videoResultInsertInto(ExternalInterfaceMonitoring externalInterfaceMonitoring, Response response) throws Exception {
ResponseBody body = response.body(); ResponseBody body = response.body();
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
if (body != null) { if (body != null) {
JSONObject jsonResult = JSONObject.parseObject(body.string()); 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())) { if (jsonResult.containsKey("code") && jsonResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber());
} }
externalInterfaceMonitoring.setOperationResult(JSON.toJSONString(jsonResult)); externalInterfaceMonitoring.setOperationResult(newJson.toJSONString());
} else { } else {
externalInterfaceMonitoring.setOperationResult(response.toString()); externalInterfaceMonitoring.setOperationResult(response.toString());
} }
@ -888,7 +909,10 @@ public class ExternalInterfaceMonitoringTask extends BaseController {
public void resultAnalysis(AjaxResult ajaxResult, ExternalInterfaceMonitoring externalInterfaceMonitoring) { public void resultAnalysis(AjaxResult ajaxResult, ExternalInterfaceMonitoring externalInterfaceMonitoring) {
if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) { if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.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 { } else {
externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber());
externalInterfaceMonitoring.setOperationResult(ajaxResult.get("msg").toString()); externalInterfaceMonitoring.setOperationResult(ajaxResult.get("msg").toString());

Loading…
Cancel
Save