From 860ccb17f2857c51f29d80d72f52ee473019c7a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=92?= Date: Fri, 3 Oct 2025 17:53:52 +0800 Subject: [PATCH] 1 --- .../service/impl/InstructionServiceImpl.java | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/InstructionServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/InstructionServiceImpl.java index 05fc697..e43a92a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/InstructionServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/InstructionServiceImpl.java @@ -45,9 +45,9 @@ public class InstructionServiceImpl implements IInstructionService { public List execute(String command) { // 存储接收的消息到Redis队列 storeMessageToRedis("instruction:request", command); - + List result; - + if (command == null || command.trim().isEmpty()) { result = Collections.singletonList("请输入指令"); } else { @@ -72,14 +72,14 @@ public class InstructionServiceImpl implements IInstructionService { result = Collections.singletonList(helpText()); } } - + // 存储返回的消息到Redis队列 String response = result != null ? String.join("\n", result) : ""; storeMessageToRedis("instruction:response", response); - + return result; } - + /** * 将消息存储到Redis队列,最多保留100条 * @param key Redis键 @@ -101,13 +101,13 @@ public class InstructionServiceImpl implements IInstructionService { System.err.println("存储消息到Redis失败: " + e.getMessage()); } } - + @Override public List getHistory(String type, Integer limit) { if (stringRedisTemplate == null) { return Collections.emptyList(); } - + try { // 确定Redis键 String key; @@ -118,13 +118,13 @@ public class InstructionServiceImpl implements IInstructionService { } else { return Collections.emptyList(); } - + // 确定获取数量,默认100条 int count = (limit != null && limit > 0) ? Math.min(limit, 100) : 100; - + // 从Redis获取历史消息(索引0到count-1) List messages = stringRedisTemplate.opsForList().range(key, 0, count - 1); - + return messages != null ? messages : Collections.emptyList(); } catch (Exception e) { System.err.println("获取历史消息失败: " + e.getMessage()); @@ -279,21 +279,14 @@ public class InstructionServiceImpl implements IInstructionService { private static final HashMap productWithJF = new HashMap<>(); static { - /** - * 130 - * https://u.jd.com/S1BkTIS - * 130B - * https://u.jd.com/S1BkvGO - * 150 - * https://u.jd.com/SaBkAXo - * 180 - * https://u.jd.com/SDBkTJg - * */ - productWithJF.put("ZQD130F-EB130", "https://u.jd.com/S1BkTIS"); - productWithJF.put("ZQD130F-EB130B", "https://u.jd.com/S1BkvGO"); - productWithJF.put("ZQD150F-EB150", "https://u.jd.com/SaBkAXo"); - productWithJF.put("ZQD180F-EB200", "https://u.jd.com/SDBkTJg"); - productWithJF.put("CXW-298-IQ92DPRO", "https://u.jd.com/SrWlqkb"); + + productWithJF.put("ZQD110F-EB031", "https://u.jd.com/0gGPOZX"); + productWithJF.put("ZQD130F-EB130", "https://u.jd.com/0OGTvHh"); + productWithJF.put("ZQD130F-EB130B", "https://u.jd.com/0GGWEOR"); + productWithJF.put("ZQD150F-EB150", "https://u.jd.com/0O8BYjb"); + productWithJF.put("ZQD180F-EB200", "https://u.jd.com/0gGSoiN"); + productWithJF.put("ZQD115F-12LCS", "https://u.jd.com/0DGSFcH"); + productWithJF.put("CXW-298-IQ92DPRO", "https://u.jd.com/0OG04su"); } private static final List phoneWithTF = new ArrayList<>();