diff --git a/backend/src/jobs/warehouseLogisticsExceptionNotifyJob.js b/backend/src/jobs/warehouseLogisticsExceptionNotifyJob.js index 0663c70..5fac23f 100644 --- a/backend/src/jobs/warehouseLogisticsExceptionNotifyJob.js +++ b/backend/src/jobs/warehouseLogisticsExceptionNotifyJob.js @@ -9,6 +9,8 @@ * ② 不发 .xlsx 附件 —— 群机器人 webhook 发不了文件,业务也确认群里看文本就够。 * 内容 = 汇总(发货/异常/异常率/分类型/分仓)+ 前 N 条明细 + 页面链接。 * N 由页面配置(默认 30,上限 50);要全部明细就点链接去页面导出 Excel。 + * 明细一行 = 仓|内部单号|快递|异常类型|待处理小时数。 + * ⚠️ **不带发货时间**(业务 2026-10-22 要求),别再加 sendTime 回去。 * ③ 消息里**必须带「异常」字样**:钉钉群机器人若用「自定义关键词」安全设置, * 关键词一般是「异常」,缺了会被拒(errcode 310000)。 * ④ 一天只推一次:状态存 system_config,按「推送日(北京时间)」去重, @@ -74,29 +76,23 @@ function cleanCell(value, fallback = '') { return text || fallback; } -/** '2026-10-21 16:00:00' → '10-21 16:00';空值给「—」 */ -function shortTime(value) { - const text = cleanCell(value); - if (!text) return '—'; - const match = text.match(/^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})/); - if (!match) return text.slice(0, 16); - return `${match[2]}-${match[3]} ${match[4]}:${match[5]}`; -} - function formatHours(value) { const num = Number(value); if (!Number.isFinite(num)) return '—'; return `${Math.round(num * 10) / 10}h`; } -/** 明细一行:仓|内部单号|快递|异常类型|发货时间|待处理 */ +/** + * 明细一行:仓|内部单号|快递|异常类型|待处理小时数 + * ⚠️ 业务明确要求明细**不带发货时间**(20-22 反馈),别再加 sendTime 回去 —— + * 仓库看单子只需知道「哪个单、什么异常、压了多久」,发货时间在页面上看。 + */ function buildDetailLine(row, index) { const parts = [ cleanCell(row?.warehouseName, '未知仓'), cleanCell(row?.oId, '无单号'), cleanCell(row?.carrier, '未知快递'), cleanCell(row?.exceptionLabel, '异常'), - shortTime(row?.sendTime), formatHours(row?.pendingHours), ]; return `${index}. ${parts.join('|')}`; @@ -428,6 +424,5 @@ module.exports = { cleanCell, pushWarehouseLogisticsExceptionNotify, runWarehouseLogisticsExceptionNotifyJob, - shortTime, startWarehouseLogisticsExceptionNotifyScheduler, }; diff --git a/backend/test/warehouseLogisticsExceptionNotify.test.js b/backend/test/warehouseLogisticsExceptionNotify.test.js index 1864c31..2883c17 100644 --- a/backend/test/warehouseLogisticsExceptionNotify.test.js +++ b/backend/test/warehouseLogisticsExceptionNotify.test.js @@ -118,7 +118,7 @@ test('群消息正文:抬头带「异常」关键词、数字与分类型、 assert.equal(built.truncated, false); }); -test('明细行:仓|内部单号|快递|异常类型|发货时间|待处理,字段里换行要压平', () => { +test('明细行:仓|内部单号|快递|异常类型|待处理(不带发货时间),字段里换行要压平', () => { const line = job.buildDetailLine({ warehouseName: '崔桥工厂仓', oId: '9845001', @@ -129,14 +129,17 @@ test('明细行:仓|内部单号|快递|异常类型|发货时间| lastLogisticInfo: '第一行\n第二行', }, 3); - assert.equal(line, '3. 崔桥工厂仓|9845001|京东快递|已揽收未中转|10-21 16:00|17.3h'); + assert.equal(line, '3. 崔桥工厂仓|9845001|京东快递|已揽收未中转|17.3h'); + // 业务要求:明细不带发货时间(哪怕传了 sendTime 也不能出现在消息里) + assert.ok(!line.includes('10-21'), '明细行不该再带发货时间'); + assert.ok(!line.includes('16:00'), '明细行不该再带发货时间'); // 物流描述里的换行不能漏进消息(会把一条明细劈成两行,看着像两条异常) assert.equal(job.cleanCell('甲\n乙\t丙 丁'), '甲 乙 丙 丁'); // 空值兜底:不能让消息里出现「undefined|null」 assert.equal( job.buildDetailLine({}, 1), - '1. 未知仓|无单号|未知快递|异常|—|—' + '1. 未知仓|无单号|未知快递|异常|—' ); });