Skip to content

Commit

Permalink
Merge commit 'fb8d759103d8468e6ef51f18d1c5f31a2b3e6a89' into pro
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Jan 4, 2024
2 parents b4b268a + fb8d759 commit 85ceb8b
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 43 deletions.
30 changes: 15 additions & 15 deletions app/Http/Controllers/Api/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,12 @@ public function download__pack()
return Base::retError('一次最多可以下载100个文件或文件夹');
}

$botUser = User::botGetOrCreate('system-msg');
if (empty($botUser)) {
return Base::retError('系统机器人不存在');
}
$dialog = WebSocketDialog::checkUserDialog($botUser, $user->userid);

$files = [];
$totalSize = 0;

Expand All @@ -1053,7 +1059,7 @@ public function download__pack()
return Base::retError('创建压缩文件失败');
}

go(function () use ($zipPath, $fileUrl, $user, $zip, $files, $fileName, $zipFile) {
go(function () use ($zipPath, $fileUrl, $zip, $files, $fileName, $botUser, $dialog) {
Coroutine::sleep(0.1);
// 压缩进度
$progress = 0;
Expand All @@ -1079,20 +1085,14 @@ public function download__pack()
]);
}
//
$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 .= '<a href="' . $fileUrl . '" target="_blank"><button type="button" class="ivu-btn ivu-btn-warning" style="margin-top: 10px;"><span>立即下载</span></button></a>';
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid, false, false, true);
}
$text = "<b>文件下载打包已完成。</b>";
$text .= "\n\n";
$text .= "文件名:{$fileName}";
$text .= "\n";
$text .= "文件大小:".Base::twoFloat(filesize($zipPath) / 1024, true)."KB";
$text .= "\n";
$text .= '<a href="' . $fileUrl . '" target="_blank"><button type="button" class="ivu-btn ivu-btn-warning" style="margin-top: 10px;"><span>立即下载</span></button></a>';
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid, false, false, true);
});
return Base::retSuccess('success', [
'name' => $fileName,
Expand Down
46 changes: 27 additions & 19 deletions app/Http/Controllers/Api/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,13 @@ public function task__export()
if (Carbon::parse($time[1])->timestamp - Carbon::parse($time[0])->timestamp > 90 * 86400) {
return Base::retError('时间范围限制最大90天');
}
go(function () use ($user, $userid, $time, $type) {
$botUser = User::botGetOrCreate('system-msg');
if (empty($botUser)) {
return Base::retError('系统机器人不存在');
}
$dialog = WebSocketDialog::checkUserDialog($botUser, $user->userid);
//
go(function () use ($user, $userid, $time, $type, $botUser, $dialog) {
Coroutine::sleep(0.1);
$headings = [];
$headings[] = '任务ID';
Expand All @@ -1221,6 +1227,9 @@ public function task__export()
$headings[] = '状态';
$datas = [];
//
$text = '<b>导出任务统计已完成。</b>';
$text .= "\n\n";
//
$builder = ProjectTask::select(['project_tasks.*', 'project_task_users.userid as ownerid'])
->join('project_task_users', 'project_tasks.id', '=', 'project_task_users.task_id')
->where('project_task_users.owner', 1)
Expand Down Expand Up @@ -1318,7 +1327,9 @@ public function task__export()
}
});
if (empty($datas)) {
return Base::retError('没有任何数据');
$text .= '没有任何数据';
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid, false, false, true);
return;
}
//
$sheets = [];
Expand All @@ -1334,15 +1345,18 @@ public function task__export()
//
$fileName = User::userid2nickname($userid[0]) ?: $userid[0];
if (count($userid) > 1) {
$fileName .= "" . count($userid) . "位成员";
$fileName .= '' . count($userid) . '位成员任务统计';
}
$fileName .= '任务统计_' . Base::time() . '.xls';
$fileName .= '_' . Base::time() . '.xls';
$filePath = "temp/task/export/" . date("Ym", Base::time());
$export = new BillMultipleExport($sheets);
$res = $export->store($filePath . "/" . $fileName);
if ($res != 1) {
return Base::retError('导出失败,' . $fileName . '');
$text .= "导出失败,{$fileName}";
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid, false, false, true);
return;
}
//
$xlsPath = storage_path("app/" . $filePath . "/" . $fileName);
$zipFile = "app/" . $filePath . "/" . Base::rightDelete($fileName, '.xls') . ".zip";
$zipPath = storage_path($zipFile);
Expand All @@ -1360,21 +1374,15 @@ public function task__export()
]));
$fileUrl = Base::fillUrl('api/project/task/down?key=' . urlencode($base64));
Session::put('task::export:userid', $user->userid);
$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 .= '<a href="' . $fileUrl . '" target="_blank"><button type="button" class="ivu-btn ivu-btn-warning" style="margin-top: 10px;"><span>立即下载</span></button></a>';
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid, false, false, true);
}
$text .= "文件名:{$fileName}";
$text .= "\n";
$text .= "文件大小:" . Base::twoFloat(filesize($zipPath) / 1024, true) . "KB";
$text .= "\n";
$text .= '<a href="' . $fileUrl . '" target="_blank"><button type="button" class="ivu-btn ivu-btn-warning" style="margin-top: 10px;"><span>立即下载</span></button></a>';
} else {
$text .= '打包失败,请稍后再试...';
}
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid, false, false, true);
});
return Base::retSuccess('success', ['msg' => '正在打包,请留意系统消息。']);
}
Expand Down
2 changes: 2 additions & 0 deletions language/original-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -482,3 +482,5 @@ Api接口文档
移动成功

不能重复投票

系统机器人不存在
11 changes: 11 additions & 0 deletions language/translate.json
Original file line number Diff line number Diff line change
Expand Up @@ -19523,5 +19523,16 @@
"de": "Lade deine taschen herunter (*)",
"fr": "Pack à télécharger (*)",
"id": "Kemas tas untuk download (*)"
},
{
"key": "系统机器人不存在",
"zh": "",
"zh-CHT": "系統機器人不存在",
"en": "Systematic robots do not exist",
"ko": "시스템 로봇은 존재하지 않습니다",
"ja": "システムロボットは存在しません",
"de": "Roboter existieren nicht",
"fr": "Le robot système n’existe pas",
"id": "Robot sistem tidak ada"
}
]
2 changes: 1 addition & 1 deletion public/language/api/de.json

Large diffs are not rendered by default.

Loading

0 comments on commit 85ceb8b

Please sign in to comment.