- 仪表盘报表:新增 app/service/dashboard.js + app/controller/dashboard.js + app/lib/billStatus.js,注册 GET /api/dashboard/report(jwtAuth + principalCheck), 一次聚合返回概览指标、发货单/入库单/出库单状态分布与待办、近 N 天单据量与 出入库数量趋势、库存 Top 商品、最近出入库流水;warehouse_id 只过滤单据与流水 (product_stocks 无仓库维度);契约 dashboard* 同步到 swagger - 接口配置裁剪:仓库接口配置只保留 api_version 与 item_name_with_spec; 历史 warehouse_apis.extra 冗余键、owner_code 配置、递交/回传设置一并清理 (迁移 20260915002400~02800) - 入库/出库/发货单报文与字段对齐 WMS 标准:去掉 ownerCode、operatorCode 等多余字段, 入库明细补 itemId;发货单明细去掉无意义的 owner_code(迁移 20260915002600) - 单号 5 位起:四张单据表 AUTO_INCREMENT 提到 10000(迁移 20260915002900) - 账号名称/头像按主体维护:principal_users 增 name/avatar 并回填(迁移 20260915003000/03100), 新增 app/lib/accountProfile.js(关联表名称/头像 → users 兜底);审核人写入 operator/operator_name; register 不再写 nickname、updateProfile 仅接受邮箱/手机号 - 出库单推送/锁库存链路的配套调整(outboundOrderPush、订单与发货单控制器) Co-Authored-By: GitHub Copilot <noreply@github.com>
56 lines
2.3 KiB
JavaScript
56 lines
2.3 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 清理仓库接口配置项残留键(第二轮):warehouse_apis.extra 中「已不在硬编码清单内」的键
|
||
*
|
||
* 背景:2026-09-14 按用户要求核实后,把「基础信息」分组整体移除(`app/lib/warehouseApiFields.js`):
|
||
* - `customer_id` 客户ID:openapi 契约上下文里 customerId 恒为 null(奇门渠道才用它做鉴权),OMS 从未读取
|
||
* - `owner_alias` 货主别名 / `outsource_api_type` 委外接口类型:无任何代码引用
|
||
* - `owner_code` 货主编码:openapi 的 entryorder.create / stockout.create / deliveryorder.create
|
||
* 对 ownerCode 均为 required=false(不传则 WMS 落空串),且 OMS 接收回传不看 ownerCode
|
||
* 故不再需要这些配置项,报文中也不再下发 ownerCode(见 `app/lib/wms/qimenClient.js`)。
|
||
*
|
||
* 口径:以当前清单的 key 集合为准,删除 extra 中**不在清单内**的所有键;
|
||
* 无可删键时不写库(幂等),只动 `extra`,不改 `updated_at`。
|
||
*/
|
||
const { listFieldDefs } = require('../../app/lib/warehouseApiFields');
|
||
|
||
module.exports = {
|
||
async up(queryInterface) {
|
||
const sequelize = queryInterface.sequelize;
|
||
const validKeys = new Set(listFieldDefs().map(field => field.key));
|
||
|
||
const rows = await sequelize.query('SELECT id, extra FROM warehouse_apis', { type: sequelize.QueryTypes.SELECT });
|
||
let prunedKeys = 0;
|
||
let touchedRows = 0;
|
||
|
||
for (const row of rows) {
|
||
let extra = row.extra;
|
||
if (typeof extra === 'string') {
|
||
try { extra = JSON.parse(extra); } catch { extra = null; }
|
||
}
|
||
if (!extra || typeof extra !== 'object' || Array.isArray(extra)) continue;
|
||
|
||
const stale = Object.keys(extra).filter(key => !validKeys.has(key));
|
||
if (!stale.length) continue;
|
||
|
||
const next = { ...extra };
|
||
for (const key of stale) delete next[key];
|
||
|
||
await sequelize.query(
|
||
'UPDATE warehouse_apis SET extra = ? WHERE id = ?',
|
||
{ replacements: [ JSON.stringify(next), row.id ] }
|
||
);
|
||
prunedKeys += stale.length;
|
||
touchedRows += 1;
|
||
}
|
||
|
||
console.log(`[migration] warehouse_apis.extra 清理清单外配置项:${touchedRows} 行 / ${prunedKeys} 个键`);
|
||
},
|
||
|
||
/**
|
||
* 不可逆:被删的键已无任何代码引用(如确需恢复,在页面重新填写即可)
|
||
*/
|
||
async down() {},
|
||
};
|