From 8abda21eb48f9d17941b4c2b60bda1ee643b1bd0 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Thu, 18 Jul 2024 10:01:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E5=A4=87=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E8=B0=83=E7=94=A8=E8=BF=94=E5=9B=9E=E5=86=85=E5=AE=B9?= =?UTF-8?q?=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");