Commit 1a4aa715 by 宋祥

Merge branch 'dev-sx' of http://git.pseer.com:8800/platform/hg-smart into dev

parents 97636a5c 4974c17c
package com.baosight.hggp.core.tools;
import com.baosight.hggp.core.constant.OSConstant;
import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.FileUtils;
import java.io.File;
import java.time.LocalDate;
import lombok.extern.slf4j.Slf4j;
/**
* @author:songx
* @date:2024/10/12,10:27
*/
@Slf4j
public class FileTools {
/**
* 清理ZIP文件
*/
public static void clearZip() {
File zipFolder = new File(OSConstant.ZIP_DIR);
File[] zipFolderFiles = zipFolder.listFiles();
if (zipFolderFiles.length == 0) {
log.warn("清理ZIP文件:无有效的文件");
}
for (File zipFolderFile : zipFolderFiles) {
String folderName = zipFolderFile.getName();
// 当天以前的文件夹全部删除
if (LocalDate.parse(folderName, DateUtils.SHORT_DATE).isBefore(LocalDate.now())) {
FileUtils.deleteFiles(zipFolderFile);
}
}
log.info("清理ZIP文件成功!!!");
}
}
......@@ -7,6 +7,7 @@ import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.core.tools.FileTools;
import com.baosight.hggp.core.tools.Iplat4jTools;
import com.baosight.hggp.core.utils.Iplat4jUtils;
import com.baosight.hggp.hg.constant.HGConstant;
......@@ -581,4 +582,19 @@ public class ServiceHGWD001 extends ServiceEPBase {
return inInfo;
}
/**
* 清理下载的文件
*
* @param inInfo
* @return
*/
public EiInfo clearDownload(EiInfo inInfo) {
try {
FileTools.clearZip();
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "清理下载的文件失败");
}
return inInfo;
}
}
package com.baosight.hggp.job;
import com.baosight.hggp.core.constant.OSConstant;
import com.baosight.hggp.core.tools.FileTools;
import com.baosight.hggp.util.DateUtil;
import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.FileUtils;
......@@ -29,19 +30,7 @@ public class ClearZipJob {
@Scheduled(cron = "0 45 0/3 * * ? ")
public void clearZipFile() {
try {
File zipFolder = new File(OSConstant.ZIP_DIR);
File[] zipFolderFiles = zipFolder.listFiles();
if (zipFolderFiles.length == 0) {
log.warn("清理ZIP文件:无有效的文件");
}
for (File zipFolderFile : zipFolderFiles) {
String folderName = zipFolderFile.getName();
// 当天以前的文件夹全部删除
if (LocalDate.parse(folderName, DateUtils.SHORT_DATE).isBefore(LocalDate.now())) {
FileUtils.deleteFiles(zipFolderFile);
}
}
log.info("清理ZIP文件成功!!!");
FileTools.clearZip();
} catch (Exception e) {
log.error("清理ZIP文件失败:{}", e.getMessage(), e);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment