|
@@ -2,27 +2,36 @@ package com.tzld.longarticle.recommend.server.service.recommend;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.aigc.PushTypeEnum;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleDeleteStatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotIdEnum;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
|
|
|
import com.tzld.longarticle.recommend.server.model.dto.*;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
|
|
|
+import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.longArticle.*;
|
|
|
+import com.tzld.longarticle.recommend.server.model.param.ArticleDangerFindDeleteParam;
|
|
|
import com.tzld.longarticle.recommend.server.model.param.ArticleVideoAuditResultParam;
|
|
|
+import com.tzld.longarticle.recommend.server.model.param.PublishContentParam;
|
|
|
import com.tzld.longarticle.recommend.server.remote.WxAccessTokenRemoteService;
|
|
|
import com.tzld.longarticle.recommend.server.remote.WxArticleDeleteService;
|
|
|
import com.tzld.longarticle.recommend.server.repository.aigc.PublishAccountRepository;
|
|
|
+import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.longArticle.*;
|
|
|
import com.tzld.longarticle.recommend.server.util.DateUtils;
|
|
|
+import com.tzld.longarticle.recommend.server.util.Md5Util;
|
|
|
import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
|
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -51,9 +60,11 @@ public class ArticleAuditService {
|
|
|
private AigcBaseMapper aigcBaseMapper;
|
|
|
@Autowired
|
|
|
private PublishAccountRepository publishAccountRepository;
|
|
|
+ @Autowired
|
|
|
+ private ArticleRepository articleRepository;
|
|
|
|
|
|
|
|
|
- @XxlJob("articleVideoAudit")
|
|
|
+// @XxlJob("articleVideoAudit")
|
|
|
public ReturnT<String> articleVideoAudit(String param) {
|
|
|
long publishTime = DateUtils.getTodayStart();
|
|
|
if (StringUtils.hasText(param)) {
|
|
@@ -118,8 +129,10 @@ public class ArticleAuditService {
|
|
|
List<String> traceIds = crawlerVideoList.stream().map(LongArticleCrawlerVideo::getTraceId).collect(Collectors.toList());
|
|
|
List<PublishContentMiniprogramDTO> publishContentList = aigcBaseMapper.getPublishContentByTraceIdIn(traceIds);
|
|
|
List<String> publishContentIds = publishContentList.stream().map(PublishContentMiniprogramDTO::getPublishContentId).collect(Collectors.toList());
|
|
|
- Map<String, String> publishContentIdMap = publishContentList.stream()
|
|
|
- .collect(Collectors.toMap(PublishContentMiniprogramDTO::getTraceId, PublishContentMiniprogramDTO::getPublishContentId));
|
|
|
+ buildArticleAuditDelete(publishContentIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void buildArticleAuditDelete(List<String> publishContentIds) {
|
|
|
List<PublishGzhPushContentRelDTO> pushContentRelList = aigcBaseMapper.getPushContentRelByPublishContentIdIn(publishContentIds);
|
|
|
List<String> pushIds = pushContentRelList.stream().map(PublishGzhPushContentRelDTO::getPushId).collect(Collectors.toList());
|
|
|
Map<String, String> publishPushIdMap = pushContentRelList.stream()
|
|
@@ -138,14 +151,16 @@ public class ArticleAuditService {
|
|
|
List<PublishGzhPushContentRelDTO> groupPushRelList = aigcBaseMapper.getGroupPushRelByPushIdIn(pushIds);
|
|
|
Map<String, List<PublishGzhPushContentRelDTO>> groupPushRelMap = groupPushRelList.stream()
|
|
|
.collect(Collectors.groupingBy(PublishGzhPushContentRelDTO::getPushId));
|
|
|
- for (String traceId : traceIds) {
|
|
|
- String publishContentId = publishContentIdMap.get(traceId);
|
|
|
+ // 删除文章
|
|
|
+ for (String publishContentId : publishContentIds) {
|
|
|
String pushId = publishPushIdMap.get(publishContentId);
|
|
|
if (!StringUtils.hasText(pushId)) {
|
|
|
- // todo 未发布文章如何进行小程序替换
|
|
|
continue;
|
|
|
}
|
|
|
PublishGzhPushDTO publishGzhPushDTO = pushDTOMap.get(pushId);
|
|
|
+ if (Objects.isNull(publishGzhPushDTO)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
String groupPushMsgId = pushIdMap.get(pushId);
|
|
|
String publishAccountId = pushAccountMap.get(pushId);
|
|
|
String ghId = publishAccountMap.get(publishAccountId);
|
|
@@ -175,7 +190,7 @@ public class ArticleAuditService {
|
|
|
*/
|
|
|
@XxlJob("articleVideoDelete")
|
|
|
public ReturnT<String> articleVideoDelete(String param) {
|
|
|
- List<LongArticleAuditDelete> dealList = longArticleAuditDeleteRepository.getByStatus(StatusEnum.ZERO.getCode());
|
|
|
+ List<LongArticleAuditDelete> dealList = longArticleAuditDeleteRepository.getByStatus(ArticleDeleteStatusEnum.WAITING.getCode());
|
|
|
for (LongArticleAuditDelete delete : dealList) {
|
|
|
if (Objects.equals(delete.getPushType(), PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
|
|
|
// 获取token
|
|
@@ -183,9 +198,10 @@ public class ArticleAuditService {
|
|
|
// 删除文章
|
|
|
RequestResult<String> result = wxArticleDeleteService.deleteArticle(token, delete.getMsgId(), delete.getIndex());
|
|
|
if (result.isSuccess()) {
|
|
|
- delete.setStatus(StatusEnum.ONE.getCode());
|
|
|
+ delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
|
|
|
} else {
|
|
|
- delete.setStatus(StatusEnum.TWO.getCode());
|
|
|
+ delete.setStatus(ArticleDeleteStatusEnum.FAIL.getCode());
|
|
|
+ delete.setFailReason(result.getFailReason());
|
|
|
delete.setFinishTimestamp(System.currentTimeMillis());
|
|
|
}
|
|
|
longArticleAuditDeleteRepository.save(delete);
|
|
@@ -201,10 +217,38 @@ public class ArticleAuditService {
|
|
|
+ "位置: " + delete.getIndex() + "\n"
|
|
|
+ "标题: " + publishContent.getTitle());
|
|
|
|
|
|
- delete.setStatus(StatusEnum.ONE.getCode());
|
|
|
+ delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
|
|
|
longArticleAuditDeleteRepository.save(delete);
|
|
|
}
|
|
|
}
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
+
|
|
|
+ public void titleDangerFindDelete(ArticleDangerFindDeleteParam param) {
|
|
|
+ String titleMd5 = Md5Util.encoderByMd5(param.getTitle());
|
|
|
+ // 根据标题查找已发布文章
|
|
|
+ List<Article> articleList = articleRepository.getByTitleMd5(titleMd5);
|
|
|
+ List<String> ghIds = articleList.stream().map(Article::getGhId).distinct().collect(Collectors.toList());
|
|
|
+ List<PublishAccount> publishAccountList = publishAccountRepository.getAllByGhIdIn(ghIds);
|
|
|
+ List<PublishContentParam> publishContentParamList = publishAccountList.stream().map(account -> {
|
|
|
+ PublishContentParam item = new PublishContentParam();
|
|
|
+ item.setTitle(param.getTitle());
|
|
|
+ item.setPublishAccountId(account.getId());
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ List<PublishContentDTO> publishContents = new ArrayList<>();
|
|
|
+ for (List<PublishContentParam> partitions : Lists.partition(publishContentParamList, 100)) {
|
|
|
+ publishContents.addAll(aigcBaseMapper.getPublishContentByTitle(partitions));
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isEmpty(publishContents)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 查找该生成内容下所有已发布内容
|
|
|
+ List<String> sourceIds = publishContents.stream().map(PublishContentDTO::getSourceId).distinct().collect(Collectors.toList());
|
|
|
+ publishContents = aigcBaseMapper.getPublishContentBySourceIdIn(sourceIds);
|
|
|
+
|
|
|
+ // 根据已发布文章查找推送id 并删除
|
|
|
+ List<String> publishContentIds = publishContents.stream().map(PublishContentDTO::getId).collect(Collectors.toList());
|
|
|
+ buildArticleAuditDelete(publishContentIds);
|
|
|
+ }
|
|
|
}
|