feat: 新增检测单关联、基础数据优化与入库单升级
1. 新增出库单检测单号字段并添加索引支持溯源 2. 优化基础数据页面物料类型展示与选择逻辑 3. 升级入库单导入功能,支持自动生成单号并返回导入结果 4. 优化接驳台查询排序方式 5. 修复字符串拼接空格问题
This commit is contained in:
@@ -236,6 +236,33 @@ func applyColumnPatches(ctx context.Context) {
|
||||
`ALTER TABLE inbound_orders ADD COLUMN IF NOT EXISTS void_reason text`,
|
||||
`ALTER TABLE inbound_orders ADD COLUMN IF NOT EXISTS voided_by text`,
|
||||
`ALTER TABLE inbound_orders ADD COLUMN IF NOT EXISTS voided_at bigint`,
|
||||
// ===== 2026-09-21 单号格式升级:IB/OB + YYYYMMDD + NNN + 高频查询字段统一加索引 =====
|
||||
// 单号唯一:防止手工/自动生成撞号,应用层 validateUniqueNo 只做业务友好校验,DB 端唯一约束才是硬保证
|
||||
// 注:存量库若有重复 IB433efbcc 这种旧单号会导致建索引失败,先在控制台 SELECT inbound_no, COUNT(*) GROUP BY 清掉重复
|
||||
`CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS ux_inbound_orders_inbound_no ON inbound_orders (inbound_no)`,
|
||||
`CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS ux_outbound_orders_outbound_no ON outbound_orders (outbound_no)`,
|
||||
// 出库单也挂检测单号——退货/报废等场景需要溯源检验单据
|
||||
`ALTER TABLE outbound_orders ADD COLUMN IF NOT EXISTS inspection_no text DEFAULT ''`,
|
||||
// 高频查询/关联字段(ORDER BY / WHERE / JOIN)
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inbound_orders_created_at ON inbound_orders (created_at DESC)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inbound_orders_material_code ON inbound_orders (material_code)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inbound_orders_inspection_no ON inbound_orders (inspection_no)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_outbound_orders_order_no ON outbound_orders (order_no)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_outbound_orders_material_code ON outbound_orders (material_code)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_outbound_orders_inspection_no ON outbound_orders (inspection_no)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inventories_inbound_no ON inventories (inbound_no)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inventories_outbound_no ON inventories (outbound_no)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inventories_material_code ON inventories (material_code)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inventories_quality_status ON inventories (quality_status)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inventories_manage_mode ON inventories (manage_mode)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_outbound_details_outbound_no ON outbound_details (outbound_no)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inbound_details_inbound_no ON inbound_details (inbound_no)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inspection_records_target_id ON inspection_records (target_id)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inspection_records_inspection_no ON inspection_records (inspection_no)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_inspection_records_status ON inspection_records (status)`,
|
||||
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_materials_code ON materials (code)`,
|
||||
`CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS ux_order_material_ledger_order_material ON order_material_ledgers (order_no, material_code)`,
|
||||
`CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS ux_agv_tasks_task_no ON agv_tasks (task_no)`,
|
||||
// 附件:新存储方案(年/月/日/文件类型/uuid.ext)——补文件类型/UUID名/相对路径/逻辑删除/归档列
|
||||
`ALTER TABLE attachments ADD COLUMN IF NOT EXISTS file_type text`,
|
||||
`ALTER TABLE attachments ADD COLUMN IF NOT EXISTS file_ext text`,
|
||||
|
||||
Reference in New Issue
Block a user