Browse Source

机柜定时菜取数据

develop
wangsixiang 4 weeks ago
parent
commit
1ecd254af1
  1. 36
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

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

@ -1426,6 +1426,42 @@ public class DcDeviceController extends BaseController {
jsonObject.put("functions", functions); jsonObject.put("functions", functions);
return batchInvokedFunction2(jsonObject); return batchInvokedFunction2(jsonObject);
} }
//一体机柜空调定时调用,采数据
@Scheduled(cron = "0 11/10 * * * ?")
public AjaxResult integratedCabinetAirConditioner() throws InterruptedException, IOException, HttpException {
DcDevice dcDevice = new DcDevice();
dcDevice.setDeviceType(UniversalEnum.SEVENTEEN.getValue());
dcDevice.setDeviceState(UniversalEnum.ONE.getValue());
IDcDeviceService dcDeviceService = SpringUtils.getBean(IDcDeviceService.class);
List<DcDevice> dcDeviceList = dcDeviceService.listDevice(dcDevice);
ArrayList devices = new ArrayList<>();
for (DcDevice device : dcDeviceList) {
String iotDeviceId = device.getIotDeviceId();
if (iotDeviceId != null && !iotDeviceId.equals(UniversalEnum.EMPTY_STRING.getValue())) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", device.getId());
jsonObject.put("iotDeviceId", device.getIotDeviceId());
jsonObject.put("deviceType", device.getDeviceType());
devices.add(jsonObject);
}
}
ArrayList functions = new ArrayList();
for (int i = UniversalEnum.ONE.getNumber(); i <= UniversalEnum.THREE.getNumber(); i++) {
JSONObject function = new JSONObject();
if (i == 2) {
continue;
}
String valueOf = String.valueOf(i);
function.put("functionId", "0" + valueOf);
function.put("params", new JSONObject());
functions.add(function);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("devices", devices);
jsonObject.put("functions", functions);
return batchInvokedFunction2(jsonObject);
}
public AjaxResult batchInvokedFunction2(@RequestBody Map<String, Object> props) throws HttpException, IOException, InterruptedException { public AjaxResult batchInvokedFunction2(@RequestBody Map<String, Object> props) throws HttpException, IOException, InterruptedException {
ArrayList<JSONObject> devices = (ArrayList<JSONObject>) props.get("devices"); ArrayList<JSONObject> devices = (ArrayList<JSONObject>) props.get("devices");
ArrayList<JSONObject> functions = (ArrayList<JSONObject>) props.get("functions"); ArrayList<JSONObject> functions = (ArrayList<JSONObject>) props.get("functions");

Loading…
Cancel
Save