1
This commit is contained in:
@@ -21,14 +21,15 @@ public class InstructionController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行文本指令
|
||||
* 执行文本指令(控制台入口,需要权限)
|
||||
* body: { command: "京今日统计", forceGenerate: false }
|
||||
*/
|
||||
@PostMapping("/execute")
|
||||
public AjaxResult execute(@RequestBody Map<String, Object> body) {
|
||||
String cmd = body != null ? (body.get("command") != null ? String.valueOf(body.get("command")) : null) : null;
|
||||
boolean forceGenerate = body != null && body.get("forceGenerate") != null && Boolean.parseBoolean(String.valueOf(body.get("forceGenerate")));
|
||||
java.util.List<String> result = instructionService.execute(cmd, forceGenerate);
|
||||
// 控制台入口,传递 isFromConsole=true,跳过订单查询校验
|
||||
java.util.List<String> result = instructionService.execute(cmd, forceGenerate, true);
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,15 @@ public interface IInstructionService {
|
||||
*/
|
||||
java.util.List<String> execute(String command, boolean forceGenerate);
|
||||
|
||||
/**
|
||||
* 执行文本指令,返回结果文本(支持强制生成参数和控制台入口标识)
|
||||
* @param command 指令内容
|
||||
* @param forceGenerate 是否强制生成表单(跳过地址重复检查)
|
||||
* @param isFromConsole 是否来自控制台入口(控制台入口跳过订单查询校验)
|
||||
* @return 执行结果文本列表(可能为单条或多条)
|
||||
*/
|
||||
java.util.List<String> execute(String command, boolean forceGenerate, boolean isFromConsole);
|
||||
|
||||
/**
|
||||
* 获取历史消息记录
|
||||
* @param type 消息类型:request(请求) 或 response(响应)
|
||||
|
||||
@@ -63,6 +63,11 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
|
||||
@Override
|
||||
public List<String> execute(String command, boolean forceGenerate) {
|
||||
return execute(command, forceGenerate, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> execute(String command, boolean forceGenerate, boolean isFromConsole) {
|
||||
// 存储接收的消息到Redis队列
|
||||
storeMessageToRedis("instruction:request", command);
|
||||
|
||||
@@ -103,7 +108,7 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
} else if (input.equals("拼多多") || input.startsWith("拼多多\n") || input.startsWith("拼多多\r\n") || isPDDFormat(input)) {
|
||||
result = Collections.singletonList(handlePDD(input, forceGenerate));
|
||||
} else if (input.startsWith("录单") || input.startsWith("慢单") || input.startsWith("慢搜") || input.startsWith("慢查") || input.startsWith("单")) {
|
||||
result = handleRecordLikeMulti(input, forceGenerate);
|
||||
result = handleRecordLikeMulti(input, forceGenerate, isFromConsole);
|
||||
} else if (input.startsWith("转链") || input.startsWith("文案") || input.startsWith("转")) {
|
||||
result = Collections.singletonList(handleTransferLike(input));
|
||||
} else {
|
||||
@@ -221,10 +226,14 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
}
|
||||
|
||||
private List<String> handleRecordLikeMulti(String input) {
|
||||
return handleRecordLikeMulti(input, false);
|
||||
return handleRecordLikeMulti(input, false, false);
|
||||
}
|
||||
|
||||
private List<String> handleRecordLikeMulti(String input, boolean forceGenerate) {
|
||||
return handleRecordLikeMulti(input, forceGenerate, false);
|
||||
}
|
||||
|
||||
private List<String> handleRecordLikeMulti(String input, boolean forceGenerate, boolean isFromConsole) {
|
||||
// 仅实现“慢搜/慢查 关键词”与“录单/慢单 日期范围”的只读输出,避免侵入写库
|
||||
if (input.startsWith("慢搜") || input.startsWith("慢查")) {
|
||||
String kw = input.replaceFirst("^慢搜|^慢查", "").trim();
|
||||
@@ -622,7 +631,7 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
return outputs.isEmpty() ? Collections.singletonList("无数据") : outputs;
|
||||
}
|
||||
if (input.startsWith("单")) {
|
||||
return Collections.singletonList(handleDanWriteDb(input, forceGenerate));
|
||||
return Collections.singletonList(handleDanWriteDb(input, forceGenerate, isFromConsole));
|
||||
}
|
||||
return Collections.singletonList(helpText());
|
||||
}
|
||||
@@ -1270,10 +1279,14 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
|
||||
// ===== "单 …" 写库 =====
|
||||
private String handleDanWriteDb(String input) {
|
||||
return handleDanWriteDb(input, false);
|
||||
return handleDanWriteDb(input, false, false);
|
||||
}
|
||||
|
||||
private String handleDanWriteDb(String input, boolean forceGenerate) {
|
||||
return handleDanWriteDb(input, forceGenerate, false);
|
||||
}
|
||||
|
||||
private String handleDanWriteDb(String input, boolean forceGenerate, boolean isFromConsole) {
|
||||
// 保存原始输入,用于返回前端时保留完整物流链接
|
||||
String originalInput = input.trim().replace("元", "");
|
||||
// 与 JDUtil.parseOrderFromText 一致的模板字段
|
||||
@@ -1344,8 +1357,8 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
}
|
||||
}
|
||||
|
||||
// 验证1:如果查询不到对应订单,提示用户
|
||||
if (isEmpty(order.getOrderId()) || orderRow == null) {
|
||||
// 验证1:如果查询不到对应订单,提示用户(控制台入口跳过此校验)
|
||||
if (!isFromConsole && (isEmpty(order.getOrderId()) || orderRow == null)) {
|
||||
String warn = "[炸弹] [炸弹] [炸弹] 录单警告!!! \n查询不到对应订单(使用红包 或者 转链),请五分钟后再试,或重新下单";
|
||||
return warn;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user