开发者口径:「可以按照方案 A 设计,但要确保我们这边能扫描的同时,主系统那边也能扫描。」
冲突:同一件商品两边 SKU 不同(真库:土豆 主系统 SKU78661069731 / 我方 SKU88064225461);
主系统扫码入口是 SELECT sku_code FROM skus WHERE barcode=$1 OR sku_code=$1(查他们自己的表),
所以只印我方码他们扫不了;只印他们的码我方配送员又会「未找到条码对应商品」。
做法(两边都不断):
① 打印:PICKING_ITEMS_ENRICHED_SQL 新增 label_barcode = 主系统 SKU(行级台账
main_system_order_import_items.main_sku_code,按 our_order_item_id 关联)优先 →
回退既有 barcode 链(我方条码/SKU);Web 两处打印 + 小程序打印都优先用 label_barcode。
主系统侧因此**零改造**即可扫(真库核对:tenant_br002.skus 里这些码都在且 barcode==sku_code)。
② 我方扫码:两个入口(分拣扫码 scanPickingBarcode、发车核货扫码 scanDeliveryLoadingBarcode)
在**未命中我方 skus** 时,调用共享函数 resolveOurSkuByMainSystemSku({barcode, pickCode?/orderCode?})
**在本单/本分拣单内**反查我方 SKU,再走原有逻辑;不带上下文直接返回 null(绝不全局猜)。
老标签命中原路径 ⇒ 行为逐字不变。
真库实测(临时单,跑完即清理):
造单用**他们的** SKU SKU78661069731(土豆)⇒ 我方行 SKU88064225461、台账记 main_sku_code;
标签 label_barcode = SKU78661069731(主系统可扫);用该码走我方分拣扫码 ⇒ 反查命中,
该行 picked_qty=1.00 / review_status=20(我方配送员照旧能扫);清理并回补账外余额(土豆回 ¥46.00)。
边界:我方自建/自采行继续印我方码;同 SKU 多行在本单内按"未完成优先→顺序"定位;
主系统"扫码入库"入口需他们新增(对他们就是扫自己的商品码,无需认识我们),扫完照旧推
preparations.picked_up / inbound_completed(我方接收端与幂等已就绪)。
测试:新增 labelBarcodeDualScan 4 例(标签取值/两端打印/两个入口共享兜底/必须带上下文);
相关 6 个文件 57 例全绿;root+server tsc exit 0;门禁 8/1/1。设计文见
docs/design/20261013-分拣标签二维码两端可扫(方案A).md
121 lines
3.7 KiB
TypeScript
121 lines
3.7 KiB
TypeScript
/** 分拣任务类型(业务逻辑见 server/pickingService + workflowApi) */
|
||
|
||
export interface OrderForPicking {
|
||
order_code: string;
|
||
branch_code?: string | null;
|
||
}
|
||
|
||
export interface OrderItemForPicking {
|
||
id: string;
|
||
order_code: string | null;
|
||
sku_code: string | null;
|
||
item_name?: string | null;
|
||
quantity: number;
|
||
unit?: string | null;
|
||
branch_code?: string | null;
|
||
}
|
||
|
||
export interface PickingItemRow {
|
||
id: string;
|
||
pick_code: string;
|
||
order_item_id?: string | null;
|
||
order_code: string | null;
|
||
sku_code: string | null;
|
||
item_name?: string | null;
|
||
required_qty: number;
|
||
picked_qty: number;
|
||
picked_weight?: number | null;
|
||
unit?: string | null;
|
||
review_status: number;
|
||
diff_reason?: string | null;
|
||
barcode?: string | null;
|
||
/**
|
||
* 分拣标签二维码内容(2026-10-13 方案 A):有主系统来源的行=**主系统 SKU**(他们零改造可扫),
|
||
* 无来源=我方条码/SKU。老接口无该字段时回退 `barcode`。
|
||
*/
|
||
label_barcode?: string | null;
|
||
/** 商品分类(`order_items.category_name`),分拣列表批量打印按「分类」排队用 */
|
||
category_name?: string | null;
|
||
sort_order?: number | null;
|
||
container_code?: string | null;
|
||
staged_at?: string | null;
|
||
/** 商品默认区域(`skus.storage_zone`),用于分拣按区域展示 */
|
||
storage_zone?: string | null;
|
||
/** 分拣「完成」时手选的出库批次计划(发车核货按此扣库;空=默认 FIFO) */
|
||
outbound_batches?: Array<{ batch_no: string; qty: number }> | null;
|
||
/** 分拣出库留证照(商品级,对象路径);见 docs/design/20261103-分拣出库拍照留证.md */
|
||
outbound_photos?: string[];
|
||
/** 上述照片的服务端签名可读链接(与 outbound_photos 同序) */
|
||
outbound_photo_urls?: string[];
|
||
}
|
||
|
||
export interface PickingTaskRow {
|
||
id: string;
|
||
pick_code: string;
|
||
order_code: string | null;
|
||
order_codes?: string | null;
|
||
warehouse_code: string | null;
|
||
pick_status: number;
|
||
created_at: string | null;
|
||
reviewed_at?: string | null;
|
||
outbound_at?: string | null;
|
||
remark?: string | null;
|
||
branch_code?: string | null;
|
||
delivery_date?: string | null;
|
||
/** 关联订单 MIN(created_at),列表「下单日」列用 */
|
||
order_created_at?: string | null;
|
||
item_count?: number;
|
||
delivery_address?: string | null;
|
||
picker_id?: string | null;
|
||
picker_name?: string | null;
|
||
customer_code?: string | null;
|
||
company_name?: string | null;
|
||
scope_type?: 'order' | 'category' | 'customer' | string | null;
|
||
scope_key?: string | null;
|
||
scope_label?: string | null;
|
||
}
|
||
|
||
export type PickingTaskMode = 'order' | 'category' | 'sku' | 'zone';
|
||
|
||
export interface PickingAssignee {
|
||
id: string;
|
||
full_name: string | null;
|
||
username: string | null;
|
||
branch_code: string | null;
|
||
display_name: string;
|
||
/**
|
||
* 角色码(`picker` / `warehouse` / `delivery`…)。
|
||
* 分拣池含"勾了分拣出库的配送员"是既有设计(配送员兼分拣),界面**标出角色**以免被误认成专责分拣员。
|
||
*/
|
||
roles?: string[];
|
||
}
|
||
|
||
export type PickingAssignRuleType = 'category' | 'customer';
|
||
|
||
/** 与称端 WeighStationMatcher.isWeightUnit 对齐:斤/kg/两等须录实拣重量 */
|
||
export function isPickingWeightUnit(unit?: string | null): boolean {
|
||
if (!unit) return false;
|
||
const u = unit.trim().toLowerCase();
|
||
return (
|
||
u.includes('斤') ||
|
||
u.includes('公斤') ||
|
||
u === 'kg' ||
|
||
u === 'g' ||
|
||
u.includes('千克') ||
|
||
u === '市斤' ||
|
||
u === '克' ||
|
||
u.includes('两')
|
||
);
|
||
}
|
||
|
||
export interface PickingAssignRule {
|
||
id: string;
|
||
branch_code: string;
|
||
rule_type: PickingAssignRuleType;
|
||
scope_key: string;
|
||
picker_id: string;
|
||
is_active: boolean;
|
||
scope_label?: string | null;
|
||
picker_name?: string | null;
|
||
}
|