소스 검색

冷启抓取计划每日抓取数量报警

wangyunpeng 7 달 전
부모
커밋
31a273139a

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

@@ -56,4 +56,6 @@ public interface AigcBaseMapper {
     PublishContentDTO getPublishContentById(String publishContentId);
 
     List<PublishContentDTO> getPublishContentBySourceIdIn(List<String> sourceIds);
+
+    List<CrawlerPlan> getColdCrawlerPlan(Long timeStart, Long timeEnd, List<String> planTags);
 }

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

@@ -17,6 +17,7 @@ import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseM
 import com.tzld.longarticle.recommend.server.model.dto.AccountTypeFansDTO;
 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.entity.aigc.CrawlerPlan;
 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;
@@ -201,6 +202,44 @@ public class XxlJobService {
         return ReturnT.SUCCESS;
     }
 
+    @XxlJob("checkColdCrawlerPlan")
+    public ReturnT<String> checkColdCrawlerPlan(String param) {
+        long timeStamp = DateUtils.getBeforeDayStart(1);
+        if (StringUtils.hasText(param)) {
+            timeStamp = DateUtils.getStartOfDay(param, "yyyyMMdd");
+        }
+        String dateStr = DateUtils.timestampToYMDStr(timeStamp, "yyyyMMdd");
+        timeStamp = timeStamp * 1000;
+        List<String> planTags = Arrays.asList("账号联想_v1", "文章联想_v1", "品类冷启动");
+        List<CrawlerPlan> crawlerPlanList = aigcBaseMapper.getColdCrawlerPlan(timeStamp, timeStamp + 86400000, planTags);
+        if (CollectionUtil.isNotEmpty(crawlerPlanList)) {
+            for (CrawlerPlan crawlerPlan : crawlerPlanList) {
+                JSONObject crawlerModeValue = JSONObject.parseObject(crawlerPlan.getCrawlerModeValue());
+                if (crawlerModeValue == null) {
+                    continue;
+                }
+                JSONObject sourceModeValues = crawlerModeValue.getJSONObject("sourceModeValues");
+                if (sourceModeValues == null) {
+                    continue;
+                }
+                JSONArray inputModeValues = sourceModeValues.getJSONArray("inputModeValues");
+                if (inputModeValues == null) {
+                    continue;
+                }
+                log.info("checkColdCrawlerPlan crawlerPlan: {}", JSONObject.toJSONString(crawlerPlan));
+                FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
+                        dateStr + "冷启计划抓取数量\n"
+                                + "计划ID: " + crawlerPlan.getId() + "\n"
+                                + "计划名称: " + crawlerPlan.getName() + "\n"
+                                + "计划标签: " + crawlerPlan.getPlanTag() + "\n"
+                                + "计划抓取数量: " + inputModeValues.size() + "\n"
+                                + "实际抓取数量: " + crawlerPlan.getCrawlerTotalNum() + "\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

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

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

@@ -271,4 +271,16 @@
         </foreach>
     </select>
 
+    <select id="getColdCrawlerPlan"
+            resultType="com.tzld.longarticle.recommend.server.model.entity.aigc.CrawlerPlan">
+        select *
+        from crawler_plan
+        where plan_type = 2 and channel = 5 and content_modal = 3
+        and create_timestamp between #{timeStart} and #{timeEnd}
+        and plan_tag in
+        <foreach collection="planTags" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </select>
+
 </mapper>