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); } }