Commit 1ae0dc57 张少辉

Merge remote-tracking branch 'origin/master'

2 个父辈 d42d9734 078c99f3
......@@ -16,7 +16,7 @@ import java.util.Map;
*
* 条码规则,可用字段有:
* PN为物料编号即 PartNumber
* RI 为唯一码即ReelId,[RI]为所有字符串作为一个唯一码
* RI 为唯一码即ReelId,[RI]为所有字符串作为一个唯一码,[GRI]生成yyyyMMddHHmmssS格式的唯一码
* QTY 为数量
* PRODATE为生产日期xxPRODATEyyyyMMdd
* EXPDATE为过期日期xxxEXPDATEyyyyMMdd
......@@ -143,8 +143,11 @@ public class BarcodeRule {
fieldValue = fieldValue.replace(newRule.partNumber_item.name,"");
}
}
if(!newRule.whole_reelId_item.hasThisField() && !newRule.reelId_item.hasThisField()){
if(newRule.whole_reelId_item.matchRule(fieldValue, i)){
if(!newRule.whole_reelId_item.hasThisField() && !newRule.reelId_item.hasThisField() && !newRule.generate_reelId_item.hasThisField()){
if(newRule.generate_reelId_item.matchRule(fieldValue, i)){
log.info("generate reelId: 为" + newRule.generate_reelId_item.toString());
fieldValue = fieldValue.replace(newRule.generate_reelId_item.name,"");
}else if(newRule.whole_reelId_item.matchRule(fieldValue, i)){
log.info("whole reelId: 为" + newRule.whole_reelId_item.toString());
fieldValue = fieldValue.replace(newRule.whole_reelId_item.name,"");
}else if(newRule.reelId_item.matchRule(fieldValue, i)){
......@@ -212,7 +215,7 @@ public class BarcodeRule {
}
boolean validRule = false;
if(newRule.partNumber_item.hasThisField()){
if(newRule.reelId_item.hasThisField() || newRule.whole_reelId_item.hasThisField()){
if(newRule.reelId_item.hasThisField() || newRule.whole_reelId_item.hasThisField() || newRule.generate_reelId_item.hasThisField()){
validRule = true;
}
}
......@@ -244,6 +247,7 @@ public class BarcodeRule {
private RuleItem partNumber_item = new RuleItem("PN");
private RuleItem reelId_item = new RuleItem("RI");
private RuleItem whole_reelId_item = new RuleItem("[RI]");
private RuleItem generate_reelId_item = new RuleItem("[GRI]");
private RuleItem quantity_item = new RuleItem("QTY");
private RuleItem produceDate_item = new RuleItem("PRODATE");
private RuleItem expireDate_item = new RuleItem("EXPDATE");
......@@ -383,6 +387,10 @@ public class BarcodeRule {
}
if(!Strings.isNullOrEmpty(startWith)){
int startIndex = codeValue.indexOf(startWith);
if(startIndex>=0){
codeValue = codeValue.substring(startIndex);
}
//不是以startWith开头
if(!codeValue.startsWith(startWith)){
return null;
......@@ -397,6 +405,10 @@ public class BarcodeRule {
}
if(!Strings.isNullOrEmpty(endWith)){
int endIndex = codeValue.indexOf(endWith);
if(endIndex>=0){
codeValue = codeValue.substring(0,endIndex+endWith.length());
}
//不是以endWith结尾
if(!codeValue.endsWith(endWith)){
return null;
......@@ -579,7 +591,9 @@ public class BarcodeRule {
Barcode b = new Barcode();
b.setFullCode(codeStr);
String reelId = "";
if(whole_reelId_item.hasThisField()){
if(generate_reelId_item.hasThisField()){
reelId = DateUtil.toDateString(new Date(),"yyyyMMddHHmmssS");
}else if(whole_reelId_item.hasThisField()){
reelId = codeStr;
}else{
reelId = reelId_item.getStrValue(codeArr);
......@@ -861,6 +875,22 @@ public class BarcodeRule {
rule = "1@2@3@xPN@5@6@7@RI@xQTY@10@@";
codeStr = "671200%10000%1MTR";
rule = "PN%QTY%BATCH[RI]";
codeStr = "A11111MDAS1PGDM4600034251T67151T100ZC1VWINBOND1D17361Q5000";
rule = "RI[-1:0:2_1P]PN[2_1P:0:2_1T]BATCH[2_1T:0:2_1V]QTY[2_1Q:0:-1]SP[2_1V:0:2_1D]";
rule = "PN[2_1P:0:2_1T]BATCH[2_1T:0:2_1V]QTY[2_1Q:0:-1]SP[2_1V:0:2_1D][GRI]";
codeStr = "3N1949569-9730 300 12345678901234567890 JUTYUUSYA";
rule = "PN[3_3N1:12_-:-1] QTY 3 4[GRI]";
codeStr = "3N1949568-9430 300 12345678901234567890";
rule = "PN[3_3N1:12_-:-1] QTY 3[GRI]";
codeStr = "3N1239071-0260 300";
rule = "PN[3_3N1:12_-:-1] QTY[GRI]";
codeStr = "3N1949377-1010";
rule = "PN[3_3N1:12_-:-1][GRI]";
BarcodeRule br = BarcodeRule.newRule(rule);
Barcode b = br.toCodeBean(codeStr).getBarcode();
if(b != null){
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!