Commit c0a9630b sunke

条码解析添加生产商物料编号字段mpn

1 个父辈 93d0803f
......@@ -24,6 +24,7 @@ import java.util.Map;
* BATCH 为批次
* MSL 为MSL等级
* MEMO 备注信息
* MPN 生产商物料编号
*
*
*
......@@ -135,9 +136,11 @@ public class BarcodeRule {
for (int i=0; i<tempArr.length; i++) {
String fieldValue = tempArr[i];
fieldValue = resolveField(newRule.mpn_item,fieldValue,i);
if(!newRule.partNumber_item.hasThisField()){
if(newRule.partNumber_item.matchRule(fieldValue, i)){
log.info("partNumber: 为" + newRule.partNumber_item.toString());
fieldValue = fieldValue.replace(newRule.partNumber_item.name,"");
}
}
if(!newRule.whole_reelId_item.hasThisField() && !newRule.reelId_item.hasThisField()){
......@@ -216,6 +219,17 @@ public class BarcodeRule {
return newRule;
}
private static String resolveField(RuleItem ruleItem, String fieldValue, int ruleIndex){
if(!ruleItem.hasThisField()){
if(ruleItem.matchRule(fieldValue, ruleIndex)){
log.info(ruleItem.name + " 为" + ruleItem.toString());
fieldValue = fieldValue.replace(ruleItem.name,"");
}
}
return fieldValue;
}
private String ruleStr;
private String separator;
private int length = 0;
......@@ -234,6 +248,7 @@ public class BarcodeRule {
private RuleItem batch_item = new RuleItem("BATCH");
private RuleItem msl_item = new RuleItem("MSL");
private RuleItem memo_item = new RuleItem("MEMO");
private RuleItem mpn_item = new RuleItem("MPN");
private class RuleItem{
private RuleItem(String ruleName) {
......@@ -476,10 +491,6 @@ public class BarcodeRule {
}
}
public static void toRule(String codeStr){
String[] codeArr = new String[]{codeStr};
}
/**
* 从条码中解析尺寸和条码
......@@ -540,54 +551,6 @@ public class BarcodeRule {
log.info("开始解析条码["+codeStr+"]");
CodeBean codeBean = splitCodeAndSize(codeStr);
// CodeBean codeBean = new CodeBean();
// codeBean.setCodeStr(codeStr);
// //是否带有位置信息
// float locationX = -1f;
// float locationY = -1f;
// int reelWidth = -1;
// int reelHeight = -1;
// //=摄像头编号+条码X坐标x条码Y坐标-料盘尺寸=CODE
// //=1+123.4x100.5-7x12=CODE或者7x12=CODE
// if(codeStr.startsWith("=") && codeStr.contains("x")){
// codeStr = codeStr.substring(1);
// String[] arr = codeStr.split("=", 2);
// String sizeStr = arr[0];
// if(sizeStr.contains("+") && sizeStr.contains("-")){
// String[] locationSizeArr = sizeStr.split("-",2);
// //尺寸信息
// sizeStr = locationSizeArr[1];
//
// String[] locationInfoArr = locationSizeArr[0].split("\\+");
// String cameraIndexStr = locationInfoArr[0];
// //摄像头编号信息
// int cameraIndex = Integer.valueOf(cameraIndexStr);
//
// codeBean.setCameraIndex(cameraIndex);
//
// String locationStr = locationInfoArr[1];
//
// //带有位置信息
// String[] locationArr = locationStr.split("x");
// locationX = Float.valueOf(locationArr[0].trim());
// locationY = Float.valueOf(locationArr[1].trim());
// }
//
// //带有料盘宽高信息
// if(!Strings.isNullOrEmpty(sizeStr)){
// String[] sizeInfoArr = sizeStr.split("x",2);
// reelWidth = Integer.parseInt(sizeInfoArr[0].trim());
// reelHeight = Integer.parseInt(sizeInfoArr[1].trim());
// }
//
// codeBean.setLocationX(locationX);
// codeBean.setLocationY(locationY);
// codeBean.setReelWidth(reelWidth);
// codeBean.setReelHeight(reelHeight);
// codeStr = arr[1];
//
// }
// codeBean.setCodeStr(codeStr);
if(!isValidRule()){
codeBean.setError("smfcore.error.barcode.noRule","解析规则未定义");
return codeBean;
......@@ -629,6 +592,16 @@ public class BarcodeRule {
codeBean.setError("smfcore.error.barcode.noField",new String[]{"PN"}, "条码解析失败,未找到{0}字段");
return codeBean;
}
if(mpn_item.hasThisField()){
String mpn = mpn_item.getStrValue(codeArr);
b.setMpn(mpn);
if(Strings.isNullOrEmpty(mpn)){
log.info("MPN解析失败");
codeBean.setError("smfcore.error.mpn.noField",new String[]{"MPN"}, "MPN解析失败");
return codeBean;
}
}
if(batch_item.hasThisField()){
String batch = batch_item.getStrValue(codeArr);
b.setBatch(batch);
......@@ -865,7 +838,7 @@ public class BarcodeRule {
rule="EXPDATEyyMMdd[12:0:-1]|BATCH[2:0:-1]|QTY[2:0:-1]|RI[2:0:-1]|PN[1:0:-1]|XXX";
codeStr="=1+0x0-400x62=zJFSRW46.11+250205|1TJFSRW46.11|7Q404|1TJFSRW46.11|P530828|1PMT29F2T08ELLEEG7-QD:E";
rule="EXPDATEyyMMdd[12:0:-1]|BATCH[2:0:-1]|QTY[2:0:-1]|RI[2:0:-1]|PN[1:0:-1]|XXX";
rule="EXPDATEyyMMdd[12:0:-1]|BATCH[2:0:-1]|QTY[2:0:-1]|RI[2:0:-1]|PN[1:0:-1]|MPN[-1:0:2]";
// rule="PN[1:0:-1]|BATCH[2:0:-1]|LOT[2:0:-1]|QTY[2_7Q:0:-1]|RI[1:0:-1]|SP[3:0:-1]|PRODATEyyyyMMdd[2:0:-1]|xxx";
BarcodeRule br = BarcodeRule.newRule(rule);
......@@ -880,6 +853,7 @@ public class BarcodeRule {
System.out.println("EXPDATE:"+b.getExpireDate());
System.out.println("Supllier:"+b.getProvider());
System.out.println("Memo:"+b.getMemo());
System.out.println("MPN:"+b.getMpn());
}else{
System.out.println("解析失败");
log.info("解析失败");
......
......@@ -66,6 +66,11 @@ public class Barcode extends BasePo implements Serializable {
* 料件编号
*/
private String partNumber;
/**
* 制造商物料编号
*/
private String mpn;
/**
* 供应商编号
*/
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!