Explorar o código

Merge branch 'master' into wyp/0914-export

wangyunpeng hai 10 meses
pai
achega
2d25c02b6c

+ 5 - 0
long-article-recommend-service/pom.xml

@@ -126,6 +126,11 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-webflux</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>com.xuxueli</groupId>
+            <artifactId>xxl-job-core</artifactId>
+        </dependency>
     </dependencies>
 
 

+ 56 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/config/XxlJobConfig.java

@@ -0,0 +1,56 @@
+package com.tzld.longarticle.recommend.server.config;
+
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author ehlxr
+ * @since 2022-01-17 13:48.
+ */
+@Configuration
+public class XxlJobConfig {
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
+    @Value("${xxl.job.admin.addresses}")
+    private String adminAddresses;
+
+    @Value("${xxl.job.accessToken}")
+    private String accessToken;
+
+    @Value("${xxl.job.executor.appname}")
+    private String appName;
+
+    @Value("${xxl.job.executor.address}")
+    private String address;
+
+    @Value("${xxl.job.executor.ip}")
+    private String ip;
+
+    @Value("${xxl.job.executor.port}")
+    private int port;
+
+    @Value("${xxl.job.executor.logpath}")
+    private String logPath;
+
+    @Value("${xxl.job.executor.logretentiondays}")
+    private int logRetentionDays;
+
+    @Bean
+    public XxlJobSpringExecutor xxlJobExecutor() {
+        log.info("xxl-job config init");
+        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
+        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
+        xxlJobSpringExecutor.setAppname(appName);
+        xxlJobSpringExecutor.setAddress(address);
+        xxlJobSpringExecutor.setIp(ip);
+        xxlJobSpringExecutor.setPort(port);
+        xxlJobSpringExecutor.setAccessToken(accessToken);
+        xxlJobSpringExecutor.setLogPath(logPath);
+        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
+        return xxlJobSpringExecutor;
+    }
+
+}

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

@@ -24,13 +24,14 @@ import com.tzld.longarticle.recommend.server.repository.mapper.longArticle.LongA
 import com.tzld.longarticle.recommend.server.util.DateUtils;
 import com.tzld.longarticle.recommend.server.util.MapBuilder;
 import com.tzld.longarticle.recommend.server.util.feishu.FeiShu;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.util.Pair;
 import org.springframework.http.*;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
@@ -76,10 +77,11 @@ public class DataDashboardService {
         exportFeishuNewSortStrategy(dateStrList, sheetToken, "7d4e12");
     }
 
-    @Scheduled(cron = "0 0 4 * * ?")
-    public void scheduledExport() {
+    @XxlJob("scheduledExport")
+    public ReturnT<String> scheduledExport(String param) {
         List<String> dateStrList = DateUtils.getBeforeDays(null, 5);
         exportFeishuNewSortStrategy(dateStrList, sheetToken, "7d4e12");
+        return ReturnT.SUCCESS;
     }
 
 
@@ -356,6 +358,7 @@ public class DataDashboardService {
             if (sumFission0 > 0) {
                 obj.setFission1Fission0Rate((sumFission1 * 1.0) / sumFission0);
             }
+            result.add(obj);
             // aigc 数据
             PublishAccount publishAccount = publishAccountMap.get(article.getGhId());
             Map<String, PublishContent> titleContentMap = publishContentMap.get(publishAccount.getId());
@@ -411,7 +414,6 @@ public class DataDashboardService {
                     }
                 }
             }
-            result.add(obj);
         }
         result.sort(Comparator.comparing(NewSortStrategyExport::getDateStr).reversed()
                 .thenComparing(NewSortStrategyExport::getGhId).thenComparing(NewSortStrategyExport::getPosition));

+ 5 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/RecallService.java

@@ -28,6 +28,7 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.stereotype.Service;
@@ -68,6 +69,9 @@ public class RecallService implements ApplicationContextAware {
     private ApplicationContext applicationContext;
     private final ExecutorService pool = ThreadPoolFactory.recallPool();
 
+    @Value("${recall.content.his.fieshu.enable:false}")
+    private Boolean contentHisFieshuEnable;
+
 
     @PostConstruct
     public void init() {
@@ -344,7 +348,7 @@ public class RecallService implements ApplicationContextAware {
             }
             if (CollectionUtils.isEmpty(article.getArticleDetailInfoList())) {
                 // 仅判断7.12以后发布文章
-                if (article.getUpdateTime() > 1720713600) {
+                if (article.getUpdateTime() > 1720713600 && contentHisFieshuEnable) {
                     FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634", "历史表现裂变特征获取失败\n"
                             + "ghId: " + article.getGhId() + "\n"
                             + "账号名称: " + article.getAccountName() + "\n"

+ 13 - 0
long-article-recommend-service/src/main/resources/application-dev.yml

@@ -85,6 +85,19 @@ spring:
 apollo:
   meta: http://devapolloconfig-internal.piaoquantv.com
 
+xxl:
+  job:
+    admin:
+      addresses: http://xxl-job-test-internal.piaoquantv.com/xxl-job-admin
+    accessToken:
+    executor:
+      appname: ${spring.application.name}
+      address:
+      ip:
+      port: 9999
+      logpath: /datalog/weblog/${spring.application.name}/xxl-job/
+      logretentiondays: 30
+
 aliyun:
   log:
     endpoint: cn-hangzhou.log.aliyuncs.com

+ 5 - 0
long-article-recommend-service/src/main/resources/application-prod.yml

@@ -68,6 +68,11 @@ spring:
 apollo:
   meta: http://apolloconfig-internal.piaoquantv.com
 
+xxl:
+  job:
+    admin:
+      addresses: http://xxl-job-internal.piaoquantv.com/xxl-job-admin
+
 aliyun:
   log:
     endpoint: cn-hangzhou-intranet.log.aliyuncs.com

+ 1 - 1
long-article-recommend-service/src/main/resources/application.yml

@@ -54,4 +54,4 @@ apollo:
   cacheDir: /datalog/apollo-cache-dir
 
 mybatis:
-  mapper-locations: classpath:/mapper/*.xml
+  mapper-locations: classpath:/mapper/*.xml