diff --git a/_sql/add_security_id_field.sql b/_sql/add_security_id_field.sql index 51417b0..517baf0 100644 --- a/_sql/add_security_id_field.sql +++ b/_sql/add_security_id_field.sql @@ -19,4 +19,4 @@ CREATE INDEX idx_securityId ON job_postings(securityId); -- ============================================ -- 如果字段已存在,执行 ALTER TABLE 会报错,可以忽略 -- 执行前建议先备份数据库 --- 注意: resume_info 表的 updated_time 字段由框架自动管理,无需手动添加 +-- 注意: resume_info 表的 last_modify_time 字段由框架自动管理,无需手动添加 diff --git a/api/controller_front/task.js b/api/controller_front/task.js index abaa8d4..2e7ef77 100644 --- a/api/controller_front/task.js +++ b/api/controller_front/task.js @@ -213,7 +213,7 @@ module.exports = { * /api/task/statistics: * get: * summary: 获取任务统计 - * description: 根据设备SN码获取任务统计数据(包含今日、本周、本月统计) + * description: 根据设备SN码获取任务统计数据(包含今日获取的岗位列表数量、本周、本月统计) * tags: [前端-任务管理] * parameters: * - in: query @@ -234,7 +234,7 @@ module.exports = { return ctx.fail('请提供设备SN码'); } - const { task_status, op } = await Framework.getModels(); + const { task_status, job_postings, op } = await Framework.getModels(); // 计算时间范围 const now = new Date(); @@ -264,34 +264,31 @@ module.exports = { weekCount, monthCount ] = await Promise.all([ - // 总计 + // 总计(任务总数) task_status.count({ where: { sn_code: sn_code } }), task_status.count({ where: { sn_code: sn_code, status: 'completed' } }), task_status.count({ where: { sn_code: sn_code, status: 'running' } }), task_status.count({ where: { sn_code: sn_code, status: 'pending' } }), task_status.count({ where: { sn_code: sn_code, status: 'failed' } }), - // 今日完成 - task_status.count({ + // 今日获取的岗位列表数量(从job_postings表统计) + job_postings.count({ where: { sn_code: sn_code, - status: 'completed', - updated_time: { [op.gte]: todayStart } + create_time: { [op.gte]: todayStart } } }), - // 本周完成 - task_status.count({ + // 本周获取的岗位列表数量 + job_postings.count({ where: { sn_code: sn_code, - status: 'completed', - updated_time: { [op.gte]: weekStart } + create_time: { [op.gte]: weekStart } } }), - // 本月完成 - task_status.count({ + // 本月获取的岗位列表数量 + job_postings.count({ where: { sn_code: sn_code, - status: 'completed', - updated_time: { [op.gte]: monthStart } + create_time: { [op.gte]: monthStart } } }) ]);