|
@@ -2,7 +2,9 @@ package com.tzld.longarticle.recommend.server.service.recommend;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+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.aigc.PublishContentStatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
|
|
@@ -22,6 +24,7 @@ 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.PublishContentParam;
|
|
|
+import com.tzld.longarticle.recommend.server.model.vo.FeishuTableDTO;
|
|
|
import com.tzld.longarticle.recommend.server.remote.WxAccessTokenRemoteService;
|
|
|
import com.tzld.longarticle.recommend.server.remote.WxArticleDeleteService;
|
|
|
import com.tzld.longarticle.recommend.server.remote.pq.PQVideoAuditResultService;
|
|
@@ -221,13 +224,13 @@ public class ArticleAuditService {
|
|
|
List<String> contentIds = crawlerVideoList.stream().map(LongArticleCrawlerVideo::getContentId).collect(Collectors.toList());
|
|
|
List<LongArticlesMatchVideo> matchVideoList = longArticlesMatchVideoRepository.getByContentIdIn(contentIds);
|
|
|
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<PublishContentMiniprogramDTO> publishContentMiniprogramList = aigcBaseMapper.getPublishContentByTraceIdIn(traceIds);
|
|
|
List<String> publishContentIds = publishContentMiniprogramList.stream()
|
|
|
.map(PublishContentMiniprogramDTO::getPublishContentId).collect(Collectors.toList());
|
|
|
Map<String, String> PublishTraceIdMap = publishContentMiniprogramList.stream()
|
|
|
- .collect(Collectors.toMap(PublishContentMiniprogramDTO::getPublishContentId, PublishContentMiniprogramDTO::getTraceId));
|
|
|
+ .collect(Collectors.toMap(PublishContentMiniprogramDTO::getPublishContentId, PublishContentMiniprogramDTO::getTraceId));
|
|
|
// 过滤状态非已发布内容
|
|
|
List<PublishContent> publishContentList = publishContentRepository.getByIdIn(publishContentIds);
|
|
|
List<String> publishedIds = publishContentList.stream()
|
|
@@ -310,15 +313,16 @@ public class ArticleAuditService {
|
|
|
Map<String, PublishAccountTypeDTO> accountTypeMap = accountTypeList.stream()
|
|
|
.collect(Collectors.toMap(PublishAccountTypeDTO::getGhId, Function.identity()));
|
|
|
// 删除文章
|
|
|
+ List<JSONObject> alarmList = new ArrayList<>();
|
|
|
for (String publishContentId : publishContentIds) {
|
|
|
String pushId = publishPushIdMap.get(publishContentId);
|
|
|
if (!StringUtils.hasText(pushId)) {
|
|
|
- deleteFailAlarm(publishContentId, "无推送记录", 0, accountTypeMap);
|
|
|
+ deleteFailAlarmAdd(alarmList, publishContentId, "无推送记录", 0);
|
|
|
continue;
|
|
|
}
|
|
|
PublishGzhPushDTO publishGzhPushDTO = pushDTOMap.get(pushId);
|
|
|
if (Objects.isNull(publishGzhPushDTO)) {
|
|
|
- deleteFailAlarm(publishContentId, "无推送记录", 0, accountTypeMap);
|
|
|
+ deleteFailAlarmAdd(alarmList, publishContentId, "无推送记录", 0);
|
|
|
continue;
|
|
|
}
|
|
|
String publishAccountId = pushAccountMap.get(pushId);
|
|
@@ -334,12 +338,12 @@ public class ArticleAuditService {
|
|
|
}
|
|
|
if (!publishGzhPushDTO.getPushType().equals(PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
|
|
|
PushTypeEnum pushTypeEnum = PushTypeEnum.from(publishGzhPushDTO.getPushType());
|
|
|
- deleteFailAlarm(publishContentId, "推送类型为" + pushTypeEnum.getDescription(), index, accountTypeMap);
|
|
|
+ deleteFailAlarmAdd(alarmList, publishContentId, "推送类型为" + pushTypeEnum.getDescription(), index);
|
|
|
continue;
|
|
|
}
|
|
|
String groupPushMsgId = pushIdMap.get(pushId);
|
|
|
if (!StringUtils.hasText(groupPushMsgId)) {
|
|
|
- deleteFailAlarm(publishContentId, "无推送MsgId", index, accountTypeMap);
|
|
|
+ deleteFailAlarmAdd(alarmList, publishContentId, "无推送MsgId", index);
|
|
|
continue;
|
|
|
}
|
|
|
LongArticleAuditDelete delete = new LongArticleAuditDelete();
|
|
@@ -353,6 +357,15 @@ public class ArticleAuditService {
|
|
|
delete.setCreateTimestamp(System.currentTimeMillis());
|
|
|
longArticleAuditDeleteRepository.save(delete);
|
|
|
}
|
|
|
+ deleteFailAlarm(alarmList, accountTypeMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deleteFailAlarmAdd(List<JSONObject> alarmList, String publishContentId, String errMsg, Integer index) {
|
|
|
+ JSONObject alarm = new JSONObject();
|
|
|
+ alarm.put("publishContentId", publishContentId);
|
|
|
+ alarm.put("errMsg", errMsg);
|
|
|
+ alarm.put("index", index);
|
|
|
+ alarmList.add(alarm);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -364,6 +377,7 @@ public class ArticleAuditService {
|
|
|
List<PublishAccountTypeDTO> accountTypeList = aigcBaseMapper.getAccountTypeList();
|
|
|
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())) {
|
|
@@ -378,7 +392,7 @@ public class ArticleAuditService {
|
|
|
delete.setFailReason(result.getFailReason());
|
|
|
}
|
|
|
} else {
|
|
|
- deleteFailAlarm(delete.getPublishContentId(), "非自动群发", delete.getIndex(), accountTypeMap);
|
|
|
+ deleteFailAlarmAdd(alarmList, delete.getPublishContentId(), "非自动群发", delete.getIndex());
|
|
|
delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
|
|
|
}
|
|
|
delete.setFinishTimestamp(System.currentTimeMillis());
|
|
@@ -387,26 +401,75 @@ public class ArticleAuditService {
|
|
|
log.error("articleVideoDelete ghId:{} error", delete.getGhId(), e);
|
|
|
}
|
|
|
}
|
|
|
+ deleteFailAlarm(alarmList, accountTypeMap);
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
|
- private void deleteFailAlarm(String publishContentId, String typeMsg, Integer index,
|
|
|
+ private void deleteFailAlarm(List<JSONObject> alarmList,
|
|
|
Map<String, PublishAccountTypeDTO> accountTypeMap) {
|
|
|
- PublishContentDTO publishContent = aigcBaseMapper.getPublishContentById(publishContentId);
|
|
|
- PublishAccount publishAccount = publishAccountRepository.getById(publishContent.getPublishAccountId());
|
|
|
- String publishTime = DateUtils.timestampToYMDStr(publishContent.getPublishTimestamp() / 1000, "yyyyMMdd");
|
|
|
- PublishAccountTypeDTO accountTypeDTO = accountTypeMap.get(publishAccount.getGhId());
|
|
|
- String accountType = Objects.nonNull(accountTypeDTO) ? accountTypeDTO.getAccountSourceName() : "未知";
|
|
|
+ List<String> publishContentIds = alarmList.stream().map(o -> o.getString("publishContentId"))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<PublishContentDTO> publishContents = aigcBaseMapper.getPublishContentByIdIn(publishContentIds);
|
|
|
+ Map<String, PublishContentDTO> publishContentMap = publishContents.stream()
|
|
|
+ .collect(Collectors.toMap(PublishContentDTO::getId, Function.identity()));
|
|
|
+ List<String> publishAccountIds = publishContents.stream().map(PublishContentDTO::getPublishAccountId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<PublishAccount> publishAccounts = publishAccountRepository.getByIdIn(publishAccountIds);
|
|
|
+ Map<String, PublishAccount> publishAccountMap = publishAccounts.stream()
|
|
|
+ .collect(Collectors.toMap(PublishAccount::getId, Function.identity()));
|
|
|
+ List<FeishuTableDTO.Column> columns = buildArticleDeleteFailColumns();
|
|
|
+ List<JSONObject> rows = new ArrayList<>();
|
|
|
+ for (JSONObject alarm : alarmList) {
|
|
|
+ String publishContentId = alarm.getString("publishContentId");
|
|
|
+ PublishContentDTO publishContent = publishContentMap.get(publishContentId);
|
|
|
+ String publishTime = DateUtils.timestampToYMDStr(publishContent.getPublishTimestamp() / 1000, "yyyyMMdd");
|
|
|
+ PublishAccount publishAccount = publishAccountMap.get(publishContent.getPublishAccountId());
|
|
|
+ PublishAccountTypeDTO accountTypeDTO = accountTypeMap.get(publishAccount.getGhId());
|
|
|
+ String accountType = Objects.nonNull(accountTypeDTO) ? accountTypeDTO.getAccountSourceName() : "未知";
|
|
|
+
|
|
|
+ JSONObject row = new JSONObject();
|
|
|
+ row.put("account_name", publishAccount.getName());
|
|
|
+ row.put("gh_id", publishAccount.getGhId());
|
|
|
+ row.put("account_type", accountType);
|
|
|
+ row.put("publish_time", publishTime);
|
|
|
+ row.put("index", String.valueOf(alarm.getInteger("index")));
|
|
|
+ row.put("title", publishContent.getTitle());
|
|
|
+ row.put("err_msg", alarm.getString("errMsg"));
|
|
|
+ rows.add(row);
|
|
|
+ }
|
|
|
+ FeishuTableDTO tableDTO = FeishuTableDTO.createTable("文章删除失败", columns, rows);
|
|
|
+ JSONObject content = JSONObject.parseObject(JSONObject.toJSONString(tableDTO));
|
|
|
// 无法自动删除 发送飞书通知 人工删除
|
|
|
- FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.ARTICLE_DELETE.getRobotId(),
|
|
|
- "【文章删除失败】\n" +
|
|
|
- "账号名称: " + publishAccount.getName() + "\n" +
|
|
|
- "账号ghId: " + publishAccount.getGhId() + "\n" +
|
|
|
- "账号来源: " + accountType + "\n" +
|
|
|
- "发布日期: " + publishTime + "\n" +
|
|
|
- "位置: " + index + "\n" +
|
|
|
- "标题: " + publishContent.getTitle() + "\n" +
|
|
|
- "原因: " + typeMsg);
|
|
|
+ JSONObject bodyParam = new JSONObject();
|
|
|
+ bodyParam.put("msg_type", "interactive");
|
|
|
+ bodyParam.put("card", content);
|
|
|
+ FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.ARTICLE_DELETE.getRobotId(), bodyParam);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<FeishuTableDTO.Column> buildArticleDeleteFailColumns() {
|
|
|
+ List<FeishuTableDTO.Column> columns = new ArrayList<>();
|
|
|
+ FeishuTableDTO.Column accountNameColumn = FeishuTableDTO.createFeishuColumns(
|
|
|
+ FieshuTableColumnDataTypeEnum.TEXT.getType(), "account_name", "账号名称", null);
|
|
|
+ columns.add(accountNameColumn);
|
|
|
+ FeishuTableDTO.Column accountGhIdColumn = FeishuTableDTO.createFeishuColumns(
|
|
|
+ FieshuTableColumnDataTypeEnum.TEXT.getType(), "gh_id", "账号ghId", null);
|
|
|
+ columns.add(accountGhIdColumn);
|
|
|
+ FeishuTableDTO.Column accountTypeColumn = FeishuTableDTO.createFeishuColumns(
|
|
|
+ FieshuTableColumnDataTypeEnum.TEXT.getType(), "account_type", "账号来源", null);
|
|
|
+ columns.add(accountTypeColumn);
|
|
|
+ FeishuTableDTO.Column publishTimeColumn = FeishuTableDTO.createFeishuColumns(
|
|
|
+ FieshuTableColumnDataTypeEnum.TEXT.getType(), "publish_time", "发布日期", null);
|
|
|
+ columns.add(publishTimeColumn);
|
|
|
+ FeishuTableDTO.Column indexColumn = FeishuTableDTO.createFeishuColumns(
|
|
|
+ FieshuTableColumnDataTypeEnum.TEXT.getType(), "index", "位置", null);
|
|
|
+ columns.add(indexColumn);
|
|
|
+ FeishuTableDTO.Column titleColumn = FeishuTableDTO.createFeishuColumns(
|
|
|
+ FieshuTableColumnDataTypeEnum.TEXT.getType(), "title", "标题", null);
|
|
|
+ columns.add(titleColumn);
|
|
|
+ FeishuTableDTO.Column errMsgColumn = FeishuTableDTO.createFeishuColumns(
|
|
|
+ FieshuTableColumnDataTypeEnum.TEXT.getType(), "err_msg", "原因", null);
|
|
|
+ columns.add(errMsgColumn);
|
|
|
+ return columns;
|
|
|
}
|
|
|
|
|
|
public void titleDangerFindDelete(ArticleDangerFindDeleteParam param) {
|