WMS_MAIN/script/tmp-check-batch-no-array-backfill-scope.cjs
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

52 lines
1.9 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';
/**
* 回填 wms_wave_pick_task.batch_no_array(生产只读预检)。
*
* 从 wms_wave_pick_task_wave 按 task_id 聚合 wave_no(逗号分隔,按 id 升序),
* 只更新 batch_no_array IS NULL 的任务,幂等可重复执行。
*/
const dbConfig = require('../database/config.js');
const Sequelize = require('sequelize');
(async () => {
const cfg = dbConfig.production;
const s = new Sequelize(cfg.database, cfg.username, cfg.password, {
host: cfg.host,
port: cfg.port,
dialect: cfg.dialect || 'mysql',
logging: false,
});
const q = async (sql, repl) => {
const rows = await s.query(sql, { replacements: repl, type: Sequelize.QueryTypes.SELECT });
return Array.isArray(rows) ? rows : [];
};
const total = await q('SELECT COUNT(*) AS c FROM wms_wave_pick_task');
console.log('A. 任务总数:', JSON.stringify(total));
const nullable = await q("SELECT COUNT(*) AS c FROM wms_wave_pick_task WHERE batch_no_array IS NULL OR batch_no_array = ''");
console.log('B. batch_no_array 为空的任务数:', JSON.stringify(nullable));
const backfillable = await q(
"SELECT COUNT(DISTINCT tw.task_id) AS c FROM wms_wave_pick_task_wave tw "
+ "INNER JOIN wms_wave_pick_task t ON t.id = tw.task_id "
+ "WHERE tw.wave_no IS NOT NULL AND tw.wave_no <> '' "
+ "AND (t.batch_no_array IS NULL OR t.batch_no_array = '')"
);
console.log('C. 可回填的任务数(有 wave 记录且 batch_no_array 为空):', JSON.stringify(backfillable));
const byWaveRows = await q(
"SELECT task_id, COUNT(*) AS c FROM wms_wave_pick_task_wave "
+ "WHERE wave_no IS NOT NULL AND wave_no <> '' GROUP BY task_id ORDER BY c DESC LIMIT 5"
);
console.log('D. 单任务最多波次记录数样例:', JSON.stringify(byWaveRows));
await s.close();
})().catch(e => {
console.error('ERROR:', e.message);
process.exit(1);
});