|
@@ -3,6 +3,7 @@ package com.tzld.longarticle.recommend.server.remote;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
import com.tzld.longarticle.recommend.server.common.HttpPoolFactory;
|
|
import com.tzld.longarticle.recommend.server.common.HttpPoolFactory;
|
|
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotIdEnum;
|
|
|
import com.tzld.longarticle.recommend.server.model.dto.Content;
|
|
import com.tzld.longarticle.recommend.server.model.dto.Content;
|
|
|
import com.tzld.longarticle.recommend.server.util.MapBuilder;
|
|
import com.tzld.longarticle.recommend.server.util.MapBuilder;
|
|
|
import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
|
|
import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
|
|
@@ -17,7 +18,6 @@ import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -50,12 +50,13 @@ public class NLPRemoteService {
|
|
|
private static final String scoreListUrl = "http://61.48.133.26:6060/score_list";
|
|
private static final String scoreListUrl = "http://61.48.133.26:6060/score_list";
|
|
|
private static final String backUrl = "http://47.98.136.48:6060/score_list";
|
|
private static final String backUrl = "http://47.98.136.48:6060/score_list";
|
|
|
|
|
|
|
|
- public Map<String, Double> score(String accountName, List<Content> contentList) {
|
|
|
|
|
|
|
+ public Map<String, Double> score(String ghId, String accountName, List<Content> contentList) {
|
|
|
long start = System.currentTimeMillis();
|
|
long start = System.currentTimeMillis();
|
|
|
Map<String, Double> result = new HashMap<>();
|
|
Map<String, Double> result = new HashMap<>();
|
|
|
List<String> titleList = contentList.stream().map(Content::getTitle).collect(Collectors.toList());
|
|
List<String> titleList = contentList.stream().map(Content::getTitle).collect(Collectors.toList());
|
|
|
String url = scoreListUrl;
|
|
String url = scoreListUrl;
|
|
|
JSONObject bodyParam = new JSONObject();
|
|
JSONObject bodyParam = new JSONObject();
|
|
|
|
|
+ bodyParam.put("gh_id_list", Collections.singletonList(ghId));
|
|
|
bodyParam.put("account_nickname_list", Collections.singletonList(accountName));
|
|
bodyParam.put("account_nickname_list", Collections.singletonList(accountName));
|
|
|
bodyParam.put("text_list", titleList);
|
|
bodyParam.put("text_list", titleList);
|
|
|
bodyParam.put("interest_type", accountScoreInterestTypeMap.getOrDefault(accountName, "avg"));
|
|
bodyParam.put("interest_type", accountScoreInterestTypeMap.getOrDefault(accountName, "avg"));
|
|
@@ -84,7 +85,14 @@ public class NLPRemoteService {
|
|
|
// log.info("scoreList 返回的数据:{}", responseBody);
|
|
// log.info("scoreList 返回的数据:{}", responseBody);
|
|
|
JSONObject scoreListResponse = JSONObject.parseObject(responseBody);
|
|
JSONObject scoreListResponse = JSONObject.parseObject(responseBody);
|
|
|
if (Objects.nonNull(scoreListResponse)) {
|
|
if (Objects.nonNull(scoreListResponse)) {
|
|
|
- JSONObject accountScoreList = scoreListResponse.getJSONObject(accountName);
|
|
|
|
|
|
|
+ Set<String> keySet = scoreListResponse.keySet();
|
|
|
|
|
+ JSONObject accountScoreList = null;
|
|
|
|
|
+ for (String key : keySet) {
|
|
|
|
|
+ if (key.equals(accountName) || key.equals(ghId)) {
|
|
|
|
|
+ accountScoreList = scoreListResponse.getJSONObject(key);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (Objects.nonNull(accountScoreList)) {
|
|
if (Objects.nonNull(accountScoreList)) {
|
|
|
List<Double> scoreList = accountScoreList.getJSONArray("score_list").toJavaList(Double.class);
|
|
List<Double> scoreList = accountScoreList.getJSONArray("score_list").toJavaList(Double.class);
|
|
|
for (int i = 0; i < contentList.size(); i++) {
|
|
for (int i = 0; i < contentList.size(); i++) {
|
|
@@ -101,13 +109,12 @@ public class NLPRemoteService {
|
|
|
.put("url", url)
|
|
.put("url", url)
|
|
|
.put("账号名称", accountName)
|
|
.put("账号名称", accountName)
|
|
|
.build());
|
|
.build());
|
|
|
- FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634", "4090计算评分失败\n"
|
|
|
|
|
|
|
+ FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
|
|
|
|
|
+ "4090计算评分失败\n"
|
|
|
+ "url: " + url +"\n"
|
|
+ "url: " + url +"\n"
|
|
|
+ "账号名称: " + accountName);
|
|
+ "账号名称: " + accountName);
|
|
|
- if (StringUtils.hasText(e.getMessage()) && e.getMessage().contains("Connection")) {
|
|
|
|
|
- url = backUrl;
|
|
|
|
|
- client = HttpPoolFactory.thirtySecondPool();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ url = backUrl;
|
|
|
|
|
+ client = HttpPoolFactory.thirtySecondPool();
|
|
|
log.error("score error", e);
|
|
log.error("score error", e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|