From 2f9c866da5548b6a37c4016bec7c5a8f2ee22462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Fri, 11 Oct 2024 17:30:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=AA=E9=98=B3=E8=83=BD=E5=AE=9A=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcDeviceController.java | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 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 f4a52ba9..4872caaa 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 @@ -63,8 +63,15 @@ public class DcDeviceController extends BaseController { @Resource private IDcDeviceService dcDeviceService; +/* @Value("${iot.address}") private String iotAddress; +*/ + private static String iotAddress; + @Value("${iot.address}") + public void setIotAddress(String url) { + iotAddress = url; + } @Resource private BroadcastController broadcastController; @@ -405,7 +412,7 @@ public class DcDeviceController extends BaseController { parameter.put("deviceType","15"); parameter.put("endStakeMark",endStakeMark); parameter.put("startStakeMark",startStakeMark); - // parameter.put("deviceState","1"); + parameter.put("deviceState","1"); // 创建一个映射来存储按小时汇总的数据 Map allDevicesHourlyAggregates = new TreeMap<>(); @@ -471,7 +478,7 @@ public class DcDeviceController extends BaseController { parameters.put("deviceType", "15"); parameters.put("endStakeMark", endStakeMark); parameters.put("startStakeMark", startStakeMark); - // parameters.put("deviceState", "1"); + parameters.put("deviceState", "1"); // List propertyIds = Arrays.asList("visibility", "wetSlipperyCoefficient", "waterFilmIceSnowValue"); //generatingPower 发电功率 //"cumulativeElectricityConsumptionInTheYear", //当年累计用电量 @@ -1385,6 +1392,7 @@ public class DcDeviceController extends BaseController { public AjaxResult ConfluenceAreaEarlyWarningDeviceBatteryLowWarning() throws HttpException, IOException, InterruptedException { DcDevice dcDevice = new DcDevice(); dcDevice.setDeviceType(UniversalEnum.FIFTEEN.getValue()); + dcDevice.setDeviceState(UniversalEnum.ONE.getValue()); IDcDeviceService dcDeviceService = SpringUtils.getBean(IDcDeviceService.class); List dcDeviceList = dcDeviceService.listDevice(dcDevice); @@ -1415,7 +1423,24 @@ public class DcDeviceController extends BaseController { JSONObject jsonObject = new JSONObject(); jsonObject.put("devices", devices); jsonObject.put("functions", functions); - return batchInvokedFunction(jsonObject); + return batchInvokedFunction2(jsonObject); + } + public AjaxResult batchInvokedFunction2(@RequestBody Map props) throws HttpException, IOException, InterruptedException { + ArrayList devices = (ArrayList) props.get("devices"); + ArrayList functions = (ArrayList) props.get("functions"); + JSONArray resultArray = new JSONArray(); + for (Object dev : devices) { + JSONObject device = (JSONObject) JSON.toJSON(dev); + String iotDeviceId = device.getString("iotDeviceId"); + for (Object function : functions) { + JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function); + 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); + } + } + return AjaxResult.success(resultArray); } }