Browse Source

太阳能定时

develop
王兴琳 2 months ago
parent
commit
2f9c866da5
  1. 31
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

31
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -63,8 +63,15 @@ public class DcDeviceController extends BaseController {
@Resource @Resource
private IDcDeviceService dcDeviceService; private IDcDeviceService dcDeviceService;
/*
@Value("${iot.address}") @Value("${iot.address}")
private String iotAddress; private String iotAddress;
*/
private static String iotAddress;
@Value("${iot.address}")
public void setIotAddress(String url) {
iotAddress = url;
}
@Resource @Resource
private BroadcastController broadcastController; private BroadcastController broadcastController;
@ -405,7 +412,7 @@ public class DcDeviceController extends BaseController {
parameter.put("deviceType","15"); parameter.put("deviceType","15");
parameter.put("endStakeMark",endStakeMark); parameter.put("endStakeMark",endStakeMark);
parameter.put("startStakeMark",startStakeMark); parameter.put("startStakeMark",startStakeMark);
// parameter.put("deviceState","1"); parameter.put("deviceState","1");
// 创建一个映射来存储按小时汇总的数据 // 创建一个映射来存储按小时汇总的数据
Map<String, Double> allDevicesHourlyAggregates = new TreeMap<>(); Map<String, Double> allDevicesHourlyAggregates = new TreeMap<>();
@ -471,7 +478,7 @@ public class DcDeviceController extends BaseController {
parameters.put("deviceType", "15"); parameters.put("deviceType", "15");
parameters.put("endStakeMark", endStakeMark); parameters.put("endStakeMark", endStakeMark);
parameters.put("startStakeMark", startStakeMark); parameters.put("startStakeMark", startStakeMark);
// parameters.put("deviceState", "1"); parameters.put("deviceState", "1");
// List<String> propertyIds = Arrays.asList("visibility", "wetSlipperyCoefficient", "waterFilmIceSnowValue"); // List<String> propertyIds = Arrays.asList("visibility", "wetSlipperyCoefficient", "waterFilmIceSnowValue");
//generatingPower 发电功率 //"cumulativeElectricityConsumptionInTheYear", //当年累计用电量 //generatingPower 发电功率 //"cumulativeElectricityConsumptionInTheYear", //当年累计用电量
@ -1385,6 +1392,7 @@ public class DcDeviceController extends BaseController {
public AjaxResult ConfluenceAreaEarlyWarningDeviceBatteryLowWarning() throws HttpException, IOException, InterruptedException { public AjaxResult ConfluenceAreaEarlyWarningDeviceBatteryLowWarning() throws HttpException, IOException, InterruptedException {
DcDevice dcDevice = new DcDevice(); DcDevice dcDevice = new DcDevice();
dcDevice.setDeviceType(UniversalEnum.FIFTEEN.getValue()); dcDevice.setDeviceType(UniversalEnum.FIFTEEN.getValue());
dcDevice.setDeviceState(UniversalEnum.ONE.getValue());
IDcDeviceService dcDeviceService = SpringUtils.getBean(IDcDeviceService.class); IDcDeviceService dcDeviceService = SpringUtils.getBean(IDcDeviceService.class);
List<DcDevice> dcDeviceList = dcDeviceService.listDevice(dcDevice); List<DcDevice> dcDeviceList = dcDeviceService.listDevice(dcDevice);
@ -1415,7 +1423,24 @@ public class DcDeviceController extends BaseController {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("devices", devices); jsonObject.put("devices", devices);
jsonObject.put("functions", functions); jsonObject.put("functions", functions);
return batchInvokedFunction(jsonObject); return batchInvokedFunction2(jsonObject);
}
public AjaxResult batchInvokedFunction2(@RequestBody Map<String, Object> props) throws HttpException, IOException, InterruptedException {
ArrayList<JSONObject> devices = (ArrayList<JSONObject>) props.get("devices");
ArrayList<JSONObject> functions = (ArrayList<JSONObject>) 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);
} }
} }

Loading…
Cancel
Save