修改
This commit is contained in:
@@ -42,10 +42,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 作业统计 Service 实现
|
||||
@@ -88,6 +87,26 @@ public class ToWmsServiceImpl implements IToWmsService {
|
||||
@Autowired
|
||||
private IBasStockService stockService;
|
||||
|
||||
private static final Map<String, Pattern> PATTERNS = createPatterns();
|
||||
private static Map<String, Pattern> createPatterns() {
|
||||
Map<String, Pattern> map = new LinkedHashMap<>();
|
||||
map.put("MODEL", Pattern.compile("MODEL:([^\\s]+)", Pattern.CASE_INSENSITIVE));
|
||||
map.put("COLOR", Pattern.compile("COLOR:([^\\s]+)", Pattern.CASE_INSENSITIVE));
|
||||
map.put("SERIAL", Pattern.compile("SERIAL:([^\\s]+)", Pattern.CASE_INSENSITIVE));
|
||||
map.put("V", Pattern.compile("V:([^\\s]+)", Pattern.CASE_INSENSITIVE));
|
||||
map.put("Hz", Pattern.compile("Hz:([^\\s]+)", Pattern.CASE_INSENSITIVE));
|
||||
map.put("PH", Pattern.compile("PH:([^\\s]+)", Pattern.CASE_INSENSITIVE));
|
||||
map.put("NW", Pattern.compile("N\\.W\\.:([^\\s]+)", Pattern.CASE_INSENSITIVE));
|
||||
map.put("GW", Pattern.compile("G\\.W\\.:([^\\s]+)", Pattern.CASE_INSENSITIVE));
|
||||
map.put("ITEM_CODE", Pattern.compile("ITEM_CODE:([^\\s]+)", Pattern.CASE_INSENSITIVE));
|
||||
map.put("@", Pattern.compile("@:([^\\s]+)", Pattern.CASE_INSENSITIVE));
|
||||
return map;
|
||||
}
|
||||
private static String findFirst(Pattern pattern, String input) {
|
||||
if (pattern == null || input == null) return null;
|
||||
Matcher m = pattern.matcher(input);
|
||||
return m.find() ? m.group(1) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -103,17 +122,19 @@ public class ToWmsServiceImpl implements IToWmsService {
|
||||
|
||||
//解析扫码内容
|
||||
String trayCode = requestEnter.getTrayCode();
|
||||
String[] split = trayCode.split(" ");
|
||||
String model = split[0].substring(6);
|
||||
String color = split[1].substring(6);
|
||||
String serial = split[2].substring(7);
|
||||
String v = split[3].substring(2);
|
||||
String hz = split[4].substring(3);
|
||||
String ph = split[5].substring(3);
|
||||
String nw = split[6].substring(5);
|
||||
String gw = split[7].substring(5);
|
||||
String productId = split[8].substring(10);
|
||||
String bm = split[9].substring(2, split[9].length() - 1);
|
||||
String[] split = trayCode.split("\\s+");
|
||||
String model = findFirst(PATTERNS.get("MODEL"), trayCode);
|
||||
model=model.replace("<EFBFBD>"," ");
|
||||
String color = findFirst(PATTERNS.get("COLOR"), trayCode);
|
||||
String serial = findFirst(PATTERNS.get("SERIAL"), trayCode);
|
||||
String v = findFirst(PATTERNS.get("V"), trayCode);
|
||||
String hz = findFirst(PATTERNS.get("Hz"), trayCode);
|
||||
String ph = findFirst(PATTERNS.get("PH"), trayCode);
|
||||
String nw = findFirst(PATTERNS.get("NW"), trayCode);
|
||||
String gw = findFirst(PATTERNS.get("GW"), trayCode);;
|
||||
String productId = findFirst(PATTERNS.get("ITEM_CODE"), trayCode);
|
||||
String bm = findFirst(PATTERNS.get("@"), trayCode);
|
||||
bm=bm.substring(0,bm.length()-1);
|
||||
String[] decode = ProcodeUtils.decode(bm);
|
||||
String erpBill = decode[0];
|
||||
String xh = decode[1];
|
||||
@@ -126,7 +147,6 @@ public class ToWmsServiceImpl implements IToWmsService {
|
||||
return new AjaxResult(1, "二维码内容错误!");
|
||||
}
|
||||
}
|
||||
|
||||
List<MydoJob> inList = mydoJobService.getInJobBySerial(serial);
|
||||
List<BasStock> stockList = stockService.getStockBySerial(serial);
|
||||
if(!CollUtil.isEmpty(inList) || !CollUtil.isEmpty(stockList)) {
|
||||
|
||||
Reference in New Issue
Block a user