1
This commit is contained in:
@@ -426,47 +426,73 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
phoneWithTF.add("17530176250");
|
||||
}
|
||||
|
||||
private String handleTF(String input) {
|
||||
String body = input.replaceFirst("^TF\\s*", "");
|
||||
body = body.replaceAll("[啊阿]", "");
|
||||
String[] lines = body.split("\\r?\\n+");
|
||||
List<String> outputs = new ArrayList<>();
|
||||
for (String line : lines) {
|
||||
if (line == null) continue;
|
||||
line = line.trim();
|
||||
if (line.isEmpty()) continue;
|
||||
String[] parts = line.split("\t"); // 使用制表符分割每一行
|
||||
if (parts.length >= 3) {
|
||||
String modelNumber = parts[0].replace("\\n", ""); // 型号
|
||||
String quantityStr = parts[1]; // 数量
|
||||
StringBuilder address = new StringBuilder();
|
||||
// 使用正则表达式提取中文字符(常用于姓名开头)
|
||||
Pattern pattern = Pattern.compile("[\\u4E00-\\u9FA5]+");
|
||||
Matcher matcher = pattern.matcher(parts[2]);
|
||||
if (matcher.find()) {
|
||||
address = new StringBuilder(matcher.group());
|
||||
private String handleTF(String input) {
|
||||
String body = input.replaceFirst("^TF\\s*", "");
|
||||
body = body.replaceAll("[啊阿]", "");
|
||||
String[] lines = body.split("\\r?\\n+");
|
||||
List<String> outputs = new ArrayList<>();
|
||||
for (String line : lines) {
|
||||
if (line == null) continue;
|
||||
line = line.trim();
|
||||
if (line.isEmpty()) continue;
|
||||
String[] parts = line.split("\t"); // 使用制表符分割每一行
|
||||
/**
|
||||
* 原来的
|
||||
* ZQD180F-EB200 1 石**[7796] 13243039070 上海市 上海市 普陀区 水泉南路58弄3-12-502[阿15783543077转7796]
|
||||
* 改成
|
||||
* 10.10 腾锋 JY202510093195 ZQD180F-EB200 1 石**[7796] 13243039070 上海市 上海市 普陀区 水泉南路58弄3-12-502[阿15783543077转7796] 1650 有货 2
|
||||
* 型号,地址,电话的处理逻辑不变,将10.10 腾锋 JY202510093195 设置成分销标识这个字段,比如之前是H-TF,现在改成H-TF(10.10 腾锋 JY202510093195)
|
||||
* */
|
||||
if (parts.length >= 3) {
|
||||
// 新增部分:处理分销标记
|
||||
String fenxiaoInfo = "";
|
||||
StringBuilder fenxiaoBuilder = new StringBuilder("H-TF");
|
||||
StringBuilder extraInfo = new StringBuilder();
|
||||
for (int i = 0; i < Math.min(3, parts.length); i++) {
|
||||
if (!parts[i].isEmpty()) {
|
||||
if (extraInfo.length() > 0) {
|
||||
extraInfo.append("\t");
|
||||
}
|
||||
extraInfo.append(parts[i]);
|
||||
}
|
||||
String phone = parts[3];
|
||||
//从phoneWithTF随机拿一个出来
|
||||
if ("13243039070".equals(phone)) {
|
||||
phone = phoneWithTF.get(new Random().nextInt(phoneWithTF.size()));
|
||||
}
|
||||
address.append(phone);
|
||||
System.out.println(address);
|
||||
for (int i = 4; i < parts.length; i++) {
|
||||
address.append(parts[i]);
|
||||
}
|
||||
String jf = productJdConfigService.getJdUrlByProductModel(modelNumber);
|
||||
|
||||
StringBuilder order = new StringBuilder();
|
||||
order.append("生").append("\n").append("H-TF").append("\n").append(modelNumber).append("\n").append(jf).append("\n").append(quantityStr).append("\n").append(address);
|
||||
outputs.add(generateOrderText(order.toString()));
|
||||
} else {
|
||||
outputs.add("TF 指令格式:TF\t型号\t数量\t地址(可含其它字段) ;也支持多行,每行一条数据");
|
||||
}
|
||||
if (extraInfo.length() > 0) {
|
||||
fenxiaoBuilder.append("(").append(extraInfo).append(")");
|
||||
}
|
||||
fenxiaoInfo = fenxiaoBuilder.toString();
|
||||
|
||||
String modelNumber = parts[Math.max(0, parts.length - 5)].replace("\\n", ""); // 型号
|
||||
String quantityStr = parts[Math.max(0, parts.length - 4)]; // 数量
|
||||
StringBuilder address = new StringBuilder();
|
||||
// 使用正则表达式提取中文字符(常用于姓名开头)
|
||||
Pattern pattern = Pattern.compile("[\\u4E00-\\u9FA5]+");
|
||||
String namePart = parts[Math.max(0, parts.length - 3)];
|
||||
Matcher matcher = pattern.matcher(namePart);
|
||||
if (matcher.find()) {
|
||||
address = new StringBuilder(matcher.group());
|
||||
}
|
||||
String phone = parts[Math.max(0, parts.length - 2)];
|
||||
//从phoneWithTF随机拿一个出来
|
||||
if ("13243039070".equals(phone)) {
|
||||
phone = phoneWithTF.get(new Random().nextInt(phoneWithTF.size()));
|
||||
}
|
||||
address.append(phone);
|
||||
System.out.println(address);
|
||||
for (int i = Math.max(0, parts.length - 1); i < parts.length; i++) {
|
||||
address.append(parts[i]);
|
||||
}
|
||||
String jf = productJdConfigService.getJdUrlByProductModel(modelNumber);
|
||||
|
||||
StringBuilder order = new StringBuilder();
|
||||
order.append("生").append("\n").append(fenxiaoInfo).append("\n").append(modelNumber).append("\n").append(jf).append("\n").append(quantityStr).append("\n").append(address);
|
||||
outputs.add(generateOrderText(order.toString()));
|
||||
} else {
|
||||
outputs.add("TF 指令格式:TF\t分销信息\t分销信息\t分销信息\t型号\t数量\t地址(可含其它字段) ;也支持多行,每行一条数据");
|
||||
}
|
||||
return String.join("\n\n", outputs);
|
||||
}
|
||||
return String.join("\n\n", outputs);
|
||||
}
|
||||
|
||||
|
||||
private String handleH(String input) {
|
||||
String[] lines = input.replaceFirst("^H", "").split("\n");
|
||||
|
||||
Reference in New Issue
Block a user