1
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
})
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user