From aaab1b20b33c5d2e63144ecdf0967dde3e0014d5 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Mon, 15 Jul 2024 14:27:04 +0800 Subject: [PATCH 01/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E5=AD=98=E5=82=A8=E5=88=B0=E7=AE=A1=E6=8E=A7?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9A=84=E5=AD=98=E5=82=A8=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DcEmergencyPlansServiceImpl.java | 70 +++++++++++++------ 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java index 0aec039c..ad6b7fee 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java @@ -880,8 +880,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { // functions List> functionList = new ArrayList<>(); - remark.append(device.getDeviceName()); - remark.append(UniversalEnum.INVOKE.getValue()); try { if (device.getDeviceType().equals(DeviceTypeConstants.DRIVING_GUIDANCE.toString())) { // 行车诱导 @@ -899,11 +897,23 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { props.put("startDisplayTime", startTime); props.put("endDisplayTime", endTime); result.put("content", "自动:" + stateName + ";时间范围:" + startTime + UniversalEnum.SHORT_BAR.getValue() + endTime); + remark.append("时间自动控制模式:"); + remark.append(startTime); + remark.append("-"); + remark.append(endTime); } else if (controlModel.equals(UniversalEnum.ZERO_ZERO.getValue())) { result.put("content", "手动:" + stateName); + remark.append("远程手动控制模式"); } else { result.put("content", "万年历:" + stateName); + remark.append("万年历自动控制模式"); } + remark.append(":"); + remark.append("上行:"); + remark.append(otherConfig.get("name").toString()); + remark.append(","); + remark.append("下行:"); + remark.append(otherConfig.get("name").toString()); result.put("device", device.getId()); result.put("deviceName", device.getDeviceName()); result.put("deviceType", device.getDeviceType()); @@ -918,7 +928,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } else { status = UniversalEnum.ONE.getNumber(); } - remark.append(UniversalEnum.DEVICE_CONTROL_MODE.getValue()); result.put("result", ajaxResult); dcOperLog.add(result); resultArray.add(result); @@ -956,11 +965,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { jsonObject.get("dcDeviceId").toString().equals(device.getId().toString())) .findFirst() .orElse(null); - remark.append(UniversalEnum.FILE_NAME_SENDING.getValue()); - remark.append("、"); - remark.append(UniversalEnum.FILE_SENDING.getValue()); - remark.append("、"); - remark.append(UniversalEnum.SPECIFIES_THE_LIST_THAT_CURRENTLY_NEEDS_TO_BE_PLAYED.getValue()); if (foundContent == null) { // 说明没有匹配到设备 JSONObject errorResult = new JSONObject(); @@ -975,10 +979,11 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { resultArray.add(result); dcOperLog.add(result); status = UniversalEnum.ONE.getNumber(); + remark.append(errorResult.get("content")); } else { JSONObject jsonObject = new JSONObject(); jsonObject.put("dcInfoBoardTemplate", foundContent); - status = boardReleaseProcess(props, iotDeviceId, jsonObject, device, resultArray, functionList, dcOperLog); + status = boardReleaseProcess(props, iotDeviceId, jsonObject, device, resultArray, functionList, dcOperLog, remark); } } @@ -1010,6 +1015,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { errorResult.put("result",resu); dcOperLog.add(errorResult); resultArray.add(errorResult); + remark.append(errorResult.get("content")); }else { if (StringUtils.isEmpty(foundContent.getString("content"))) { params.put("text", UniversalEnum.WELCOME_TO_SHANDONG_EXPRESSWAY.getValue()); @@ -1028,8 +1034,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { result.put("deviceName", device.getDeviceName()); result.put("deviceType", device.getDeviceType()); result.put("content", params.get("text")); - - remark.append(UniversalEnum.RELEASE_VOICE_BROADCAST.getValue()); + remark.append(result.get("content")); processingDeviceParameters(UniversalEnum.A_ONE.getValue(), functionList, params); @@ -1049,17 +1054,27 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } else if (device.getDeviceType().equals(DeviceTypeConstants.LASER_FATIGUE_AWAKENING.toString())) { // 激光疲劳唤醒 - HashMap map = new HashMap<>(); - map.put(UniversalEnum.SET.getValue(), otherConfig.get("operationType").toString()); + + // 查看当前设备控制的状态 + JSONObject mdJSONObject = (JSONObject) JSON.toJSON(dcDeviceController.getDeviceLatestProperty(iotDeviceId, "MD").get("data")); + String mdValue = mdJSONObject.containsKey("value")? mdJSONObject.getString("value") : null; + + JSONObject tmJSONObject = (JSONObject) JSON.toJSON(dcDeviceController.getDeviceLatestProperty(iotDeviceId, "TM").get("data")); + String tmValue = tmJSONObject.containsKey("value")? tmJSONObject.getString("value") : null; + JSONObject resultTime = new JSONObject(); resultTime.put("device", device.getId()); resultTime.put("deviceName", device.getDeviceName()); resultTime.put("deviceType", device.getDeviceType()); - remark.append(UniversalEnum.MODE_SETTING_COMMAND.getValue()); - remark.append("、"); - remark.append(UniversalEnum.WORK_TIME_SETTING_COMMAND.getValue()); + remark.append(otherConfig.get("name").toString()); + remark.append(","); + remark.append(otherConfig.get("operationDuration")); + remark.append(UniversalEnum.MINUTES.getValue()); + HashMap map = new HashMap<>(); + map.put(UniversalEnum.SET.getValue(), otherConfig.get("operationType").toString()); + // 调用设备参数存储格式 processingDeviceParameters(UniversalEnum.SETMD.getValue(), functionList, map); AjaxResult ajaxResultState = dcDeviceController.getAjaxResult(iotDeviceId, UniversalEnum.SETMD.getValue(), map); @@ -1074,6 +1089,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_SETTM; resultTime.put("content", "状态:" + name + ";操作时长" + otherConfig.get("operationDuration") + UniversalEnum.MINUTES.getValue()); + // 调用设备参数存储格式 processingDeviceParameters(functionId, functionList, propsTime); AjaxResult ajaxResult = dcDeviceController.getAjaxResult(iotDeviceId, functionId, propsTime); @@ -1085,6 +1101,15 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { status = UniversalEnum.ZERO.getNumber(); } else { status = UniversalEnum.ONE.getNumber(); + // 模拟事务,回滚设备当前的使用状态 + if (!ajaxResultState.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber()) && mdValue != null) { + map.put(UniversalEnum.SET.getValue(), mdValue); + dcDeviceController.getAjaxResult(iotDeviceId, UniversalEnum.SETMD.getValue(), map); + } + if (!ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber()) && tmValue != null) { + propsTime.put(UniversalEnum.SET.getValue(), UniversalEnum.SETTM.getValue() + tmValue); + dcDeviceController.getAjaxResult(iotDeviceId, DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_SETTM, propsTime); + } } } @@ -1098,7 +1123,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } catch (HttpException | IOException e) { log.error(e.toString()); - throw new RuntimeException(e); } } @@ -1126,7 +1150,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { DcDevice device, JSONArray resultArray, List> functionList, - JSONArray dcOperLog + JSONArray dcOperLog, + StringBuilder remark ) throws HttpException, IOException { String functionId = UniversalEnum.EMPTY_STRING.getValue(); Integer status = UniversalEnum.ZERO.getNumber(); @@ -1138,13 +1163,14 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { props.put("size", UniversalEnum.SIXTY_FIVE_THOUSAND_FIVE_HUNDRED_THIRTY_FIVE.getValue()); processingDeviceParameters(functionId, functionList, props); - - AjaxResult ajaxResult11 = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props); - dcOperLog.add(getDcOperLog(device,ajaxResult11)); - // 13功能码执行参数构造 DcInfoBoardTemplate dcInfoBoardTemplate = JSON.parseObject( JSON.toJSONString(otherConfig.get("dcInfoBoardTemplate")), DcInfoBoardTemplate.class); + remark.append(dcInfoBoardTemplate.getContent()); + AjaxResult ajaxResult11 = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props); + dcOperLog.add(getDcOperLog(device,ajaxResult11)); + // 13功能码执行参数构造 + HashMap props11 = new HashMap<>(); functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_13; List> list = new ArrayList<>(); From 6f2416a509421c339be6b144036976360f282716 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Mon, 15 Jul 2024 15:49:26 +0800 Subject: [PATCH 02/28] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9F=A5=E8=AF=A2=E5=8F=AA=E8=83=BD=E6=9F=A5?= =?UTF-8?q?=E8=AF=A231=E5=A4=A9=E9=97=AE=E9=A2=98=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=AE=A1=E6=8E=A7=E8=AE=B0=E5=BD=95=E6=8F=8F=E8=BF=B0=E5=86=85?= =?UTF-8?q?=E5=AE=B9=20=E4=BC=98=E5=8C=96=E8=AE=BE=E5=A4=87=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcDeviceController.java | 145 +++++++-- .../interfaces/OperationLogAspect.java | 288 ++++++++++++++++-- .../mapper/business/StatusMapper.xml | 2 +- 3 files changed, 385 insertions(+), 50 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java index b1cdbaac..48da7ae8 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java @@ -534,22 +534,102 @@ public class DcDeviceController extends BaseController { JSONObject device = (JSONObject) JSON.toJSON(dev); //JSONObject device = (JSONObject) JSON.toJSON(dev.toString()); String iotDeviceId = device.getString("iotDeviceId"); - for (Object function : functions) { - JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function); - //JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function.toString()) ; - String functionId = functionJSONObject.getString("functionId"); - JSONObject jsonObject = functionJSONObject.getJSONObject("params") != null ? functionJSONObject.getJSONObject("params") : new JSONObject(); - JSONObject result = getResult(device, iotDeviceId, functionId, jsonObject); - resultArray.add(result); - AjaxResult ajaxResult = (AjaxResult) result.get("result"); - if (!Objects.equals(String.valueOf(ajaxResult.get("code")), UniversalEnum.TWO_HUNDRED.getValue())) { - if (Objects.equals(device.getString("deviceType"), UniversalEnum.FIFTEEN.getValue())) { - return AjaxResult.error(UniversalEnum.TWO_HUNDRED.getNumber(), UniversalEnum.FIVE_HUNDRED.getValue()); + String deviceType = device.getString("deviceType"); + boolean continueToExecute = true; + if (Objects.equals(deviceType, "10")) { + + JSONObject mdJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, "MD").get("data")); + + String mdValue = mdJSONObject.getString("value"); + + JSONObject tmJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, "TM").get("data")); + + String tmValue = tmJSONObject.getString("value"); + + for (Object function : functions) { + JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function); + //JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function.toString()) ; + String functionId = functionJSONObject.getString("functionId"); + if (continueToExecute) { + JSONObject jsonObject = functionJSONObject.getJSONObject("params") != null ? functionJSONObject.getJSONObject("params") : new JSONObject(); + JSONObject result = getResult(device, iotDeviceId, functionId, jsonObject); + resultArray.add(result); + AjaxResult ajaxResult = (AjaxResult) result.get("result"); + if (!Objects.equals(String.valueOf(ajaxResult.get("code")), UniversalEnum.TWO_HUNDRED.getValue())) { + continueToExecute = false; + if (Objects.equals(device.getString("deviceType"), UniversalEnum.FIFTEEN.getValue())) { + return AjaxResult.error(UniversalEnum.TWO_HUNDRED.getNumber(), UniversalEnum.FIVE_HUNDRED.getValue()); + } + } } else { - //return AjaxResult.success(resultArray); + List collect = resultArray.stream().filter(item -> Objects.equals(((JSONObject) JSON.toJSON(item)).getString("device"), device.getString("id"))).collect(Collectors.toList()); + if (collect.size() == 0) { + JSONObject result = new JSONObject(); + result.put("device", device.getString("id")); + result.put("deviceType", device.getInteger("deviceType")); + result.put("functionId", functionId); + result.put("result", AjaxResult.error()); + resultArray.add(result); + } else { + for (int i = 0; i < resultArray.size(); i++) { + JSONObject jsonObject = (JSONObject) JSON.toJSON(resultArray.get(i)); + if (!Objects.equals(jsonObject.getString("device"), device.getString("id"))) { + JSONObject result = jsonObject.getJSONObject("result"); + if (!Objects.equals(result.getString("code"), "200")) { + break; + } else { + result.put("code", "500"); + jsonObject.put("result", result); + resultArray.add(i, jsonObject); + } + } else { + break; + } + } + + } + if (Objects.equals(functionId, "SETMD")) { + JSONObject jsonObjectMD = new JSONObject(); + jsonObjectMD.put("SET", mdValue); + getAjaxResult(iotDeviceId, functionId, jsonObjectMD.toJavaObject(new TypeReference>() { + })); + } + if (Objects.equals(functionId, "SETTM")) { + JSONObject jsonObjectTM = new JSONObject(); + jsonObjectTM.put("SET", tmValue); + getAjaxResult(iotDeviceId, functionId, jsonObjectTM.toJavaObject(new TypeReference>() { + })); + } + } + } + } else { + + for (Object function : functions) { + JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function); + //JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function.toString()) ; + String functionId = functionJSONObject.getString("functionId"); + if (continueToExecute) { + JSONObject jsonObject = functionJSONObject.getJSONObject("params") != null ? functionJSONObject.getJSONObject("params") : new JSONObject(); + //JSONObject result = getResult(device, iotDeviceId, functionId, jsonObject); + //resultArray.add(result); + //AjaxResult ajaxResult = (AjaxResult) result.get("result"); + //if (!Objects.equals(String.valueOf(ajaxResult.get("code")), UniversalEnum.TWO_HUNDRED.getValue())) { + // continueToExecute = false; + // if (Objects.equals(device.getString("deviceType"), UniversalEnum.FIFTEEN.getValue())) { + // return AjaxResult.error(UniversalEnum.TWO_HUNDRED.getNumber(), UniversalEnum.FIVE_HUNDRED.getValue()); + // } + //} + } else { + JSONObject result = new JSONObject(); + result.put("device", device.getString("id")); + result.put("deviceType", device.getInteger("deviceType")); + result.put("functionId", functionId); + result.put("result", AjaxResult.error()); + resultArray.add(result); } } } + } return AjaxResult.success(resultArray); } @@ -561,22 +641,22 @@ public class DcDeviceController extends BaseController { result.put("device", device.getString("id")); result.put("deviceType", device.getInteger("deviceType")); result.put("functionId", functionId); - if (device.getInteger("deviceType").equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) { - JSONObject value = broadcastController.nearCamListDistance(jsonObject); - AjaxResult ajaxResult = new AjaxResult(); - value.keySet().forEach(item -> { - ajaxResult.put(item, value.getString(item)); - }); - if (Objects.equals(String.valueOf(ajaxResult.get("retCode")), UniversalEnum.ZERO.getValue())){ - ajaxResult.put("code", UniversalEnum.TWO_HUNDRED.getNumber()); - }else { - ajaxResult.put("code", UniversalEnum.FIVE_HUNDRED.getNumber()); - } - - result.put("result", ajaxResult); - } else { - result.put("result", getAjaxResult(iotDeviceId, functionId, params)); - } + //if (device.getInteger("deviceType").equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) { + // JSONObject value = broadcastController.nearCamListDistance(jsonObject); + // AjaxResult ajaxResult = new AjaxResult(); + // value.keySet().forEach(item -> { + // ajaxResult.put(item, value.getString(item)); + // }); + // if (Objects.equals(String.valueOf(ajaxResult.get("retCode")), UniversalEnum.ZERO.getValue())) { + // ajaxResult.put("code", UniversalEnum.TWO_HUNDRED.getNumber()); + // } else { + // ajaxResult.put("code", UniversalEnum.FIVE_HUNDRED.getNumber()); + // } + // + // result.put("result", ajaxResult); + //} else { + // result.put("result", getAjaxResult(iotDeviceId, functionId, params)); + //} return result; } @@ -798,8 +878,8 @@ public class DcDeviceController extends BaseController { results.sort(Comparator.comparing(hashMap -> hashMap.get("timestamp"))); return AjaxResult.success(results); } - if (UniversalEnum.THREE.getValue().equals(deviceType)||UniversalEnum.SEVENTEEN.getValue().equals(deviceType)|| - UniversalEnum.FIFTEEN.getValue().equals(deviceType)){ //气象预警/ups设备/太阳能板 + if (UniversalEnum.THREE.getValue().equals(deviceType) || UniversalEnum.SEVENTEEN.getValue().equals(deviceType) || + UniversalEnum.FIFTEEN.getValue().equals(deviceType)) { //气象预警/ups设备/太阳能板 JSONObject data = (JSONObject) ajaxResult.get("data"); JSONArray dataValue = (JSONArray) data.get("data"); List jsonObjectList = dataValue.toJavaList(JSONObject.class); @@ -831,10 +911,11 @@ public class DcDeviceController extends BaseController { String key = configService.selectConfigByKey(UniversalEnum.SBX_FUN_KL.getValue());//密钥 return AjaxResult.success(key.equals(secretKey)); } + //设备分析 @PostMapping("/properties/deviceAnalysis") public AjaxResult deviceAnalysis(@RequestBody HashMap map) throws IOException, HttpException { - if (map==null||!map.containsKey("deviceId")||!map.containsKey("deviceType") ||!map.containsKey("dateTime")){ + if (map == null || !map.containsKey("deviceId") || !map.containsKey("deviceType") || !map.containsKey("dateTime")) { return AjaxResult.error(UniversalEnum.PARAMETER_ERROR.getValue()); } String type = map.get("deviceType").toString();//设备类型 @@ -860,7 +941,7 @@ public class DcDeviceController extends BaseController { props.put("sorts[0].order", "asc"); props.put("sorts[0].name", "timestamp"); List> mapList = dcDeviceService.selectDeviceParameterProperties(dcDevice);//属性的参数信息 - List resultsMapValue=new ArrayList<>(); + List resultsMapValue = new ArrayList<>(); for (HashMap hashMap : mapList) { HashMap resultsMap = new HashMap<>(); String name = hashMap.get("name").toString();//属性名称 diff --git a/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java b/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java index ff8670b4..6854137e 100644 --- a/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java +++ b/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java @@ -81,6 +81,7 @@ public class OperationLogAspect { put(UniversalEnum.THREE_C.getValue(), UniversalEnum.READ_THE_CURRENT_DEVICE_STATUS.getValue()); }}); put(UniversalEnum.THIRTEEN.getValue(), new HashMap() {{ + put("102", "设备开关"); }}); put(UniversalEnum.FOURTEEN.getValue(), new HashMap() {{ }}); @@ -93,6 +94,7 @@ public class OperationLogAspect { put(UniversalEnum.A_SIX.getValue(), UniversalEnum.QUERY_DATA.getValue()); }}); put(UniversalEnum.SIXTEEN.getValue(), new HashMap() {{ + put("102", "设备开关"); }}); }}; @@ -104,7 +106,7 @@ public class OperationLogAspect { @AfterThrowing(value = "@annotation(operationLog)", throwing = "e") public void AfterThrowing(JoinPoint joinPoint, OperationLog operationLog, Exception e) throws Throwable { - around((ProceedingJoinPoint) joinPoint, operationLog, UniversalEnum.ONE.getValue(), null, e); + around((ProceedingJoinPoint) joinPoint, operationLog, UniversalEnum.ONE.getValue(), AjaxResult.error(), e); } public void around(ProceedingJoinPoint joinPoint, OperationLog operationLog, String state, Object jsonResult, Exception exception) throws Throwable { @@ -208,21 +210,241 @@ public class OperationLogAspect { return; } - remark.append(deviceName); - String hashMap = Objects.equals(deviceType, UniversalEnum.FIVE.getValue()) ? - UniversalEnum.RELEASE_VOICE_BROADCAST.getValue() : - String.valueOf( - ((HashMap) (DEVICEFUNCTIONNAME.get(deviceType))) - .get(functionId) == null ? - UniversalEnum.UNKNOWN_METHOD.getValue() : - ((HashMap) (DEVICEFUNCTIONNAME.get(deviceType))) - .get(functionId)); + //String hashMap = Objects.equals(deviceType, UniversalEnum.FIVE.getValue()) ? + // UniversalEnum.RELEASE_VOICE_BROADCAST.getValue() : + // String.valueOf( + // ((HashMap) (DEVICEFUNCTIONNAME.get(deviceType))) + // .get(functionId) == null ? + // UniversalEnum.UNKNOWN_METHOD.getValue() : + // ((HashMap) (DEVICEFUNCTIONNAME.get(deviceType))) + // .get(functionId)); + //remark.append(hashMap).append(":"); - remark.append(UniversalEnum.INVOKE.getValue()).append(hashMap).append(UniversalEnum.FEATURE.getValue()); + JSONObject params = function.getJSONObject("params"); - if (i1 < functions.size() - UniversalEnum.ONE.getNumber()) { - remark.append(UniversalEnum.SEMICOLON.getValue()); + + if (Objects.equals(deviceType, "2")) { + + //if (Objects.equals(functionId, UniversalEnum.ELEVEN.getValue())) { + // + // remark.append("文件名称:").append(params.getString("fileName")).append("、文件大小:").append(params.getString("size")).append("KB"); + // + //} else + if (Objects.equals(functionId, UniversalEnum.THIRTEEN.getValue())) { + + JSONArray parameters = params.getJSONArray("parameters"); + + for (int i2 = 0; i2 < parameters.size(); i2++) { + + remark.append(((JSONObject) JSON.toJSON(parameters.get(i2))).getString("CONTENT")); + //remark.append("文件内容:").append(((JSONObject) JSON.toJSON(parameters.get(i2))).getString("CONTENT")); + + if (i2 < parameters.size() - 1) { + remark.append("、"); + } + } + + } + //else if (Objects.equals(functionId, UniversalEnum.ONE_B.getValue())) { + // + // remark.append("文件标识:").append(params.getString("fileId")); + // + //} + + } else if (Objects.equals(deviceType, "5")) { + + remark.append(params.getString("text")); + + } else if (Objects.equals(deviceType, "10")) { + + String set = params.getString("SET"); + if (Objects.equals(functionId, UniversalEnum.SETMD.getValue())) { + + if (Objects.equals(set, "0")) { + + remark.append("关闭"); + + } else if (Objects.equals(set, "1")) { + + remark.append("常亮"); + + } else if (Objects.equals(set, "2")) { + + remark.append("间隔100ms闪烁"); + + } else if (Objects.equals(set, "3")) { + + remark.append("间隔200ms闪烁"); + + } else if (Objects.equals(set, "4")) { + + remark.append("间隔500ms闪烁"); + + } else if (Objects.equals(set, "5")) { + + remark.append("2次闪烁"); + + } else if (Objects.equals(set, "6")) { + + remark.append("SOS"); + + } else if (Objects.equals(set, "7")) { + + remark.append("自定义闪烁时间"); + + } + + remark.append("模式"); + + } else if (Objects.equals(functionId, UniversalEnum.SETTM.getValue())) { + + remark.append(set).append("分钟"); + } + + } else if (Objects.equals(deviceType, "12")) { + + if (Objects.equals(functionId, "51")) { + + //remark.append("模式:"); + + String mode = params.getString("mode"); + + if (Objects.equals(mode, "00")) { + + remark.append("远程手动控制模式:上行:"); + String onWorkStatus = params.getString("onWorkStatus"); + String inWorkStatus = params.getString("inWorkStatus"); + + if (Objects.equals(onWorkStatus, "00")) { + + remark.append("不更新状态,下行:"); + + } else if (Objects.equals(onWorkStatus, "01")) { + + remark.append("常亮,下行:"); + + } else if (Objects.equals(onWorkStatus, "02")) { + + remark.append("流水,下行:"); + + } else if (Objects.equals(onWorkStatus, "03")) { + + remark.append("闪烁,下行:"); + + } else if (Objects.equals(onWorkStatus, "04")) { + + remark.append("关闭,下行:"); + + } + + if (Objects.equals(inWorkStatus, "00")) { + + remark.append("不更新状态"); + + } else if (Objects.equals(inWorkStatus, "01")) { + + remark.append("常亮"); + + } else if (Objects.equals(inWorkStatus, "02")) { + + remark.append("流水"); + + } else if (Objects.equals(inWorkStatus, "03")) { + + remark.append("闪烁"); + + } else if (Objects.equals(inWorkStatus, "04")) { + + remark.append("关闭"); + + } + + } else if (Objects.equals(mode, "01")) { + + remark.append("时间段自动控制模式:") + .append(params.getString("startDisplayTime")) + .append("-") + .append(params.getString("endDisplayTime")); + + } else if (Objects.equals(mode, "02")) { + + remark.append("万年历自动控制模式"); + + } else if (Objects.equals(mode, "03")) { + + remark.append("能见度自动控制模式"); + + } + + } else if (Objects.equals(functionId, "30")) { + + String onWorkStatus = params.getString("onWorkStatus"); + String inWorkStatus = params.getString("inWorkStatus"); + + if (Objects.equals(onWorkStatus, "00")) { + + remark.append("上行:不更新状态,下行:"); + + } else if (Objects.equals(onWorkStatus, "01")) { + + remark.append("上行:常亮,下行:"); + + } else if (Objects.equals(onWorkStatus, "02")) { + + remark.append("上行:流水,下行:"); + + } else if (Objects.equals(onWorkStatus, "03")) { + + remark.append("上行:闪烁,下行:"); + + } else if (Objects.equals(onWorkStatus, "04")) { + + remark.append("上行:关闭,下行:"); + + } + + if (Objects.equals(inWorkStatus, "00")) { + + remark.append("不更新状态"); + + } else if (Objects.equals(inWorkStatus, "01")) { + + remark.append("常亮"); + + } else if (Objects.equals(inWorkStatus, "02")) { + + remark.append("流水"); + + } else if (Objects.equals(inWorkStatus, "03")) { + + remark.append("闪烁"); + + } else if (Objects.equals(inWorkStatus, "04")) { + + remark.append("关闭"); + + } + } + + } + + + //remark.append(deviceName); + + //String hashMap = Objects.equals(deviceType, UniversalEnum.FIVE.getValue()) ? + // UniversalEnum.RELEASE_VOICE_BROADCAST.getValue() : + // String.valueOf( + // ((HashMap) (DEVICEFUNCTIONNAME.get(deviceType))) + // .get(functionId) == null ? + // UniversalEnum.UNKNOWN_METHOD.getValue() : + // ((HashMap) (DEVICEFUNCTIONNAME.get(deviceType))) + // .get(functionId)); + + //remark.append(UniversalEnum.INVOKE.getValue()).append(hashMap).append(UniversalEnum.FEATURE.getValue()); + + if (i1 < functions.size() - UniversalEnum.ONE.getNumber() && !Objects.equals(deviceType, "2")) { + remark.append(UniversalEnum.COMMA.getValue()); } @@ -239,7 +461,7 @@ public class OperationLogAspect { } if (i < (devices.size() - UniversalEnum.ONE.getNumber())) { - remark.append(UniversalEnum.COMMA.getValue()); + remark.append(UniversalEnum.UNDERLINE.getValue()); } } @@ -317,6 +539,8 @@ public class OperationLogAspect { String functionId = String.valueOf(pointArgs[UniversalEnum.ONE.getNumber()]); + JSONObject params = (JSONObject) JSON.toJSON(pointArgs[UniversalEnum.TWO.getNumber()]); + if (Objects.equals(functionId, UniversalEnum.A_ONE.getValue()) || Objects.equals(functionId, UniversalEnum.A_TWO.getValue()) || Objects.equals(functionId, UniversalEnum.A_THREE.getValue()) || @@ -332,9 +556,39 @@ public class OperationLogAspect { return; } - String hashMap = Objects.equals(deviceType, UniversalEnum.FIVE.getValue()) ? UniversalEnum.RELEASE_VOICE_BROADCAST.getValue() : String.valueOf(((HashMap) (DEVICEFUNCTIONNAME.get(deviceType))).get(functionId)); + //String hashMap = Objects.equals(deviceType, UniversalEnum.FIVE.getValue()) + // ? UniversalEnum.RELEASE_VOICE_BROADCAST.getValue() + // : String.valueOf(((HashMap) (DEVICEFUNCTIONNAME.get(deviceType))).get(functionId)); + // + //remark.append(hashMap).append(":"); + if (Objects.equals(deviceType, "13") || Objects.equals(deviceType, "16")) { + + String identification = params.getString("deviceName"); + String value = params.getString("value"); + + if (Objects.equals(identification, "ac_out_1_en")) { + + remark.append("220V 输出 1").append(Objects.equals(value, "1") ? "打开" : "关闭"); + + } else if (Objects.equals(identification, "ac_out_2_en")) { + + remark.append("220V 输出 2").append(Objects.equals(value, "1") ? "打开" : "关闭"); + + } else if (Objects.equals(identification, "dc_out_1_en")) { + + remark.append("12V 输出 1").append(Objects.equals(value, "1") ? "打开" : "关闭"); - remark.append(deviceName).append(UniversalEnum.INVOKE.getValue()).append(hashMap).append(UniversalEnum.FEATURE.getValue()); + } else if (Objects.equals(identification, "dc_out_2_en")) { + + remark.append("12V 输出 2").append(Objects.equals(value, "1") ? "打开" : "关闭"); + + } else if (Objects.equals(identification, "fan_out_en")) { + + remark.append("风扇").append(Objects.equals(value, "1") ? "打开" : "关闭"); + + } + + } if (loginUser != null) { SysDept sysDept = deptService.selectDeptById(loginUser.getDeptId()); @@ -396,7 +650,7 @@ public class OperationLogAspect { operLog.setOperTime(new Date()); operLog.setDcDeviceType(deviceType); operLog.setRemark(remark.toString()); - operLog.setJsonResult(jsonResult.toJSONString()); + operLog.setJsonResult(jsonResult != null ? jsonResult.toJSONString() : AjaxResult.error().toString()); dcOperLogService.save(operLog); } } diff --git a/zc-business/src/main/resources/mapper/business/StatusMapper.xml b/zc-business/src/main/resources/mapper/business/StatusMapper.xml index 6d9e9f7d..33bd42dd 100644 --- a/zc-business/src/main/resources/mapper/business/StatusMapper.xml +++ b/zc-business/src/main/resources/mapper/business/StatusMapper.xml @@ -261,7 +261,7 @@ GROUP BY d.child_type, d.device_type, - DAY (s.time) + DATE_FORMAT(s.time, '%Y-%m-%d') ORDER BY ${status.orderByField} ${status.orderDirection} From 08757b5cabc6611282bfea233c7eac3b809adec8 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Mon, 15 Jul 2024 16:23:04 +0800 Subject: [PATCH 03/28] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E7=BB=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcBatchFunctionsJobGroupController.java | 16 +++++++++++ .../domain/DcBatchFunctionsJobGroup.java | 5 ++++ .../IDcBatchFunctionsJobGroupService.java | 2 ++ .../DcBatchFunctionsJobGroupServiceImpl.java | 28 +++++++++++++++++-- 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobGroupController.java b/zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobGroupController.java index e4b043a9..f3835775 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobGroupController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobGroupController.java @@ -86,6 +86,22 @@ public class DcBatchFunctionsJobGroupController extends BaseController { return AjaxResult.success(dcBatchFunctionsJobGroupService.addDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup)); } + + + /** + * 新增 + * + * @param dcBatchFunctionsJobGroup 新增参数 + * @return 新增操作结果 + */ + @ApiOperation("新增") + //@PreAuthorize("@ss.hasPermi('iot:facility:add')") + @Log(title = "新增", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult adddcBatchFunctionsJobGroupAnddcBatchFunctionsJob(@Valid @RequestBody DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException { + return AjaxResult.success(dcBatchFunctionsJobGroupService.adddcBatchFunctionsJobGroupAnddcBatchFunctionsJob(dcBatchFunctionsJobGroup)); + } + /** * 修改 * diff --git a/zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java b/zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java index 1945506a..b1e67209 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java @@ -1,12 +1,15 @@ package com.zc.business.domain; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.ArrayList; import java.util.Date; +import java.util.List; @Data @ApiModel(value = "DcBatchFunctionsJobGroup", description = "定时任务组实体") @@ -30,4 +33,6 @@ public class DcBatchFunctionsJobGroup { private Date updateBy; @ApiModelProperty("修改时间") private Date updateTime; + @TableField(exist = false) + private List dcBatchFunctionsJobList; } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java b/zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java index 9dda4855..701bc6d7 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java @@ -50,4 +50,6 @@ public interface IDcBatchFunctionsJobGroupService extends IService listDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup); boolean changeStatus(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException; + + DcBatchFunctionsJobGroup adddcBatchFunctionsJobGroupAnddcBatchFunctionsJob(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException; } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java index a9f91a3b..c0412f2d 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java @@ -1,5 +1,6 @@ package com.zc.business.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -13,11 +14,14 @@ import com.zc.business.service.IDcBatchFunctionsJobGroupService; import com.zc.business.service.IDcBatchFunctionsJobService; import org.quartz.SchedulerException; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Objects; /** * 定时任务组Service业务层处理 @@ -49,9 +53,9 @@ public class DcBatchFunctionsJobGroupServiceImpl extends ServiceImpl dcBatchFunctionsJobLambdaQueryWrapper = new LambdaQueryWrapper<>(); - dcBatchFunctionsJobLambdaQueryWrapper.eq(DcBatchFunctionsJob::getJobGroup,dcBatchFunctionsJobGroup.getId()); + dcBatchFunctionsJobLambdaQueryWrapper.eq(DcBatchFunctionsJob::getJobGroup, dcBatchFunctionsJobGroup.getId()); List list = dcBatchFunctionsJobService.list(dcBatchFunctionsJobLambdaQueryWrapper); - list.forEach(item->{ + list.forEach(item -> { try { dcBatchFunctionsJobService.editDcBatchFunctionsJob(item); } catch (SchedulerException e) { @@ -134,5 +138,25 @@ public class DcBatchFunctionsJobGroupServiceImpl extends ServiceImpl dcBatchFunctionsJobList = dcBatchFunctionsJobGroup.getDcBatchFunctionsJobList(); + DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup1 = addDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup); + if (dcBatchFunctionsJobGroup1 == null) { + throw new NullPointerException(); + } + for (DcBatchFunctionsJob job : dcBatchFunctionsJobList) { + + job.setJobGroup(String.valueOf(dcBatchFunctionsJobGroup1.getId())); + + DcBatchFunctionsJob dcBatchFunctionsJob = dcBatchFunctionsJobService.addDcBatchFunctionsJob(job); + if (dcBatchFunctionsJob == null) { + throw new NullPointerException(); + } + } + return dcBatchFunctionsJobGroup1; + } } From 972c686d5946669b61722cbd7dbe79479b36d1f3 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Mon, 15 Jul 2024 17:04:49 +0800 Subject: [PATCH 04/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=AD=94=E6=B3=95?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcDeviceController.java | 72 +++++------ .../zc/business/controller/DeviceStatus.java | 6 +- .../com/zc/business/enums/UniversalEnum.java | 45 +++++++ .../interfaces/OperationLogAspect.java | 116 +++++++++--------- 4 files changed, 143 insertions(+), 96 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java index 48da7ae8..266d70fe 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java @@ -536,13 +536,13 @@ public class DcDeviceController extends BaseController { String iotDeviceId = device.getString("iotDeviceId"); String deviceType = device.getString("deviceType"); boolean continueToExecute = true; - if (Objects.equals(deviceType, "10")) { + if (Objects.equals(deviceType, UniversalEnum.TEN.getValue())) { - JSONObject mdJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, "MD").get("data")); + JSONObject mdJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.MD.getValue()).get("data")); String mdValue = mdJSONObject.getString("value"); - JSONObject tmJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, "TM").get("data")); + JSONObject tmJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.TM.getValue()).get("data")); String tmValue = tmJSONObject.getString("value"); @@ -563,7 +563,7 @@ public class DcDeviceController extends BaseController { } } else { List collect = resultArray.stream().filter(item -> Objects.equals(((JSONObject) JSON.toJSON(item)).getString("device"), device.getString("id"))).collect(Collectors.toList()); - if (collect.size() == 0) { + if (collect.size() == UniversalEnum.ZERO.getNumber()) { JSONObject result = new JSONObject(); result.put("device", device.getString("id")); result.put("deviceType", device.getInteger("deviceType")); @@ -571,14 +571,14 @@ public class DcDeviceController extends BaseController { result.put("result", AjaxResult.error()); resultArray.add(result); } else { - for (int i = 0; i < resultArray.size(); i++) { + for (int i = UniversalEnum.ZERO.getNumber(); i < resultArray.size(); i++) { JSONObject jsonObject = (JSONObject) JSON.toJSON(resultArray.get(i)); if (!Objects.equals(jsonObject.getString("device"), device.getString("id"))) { JSONObject result = jsonObject.getJSONObject("result"); - if (!Objects.equals(result.getString("code"), "200")) { + if (!Objects.equals(result.getString("code"), UniversalEnum.TWO_HUNDRED.getValue())) { break; } else { - result.put("code", "500"); + result.put("code", UniversalEnum.FIVE_HUNDRED.getValue()); jsonObject.put("result", result); resultArray.add(i, jsonObject); } @@ -588,15 +588,15 @@ public class DcDeviceController extends BaseController { } } - if (Objects.equals(functionId, "SETMD")) { + if (Objects.equals(functionId, UniversalEnum.SETMD.getValue())) { JSONObject jsonObjectMD = new JSONObject(); - jsonObjectMD.put("SET", mdValue); + jsonObjectMD.put(UniversalEnum.SET.getValue(), mdValue); getAjaxResult(iotDeviceId, functionId, jsonObjectMD.toJavaObject(new TypeReference>() { })); } - if (Objects.equals(functionId, "SETTM")) { + if (Objects.equals(functionId, UniversalEnum.SETTM.getValue())) { JSONObject jsonObjectTM = new JSONObject(); - jsonObjectTM.put("SET", tmValue); + jsonObjectTM.put(UniversalEnum.SET.getValue(), tmValue); getAjaxResult(iotDeviceId, functionId, jsonObjectTM.toJavaObject(new TypeReference>() { })); } @@ -610,15 +610,15 @@ public class DcDeviceController extends BaseController { String functionId = functionJSONObject.getString("functionId"); if (continueToExecute) { JSONObject jsonObject = functionJSONObject.getJSONObject("params") != null ? functionJSONObject.getJSONObject("params") : new JSONObject(); - //JSONObject result = getResult(device, iotDeviceId, functionId, jsonObject); - //resultArray.add(result); - //AjaxResult ajaxResult = (AjaxResult) result.get("result"); - //if (!Objects.equals(String.valueOf(ajaxResult.get("code")), UniversalEnum.TWO_HUNDRED.getValue())) { - // continueToExecute = false; - // if (Objects.equals(device.getString("deviceType"), UniversalEnum.FIFTEEN.getValue())) { - // return AjaxResult.error(UniversalEnum.TWO_HUNDRED.getNumber(), UniversalEnum.FIVE_HUNDRED.getValue()); - // } - //} + JSONObject result = getResult(device, iotDeviceId, functionId, jsonObject); + resultArray.add(result); + AjaxResult ajaxResult = (AjaxResult) result.get("result"); + if (!Objects.equals(String.valueOf(ajaxResult.get("code")), UniversalEnum.TWO_HUNDRED.getValue())) { + continueToExecute = false; + if (Objects.equals(device.getString("deviceType"), UniversalEnum.FIFTEEN.getValue())) { + return AjaxResult.error(UniversalEnum.TWO_HUNDRED.getNumber(), UniversalEnum.FIVE_HUNDRED.getValue()); + } + } } else { JSONObject result = new JSONObject(); result.put("device", device.getString("id")); @@ -641,22 +641,22 @@ public class DcDeviceController extends BaseController { result.put("device", device.getString("id")); result.put("deviceType", device.getInteger("deviceType")); result.put("functionId", functionId); - //if (device.getInteger("deviceType").equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) { - // JSONObject value = broadcastController.nearCamListDistance(jsonObject); - // AjaxResult ajaxResult = new AjaxResult(); - // value.keySet().forEach(item -> { - // ajaxResult.put(item, value.getString(item)); - // }); - // if (Objects.equals(String.valueOf(ajaxResult.get("retCode")), UniversalEnum.ZERO.getValue())) { - // ajaxResult.put("code", UniversalEnum.TWO_HUNDRED.getNumber()); - // } else { - // ajaxResult.put("code", UniversalEnum.FIVE_HUNDRED.getNumber()); - // } - // - // result.put("result", ajaxResult); - //} else { - // result.put("result", getAjaxResult(iotDeviceId, functionId, params)); - //} + if (device.getInteger("deviceType").equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) { + JSONObject value = broadcastController.nearCamListDistance(jsonObject); + AjaxResult ajaxResult = new AjaxResult(); + value.keySet().forEach(item -> { + ajaxResult.put(item, value.getString(item)); + }); + if (Objects.equals(String.valueOf(ajaxResult.get("retCode")), UniversalEnum.ZERO.getValue())) { + ajaxResult.put("code", UniversalEnum.TWO_HUNDRED.getNumber()); + } else { + ajaxResult.put("code", UniversalEnum.FIVE_HUNDRED.getNumber()); + } + + result.put("result", ajaxResult); + } else { + result.put("result", getAjaxResult(iotDeviceId, functionId, params)); + } return result; } diff --git a/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java b/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java index 2d3b050c..070ecd19 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java +++ b/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java @@ -15,7 +15,6 @@ import com.zc.business.service.impl.StatusService; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.io.BufferedReader; @@ -23,7 +22,9 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.InetAddress; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.ArrayList; @@ -103,7 +104,8 @@ public class DeviceStatus { //@Scheduled(cron = "0 30 23 * * ?") public void periodicDataClearing() { StatusService statusService = SpringUtils.getBean(StatusService.class); - LocalDateTime startTime = LocalDateTime.now().minusMonths(UniversalEnum.THREE.getNumber()); + LocalDateTime startTime = LocalDateTime.of(LocalDate.now().minusMonths(UniversalEnum.THREE.getNumber()), LocalTime.MIN); + ; Status status = new Status(); status.setStartTime(startTime); statusService.delStatusByTime(status); diff --git a/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java b/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java index bf575f57..31fd11aa 100644 --- a/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java +++ b/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java @@ -772,6 +772,36 @@ public enum UniversalEnum { // 内容 CONTENT(0, "内容"), + // 关闭 + OFF(0, "关闭"), + + // 打开 + UNPACK(0, "打开"), + + // 常亮 + STEADY_ON(0, "常亮"), + + // 间隔100ms闪烁 + BLINK_AT_AN_INTERVAL_OF_100_MS(0, "间隔100ms闪烁"), + + // 间隔200ms闪烁 + BLINK_AT_AN_INTERVAL_OF_200_MS(0, "间隔200ms闪烁"), + + // 间隔500ms闪烁 + BLINK_AT_AN_INTERVAL_OF_500_MS(0, "间隔500ms闪烁"), + + // 2次闪烁 + DOUBLE_FLICKER(0, "2次闪烁"), + + // SOS + SOS(0, "SOS"), + + // 自定义闪烁时间 + CUSTOMIZE_THE_BLINKING_TIME(0, "自定义闪烁时间"), + + // 模式 + MODE(0, "模式"), + // 一般 NORMAL(0, "一般"), @@ -1162,12 +1192,18 @@ public enum UniversalEnum { // SETMD SETMD(0, "SETMD"), + // MD + MD(0, "MD"), + // ASKMD ASKMD(0, "ASKMD"), // SETTM SETTM(0, "SETTM"), + // TM + TM(0, "TM"), + // ASKTM ASKTM(0, "ASKTM"), @@ -2064,6 +2100,15 @@ public enum UniversalEnum { // 行车诱导功能码 01 ZERO_ONE(0, "01"), + // 行车诱导功能码 02 + ZERO_TWO(0, "02"), + + // 行车诱导功能码 03 + ZERO_THREE(0, "03"), + + // 行车诱导功能码 04 + ZERO_FOUR(0, "04"), + // 行车诱导功能码 0b ZERO_B(0, "0b"), diff --git a/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java b/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java index 6854137e..0ccd7215 100644 --- a/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java +++ b/zc-business/src/main/java/com/zc/business/interfaces/OperationLogAspect.java @@ -224,7 +224,7 @@ public class OperationLogAspect { JSONObject params = function.getJSONObject("params"); - if (Objects.equals(deviceType, "2")) { + if (Objects.equals(deviceType, UniversalEnum.TWO.getValue())) { //if (Objects.equals(functionId, UniversalEnum.ELEVEN.getValue())) { // @@ -235,13 +235,13 @@ public class OperationLogAspect { JSONArray parameters = params.getJSONArray("parameters"); - for (int i2 = 0; i2 < parameters.size(); i2++) { + for (int i2 = UniversalEnum.ZERO.getNumber(); i2 < parameters.size(); i2++) { remark.append(((JSONObject) JSON.toJSON(parameters.get(i2))).getString("CONTENT")); //remark.append("文件内容:").append(((JSONObject) JSON.toJSON(parameters.get(i2))).getString("CONTENT")); - if (i2 < parameters.size() - 1) { - remark.append("、"); + if (i2 < parameters.size() - UniversalEnum.ONE.getNumber()) { + remark.append(UniversalEnum.SEMICOLON.getValue()); } } @@ -252,175 +252,175 @@ public class OperationLogAspect { // //} - } else if (Objects.equals(deviceType, "5")) { + } else if (Objects.equals(deviceType, UniversalEnum.FIVE.getValue())) { remark.append(params.getString("text")); - } else if (Objects.equals(deviceType, "10")) { + } else if (Objects.equals(deviceType, UniversalEnum.TEN.getValue())) { - String set = params.getString("SET"); + String set = params.getString(UniversalEnum.SET.getValue()); if (Objects.equals(functionId, UniversalEnum.SETMD.getValue())) { - if (Objects.equals(set, "0")) { + if (Objects.equals(set, UniversalEnum.ZERO.getValue())) { - remark.append("关闭"); + remark.append(UniversalEnum.OFF.getValue()); - } else if (Objects.equals(set, "1")) { + } else if (Objects.equals(set, UniversalEnum.ONE.getValue())) { - remark.append("常亮"); + remark.append(UniversalEnum.STEADY_ON.getValue()); - } else if (Objects.equals(set, "2")) { + } else if (Objects.equals(set, UniversalEnum.TWO.getValue())) { - remark.append("间隔100ms闪烁"); + remark.append(UniversalEnum.BLINK_AT_AN_INTERVAL_OF_100_MS.getValue()); - } else if (Objects.equals(set, "3")) { + } else if (Objects.equals(set, UniversalEnum.THREE.getValue())) { - remark.append("间隔200ms闪烁"); + remark.append(UniversalEnum.BLINK_AT_AN_INTERVAL_OF_200_MS.getValue()); - } else if (Objects.equals(set, "4")) { + } else if (Objects.equals(set, UniversalEnum.FOUR.getValue())) { - remark.append("间隔500ms闪烁"); + remark.append(UniversalEnum.BLINK_AT_AN_INTERVAL_OF_500_MS.getValue()); - } else if (Objects.equals(set, "5")) { + } else if (Objects.equals(set, UniversalEnum.FIVE.getValue())) { - remark.append("2次闪烁"); + remark.append(UniversalEnum.DOUBLE_FLICKER.getValue()); - } else if (Objects.equals(set, "6")) { + } else if (Objects.equals(set, UniversalEnum.SIX.getValue())) { - remark.append("SOS"); + remark.append(UniversalEnum.SOS.getValue()); - } else if (Objects.equals(set, "7")) { + } else if (Objects.equals(set, UniversalEnum.SEVEN.getValue())) { - remark.append("自定义闪烁时间"); + remark.append(UniversalEnum.CUSTOMIZE_THE_BLINKING_TIME.getValue()); } - remark.append("模式"); + remark.append(UniversalEnum.MODE.getValue()); } else if (Objects.equals(functionId, UniversalEnum.SETTM.getValue())) { - remark.append(set).append("分钟"); + remark.append(set).append(UniversalEnum.MINUTES.getValue()); } - } else if (Objects.equals(deviceType, "12")) { + } else if (Objects.equals(deviceType, UniversalEnum.TWELVE.getValue())) { - if (Objects.equals(functionId, "51")) { + if (Objects.equals(functionId, UniversalEnum.FIFTY_ONE.getValue())) { //remark.append("模式:"); String mode = params.getString("mode"); - if (Objects.equals(mode, "00")) { + if (Objects.equals(mode, UniversalEnum.ZERO_ZERO.getValue())) { remark.append("远程手动控制模式:上行:"); String onWorkStatus = params.getString("onWorkStatus"); String inWorkStatus = params.getString("inWorkStatus"); - if (Objects.equals(onWorkStatus, "00")) { + if (Objects.equals(onWorkStatus, UniversalEnum.ZERO_ZERO.getValue())) { remark.append("不更新状态,下行:"); - } else if (Objects.equals(onWorkStatus, "01")) { + } else if (Objects.equals(onWorkStatus, UniversalEnum.ZERO_ONE.getValue())) { remark.append("常亮,下行:"); - } else if (Objects.equals(onWorkStatus, "02")) { + } else if (Objects.equals(onWorkStatus, UniversalEnum.ZERO_TWO.getValue())) { remark.append("流水,下行:"); - } else if (Objects.equals(onWorkStatus, "03")) { + } else if (Objects.equals(onWorkStatus, UniversalEnum.ZERO_THREE.getValue())) { remark.append("闪烁,下行:"); - } else if (Objects.equals(onWorkStatus, "04")) { + } else if (Objects.equals(onWorkStatus, UniversalEnum.ZERO_FOUR.getValue())) { remark.append("关闭,下行:"); } - if (Objects.equals(inWorkStatus, "00")) { + if (Objects.equals(inWorkStatus, UniversalEnum.ZERO_ZERO.getValue())) { remark.append("不更新状态"); - } else if (Objects.equals(inWorkStatus, "01")) { + } else if (Objects.equals(inWorkStatus, UniversalEnum.ZERO_ONE.getValue())) { remark.append("常亮"); - } else if (Objects.equals(inWorkStatus, "02")) { + } else if (Objects.equals(inWorkStatus, UniversalEnum.ZERO_TWO.getValue())) { remark.append("流水"); - } else if (Objects.equals(inWorkStatus, "03")) { + } else if (Objects.equals(inWorkStatus, UniversalEnum.ZERO_THREE.getValue())) { remark.append("闪烁"); - } else if (Objects.equals(inWorkStatus, "04")) { + } else if (Objects.equals(inWorkStatus, UniversalEnum.ZERO_FOUR.getValue())) { remark.append("关闭"); } - } else if (Objects.equals(mode, "01")) { + } else if (Objects.equals(mode, UniversalEnum.ZERO_ONE.getValue())) { remark.append("时间段自动控制模式:") .append(params.getString("startDisplayTime")) .append("-") .append(params.getString("endDisplayTime")); - } else if (Objects.equals(mode, "02")) { + } else if (Objects.equals(mode, UniversalEnum.ZERO_TWO.getValue())) { remark.append("万年历自动控制模式"); - } else if (Objects.equals(mode, "03")) { + } else if (Objects.equals(mode, UniversalEnum.ZERO_THREE.getValue())) { remark.append("能见度自动控制模式"); } - } else if (Objects.equals(functionId, "30")) { + } else if (Objects.equals(functionId, UniversalEnum.THIRTY.getValue())) { String onWorkStatus = params.getString("onWorkStatus"); String inWorkStatus = params.getString("inWorkStatus"); - if (Objects.equals(onWorkStatus, "00")) { + if (Objects.equals(onWorkStatus, UniversalEnum.ZERO_ZERO.getValue())) { remark.append("上行:不更新状态,下行:"); - } else if (Objects.equals(onWorkStatus, "01")) { + } else if (Objects.equals(onWorkStatus, UniversalEnum.ZERO_ONE.getValue())) { remark.append("上行:常亮,下行:"); - } else if (Objects.equals(onWorkStatus, "02")) { + } else if (Objects.equals(onWorkStatus, UniversalEnum.ZERO_TWO.getValue())) { remark.append("上行:流水,下行:"); - } else if (Objects.equals(onWorkStatus, "03")) { + } else if (Objects.equals(onWorkStatus, UniversalEnum.ZERO_THREE.getValue())) { remark.append("上行:闪烁,下行:"); - } else if (Objects.equals(onWorkStatus, "04")) { + } else if (Objects.equals(onWorkStatus, UniversalEnum.ZERO_FOUR.getValue())) { remark.append("上行:关闭,下行:"); } - if (Objects.equals(inWorkStatus, "00")) { + if (Objects.equals(inWorkStatus, UniversalEnum.ZERO_ZERO.getValue())) { remark.append("不更新状态"); - } else if (Objects.equals(inWorkStatus, "01")) { + } else if (Objects.equals(inWorkStatus, UniversalEnum.ZERO_ONE.getValue())) { remark.append("常亮"); - } else if (Objects.equals(inWorkStatus, "02")) { + } else if (Objects.equals(inWorkStatus, UniversalEnum.ZERO_TWO.getValue())) { remark.append("流水"); - } else if (Objects.equals(inWorkStatus, "03")) { + } else if (Objects.equals(inWorkStatus, UniversalEnum.ZERO_THREE.getValue())) { remark.append("闪烁"); - } else if (Objects.equals(inWorkStatus, "04")) { + } else if (Objects.equals(inWorkStatus, UniversalEnum.ZERO_FOUR.getValue())) { remark.append("关闭"); @@ -561,30 +561,30 @@ public class OperationLogAspect { // : String.valueOf(((HashMap) (DEVICEFUNCTIONNAME.get(deviceType))).get(functionId)); // //remark.append(hashMap).append(":"); - if (Objects.equals(deviceType, "13") || Objects.equals(deviceType, "16")) { + if (Objects.equals(deviceType, UniversalEnum.THIRTEEN.getValue()) || Objects.equals(deviceType, UniversalEnum.SIXTEEN.getValue())) { String identification = params.getString("deviceName"); String value = params.getString("value"); if (Objects.equals(identification, "ac_out_1_en")) { - remark.append("220V 输出 1").append(Objects.equals(value, "1") ? "打开" : "关闭"); + remark.append("220V 输出 1").append(Objects.equals(value, UniversalEnum.ONE.getValue()) ? UniversalEnum.UNPACK.getValue() : UniversalEnum.OFF.getValue()); } else if (Objects.equals(identification, "ac_out_2_en")) { - remark.append("220V 输出 2").append(Objects.equals(value, "1") ? "打开" : "关闭"); + remark.append("220V 输出 2").append(Objects.equals(value, UniversalEnum.ONE.getValue()) ? UniversalEnum.UNPACK.getValue() : UniversalEnum.OFF.getValue()); } else if (Objects.equals(identification, "dc_out_1_en")) { - remark.append("12V 输出 1").append(Objects.equals(value, "1") ? "打开" : "关闭"); + remark.append("12V 输出 1").append(Objects.equals(value, UniversalEnum.ONE.getValue()) ? UniversalEnum.UNPACK.getValue() : UniversalEnum.OFF.getValue()); } else if (Objects.equals(identification, "dc_out_2_en")) { - remark.append("12V 输出 2").append(Objects.equals(value, "1") ? "打开" : "关闭"); + remark.append("12V 输出 2").append(Objects.equals(value, UniversalEnum.ONE.getValue()) ? UniversalEnum.UNPACK.getValue() : UniversalEnum.OFF.getValue()); } else if (Objects.equals(identification, "fan_out_en")) { - remark.append("风扇").append(Objects.equals(value, "1") ? "打开" : "关闭"); + remark.append("风扇").append(Objects.equals(value, UniversalEnum.ONE.getValue()) ? UniversalEnum.UNPACK.getValue() : UniversalEnum.OFF.getValue()); } From 512b4c1e28f09a3764f2fdba7cfd37a9e5df26b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Tue, 16 Jul 2024 09:59:23 +0800 Subject: [PATCH 05/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E9=93=83=E9=93=9B=20=E4=BA=8B=E4=BB=B6=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../message/device/handler/DeviceMessageHandler.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java index f401e0fe..f55b91ef 100644 --- a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java +++ b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java @@ -320,7 +320,9 @@ public class DeviceMessageHandler { String title = direction + WarningSubclassEnum.getDecorateInfo(warningSubclass); // 标题 dcWarning.setWarningTitle(title); - dcWarning.setRemark(DateUtil.formatDateTime(DateUtil.date(captureTime)) + UniversalEnum.BLANK_SPACE.getValue() + title); + SimpleDateFormat sdf = new SimpleDateFormat(UniversalEnum.CHINESE_CHARACTER_TIME_FORMAT.getValue()); + String formattedDate = sdf.format(new Date()); + dcWarning.setRemark(formattedDate + UniversalEnum.BLANK_SPACE.getValue() + title); // 影响车道 // 物联设备id @@ -622,7 +624,9 @@ public class DeviceMessageHandler { DcWarning dcWarning = new DcWarning(); dcWarning.setWarningState(UniversalEnum.ONE.getNumber()); - dcWarning.setRemark(new Date() + UniversalEnum.BLANK_SPACE.getValue() + content); + SimpleDateFormat sdf = new SimpleDateFormat(UniversalEnum.CHINESE_CHARACTER_TIME_FORMAT.getValue()); + String formattedDate = sdf.format(new Date()); + dcWarning.setRemark(formattedDate + UniversalEnum.BLANK_SPACE.getValue() + content); dcWarning.setWarningTime(new Date()); dcWarning.setWarningType(UniversalEnum.EIGHT_ONE.getNumber()); dcWarning.setWarningSubclass(UniversalEnum.EIGHT_ONE.getValue()); @@ -669,7 +673,9 @@ public class DeviceMessageHandler { String string = object.toString(); DcWarning dcWarning = new DcWarning(); dcWarning.setWarningState(UniversalEnum.ONE.getNumber()); - dcWarning.setRemark(new Date() + UniversalEnum.BLANK_SPACE.getValue() + content); + SimpleDateFormat sdf = new SimpleDateFormat(UniversalEnum.CHINESE_CHARACTER_TIME_FORMAT.getValue()); + String formattedDate = sdf.format(new Date()); + dcWarning.setRemark(formattedDate + UniversalEnum.BLANK_SPACE.getValue() + content); dcWarning.setWarningTime(new Date()); dcWarning.setWarningType(UniversalEnum.EIGHT_FOUR.getNumber()); dcWarning.setWarningSubclass(UniversalEnum.EIGHT_FOUR.getValue()); From 0872cab14bddecd1db4a9c23ff3de3089b1cfbbc Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Tue, 16 Jul 2024 10:11:15 +0800 Subject: [PATCH 06/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BD=A6=E8=BE=86?= =?UTF-8?q?=E6=95=85=E9=9A=9C=E4=BA=8B=E4=BB=B6=E4=B8=8A=E6=8A=A5=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E5=86=85=E5=AE=B9=20=E4=BC=98=E5=8C=96=E6=B0=94?= =?UTF-8?q?=E8=B1=A1=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/CodeScanningAlarmController.java | 4 ++++ .../zc/business/controller/WeatherForecastController.java | 4 +++- .../service/impl/DcNoStakeWarningTableServiceImpl.java | 8 ++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java b/zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java index 14b9cfee..5c925020 100644 --- a/zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java +++ b/zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java @@ -79,8 +79,12 @@ public class CodeScanningAlarmController extends BaseController { dcWarning.setWarningSubclass(UniversalEnum.TEN_THREE.getValue()); break; } + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mmXXX"); + String warningTitle = "G35济菏高速" + dcWarning.getStakeMark() + (Objects.equals(roadCode, UniversalEnum.ONE.getValue()) ? UniversalEnum.DIRECTION_OF_JINAN.getValue() : UniversalEnum.DIRECTION_OF_HEZE.getValue()) + "发生" + (Integer.parseInt(accidentType) >= 4 ? UniversalEnum.TRAFFIC_ACCIDENT_EVENT.getValue() : UniversalEnum.VEHICLE_BREAKDOWN_EVENT.getValue()); dcWarning.setWarningTitle(warningTitle); + dcWarning.setRemark(simpleDateFormat.format(dcWarning.getWarningTime()) + warningTitle); dcWarning.setWarningSource(UniversalEnum.FIVE.getNumber()); dcWarning.setWarningState(UniversalEnum.ONE.getNumber()); return AjaxResult.success(dcWarningService.insertDcWarning(dcWarning)); diff --git a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java index d1e14635..3c296314 100644 --- a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java +++ b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java @@ -84,7 +84,9 @@ public class WeatherForecastController extends BaseController { JSONArray data = (JSONArray) JSON.toJSON(ajaxResult.get("data")); if (data.size() > UniversalEnum.ZERO.getNumber()) { - List dcNoStakeWarningTables = noStakeWarningTableService.listDcNoStakeWarningTable(new DcNoStakeWarningTable(), null, null); + DcNoStakeWarningTable noStakeWarningTable = new DcNoStakeWarningTable(); + noStakeWarningTable.setWarningType(UniversalEnum.TWO.getValue()); + List dcNoStakeWarningTables = noStakeWarningTableService.listDcNoStakeWarningTable(noStakeWarningTable, null, null); data.forEach(item -> { JSONObject jsonObject = (JSONObject) JSON.toJSON(item); String earlyWorningSignal = jsonObject.getString("earlyWorningSignal"); diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcNoStakeWarningTableServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcNoStakeWarningTableServiceImpl.java index 0009d2bc..71dac816 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcNoStakeWarningTableServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcNoStakeWarningTableServiceImpl.java @@ -31,22 +31,22 @@ public class DcNoStakeWarningTableServiceImpl extends ServiceImpl Date: Tue, 16 Jul 2024 10:25:45 +0800 Subject: [PATCH 07/28] =?UTF-8?q?=E6=89=AB=E7=A0=81=E6=8A=A5=E8=AD=A6?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/zc/business/mapper/DcWarningMapper.java | 8 ++++++++ .../com/zc/business/service/IDcWarningService.java | 2 ++ .../business/service/impl/DcWarningServiceImpl.java | 12 ++++++++++++ .../resources/mapper/business/DcWarningMapper.xml | 5 +++++ 4 files changed, 27 insertions(+) diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java index 05795762..a480dbef 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java @@ -34,6 +34,14 @@ public interface DcWarningMapper */ public HashMap selectDcWarningById(String id); + /** + * 查询预警信息 + * + * @param id 预警信息主键 + * @return 预警信息 + */ + public HashMap selectAlarmById(String id); + /** * 查询预警信息列表 * diff --git a/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java b/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java index 73f3312c..f4d8576f 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java @@ -32,6 +32,8 @@ public interface IDcWarningService */ public HashMap selectDcWarningById(String id); + public HashMap selectAlarmById(String id); + /** * 查询预警信息列表 * diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java index c2a14751..1a8c08b9 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java @@ -93,6 +93,18 @@ public class DcWarningServiceImpl implements IDcWarningService return dcWarningMapper.selectDcWarningById(id); } + /** + * 查询预警信息 + * + * @param id 预警信息主键 + * @return 预警信息 + */ + @Override + public HashMap selectAlarmById(String id) + { + return dcWarningMapper.selectAlarmById(id); + } + /** * 查询预警信息列表 * diff --git a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml index 514ba14f..7d6bb3a8 100644 --- a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml @@ -77,6 +77,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + diff --git a/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml index b4c8a6e1..03a98a3a 100644 --- a/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml @@ -328,7 +328,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" JOIN dc_gantry_statistics_data AS dgsd ON ps.facility_code = dgsd.gantry_code - AND DATE(dgsd.statistical_date) BETWEEN #{startDate} AND #{endDate} + + AND DATE(dgsd.statistical_date) BETWEEN #{startDate} AND #{endDate} + AND dgsd.period_type = #{periodType} From 69925e8cec469b1483a24e165339b9611f026c87 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Wed, 17 Jul 2024 17:10:42 +0800 Subject: [PATCH 19/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=A9=E6=B0=94?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=20=E5=A4=A9=E6=B0=94=E6=83=85=E5=86=B5?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WeatherForecastController.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java index 3c296314..53794d82 100644 --- a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java +++ b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java @@ -267,15 +267,22 @@ public class WeatherForecastController extends BaseController { String visLevel = jsonObject.getString("visLevel"); - if (Objects.equals(visLevel, UniversalEnum.ONE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); - } else if (Objects.equals(visLevel, UniversalEnum.TWO.getValue()) || Objects.equals(visLevel, UniversalEnum.THREE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.CLOUDY.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.CLOUDY.getNumber()); - } else if (Objects.equals(visLevel, UniversalEnum.FOUR.getValue()) || Objects.equals(visLevel, UniversalEnum.FIVE.getValue()) || Objects.equals(visLevel, UniversalEnum.SIX.getValue())) { + Double rhu = jsonObject.getDouble("rhu"); + + if (rhu > UniversalEnum.SIXTY.getNumber()) { jsonObject.put("weatherCondition", UniversalEnum.OVERCAST_SKY.getValue()); jsonObject.put("weatherConditionCode", UniversalEnum.OVERCAST_SKY.getNumber()); + } else { + if (Objects.equals(visLevel, UniversalEnum.ONE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); + } else if (Objects.equals(visLevel, UniversalEnum.TWO.getValue()) || Objects.equals(visLevel, UniversalEnum.THREE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.CLOUDY.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.CLOUDY.getNumber()); + } else if (Objects.equals(visLevel, UniversalEnum.FOUR.getValue()) || Objects.equals(visLevel, UniversalEnum.FIVE.getValue()) || Objects.equals(visLevel, UniversalEnum.SIX.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.OVERCAST_SKY.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.OVERCAST_SKY.getNumber()); + } } } else { From 4b38e21310cf29891dc98e8b95875ca7fe9753ef Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Wed, 17 Jul 2024 18:10:23 +0800 Subject: [PATCH 20/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=A9=E6=B0=94?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=20=E5=A4=A9=E6=B0=94=E6=83=85=E5=86=B5?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zc/business/controller/WeatherForecastController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java index 53794d82..553eb249 100644 --- a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java +++ b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java @@ -263,7 +263,7 @@ public class WeatherForecastController extends BaseController { JSONObject jsonObject = (JSONObject) JSON.toJSON(data.get(i)); String pre = jsonObject.getString("pre"); - if (Objects.equals(pre, UniversalEnum.ZERO.getValue())) { + if (Objects.equals(pre, UniversalEnum.ZERO.getValue())||Double.parseDouble(pre)==UniversalEnum.ZERO.getNumber()) { String visLevel = jsonObject.getString("visLevel"); From e21e6ff297d1becb0b74ae10f0f3cd55947e06b8 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Wed, 17 Jul 2024 19:13:05 +0800 Subject: [PATCH 21/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=A9=E6=B0=94?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=20=E5=A4=A9=E6=B0=94=E6=83=85=E5=86=B5?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WeatherForecastController.java | 313 +++++++++--------- 1 file changed, 163 insertions(+), 150 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java index 553eb249..9cfc7927 100644 --- a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java +++ b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java @@ -258,157 +258,9 @@ public class WeatherForecastController extends BaseController { JSONObject jsonResult = JSONObject.parseObject(response.body().string()); if (jsonResult.getInteger("code") == UniversalEnum.TWO_HUNDRED.getNumber()) { JSONArray data = jsonResult.getJSONArray("data"); - JSONArray jsonArray = new JSONArray(); - for (int i = UniversalEnum.ZERO.getNumber(); i < data.size(); i++) { - - JSONObject jsonObject = (JSONObject) JSON.toJSON(data.get(i)); - String pre = jsonObject.getString("pre"); - if (Objects.equals(pre, UniversalEnum.ZERO.getValue())||Double.parseDouble(pre)==UniversalEnum.ZERO.getNumber()) { - - String visLevel = jsonObject.getString("visLevel"); - - Double rhu = jsonObject.getDouble("rhu"); - - if (rhu > UniversalEnum.SIXTY.getNumber()) { - jsonObject.put("weatherCondition", UniversalEnum.OVERCAST_SKY.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.OVERCAST_SKY.getNumber()); - } else { - if (Objects.equals(visLevel, UniversalEnum.ONE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); - } else if (Objects.equals(visLevel, UniversalEnum.TWO.getValue()) || Objects.equals(visLevel, UniversalEnum.THREE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.CLOUDY.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.CLOUDY.getNumber()); - } else if (Objects.equals(visLevel, UniversalEnum.FOUR.getValue()) || Objects.equals(visLevel, UniversalEnum.FIVE.getValue()) || Objects.equals(visLevel, UniversalEnum.SIX.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.OVERCAST_SKY.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.OVERCAST_SKY.getNumber()); - } - } - } else { - - String preLevel = jsonObject.getString("preLevel"); - String pph = jsonObject.getString("pph"); - - switch (preLevel) { - case "0": - jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); - break; - case "1": - case "2": - if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.SPIT.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.SPIT.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.LIGHT_SNOW.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.LIGHT_SNOW.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); - } - break; - case "3": - if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.MODERATE_RAIN.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.MODERATE_RAIN.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.MODERATE_SNOW.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.MODERATE_SNOW.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); - } - break; - case "4": - if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.HEAVY_RAIN.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.HEAVY_RAIN.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.HEAVY_SNOW.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.HEAVY_SNOW.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); - } - break; - case "5": - if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.RAINSTORM.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.RAINSTORM.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.BLIZZARD.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.BLIZZARD.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); - } - break; - case "6": - if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.BIG_RAINSTORM.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.BIG_RAINSTORM.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.BIG_BLIZZARD.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.BIG_BLIZZARD.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); - } - break; - case "7": - if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.EXTREMELY_HEAVY_RAINSTORM.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.EXTREMELY_HEAVY_RAINSTORM.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.HEAVY_SNOWSTORM.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.HEAVY_SNOWSTORM.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); - } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { - jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); - jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); - } - break; - } - - } - jsonArray.add(i, jsonObject); - } ; + JSONArray jsonArray = processingWeatherData(data); + if (jsonArray.size() != UniversalEnum.ZERO.getNumber()) { redisCache.deleteObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake); redisCache.setCacheObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake, jsonArray); @@ -429,6 +281,167 @@ public class WeatherForecastController extends BaseController { return AjaxResult.error(UniversalEnum.REQUEST_FAILED.getValue()); } + public JSONArray processingWeatherData(JSONArray data) { + JSONArray jsonArray = new JSONArray(); + for (int i = UniversalEnum.ZERO.getNumber(); i < data.size(); i++) { + + JSONObject jsonObject = (JSONObject) JSON.toJSON(data.get(i)); + String pre = jsonObject.getString("pre"); + if (Objects.equals(pre, UniversalEnum.ZERO.getValue()) || Double.parseDouble(pre) == UniversalEnum.ZERO.getNumber()) { + + String visLevel = jsonObject.getString("visLevel"); + + Double rhu = jsonObject.getDouble("rhu"); + + if (rhu > UniversalEnum.SIXTY.getNumber()) { + jsonObject.put("weatherCondition", UniversalEnum.OVERCAST_SKY.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.OVERCAST_SKY.getNumber()); + } else { + if (Objects.equals(visLevel, UniversalEnum.ONE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); + } else if (Objects.equals(visLevel, UniversalEnum.TWO.getValue()) || Objects.equals(visLevel, UniversalEnum.THREE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.CLOUDY.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.CLOUDY.getNumber()); + } else if (Objects.equals(visLevel, UniversalEnum.FOUR.getValue()) || Objects.equals(visLevel, UniversalEnum.FIVE.getValue()) || Objects.equals(visLevel, UniversalEnum.SIX.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.OVERCAST_SKY.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.OVERCAST_SKY.getNumber()); + } + } + } else { + + String preLevel = jsonObject.getString("preLevel"); + String pph = jsonObject.getString("pph"); + + switch (preLevel) { + case "0": + jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); + break; + case "1": + case "2": + if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.SPIT.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.SPIT.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.LIGHT_SNOW.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.LIGHT_SNOW.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); + } + break; + case "3": + if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.MODERATE_RAIN.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.MODERATE_RAIN.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.MODERATE_SNOW.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.MODERATE_SNOW.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); + } + break; + case "4": + if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.HEAVY_RAIN.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.HEAVY_RAIN.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.HEAVY_SNOW.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.HEAVY_SNOW.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); + } + break; + case "5": + if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.RAINSTORM.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.RAINSTORM.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.BLIZZARD.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.BLIZZARD.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); + } + break; + case "6": + if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.BIG_RAINSTORM.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.BIG_RAINSTORM.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.BIG_BLIZZARD.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.BIG_BLIZZARD.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); + } + break; + case "7": + if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.EXTREMELY_HEAVY_RAINSTORM.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.EXTREMELY_HEAVY_RAINSTORM.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.SLEET.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.SLEET.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.HEAVY_SNOWSTORM.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.HEAVY_SNOWSTORM.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.FREEZING_RAIN.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.FREEZING_RAIN.getNumber()); + } else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { + jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); + jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); + } + break; + } + + } + JSONArray forecastList = jsonObject.getJSONArray("forecastList"); + if (forecastList != null && forecastList.size() != UniversalEnum.ZERO.getNumber()) { + + jsonObject.put("forecastList",processingWeatherData(forecastList)); + } + + jsonArray.add(i, jsonObject); + } + return jsonArray; + } + + public static int findNearestMultipleOfFive(int number) { // 计算除以5的余数 int remainder = number % UniversalEnum.FIVE.getNumber(); From f8025066c4e5bd987daf504e0d5fc4e29e0c7548 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Thu, 18 Jul 2024 08:46:04 +0800 Subject: [PATCH 22/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=A9=E6=B0=94?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=20=E5=A4=A9=E6=B0=94=E6=83=85=E5=86=B5?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zc/business/controller/WeatherForecastController.java | 2 +- .../src/main/java/com/zc/business/enums/UniversalEnum.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java index 9cfc7927..407c7249 100644 --- a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java +++ b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java @@ -293,7 +293,7 @@ public class WeatherForecastController extends BaseController { Double rhu = jsonObject.getDouble("rhu"); - if (rhu > UniversalEnum.SIXTY.getNumber()) { + if (rhu > UniversalEnum.NINETY.getNumber()) { jsonObject.put("weatherCondition", UniversalEnum.OVERCAST_SKY.getValue()); jsonObject.put("weatherConditionCode", UniversalEnum.OVERCAST_SKY.getNumber()); } else { diff --git a/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java b/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java index 31fd11aa..00a79b0e 100644 --- a/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java +++ b/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java @@ -1405,6 +1405,9 @@ public enum UniversalEnum { // 70 SEVENTY(70, "70"), + // 90 + NINETY(90, "90"), + // 91 NINETY_ONE(91, "91"), From c75b9ee8f6b18e36afe5b840b951ed6dcb9d5f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Thu, 18 Jul 2024 09:22:08 +0800 Subject: [PATCH 23/28] =?UTF-8?q?=E6=97=A0=E4=BA=8B=E4=BB=B6=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=BF=94=E5=9B=9E=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/zc/business/service/impl/DcEventServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java index 82d7d60f..d072cb49 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java @@ -1172,6 +1172,9 @@ public class DcEventServiceImpl extends ServiceImpl impl public DcEvent selectEventSubclassById(String id) { // DcEvent dcEvent = dcEventMapper.selectDcEventById(id); + if (dcEvent ==null){ + return new DcEvent(); + } int eventType = Math.toIntExact(dcEvent.getEventType()); List processConfigList = dcProcessConfigMapper.selectDcProcessConfigByEventType(Math.toIntExact(dcEvent.getEventType())); dcEvent.setProcessConfigList(processConfigList); From 8abda21eb48f9d17941b4c2b60bda1ee643b1bd0 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Thu, 18 Jul 2024 10:01:30 +0800 Subject: [PATCH 24/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E8=B0=83=E7=94=A8=E8=BF=94=E5=9B=9E=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcDeviceController.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java index 266d70fe..aae52723 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java @@ -537,7 +537,41 @@ public class DcDeviceController extends BaseController { String deviceType = device.getString("deviceType"); boolean continueToExecute = true; if (Objects.equals(deviceType, UniversalEnum.TEN.getValue())) { + if (iotDeviceId == null) { + for (Object function : functions) { + JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function); + //JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function.toString()) ; + String functionId = functionJSONObject.getString("functionId"); + List collect = resultArray.stream().filter(item -> Objects.equals(((JSONObject) JSON.toJSON(item)).getString("device"), device.getString("id"))).collect(Collectors.toList()); + if (collect.size() == UniversalEnum.ZERO.getNumber()) { + JSONObject result = new JSONObject(); + result.put("device", device.getString("id")); + result.put("deviceType", device.getInteger("deviceType")); + result.put("functionId", functionId); + result.put("result", AjaxResult.error()); + resultArray.add(result); + } else { + for (int i = UniversalEnum.ZERO.getNumber(); i < resultArray.size(); i++) { + JSONObject jsonObject = (JSONObject) JSON.toJSON(resultArray.get(i)); + if (!Objects.equals(jsonObject.getString("device"), device.getString("id"))) { + JSONObject result = jsonObject.getJSONObject("result"); + if (!Objects.equals(result.getString("code"), UniversalEnum.TWO_HUNDRED.getValue())) { + break; + } else { + result.put("code", UniversalEnum.FIVE_HUNDRED.getValue()); + jsonObject.put("result", result); + resultArray.add(i, jsonObject); + } + } else { + break; + } + } + + } + } + break; + } JSONObject mdJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.MD.getValue()).get("data")); String mdValue = mdJSONObject.getString("value"); From 65837ede55861bd15d5c9f0491e8d722f805b896 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Thu, 18 Jul 2024 15:09:10 +0800 Subject: [PATCH 25/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E8=B0=83=E7=94=A8=E8=BF=94=E5=9B=9E=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcDeviceController.java | 107 +++++++++--------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java index aae52723..25b62aaa 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java @@ -570,69 +570,70 @@ public class DcDeviceController extends BaseController { } } - break; - } - JSONObject mdJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.MD.getValue()).get("data")); + } else { - String mdValue = mdJSONObject.getString("value"); + JSONObject mdJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.MD.getValue()).get("data")); - JSONObject tmJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.TM.getValue()).get("data")); + String mdValue = mdJSONObject.getString("value"); - String tmValue = tmJSONObject.getString("value"); + JSONObject tmJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.TM.getValue()).get("data")); - for (Object function : functions) { - JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function); - //JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function.toString()) ; - String functionId = functionJSONObject.getString("functionId"); - if (continueToExecute) { - JSONObject jsonObject = functionJSONObject.getJSONObject("params") != null ? functionJSONObject.getJSONObject("params") : new JSONObject(); - JSONObject result = getResult(device, iotDeviceId, functionId, jsonObject); - resultArray.add(result); - AjaxResult ajaxResult = (AjaxResult) result.get("result"); - if (!Objects.equals(String.valueOf(ajaxResult.get("code")), UniversalEnum.TWO_HUNDRED.getValue())) { - continueToExecute = false; - if (Objects.equals(device.getString("deviceType"), UniversalEnum.FIFTEEN.getValue())) { - return AjaxResult.error(UniversalEnum.TWO_HUNDRED.getNumber(), UniversalEnum.FIVE_HUNDRED.getValue()); - } - } - } else { - List collect = resultArray.stream().filter(item -> Objects.equals(((JSONObject) JSON.toJSON(item)).getString("device"), device.getString("id"))).collect(Collectors.toList()); - if (collect.size() == UniversalEnum.ZERO.getNumber()) { - JSONObject result = new JSONObject(); - result.put("device", device.getString("id")); - result.put("deviceType", device.getInteger("deviceType")); - result.put("functionId", functionId); - result.put("result", AjaxResult.error()); + String tmValue = tmJSONObject.getString("value"); + + for (Object function : functions) { + JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function); + //JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function.toString()) ; + String functionId = functionJSONObject.getString("functionId"); + if (continueToExecute) { + JSONObject jsonObject = functionJSONObject.getJSONObject("params") != null ? functionJSONObject.getJSONObject("params") : new JSONObject(); + JSONObject result = getResult(device, iotDeviceId, functionId, jsonObject); resultArray.add(result); + AjaxResult ajaxResult = (AjaxResult) result.get("result"); + if (!Objects.equals(String.valueOf(ajaxResult.get("code")), UniversalEnum.TWO_HUNDRED.getValue())) { + continueToExecute = false; + if (Objects.equals(device.getString("deviceType"), UniversalEnum.FIFTEEN.getValue())) { + return AjaxResult.error(UniversalEnum.TWO_HUNDRED.getNumber(), UniversalEnum.FIVE_HUNDRED.getValue()); + } + } } else { - for (int i = UniversalEnum.ZERO.getNumber(); i < resultArray.size(); i++) { - JSONObject jsonObject = (JSONObject) JSON.toJSON(resultArray.get(i)); - if (!Objects.equals(jsonObject.getString("device"), device.getString("id"))) { - JSONObject result = jsonObject.getJSONObject("result"); - if (!Objects.equals(result.getString("code"), UniversalEnum.TWO_HUNDRED.getValue())) { - break; + List collect = resultArray.stream().filter(item -> Objects.equals(((JSONObject) JSON.toJSON(item)).getString("device"), device.getString("id"))).collect(Collectors.toList()); + if (collect.size() == UniversalEnum.ZERO.getNumber()) { + JSONObject result = new JSONObject(); + result.put("device", device.getString("id")); + result.put("deviceType", device.getInteger("deviceType")); + result.put("functionId", functionId); + result.put("result", AjaxResult.error()); + resultArray.add(result); + } else { + for (int i = UniversalEnum.ZERO.getNumber(); i < resultArray.size(); i++) { + JSONObject jsonObject = (JSONObject) JSON.toJSON(resultArray.get(i)); + if (!Objects.equals(jsonObject.getString("device"), device.getString("id"))) { + JSONObject result = jsonObject.getJSONObject("result"); + if (!Objects.equals(result.getString("code"), UniversalEnum.TWO_HUNDRED.getValue())) { + break; + } else { + result.put("code", UniversalEnum.FIVE_HUNDRED.getValue()); + jsonObject.put("result", result); + resultArray.add(i, jsonObject); + } } else { - result.put("code", UniversalEnum.FIVE_HUNDRED.getValue()); - jsonObject.put("result", result); - resultArray.add(i, jsonObject); + break; } - } else { - break; } - } - } - if (Objects.equals(functionId, UniversalEnum.SETMD.getValue())) { - JSONObject jsonObjectMD = new JSONObject(); - jsonObjectMD.put(UniversalEnum.SET.getValue(), mdValue); - getAjaxResult(iotDeviceId, functionId, jsonObjectMD.toJavaObject(new TypeReference>() { - })); - } - if (Objects.equals(functionId, UniversalEnum.SETTM.getValue())) { - JSONObject jsonObjectTM = new JSONObject(); - jsonObjectTM.put(UniversalEnum.SET.getValue(), tmValue); - getAjaxResult(iotDeviceId, functionId, jsonObjectTM.toJavaObject(new TypeReference>() { - })); + } + if (Objects.equals(functionId, UniversalEnum.SETMD.getValue())) { + JSONObject jsonObjectMD = new JSONObject(); + jsonObjectMD.put(UniversalEnum.SET.getValue(), mdValue); + getAjaxResult(iotDeviceId, functionId, jsonObjectMD.toJavaObject(new TypeReference>() { + })); + } + if (Objects.equals(functionId, UniversalEnum.SETTM.getValue())) { + JSONObject jsonObjectTM = new JSONObject(); + jsonObjectTM.put(UniversalEnum.SET.getValue(), tmValue); + getAjaxResult(iotDeviceId, functionId, jsonObjectTM.toJavaObject(new TypeReference>() { + })); + } } } } From 936b7400e9fe74549d8d56030e5f3312656c2e6c Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Thu, 18 Jul 2024 17:29:06 +0800 Subject: [PATCH 26/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=A9=E6=B0=94?= =?UTF-8?q?=E9=A2=84=E8=AD=A6=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WeatherForecastController.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java index 407c7249..54d91195 100644 --- a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java +++ b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java @@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Objects; @@ -270,7 +271,8 @@ public class WeatherForecastController extends BaseController { return AjaxResult.success(cacheObject); } } else { - return AjaxResult.error(jsonResult.getInteger("code"), UniversalEnum.REQUEST_FAILED.getValue()); + JSONArray cacheObject = redisCache.getCacheObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake); + return AjaxResult.success(cacheObject); } } } catch (Exception ignored) { @@ -278,7 +280,8 @@ public class WeatherForecastController extends BaseController { logger.error(String.valueOf(ignored)); } - return AjaxResult.error(UniversalEnum.REQUEST_FAILED.getValue()); + JSONArray cacheObject = redisCache.getCacheObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake); + return AjaxResult.success(cacheObject); } public JSONArray processingWeatherData(JSONArray data) { @@ -433,7 +436,7 @@ public class WeatherForecastController extends BaseController { JSONArray forecastList = jsonObject.getJSONArray("forecastList"); if (forecastList != null && forecastList.size() != UniversalEnum.ZERO.getNumber()) { - jsonObject.put("forecastList",processingWeatherData(forecastList)); + jsonObject.put("forecastList", processingWeatherData(forecastList)); } jsonArray.add(i, jsonObject); @@ -539,14 +542,14 @@ public class WeatherForecastController extends BaseController { // return AjaxResult.success(redisCache.getCacheList("currentWeatherWarningInformationQuery")); //} } else { - return AjaxResult.error(jsonResult.getInteger("code"), UniversalEnum.REQUEST_FAILED.getValue()); + return AjaxResult.success(new ArrayList<>()); } } } catch (Exception ignored) { } - return AjaxResult.error(UniversalEnum.REQUEST_FAILED.getValue()); + return AjaxResult.success(new ArrayList<>()); } From ee9061e10cbe9f8996fdece86a7bbad69adecd8e Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Thu, 18 Jul 2024 18:31:30 +0800 Subject: [PATCH 27/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=9B=91=E6=B5=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/ExternalInterfaceMonitoringTask.java | 287 +++++++++++++----- 1 file changed, 205 insertions(+), 82 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java b/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java index 8c6aa902..44fbf843 100644 --- a/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java +++ b/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java @@ -223,7 +223,7 @@ public class ExternalInterfaceMonitoringTask extends BaseController { /** * 交通流通用 */ - public void dcTrafficStatisticsCurrency(String path, String operationName) throws Exception { + public void dcTrafficStatisticsCurrency(String path, String operationName) { // 参数 RequestParams requestParams = new RequestParams(); @@ -232,18 +232,27 @@ public class ExternalInterfaceMonitoringTask extends BaseController { Map headers = new HashMap<>(); headers.put("Authorization", DcTrafficStatisticsServiceImpl.getAccessToken()); String url = UniversalEnum.DATA_CENTER_TRAFFIC_STATISTICS_IP_PORT.getValue() + path; - // 请求 - Response response = postRequestByHeadersAndParams(headers, url, requestParams); // 构造 ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.TRAFFIC_FLOW.getCode()); externalInterfaceMonitoring.setInterfaceName(operationName); - // 插入 - trafficFlowResultProcessing(externalInterfaceMonitoring, response); + try { + Response response = postRequestByHeadersAndParams(headers, url, requestParams); + // 插入 + trafficFlowResultProcessing(externalInterfaceMonitoring, response); + }catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } + } //车辆 - public void dcTrafficStatisticsCurrencyVehicle(String path, String operationName) throws Exception { + public void dcTrafficStatisticsCurrencyVehicle(String path, String operationName) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); LocalDate currentDate = LocalDate.now(); String nowYear = currentDate.format(formatter); @@ -264,18 +273,27 @@ public class ExternalInterfaceMonitoringTask extends BaseController { Map headers = new HashMap<>(); headers.put("Authorization", DcTrafficStatisticsServiceImpl.getAccessToken()); String url = UniversalEnum.DATA_CENTER_TRAFFIC_STATISTICS_IP_PORT.getValue() + path; - // 请求 - Response response = postRequestByHeadersAndParams(headers, url, requestParams); // 构造 ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.TRAFFIC_FLOW.getCode()); externalInterfaceMonitoring.setInterfaceName(operationName); - // 插入 - trafficFlowResultProcessing(externalInterfaceMonitoring, response); + try { + // 请求 + Response response = postRequestByHeadersAndParams(headers, url, requestParams); + // 插入 + trafficFlowResultProcessing(externalInterfaceMonitoring, response); + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } } //获取门架指标数据 - public void obtainTheShelfIndicatorData(String path, String operationName) throws Exception { + public void obtainTheShelfIndicatorData(String path, String operationName) { // 计算一小时前的时间点 DateTime lastHour = DateUtil.offsetHour(new Date(), UniversalEnum.MINUS_ONE.getNumber()); @@ -299,22 +317,33 @@ public class ExternalInterfaceMonitoringTask extends BaseController { Map headers = new HashMap<>(); headers.put("Authorization", DcTrafficStatisticsServiceImpl.getAccessToken()); - Response response // 请求响应 - = okHttp - .headers(headers) - .url(UniversalEnum.DATA_CENTER_TRAFFIC_STATISTICS_IP_PORT.getValue() + path) // 请求地址 - .data(requestParams) // 请求参数 - .post(); // 请求方法 + // 构造 ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.TRAFFIC_FLOW.getCode()); externalInterfaceMonitoring.setInterfaceName(operationName); - // 插入 - trafficFlowResultProcessing(externalInterfaceMonitoring, response); + + try { + Response response // 请求响应 + = okHttp + .headers(headers) + .url(UniversalEnum.DATA_CENTER_TRAFFIC_STATISTICS_IP_PORT.getValue() + path) // 请求地址 + .data(requestParams) // 请求参数 + .post(); // 请求方法 + // 插入 + trafficFlowResultProcessing(externalInterfaceMonitoring, response); + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } } //收费站 TollStation - public void dcTrafficStatisticsCurrencyTollStation(String path, String operationName, String stationType) throws Exception { + public void dcTrafficStatisticsCurrencyTollStation(String path, String operationName, String stationType) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); LocalDate currentDate = LocalDate.now(); String nowYear = currentDate.format(formatter); @@ -336,56 +365,84 @@ public class ExternalInterfaceMonitoringTask extends BaseController { Map headers = new HashMap<>(); headers.put("Authorization", DcTrafficStatisticsServiceImpl.getAccessToken()); String url = UniversalEnum.DATA_CENTER_TRAFFIC_STATISTICS_IP_PORT.getValue() + path; - // 请求 - Response response = postRequestByHeadersAndParams(headers, url, requestParams); // 构造 ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.TRAFFIC_FLOW.getCode()); externalInterfaceMonitoring.setInterfaceName(operationName); - // 插入 - trafficFlowResultProcessing(externalInterfaceMonitoring, response); + + try { + // 请求 + Response response = postRequestByHeadersAndParams(headers, url, requestParams); + // 插入 + trafficFlowResultProcessing(externalInterfaceMonitoring, response); + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } } /** * 全国气象数据 - 雷达数据 */ - public void getRadarData() throws Exception { + public void getRadarData() { ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); - OkHttp okHttp = new OkHttp(); - Response response // 请求响应 - = okHttp - .url(UniversalEnum.RADAR_DATA.getValue()) // 请求地址 - .get(); // 请求方法 externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.NATIONAL_METEOROLOGY.getCode()); externalInterfaceMonitoring.setInterfaceName("雷达数据"); - 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)); + + + try { + OkHttp okHttp = new OkHttp(); + Response response // 请求响应 + = okHttp + .url(UniversalEnum.RADAR_DATA.getValue()) // 请求地址 + .get(); // 请求方法 + 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)); + } + } else { + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setOperationResult(response.toString()); } - } else { + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); - externalInterfaceMonitoring.setOperationResult(response.toString()); + }finally { + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); } - externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); - externalInterfaceMonitoring.setOperatorName("系统"); - externalInterfaceMonitoring.setOperationTime(new Date()); - externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); } /** * 全国气象数据 - 雷达图 */ - public void getRadarChart() throws Exception { + public void getRadarChart() { Map headers = new HashMap<>(); headers.put("Referer", UniversalEnum.RADAR_MAP_WEATHER.getValue()); - Response response = getRequestByHeaders(headers, UniversalEnum.RADAR_MAP.getValue() + new Date().getTime()); ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.NATIONAL_METEOROLOGY.getCode()); externalInterfaceMonitoring.setInterfaceName("雷达图"); - insertIntoExternalInterface(externalInterfaceMonitoring, response); + + try { + Response response = getRequestByHeaders(headers, UniversalEnum.RADAR_MAP.getValue() + new Date().getTime()); + insertIntoExternalInterface(externalInterfaceMonitoring, response); + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } } /** @@ -398,25 +455,31 @@ public class ExternalInterfaceMonitoringTask extends BaseController { parameter.put("stakeNum", UniversalEnum.STAKE_NUM.getValue()); parameter.put("forecastHour", UniversalEnum.STAKE_NUM.getNumber()); parameter.put("managerId", UniversalEnum.MANAGER_ID.getValue()); - // 结果 - AjaxResult ajaxResult = weatherForecastController.currentWeatherAndForecastInformation(parameter); // 构造 ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.WEATHER.getCode()); externalInterfaceMonitoring.setInterfaceName("当前气象及预报信息查询"); - resultAnalysis(ajaxResult, externalInterfaceMonitoring); externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); externalInterfaceMonitoring.setOperatorName("系统"); externalInterfaceMonitoring.setOperationTime(new Date()); - // 插入 - externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + + try { + // 结果 + AjaxResult ajaxResult = weatherForecastController.currentWeatherAndForecastInformation(parameter); + resultAnalysis(ajaxResult, externalInterfaceMonitoring); + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + }finally { + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } } /** * 天气预报 - 当前气象预警信息查询 */ - public void currentWeatherWarningInformationQuery() throws Exception { + public void currentWeatherWarningInformationQuery() { // 参数 JSONObject weather = JSONObject.parseObject(configService.selectConfigByKey("weather")); HashMap parameter = new HashMap<>(); @@ -424,14 +487,25 @@ public class ExternalInterfaceMonitoringTask extends BaseController { parameter.put("earlyWorningLevel", UniversalEnum.EARLY_WORNING_LEVEL.getValue()); String url = weather.getString("get_earlyworning_info"); RequestParams requestParams = new RequestParams(parameter); - //结果 - Response response = postRequestByHeadersAndParams(new HashMap<>(), url, requestParams); + //构造 ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.WEATHER.getCode()); externalInterfaceMonitoring.setInterfaceName("当前气象预警信息查询"); - //插入 - insertIntoExternalInterface(externalInterfaceMonitoring, response); + + try { + //结果 + Response response = postRequestByHeadersAndParams(new HashMap<>(), url, requestParams); + //插入 + insertIntoExternalInterface(externalInterfaceMonitoring, response); + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } } /** @@ -448,14 +522,24 @@ public class ExternalInterfaceMonitoringTask extends BaseController { header.put("Authorization", videoTOKEN); - Response response = getRequestByHeaders(header, - cameraInfo.getString("URL") + UniversalEnum.EXAMPLE_QUERY_SYNC_CAMERA_DATA.getValue()); //构造 ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.VIDEO.getCode()); externalInterfaceMonitoring.setInterfaceName("查询同步相机数据"); - //插入 - videoResultInsertInto(externalInterfaceMonitoring, response); + + try { + Response response = getRequestByHeaders(header, + cameraInfo.getString("URL") + UniversalEnum.EXAMPLE_QUERY_SYNC_CAMERA_DATA.getValue()); + //插入 + videoResultInsertInto(externalInterfaceMonitoring, response); + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } } @@ -476,16 +560,26 @@ public class ExternalInterfaceMonitoringTask extends BaseController { header.put("Authorization", videoTOKEN); - Response response = postRequestByHeadersAndParams(header, - cameraInfo.getString("URL") + UniversalEnum.GET_VIDEO_STREAM_INFORMATION.getValue(), - requestParams); //构造 ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.VIDEO.getCode()); externalInterfaceMonitoring.setInterfaceName("获取视频流信息"); - //插入 - videoResultInsertInto(externalInterfaceMonitoring, response); + + try { + Response response = postRequestByHeadersAndParams(header, + cameraInfo.getString("URL") + UniversalEnum.GET_VIDEO_STREAM_INFORMATION.getValue(), + requestParams); + //插入 + videoResultInsertInto(externalInterfaceMonitoring, response); + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } } /** @@ -494,8 +588,6 @@ public class ExternalInterfaceMonitoringTask extends BaseController { public void queryPresetPositionList() throws Exception { JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo")); - OkHttp okHttp = new OkHttp(); - RequestParams requestParams = new RequestParams(); requestParams.put("camId", "57941"); @@ -507,16 +599,25 @@ public class ExternalInterfaceMonitoringTask extends BaseController { header.put("Authorization", videoTOKEN); - Response response = getRequestByHeadersByParam(header, - cameraInfo.getString("URL") + UniversalEnum.EXAMPLE_QUERY_THE_PRESET_BIT_LIST.getValue(), - requestParams); - //构造 ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.VIDEO.getCode()); externalInterfaceMonitoring.setInterfaceName("查询预置位列表"); - //插入 - videoResultInsertInto(externalInterfaceMonitoring, response); + + try { + Response response = getRequestByHeadersByParam(header, + cameraInfo.getString("URL") + UniversalEnum.EXAMPLE_QUERY_THE_PRESET_BIT_LIST.getValue(), + requestParams); + //插入 + videoResultInsertInto(externalInterfaceMonitoring, response); + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } } /** @@ -535,21 +636,32 @@ public class ExternalInterfaceMonitoringTask extends BaseController { } header.put("Authorization", videoTOKEN); - Response response = getRequestByHeadersByParam(header, - cameraInfo.getString("URL") + UniversalEnum.GET_CAMERA_INFORMATION_BY_ORGANIZATION.getValue(), - requestParams); //构造 ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.VIDEO.getCode()); externalInterfaceMonitoring.setInterfaceName("根据组织机构获取摄像机信息"); - //插入 - videoResultInsertInto(externalInterfaceMonitoring, response); + + + try { + Response response = getRequestByHeadersByParam(header, + cameraInfo.getString("URL") + UniversalEnum.GET_CAMERA_INFORMATION_BY_ORGANIZATION.getValue(), + requestParams); + //插入 + videoResultInsertInto(externalInterfaceMonitoring, response); + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } } /** * 云平台控制 */ - public void cloudPlatformControl() throws Exception { + public void cloudPlatformControl() { JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo")); RequestParams requestParams = new RequestParams(); @@ -563,15 +675,26 @@ public class ExternalInterfaceMonitoringTask extends BaseController { header.put("Authorization", videoTOKEN); - Response response = getRequestByHeadersByParam(header, - cameraInfo.getString("URL") + UniversalEnum.CLOUD_PLATFORM_CONTROL.getValue(), - requestParams); //构造 ExternalInterfaceMonitoring externalInterfaceMonitoring = new ExternalInterfaceMonitoring(); externalInterfaceMonitoring.setInterfaceOwnership(InterfaceOwnershipEnum.VIDEO.getCode()); externalInterfaceMonitoring.setInterfaceName("云平台控制"); - //插入 - videoResultInsertInto(externalInterfaceMonitoring, response); + + + try { + Response response = getRequestByHeadersByParam(header, + cameraInfo.getString("URL") + UniversalEnum.CLOUD_PLATFORM_CONTROL.getValue(), + requestParams); + //插入 + videoResultInsertInto(externalInterfaceMonitoring, response); + } catch (Exception e) { + externalInterfaceMonitoring.setOperationResult(e.getMessage()); + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); + externalInterfaceMonitoring.setOperatorName("系统"); + externalInterfaceMonitoring.setOperationTime(new Date()); + externalInterfaceMonitoringMapper.insert(externalInterfaceMonitoring); + } } /** From e09405a133bb7cf9753214eeeb898633029c5b71 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Thu, 18 Jul 2024 18:41:44 +0800 Subject: [PATCH 28/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=9B=91=E6=B5=8B=E9=87=8D=E7=BD=AE=E6=8C=89=E9=92=AE=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/monitor/Interface/index.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ruoyi-ui/src/views/monitor/Interface/index.vue b/ruoyi-ui/src/views/monitor/Interface/index.vue index 66b89320..d429020c 100644 --- a/ruoyi-ui/src/views/monitor/Interface/index.vue +++ b/ruoyi-ui/src/views/monitor/Interface/index.vue @@ -160,6 +160,8 @@ export default { }, /** 重置 */ resetQuery() { + this.queryParams.startTime = undefined; + this.queryParams.endTime = undefined; this.resetForm("queryForm"); this.handleQuery(); },