create report views

This commit is contained in:
2025-01-22 11:25:57 +03:30
parent 03fd210671
commit e6dcd36fc9
5 changed files with 222 additions and 54 deletions

View File

@@ -26,52 +26,77 @@ enum InfoItem: int
public static function subItems(int $item): array
{
$subitems = [
1 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
2 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
3 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
4 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
5 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
6 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
7 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
8 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
9 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
10 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
11 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
12 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
13 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
14 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
15 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
16 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
17 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
20 => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13],
1 => [1 => 'LabeAsphalt', 2 => 'ShaneSazi', 3 => 'GodOftadegi', 4 => 'Lakegiri',
5 => 'Maremat', 6 => 'BastarHarim', 8 => 'Darzgiri', 9 => 'Mozres',
10 => 'TarashRooye', 11 => 'Tighzani', 12 => 'Shenrizi', 13 => 'Khakbardari',
14 => 'TaranesheBardary'
],
2 => [1 => 'PaksaziSathRah', 2 => 'TanfieAbro', 3 => 'PaksaziLashe', 4 => 'PaksaziGhono',
5 => 'PaksaziTasadofat', 6 => 'AlafKani', 7 => 'PaksaziHarim', 8 => 'JamavariGhateat',
9 => 'PaksaziParking', 10 => 'PaksaziKenarGharnizPol', 11 => 'PaksaziJazire',
12 => 'PaksaziTanfieDakhelPol', 13 => 'PaksaziSifon', 14 => 'PaksaziShakheDerakhtan', 15 => 'PaksaziMavadNafti',
16 => 'AlafKaniDasti', 17 => 'RizeshBardari', 18 => 'JamavariSang', 19 => 'Layeroobi'
],
3 => [1 => 'TabloEkhtari', 2 => 'TabloEtelati', 3 => 'Shabrang', 4 => 'Baztab', 5 => 'TavizTablo',
6 => 'Maremat', 7 => 'EslahKajShodegi', 8 => 'NasbAlaemMovaghat', 9 => 'ShibShirvani'
],
4 => [1 => 'Miani', 2 => 'Pol', 3 => 'Behsazi'],
5 => [1 => 'NegahdariTool', 2 => 'NegahdariHashieh', 3 => 'NegahdariNoghteyi', 4 => 'NegahdariNavahi',
5 => 'NegahdariMehgir', 6 => 'NegahdariToonel', 7 => 'TamiratCable', 8 => 'TamiratKaleCheragh',
9 => 'TamiratMafselzani', 10 => 'TamiratTablo', 11 => 'TamiratBorjNoori'
],
6 => [1 => 'KhatkeshiRangGarm', 2 => 'KhatkeshiRangSard', 3 => 'TarsimKhat',
4 => 'EjrayeTooli', 5 => 'EjrayeArzi', 6 => 'PakKardanKhotoot'
],
7 => [1 => 'RangamiziTablo', 2 => 'RangamiziCheraq', 3 => 'RangimiziPayeRoshanayi', 4 => 'RangamiziPol',
5 => 'RangamiziDarvazi', 6 => 'RangamiziHefazFelezi', 7 => 'RangamiziNewjersi', 8 => 'RangamiziSoratgah', 9 => 'RangamiziPaye'
],
8 => [1 => 'ShosteshooAlaem', 2 => 'ShosteshooTablo', 3 => 'ShosteshooJadval', 4 => 'ShosteshooNewjersi',
5 => 'ShosteshooGuardrail', 6 => 'ShosteshooToonel', 7 => 'ShosteshooPol'
],
9 => [1 => 'ImensaziSarguard', 4 => ' TamiratCheraq', 5 => 'IjadShiar',
6 => 'Zarbegir', 7 => 'NasbSoratgir', 8 => 'IjadLarzanande',
9 => 'OstevaneImeni', 11 => 'EhdasSoratgir', 12 => 'EjrayeNoghteyi',
13 => 'EjrayeTooli', 14 => 'TarizMaghtaei', 15 => 'HazfMavane', 16 => 'DivarChini'
],
10 => [4 => 'BarkhordBaDastfroosh', 5 => 'JamavariTabloo', 6 => 'JamavariBanner'],
11 => [1 => 'EhdasGharnizPol', 2 => 'Lole', 3 => 'Tatvil', 4 => 'Bazsazi',
5 => 'TamiratAbro', 6 => 'Maremat', 7 => 'Radie'
],
12 => [1 => 'Zehkeshi', 2 => 'Maremat', 3 => 'Lining', 4 => 'TamirGallery',
5 => 'Gabarit', 6 => 'Doorbin', 7 => 'Tahvie'
],
13 => [1 => 'Yakhzodaei', 2 => 'BarfRoobi',
5 => 'MizanNamak', 7 => 'Mosaferin', 8 => 'KomakResani'
],
14 => [1 => 'BenzinMasrafi', 2 => 'GazMasrafi', 3 => 'MavadNafti', 4 => 'Bazsazi',
8 => 'Service', 9 => 'NamakPash', 10 => 'Jabejayi'
],
15 => [1 => 'Tamirat', 3 => 'Jalasat'],
16 => [1 => 'Paksazi', 2 => 'Taradod', 3 => 'BargharariErtebat', 4 => 'AbBordegi',
5 => 'ShekastegiPol', 6 => 'HedayatTraffici', 7 => 'Bozgoshaei', 8 => 'Jabejayi', 9 => 'Laghgiri'
],
20 => [1 => 'AbniyeFani', 2 => 'Alaem', 3 => 'Taranshe', 4 => 'RoyeAphalt',
5 => 'HarimRah', 6 => 'MashinAlat'],
];
return $subitems[$item];
}
public static function persianName(int $item): string
{
$persianName = [
1 => '',
2 => '',
3 => '',
4 => '',
5 => '',
6 => '',
7 => '',
8 => '',
9 => '',
10 => '',
11 => '',
12 => '',
13 => '',
14 => '',
15 => '',
16 => '',
17 => '',
20 => '',
];
return $persianName[$item];
}
}

