Browse Source

每日冷启生成计划审核报警

wangyunpeng 7 months ago
parent
commit
6584dfbf89

+ 34 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/aigc/ProduceContentAuditStatusEnum.java

@@ -0,0 +1,34 @@
+package com.tzld.longarticle.recommend.server.common.enums.aigc;
+
+import lombok.Getter;
+
+import java.util.Objects;
+
+@Getter
+public enum ProduceContentAuditStatusEnum {
+    // 0-待审核,1-审核通过,2-审核不通过,3-不审核
+    waiting(0, "待审核"),
+    pass(1, "审核通过"),
+    reject(2, "审核不通过"),
+    not_audit(3, "不审核"),
+
+    other(999, "其他"),
+    ;
+
+    private final Integer val;
+    private final String description;
+
+    ProduceContentAuditStatusEnum(Integer val, String description) {
+        this.val = val;
+        this.description = description;
+    }
+
+    public static ProduceContentAuditStatusEnum from(Integer val) {
+        for (ProduceContentAuditStatusEnum statusEnum : ProduceContentAuditStatusEnum.values()) {
+            if (Objects.equals(statusEnum.val, val)) {
+                return statusEnum;
+            }
+        }
+        return other;
+    }
+}

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/aigc/AigcBaseMapper.java

@@ -58,4 +58,6 @@ public interface AigcBaseMapper {
     List<PublishContentDTO> getPublishContentBySourceIdIn(List<String> sourceIds);
 
     List<CrawlerPlan> getColdCrawlerPlan(Long timeStart, Long timeEnd, List<String> planTags);
+
+    List<ProducePlanAuditCheckDTO> getColdProducePlanAudit(Long timeStart, Long timeEnd, List<String> planIds);
 }

+ 10 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/ProducePlanAuditCheckDTO.java

@@ -0,0 +1,10 @@
+package com.tzld.longarticle.recommend.server.model.dto;
+
+import lombok.Data;
+
+@Data
+public class ProducePlanAuditCheckDTO {
+    private String planId;
+    private Integer auditStatus;
+    private Integer num;
+}

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

@@ -8,17 +8,16 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import com.tzld.longarticle.recommend.server.common.CommonThreadPoolExecutor;
+import com.tzld.longarticle.recommend.server.common.enums.aigc.ProduceContentAuditStatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.AccountBusinessTypeEnum;
 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.crawler.CrawlerBaseMapper;
 import com.tzld.longarticle.recommend.server.mapper.growth.NewPushMessageCallbackMapper;
 import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
-import com.tzld.longarticle.recommend.server.model.dto.AccountTypeFansDTO;
-import com.tzld.longarticle.recommend.server.model.dto.Content;
-import com.tzld.longarticle.recommend.server.model.dto.NotPublishPlan;
-import com.tzld.longarticle.recommend.server.model.dto.PublishPlanAccountNotifyDTO;
+import com.tzld.longarticle.recommend.server.model.dto.*;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.CrawlerPlan;
+import com.tzld.longarticle.recommend.server.model.entity.aigc.ProducePlan;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountAvgInfo;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.GetOffVideoCrawler;
@@ -27,6 +26,7 @@ import com.tzld.longarticle.recommend.server.model.entity.longArticle.*;
 import com.tzld.longarticle.recommend.server.model.param.ArticleFindSourceParam;
 import com.tzld.longarticle.recommend.server.model.param.TitleHisCacheParam;
 import com.tzld.longarticle.recommend.server.remote.ODPSManager;
