|
@@ -19,6 +19,7 @@ import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleDelet
|
|
import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleMatchContentStatusEnum;
|
|
import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleMatchContentStatusEnum;
|
|
import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotIdEnum;
|
|
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.mapper.aigc.AigcBaseMapper;
|
|
|
|
+import com.tzld.longarticle.recommend.server.mapper.aigc.PublishContentMapper;
|
|
import com.tzld.longarticle.recommend.server.mapper.crawler.ArticleMapper;
|
|
import com.tzld.longarticle.recommend.server.mapper.crawler.ArticleMapper;
|
|
import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
|
|
import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
|
|
import com.tzld.longarticle.recommend.server.model.cgi.AlgFaceRecognizeResult;
|
|
import com.tzld.longarticle.recommend.server.model.cgi.AlgFaceRecognizeResult;
|
|
@@ -81,6 +82,8 @@ public class ArticleAuditService {
|
|
@Autowired
|
|
@Autowired
|
|
private AigcBaseMapper aigcBaseMapper;
|
|
private AigcBaseMapper aigcBaseMapper;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private PublishContentMapper publishContentMapper;
|
|
|
|
+ @Autowired
|
|
private PublishAccountRepository publishAccountRepository;
|
|
private PublishAccountRepository publishAccountRepository;
|
|
@Autowired
|
|
@Autowired
|
|
private ArticleRepository articleRepository;
|
|
private ArticleRepository articleRepository;
|
|
@@ -347,7 +350,7 @@ public class ArticleAuditService {
|
|
Map<String, LongArticlesMatchVideo> matchVideoMap = matchVideoList.stream()
|
|
Map<String, LongArticlesMatchVideo> matchVideoMap = matchVideoList.stream()
|
|
.collect(Collectors.toMap(LongArticlesMatchVideo::getTraceId, Function.identity()));
|
|
.collect(Collectors.toMap(LongArticlesMatchVideo::getTraceId, Function.identity()));
|
|
List<String> traceIds = matchVideoList.stream().map(LongArticlesMatchVideo::getTraceId).collect(Collectors.toList());
|
|
List<String> traceIds = matchVideoList.stream().map(LongArticlesMatchVideo::getTraceId).collect(Collectors.toList());
|
|
- List<PublishContentMiniprogramDTO> publishContentMiniprogramList = aigcBaseMapper.getPublishContentByTraceIdIn(traceIds);
|
|
|
|
|
|
+ List<PublishContentMiniprogramDTO> publishContentMiniprogramList = publishContentMapper.getPublishContentByTraceIdIn(traceIds);
|
|
List<String> publishContentIds = publishContentMiniprogramList.stream()
|
|
List<String> publishContentIds = publishContentMiniprogramList.stream()
|
|
.map(PublishContentMiniprogramDTO::getPublishContentId).collect(Collectors.toList());
|
|
.map(PublishContentMiniprogramDTO::getPublishContentId).collect(Collectors.toList());
|
|
Map<String, String> PublishTraceIdMap = publishContentMiniprogramList.stream()
|
|
Map<String, String> PublishTraceIdMap = publishContentMiniprogramList.stream()
|
|
@@ -400,7 +403,7 @@ public class ArticleAuditService {
|
|
longArticleBaseMapper.batchInsertArticleReMatchRecord(reMatchRecordList);
|
|
longArticleBaseMapper.batchInsertArticleReMatchRecord(reMatchRecordList);
|
|
}
|
|
}
|
|
|
|
|
|
- private void buildArticleAuditDelete(List<String> publishContentIds) {
|
|
|
|
|
|
+ public void buildArticleAuditDelete(List<String> publishContentIds) {
|
|
if (CollectionUtils.isEmpty(publishContentIds)) {
|
|
if (CollectionUtils.isEmpty(publishContentIds)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -411,7 +414,7 @@ public class ArticleAuditService {
|
|
if (CollectionUtils.isEmpty(publishContentIds)) {
|
|
if (CollectionUtils.isEmpty(publishContentIds)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- List<PublishGzhPushContentRelDTO> pushContentRelList = aigcBaseMapper.getPushContentRelByPublishContentIdIn(publishContentIds);
|
|
|
|
|
|
+ List<PublishGzhPushContentRelDTO> pushContentRelList = publishContentMapper.getPushContentRelByPublishContentIdIn(publishContentIds);
|
|
if (CollectionUtils.isEmpty(pushContentRelList)) {
|
|
if (CollectionUtils.isEmpty(pushContentRelList)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -420,7 +423,7 @@ public class ArticleAuditService {
|
|
.collect(Collectors.toMap(PublishGzhPushContentRelDTO::getPublishContentId,
|
|
.collect(Collectors.toMap(PublishGzhPushContentRelDTO::getPublishContentId,
|
|
PublishGzhPushContentRelDTO::getPushId,
|
|
PublishGzhPushContentRelDTO::getPushId,
|
|
(o1, o2) -> o2));
|
|
(o1, o2) -> o2));
|
|
- List<PublishGzhPushDTO> pushList = aigcBaseMapper.getPushByPushIdIn(pushIds);
|
|
|
|
|
|
+ List<PublishGzhPushDTO> pushList = publishContentMapper.getPushByPushIdIn(pushIds);
|
|
Map<String, PublishGzhPushDTO> pushDTOMap = pushList.stream()
|
|
Map<String, PublishGzhPushDTO> pushDTOMap = pushList.stream()
|
|
.collect(Collectors.toMap(PublishGzhPushDTO::getPushId, Function.identity()));
|
|
.collect(Collectors.toMap(PublishGzhPushDTO::getPushId, Function.identity()));
|
|
Map<String, String> pushIdMap = pushList.stream().filter(o -> StringUtils.hasText(o.getGroupPushMsgId()))
|
|
Map<String, String> pushIdMap = pushList.stream().filter(o -> StringUtils.hasText(o.getGroupPushMsgId()))
|
|
@@ -432,10 +435,10 @@ public class ArticleAuditService {
|
|
List<String> ghIds = publishAccountList.stream().map(PublishAccount::getGhId).collect(Collectors.toList());
|
|
List<String> ghIds = publishAccountList.stream().map(PublishAccount::getGhId).collect(Collectors.toList());
|
|
Map<String, String> publishAccountMap = publishAccountList.stream()
|
|
Map<String, String> publishAccountMap = publishAccountList.stream()
|
|
.collect(Collectors.toMap(PublishAccount::getId, PublishAccount::getGhId));
|
|
.collect(Collectors.toMap(PublishAccount::getId, PublishAccount::getGhId));
|
|
- List<PublishGzhPushContentRelDTO> groupPushRelList = aigcBaseMapper.getGroupPushRelByPushIdIn(pushIds);
|
|
|
|
|
|
+ List<PublishGzhPushContentRelDTO> groupPushRelList = publishContentMapper.getGroupPushRelByPushIdIn(pushIds);
|
|
Map<String, List<PublishGzhPushContentRelDTO>> groupPushRelMap = groupPushRelList.stream()
|
|
Map<String, List<PublishGzhPushContentRelDTO>> groupPushRelMap = groupPushRelList.stream()
|
|
.collect(Collectors.groupingBy(PublishGzhPushContentRelDTO::getPushId));
|
|
.collect(Collectors.groupingBy(PublishGzhPushContentRelDTO::getPushId));
|
|
- List<PublishAccountTypeDTO> accountTypeList = aigcBaseMapper.getAccountTypeList(ghIds);
|
|
|
|
|
|
+ List<PublishAccountTypeDTO> accountTypeList = publishContentMapper.getAccountTypeList(ghIds);
|
|
Map<String, PublishAccountTypeDTO> accountTypeMap = accountTypeList.stream()
|
|
Map<String, PublishAccountTypeDTO> accountTypeMap = accountTypeList.stream()
|
|
.collect(Collectors.toMap(PublishAccountTypeDTO::getGhId, Function.identity()));
|
|
.collect(Collectors.toMap(PublishAccountTypeDTO::getGhId, Function.identity()));
|
|
// 删除文章
|
|
// 删除文章
|
|
@@ -505,7 +508,7 @@ public class ArticleAuditService {
|
|
public ReturnT<String> articleVideoDelete(String param) {
|
|
public ReturnT<String> articleVideoDelete(String param) {
|
|
List<LongArticleAuditDelete> dealList = longArticleAuditDeleteRepository.getByStatus(ArticleDeleteStatusEnum.WAITING.getCode());
|
|
List<LongArticleAuditDelete> dealList = longArticleAuditDeleteRepository.getByStatus(ArticleDeleteStatusEnum.WAITING.getCode());
|
|
List<String> ghIds = dealList.stream().map(LongArticleAuditDelete::getGhId).collect(Collectors.toList());
|
|
List<String> ghIds = dealList.stream().map(LongArticleAuditDelete::getGhId).collect(Collectors.toList());
|
|
- List<PublishAccountTypeDTO> accountTypeList = aigcBaseMapper.getAccountTypeList(ghIds);
|
|
|
|
|
|
+ List<PublishAccountTypeDTO> accountTypeList = publishContentMapper.getAccountTypeList(ghIds);
|
|
Map<String, PublishAccountTypeDTO> accountTypeMap = accountTypeList.stream()
|
|
Map<String, PublishAccountTypeDTO> accountTypeMap = accountTypeList.stream()
|
|
.collect(Collectors.toMap(PublishAccountTypeDTO::getGhId, Function.identity()));
|
|
.collect(Collectors.toMap(PublishAccountTypeDTO::getGhId, Function.identity()));
|
|
List<JSONObject> alarmList = Collections.synchronizedList(new ArrayList<>());
|
|
List<JSONObject> alarmList = Collections.synchronizedList(new ArrayList<>());
|
|
@@ -521,25 +524,77 @@ public class ArticleAuditService {
|
|
// 获取token
|
|
// 获取token
|
|
String token = wxAccessTokenRemoteService.getAccessToken(entry.getKey());
|
|
String token = wxAccessTokenRemoteService.getAccessToken(entry.getKey());
|
|
List<LongArticleAuditDelete> list = entry.getValue();
|
|
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());
|
|
|
|
|
|
+ Map<String, List<LongArticleAuditDelete>> msgIdMap = list.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(LongArticleAuditDelete::getMsgId));
|
|
|
|
+ List<String> msgIds = new ArrayList<>(msgIdMap.keySet());
|
|
|
|
+ List<LongArticleAuditDelete> accountAllDeleteList = longArticleAuditDeleteRepository.getByGhIdAndMsgIdIn(entry.getKey(), msgIds);
|
|
|
|
+ Map<String, List<LongArticleAuditDelete>> accountAllDeleteMap = accountAllDeleteList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(LongArticleAuditDelete::getMsgId));
|
|
|
|
+ for (Map.Entry<String, List<LongArticleAuditDelete>> msgIdEntry : msgIdMap.entrySet()) {
|
|
|
|
+ String msgId = msgIdEntry.getKey();
|
|
|
|
+ List<LongArticleAuditDelete> msgIdList = msgIdEntry.getValue();
|
|
|
|
+ Integer pushType = msgIdList.get(0).getPushType();
|
|
|
|
+ List<LongArticleAuditDelete> msgIdDeleteList = accountAllDeleteMap.get(msgId);
|
|
|
|
+ List<LongArticleAuditDelete> deleteAllCount = msgIdDeleteList.stream()
|
|
|
|
+ .filter(o -> Objects.equals(o.getStatus(), ArticleDeleteStatusEnum.SUCCESS.getCode()))
|
|
|
|
+ .filter(o -> o.getDeleteAll() == 1)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ int count = msgIdDeleteList.size();
|
|
|
|
+ int status;
|
|
|
|
+ String errMsg;
|
|
|
|
+ // 执行过全部删除,则自动置为历史状态
|
|
|
|
+ if (!deleteAllCount.isEmpty()) {
|
|
|
|
+ LongArticleAuditDelete statusDelete = deleteAllCount.get(0);
|
|
|
|
+ msgIdList.forEach(delete -> {
|
|
|
|
+ delete.setStatus(statusDelete.getStatus());
|
|
|
|
+ delete.setFailReason(statusDelete.getFailReason());
|
|
|
|
+ delete.setFinishTimestamp(System.currentTimeMillis());
|
|
|
|
+ longArticleAuditDeleteRepository.save(delete);
|
|
|
|
+ });
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (Objects.equals(pushType, PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
|
|
|
|
+ // 删除文章
|
|
|
|
+ if (count > 1) {
|
|
|
|
+ RequestResult<String> result = wxArticleDeleteService.deleteArticle(token, msgId, 0);
|
|
if (result.isSuccess()) {
|
|
if (result.isSuccess()) {
|
|
- delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
|
|
|
|
|
|
+ errMsg = null;
|
|
|
|
+ status = ArticleDeleteStatusEnum.SUCCESS.getCode();
|
|
} else {
|
|
} else {
|
|
- delete.setStatus(ArticleDeleteStatusEnum.FAIL.getCode());
|
|
|
|
- delete.setFailReason(result.getFailReason());
|
|
|
|
|
|
+ status = ArticleDeleteStatusEnum.FAIL.getCode();
|
|
|
|
+ errMsg = result.getFailReason();
|
|
}
|
|
}
|
|
|
|
+ msgIdList.forEach(delete -> {
|
|
|
|
+ delete.setStatus(status);
|
|
|
|
+ delete.setFailReason(errMsg);
|
|
|
|
+ delete.setDeleteAll(1);
|
|
|
|
+ delete.setFinishTimestamp(System.currentTimeMillis());
|
|
|
|
+ longArticleAuditDeleteRepository.save(delete);
|
|
|
|
+ });
|
|
} else {
|
|
} else {
|
|
|
|
+ LongArticleAuditDelete delete = msgIdList.get(0);
|
|
|
|
+ try {
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ delete.setFinishTimestamp(System.currentTimeMillis());
|
|
|
|
+ longArticleAuditDeleteRepository.save(delete);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("articleVideoDelete ghId:{} error", delete.getGhId(), e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ msgIdList.forEach(delete -> {
|
|
deleteFailAlarmAdd(alarmList, delete.getPublishContentId(), "非自动群发", delete.getIndex());
|
|
deleteFailAlarmAdd(alarmList, delete.getPublishContentId(), "非自动群发", delete.getIndex());
|
|
delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
|
|
delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
|
|
- }
|
|
|
|
- delete.setFinishTimestamp(System.currentTimeMillis());
|
|
|
|
- longArticleAuditDeleteRepository.save(delete);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("articleVideoDelete ghId:{} error", delete.getGhId(), e);
|
|
|
|
|
|
+ delete.setFinishTimestamp(System.currentTimeMillis());
|
|
|
|
+ longArticleAuditDeleteRepository.save(delete);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} finally {
|
|
} finally {
|
|
@@ -561,7 +616,7 @@ public class ArticleAuditService {
|
|
if (CollectionUtils.isEmpty(publishContentIds)) {
|
|
if (CollectionUtils.isEmpty(publishContentIds)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- List<PublishContentDTO> publishContents = aigcBaseMapper.getPublishContentByIdIn(publishContentIds);
|
|
|
|
|
|
+ List<PublishContentDTO> publishContents = publishContentMapper.getPublishContentByIdIn(publishContentIds);
|
|
Map<String, PublishContentDTO> publishContentMap = publishContents.stream()
|
|
Map<String, PublishContentDTO> publishContentMap = publishContents.stream()
|
|
.collect(Collectors.toMap(PublishContentDTO::getId, Function.identity()));
|
|
.collect(Collectors.toMap(PublishContentDTO::getId, Function.identity()));
|
|
List<String> publishAccountIds = publishContents.stream().map(PublishContentDTO::getPublishAccountId)
|
|
List<String> publishAccountIds = publishContents.stream().map(PublishContentDTO::getPublishAccountId)
|
|
@@ -641,7 +696,7 @@ public class ArticleAuditService {
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
List<PublishContentDTO> publishContents = new ArrayList<>();
|
|
List<PublishContentDTO> publishContents = new ArrayList<>();
|
|
for (List<PublishContentParam> partitions : Lists.partition(publishContentParamList, 100)) {
|
|
for (List<PublishContentParam> partitions : Lists.partition(publishContentParamList, 100)) {
|
|
- publishContents.addAll(aigcBaseMapper.getPublishContentByTitle(partitions));
|
|
|
|
|
|
+ publishContents.addAll(publishContentMapper.getPublishContentByTitle(partitions));
|
|
}
|
|
}
|
|
if (CollectionUtils.isEmpty(publishContents)) {
|
|
if (CollectionUtils.isEmpty(publishContents)) {
|
|
return;
|
|
return;
|
|
@@ -657,7 +712,7 @@ public class ArticleAuditService {
|
|
}
|
|
}
|
|
// 查找该生成内容下所有已发布内容
|
|
// 查找该生成内容下所有已发布内容
|
|
List<String> sourceIds = publishContents.stream().map(PublishContentDTO::getSourceId).distinct().collect(Collectors.toList());
|
|
List<String> sourceIds = publishContents.stream().map(PublishContentDTO::getSourceId).distinct().collect(Collectors.toList());
|
|
- publishContents = aigcBaseMapper.getPublishContentBySourceIdIn(sourceIds);
|
|
|
|
|
|
+ publishContents = publishContentMapper.getPublishContentBySourceIdIn(sourceIds);
|
|
|
|
|
|
// 根据已发布文章查找推送id 并删除
|
|
// 根据已发布文章查找推送id 并删除
|
|
List<String> publishContentIds = publishContents.stream().map(PublishContentDTO::getId).collect(Collectors.toList());
|
|
List<String> publishContentIds = publishContents.stream().map(PublishContentDTO::getId).collect(Collectors.toList());
|
|
@@ -693,7 +748,7 @@ public class ArticleAuditService {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
List<String> ghIds = list.stream().map(ArticleDeleteListVO::getGhId).distinct().collect(Collectors.toList());
|
|
List<String> ghIds = list.stream().map(ArticleDeleteListVO::getGhId).distinct().collect(Collectors.toList());
|
|
- List<PublishAccountTypeDTO> accountTypeList = aigcBaseMapper.getAccountTypeList(ghIds);
|
|
|
|
|
|
+ List<PublishAccountTypeDTO> accountTypeList = publishContentMapper.getAccountTypeList(ghIds);
|
|
Map<String, PublishAccountTypeDTO> accountTypeMap = accountTypeList.stream()
|
|
Map<String, PublishAccountTypeDTO> accountTypeMap = accountTypeList.stream()
|
|
.collect(Collectors.toMap(PublishAccountTypeDTO::getGhId, Function.identity()));
|
|
.collect(Collectors.toMap(PublishAccountTypeDTO::getGhId, Function.identity()));
|
|
// List<PublishAccount> publishAccountList = publishAccountRepository.getAllByGhIdIn(ghIds);
|
|
// List<PublishAccount> publishAccountList = publishAccountRepository.getAllByGhIdIn(ghIds);
|
|
@@ -774,7 +829,7 @@ public class ArticleAuditService {
|
|
Integer pageSize = 100;
|
|
Integer pageSize = 100;
|
|
while (true) {
|
|
while (true) {
|
|
Integer offset = (pageNum - 1) * pageSize;
|
|
Integer offset = (pageNum - 1) * pageSize;
|
|
- List<String> publishContentIds = aigcBaseMapper.getOnlyMiniprogramArticle(offset, pageSize);
|
|
|
|
|
|
+ List<String> publishContentIds = publishContentMapper.getOnlyMiniprogramArticle(offset, pageSize);
|
|
if (CollectionUtils.isEmpty(publishContentIds)) {
|
|
if (CollectionUtils.isEmpty(publishContentIds)) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|