Commit de4a8ab7 LN

Merge remote-tracking branch 'origin/master'

2 个父辈 cb7b73c3 bbade6e5
...@@ -46,6 +46,11 @@ import java.util.Date; ...@@ -46,6 +46,11 @@ import java.util.Date;
* 例五: QTY[1:0:-1]去除前面1位后,剩余的作为数量 * 例五: QTY[1:0:-1]去除前面1位后,剩余的作为数量
* 例六: QTY[0:5:3]去除前面0位和后面3位,剩余的5位作为数量,也就是说只能为8位 * 例六: QTY[0:5:3]去除前面0位和后面3位,剩余的5位作为数量,也就是说只能为8位
* *
*
* PN[-1_A:0_B:13_C]RI[-1:0:-1]
*
* PN必须是以A开头,包含B,且以C结尾,去掉后面13位后的值就是PN
*
* 示例: * 示例:
* 规则为: [RI]_PN_PRODATEyyMMdd_QTY[0:5:4] * 规则为: [RI]_PN_PRODATEyyMMdd_QTY[0:5:4]
* 条码: 4500065747_CS000069_180101_030000041 * 条码: 4500065747_CS000069_180101_030000041
...@@ -239,20 +244,42 @@ public class BarcodeRule { ...@@ -239,20 +244,42 @@ public class BarcodeRule {
//前缀(-1时表示没有前缀)如果要验证总长度,可设置为0 //前缀(-1时表示没有前缀)如果要验证总长度,可设置为0
private int prefix = -1; private int prefix = -1;
/**
* 以某些字符串开头
*/
private String startWith = "";
private int length = 0; private int length = 0;
/**
* 包含某此字符串
*/
private String contains = "";
//后缀(-1时表示没有前缀)如果要验证总长度,可设置为0 //后缀(-1时表示没有前缀)如果要验证总长度,可设置为0
private int suffix = -1; private int suffix = -1;
/**
* 以某此字符串结尾
*/
private String endWith = "";
//日期格式 //日期格式
private String formatStr = ""; private String formatStr = "";
@Override @Override
public String toString() { public String toString() {
return "{" + return "RuleItem{" +
"name='" + name + '\'' + "contains='" + contains + '\'' +
", name='" + name + '\'' +
", index=" + index + ", index=" + index +
", prefix='" + prefix + '\'' + ", prefix=" + prefix +
", length='" + length + '\'' + ", startWith='" + startWith + '\'' +
", suffix='" + suffix + '\'' + ", length=" + length +
", suffix=" + suffix +
", endWith='" + endWith + '\'' +
", formatStr='" + formatStr + '\'' +
'}'; '}';
} }
...@@ -271,11 +298,25 @@ public class BarcodeRule { ...@@ -271,11 +298,25 @@ public class BarcodeRule {
int endIndex = ruleValue.indexOf("]",nameIndex); int endIndex = ruleValue.indexOf("]",nameIndex);
if(endIndex > startIndex){ if(endIndex > startIndex){
index = ruleIndex; index = ruleIndex;
String limitStr = ruleValue.substring(startIndex+1,endIndex); String limitStr = ruleValue.substring(startIndex+1,endIndex);
String[] limitInfo = limitStr.split(":"); String[] limitInfo = limitStr.split(":");
prefix = Integer.valueOf(limitInfo[0]); String[] first = limitInfo[0].split("_",2);
length = Integer.valueOf(limitInfo[1]); prefix = Integer.valueOf(first[0]);
suffix = Integer.valueOf(limitInfo[2]); if(first.length == 2){
startWith = first[1];
}
String[] middle = limitInfo[1].split("_",2);
length = Integer.valueOf(middle[0]);
if(middle.length == 2){
contains = middle[1];
}
String[] end = limitInfo[2].split("_",2);
suffix = Integer.valueOf(end[0]);
if(end.length == 2){
endWith = end[1];
}
if(isDateField()){ if(isDateField()){
//取日期格式 //取日期格式
formatStr = ruleValue.substring(nameIndex+name.length(),startIndex); formatStr = ruleValue.substring(nameIndex+name.length(),startIndex);
...@@ -316,6 +357,28 @@ public class BarcodeRule { ...@@ -316,6 +357,28 @@ public class BarcodeRule {
if(codeValue.length() < prefix + suffix){ if(codeValue.length() < prefix + suffix){
return null; return null;
} }
if(!Strings.isNullOrEmpty(startWith)){
//不是以startWith开头
if(!codeValue.startsWith(startWith)){
return null;
}
}
if(!Strings.isNullOrEmpty(contains)){
//不是以endWith结尾
if(!codeValue.contains(contains)){
return null;
}
}
if(!Strings.isNullOrEmpty(endWith)){
//不包含contains
if(!codeValue.endsWith(endWith)){
return null;
}
}
//如果有前缀和后缀 //如果有前缀和后缀
if(prefix > 0){ if(prefix > 0){
codeValue = codeValue.substring(prefix); codeValue = codeValue.substring(prefix);
...@@ -339,14 +402,6 @@ public class BarcodeRule { ...@@ -339,14 +402,6 @@ public class BarcodeRule {
}else if(length < 0){ }else if(length < 0){
return codeValue.substring(codeValue.length()+length, codeValue.length()); return codeValue.substring(codeValue.length()+length, codeValue.length());
} }
//是否是日期
// if(!isDateField()){
// if(codeValue.length() < suffix){
// return null;
// }
// codeValue = codeValue.substring(0,codeValue.length() - suffix);
// }
return codeValue; return codeValue;
} }
...@@ -635,6 +690,16 @@ public class BarcodeRule { ...@@ -635,6 +690,16 @@ public class BarcodeRule {
codeStr = "=7x8=140032005 18B030918B 200.000 614A 0001045024 0001 20200414-141329"; codeStr = "=7x8=140032005 18B030918B 200.000 614A 0001045024 0001 20200414-141329";
rule = "PN BATCH QTY[-1:0:1] RI "; rule = "PN BATCH QTY[-1:0:1] RI ";
codeStr = "[)>@06@12S0002@P791.704-06@1PGCJ21BR71H105KA01L@31P791.704-06@12V100@10VJPN-IA@2P@20P@6D20210727@14D20220727@30PY@Z1@K0@16K0@V48200085@3SSIA1715LS0N1S@Q3000NAR000@20T1@1TIA1715LS0@2T@1Z@@";
rule = "1@2@3@PN[1:0:-1]@5@6@7@8@9@10@11@12@13@14@15@16@RI[1:0:-1]@18@QTY[1:4:-1]@20@21@22@23@@";
codeStr = "792.664-0001000aq0fK792.664-00";
rule = "PN[-1:10:-1]QTY[10:5:-1]RI[15:5:-1]";
codeStr = "327203324369301963";
rule = "PN[-1_32:0:-1_3]RI[-1:0:-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){
......
...@@ -193,8 +193,9 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen ...@@ -193,8 +193,9 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen
} }
} }
String respMsg = "unloadMaterialResp;"+ eventId+";" + resultCode+";"+resultMsg; String respMsg = "unloadMaterialResp;"+ eventId+";" + resultCode+";"+resultMsg;
log.info(respMsg); // log.info(respMsg);
session.write(respMsg); // session.write("\02" + respMsg);
HellaTcpClient.sendMsg(respMsg,session);
}else if(respCommand.isOrderMaterialExtCmd()){ }else if(respCommand.isOrderMaterialExtCmd()){
handleOrderMaterialExtCmd(session,resposArr); handleOrderMaterialExtCmd(session,resposArr);
}else if(respCommand.isGetInventoryCmd()){ }else if(respCommand.isGetInventoryCmd()){
...@@ -237,8 +238,9 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen ...@@ -237,8 +238,9 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen
} }
String respMsg = "getInventoryResp;"+eventId+";"+resultCode+";"+resultMsg+";"+dataStr; String respMsg = "getInventoryResp;"+eventId+";"+resultCode+";"+resultMsg+";"+dataStr;
log.info(respMsg); // log.info(respMsg);
session.write(respMsg); //session.write("\02" + respMsg);
HellaTcpClient.sendMsg(respMsg,session);
} }
} }
...@@ -438,8 +440,10 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen ...@@ -438,8 +440,10 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen
//orderMaterialExtResp;0;-1;Some material not on the shelf;1408;1;325.618-01;1;;791.704-06NOT_FOUND;0 //orderMaterialExtResp;0;-1;Some material not on the shelf;1408;1;325.618-01;1;;791.704-06NOT_FOUND;0
//<STX>orderMaterialExtResp;eventId;returnCode;messageText;workorderNumber;currentWorkorderflag;reflowgroupNumber;numberofPartnumbers;partNumber1;containerNumber;quantity;…;partNumberN;containerNumberN;quantityN<CR><LF> //<STX>orderMaterialExtResp;eventId;returnCode;messageText;workorderNumber;currentWorkorderflag;reflowgroupNumber;numberofPartnumbers;partNumber1;containerNumber;quantity;…;partNumberN;containerNumberN;quantityN<CR><LF>
String respMsg = "orderMaterialExtResp;"+ eventId+";" + resultCode+";"+resultMsg+";"+workorderNumber+";"+currentWorkorderflag+";"+reflowgroupNumber+";"+numberofPartnumbers +";" +resultDataStr; String respMsg = "orderMaterialExtResp;"+ eventId+";" + resultCode+";"+resultMsg+";"+workorderNumber+";"+currentWorkorderflag+";"+reflowgroupNumber+";"+numberofPartnumbers +";" +resultDataStr;
log.info("工单结果:" + respMsg); // log.info("工单结果:" + respMsg);
session.write("\02"+respMsg); // session.write("\02"+respMsg);
HellaTcpClient.sendMsg(respMsg,session);
} }
} }
......
...@@ -169,4 +169,9 @@ public class HellaTcpClient { ...@@ -169,4 +169,9 @@ public class HellaTcpClient {
} }
} }
public static void sendMsg(String msg,IoSession session){
log.info("发送反馈消息:" + msg);
session.write("\02" + msg);
}
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!