diff --git a/Laravel/app/Http/Controllers/API/Admin/ConfigController.php b/Laravel/app/Http/Controllers/API/Admin/ConfigController.php index 1882c9a..3b2997d 100644 --- a/Laravel/app/Http/Controllers/API/Admin/ConfigController.php +++ b/Laravel/app/Http/Controllers/API/Admin/ConfigController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\API\Admin; use App\Http\Controllers\Controller; use App\Services\ConfigService; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; class ConfigController extends Controller { @@ -12,7 +13,17 @@ class ConfigController extends Controller //获取站点配置信息 public function GetConfigInfo(){ $configs = new ConfigService(); - return $configs->GetConfigInfo(['站点名称','站点图片','门诊缴费超时时间','门诊缴费轮询间隔']); + $config_arrs = request('config_arrs'); + if(!isset($config_arrs) || empty($config_arrs)){ + $config_arrs =['站点名称','站点图片','门诊缴费超时时间','门诊缴费轮询间隔']; + } + return $configs->GetConfigInfo($config_arrs); + } + public function GetConfigInfo2(){ + $config_arrs = request('config_arrs'); + $q=DB::table('configs')->select(['label','value'])->whereIn('label',$config_arrs)->get(); + return \Yz::JsonReturn(true,"查询完成",['list'=>$q]); + } public function SaveConfig(){ $info = request('info'); diff --git a/Laravel/app/Http/Controllers/API/PdfController.php b/Laravel/app/Http/Controllers/API/PdfController.php new file mode 100644 index 0000000..4abad0a --- /dev/null +++ b/Laravel/app/Http/Controllers/API/PdfController.php @@ -0,0 +1,96 @@ +where(['a.entrust_id'=>$orderNo,'a.list_status'=>1,'a.is_nullify'=>0])->first(); + $url=""; + if(!!$entrustInfo) $url=env('APP_URL') .$entrustInfo->check_aply_pdf ; + $list[] = [ + 'OrderNo' => $orderNo, + 'PdfUrl' => $url, + ]; + } + return \Yz::JsonReturn(true, '查询完成', ['list' => $list]); + } + + //创建检查申请单pdf文件 + public function CreateJianChaShenQingDanPdf() + { + $OrderNoList = request('OrderNoList');//医嘱号列表(数组) + if (!isset($OrderNoList) or empty($OrderNoList)) return \Yz::JsonReturn("OrderNoList,不能为空"); + if (!is_array($OrderNoList)) return \Yz::JsonReturn("OrderNoList,应为数组"); + $config=DB::table('configs')->where(['label'=>'开启申请单pdf'])->first(); + if (!$config or $config->value<>1) return \Yz::JsonError("未开启申请单pdf"); + $generator = new \Picqer\Barcode\BarcodeGeneratorHTML(); + $successCount=0; + foreach ($OrderNoList as $orderNo) { + $entrustInfo=DB::table('s_list as a')->where(['a.entrust_id'=>$orderNo,'a.list_status'=>1,'a.is_nullify'=>0]) + ->select('a.*','c.period_begin_time','c.period_end_time') + ->leftJoin('s_period as c','a.reservation_time','=','c.id') + ->first(); + if(!$entrustInfo) continue; + $tiaoma = $generator->getBarcode($entrustInfo->app_num, $generator::TYPE_CODE_128, 2, 40); + + $source=null; + if(!empty($entrustInfo->reservation_sources)){ + $source=DB::table('s_department_resources')->where(['id'=>$entrustInfo->reservation_sources])->first(); + } + $entrustInfo->department_resources=$source; + $entrustInfo->user_sex_label=''; + if($entrustInfo->user_sex==1){ + $entrustInfo->user_sex_label='男'; + } + if($entrustInfo->user_sex==2){ + $entrustInfo->user_sex_label='女'; + } + $entrustInfo->age=\Tools::getAgeFromBirthday($entrustInfo->user_brithday); + //患者类型 + $p_type=config('app.globals.患者类型'); + $entrustInfo->patient_type_label=$p_type[$entrustInfo->patient_type] ?? ''; + //星期 + $entrustInfo->weekday_label=\Tools::GetWeekName($entrustInfo->reservation_date); + + // 准备数据 + $data = [ + 'printInfo' =>$entrustInfo, + 'barcode' => $tiaoma, + ]; + + $filePath = storage_path('app/public/CheckPdf/' . date('Ymd') . '/' . $orderNo . '.pdf'); +// 检查文件是否存在,存在则删除 + if (File::exists($filePath)) { + File::delete($filePath); + } +// 生成并保存新文件 + $pdf = SnappyPdf::loadView('pdf.JianChaShenQingDan', $data) + ->setOption('page-size', 'a5') + // 设置方向(portrait 纵向 / landscape 横向) + ->setOption('orientation', 'landscape'); + $pdf->save($filePath); + $fileUrl = Storage::url('CheckPdf/' . date('Ymd') . '/' . $orderNo . '.pdf'); + DB::table('s_list')->where('entrust_id', $orderNo)->update(['check_aply_pdf' => $fileUrl]); + $successCount++; + } + + return \Yz::JsonReturn(true, '生成检查申请单pdf成功', ['success_count' => $successCount]); + + + } + +} diff --git a/Laravel/composer.json b/Laravel/composer.json index a4eb26c..f1394f9 100644 --- a/Laravel/composer.json +++ b/Laravel/composer.json @@ -6,6 +6,7 @@ "license": "MIT", "require": { "php": "^7.4|^8.0", + "barryvdh/laravel-snappy": "^1.0", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "laravel/framework": "^8.75", diff --git a/Laravel/composer.lock b/Laravel/composer.lock index 6eb020c..23fb4ea 100644 --- a/Laravel/composer.lock +++ b/Laravel/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f37155ab1899ea3d5b3c56dba1cf5e92", + "content-hash": "091dac62fedbd23925a364176d123da9", "packages": [ { "name": "asm89/stack-cors", @@ -68,6 +68,84 @@ }, "time": "2022-01-18T09:12:03+00:00" }, + { + "name": "barryvdh/laravel-snappy", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-snappy.git", + "reference": "2c18a3602981bc6f25b32908cf8aaa05952ab2f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-snappy/zipball/2c18a3602981bc6f25b32908cf8aaa05952ab2f7", + "reference": "2c18a3602981bc6f25b32908cf8aaa05952ab2f7", + "shasum": "" + }, + "require": { + "illuminate/filesystem": "^6|^7|^8|^9", + "illuminate/support": "^6|^7|^8|^9", + "knplabs/knp-snappy": "^1", + "php": ">=7.2" + }, + "require-dev": { + "orchestra/testbench": "^4|^5|^6|^7" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "PDF": "Barryvdh\\Snappy\\Facades\\SnappyPdf", + "SnappyImage": "Barryvdh\\Snappy\\Facades\\SnappyImage" + }, + "providers": [ + "Barryvdh\\Snappy\\ServiceProvider" + ] + }, + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\Snappy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Snappy PDF/Image for Laravel", + "keywords": [ + "image", + "laravel", + "pdf", + "snappy", + "wkhtmltoimage", + "wkhtmltopdf" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-snappy/issues", + "source": "https://github.com/barryvdh/laravel-snappy/tree/v1.0.0" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2022-01-29T19:36:49+00:00" + }, { "name": "brick/math", "version": "0.9.3", @@ -1032,6 +1110,80 @@ ], "time": "2023-08-03T15:06:02+00:00" }, + { + "name": "knplabs/knp-snappy", + "version": "v1.4.4", + "source": { + "type": "git", + "url": "https://github.com/KnpLabs/snappy.git", + "reference": "3db13fe45d12a7bccb2b83f622e5a90f7e40b111" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/KnpLabs/snappy/zipball/3db13fe45d12a7bccb2b83f622e5a90f7e40b111", + "reference": "3db13fe45d12a7bccb2b83f622e5a90f7e40b111", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/log": "^1.0||^2.0||^3.0", + "symfony/process": "~3.4||~4.3||~5.0||~6.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.16||^3.0", + "pedrotroller/php-cs-custom-fixer": "^2.19", + "phpstan/phpstan": "^1.0.0", + "phpstan/phpstan-phpunit": "^1.0.0", + "phpunit/phpunit": "~7.4||~8.5" + }, + "suggest": { + "h4cc/wkhtmltoimage-amd64": "Provides wkhtmltoimage-amd64 binary for Linux-compatible machines, use version `~0.12` as dependency", + "h4cc/wkhtmltoimage-i386": "Provides wkhtmltoimage-i386 binary for Linux-compatible machines, use version `~0.12` as dependency", + "h4cc/wkhtmltopdf-amd64": "Provides wkhtmltopdf-amd64 binary for Linux-compatible machines, use version `~0.12` as dependency", + "h4cc/wkhtmltopdf-i386": "Provides wkhtmltopdf-i386 binary for Linux-compatible machines, use version `~0.12` as dependency", + "wemersonjanuario/wkhtmltopdf-windows": "Provides wkhtmltopdf executable for Windows, use version `~0.12` as dependency" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Knp\\Snappy\\": "src/Knp/Snappy" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "KNP Labs Team", + "homepage": "http://knplabs.com" + }, + { + "name": "Symfony Community", + "homepage": "http://github.com/KnpLabs/snappy/contributors" + } + ], + "description": "PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage.", + "homepage": "http://github.com/KnpLabs/snappy", + "keywords": [ + "knp", + "knplabs", + "pdf", + "snapshot", + "thumbnail", + "wkhtmltopdf" + ], + "support": { + "issues": "https://github.com/KnpLabs/snappy/issues", + "source": "https://github.com/KnpLabs/snappy/tree/v1.4.4" + }, + "time": "2023-09-13T12:18:19+00:00" + }, { "name": "laravel/framework", "version": "v8.83.27", diff --git a/Laravel/config/app.php b/Laravel/config/app.php index 7e18451..dcf2386 100644 --- a/Laravel/config/app.php +++ b/Laravel/config/app.php @@ -191,6 +191,7 @@ return [ App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, App\Providers\SoapServiceProvider::class, + Barryvdh\Snappy\ServiceProvider::class, ], /* @@ -245,7 +246,6 @@ return [ 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, - ], ]; diff --git a/Laravel/config/snappy.php b/Laravel/config/snappy.php new file mode 100644 index 0000000..01a6d92 --- /dev/null +++ b/Laravel/config/snappy.php @@ -0,0 +1,52 @@ + [ + 'enabled' => true, + 'binary' => '"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe"', + 'timeout' => false, + 'options' => [], + 'env' => [], + ], + + 'image' => [ + 'enabled' => true, + 'binary' => '"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltoimage.exe"', + 'timeout' => false, + 'options' => [], + 'env' => [], + ], + +]; diff --git a/Laravel/resources/views/pdf/JianChaShenQingDan.blade.php b/Laravel/resources/views/pdf/JianChaShenQingDan.blade.php new file mode 100644 index 0000000..ef55c3f --- /dev/null +++ b/Laravel/resources/views/pdf/JianChaShenQingDan.blade.php @@ -0,0 +1,103 @@ + + +
+ +| 姓名:{{$printInfo->user_name}} | +性别:{{$printInfo->user_sex_label}} | +年龄:{{$printInfo->age}} | +病人类型:{{$printInfo->patient_type_label}} | +
| + {{$printInfo->patient_type_label}}号:{{$printInfo->reg_num}} + | + @if($printInfo->patient_type==0)病区:{{$printInfo->warddesc ?? ''}} | +床号:{{$printInfo->bedno ?? ''}} | @endif +联系电话:{{$printInfo->user_phone}} | +
| 温馨提示: | +
+ 1、预约后请您及时缴费,门诊患者预约成功后60分钟内不缴费,系统会自动取消您的预约申请。自动取消后,如需继续预约,请到相关检查科室重新预约。
+ 2、预约时间为8点~10点的,请8点到登记处签到,预约时间为10点~12点的,请10点前到登记处签到,便于工作人员进行检查评估和准备。
+ 3、预约时间不是实际检查时间,以现场登记后排队号为准。
+ |
+