文件模块定时清除任务迁移

This commit is contained in:
weizhiqiang 2022-08-07 21:41:18 +08:00
parent eeec8c90f5
commit bb9266e59f
2 changed files with 1 additions and 79 deletions

View file

@ -3,7 +3,7 @@
> 基于SpringBoot 2.X框架为中小企业打造开源好用的ERP软件。主要模块有零售管理、采购管理、销售管理、仓库管理、财务管理、报表查询、系统管理等。支持预付款、收入支出、仓库调拨、组装拆卸、订单生产等特色功能。拥有库存状况、出入库统计等报表。对权限进行精确划分同时支持多系统集成方案可与OACRM知识库等多个系统进行集成使用。同时对角色和权限进行了细致全面控制精确到每个按钮和菜单。集成apollo配置中心。
- 该项目企业版有体验地址,需要的加微信
- 最新资讯: [2022-07-25 智能制造云办公 v3.7.23 发布 数据权限](https://www.oschina.net/news/204027)
- 最新资讯:[2022-08-08 智能制造云办公 v3.7.25 发布,微服务拆分](https://www.bilibili.com/read/cv17978946)
- [软件更新资讯](https://gitee.com/doc_wei01/skyeye/blob/company_server/HISTORY_UPDATE.md)
- 开源版请下载`master`分支
- [项目功能结构](https://docs.qq.com/flowchart/DYUFQQnlCUm9Ua2FI)

View file

@ -1,78 +0,0 @@
/*******************************************************************************
* Copyright 卫志强 QQ598748873@qq.com Inc. All rights reserved. 开源地址https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.sys.quartz;
import com.skyeye.common.util.DateUtil;
import com.skyeye.jedis.JedisClientService;
import com.xxl.job.core.handler.annotation.XxlJob;
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;
import java.io.File;
/**
* @ClassName: TemporaryFileDeleteQuartz
* @Description: 定时删除临时的云压缩文件
* @author: skyeye云系列--卫志强
* @date: 2021/6/14 11:11
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@Component
public class TemporaryFileDeleteQuartz {
private static Logger log = LoggerFactory.getLogger(TemporaryFileDeleteQuartz.class);
@Autowired
public JedisClientService jedisClientService;
@Value("${IMAGES_PATH}")
private String tPath;
private long DAY_MINUTE_TIME = 24 * 60;
/**
* 定时删除临时的云压缩文件,每天23点执行
*/
@XxlJob("temporaryFileDeleteQuartz")
public void deleteTemporaryFile() {
log.info("TemporaryFileDeleteQuartz start");
try {
// 临时文件存储路径
String basePath = tPath + "\\upload\\fileconsole\\temporaryfile\\";
File pack = new File(basePath);
if (!pack.isDirectory()) {
// 创建目录
pack.mkdirs();
}
// 读取指定路径下的文件名和目录名
getAllFileByRecursion(pack.listFiles());
} catch (Exception e) {
log.warn("TemporaryFileDeleteQuartz error.", e);
}
log.info("TemporaryFileDeleteQuartz end");
}
public void getAllFileByRecursion(File[] fileList) {
for (int i = 0; i < fileList.length; i++) {
if (fileList[i].isFile()) {
// 如果是文件,获取文件最后的修改时间
String upTime = DateUtil.getDateStr(fileList[i].lastModified());
// 获取当前时间和文件最后修改时间的时间差多少分钟
long time = DateUtil.getDistanceMinute(upTime, DateUtil.getTimeAndToString());
if (time > DAY_MINUTE_TIME) {
fileList[i].delete();
}
} else {
//如果是文件夹
getAllFileByRecursion(fileList[i].listFiles());
}
}
}
}