refactor: 扫码查单优先外部WMS,兜底老系统方法

- scan 查单顺序改为:优先 newWms.queryOrder,未命中再兜底老系统 getOrderInfo
- 外部WMS命中走 _packWmsOrder 回传,老系统命中走 _packOrder 本地打包
- 更新日志文案以区分订单来源
This commit is contained in:
liufumingren 2026-08-29 23:25:22 +08:00
parent 72bd5d21e9
commit b2fed22caa

View File

@ -193,21 +193,22 @@ class Gzt extends Service {
}
} else {
ctx.logger.info(`[scan] 非包材,查询订单 | barcode=${barcode} | WAREHOUSEID=${gzt.WAREHOUSEID}`);
// 尝试本地订单 → 外部WMS → 无记录
let order = await this.getOrderInfo(barcode.replace(/-1-1-/g, ''), gzt.WAREHOUSEID);
// 优先查询外部WMS → 兜底老系统方法 → 无记录
let order = null;
let isWmsOrder = false;
if (!order) {
ctx.logger.info(`[scan] 本地订单未找到,查询外部WMS | barcode=${barcode}`);
const wmsResult = await this.ctx.service.newWms.queryOrder(barcode, gzt.WAREHOUSEID);
if (wmsResult && wmsResult.success) {
ctx.logger.info(`[scan] 外部WMS订单命中 | barcode=${barcode}`);
order = wmsResult.data;
isWmsOrder = true;
} else {
ctx.logger.info(`[scan] 外部WMS也未找到 | barcode=${barcode}`);
}
const wmsResult = await this.ctx.service.newWms.queryOrder(barcode, gzt.WAREHOUSEID);
if (wmsResult && wmsResult.success) {
ctx.logger.info(`[scan] 外部WMS订单命中 | barcode=${barcode}`);
order = wmsResult.data;
isWmsOrder = true;
} 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) {