浏览代码

发布计划检查修改

wangyunpeng 7 月之前
父节点
当前提交
fc65936810

+ 37 - 6
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/XxlJobService.java

@@ -40,6 +40,9 @@ import com.tzld.longarticle.recommend.server.util.LarkRobotUtil;
 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.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DuplicateKeyException;
@@ -119,6 +122,22 @@ public class XxlJobService {
         return ReturnT.SUCCESS;
     }
 
+    @Getter
+    @Setter
+    @Accessors(chain = true)
+    public static class PlanErrorMsg {
+        private String date;
+        List<PlanErrorMsgDetail> errorMsgDetails;
+    }
+
+    @Getter
+    @Setter
+    @Accessors(chain = true)
+    public static class PlanErrorMsgDetail {
+        private String accountName;
+        private String errorMsg;
+    }
+
     private void sendFeishuPublishPlanNotPushWarn(NotPublishPlan publishPlan) {
         Long todayStart = DateUtils.getTodayStart();
         List<PublishAccount> publishAccounts = aigcBaseMapper.getPublishAccounts(publishPlan.getPlanId(), todayStart);
@@ -128,11 +147,23 @@ public class XxlJobService {
         } else {
             return;
         }
-        if (StringUtils.hasText(publishPlan.getErrorMsg()) && (
-                publishPlan.getErrorMsg().contains("45028")
-                        || publishPlan.getErrorMsg().contains("48004")
-                        || publishPlan.getErrorMsg().contains("50002")
-        )) {
+        PlanErrorMsg planErrorMsg = JSONObject.parseObject(publishPlan.getErrorMsg(), PlanErrorMsg.class);
+        if (planErrorMsg == null) {
+            return;
+        } else if (CollectionUtil.isEmpty(planErrorMsg.getErrorMsgDetails())) {
+            return;
+        }
+        Iterator<PlanErrorMsgDetail> iterator = planErrorMsg.getErrorMsgDetails().iterator();
+        while (iterator.hasNext()) {
+            PlanErrorMsgDetail errorMsgDetail = iterator.next();
+            if (errorMsgDetail.getErrorMsg().contains("45028")
+                    || errorMsgDetail.getErrorMsg().contains("48004")
+                    || errorMsgDetail.getErrorMsg().contains("50002")) {
+                iterator.remove();
+                accountNames.remove(errorMsgDetail.getAccountName());
+            }
+        }
+        if (CollectionUtil.isEmpty(planErrorMsg.getErrorMsgDetails())) {
             return;
         }
         FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
@@ -142,7 +173,7 @@ public class XxlJobService {
                         + "预计数量: " + publishPlan.getExpectCount() + "\n"
                         + "实际数量: " + publishPlan.getPublishCount() + "\n"
                         + "发送失败账号: " + JSONObject.toJSONString(accountNames) + "\n"
-                        + "发布计划失败原因: " + publishPlan.getErrorMsg() + "\n"
+                        + "发布计划失败原因: " + JSONObject.toJSONString(planErrorMsg) + "\n"
                         + "发布时间: " + publishPlan.getPublishPushTime() + "\n"
                         + "<at user_id=\"all\">所有人</at> ");
     }