1
This commit is contained in:
@@ -45,9 +45,9 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
public List<String> execute(String command) {
|
||||
// 存储接收的消息到Redis队列
|
||||
storeMessageToRedis("instruction:request", command);
|
||||
|
||||
|
||||
List<String> 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<String> 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<String> 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<String, String> 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<String> phoneWithTF = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user