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