liufumingren 95067aeb8a feat(wms): 工作台成员、波次范围、库存明细与报表修复等多项更新
- workbench: 工作台成员拆分 wms_workbench_member 表,下线 barcode 字段,新增绑定/移除成员接口

- order: 订单配送新增 wave_scope 波次范围字段与历史回填,自动分配快递排除备注与储位分配限制修复

- storage.transaction.list: 重写为 wms_storage_transaction 逐条明细查询,消除聚合慢查询

- stock.report: 分页默认生效、排序白名单扩充、where.stock_id 数组兼容修复

- storage.entry: quickInbound/commit 新增 noNeedNotice 通知开关

- storage.inventory.list: stock_query 支持数组多关键字并集匹配

- store: 手工单回传通知策略 notify_manual_sync

- docs: 同步接口文档与变更记录、路由表;test: 补充快递排除与储位分配限制测试
2026-09-05 22:43:38 +08:00

226 lines
6.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const MainService = require('../main');
class WorkbenchService extends MainService {
constructor(ctx) {
super(ctx);
const _noNeedLogin = 'business,getWorkbenchInfo,removeMember,bindMember';
const _noNeedRight = 'list,detail,business,getWorkbenchInfo,removeMember,bindMember';
const _noNeedLog = 'list,detail,getWorkbenchInfo,removeMember,bindMember';
const _noNeedAuth = 'list,detail,business,getWorkbenchInfo,removeMember,bindMember';
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth);
}
/**
* 工作台列表(分页 + 筛选)
* @param data
*/
async list(data) {
const { service } = this;
try {
const result = await service.systems.workbench.list(data || {});
return this.success('获取成功', result);
} catch (error) {
return this.fail(error.message);
}
}
/**
* 工作台详情
* @param data
*/
async detail(data) {
const { service } = this;
try {
const { id } = data || {};
if (!id) return this.fail('工作台ID不能为空');
const record = await service.systems.workbench.detail(parseInt(id));
return this.success('获取成功', record);
} catch (error) {
return this.fail(error.message);
}
}
/**
* 创建工作台
* @param data
*/
async create(data) {
const { service } = this;
try {
const record = await service.systems.workbench.create(data);
return this.success('创建成功', record);
} catch (error) {
return this.fail(error.message);
}
}
/**
* 更新工作台
* @param data
*/
async update(data) {
const { service } = this;
try {
const { id, ...fields } = data || {};
if (!id) return this.fail('工作台ID不能为空');
const record = await service.systems.workbench.update(parseInt(id), fields);
return this.success('更新成功', record);
} catch (error) {
return this.fail(error.message);
}
}
/**
* 删除工作台(软删除)
* @param data
*/
async delete(data) {
const { service } = this;
try {
const { id } = data || {};
if (!id) return this.fail('工作台ID不能为空');
await service.systems.workbench.delete(parseInt(id));
return this.success('删除成功');
} catch (error) {
return this.fail(error.message);
}
}
/**
* 工作台业务入口(免登录、免鉴权)
* @param {Object} data - { name, data }
*/
async business(data) {
const { ctx, service } = this;
const { name, data: bizData } = data || {};
ctx.logger.info('[Workbench.business] 收到业务请求 name=%s data=%j', name, bizData);
try {
const result = await service.systems.workbench.business(name, bizData);
return this.success('ok', result);
} catch (error) {
ctx.logger.error('[Workbench.business] 业务处理失败 name=%s error=%s', name, error.message);
return this.fail(error.message);
}
}
/**
* 工作台绑定摄像头
* @param data
*/
async bindCamera(data) {
const { service } = this;
try {
const { id, camera_ids } = data || {};
if (!id) return this.fail('工作台ID不能为空');
const record = await service.systems.workbench.bindCamera(parseInt(id), camera_ids);
return this.success('绑定成功', record);
} catch (error) {
return this.fail(error.message);
}
}
/**
* 工作台绑定:校验缓存绑定码与工作台ID,写入随机 token(需登录、需权限)
* @param data - { code, id }
*/
async bind(data) {
const { service } = this;
try {
const result = await service.systems.workbench.bindWorkbench(data || {});
if (result && result.success) {
return this.success('绑定成功', result);
}
const statusCode = result && result.statusCode;
return this.fail(
result && result.message ? result.message : '绑定失败',
statusCode ? { code: statusCode } : undefined
);
} catch (error) {
return this.fail(error.message);
}
}
/**
* 使用 token 获取工作台信息(免登录、免鉴权)
* @param data - { token }
*/
async getWorkbenchInfo(data) {
const { service } = this;
try {
const result = await service.systems.workbench.getWorkbenchInfoByToken(data || {});
if (result && result.success) {
return this.success('获取成功', result);
}
const statusCode = result && result.statusCode;
return this.fail(
result && result.message ? result.message : '获取工作台信息失败',
statusCode ? { code: statusCode } : undefined
);
} catch (error) {
return this.fail(error.message);
}
}
/**
* 重置工作台登录码(需登录、需权限)
* @param data - { id }
*/
async resetLoginCode(data) {
const { service } = this;
try {
const { id } = data || {};
if (!id) return this.fail('工作台ID不能为空');
const result = await service.systems.workbench.resetLoginCode(parseInt(id));
return this.success('重置成功', result);
} catch (error) {
return this.fail(error.message);
}
}
/**
* 移除工作台成员(免登录、免鉴权,以工作台 token 鉴权)
* @param data - { ids, token }
*/
async removeMember(data) {
const { service } = this;
try {
const result = await service.systems.workbench.removeWorkbenchMember(data || {});
if (result && result.success) {
return this.success('移除成功', result);
}
const statusCode = result && result.statusCode;
return this.fail(
result && result.message ? result.message : '移除成员失败',
statusCode ? { code: statusCode } : undefined
);
} catch (error) {
return this.fail(error.message);
}
}
/**
* 绑定工作台成员(免登录、免鉴权,以工作台 token 鉴权)
* @param data - { userId | user_id, userName | user_name | name, token }
*/
async bindMember(data) {
const { service } = this;
try {
const result = await service.systems.workbench.bindWorkbenchMember(data || {});
if (result && result.success) {
return this.success('绑定成功', result);
}
const statusCode = result && result.statusCode;
return this.fail(
result && result.message ? result.message : '绑定成员失败',
statusCode ? { code: statusCode } : undefined
);
} catch (error) {
return this.fail(error.message);
}
}
}
module.exports = WorkbenchService;