Files
SupplierSystem/docs/audit/scripts/20260915-dashboard-verify/verify-drilldown.mjs
T
Ubuntu 1d47267a8d
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
chore(sync): 提交剩余本地改动(规则文档 / 部署配置 / 小程序入库归档 / 工具与测试)
- .cursor/rules + AGENTS.md:供应商二次开发的隔离硬规则落库(库/端口/上传目录/对象前缀)
- 部署与本地配置:docker-compose*.yml、.env.*.example(仅占位值)、start-split-native / sync-prod-db-to-local 脚本
- 小程序:入库归档识别(stockInboundArchive + 识别与入库面板改动)
- tools:设计门禁脚本(check-migrations / run-all / verify-facts)与架构图脚本更新
- docs:跨系统改价改量审核、第三方订单退货跟随、免入库推进、500+ 分公司规模改造、
  拍照入库识别与档案回写等设计文档;对接清单新增 §4.5.4 我方回执(第六批端到端)
- server:存量修数脚本(legacy CS / 供应商应付 / 结算口径)、采购耳标核对脚本;
  新增测试:入库归档回写、租户优选顺序、规模并发
2026-10-09 22:28:15 +08:00

38 lines
2.5 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.
// 端到端核验(本地同步库,不动生产):下钻区间是否真的生效
import { createRequire } from 'node:module';
const require = createRequire('/home/ubuntu/harness/ai-fresh-delivery/server/index.js');
process.env.DATABASE_URL = process.env.DATABASE_URL || process.env.DATABASE_URL || 'postgresql://supplier@127.0.0.1:5432/supplier_delivery';
const { pool } = require('/home/ubuntu/harness/ai-fresh-delivery/server/dist/db.js');
const { listOrdersForManagement } = require('/home/ubuntu/harness/ai-fresh-delivery/server/dist/services/orderManagementQueryService.js');
const { runInBranchSchema } = require('/home/ubuntu/harness/ai-fresh-delivery/server/dist/services/tenantSchemaFallback.js');
const branch = process.argv[2] || 'BR002';
const from = process.argv[3] || '2026-09-14';
const to = process.argv[4] || '2026-09-14';
const field = process.argv[5] || 'created_at';
const ctx = { userId: null, roles: ['admin'], permissions: [], branchCode: branch, supplierCode: null, purchaserCode: null, isSuperAdmin: false, isBranchAdmin: true, isInternalStaff: true, isSupplierAccount: false };
const res = await runInBranchSchema(branch, () =>
listOrdersForManagement(ctx, branch, { page: 1, pageSize: 200, statusGroup: 'all', dateRangePreset: 'custom', dateFrom: from, dateTo: to, dateField: field })
);
console.log(`下钻区间 ${from} ~ ${to}(${field},${branch})→ 命中订单 ${res.total} 单`);
const ymd = (v) => {
if (!v) return '';
const d = v instanceof Date ? v : new Date(String(v));
if (Number.isNaN(d.getTime())) return String(v).slice(0, 10);
return new Date(d.getTime() + 8 * 3600 * 1000).toISOString().slice(0, 10);
};
const days = new Set(res.rows.map((r) => ymd(r.delivery_date)));
const created = new Set(res.rows.map((r) => ymd(r.created_at)));
console.log(' 返回行的配送日集合:', [...days].sort().join(', ') || '(空)');
console.log(' 返回行的下单日集合:', [...created].sort().join(', ') || '(空)');
const outOfRange = res.rows.filter((r) => {
const d = field === 'delivery_date' ? ymd(r.delivery_date) : ymd(r.created_at);
return d && (d < from || d > to);
});
console.log(` 越界行数(应为 0): ${outOfRange.length}`);
// 对照组:不带区间应返回更多
const all = await runInBranchSchema(branch, () =>
listOrdersForManagement(ctx, branch, { page: 1, pageSize: 200, statusGroup: 'all', dateRangePreset: 'all' })
);
console.log(` 对照(dateRange=all): ${all.total} 单 → 区间生效: ${res.total !== all.total || all.total === 0}`);
await pool.end();