View File

@@ -43,7 +43,7 @@ class CountryActivityPerItemReport implements FromView, WithEvents, ShouldAutoSi
COUNT(CASE WHEN item = 16 THEN 1 END) AS EmergencyCount,
province_fa,
province_id,
COUNT(CASE WHEN item != -1 THEN 1 END) AS TotalCount
COUNT(CASE WHEN item != -1 THEN 1 END) AS TotalProvinceCount
FROM (
SELECT
province_fa,
@@ -56,10 +56,31 @@ class CountryActivityPerItemReport implements FromView, WithEvents, ShouldAutoSi
WHERE status = 1
GROUP BY province_id, province_fa;";
$countryActivities = DB::select($query);
$provinceActivities = collect(DB::select($query));
return view('', [
'activities' => $countryActivities,
$totalItemCount = [
'totalMarematRooyeCount' => $provinceActivities->sum('MarematRooyeCount'),
'totalPaksaziCount' => $provinceActivities->sum('PaksaziCount'),
'totalAlaemCount' => $provinceActivities->sum('AlaemCount'),
'totalHefazCount' => $provinceActivities->sum('HefazCount'),
'totalRoshanayiCount' => $provinceActivities->sum('RoshanayiCount'),
'totalKhatkeshiCount' => $provinceActivities->sum('KhatkeshiCount'),
'totalRangamiziCount' => $provinceActivities->sum('RangamiziCount'),
'totalWashingCount' => $provinceActivities->sum('WashingCount'),
'totalImenSaziCount' => $provinceActivities->sum('ImenSaziCount'),
'totalHarimCount' => $provinceActivities->sum('HarimCount'),
'totalPolCount' => $provinceActivities->sum('PolCount'),
'totalToonelCount' => $provinceActivities->sum('ToonelCount'),
'totalAmaliatZemestaniCount' => $provinceActivities->sum('AmaliatZemestaniCount'),
'totalMashinAlatCount' => $provinceActivities->sum('MashinAlatCount'),
'totalTollhouseCount' => $provinceActivities->sum('TollhouseCount'),
'totalEmergencyCount' => $provinceActivities->sum('EmergencyCount'),
'totalCountryCount' => $provinceActivities->sum('TotalProvinceCount'),
];
return view('v3.Reports.RoadItems.CountryActivityPerItem', [
'provinceCount' => $provinceActivities,
'countryCount' => $totalItemCount,
'fromDate' => $fromDate,
'toDate' => $toDate
]);

View File

@@ -2,7 +2,7 @@
namespace App\Services\Reports;
use App\Enums\InfoItem;
use App\Models\InfoItem;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
@@ -11,15 +11,15 @@ class RoadItemReportService
{
public function countryActivityPerSubItem(int $item, string $fromDate, string $toDate): Collection
{
$subItems = InfoItem::subItems($item);
$subItems = InfoItem::query()->where('item', $item)->get(['sub_item', 'sub_item_str']);
$query = DB::table('road_items_projects')
->selectRaw('province_id, province_fa');
foreach ($subItems as $key => $name) {
foreach ($subItems as $subItem) {
$query->selectRaw("
COUNT(CASE WHEN sub_item = {$key} THEN 1 END) as {$name}Count,
SUM(CASE WHEN sub_item = {$key} THEN sub_item_data END) as {$name}Sum
COUNT(CASE WHEN sub_item = {$subItem->sub_item} THEN 1 END) as Count_{$subItem->sub_item},
SUM(CASE WHEN sub_item = {$subItem->sub_item} THEN sub_item_data END) as Sum_{$subItem->sub_item}
");
}
@@ -35,6 +35,7 @@ class RoadItemReportService
'data' => $activities,
'fromDate' => $fromDate,
'toDate' => $toDate,
'titles' => $subItems->pluck('sub_item_str')
]);
}

View File

@@ -1 +1,3 @@
views
/views/*
!/views/v3/
!/views/v3/*`

View File

@@ -0,0 +1,119 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>کشوری</title>
</head>
<body dir="rtl" style="text-align: center;">
<table>
<thead>
<tr>
<th colspan="18"
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
</th>
</tr>
<tr>
<th colspan="18"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="18"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
گزارش فعالیت روزانه و جاری راهداری از تاریخ
{{ verta($fromDate)->format('Y/n/j') }}
تا
تاریخ
{{ verta($toDate)->format('Y/n/j') }}
</th>
</tr>
<tr>
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">اداره کل
</th>
<th colspan="16" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">فعالیت های
جاری و روزانه راهداری
</th>
<th rowspan="2" style="border:1px solid black;text-align:center;background-color: #EBF1DE;">کل</th>
</tr>
<tr>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">مرمت رویه</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">پاکسازی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">علائم</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">حفاظ</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">روشنایی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">خط کشی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">رنگ آمیزی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">شستشو</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">ایمن سازی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">حریم</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">پل</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">تونل و گالری</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">عملیات زمستانی</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">ماشین آلات</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">راهدارخانه</th>
<th style="border:1px solid black;text-align:center;background-color: #C4D79B;">موارد اضطراری</th>
</tr>
</thead>
<tbody>
@foreach ($provinceCount as $activity)
<tr>
<td style="border:1px solid black;text-align: center;">{{ $activity['province_fa'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['MarematRooyeCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['PaksaziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['AlaemCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['HefazCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['RoshanayiCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['KhatkeshiCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['RangamiziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['WashingCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['ImenSaziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['HarimCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['PolCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['ToonelCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['AmaliatZemestaniCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['MashinAlatCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['TollhouseCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['EmergencyCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $activity['TotalProvinceCount'] }}</td>
</tr>
@endforeach
<tr>
<td style="border:1px solid black;text-align: center;">کشوری</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalMarematRooyeCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalPaksaziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalAlaemCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalHefazCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalRoshanayiCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalKhatkeshiCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalRangamiziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalWashingCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalImenSaziCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalHarimCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalPolCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalToonelCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalAmaliatZemestaniCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalMashinAlatCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalTollhouseCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalEmergencyCount'] }}</td>
<td style="border:1px solid black;text-align: center;">{{ $countryCount['totalCountryCount'] }}</td>
</tr>
</tbody>
</table>
</body>
</html>