重构评论
This commit is contained in:
@@ -8,6 +8,7 @@ import cn.van.business.model.pl.Comment;
|
||||
import cn.van.business.repository.CommentRepository;
|
||||
import cn.van.business.repository.OrderRowRepository;
|
||||
import cn.van.business.util.ds.DeepSeekClientUtil;
|
||||
import cn.van.business.util.ds.GPTClientUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
@@ -115,6 +116,7 @@ public class JDUtil {
|
||||
|
||||
private final OrderUtil orderUtil;
|
||||
private final DeepSeekClientUtil deepSeekClientUtil;
|
||||
private final GPTClientUtil gptClientUtil;
|
||||
// 添加ObjectMapper来序列化和反序列化UserInteractionState
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
private final ConcurrentHashMap<String, UserInteractionState> userInteractionStates = new ConcurrentHashMap<>();
|
||||
@@ -122,7 +124,7 @@ public class JDUtil {
|
||||
|
||||
// 构造函数中注入StringRedisTemplate
|
||||
@Autowired
|
||||
public JDUtil(StringRedisTemplate redisTemplate, OrderRowRepository orderRowRepository, WXUtil wxUtil, OrderUtil orderUtil, DeepSeekClientUtil deepSeekClientUtil, CommentRepository commentRepository) {
|
||||
public JDUtil(StringRedisTemplate redisTemplate, OrderRowRepository orderRowRepository, WXUtil wxUtil, OrderUtil orderUtil, DeepSeekClientUtil deepSeekClientUtil, CommentRepository commentRepository, GPTClientUtil gptClientUtil) {
|
||||
|
||||
this.redisTemplate = redisTemplate;
|
||||
this.orderRowRepository = orderRowRepository;
|
||||
@@ -130,6 +132,7 @@ public class JDUtil {
|
||||
this.orderUtil = orderUtil;
|
||||
this.deepSeekClientUtil = deepSeekClientUtil;
|
||||
this.commentRepository = commentRepository;
|
||||
this.gptClientUtil = gptClientUtil;
|
||||
}
|
||||
|
||||
private List<OrderRow> filterOrdersByDate(List<OrderRow> orderRows, int daysBack) {
|
||||
@@ -1767,15 +1770,18 @@ public class JDUtil {
|
||||
}
|
||||
// 调用 DeepSeek 生成新的评论内容
|
||||
String deepSeekPrompt = COMMENT_TEMPLATES_DS + commentToUse.getCommentText();
|
||||
String deepSeekResponse = "";
|
||||
//String deepSeekResponse = "";
|
||||
String gptResponse = "";
|
||||
try {
|
||||
deepSeekResponse = deepSeekClientUtil.getDeepSeekResponse(deepSeekPrompt);
|
||||
//deepSeekResponse = deepSeekClientUtil.getDeepSeekResponse(deepSeekPrompt);
|
||||
gptResponse = gptClientUtil.getGPTResponse(deepSeekPrompt);
|
||||
} catch (IOException e) {
|
||||
logger.error("生成评论异常 - 用户: {}", fromWxid, e);
|
||||
wxUtil.sendTextMessage(fromWxid, "DS评论生成失败", 1, fromWxid, false);
|
||||
wxUtil.sendTextMessage(fromWxid, "AI 评论生成失败", 1, fromWxid, false);
|
||||
}
|
||||
// 发送生成的评论文本
|
||||
wxUtil.sendTextMessage(fromWxid, "DS回复:\n" + deepSeekResponse, 1, fromWxid, true);
|
||||
//wxUtil.sendTextMessage(fromWxid, "DS回复:\n" + deepSeekResponse, 1, fromWxid, true);
|
||||
wxUtil.sendTextMessage(fromWxid, "GPT回复:\n" + gptResponse, 1, fromWxid, true);
|
||||
|
||||
// 更新评论状态为已使用
|
||||
commentToUse.setIsUse(1);
|
||||
|
||||
Reference in New Issue
Block a user