From cb42bbb9d00a6eaa358cc2cbb87847032d1baa21 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Tue, 2 Jul 2024 11:57:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=A4=AA=E9=98=B3=E8=83=BD?= =?UTF-8?q?=E6=9D=BF=E8=AE=BE=E5=A4=87=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcDeviceController.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) 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 47ae34ad..01f88b6e 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 @@ -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 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); + } + }