89 lines
2.7 KiB
JavaScript
89 lines
2.7 KiB
JavaScript
'use strict';
|
||
|
||
const Service = require('egg').Service;
|
||
|
||
/**
|
||
* workbench 业务服务
|
||
* 由 /system 接口统一调度
|
||
*/
|
||
class WorkbenchService extends Service {
|
||
|
||
/**
|
||
* 扫码查单 - 调用 new_wms.queryOrder
|
||
*/
|
||
async someAction(data) {
|
||
const { barcode, warehouseId } = data;
|
||
if (!barcode) {
|
||
return { success: false, message: '缺少 barcode' };
|
||
}
|
||
const result = await this.service.newWms.queryOrder(barcode, warehouseId);
|
||
return result || { success: false, message: '未查询到订单' };
|
||
}
|
||
|
||
/**
|
||
* 查询 - 调用 newWms.queryOrder
|
||
*/
|
||
async query(data) {
|
||
const { barcode, warehouseId } = data;
|
||
if (!barcode) {
|
||
return { success: false, message: '缺少 barcode' };
|
||
}
|
||
const result = await this.service.newWms.queryOrder(barcode, warehouseId);
|
||
return result || { success: false, message: '未查询到订单' };
|
||
}
|
||
|
||
/**
|
||
* 回传打包状态 - 调用 newWms.reportPackStatus
|
||
*/
|
||
async reportPackStatus(data) {
|
||
const result = await this.service.newWms.reportPackStatus(data);
|
||
if (result) {
|
||
return { success: true, data: result, message: 'ok' };
|
||
}
|
||
return { success: false, message: '回传失败' };
|
||
}
|
||
|
||
/**
|
||
* 打包回传 - 仅外部WMS订单(types=4)才发送到外部
|
||
*/
|
||
async packOrder(data) {
|
||
const { types, POSTNUM, grabnum, WAREHOUSEID, gztid, _wms_delivery_order_code, wms_order_ids } = data;
|
||
// 仅外部WMS订单才回传
|
||
if (types !== 4) {
|
||
return { success: false, message: '非外部WMS订单,无需回传' };
|
||
}
|
||
if (!POSTNUM || !grabnum) {
|
||
return { success: false, message: '缺少 POSTNUM 或 grabnum' };
|
||
}
|
||
const result = await this.service.newWms.reportPackStatus({
|
||
POSTNUM,
|
||
grabnum,
|
||
WAREHOUSEID: WAREHOUSEID || '1000028',
|
||
gztid: gztid || '',
|
||
_wms_delivery_order_code: _wms_delivery_order_code || '',
|
||
wms_order_ids: wms_order_ids || '',
|
||
});
|
||
if (result && result.flag === 'success') {
|
||
return { success: true, data: result, message: '回传成功' };
|
||
}
|
||
return { success: false, message: result?.message || '回传失败', wmsResult: result };
|
||
}
|
||
|
||
/**
|
||
* 结束打包任务 - 关闭工作台最后一个未结束任务
|
||
*/
|
||
async finishPack(data) {
|
||
const { workbench_id, warehouse_id } = data;
|
||
if (!workbench_id || !warehouse_id) {
|
||
return { success: false, message: '缺少 workbench_id 或 warehouse_id' };
|
||
}
|
||
const result = await this.service.newWms.finishPack({ workbench_id, warehouse_id });
|
||
if (result && result.flag === 'success') {
|
||
return { success: true, data: result, message: '结束成功' };
|
||
}
|
||
return { success: false, message: result?.message || '结束失败', wmsResult: result };
|
||
}
|
||
}
|
||
|
||
module.exports = WorkbenchService;
|