Browse Source

新增太阳能板设备定时任务

develop
zhaoxianglong 8 months ago
parent
commit
cb42bbb9d0
  1. 34
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

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

@ -28,6 +28,7 @@ import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Parameter;
import okhttp3.Response;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@ -933,4 +934,37 @@ public class DcDeviceController extends BaseController {
// }
//}
/***
* 太阳能板设备定时任务
*/
@Scheduled(cron = "0 0/5 * * * ?")
public void ConfluenceAreaEarlyWarningDeviceBatteryLowWarning() throws HttpException, IOException, InterruptedException {
DcDevice dcDevice = new DcDevice();
dcDevice.setDeviceType(UniversalEnum.FIFTEEN.getValue());
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.ZERO.getNumber(); i < UniversalEnum.SIX.getNumber(); i++) {
JSONObject function = new JSONObject();
function.put("functionId", UniversalEnum.A.getValue() + (i + UniversalEnum.ONE.getNumber()));
function.put("params", new JSONObject());
functions.add(function);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("devices", devices);
jsonObject.put("functions", functions);
batchInvokedFunction(jsonObject);
}
}

Loading…
Cancel
Save