亳州修改下线定时任务

ds-bozhou
luyya 2026-04-20 10:18:27 +08:00
parent 7aca2c9649
commit 7961588e39
1 changed files with 4 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.redis.utils.RedisUtils; import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.data2es.domain.EsGpsInfoVO2; import org.dromara.data2es.domain.EsGpsInfoVO2;
import org.dromara.data2es.service.IGpsService; import org.dromara.data2es.service.IGpsService;
@ -22,13 +23,14 @@ import java.util.List;
* @date 2021-05-18 18:23 * @date 2021-05-18 18:23
*/ */
@Slf4j
@Configuration @Configuration
public class RedisOnlineUserSchedule { public class RedisOnlineUserSchedule {
@Autowired @Autowired
IGpsService gpsService; IGpsService gpsService;
@Scheduled(cron = "0 0/20 * * * ?") @Scheduled(cron = "0 0/10 * * * ?")
public void redisTimeOutRemove(){ public void redisTimeOutRemove(){
List<JSONObject> jlist = RedisUtils.searchAndGetKeysValues("online_users:*"); List<JSONObject> jlist = RedisUtils.searchAndGetKeysValues("online_users:*");
List<EsGpsInfoVO2> gpsInfoVO2s = new ArrayList<>(); List<EsGpsInfoVO2> gpsInfoVO2s = new ArrayList<>();
@ -48,6 +50,7 @@ public class RedisOnlineUserSchedule {
} }
} }
if (gpsInfoVO2s.size() > 0){ if (gpsInfoVO2s.size() > 0){
log.error("下线设备集合={}",gpsInfoVO2s.toString());
gpsService.updateOnlineStatusBatch(gpsInfoVO2s); gpsService.updateOnlineStatusBatch(gpsInfoVO2s);
} }
} }