This commit is contained in:
杨建炊 2025-10-11 10:54:37 +08:00
parent a83c885892
commit 248d747604

View File

@ -60,24 +60,38 @@ public class CropController {
@GetMapping("/crop/chatData")
public List<CropMessage> chatData(Long startSeq, String corpId) throws IOException {
synchronized (SDK_LOCK) {
long limit = 50;
long limit = 10;
long slice = Finance.NewSlice();
long sdk = 0;
try {
Long sdk = sdkManager.initSdk(corpId, "mEizahrSF6axdfWtSK_f73a3j6-sV02hhyGG7ogmTpM");
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);
//Finance.FreeSlice(slice);
return null;
}
String contentResult = Finance.GetContentFromSlice(slice);
log.info("内容字符串" + contentResult);
return decodeChatData(contentResult, startSeq, sdk, corpId);
} catch (Exception e) {
log.error("获取chat数据异常{}", e.getMessage());
// 收集失败情况数据
e.printStackTrace();
} finally {
Finance.FreeSlice(slice); // 无论如何都释放
if (sdk != 0) {
try {
Finance.DestroySdk(sdk); // 重要
} catch (Throwable t) {
log.warn("DestroySdk 失败", t);
}
}
}
}
return Collections.emptyList() ;
}
/**