Commit 5a2f3048 authored by fangxinjiang's avatar fangxinjiang

Merge remote-tracking branch 'origin/MVP1.7.21' into MVP1.7.21

parents 3e1c78dc 6fc6da3d
...@@ -205,6 +205,18 @@ public class SocialTask { ...@@ -205,6 +205,18 @@ public class SocialTask {
"/tsocialfriend/inner/doPushFriend","", Object.class, SecurityConstants.FROM_IN); "/tsocialfriend/inner/doPushFriend","", Object.class, SecurityConstants.FROM_IN);
log.info("------------1定时任务推送税友-定时任务结束------------"); log.info("------------1定时任务推送税友-定时任务结束------------");
} }
/**
* @Description: 定时任务清理临时文件
* @Author: hgw
* @Date: 20260409
**/
public void doClearFriend() {
log.info("------------定时任务清理临时文件-定时任务开始------------");
HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),
"/tsocialfriend/inner/doClearFriend","", Object.class, SecurityConstants.FROM_IN);
log.info("------------定时任务清理临时文件-定时任务结束------------");
}
/** /**
* @Description: 2定时任务获取税友 * @Description: 2定时任务获取税友
* @Author: hgw * @Author: hgw
......
...@@ -87,6 +87,14 @@ public class TSocialFriendController { ...@@ -87,6 +87,14 @@ public class TSocialFriendController {
return tSocialFriendPushService.pushFriend(null, null, CommonConstants.ONE_INT, null); return tSocialFriendPushService.pushFriend(null, null, CommonConstants.ONE_INT, null);
} }
@Operation(description = "定时任务清理临时文件")
@PostMapping("/inner/doClearFriend")
@SysLog("定时任务清理临时文件")
@Inner
public void doClearFriend() {
tSocialFriendPushService.doClearFriend();
}
@Operation(description = "2定时任务获取税友") @Operation(description = "2定时任务获取税友")
@PostMapping("/inner/doGetFriendByRequestId") @PostMapping("/inner/doGetFriendByRequestId")
@SysLog("2定时任务获取税友") @SysLog("2定时任务获取税友")
......
...@@ -43,6 +43,9 @@ public interface TSocialFriendPushService extends IService<TSocialInfo> { ...@@ -43,6 +43,9 @@ public interface TSocialFriendPushService extends IService<TSocialInfo> {
**/ **/
R<String> pushFriend(List<String> dispatchIdList, List<String> pushDispatchIdList, Integer isAuto, String userId); R<String> pushFriend(List<String> dispatchIdList, List<String> pushDispatchIdList, Integer isAuto, String userId);
// 定时任务清理临时文件
void doClearFriend();
R<String> doExportRoster(String socialId, String type, String unitCreditCode, List<SociaFriendYgsAddVo> listVo); R<String> doExportRoster(String socialId, String type, String unitCreditCode, List<SociaFriendYgsAddVo> listVo);
R<String> test(); R<String> test();
......
...@@ -190,7 +190,6 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe ...@@ -190,7 +190,6 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
} }
} finally { } finally {
atomicPushFriend.decrementAndGet(); atomicPushFriend.decrementAndGet();
cleanSpireTempFiles();
} }
return R.ok(); return R.ok();
} else { } else {
...@@ -203,41 +202,23 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe ...@@ -203,41 +202,23 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
// 不可以并发,会使花名册转图片的字体不正确 // 不可以并发,会使花名册转图片的字体不正确
// 后续优化,考虑升级(spire.xls)的版本 // 后续优化,考虑升级(spire.xls)的版本
// 此方法是:删除临时文件 // 此方法是:删除临时文件
public void cleanSpireTempFiles() { @Override
public void doClearFriend() {
try { try {
// 暂停1分钟:不暂停,删10分钟前的数据
/*try {
Thread.sleep(60000);
} catch (InterruptedException e) {
}*/
String tempDirPath = System.getProperty("java.io.tmpdir"); String tempDirPath = System.getProperty("java.io.tmpdir");
File tempDir = new File(tempDirPath); File tempDir = new File(tempDirPath);
if (tempDir.exists() && tempDir.isDirectory()) { if (tempDir.exists() && tempDir.isDirectory()) {
File[] spireTempFiles = tempDir.listFiles((dir, name) -> File[] spireTempFiles = tempDir.listFiles((dir, name) ->
name.startsWith("+~JF") && name.endsWith(".tmp") name.startsWith("+~JF") && name.endsWith(".tmp")
); );
if (spireTempFiles != null && spireTempFiles.length > 0) { if (spireTempFiles != null && spireTempFiles.length > 0) {
int count = 0;
long totalSize = 0;
// 删30分钟前的数据 // 删30分钟前的数据
long oneMinuteAgo = System.currentTimeMillis() - 30L * 60 * 1000; long thirtyMinutesAgo = System.currentTimeMillis() - 30L * 60 * 1000;
long fileSize;
for (File file : spireTempFiles) { for (File file : spireTempFiles) {
if (file.isFile() && file.canWrite()) { if (file.isFile() && file.canWrite() && file.lastModified() < thirtyMinutesAgo) {
if (file.isFile() && file.canWrite() && file.lastModified() < oneMinuteAgo) { file.delete();
fileSize = file.length();
if (file.delete()) {
count++;
totalSize += fileSize;
}
}
} }
} }
log.info("清理 Spire.XLS 临时文件完成:删除 {} 个文件,释放 {} MB 空间",
count, totalSize / 1024 / 1024);
} }
} }
} catch (Exception e) { } catch (Exception 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