+import com.tzld.longarticle.recommend.server.repository.aigc.ProducePlanRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.GetOffVideoCrawlerRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.LongArticlesVideoRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.*;
@@ -94,6 +94,8 @@ public class XxlJobService {
     private ArticleTitleHisCacheRepository articleTitleHisCacheRepository;
     @Autowired
     private RecallService recallService;
+    @Autowired
+    private ProducePlanRepository producePlanRepository;
 
     ExecutorService thread = new CommonThreadPoolExecutor(
             5,
@@ -248,6 +250,50 @@ public class XxlJobService {
         return ReturnT.SUCCESS;
     }
 
+    @XxlJob("checkColdProducePlanAudit")
+    public ReturnT<String> checkColdProducePlanAudit(String param) {
+        long timeStamp = DateUtils.getBeforeDayStart(1);
+        if (StringUtils.hasText(param)) {
+            timeStamp = DateUtils.getStartOfDay(param, "yyyyMMdd");
+        }
+        timeStamp = timeStamp * 1000;
+        List<String> planIds = Arrays.asList("20241030070010871546586","20240802080355355308981","20240802021606053813696");
+        List<ProducePlan> producePlans = producePlanRepository.findByIdIn(planIds);
+        Map<String, String> producePlanMap = producePlans.stream().collect(Collectors.toMap(ProducePlan::getId, ProducePlan::getName));
+        List<ProducePlanAuditCheckDTO> producePlanList = aigcBaseMapper.getColdProducePlanAudit(
+                timeStamp, timeStamp + 86400000, planIds);
+        Map<String, List<ProducePlanAuditCheckDTO>> producePlanAuditMap = producePlanList.stream()
+                .collect(Collectors.groupingBy(ProducePlanAuditCheckDTO::getPlanId));
+        for (String planId : planIds) {
+            List<ProducePlanAuditCheckDTO> auditCheckDTOList = producePlanAuditMap.get(planId);
+            Integer yesterdayAuditNum = 0, yesterdayAuditPassNum = 0, waitingAuditNum = 0;
+            if (CollectionUtils.isNotEmpty(auditCheckDTOList)) {
+                for (ProducePlanAuditCheckDTO producePlanAuditCheckDTO : auditCheckDTOList) {
+                    if (Objects.equals(producePlanAuditCheckDTO.getAuditStatus(), ProduceContentAuditStatusEnum.waiting.getVal())) {
+                        waitingAuditNum = producePlanAuditCheckDTO.getNum();
+                    } else if (Objects.equals(producePlanAuditCheckDTO.getAuditStatus(), ProduceContentAuditStatusEnum.pass.getVal())) {
+                        yesterdayAuditPassNum = producePlanAuditCheckDTO.getNum();
+                        yesterdayAuditNum += producePlanAuditCheckDTO.getNum();
+                    } else if (Objects.equals(producePlanAuditCheckDTO.getAuditStatus(), ProduceContentAuditStatusEnum.reject.getVal())) {
+                        yesterdayAuditNum += producePlanAuditCheckDTO.getNum();
+                    }
+                }
+            }
+            log.info("checkColdProducePlanAudit planId: {}, planName: {}, yesterdayAuditNum: {}, " +
+                            "yesterdayAuditPassNum: {}, waitingAuditNum: {}",
+                    planId, producePlanMap.get(planId), yesterdayAuditNum, yesterdayAuditPassNum, waitingAuditNum);
+            FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.DAILY.getRobotId(),
+                    "【冷启生成计划审核数量】\n"
+                            + "planId: " + planId + "\n"
+                            + "planName: " + producePlanMap.get(planId) + "\n"
+                            + "前一天审核数量: " + yesterdayAuditNum + "\n"
+                            + "前一天审核通过数量: " + yesterdayAuditPassNum + "\n"
+                            + "当前待审核数量: " + waitingAuditNum + "\n"
+                            + "<at user_id=\"all\">所有人</at> ");
+        }
+        return ReturnT.SUCCESS;
+    }
+
     @XxlJob("migrateCrawlerRootSourceId")
     public ReturnT<String> migrateCrawlerRootSourceId(String param) {
         try {

+ 5 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/XxlJobController.java

@@ -29,6 +29,11 @@ public class XxlJobController {
         service.checkColdCrawlerPlan(dateStr);
     }
 
+    @GetMapping("/checkColdProducePlanAudit")
+    public void checkColdProducePlanAudit(String dateStr) {
+        service.checkColdProducePlanAudit(dateStr);
+    }
+
     @GetMapping("/migrateCrawlerRootSourceId")
     public void migrateCrawlerRootSourceId(String dateStr) {
         service.migrateCrawlerRootSourceId(dateStr);

+ 14 - 0
long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml

@@ -283,4 +283,18 @@
         </foreach>
     </select>
 
+    <select id="getColdProducePlanAudit"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.ProducePlanAuditCheckDTO">
+        select pper.plan_id, pper.audit_status as auditStatus, count(1) as num
+        from produce_plan_exe_record pper
+        join produce_review_record prr on prr.plan_exe_id = pper.plan_exe_id
+        where pper.plan_id in
+        <foreach collection="planIds" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+        and ((pper.audit_status in (1, 2)
+        and pper.audit_timestamp between #{timeStart} and #{timeEnd}) or (prr.review_status = 0))
+        GROUP BY pper.plan_id, pper.audit_status
+    </select>
+
 </mapper>