This commit is contained in:
Leo
2025-12-14 00:00:45 +08:00
parent f89ed66bcc
commit d78e77530b
7 changed files with 86 additions and 11 deletions

View File

@@ -72,6 +72,12 @@ public class JDScheduleJob {
@Getter
@Value("${isRunning.jd}")
private String isRunning_jd;
@Value("${jarvis.server.comment.base-url:http://192.168.8.6:5000}")
private String commentBaseUrl;
@Value("${jarvis.server.comment.fetch-path:/fetch_comments}")
private String commentFetchPath;
// 构造函数中注入StringRedisTemplate
@Autowired
@@ -516,7 +522,7 @@ public class JDScheduleJob {
try {
String fetchUrl = "http://192.168.8.6:5000/fetch_comments?product_id=" + product_id;
String fetchUrl = commentBaseUrl + commentFetchPath + "?product_id=" + product_id;
// 用hutool发起post请求
HttpResponse response = HttpRequest.post(fetchUrl).timeout(60000).execute();

View File

@@ -35,6 +35,7 @@ import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -146,6 +147,12 @@ public class JDUtil {
final WXUtil wxUtil;
private final StringRedisTemplate redisTemplate;
@Value("${jarvis.server.comment.base-url:http://192.168.8.6:5000}")
private String commentBaseUrl;
@Value("${jarvis.server.comment.fetch-path:/fetch_comments}")
private String commentFetchPath;
private final OrderRowRepository orderRowRepository;
private final CommentRepository commentRepository;
private final JDOrderRepository jdOrderRepository;
@@ -2230,7 +2237,7 @@ public class JDUtil {
*/
if (!isTb) {
try {
String fetchUrl = "http://192.168.8.6:5000/fetch_comments?product_id=" + product_id;
String fetchUrl = commentBaseUrl + commentFetchPath + "?product_id=" + product_id;
HttpResponse response = HttpRequest.post(fetchUrl).timeout(1000 * 60).execute();
logger.info("fetchUrl: {}", fetchUrl);

View File

@@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson2.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.HashMap;
@@ -21,6 +22,8 @@ public class WxtsUtil {
public static final String TOKEN = "super_token_b62190c26";
private static final String SERVER_URL = "https://wxts.van333.cn";
@Value("${jarvis.server.host:127.0.0.1}")
private String serverHost;
public void sendNotify(String content) {
try {
@@ -28,7 +31,7 @@ public class WxtsUtil {
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("title", "JD机器人微信推送");
content = content.replaceAll("\\n", "<br>");
String common = "192.168.8.88 (微信机器人), 信息 : ";
String common = serverHost + " (微信机器人), 信息 : ";
content = common + content + "<br><br>";
paramMap.put("text", content);
HttpRequest.post(url).header("vanToken", TOKEN).header("source", "XZJ_UBUNTU").body(JSON.toJSONString(paramMap)).execute();

View File

@@ -12,6 +12,7 @@ import cn.hutool.http.HttpResponse;
import cn.hutool.http.Method;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.IOException;
@@ -28,8 +29,12 @@ public class GPTClientUtil {
private static final String GPT_API_URL = "https://api.openai.com/v1/chat/completions"; // GPT API 地址
private static final String GPT_API_KEY = "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"; // 替换为你的 GPT API 密钥
private static final ObjectMapper objectMapper = new ObjectMapper(); // Jackson JSON 解析器
private static final String PROXY_HOST = "192.168.8.9"; // 本地代理地址
private static final int PROXY_PORT = 1070; // 本地代理端口
@Value("${jarvis.server.proxy.host:192.168.8.9}")
private String proxyHost; // 代理地址(注意:此服务不在同一台服务器,需要单独配置)
@Value("${jarvis.server.proxy.port:1070}")
private int proxyPort; // 代理端口
/**
* 调用 GPT API 并返回第一次回复的文本内容
@@ -59,7 +64,7 @@ public class GPTClientUtil {
String jsonBody = objectMapper.writeValueAsString(requestBody);
// 3. 使用 Hutool HTTP 发送请求,设置代理
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(PROXY_HOST, PROXY_PORT));
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
HttpRequest request = HttpRequest.of(GPT_API_URL)
.method(Method.POST)
.header("Content-Type", "application/json")