|
@@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
|
+import com.tzld.longarticle.recommend.server.common.CommonThreadPoolExecutor;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.FieshuTableColumnDataTypeEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.VideoAuditTypeEnum;
|
|
@@ -54,6 +56,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.net.URL;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -505,29 +508,47 @@ public class ArticleAuditService {
|
|
|
List<PublishAccountTypeDTO> accountTypeList = aigcBaseMapper.getAccountTypeList(ghIds);
|
|
|
Map<String, PublishAccountTypeDTO> accountTypeMap = accountTypeList.stream()
|
|
|
.collect(Collectors.toMap(PublishAccountTypeDTO::getGhId, Function.identity()));
|
|
|
- List<JSONObject> alarmList = new ArrayList<>();
|
|
|
- for (LongArticleAuditDelete delete : dealList) {
|
|
|
- try {
|
|
|
- if (Objects.equals(delete.getPushType(), PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
|
|
|
- // 获取token
|
|
|
- String token = wxAccessTokenRemoteService.getAccessToken(delete.getGhId());
|
|
|
- // 删除文章
|
|
|
- RequestResult<String> result = wxArticleDeleteService.deleteArticle(token, delete.getMsgId(), delete.getIndex());
|
|
|
- if (result.isSuccess()) {
|
|
|
- delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
|
|
|
- } else {
|
|
|
- delete.setStatus(ArticleDeleteStatusEnum.FAIL.getCode());
|
|
|
- delete.setFailReason(result.getFailReason());
|
|
|
+ List<JSONObject> alarmList = Collections.synchronizedList(new ArrayList<>());
|
|
|
+ Map<String, List<LongArticleAuditDelete>> dealMap = dealList.stream().collect(Collectors.groupingBy(LongArticleAuditDelete::getGhId));
|
|
|
+ ExecutorService pool = new CommonThreadPoolExecutor( 10, 10, 0L, TimeUnit.SECONDS,
|
|
|
+ new LinkedBlockingQueue<>(10000),
|
|
|
+ new ThreadFactoryBuilder().setNameFormat("ArticleVideoDelete-%d").build(),
|
|
|
+ new ThreadPoolExecutor.AbortPolicy());
|
|
|
+ CountDownLatch cdl = new CountDownLatch(dealMap.size());
|
|
|
+ for (Map.Entry<String, List<LongArticleAuditDelete>> entry : dealMap.entrySet()) {
|
|
|
+ pool.submit(() -> {
|
|
|
+ // 获取token
|
|
|
+ try {
|
|
|
+ String token = wxAccessTokenRemoteService.getAccessToken(entry.getKey());
|
|
|
+ List<LongArticleAuditDelete> list = entry.getValue();
|
|
|
+ for (LongArticleAuditDelete delete : list) {
|
|
|
+ try {
|
|
|
+ if (Objects.equals(delete.getPushType(), PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
|
|
|
+ // 删除文章
|
|
|
+ RequestResult<String> result = wxArticleDeleteService.deleteArticle(token, delete.getMsgId(), delete.getIndex());
|
|
|
+ if (result.isSuccess()) {
|
|
|
+ delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
|
|
|
+ } else {
|
|
|
+ delete.setStatus(ArticleDeleteStatusEnum.FAIL.getCode());
|
|
|
+ delete.setFailReason(result.getFailReason());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ deleteFailAlarmAdd(alarmList, delete.getPublishContentId(), "非自动群发", delete.getIndex());
|
|
|
+ delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
|
|
|
+ }
|
|
|
+ delete.setFinishTimestamp(System.currentTimeMillis());
|
|
|
+ longArticleAuditDeleteRepository.save(delete);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("articleVideoDelete ghId:{} error", delete.getGhId(), e);
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- deleteFailAlarmAdd(alarmList, delete.getPublishContentId(), "非自动群发", delete.getIndex());
|
|
|
- delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
|
|
|
+ } finally {
|
|
|
+ cdl.countDown();
|
|
|
}
|
|
|
- delete.setFinishTimestamp(System.currentTimeMillis());
|
|
|
- longArticleAuditDeleteRepository.save(delete);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("articleVideoDelete ghId:{} error", delete.getGhId(), e);
|
|
|
- }
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ cdl.await();
|
|
|
+ } catch (Exception ignore) {}
|
|
|
}
|
|
|
deleteFailAlarm(alarmList, accountTypeMap);
|
|
|
return ReturnT.SUCCESS;
|
|
@@ -553,6 +574,9 @@ public class ArticleAuditService {
|
|
|
for (JSONObject alarm : alarmList) {
|
|
|
String publishContentId = alarm.getString("publishContentId");
|
|
|
PublishContentDTO publishContent = publishContentMap.get(publishContentId);
|
|
|
+ if (Objects.isNull(publishContent.getPublishTimestamp())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
String publishTime = DateUtils.timestampToYMDStr(publishContent.getPublishTimestamp() / 1000, "yyyyMMdd");
|
|
|
PublishAccount publishAccount = publishAccountMap.get(publishContent.getPublishAccountId());
|
|
|
PublishAccountTypeDTO accountTypeDTO = accountTypeMap.get(publishAccount.getGhId());
|