mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
perf: 优化导出任务功能
This commit is contained in:
parent
31879cb60b
commit
25e82d690e
@ -1258,7 +1258,7 @@ class ProjectController extends AbstractController
|
||||
$dialog = WebSocketDialog::checkUserDialog($botUser, $user->userid);
|
||||
//
|
||||
go(function () use ($user, $userid, $time, $type, $botUser, $dialog) {
|
||||
Coroutine::sleep(0.1);
|
||||
Coroutine::sleep(1);
|
||||
$headings = [];
|
||||
$headings[] = Doo::translate('任务ID');
|
||||
$headings[] = Doo::translate('父级任务ID');
|
||||
@ -1394,7 +1394,7 @@ class ProjectController extends AbstractController
|
||||
'type' => 'content',
|
||||
'title' => $content[0]['content'],
|
||||
'content' => $content,
|
||||
], $botUser->userid, false, false, true);
|
||||
], $botUser->userid, true, false, true);
|
||||
return;
|
||||
}
|
||||
//
|
||||
@ -1428,7 +1428,7 @@ class ProjectController extends AbstractController
|
||||
'type' => 'content',
|
||||
'title' => $content[0]['content'],
|
||||
'content' => $content,
|
||||
], $botUser->userid, false, false, true);
|
||||
], $botUser->userid, true, false, true);
|
||||
return;
|
||||
}
|
||||
//
|
||||
@ -1455,7 +1455,7 @@ class ProjectController extends AbstractController
|
||||
'name' => $fileName,
|
||||
'size' => filesize($zipPath),
|
||||
'url' => $fileUrl,
|
||||
], $botUser->userid, false, false, true);
|
||||
], $botUser->userid, true, false, true);
|
||||
} else {
|
||||
$content[] = [
|
||||
'content' => "打包失败,请稍后再试...",
|
||||
@ -1465,9 +1465,15 @@ class ProjectController extends AbstractController
|
||||
'type' => 'content',
|
||||
'title' => $content[0]['content'],
|
||||
'content' => $content,
|
||||
], $botUser->userid, false, false, true);
|
||||
], $botUser->userid, true, false, true);
|
||||
}
|
||||
});
|
||||
//
|
||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||
'type' => 'content',
|
||||
'content' => '正在导出任务统计,请稍等...',
|
||||
], $botUser->userid, true, false, true);
|
||||
//
|
||||
return Base::retSuccess('success');
|
||||
}
|
||||
|
||||
@ -1487,6 +1493,15 @@ class ProjectController extends AbstractController
|
||||
{
|
||||
$user = User::auth('admin');
|
||||
//
|
||||
$botUser = User::botGetOrCreate('system-msg');
|
||||
if (empty($botUser)) {
|
||||
return Base::retError('系统机器人不存在');
|
||||
}
|
||||
$dialog = WebSocketDialog::checkUserDialog($botUser, $user->userid);
|
||||
//
|
||||
go(function () use ($botUser, $dialog, $user) {
|
||||
Coroutine::sleep(1);
|
||||
//
|
||||
$headings = [];
|
||||
$headings[] = Doo::translate('任务ID');
|
||||
$headings[] = Doo::translate('父级任务ID');
|
||||
@ -1501,6 +1516,12 @@ class ProjectController extends AbstractController
|
||||
$headings[] = Doo::translate('创建人');
|
||||
$data = [];
|
||||
//
|
||||
$content = [];
|
||||
$content[] = [
|
||||
'content' => '导出超期任务已完成',
|
||||
'style' => 'font-weight: bold;padding-bottom: 4px;',
|
||||
];
|
||||
//
|
||||
ProjectTask::with(['taskTag'])
|
||||
->whereNull('complete_at')
|
||||
->whereNotNull('end_at')
|
||||
@ -1546,7 +1567,16 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
});
|
||||
if (empty($data)) {
|
||||
return Base::retError('没有任何数据');
|
||||
$content[] = [
|
||||
'content' => '没有任何数据',
|
||||
'style' => 'color: #ff0000;',
|
||||
];
|
||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||
'type' => 'content',
|
||||
'title' => $content[0]['content'],
|
||||
'content' => $content,
|
||||
], $botUser->userid, true, false, true);
|
||||
return;
|
||||
}
|
||||
//
|
||||
$title = Doo::translate('超期任务');
|
||||
@ -1559,7 +1589,16 @@ class ProjectController extends AbstractController
|
||||
$export = new BillMultipleExport($sheets);
|
||||
$res = $export->store($filePath . "/" . $fileName);
|
||||
if ($res != 1) {
|
||||
return Base::retError('导出失败,' . $fileName . '!');
|
||||
$content[] = [
|
||||
'content' => "导出失败,{$fileName}!",
|
||||
'style' => 'color: #ff0000;',
|
||||
];
|
||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||
'type' => 'content',
|
||||
'title' => $content[0]['content'],
|
||||
'content' => $content,
|
||||
], $botUser->userid, true, false, true);
|
||||
return;
|
||||
}
|
||||
$xlsPath = storage_path("app/" . $filePath . "/" . $fileName);
|
||||
$zipFile = "app/" . $filePath . "/" . Base::rightDelete($fileName, '.xls') . ".zip";
|
||||
@ -1576,14 +1615,34 @@ class ProjectController extends AbstractController
|
||||
$base64 = base64_encode(Base::array2string([
|
||||
'file' => $zipFile,
|
||||
]));
|
||||
$fileUrl = Base::fillUrl('api/project/task/down?key=' . urlencode($base64));
|
||||
Session::put('task::export:userid', $user->userid);
|
||||
return Base::retSuccess('success', [
|
||||
'size' => Base::twoFloat(filesize($zipPath) / 1024, true),
|
||||
'url' => Base::fillUrl('api/project/task/down?key=' . urlencode($base64)),
|
||||
]);
|
||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||
'type' => 'file_download',
|
||||
'title' => '导出超期任务已完成',
|
||||
'name' => $fileName,
|
||||
'size' => filesize($zipPath),
|
||||
'url' => $fileUrl,
|
||||
], $botUser->userid, true, false, true);
|
||||
} else {
|
||||
return Base::retError('打包失败,请稍后再试...');
|
||||
$content[] = [
|
||||
'content' => "打包失败,请稍后再试...",
|
||||
'style' => 'color: #ff0000;',
|
||||
];
|
||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||
'type' => 'content',
|
||||
'title' => $content[0]['content'],
|
||||
'content' => $content,
|
||||
], $botUser->userid, true, false, true);
|
||||
}
|
||||
});
|
||||
//
|
||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||
'type' => 'content',
|
||||
'content' => '正在导出超期任务,请稍等...',
|
||||
], $botUser->userid, true, false, true);
|
||||
//
|
||||
return Base::retSuccess('success');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -87,6 +87,9 @@
|
||||
没有任何数据
|
||||
导出失败,(*)!
|
||||
打包失败,请稍后再试...
|
||||
正在导出任务统计,请稍等...
|
||||
导出超期任务已完成
|
||||
正在导出超期任务,请稍等...
|
||||
任务列表不存在或已被删除
|
||||
主任务已完成无法添加子任务
|
||||
子任务不支持此功能
|
||||
|
||||
@ -1639,6 +1639,9 @@ Token
|
||||
导出任务统计已完成
|
||||
没有任何数据
|
||||
打包失败,请稍后再试...
|
||||
正在导出任务统计,请稍等...
|
||||
导出超期任务已完成
|
||||
正在导出超期任务,请稍等...
|
||||
(*)查看了(*)的联系电话
|
||||
标记任务未完成
|
||||
标记任务已完成
|
||||
|
||||
@ -844,11 +844,9 @@ export default {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$store.dispatch("call", {
|
||||
url: 'project/task/exportoverdue',
|
||||
}).then(({data}) => {
|
||||
}).then(() => {
|
||||
resolve();
|
||||
this.$store.dispatch('downUrl', {
|
||||
url: data.url
|
||||
});
|
||||
$A.modalSuccess('正在打包,请留意系统消息。');
|
||||
}).catch(({msg}) => {
|
||||
reject(msg);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user