Compare commits
2 Commits
f9f9cb1057
...
a83c885892
| Author | SHA1 | Date | |
|---|---|---|---|
| a83c885892 | |||
| 7c951ac5e1 |
@ -55,11 +55,14 @@ public class CropController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
OssService ossService;
|
OssService ossService;
|
||||||
|
|
||||||
|
private static final Object SDK_LOCK = new Object();
|
||||||
|
|
||||||
@GetMapping("/crop/chatData")
|
@GetMapping("/crop/chatData")
|
||||||
public List<CropMessage> chatData(Long startSeq, String corpId) throws IOException {
|
public List<CropMessage> chatData(Long startSeq, String corpId) throws IOException {
|
||||||
long limit = 200;
|
synchronized (SDK_LOCK) {
|
||||||
|
long limit = 50;
|
||||||
long slice = Finance.NewSlice();
|
long slice = Finance.NewSlice();
|
||||||
|
try {
|
||||||
Long sdk = sdkManager.initSdk(corpId, "mEizahrSF6axdfWtSK_f73a3j6-sV02hhyGG7ogmTpM");
|
Long sdk = sdkManager.initSdk(corpId, "mEizahrSF6axdfWtSK_f73a3j6-sV02hhyGG7ogmTpM");
|
||||||
|
|
||||||
int ret = Finance.GetChatData(sdk, startSeq, limit, "", "", 1000, slice);
|
int ret = Finance.GetChatData(sdk, startSeq, limit, "", "", 1000, slice);
|
||||||
@ -71,6 +74,10 @@ public class CropController {
|
|||||||
String contentResult = Finance.GetContentFromSlice(slice);
|
String contentResult = Finance.GetContentFromSlice(slice);
|
||||||
log.info("内容字符串" + contentResult);
|
log.info("内容字符串" + contentResult);
|
||||||
return decodeChatData(contentResult, startSeq, sdk, corpId);
|
return decodeChatData(contentResult, startSeq, sdk, corpId);
|
||||||
|
} finally {
|
||||||
|
Finance.FreeSlice(slice); // ✅ 无论如何都释放
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,7 +203,11 @@ public class CropController {
|
|||||||
|
|
||||||
// ✅ 异步触发下载任务(可以轮询数据库)
|
// ✅ 异步触发下载任务(可以轮询数据库)
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
|
try {
|
||||||
downloadPendingFiles(mediaFiles, sdk); // 也可以不传参,改为查数据库
|
downloadPendingFiles(mediaFiles, sdk); // 也可以不传参,改为查数据库
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("异步下载任务异常", e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return messageList;
|
return messageList;
|
||||||
@ -283,7 +294,6 @@ public class CropController {
|
|||||||
public String downFile(String sdkField, String msgType, Long sdk) throws IOException {
|
public String downFile(String sdkField, String msgType, Long sdk) throws IOException {
|
||||||
File tempFile = File.createTempFile(GlobalConstants.DOWNLOAD_TEMP_FILE_NAME_PREFIX,
|
File tempFile = File.createTempFile(GlobalConstants.DOWNLOAD_TEMP_FILE_NAME_PREFIX,
|
||||||
msgType, mediaContext.getTempMergeFileDir());
|
msgType, mediaContext.getTempMergeFileDir());
|
||||||
sdk = sdkManager.initSdk("ww64f47cd0afc456a5", "mEizahrSF6axdfWtSK_f73a3j6-sV02hhyGG7ogmTpM");
|
|
||||||
|
|
||||||
String indexbuf = null; // 初始化 indexbuf
|
String indexbuf = null; // 初始化 indexbuf
|
||||||
try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
|
try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user