-- 补收货区:ASN 单 2601-251226002 (id=7207) 与明细可组托查询一致 -- 执行前请确认存在 type='receipt' 的 man_warehouse_areas;若你库字典值不同,改子查询条件 -- tenant_id=1 与主单一致;可组托计算:anfme - 已组托 - qty,这里 qty/work_qty=0 SET @area_id = (SELECT id FROM man_warehouse_areas WHERE `type` = 'receipt' AND deleted = 0 ORDER BY id LIMIT 1); SET @area_name = (SELECT `name` FROM man_warehouse_areas WHERE id = @area_id); SET @now = NOW(); -- 可选:先清同单旧收货区行(需则取消注释) -- DELETE FROM man_warehouse_areas_item WHERE asn_id = 7207; INSERT INTO man_warehouse_areas_item (area_id, area_name, asn_id, asn_code, asn_item_id, plat_item_id, matnr_id, matnr_code, maktx, fields_index, anfme, qty, work_qty, unit, stock_unit, ispt_result, track_code, batch, splr_batch, plat_order_code, plat_work_code, project_code, status, deleted, tenant_id, create_time, update_time) VALUES (@area_id, @area_name, 7207, '2601-251226002', 32888, '11', 92970, '2010110031#20260429#001', '气开切断阀(插装式)', 'f85050e0496cf683651df1675d3a8a3a', 1, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32889, '12', 92967, '2010110077#20260429#001', '溢流阀', 'dfc6199e1cfeb793dc6c6a36433c259c', 1, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32890, '13', 92977, '2010710003#20260429#001', '动力水阀(双作用)', 'f5ea4ab7d09e063cffca94c0cc47d799', 1, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32891, '14', 92973, '2010112077#20260429#001', '三通切断阀(插装式)', '273d3839133fa68a0aad8b87f21a44c0', 1, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32892, '1', 92968, '2010710002#20260429#001', '动力水阀(单作用)', '7017d37d82961c4da955d4120d0437ef', 2, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32893, '2', 92976, '2010710001#20260429#001', '动力水阀(单作用)', '16e2dcb1381ef58a00e89cffa58f631c', 1, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32894, '3', 92977, '2010710003#20260429#001', '动力水阀(双作用)', 'f5ea4ab7d09e063cffca94c0cc47d799', 10, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32895, '4', 92978, '2010112020#20260429#001', '闭环调节阀(插装式)', 'edce4de146dc6a2b4ebc13db91875902', 3, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32896, '5', 92979, '2010110001#20260429#001', '闭环调节阀(插装式)', 'bd747ec5840a110a04c011ec330a180b', 1, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32897, '6', 92972, '2010112028#20260429#001', '插装阀', 'd2a978e8e05f469ad3d3699204e3d88c', 1, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32898, '7', 92971, '2010110022#20260429#001', '气闭切断阀(插装式)', 'c582b1d08f58a1588e4091bfb9870428', 1, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32899, '8', 92975, '2010110041#20260429#001', '气开切断阀(插装式)', 'fc12cc177ca1994e1abb27ec4498ce1b', 1, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32900, '9', 92974, '2010110047#20260429#001', '气开切断阀(插装式)', 'b9540e19710f2f51c1f2937ed704e2c1', 1, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now), (@area_id, @area_name, 7207, '2601-251226002', 32901, '10', 92969, '2010112066#20260429#001', '三通切断阀(插装式)', '9ae7f8039161675dfe29e8429610e556', 2, 0, 0, 'PCS', 'PCS', 1, NULL, '', '', NULL, NULL, NULL, 1, 0, 1, @now, @now); -- 校验 -- SELECT COUNT(*) FROM man_warehouse_areas_item WHERE asn_id = 7207 AND deleted = 0;