数据库删除一年前

liuzhou-yancao
qiushui 4 years ago
parent f6c011c307
commit 63a1b65081

@ -1,9 +1,12 @@
package com.zhehekeji.web.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.zhehekeji.web.config.ConfigProperties;
import com.zhehekeji.web.entity.LightSource;
import com.zhehekeji.web.mapper.CheckLogMapper;
import com.zhehekeji.web.mapper.LightSourceMapper;
import com.zhehekeji.web.mapper.StockLogMapper;
import com.zhehekeji.web.service.damLightSource.JYDAMEquip;
import com.zhehekeji.web.service.damLightSource.JYDamHelper;
import com.zhehekeji.web.service.hikLightSource.HikControlSocket;
@ -46,14 +49,23 @@ public class CronTab {
//10分钟
private static BigInteger timeDIff = BigInteger.valueOf(10*60*1000);
@Resource
private CheckLogMapper checkLogMapper;
@Resource
private StockLogMapper stockLogMapper;
private static int gByte = 1024* 1024 * 1024;
@Scheduled(cron = "0 0 0 * * ?")
//@Scheduled(cron = "0 0/1 * * * *")
public void file() {
log.info(" corn delete file");
now = LocalDateTime.now();
UpdateWrapper updateWrapper = new UpdateWrapper();
updateWrapper.lt("create_time",now.minusYears(1));
checkLogMapper.delete(updateWrapper);
stockLogMapper.delete(updateWrapper);
File dir = new File(configProperties.getSavePath().getMediaPath());
long space = dir.getFreeSpace() / gByte;
log.info(" free space :{}",space);
@ -63,6 +75,7 @@ public class CronTab {
checkFileTime(dir,configProperties.getDeleteFileDays());
File dir2 = new File(configProperties.getSavePath().getMp4Path());
checkFileTime(dir2,configProperties.getDeleteFileDays());
}
public static void putTime(Integer streetId){

Loading…
Cancel
Save