更改
This commit is contained in:
parent
7c951ac5e1
commit
a83c885892
@ -55,22 +55,29 @@ public class CropController {
|
||||
@Autowired
|
||||
OssService ossService;
|
||||
|
||||
private static final Object SDK_LOCK = new Object();
|
||||
|
||||
@GetMapping("/crop/chatData")
|
||||
public List<CropMessage> chatData(Long startSeq, String corpId) throws IOException {
|
||||
long limit = 50;
|
||||
long slice = Finance.NewSlice();
|
||||
Long sdk = sdkManager.initSdk(corpId, "mEizahrSF6axdfWtSK_f73a3j6-sV02hhyGG7ogmTpM");
|
||||
synchronized (SDK_LOCK) {
|
||||
long limit = 50;
|
||||
long slice = Finance.NewSlice();
|
||||
try {
|
||||
Long sdk = sdkManager.initSdk(corpId, "mEizahrSF6axdfWtSK_f73a3j6-sV02hhyGG7ogmTpM");
|
||||
|
||||
int ret = Finance.GetChatData(sdk, startSeq, limit, "", "", 1000, slice);
|
||||
if (ret != 0) {
|
||||
System.out.println("调用sdk拉取消息接口失败,失败消息为 ret = " + ret);
|
||||
Finance.FreeSlice(slice);
|
||||
return null;
|
||||
int ret = Finance.GetChatData(sdk, startSeq, limit, "", "", 1000, slice);
|
||||
if (ret != 0) {
|
||||
System.out.println("调用sdk拉取消息接口失败,失败消息为 ret = " + ret);
|
||||
Finance.FreeSlice(slice);
|
||||
return null;
|
||||
}
|
||||
String contentResult = Finance.GetContentFromSlice(slice);
|
||||
log.info("内容字符串" + contentResult);
|
||||
return decodeChatData(contentResult, startSeq, sdk, corpId);
|
||||
} finally {
|
||||
Finance.FreeSlice(slice); // ✅ 无论如何都释放
|
||||
}
|
||||
}
|
||||
String contentResult = Finance.GetContentFromSlice(slice);
|
||||
log.info("内容字符串" + contentResult);
|
||||
return decodeChatData(contentResult, startSeq, sdk, corpId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -196,7 +203,11 @@ public class CropController {
|
||||
|
||||
// ✅ 异步触发下载任务(可以轮询数据库)
|
||||
CompletableFuture.runAsync(() -> {
|
||||
downloadPendingFiles(mediaFiles, sdk); // 也可以不传参,改为查数据库
|
||||
try {
|
||||
downloadPendingFiles(mediaFiles, sdk); // 也可以不传参,改为查数据库
|
||||
} catch (Exception e) {
|
||||
log.error("异步下载任务异常", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
return messageList;
|
||||
@ -283,7 +294,6 @@ public class CropController {
|
||||
public String downFile(String sdkField, String msgType, Long sdk) throws IOException {
|
||||
File tempFile = File.createTempFile(GlobalConstants.DOWNLOAD_TEMP_FILE_NAME_PREFIX,
|
||||
msgType, mediaContext.getTempMergeFileDir());
|
||||
sdk = sdkManager.initSdk("ww64f47cd0afc456a5", "mEizahrSF6axdfWtSK_f73a3j6-sV02hhyGG7ogmTpM");
|
||||
|
||||
String indexbuf = null; // 初始化 indexbuf
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user