Commit 0f9be23a sunke

条码规则有字段配置,但未解析到值的条码解析失败

1 个父辈 09c282a7
...@@ -599,13 +599,18 @@ public class BarcodeRule { ...@@ -599,13 +599,18 @@ public class BarcodeRule {
if(batch_item.hasThisField()){ if(batch_item.hasThisField()){
String batch = batch_item.getStrValue(codeArr); String batch = batch_item.getStrValue(codeArr);
b.setBatch(batch); b.setBatch(batch);
if(Strings.isNullOrEmpty(batch)){
log.info("BATCH解析失败");
codeBean.setError("smfcore.error.barcode.noField",new String[]{"BATCH"}, "BATCH解析失败");
return codeBean;
}
} }
int quantity = 1; int quantity = 1;
if(quantity_item.hasThisField()){ if(quantity_item.hasThisField()){
quantity = quantity_item.getIntValue(codeArr); quantity = quantity_item.getIntValue(codeArr);
if(quantity == -1){ if(quantity == -1){
log.info("条码解析失败,未找到QTY 字段"); log.info("QTY解析失败");
codeBean.setError("smfcore.error.barcode.noField",new String[]{"QTY"},"条码解析失败,未找到{0}字段"); codeBean.setError("smfcore.error.barcode.noField",new String[]{"QTY"},"QTY解析失败");
return codeBean; return codeBean;
} }
} }
...@@ -613,7 +618,7 @@ public class BarcodeRule { ...@@ -613,7 +618,7 @@ public class BarcodeRule {
Date produceDate= produceDate_item.getDateValue(codeArr); Date produceDate= produceDate_item.getDateValue(codeArr);
if(produceDate_item.hasThisField() && produceDate == null){ if(produceDate_item.hasThisField() && produceDate == null){
log.info("条码解析失败,PRODATE字段不合规则"); log.info("条码解析失败,PRODATE字段不合规则");
codeBean.setError("smfcore.error.barcode.noField",new String[]{"PRODATE"},"条码解析失败,未找到{0}字段"); codeBean.setError("smfcore.error.barcode.noField",new String[]{"PRODATE"},"PRODATE字段不合规则");
return codeBean; return codeBean;
} }
Date expireDate= expireDate_item.getDateValue(codeArr); Date expireDate= expireDate_item.getDateValue(codeArr);
...@@ -639,7 +644,15 @@ public class BarcodeRule { ...@@ -639,7 +644,15 @@ public class BarcodeRule {
expireDate = c.getTime(); expireDate = c.getTime();
} }
} }
String supplier = supplier_item.getStrValue(codeArr); if(supplier_item.hasThisField()){
String supplier = supplier_item.getStrValue(codeArr);
b.setProvider(supplier);
if(Strings.isNullOrEmpty(supplier)){
log.info("SP解析失败");
codeBean.setError("smfcore.error.barcode.noField",new String[]{"SP"}, "SP解析失败");
return codeBean;
}
}
String msl = msl_item.getStrValue(codeArr); String msl = msl_item.getStrValue(codeArr);
if(memo_item.hasThisField()){ if(memo_item.hasThisField()){
...@@ -653,7 +666,6 @@ public class BarcodeRule { ...@@ -653,7 +666,6 @@ public class BarcodeRule {
b.setAmount(quantity); b.setAmount(quantity);
b.setProduceDate(produceDate); b.setProduceDate(produceDate);
b.setExpireDate(expireDate); b.setExpireDate(expireDate);
b.setProvider(supplier);
b.setPlateSize(codeBean.getReelWidth()); b.setPlateSize(codeBean.getReelWidth());
b.setHeight(codeBean.getReelHeight()); b.setHeight(codeBean.getReelHeight());
b.setMsl(msl); b.setMsl(msl);
...@@ -782,6 +794,18 @@ public class BarcodeRule { ...@@ -782,6 +794,18 @@ public class BarcodeRule {
codeStr = "[)>@06@12S0002@PA2C4000670322@1P700042761@31PCGA4F2X7R2A103KT5Y2A@12V700042761@10VJPN-AKITA@2P1@20P25gsm@6D20210826@14D20220314@30PN@ZN@K0@16K0@V000000000@3SS100000000068@Q1KGM000@20T1@1T1@2T@1Z1@@"; codeStr = "[)>@06@12S0002@PA2C4000670322@1P700042761@31PCGA4F2X7R2A103KT5Y2A@12V700042761@10VJPN-AKITA@2P1@20P25gsm@6D20210826@14D20220314@30PN@ZN@K0@16K0@V000000000@3SS100000000068@Q1KGM000@20T1@1T1@2T@1Z1@@";
rule = "1@2@3@PPN@5@6@7@8@9@10@6DPRODATEyyyyMMdd@14DEXPDATEyyyyMMdd@13@14@15@16@VSP@3SRI@QQTYKGM000@20@1TBATCH@22@23@24@25"; rule = "1@2@3@PPN@5@6@7@8@9@10@6DPRODATEyyyyMMdd@14DEXPDATEyyyyMMdd@13@14@15@16@VSP@3SRI@QQTYKGM000@20@1TBATCH@22@23@24@25";
//菲律宾料仓Reel ID : B11111Y934
//
//Part Number : GDM0300013451T
//
//Lot Number: PC7N22AF1
//
//Vendor: MURATA
//
//Quantity: 10000
codeStr = "B11111Y9341PGDM0300013451T1TPC7N22AF11VMURATA1DNA1Q10000";
//codeStr = "B11111Y9341PGDM03000";
rule = "RI[-1:10:-1]PN[12:-14:-1]BATCH[28:9:-1]SP[39:6:-1]QTY[-1:-5:-1]";
BarcodeRule br = BarcodeRule.newRule(rule); BarcodeRule br = BarcodeRule.newRule(rule);
Barcode b = br.toCodeBean(codeStr).getBarcode(); Barcode b = br.toCodeBean(codeStr).getBarcode();
if(b != null){ if(b != null){
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!