v10,redis缓存默认改为120秒,数据库备份增加保留时间,标签删除同时删除设备关联
This commit is contained in:
parent
44866e4ef6
commit
c5f2ab160b
|
@ -1,13 +1,10 @@
|
|||
|
||||
|
||||
package net.shapelight.modules.job.task;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.shapelight.common.utils.DateUtils;
|
||||
import net.shapelight.modules.sys.entity.SysDbBakEntity;
|
||||
import net.shapelight.modules.sys.service.SysDbBakService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -20,8 +17,8 @@ import java.util.Date;
|
|||
*/
|
||||
@Component("dbBakTask")
|
||||
@Data
|
||||
@Slf4j
|
||||
public class DbBakTask implements ITask {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
private SysDbBakService sysDbBakService;
|
||||
|
@ -43,7 +40,7 @@ public class DbBakTask implements ITask {
|
|||
|
||||
@Override
|
||||
public void run(String params){
|
||||
logger.debug("dbBakTask定时任务正在执行,参数为:{}", params);
|
||||
log.debug("dbBakTask定时任务正在执行,参数为:{}", params);
|
||||
//System.out.println("执行定时任务》》》"+new Date());
|
||||
/*File uploadDir = new File(dbFilePath);
|
||||
if (!uploadDir.exists())
|
||||
|
@ -90,7 +87,7 @@ public class DbBakTask implements ITask {
|
|||
//System.out.println("备份数据库成功!!!");
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
logger.debug("备份数据库失败", params);
|
||||
log.debug("备份数据库失败", params);
|
||||
e.printStackTrace();
|
||||
|
||||
}finally {
|
||||
|
@ -105,6 +102,28 @@ public class DbBakTask implements ITask {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//删除历史文件
|
||||
int days = 30;//默认30天
|
||||
if(params != null){
|
||||
days = Integer.parseInt(params);
|
||||
}
|
||||
File[] files = fileDir.listFiles();
|
||||
if (files != null){
|
||||
for(File file: files){
|
||||
if(file.isFile()){
|
||||
String fileName = file.getName();
|
||||
long time = file.lastModified();
|
||||
Date upDate = new Date(time);
|
||||
Date now = new Date();
|
||||
long msNum = now.getTime()-upDate.getTime();
|
||||
long dayNum = msNum/(24*60*60*1000);
|
||||
if(dayNum > days){
|
||||
file.delete();
|
||||
log.debug("删除过期文件:"+fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package net.shapelight.modules.ten.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
@ -12,7 +9,10 @@ import io.swagger.annotations.ApiImplicitParam;
|
|||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.shapelight.common.annotation.SysLog;
|
||||
import net.shapelight.common.utils.Constant;
|
||||
import net.shapelight.modules.sys.controller.AbstractController;
|
||||
import net.shapelight.modules.ten.entity.TenDeviceLabelEntity;
|
||||
import net.shapelight.modules.ten.service.TenDeviceLabelService;
|
||||
import net.shapelight.modules.ten.service.TenPersonService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -37,6 +37,8 @@ public class TenLabelController extends AbstractController {
|
|||
private TenLabelService tenLabelService;
|
||||
@Autowired
|
||||
private TenPersonService tenPersonService;
|
||||
@Autowired
|
||||
private TenDeviceLabelService tenDeviceLabelService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
|
@ -141,6 +143,10 @@ public class TenLabelController extends AbstractController {
|
|||
if(pCount>0){
|
||||
return R.error("此标签已使用");
|
||||
}
|
||||
|
||||
//删除设备绑定关系:
|
||||
tenDeviceLabelService.remove(new QueryWrapper<TenDeviceLabelEntity>()
|
||||
.eq("label_id",id));
|
||||
tenLabelService.removeByIds(Arrays.asList(labelIds));
|
||||
return R.ok();
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ public class RedisConfig {
|
|||
public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
|
||||
return new RedisCacheManager(
|
||||
RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory),
|
||||
this.getRedisCacheConfigurationWithTtl(600), // 默认策略,未配置的 key 会使用这个
|
||||
this.getRedisCacheConfigurationWithTtl(120), // 默认策略,未配置的 key 会使用这个
|
||||
this.getRedisCacheConfigurationMap() // 指定 key 策略
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue