This commit is contained in:
zhang zhuo 2026-05-27 15:51:24 +08:00
parent 79d55ef669
commit 9014dd0356
9 changed files with 30 additions and 16 deletions

1
.gitignore vendored
View File

@ -18,3 +18,4 @@ composer.lock
/static/export
/static/super
/static/upload
/static/h5

View File

@ -118,7 +118,7 @@ class System extends Base
public function deptList()
{
$dept_name = $this->request->input("dept_name", "");
return $this->success("菜单列表", dModel::list($this->accountId(), $this->account()['account_type'], $dept_name));
return $this->success("菜单列表", dModel::list($this->account()['belong_id'], $this->account()['account_type'], $dept_name));
}
#[GetMapping(path: "dept/option")]

View File

@ -44,6 +44,10 @@ class WebSocket implements OnMessageInterface, OnOpenInterface, OnCloseInterface
public function onOpen($server, $request): void
{
$token = $request->get['Authorization'];
if (!$token) {
$server->push($request->fd, 'connection refused');
return;
}
$result = Token::parseToken(str_replace("Bearer ", "", $token));
$container = ApplicationContext::getContainer();
$cache = $container->get(CacheInterface::class);

View File

@ -11,7 +11,7 @@ use App\Model\Message as mModel;
class FileExportJob extends Job
{
protected int $maxAttempts = 1;
protected int $maxAttempts = 0;
protected int $attachmentId;
public function __construct(array $params)
@ -40,8 +40,6 @@ class FileExportJob extends Job
return aModel::edit(['attachment_id' => $this->attachmentId, 'status' => 2, 'fail_reason' => "导出失败"]);
}
aModel::edit(['attachment_id' => $this->attachmentId, 'status' => 1, 'type' => $type, 'path' => $res]);
// 导出成功,消息通知
$data['type'] = 'system';
$id = mModel::add([
'type' => 'attach',
'title' => $attach->name . " [执行成功]",
@ -58,6 +56,15 @@ class FileExportJob extends Job
'status' => 2,
'fail_reason' => $e->getMessage()
]);
$id = mModel::add([
'type' => 'attach',
'title' => $attach->name . " [执行失败]",
'content' => '执行失败',
'create_id' => $attach->account_id,
]);
if ($id) {
QueueClient::push("App\Job\NotifyJob", ['messageId' => $id, 'channels' => ['websocket', 'email'], 'userIds' => [$attach->account_id]]);
}
}
return true;
}

View File

@ -42,7 +42,6 @@ class JWTMiddleware implements MiddlewareInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$container = ApplicationContext::getContainer();
// 管理端 和 商户端
$request = $request->withAttribute("isLogin", false);
$request = $request->withAttribute("account", []);

View File

@ -4,7 +4,6 @@ namespace App\Utils;
use Exception;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use function Hyperf\Config\config;
@ -17,14 +16,18 @@ class Excel
{
try {
if (!$file) return false;
$file = BASE_PATH . DIRECTORY_SEPARATOR . 'runtime' . DIRECTORY_SEPARATOR . $file;
if (!file_exists($file)) return false;
// 显式使用 Xlsx 读取器并配置兼容选项
$reader = new Xlsx();
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
// 关键配置:跳过样式/公式等兼容性陷阱
$reader->setReadDataOnly(true); // 只读数据,忽略公式
$reader->setReadEmptyCells(false); // 跳过空单元格处理
$reader->setLoadSheetsOnly(["Sheet1"]); // 明确加载指定工作表
// 处理大文件内存问题
$memoryLimit = (int)ini_get('memory_limit') * 1024 * 1024;
if (filesize($file) > $memoryLimit * 0.3) {
\PhpOffice\PhpSpreadsheet\Settings::setCache(new \PhpOffice\PhpSpreadsheet\Cache\Filesys());
}
$spreadsheet = $reader->load($file);
return $spreadsheet->getSheet(0)->toArray();
} catch (Exception $e) {

View File

@ -7,7 +7,6 @@ namespace App\Utils;
use App\Exception\ServiceException;
use function Hyperf\Config\config;
use function PHPUnit\Framework\matches;
class Str
{

View File

@ -58,7 +58,8 @@
},
"autoload": {
"psr-4": {
"App\\": "app/"
"App\\": "app/",
"Plugins\\": "plugins/"
},
"files": [
"app/Utils/helpers.php"

View File

@ -59,9 +59,9 @@ return [
Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024,
Constant::OPTION_PACKAGE_MAX_LENGTH => 50 * 1024 * 1024,
'document_root' => BASE_PATH . '/static',
'enable_static_handler' => true,
'http_index_files' => ['index.html'],
Constant::OPTION_DOCUMENT_ROOT => BASE_PATH . '/static',
Constant::OPTION_ENABLE_STATIC_HANDLER => true,
Constant::OPTION_HTTP_INDEX_FILES => ['index.html'],
],
'callbacks' => [
Event::ON_BEFORE_START => [Hyperf\Framework\Bootstrap\ServerStartCallback::class, 'beforeStart'],