From 14817411aab10ef8837116efc267effc057c0119 Mon Sep 17 00:00:00 2001 From: xuyang <748613696@qq.com> Date: Wed, 8 Nov 2023 16:17:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E6=97=A5=E8=AE=BE=E5=A4=87=E6=8E=A5?= =?UTF-8?q?=E5=85=A5=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 --- .../access/runner/AccessScheduledTask.java | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/runner/AccessScheduledTask.java b/iot-access/access-boot/src/main/java/com/njcn/access/runner/AccessScheduledTask.java index cac5530..854d7e0 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/runner/AccessScheduledTask.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/runner/AccessScheduledTask.java @@ -1,50 +1,50 @@ -//package com.njcn.access.runner; -// -//import com.njcn.access.service.ICsEquipmentDeliveryService; -//import com.njcn.access.service.ICsTopicService; -//import com.njcn.access.service.impl.CsDeviceServiceImpl; -//import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.scheduling.annotation.Scheduled; -//import org.springframework.stereotype.Component; -// -//import javax.annotation.Resource; -//import java.util.List; -//import java.util.Objects; -// -///** -// * 类的介绍:防止设备掉线 系统未能调整,做一个定时任务,每天凌晨将所有设备重新接入 -// * -// * @author xuyang -// * @version 1.0.0 -// * @createTime 2023/8/28 14:21 -// */ -//@Component -//@Slf4j -//public class AccessScheduledTask { -// -// @Resource -// private CsDeviceServiceImpl csDeviceService; -// -// @Resource -// private ICsTopicService csTopicService; -// -// @Resource -// private ICsEquipmentDeliveryService csEquipmentDeliveryService; -// -// /** -// * {秒数} {分钟} {小时} {日期} {月份} {星期} {年份(可为空)} -// */ -// @Scheduled(cron = "0 0 0 * * ?") -// public void executeTask() { -// log.info("每日凌晨定时任务执行"); -// List list = csEquipmentDeliveryService.getAll(); -// list.forEach(item->{ -// String version = csTopicService.getVersion(item.getNdid()); -// if (!Objects.isNull(version)){ -// csDeviceService.devAccess(item.getNdid(),version); -// } -// }); -// } -// -//} +package com.njcn.access.runner; + +import com.njcn.access.service.ICsEquipmentDeliveryService; +import com.njcn.access.service.ICsTopicService; +import com.njcn.access.service.impl.CsDeviceServiceImpl; +import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Objects; + +/** + * 类的介绍:防止设备掉线 系统未能调整,做一个定时任务,每天凌晨将所有设备重新接入 + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/8/28 14:21 + */ +@Component +@Slf4j +public class AccessScheduledTask { + + @Resource + private CsDeviceServiceImpl csDeviceService; + + @Resource + private ICsTopicService csTopicService; + + @Resource + private ICsEquipmentDeliveryService csEquipmentDeliveryService; + + /** + * {秒数} {分钟} {小时} {日期} {月份} {星期} {年份(可为空)} + */ + @Scheduled(cron = "0 0 0 * * ?") + public void executeTask() { + log.info("每日凌晨定时任务执行"); + List list = csEquipmentDeliveryService.getAll(); + list.forEach(item->{ + String version = csTopicService.getVersion(item.getNdid()); + if (!Objects.isNull(version)){ + csDeviceService.devAccess(item.getNdid(),version); + } + }); + } + +}