博客变为论坛,修改编辑器为正常编辑器
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.quinn.task;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.quinn.common.QuinnConstant;
|
||||
import com.quinn.pojo.Source;
|
||||
import com.quinn.service.SourceService;
|
||||
@@ -16,7 +17,7 @@ import java.util.List;
|
||||
*
|
||||
* @author limqsh
|
||||
*/
|
||||
//@Component
|
||||
@Component
|
||||
public class UpdateViewTask {
|
||||
|
||||
@Resource
|
||||
@@ -28,18 +29,24 @@ public class UpdateViewTask {
|
||||
/**
|
||||
* 每小时执行一次
|
||||
*/
|
||||
// @Scheduled(cron = "0 0 */1 * * ?")
|
||||
@Scheduled(cron = "0 0 */1 * * ?")
|
||||
public void execute(){
|
||||
List<Source> list = sourceService.list(null);
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
list.forEach(x->{
|
||||
String downTimes = (String) redisUtils.get(QuinnConstant.SOURCE_KEY + x.getId());
|
||||
if (!StringUtils.isEmpty(downTimes)){
|
||||
x.setDownRecord(Integer.parseInt(downTimes));
|
||||
sourceService.updateById(x);
|
||||
List<String> keys = redisUtils.scan(QuinnConstant.SOURCE_KEY);
|
||||
// List<Source> list = sourceService.list(null);
|
||||
if (!CollectionUtils.isEmpty(keys)){
|
||||
keys.forEach(x->{
|
||||
Source source = sourceService.getById(getIdFromKey(x,QuinnConstant.SOURCE_KEY));
|
||||
if (source != null && !StringUtils.isEmpty(source.getSourceName())){
|
||||
source.setDownRecord(Integer.parseInt(redisUtils.get(x)));
|
||||
sourceService.updateById(source);
|
||||
redisUtils.del(x);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private String getIdFromKey(String key,String keyType){
|
||||
return key.substring(keyType.length());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user