| | |
| | | package com.zy.asrs.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.entity.BasMap; |
| | | import com.zy.asrs.service.BasMapService; |
| | | import com.zy.common.utils.RedisUtil; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | @Slf4j |
| | |
| | | */ |
| | | @Scheduled(cron = "1 * * * * ? ") |
| | | private void execute(){ |
| | | for (int i = 1; i <= 4; i++) {//总共四层楼 |
| | | Object data = redisUtil.get(RedisKeyType.MAP.key + i); |
| | | List<BasMap> basMaps = basMapService.selectList(new EntityWrapper<BasMap>().orderBy("lev", true)); |
| | | for (BasMap basMap : basMaps) { |
| | | Integer lev = basMap.getLev(); |
| | | Object data = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (data == null) { |
| | | continue; |
| | | } |
| | | |
| | | BasMap redisMap = JSON.parseObject(data.toString(), BasMap.class); |
| | | |
| | | BasMap basMap = basMapService.selectLatestMap(i); |
| | | if (basMap == null) { |
| | | continue; |
| | | } |
| | | |
| | | basMap.setLastData(basMap.getData()); |
| | | basMap.setData(redisMap.getData()); |
| | | basMap.setUpdateTime(new Date()); |
| | | |
| | | basMapService.updateById(basMap);//更新 |
| | | } |
| | | } |