Compare commits
5 Commits
31ef281cdb
...
03b42b4874
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03b42b4874 | ||
|
|
a1b934ea09 | ||
|
|
b2fed22caa | ||
|
|
72bd5d21e9 | ||
|
|
638fb55608 |
@ -193,21 +193,22 @@ class Gzt extends Service {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.logger.info(`[scan] 非包材,查询订单 | barcode=${barcode} | WAREHOUSEID=${gzt.WAREHOUSEID}`);
|
ctx.logger.info(`[scan] 非包材,查询订单 | barcode=${barcode} | WAREHOUSEID=${gzt.WAREHOUSEID}`);
|
||||||
// 尝试本地订单 → 外部WMS → 无记录
|
// 优先查询外部WMS → 兜底老系统方法 → 无记录
|
||||||
let order = await this.getOrderInfo(barcode.replace(/-1-1-/g, ''), gzt.WAREHOUSEID);
|
let order = null;
|
||||||
let isWmsOrder = false;
|
let isWmsOrder = false;
|
||||||
if (!order) {
|
const wmsResult = await this.ctx.service.newWms.queryOrder(barcode, gzt.WAREHOUSEID);
|
||||||
ctx.logger.info(`[scan] 本地订单未找到,查询外部WMS | barcode=${barcode}`);
|
if (wmsResult && wmsResult.success) {
|
||||||
const wmsResult = await this.ctx.service.newWms.queryOrder(barcode, gzt.WAREHOUSEID);
|
ctx.logger.info(`[scan] 外部WMS订单命中 | barcode=${barcode}`);
|
||||||
if (wmsResult && wmsResult.success) {
|
order = wmsResult.data;
|
||||||
ctx.logger.info(`[scan] 外部WMS订单命中 | barcode=${barcode}`);
|
isWmsOrder = true;
|
||||||
order = wmsResult.data;
|
|
||||||
isWmsOrder = true;
|
|
||||||
} else {
|
|
||||||
ctx.logger.info(`[scan] 外部WMS也未找到 | barcode=${barcode}`);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ctx.logger.info(`[scan] 本地订单命中 | barcode=${barcode} | PLSENDFLAG=${order.PLSENDFLAG}`);
|
ctx.logger.info(`[scan] 外部WMS未命中,查询老系统 | barcode=${barcode}`);
|
||||||
|
order = await this.getOrderInfo(barcode.replace(/-1-1-/g, ''), gzt.WAREHOUSEID);
|
||||||
|
if (order) {
|
||||||
|
ctx.logger.info(`[scan] 老系统订单命中 | barcode=${barcode} | PLSENDFLAG=${order.PLSENDFLAG}`);
|
||||||
|
} else {
|
||||||
|
ctx.logger.info(`[scan] 老系统也未找到 | barcode=${barcode}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (order) {
|
if (order) {
|
||||||
@ -218,6 +219,9 @@ class Gzt extends Service {
|
|||||||
ctx.logger.info(`[scan] 订单-外部WMS打包 | barcode=${barcode}`);
|
ctx.logger.info(`[scan] 订单-外部WMS打包 | barcode=${barcode}`);
|
||||||
// 外部WMS订单:回传打包状态到外部
|
// 外部WMS订单:回传打包状态到外部
|
||||||
await this._packWmsOrder(gzt, order, sid);
|
await this._packWmsOrder(gzt, order, sid);
|
||||||
|
} else if (order.FLAG != 0 || order.ISLOCK == 1) {
|
||||||
|
ctx.logger.info(`[scan] 订单-已拦截/取消,拒绝打包 | barcode=${barcode} | FLAG=${order.FLAG} | ISLOCK=${order.ISLOCK}`);
|
||||||
|
this._push(sid, 'msg', '订单拦截');
|
||||||
} else if (order.PLSENDFLAG === 0) {
|
} else if (order.PLSENDFLAG === 0) {
|
||||||
ctx.logger.info(`[scan] 订单-未复核,拒绝打包 | barcode=${barcode} | PLSENDFLAG=${order.PLSENDFLAG}`);
|
ctx.logger.info(`[scan] 订单-未复核,拒绝打包 | barcode=${barcode} | PLSENDFLAG=${order.PLSENDFLAG}`);
|
||||||
this._push(sid, 'msg', '订单未复核');
|
this._push(sid, 'msg', '订单未复核');
|
||||||
@ -284,6 +288,18 @@ class Gzt extends Service {
|
|||||||
async _packWmsOrder(gzt, order, sid) {
|
async _packWmsOrder(gzt, order, sid) {
|
||||||
const { ctx } = this;
|
const { ctx } = this;
|
||||||
try {
|
try {
|
||||||
|
// 外部WMS订单:判断是否已拦截/取消、是否已打包,做相应通知处理
|
||||||
|
const check = this.ctx.service.newWms.checkOrderStatus(order);
|
||||||
|
if (check.intercepted) {
|
||||||
|
ctx.logger.info(`[scan] 外部WMS订单已拦截/取消,拒绝打包 | POSTNUM=${order.POSTNUM} | status=${order.status} | intercept_flag=${order.intercept_flag}`);
|
||||||
|
this._push(sid, 'msg', '订单拦截');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (check.packed) {
|
||||||
|
ctx.logger.info(`[scan] 外部WMS订单已打包,跳过回传 | POSTNUM=${order.POSTNUM} | pack_flag=${order.pack_flag} | pack_status=${order.pack_status}`);
|
||||||
|
this._push(sid, 'msg', '订单已打包');
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 设置工作台ID,使用 gzt 表的 other_id
|
// 设置工作台ID,使用 gzt 表的 other_id
|
||||||
order.gztid = gzt.other_id || '';
|
order.gztid = gzt.other_id || '';
|
||||||
// 查询完整用户信息
|
// 查询完整用户信息
|
||||||
@ -414,7 +430,7 @@ class Gzt extends Service {
|
|||||||
}
|
}
|
||||||
async getOrderInfoBySql(postNumer,WAREHOUSEID){
|
async getOrderInfoBySql(postNumer,WAREHOUSEID){
|
||||||
const order_tmp = await this.app.mysql.get('dbwms').query(
|
const order_tmp = await this.app.mysql.get('dbwms').query(
|
||||||
`select order1.ID as ID,GRABNUM,POSTNUM,pack.NAME as PACKNAME,PLSENDFLAG,ITEMS from yj_wmsorder order1 left join yj_pack pack on pack.ID=order1.PACKID where order1.POSTNUM=? and order1.WAREHOUSEID=?`,
|
`select order1.ID as ID,GRABNUM,POSTNUM,pack.NAME as PACKNAME,PLSENDFLAG,ITEMS,order1.FLAG as FLAG,order1.ISLOCK as ISLOCK from yj_wmsorder order1 left join yj_pack pack on pack.ID=order1.PACKID where order1.POSTNUM=? and order1.WAREHOUSEID=?`,
|
||||||
[postNumer, WAREHOUSEID]
|
[postNumer, WAREHOUSEID]
|
||||||
);
|
);
|
||||||
const order = order_tmp?order_tmp[0]:null;
|
const order = order_tmp?order_tmp[0]:null;
|
||||||
@ -452,7 +468,9 @@ class Gzt extends Service {
|
|||||||
wms_order_ids:[order.ID].join(','),
|
wms_order_ids:[order.ID].join(','),
|
||||||
PACKNAME:order.PACKNAME,
|
PACKNAME:order.PACKNAME,
|
||||||
isSandan:1,
|
isSandan:1,
|
||||||
PLSENDFLAG:order.PLSENDFLAG
|
PLSENDFLAG:order.PLSENDFLAG,
|
||||||
|
FLAG:order.FLAG,
|
||||||
|
ISLOCK:order.ISLOCK
|
||||||
}
|
}
|
||||||
if(order.GRABNUM.indexOf('B')>-1){
|
if(order.GRABNUM.indexOf('B')>-1){
|
||||||
//团购
|
//团购
|
||||||
|
|||||||
@ -140,6 +140,8 @@ class NewWms extends Service {
|
|||||||
String(item.plan_qty || 1),
|
String(item.plan_qty || 1),
|
||||||
item.item_name || '',
|
item.item_name || '',
|
||||||
barcodes,
|
barcodes,
|
||||||
|
item.packing_requirements || '',
|
||||||
|
item.image_url || [],
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
@ -161,6 +163,30 @@ class NewWms extends Service {
|
|||||||
isSandan: wmsResult.isSandan || 0,
|
isSandan: wmsResult.isSandan || 0,
|
||||||
wave_total_orders: (wmsResult.batch && wmsResult.batch.total_orders) || 0,
|
wave_total_orders: (wmsResult.batch && wmsResult.batch.total_orders) || 0,
|
||||||
_wms_delivery_order_code: order.delivery_order_code || '',
|
_wms_delivery_order_code: order.delivery_order_code || '',
|
||||||
|
// 拦截/取消状态
|
||||||
|
status: order.status || '',
|
||||||
|
intercept_flag: order.intercept_flag || 0,
|
||||||
|
intercept_status: order.intercept_status || '',
|
||||||
|
// 打包状态
|
||||||
|
pack_flag: order.pack_flag || 0,
|
||||||
|
pack_status: order.pack_status || '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== 内部:判断外部WMS订单是否可打包 ==========
|
||||||
|
// 返回 { intercepted, packed }
|
||||||
|
// - intercepted: true 表示订单已取消或被拦截,禁止打包
|
||||||
|
// - packed: true 表示订单已完成打包,无需重复回传
|
||||||
|
checkOrderStatus(order) {
|
||||||
|
const status = (order && order.status) || '';
|
||||||
|
const intercept_flag = Number((order && order.intercept_flag) || 0);
|
||||||
|
const pack_flag = Number((order && order.pack_flag) || 0);
|
||||||
|
const pack_status = (order && order.pack_status) || '';
|
||||||
|
return {
|
||||||
|
intercepted: status === 'cancel' || intercept_flag === 1,
|
||||||
|
// packed: 仅以打包状态判断(pack_status 取值:packed / fin=打包完成)
|
||||||
|
// 注意:status='finished' 不代表已打包(如 pack_status=none 的出库完成单),不作为已打包依据
|
||||||
|
packed: pack_flag === 1 || pack_status === 'packed' || pack_status === 'fin',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user