fix: fetchTasks 时间转为 ISO 8601 +08:00 格式

This commit is contained in:
liufumingren 2026-07-27 02:36:06 +08:00
parent 82d0271ee2
commit 8dbc238acf

View File

@ -8,6 +8,18 @@ const BaseService = require('./base');
* hikvision.taskComplete - 任务完成回调,写入结果
*/
class HikvisionService extends BaseService {
/**
* 将 MySQL DATETIME 字符串转为 ISO 8601 带时区偏移 (+08:00)
* 输入: "2026-07-26 11:08:48" → 输出: "2026-07-26T11:08:48+08:00"
*/
_toISO(datetime) {
if (!datetime) return null;
const str = String(datetime).trim();
// 如果已经是 ISO 格式就不要再转
if (str.includes('T')) return str.replace('Z', '+08:00');
return str.replace(' ', 'T') + '+08:00';
}
/**
* 拉取待录像任务
* 查询 wms_pack_task 中 pack_mode=1 且无录像记录的任务
@ -106,8 +118,8 @@ class HikvisionService extends BaseService {
wave_no: task.wave_no,
waybill_code: task.waybill_code,
task_status: task.task_status,
start_time: task.start_time,
end_time: task.end_time,
start_time: this._toISO(task.start_time),
end_time: this._toISO(task.end_time),
operator: task.operator_text,
camera: {
id: matchedCamera.id,