You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
309 lines
8.1 KiB
309 lines
8.1 KiB
//解析扫描信息
|
|
//P2251076NAA;L220325;Q2000;N0205183222000006;SS0000066;V02051832;OPO1072;C15;
|
|
//解析规则
|
|
//P:itemCode 物料号
|
|
//L:lot批次
|
|
//Q:qty 数量
|
|
//N:asn 供应商商发货单 ASN
|
|
//S:packingCode 箱码
|
|
//T:containerCode托盘
|
|
//V:supplierCode 供应商代码
|
|
//O: order订单号
|
|
//C: poLine订单行
|
|
//B:supplierBatch 供应商批次
|
|
|
|
//返回结果
|
|
//sucess true:成功 false:失败
|
|
//scanType barcode:条码 qrcode:二维码
|
|
//isPack true:箱码 false:托码
|
|
export function analyseScanInfo(scanMsg) {
|
|
let scanResult = {
|
|
sucess: false,
|
|
message: "",
|
|
data: {
|
|
isPack: null,
|
|
scanType: null,
|
|
itemCode: null,
|
|
batch: null,
|
|
qty: null,
|
|
asn: null,
|
|
packingNumber: null,
|
|
supplierBatch: null,
|
|
order: null,
|
|
poLine: null,
|
|
code: null,
|
|
}
|
|
};
|
|
if (scanMsg === "") {
|
|
scanResult.message = "扫描到的内容为空";
|
|
} else {
|
|
try {
|
|
console.log('1.扫描到的内容:', scanMsg);
|
|
//条码
|
|
if (scanMsg.indexOf(';') < 0) {
|
|
scanResult.sucess = true;
|
|
scanResult.data.code = scanMsg;
|
|
scanResult.data.scanType = 'barcode'; //条码
|
|
} else {
|
|
let arrayItems = scanMsg.split(';');
|
|
if (arrayItems.length > 0) {
|
|
scanResult.data.scanType = 'qrcode'; //二维码
|
|
scanResult.data["test"] = 'test';
|
|
arrayItems.forEach((item, index) => {
|
|
if (item != "") {
|
|
let type = item.substring(0, 1);
|
|
let value = item.substring(1, item.length);
|
|
if (type != "") {
|
|
scanResult.data.scanType = 'qrcode';
|
|
switch (type) {
|
|
case "P": //物料号
|
|
case "p":
|
|
scanResult.data.itemCode = value;
|
|
break;
|
|
case "L": //批次
|
|
case "l":
|
|
scanResult.data.lot = value;
|
|
break;
|
|
case "Q": //数量
|
|
case "q":
|
|
scanResult.data.qty = value;
|
|
break;
|
|
case "N": //供应商商发货单 ASN
|
|
case "n":
|
|
scanResult.data.asn = value;
|
|
break;
|
|
case "S": //箱码
|
|
case "s":
|
|
scanResult.data.packingNumber = value;
|
|
scanResult.data.isPack = true;
|
|
break;
|
|
case "T": //托盘
|
|
case "t":
|
|
scanResult.data.containerCode = value;
|
|
scanResult.data.isPack = false;
|
|
break;
|
|
case "V": //供应商批次
|
|
case "v":
|
|
scanResult.data.supplierCode = value;
|
|
break;
|
|
case "O": //订单号
|
|
case "o":
|
|
scanResult.data.order = value;
|
|
break;
|
|
case "C": //订单行
|
|
case "c":
|
|
scanResult.data.poLine = value;
|
|
break;
|
|
case "B": //供应商批次
|
|
case "b":
|
|
scanResult.data.supplierBatch = value;
|
|
break;
|
|
// default: //条码
|
|
// scanResult.data.code = item;
|
|
// scanResult.data.scanType = 'barcode';
|
|
// break;
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
scanResult.sucess = true;
|
|
} else { //扫描的是条码,直接返回接收到的内容
|
|
scanResult.sucess = true;
|
|
scanResult.data.code = scanMsg;
|
|
scanResult.data.scanType = 'barcode';
|
|
}
|
|
}
|
|
} catch (ex) {
|
|
scanResult.sucess = false;
|
|
scanResult.message = "解析遇到异常" + ex.message;
|
|
}
|
|
}
|
|
|
|
return scanResult;
|
|
}
|
|
|
|
//解析完工收货标签
|
|
//P2250229RAA;L220408;Q100;N62840610;SB0000107;UEA;DU571LS;FA;E2022-4-8
|
|
//P零件号,L批次,Q数量,N生产计划号,S箱码,U计量单位,D生产线,F班次,E日期,M零件名称(待添加)
|
|
//解析规则
|
|
//P:itemCode 物料号
|
|
//L:lot批次
|
|
//Q:qty 数量
|
|
//N:pnumber productionPlanNumber生产计划号
|
|
//S:packingCode 箱码
|
|
//U:uom 计量单位
|
|
//D:prodLine 生产线
|
|
//F:shift 班次
|
|
//E:produceDate日期
|
|
|
|
//返回结果
|
|
//sucess true:成功 false:失败
|
|
//scanType barcode:条码 qrcode:二维码
|
|
//isPack true:箱码 false:托码
|
|
export function analyseProductLabelInfo(scanMsg) {
|
|
let scanResult = {
|
|
sucess: false,
|
|
message: "",
|
|
data: {
|
|
itemCode: null,
|
|
lot: null,
|
|
qty: null,
|
|
pnumber: null,
|
|
packingCode: null,
|
|
uom: null,
|
|
prodLine: null,
|
|
shift: null,
|
|
produceDate: null
|
|
}
|
|
};
|
|
if (scanMsg == "") {
|
|
scanResult.message = "扫描到的内容为空";
|
|
} else {
|
|
try {
|
|
//条码
|
|
if (scanMsg.indexOf(';') < 0) {
|
|
scanResult.sucess = false;
|
|
scanResult.message = "标签格式不正确";
|
|
} else {
|
|
let arrayItems = scanMsg.split(';');
|
|
if (arrayItems.length > 0) {
|
|
arrayItems.forEach((item, index) => {
|
|
if (item != "") {
|
|
let type = item.substring(0, 1);
|
|
let value = item.substring(1, item.length);
|
|
if (type != "") {
|
|
switch (type) {
|
|
case "P": //物料号
|
|
case "p":
|
|
scanResult.data.itemCode = value;
|
|
break;
|
|
case "L": //批次
|
|
case "l":
|
|
scanResult.data.lot = value;
|
|
break;
|
|
case "Q": //数量
|
|
case "q":
|
|
scanResult.data.qty = value;
|
|
break;
|
|
case "N": //生产计划号 ASN
|
|
case "n":
|
|
scanResult.data.pnumber = value;
|
|
break;
|
|
case "S": //箱码
|
|
case "s":
|
|
scanResult.data.packingCode = value;
|
|
break;
|
|
case "U": //计量单位
|
|
case "u":
|
|
scanResult.data.uom = value;
|
|
break;
|
|
case "D": //生产线
|
|
case "d":
|
|
scanResult.data.prodLine = value;
|
|
break;
|
|
case "F": //班次
|
|
case "f":
|
|
scanResult.data.shift = value;
|
|
break;
|
|
case "E": //日期
|
|
case "e":
|
|
scanResult.data.produceDate = value;
|
|
break;
|
|
default:
|
|
scanResult.sucess = false;
|
|
scanResult.message = "无法识别的前缀" + type;
|
|
break;
|
|
}
|
|
scanResult.sucess = true;
|
|
} else {
|
|
scanResult.sucess = false;
|
|
scanResult.message = "标签信息不能为空" + type;
|
|
}
|
|
}
|
|
})
|
|
|
|
|
|
} else { //扫描的是条码,直接返回接收到的内容
|
|
scanResult.sucess = false;
|
|
scanResult.message = "标签分隔符错误";
|
|
}
|
|
}
|
|
} catch (ex) {
|
|
scanResult.sucess = false;
|
|
scanResult.message = "解析遇到异常" + ex.message;
|
|
}
|
|
}
|
|
return scanResult;
|
|
}
|
|
|
|
|
|
//解析天津mes标签
|
|
//1#2546319FL#254FL003#202207110009:
|
|
//1.序号1,2.生产号2546311FL,3.零件号254FL004,4.批序号202207110009
|
|
export function analyseTJMesQRCode(scanMsg) {
|
|
let scanResult = {
|
|
sucess: false,
|
|
message: "",
|
|
items: []
|
|
};
|
|
if (scanMsg == "") {
|
|
scanResult.message = "扫描到的内容为空";
|
|
} else {
|
|
try {
|
|
if (scanMsg.indexOf(':') < 0) {
|
|
scanResult.sucess = false;
|
|
scanResult.message = "标签格式不正确";
|
|
} else {
|
|
let arrayItems = scanMsg.split(':');
|
|
if (arrayItems.length > 0) {
|
|
arrayItems.forEach((item, index) => {
|
|
if (item != "") {
|
|
if (item.includes('#')) {
|
|
let datas = item.split('#');
|
|
//为空时是:2N
|
|
if (datas.length > 1) {
|
|
let itemCode = datas[2];
|
|
let location = itemCode.substring(3, 5);
|
|
let data = {
|
|
seq: datas[0], //序号
|
|
produceNo: datas[1], //生产号
|
|
// projectNo: datas[2], //项目号
|
|
itemCode: itemCode, //配置码(零件号)
|
|
lot: datas[3], //批次
|
|
position: location //上层、下层
|
|
}
|
|
scanResult.items.push(data)
|
|
}
|
|
} else {
|
|
if (item.includes('N')) {
|
|
let seq = item.substring(0, item.length - 1);
|
|
let data = {
|
|
seq: seq, //序号
|
|
produceNo: 'N', //生产号
|
|
projectNo: 'N', //项目号
|
|
itemCode: 'N', //配置码(零件号)
|
|
lot: 'N', //批次
|
|
position: ''
|
|
}
|
|
scanResult.items.push(data)
|
|
}
|
|
}
|
|
} else {
|
|
scanResult.sucess = false;
|
|
scanResult.message = "标签信息不能为空";
|
|
}
|
|
})
|
|
scanResult.sucess = true;
|
|
} else { //扫描的是条码,直接返回接收到的内容
|
|
scanResult.sucess = false;
|
|
scanResult.message = "标签分隔符错误";
|
|
}
|
|
}
|
|
} catch (ex) {
|
|
scanResult.sucess = false;
|
|
scanResult.message = "解析遇到异常" + ex.message;
|
|
}
|
|
}
|
|
return scanResult;
|
|
}
|
|
|