更改
This commit is contained in:
parent
a43017f3ab
commit
62dbe1cd20
@ -3,6 +3,7 @@ package org.shop.crop;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.tencent.wework.Finance;
|
import com.tencent.wework.Finance;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.shop.crop.constant.GlobalConstants;
|
import org.shop.crop.constant.GlobalConstants;
|
||||||
@ -55,15 +56,17 @@ public class CropController {
|
|||||||
|
|
||||||
@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 {
|
||||||
|
LambdaQueryWrapper<CropConfig> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(CropConfig::getCropid, corpId);
|
||||||
|
CropConfig config = cropConfigMapper.selectOne(wrapper);
|
||||||
synchronized (SDK_LOCK) {
|
synchronized (SDK_LOCK) {
|
||||||
long limit = 50;
|
long limit = 50;
|
||||||
long slice = Finance.NewSlice();
|
long slice = Finance.NewSlice();
|
||||||
long sdk = 0;
|
long sdk = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sdk = sdkManager.initSdk(corpId, "mEizahrSF6axdfWtSK_f73a3j6-sV02hhyGG7ogmTpM");
|
sdk = sdkManager.initSdk(corpId, config.getMessageSecret());
|
||||||
|
int ret = Finance.GetChatData(sdk, config.getLastSeq(), limit, "", "", 2000, slice);
|
||||||
int ret = Finance.GetChatData(sdk, startSeq, limit, "", "", 1000, slice);
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
System.out.println("调用sdk拉取消息接口失败,失败消息为 ret = " + ret);
|
System.out.println("调用sdk拉取消息接口失败,失败消息为 ret = " + ret);
|
||||||
//Finance.FreeSlice(slice);
|
//Finance.FreeSlice(slice);
|
||||||
@ -212,13 +215,11 @@ public class CropController {
|
|||||||
cropFileService.saveBatch(mediaFiles);
|
cropFileService.saveBatch(mediaFiles);
|
||||||
|
|
||||||
// ✅ 异步触发下载任务(可以轮询数据库)
|
// ✅ 异步触发下载任务(可以轮询数据库)
|
||||||
CompletableFuture.runAsync(() -> {
|
try {
|
||||||
try {
|
downloadPendingFiles(mediaFiles, sdk); // 也可以不传参,改为查数据库
|
||||||
downloadPendingFiles(mediaFiles, sdk); // 也可以不传参,改为查数据库
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
log.error("异步下载任务异常", e);
|
||||||
log.error("异步下载任务异常", e);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return messageList;
|
return messageList;
|
||||||
}
|
}
|
||||||
@ -305,7 +306,8 @@ public class CropController {
|
|||||||
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());
|
||||||
|
|
||||||
String indexbuf = null; // 初始化 indexbuf
|
|
||||||
|
String indexbuf = ""; // 初始化 indexbuf
|
||||||
try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
|
try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
|
||||||
while (true) {
|
while (true) {
|
||||||
long mediaData = Finance.NewMediaData();
|
long mediaData = Finance.NewMediaData();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user