118 lines
4.4 KiB
PHP
118 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
use App\Services\ShjFourCService;
|
|
use App\Services\ShjMailSendService;
|
|
use App\Services\ShjNineService;
|
|
use App\Services\ShjTenService;
|
|
use App\Services\ShjSixService;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* アプリケーションサービスの登録
|
|
*/
|
|
public function register(): void
|
|
{
|
|
// SHJ-4C室割当処理サービスを登録
|
|
$this->app->singleton(ShjFourCService::class, function ($app) {
|
|
return new ShjFourCService(
|
|
$app->make(\App\Models\Park::class),
|
|
$app->make(\App\Models\RegularContract::class),
|
|
$app->make(\App\Models\Batch\BatchLog::class)
|
|
);
|
|
});
|
|
|
|
// SHJメール送信処理サービスを登録
|
|
$this->app->singleton(ShjMailSendService::class, function ($app) {
|
|
return new ShjMailSendService(
|
|
$app->make(\App\Models\MailTemplate::class),
|
|
$app->make(\App\Models\Batch\BatchLog::class)
|
|
);
|
|
});
|
|
|
|
// SHJ-9売上集計処理サービスを登録
|
|
$this->app->singleton(ShjNineService::class, function ($app) {
|
|
return new ShjNineService(
|
|
$app->make(\App\Models\Park::class),
|
|
$app->make(\App\Models\RegularContract::class),
|
|
$app->make(\App\Models\EarningsSummary::class),
|
|
$app->make(\App\Models\Psection::class),
|
|
$app->make(\App\Models\Batch\BatchLog::class),
|
|
$app->make(\App\Models\OperatorQue::class)
|
|
);
|
|
});
|
|
|
|
// SHJ-10財政年度売上集計処理サービスを登録
|
|
$this->app->singleton(ShjTenService::class, function ($app) {
|
|
return new ShjTenService(
|
|
$app->make(\App\Models\Park::class),
|
|
$app->make(\App\Models\RegularContract::class),
|
|
$app->make(\App\Models\EarningsSummary::class),
|
|
$app->make(\App\Models\Psection::class),
|
|
$app->make(\App\Models\Batch\BatchLog::class),
|
|
$app->make(\App\Models\OperatorQue::class)
|
|
);
|
|
});
|
|
|
|
// SHJ-6サーバ死活監視処理サービスを登録
|
|
$this->app->singleton(ShjSixService::class, function ($app) {
|
|
return new ShjSixService(
|
|
$app->make(\App\Models\Device::class),
|
|
$app->make(\App\Models\HardwareCheckLog::class),
|
|
$app->make(\App\Models\PrintJobLog::class),
|
|
$app->make(\App\Models\Batch\BatchLog::class),
|
|
$app->make(\App\Models\OperatorQue::class),
|
|
$app->make(\App\Services\ShjMailSendService::class)
|
|
);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* アプリケーションサービスの初期化
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
view()->composer('layouts.app', function($view){
|
|
|
|
$stats = DB::table('operator_que')
|
|
->selectRaw("
|
|
SUM(CASE WHEN que_status IN (1,2) AND que_class < 100 THEN 1 ELSE 0 END) AS task_total,
|
|
MAX(CASE WHEN que_status IN (1,2) AND que_class < 100 THEN created_at END) AS task_latest,
|
|
SUM(CASE WHEN que_status IN (1,2) AND que_class > 99 THEN 1 ELSE 0 END) AS hard_total,
|
|
MAX(CASE WHEN que_status IN (1,2) AND que_class > 99 THEN created_at END) AS hard_latest
|
|
")
|
|
->first();
|
|
|
|
$taskCount = (int)($stats->task_total ?? 0);
|
|
$hardCount = (int)($stats->hard_total ?? 0);
|
|
$taskLatest = $stats->task_latest ?? null;
|
|
$hardLatest = $stats->hard_latest ?? null;
|
|
|
|
// 最新5件 (未対応/作業中)
|
|
$latestTasks = DB::table('operator_que')
|
|
->whereIn('que_status',[1,2])
|
|
->where('que_class','<',100)
|
|
->orderByDesc('created_at')
|
|
->limit(5)
|
|
->get();
|
|
|
|
$latestHards = DB::table('operator_que')
|
|
->whereIn('que_status',[1,2])
|
|
->where('que_class','>',99)
|
|
->orderByDesc('created_at')
|
|
->limit(5)
|
|
->get();
|
|
|
|
$view->with(compact(
|
|
'taskCount','taskLatest',
|
|
'hardCount','hardLatest',
|
|
'latestTasks','latestHards'
|
|
));
|
|
});
|
|
}
|
|
}
|