소스 검색

文章删除失败 卡片表格导出

wangyunpeng 6 달 전
부모
커밋
a341ce6ee2

+ 43 - 39
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleAuditService.java

@@ -315,47 +315,51 @@ public class ArticleAuditService {
         // 删除文章
         List<JSONObject> alarmList = new ArrayList<>();
         for (String publishContentId : publishContentIds) {
-            String pushId = publishPushIdMap.get(publishContentId);
-            if (!StringUtils.hasText(pushId)) {
-                deleteFailAlarmAdd(alarmList, publishContentId, "无推送记录", 0);
-                continue;
-            }
-            PublishGzhPushDTO publishGzhPushDTO = pushDTOMap.get(pushId);
-            if (Objects.isNull(publishGzhPushDTO)) {
-                deleteFailAlarmAdd(alarmList, publishContentId, "无推送记录", 0);
-                continue;
-            }
-            String publishAccountId = pushAccountMap.get(pushId);
-            String ghId = publishAccountMap.get(publishAccountId);
-            List<PublishGzhPushContentRelDTO> relList = groupPushRelMap.get(pushId).stream()
-                    .sorted(Comparator.comparing(PublishGzhPushContentRelDTO::getId)).collect(Collectors.toList());
-            int index = 1;
-            for (int i = 0; i < relList.size(); i++) {
-                if (relList.get(i).getPublishContentId().equals(publishContentId)) {
-                    index = i + 1;
-                    break;
+            try {
+                String pushId = publishPushIdMap.get(publishContentId);
+                if (!StringUtils.hasText(pushId)) {
+                    deleteFailAlarmAdd(alarmList, publishContentId, "无推送记录", 0);
+                    continue;
                 }
+                PublishGzhPushDTO publishGzhPushDTO = pushDTOMap.get(pushId);
+                if (Objects.isNull(publishGzhPushDTO)) {
+                    deleteFailAlarmAdd(alarmList, publishContentId, "无推送记录", 0);
+                    continue;
+                }
+                String publishAccountId = pushAccountMap.get(pushId);
+                String ghId = publishAccountMap.get(publishAccountId);
+                List<PublishGzhPushContentRelDTO> relList = groupPushRelMap.get(pushId).stream()
+                        .sorted(Comparator.comparing(PublishGzhPushContentRelDTO::getId)).collect(Collectors.toList());
+                int index = 1;
+                for (int i = 0; i < relList.size(); i++) {
+                    if (relList.get(i).getPublishContentId().equals(publishContentId)) {
+                        index = i + 1;
+                        break;
+                    }
+                }
+                if (!publishGzhPushDTO.getPushType().equals(PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
+                    PushTypeEnum pushTypeEnum = PushTypeEnum.from(publishGzhPushDTO.getPushType());
+                    deleteFailAlarmAdd(alarmList, publishContentId, "推送类型为" + pushTypeEnum.getDescription(), index);
+                    continue;
+                }
+                String groupPushMsgId = pushIdMap.get(pushId);
+                if (!StringUtils.hasText(groupPushMsgId)) {
+                    deleteFailAlarmAdd(alarmList, publishContentId, "无推送MsgId", index);
+                    continue;
+                }
+                LongArticleAuditDelete delete = new LongArticleAuditDelete();
+                delete.setGhId(ghId);
+                delete.setMsgId(groupPushMsgId);
+                delete.setPushId(pushId);
+                delete.setPushType(publishGzhPushDTO.getPushType());
+                delete.setPublishContentId(publishContentId);
+                delete.setIndex(index);
+                delete.setStatus(StatusEnum.ZERO.getCode());
+                delete.setCreateTimestamp(System.currentTimeMillis());
+                longArticleAuditDeleteRepository.save(delete);
+            } catch (Exception e) {
+                log.error("buildArticleAuditDelete error", e);
             }
-            if (!publishGzhPushDTO.getPushType().equals(PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
-                PushTypeEnum pushTypeEnum = PushTypeEnum.from(publishGzhPushDTO.getPushType());
-                deleteFailAlarmAdd(alarmList, publishContentId, "推送类型为" + pushTypeEnum.getDescription(), index);
-                continue;
-            }
-            String groupPushMsgId = pushIdMap.get(pushId);
-            if (!StringUtils.hasText(groupPushMsgId)) {
-                deleteFailAlarmAdd(alarmList, publishContentId, "无推送MsgId", index);
-                continue;
-            }
-            LongArticleAuditDelete delete = new LongArticleAuditDelete();
-            delete.setGhId(ghId);
-            delete.setMsgId(groupPushMsgId);
-            delete.setPushId(pushId);
-            delete.setPushType(publishGzhPushDTO.getPushType());
-            delete.setPublishContentId(publishContentId);
-            delete.setIndex(index);
-            delete.setStatus(StatusEnum.ZERO.getCode());
-            delete.setCreateTimestamp(System.currentTimeMillis());
-            longArticleAuditDeleteRepository.save(delete);
         }
         deleteFailAlarm(alarmList, accountTypeMap);
     }