perf: 优化导出任务统计

This commit is contained in:
ganzizi 2023-12-06 11:57:29 +08:00
parent faf5dec08a
commit f5a068fffc
2 changed files with 164 additions and 152 deletions

View File

@ -12,6 +12,7 @@ use App\Module\Doo;
use App\Models\File;
use App\Models\User;
use App\Module\Base;
use Swoole\Coroutine;
use App\Models\Deleted;
use App\Models\Project;
use App\Module\TimeRange;
@ -32,6 +33,7 @@ use App\Models\WebSocketDialog;
use App\Exceptions\ApiException;
use App\Models\ProjectPermission;
use App\Module\BillMultipleExport;
use App\Models\WebSocketDialogMsg;
use Illuminate\Support\Facades\DB;
use App\Models\ProjectTaskFlowChange;
@ -1189,6 +1191,8 @@ class ProjectController extends AbstractController
if (Carbon::parse($time[1])->timestamp - Carbon::parse($time[0])->timestamp > 90 * 86400) {
return Base::retError('时间范围限制最大90天');
}
go(function() use ($user, $userid, $time, $type) {
Coroutine::sleep(0.1);
$headings = [];
$headings[] = '任务ID';
$headings[] = '父级任务ID';
@ -1346,13 +1350,23 @@ class ProjectController extends AbstractController
'file' => $zipFile,
]));
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)),
]);
} else {
return Base::retError('打包失败,请稍后再试...');
$botUser = User::botGetOrCreate('system-msg');
if (empty($botUser)) {
return;
}
if ($dialog = WebSocketDialog::checkUserDialog($botUser, $user->userid)) {
$text = "<b>导出任务统计已完成。</b>";
$text .= "\n\n";
$text .= "文件名:{$fileName}";
$text .= "\n";
$text .= "文件大小:".Base::twoFloat(filesize($zipPath) / 1024, true)."KB";
$text .= "\n";
$text .= "下载地址:".Base::fillUrl('api/project/task/down?key=' . urlencode($base64));
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid, false, false, true);
}
}
});
return Base::retSuccess('success',['msg' => '正在打包,请留意系统消息']);
}
/**

View File

@ -102,9 +102,7 @@ export default {
data: this.formData,
}).then(({data}) => {
this.show = false;
this.$store.dispatch('downUrl', {
url: data.url
});
$A.messageSuccess(data.msg);
}).catch(({msg}) => {
$A.modalError(msg);
}).finally(_ => {