Compare commits

...

2 Commits

Author SHA1 Message Date
a83c885892 更改 2025-10-09 17:18:42 +08:00
7c951ac5e1 更改 2025-10-09 17:06:42 +08:00

View File

@ -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 = 200;
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)) {