liufumingren 1571de341c feat(storage): 新增收货未入库提醒定时任务(货主/客服群通知,短语可配置)
- 新增 app/service/systems/receiving_pending_notice.js:扫描「创建时间超过 min_hours 且不足 max_hours 仍未完成入库」的收货单(wms_receiving 未作废、is_deleted=0,且 status=receiving 或 storage_status<>all),
  按货主聚合成一条消息;未绑定货主的单独一批
- 新增 app/schedule/notice_receiving_pending_inbound.js:每 5 分钟单 worker 检查,按各仓库配置的提醒时间(默认 08:30,宽限 10 分钟覆盖调度抖动)执行,
  进程内防重入 + Redis 当日锁 receiving_pending_notice🔒{warehouseId}:{YYYYMMDD}(NX/EX 24h,执行异常释放锁允许窗口内重试),保证每仓库每天只提醒一次
- 仓库设置新增字段 wms_store.subject_config.receiving_pending_inbound_notice:
  enabled(是否通知收货未入库,flag,默认 0 关闭)/ notice_time(提醒时间 HH:mm,默认 08:30)/ min_hours(超时下限,默认 24)/ max_hours(超时上限,默认 48,须大于 min_hours)
  / notice_template(仓库客服群通知短语)/ store_notice_template(货主群通知短语)
- 通知短语可配置并支持变量替换:{warehouse} {warehouse_id} {store} {store_id} {count} {min_hours} {max_hours} {date} {numbers};
  未识别占位符原样保留,留空回退默认短语,最长 500 字符(超长 400)
- 消息结构统一为「短语 + 换行 + 明细(一行一条,最多 20 行,超出提示剩余单数)+ 快速查看/详情查看链接」,不再在结尾追加句号
- 新增通知事件 receiving_pending_inbound(notification_webhook 事件注册 + notice DEFAULT_REGISTERED_EVENT_CODES)与固定群订阅:
  store:receiving,fallbackTargets=warehouse:customer_service —— 有货主推货主收货群,无货主或货主未配收货群时推仓库客服群(出站仍走 notify.reply,落 wms_inbox_message)
- 文档:methods/system.json 的 setting.warehouse.getSettings/saveSettings 补充该配置字段(版本 0.3.129 -> 0.3.131),
  变更记录新增 2026.09.15-warehouse-pending-receiving-notice / -notice-template(system)、2026-09-15-warehouse-01 / -02(warehouse,事件注册与文案结构);
  AI_METHOD_ROUTING.md 同步刷新(新服务 14 个方法)
- 单测 test/app/service/systems/receiving_pending_notice.test.js(11 用例:开关关闭/未命中提醒时间不执行、超时窗口查询条件、货主群通知、无货主回退客服群、
  当日只提醒一次、推送失败不重复、扫描异常释放锁重试、行数截断、非法配置回退默认、短语变量替换与明细逐行、未识别占位符保留)全部通过;npx eslint 无告警

同时提交上一轮未提交的 camera/PTZ 改动(app/lib/ptz_client.js 新增、systems/camera.js 与 systemMethods/camera.js:PTZ 下发给打印服务时请求体统一携带 cameraId),
其文档与路由清单改动与本提交共用 methods/system.json 等文件,无法按行安全拆分,故合并为一次提交。
2026-09-15 23:49:34 +08:00

117 lines
3.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';
const MainService = require('../main');
class CameraService extends MainService {
constructor(ctx) {
super(ctx);
const _noNeedLogin = '';
const _noNeedRight = 'list,detail,setOsd,ptzControl,ptzStop,ptzPresetGoto,ptzPresetSet';
const _noNeedLog = '*';
const _noNeedAuth = 'list,detail,setOsd,ptzControl,ptzStop,ptzPresetGoto,ptzPresetSet';
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth);
}
async list(data) {
try {
const result = await this.service.systems.camera.list(data || {});
return this.success('获取成功', result);
} catch (e) { return this.fail(e.message); }
}
async detail(data) {
try {
const { id } = data || {};
if (!id) return this.fail('ID不能为空');
return this.success('获取成功', await this.service.systems.camera.detail(parseInt(id)));
} catch (e) { return this.fail(e.message); }
}
async create(data) {
try {
return this.success('创建成功', await this.service.systems.camera.create(data));
} catch (e) { return this.fail(e.message); }
}
async update(data) {
try {
const { id, ...fields } = data || {};
if (!id) return this.fail('ID不能为空');
return this.success('更新成功', await this.service.systems.camera.update(parseInt(id), fields));
} catch (e) { return this.fail(e.message); }
}
async setOsd(data) {
try {
return this.success('设置成功', await this.service.systems.camera.setOsd(data));
} catch (e) { return this.fail(e.message); }
}
/**
* 云台方向控制(按下)
* @param {Object} data - 入参
* @param {number} data.id - 摄像头ID(必填)
* @param {number|string} data.computerId - 打印电脑ID(必填)
* @param {string} data.action - 云台方向(8 个位置,必填)
* @param {number} [data.speed] - 云台转速(1-7,默认 4)
* @return {Promise<Object>} 统一响应
*/
async ptzControl(data) {
try {
return this.success('云台控制成功', await this.service.systems.camera.ptzControl(data));
} catch (e) { return this.fail(e.message); }
}
/**
* 云台停止(松手)
* @param {Object} data - 入参
* @param {number} data.id - 摄像头ID(必填)
* @param {number|string} data.computerId - 打印电脑ID(必填)
* @param {string} data.action - 云台方向(必须与按下时一致,必填)
* @return {Promise<Object>} 统一响应
*/
async ptzStop(data) {
try {
return this.success('云台已停止', await this.service.systems.camera.ptzStop(data));
} catch (e) { return this.fail(e.message); }
}
/**
* 云台预置点跳转
* @param {Object} data - 入参
* @param {number} data.id - 摄像头ID(必填)
* @param {number|string} data.computerId - 打印电脑ID(必填)
* @param {number|string} data.presetId - 预置点编号(1-256,必填)
* @return {Promise<Object>} 统一响应
*/
async ptzPresetGoto(data) {
try {
return this.success('预置点跳转成功', await this.service.systems.camera.ptzPresetGoto(data));
} catch (e) { return this.fail(e.message); }
}
/**
* 云台预置点设置
* @param {Object} data - 入参
* @param {number} data.id - 摄像头ID(必填)
* @param {number|string} data.presetId - 预置点编号(1-256,必填)
* @return {Promise<Object>} 统一响应
*/
async ptzPresetSet(data) {
try {
return this.success('预置点设置成功', await this.service.systems.camera.ptzPresetSet(data));
} catch (e) { return this.fail(e.message); }
}
async delete(data) {
try {
const { id } = data || {};
if (!id) return this.fail('ID不能为空');
await this.service.systems.camera.delete(parseInt(id));
return this.success('删除成功');
} catch (e) { return this.fail(e.message); }
}
}
module.exports = CameraService;