来源仓库:jxc/ai-fresh-delivery 来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d 快照树: 09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件) 按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据 (生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、 deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值), 整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。 供应商系统后续开发自本提交开始。
85 lines
3.7 KiB
JavaScript
85 lines
3.7 KiB
JavaScript
#!/usr/bin/env node
|
|
import pg from 'pg';
|
|
import { readFileSync } from 'fs';
|
|
|
|
const env = readFileSync('/opt/ai-fresh-delivery/server/.env', 'utf8');
|
|
const url = env.match(/^DATABASE_URL=(.+)$/m)[1].trim().replace(/^["']|["']$/g, '');
|
|
const today = new Intl.DateTimeFormat('en-CA', { timeZone: 'Asia/Shanghai' }).format(new Date());
|
|
const pool = new pg.Pool({ connectionString: url });
|
|
|
|
const code = process.argv[2] || 'ORD_MP_1783329222231XQ2O';
|
|
|
|
try {
|
|
console.log('=== 今天:', today, '| 重点订单:', code, '===\n');
|
|
|
|
const logs = await pool.query(
|
|
`SELECT operator_name, operation_type, target_table, target_id, created_at
|
|
FROM operation_logs
|
|
WHERE created_at >= ($1::timestamptz AT TIME ZONE 'Asia/Shanghai')
|
|
ORDER BY created_at DESC LIMIT 50`,
|
|
[`${today} 00:00:00+08`]
|
|
);
|
|
console.log('--- 今日全部操作日志 ---', logs.rowCount);
|
|
logs.rows.forEach((r) => {
|
|
const t = new Date(r.created_at).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' });
|
|
console.log(`[${t}] ${r.operator_name || '-'} | ${r.operation_type} | ${r.target_table}:${r.target_id}`);
|
|
});
|
|
|
|
const order = await pool.query(
|
|
`SELECT order_code, order_status, delivery_date, branch_code, customer_code, created_at, updated_at
|
|
FROM orders WHERE order_code = $1`,
|
|
[code]
|
|
);
|
|
console.log('\n--- 订单 ---', order.rows[0] || 'NOT FOUND');
|
|
|
|
const insp = await pool.query(
|
|
`SELECT id, item_name, sku_code, actual_qty, quality_rating, inspection_time, created_at,
|
|
array_length(inspection_photos, 1) AS photo_count
|
|
FROM inspections WHERE order_code = $1 ORDER BY created_at`,
|
|
[code]
|
|
);
|
|
console.log('\n--- 验收记录 ---', insp.rowCount);
|
|
insp.rows.forEach((r) => {
|
|
const done = r.inspection_time ? '已入库' : '待验收';
|
|
const t = r.inspection_time ? new Date(r.inspection_time).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' }) : '';
|
|
console.log(` ${r.item_name} | qty=${r.actual_qty} grade=${r.quality_rating || '-'} | ${done} ${t} | photos=${r.photo_count || 0}`);
|
|
});
|
|
|
|
const prep = await pool.query(
|
|
`SELECT sku_code, prep_status, prep_qty, updated_at FROM supplier_preparations WHERE order_code = $1`,
|
|
[code]
|
|
);
|
|
console.log('\n--- 供应商备货 ---', prep.rowCount);
|
|
prep.rows.forEach((r) => console.log(` ${r.sku_code} status=${r.prep_status} qty=${r.prep_qty}`));
|
|
|
|
const pick = await pool.query(`SELECT pick_code, pick_status, created_at FROM picking_tasks WHERE order_code = $1`, [code]);
|
|
console.log('\n--- 分拣任务 ---', pick.rowCount);
|
|
pick.rows.forEach((r) => console.log(` ${r.pick_code} status=${r.pick_status}`));
|
|
|
|
const inspToday = await pool.query(
|
|
`SELECT i.order_code, i.item_name, i.inspection_time, i.actual_qty, o.order_status
|
|
FROM inspections i JOIN orders o ON o.order_code = i.order_code
|
|
WHERE i.inspection_time >= ($1::date AT TIME ZONE 'Asia/Shanghai')
|
|
ORDER BY i.inspection_time DESC LIMIT 20`,
|
|
[today]
|
|
);
|
|
console.log('\n--- 今日完成验收(inspection_time) ---', inspToday.rowCount);
|
|
inspToday.rows.forEach((r) => {
|
|
const t = new Date(r.inspection_time).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' });
|
|
console.log(` ${r.order_code} ${r.item_name} qty=${r.actual_qty} order_status=${r.order_status} @${t}`);
|
|
});
|
|
|
|
const signToday = await pool.query(
|
|
`SELECT order_code, sign_type, signed_at FROM delivery_signatures
|
|
WHERE signed_at >= ($1::date AT TIME ZONE 'Asia/Shanghai') ORDER BY signed_at DESC`,
|
|
[today]
|
|
);
|
|
console.log('\n--- 今日配送签收 ---', signToday.rowCount);
|
|
signToday.rows.forEach((r) => {
|
|
const t = new Date(r.signed_at).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' });
|
|
console.log(` ${r.order_code} type=${r.sign_type} @${t}`);
|
|
});
|
|
} finally {
|
|
await pool.end();
|
|
}
|