wangyunpeng 10 mesiacov pred
rodič
commit
3e4a36b98c

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

@@ -63,4 +63,6 @@ public interface AigcBaseMapper {
     List<ProduceContentDTO> getProduceContentById(List<String> planExeIds);
 
     List<IdNameVO<String>> articleVideoAuditPlanFilterValue(List<String> planIds, String searchKeyword);
+
+    List<PublishAccount> getPublishAccountByPlanId(String planId);
 }

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

@@ -10,4 +10,6 @@ import java.util.List;
 public interface PublishPlanRepository extends JpaRepository<PublishPlan, String> {
 
     List<PublishPlan> findByIdIn(List<String> planIds);
+
+    List<PublishPlan> getByPlanStatusAndChannel(Integer planStatus, Integer channel);
 }

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

@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: dev
+    active: test
   application:
     name: longarticle-recommend-server
 #  cloud:

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

@@ -282,4 +282,12 @@
         limit 100
     </select>
 
+    <select id="getPublishAccountByPlanId"
+            resultType="com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount">
+        select pa.*
+        from publish_account pa
+        join publish_plan_account ppa on pa.id = ppa.account_id
+        where ppa.plan_id = #{planId}
+    </select>
+
 </mapper>

+ 47 - 0
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/RecommendTest.java

@@ -11,12 +11,15 @@ import com.tzld.longarticle.recommend.server.mapper.aigc.PublishContentMapper;
 import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
 import com.tzld.longarticle.recommend.server.model.dto.PublishContentDTO;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
+import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishPlan;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountAvgInfo;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.ArticleDetailInfo;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.PublishSortLog;
 import com.tzld.longarticle.recommend.server.model.param.PublishContentParam;
+import com.tzld.longarticle.recommend.server.model.param.RecommendRequest;
 import com.tzld.longarticle.recommend.server.repository.aigc.PublishAccountRepository;
+import com.tzld.longarticle.recommend.server.repository.aigc.PublishPlanRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleDetailInfoRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
@@ -25,6 +28,7 @@ import com.tzld.longarticle.recommend.server.service.recommend.RecommendService;
 import com.tzld.longarticle.recommend.server.service.recommend.recall.RecallService;
 import com.tzld.longarticle.recommend.server.util.DateUtils;
 import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
 import org.apache.commons.math3.stat.correlation.PearsonsCorrelation;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
@@ -43,6 +47,7 @@ import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 @SpringBootTest(classes = Application.class)
@@ -69,6 +74,8 @@ public class RecommendTest {
     private AigcBaseMapper aigcBaseMapper;
     @Autowired
     private PublishContentMapper publishContentMapper;
+    @Autowired
+    private PublishPlanRepository publishPlanRepository;
 
     @ApolloJsonValue("${accountStrategyConfig:{}}")
     private Map<String, String> accountStrategyConfigMap;
@@ -877,4 +884,44 @@ public class RecommendTest {
         }
         System.out.println(JSONObject.toJSONString(accountStrategyConfigMap));
     }
+
+    @Test
+    public void deepTest() {
+        List<PublishPlan> publishPlanList = publishPlanRepository.getByPlanStatusAndChannel(1, 5);
+        for (PublishPlan publishPlan : publishPlanList) {
+            List<PublishAccount> accountList = aigcBaseMapper.getPublishAccountByPlanId(publishPlan.getId());
+            for (PublishAccount publishAccount : accountList) {
+                RecommendRequest param = new RecommendRequest();
+                param.setAccountId(publishAccount.getId());
+                param.setAccountName(publishAccount.getName());
+                param.setGhId(publishAccount.getGhId());
+                param.setPlanId(publishPlan.getId());
+                param.setPushType(1);
+                param.setPublishNum(4);
+                param.setStrategy("ArticleRankV5");
+                param.setParamStrategy(true);
+                param.setExcludeLog(true);
+                long start = System.currentTimeMillis();
+                try {
+                    OkHttpClient client = new OkHttpClient().newBuilder()
+                            .connectTimeout(15, TimeUnit.MINUTES)
+                            .readTimeout(15, TimeUnit.MINUTES)
+                            .writeTimeout(15, TimeUnit.MINUTES)
+                            .build();
+                    MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
+                    RequestBody body = RequestBody.create(mediaType, JSONObject.toJSONString(param));
+                    Request request = new Request.Builder()
+                            .url("http://121.199.79.174:80/recommend")
+                            .method("POST", body)
+                            .addHeader("Content-Type", "application/json;charset=UTF-8")
+                            .build();
+                    Response response = client.newCall(request).execute();
+                } catch (IOException e) {
+                    log.error("deepTest error", e);
+                }
+                log.info("deepTest finish planId:{} accountName:{} cost:{}", publishPlan.getId(),
+                        publishAccount.getName(), System.currentTimeMillis() - start);
+            }
+        }
+    }
 }