Merge pull request #128 from witelgroup/feature/MergToGithub
Feature/merg to GitHub
This commit is contained in:
@@ -98,9 +98,9 @@ HARIM_NEED_GUARANTEE_LETTER_URL='https://zamin.gov.ir/ow/api/ow/esb/response'
|
||||
HARIM_NEED_GUARANTEE_LETTER_PASSWORD=
|
||||
HARIM_NEED_GUARANTEE_LETTER_USERNAME=
|
||||
|
||||
BACKUP_TARGET_DIR=
|
||||
BACKUP_TARGET_DIR=/var
|
||||
BACKUP_USER=
|
||||
BACKUP_PASSWORD=
|
||||
BACKUP_PASSWORD=1qaz
|
||||
|
||||
|
||||
HARIM_ENCRYPTION_KEY="TestKey"
|
||||
|
||||
@@ -58,14 +58,20 @@ class DailyMovingMachineCommand extends Command
|
||||
break;
|
||||
}
|
||||
|
||||
$machine = CMMSMachine::query()->firstWhere('machine_code', '=', $code);
|
||||
|
||||
MissionViolation::query()->create([
|
||||
'machine_code' => $code,
|
||||
'machine_id' => CMMSMachine::query()->firstWhere('machine_code', '=', $code)->id,
|
||||
'machine_id' => $machine->id,
|
||||
'type' => MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
||||
'request_date' => $date,
|
||||
'mileage' => $cmm['mileageKM'],
|
||||
// 'exit_time' => $cmm['exit_time'],
|
||||
// 'enter_time' => $cmm['enter_time'],
|
||||
'province_id' => $machine->province_id,
|
||||
// 'province_name' => $machine->province_fa,
|
||||
'city_id' => $machine->city_id,
|
||||
// 'city_name' => $machine->city_fa,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
110
app/Exports/V3/Mission/Report/Tradod/CountryReport.php
Normal file
110
app/Exports/V3/Mission/Report/Tradod/CountryReport.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\Mission\Report\Tradod;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
|
||||
{
|
||||
public function __construct(private array $data)
|
||||
{
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$grid = [];
|
||||
$national = null;
|
||||
|
||||
foreach ($this->data as $r) {
|
||||
$pid = (int) $r->province_id;
|
||||
$name = $r->province_name;
|
||||
|
||||
if ($pid === -1) {
|
||||
$national = [
|
||||
'province_name' => $name,
|
||||
'total' => (int) ($r->total ?? 0),
|
||||
'khareg_mahdode' => (int) ($r->khareg_mahdode ?? 0),
|
||||
'gps' => (int) ($r->gps ?? 0),
|
||||
'durations' => (int) ($r->durations ?? 0),
|
||||
'bafarayand_saeti' => (int) ($r->far_h ?? 0),
|
||||
'bafarayand_rozaneh' => (int) ($r->far_d ?? 0),
|
||||
'bedon_bafarayand_saeti' => (int) ($r->un_far_h ?? 0),
|
||||
'bedon_bafarayand_rozaneh' => (int) ($r->un_far_d ?? 0),
|
||||
'item' => (int) ($r->item ?? 0),
|
||||
'patrol' => (int) ($r->patrol ?? 0),
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($grid[$pid])) {
|
||||
$grid[$pid] = [
|
||||
'province_name' => $name,
|
||||
];
|
||||
}
|
||||
|
||||
$grid[$pid]['total'] = (int) ($r->total ?? 0);
|
||||
$grid[$pid]['khareg_mahdode'] = ($r->khareg_mahdode ?? 0);
|
||||
$grid[$pid]['gps'] = (int) ($r->gps ?? 0);
|
||||
$grid[$pid]['durations'] = (int) ($r->durations ?? 0);
|
||||
$grid[$pid]['bafarayand_saeti'] = (int) ($r->far_h ?? 0);
|
||||
$grid[$pid]['bafarayand_rozaneh'] = (int) ($r->far_d ?? 0);
|
||||
$grid[$pid]['bedon_bafarayand_saeti'] = (int) ($r->un_far_h ?? 0);
|
||||
$grid[$pid]['bedon_bafarayand_rozaneh'] = (int) ($r->un_far_d ?? 0);
|
||||
$grid[$pid]['item'] = (int) ($r->item ?? 0);
|
||||
$grid[$pid]['patrol'] = (int) ($r->patrol ?? 0);
|
||||
}
|
||||
|
||||
$exportRows = [];
|
||||
if ($national) {
|
||||
$exportRows[] = $national;
|
||||
}
|
||||
foreach ($grid as $row) {
|
||||
$exportRows[] = $row;
|
||||
}
|
||||
|
||||
return view('v3.Reports.Mission.Report.CountryActivityReport', [
|
||||
'rows' => $exportRows,
|
||||
]);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings(): array
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('J1');
|
||||
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
115
app/Exports/V3/Mission/Report/Tradod/ProvinceReport.php
Normal file
115
app/Exports/V3/Mission/Report/Tradod/ProvinceReport.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\Mission\Report\Tradod;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
|
||||
{
|
||||
public function __construct(private array $data)
|
||||
{
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$grid = [];
|
||||
$province = null;
|
||||
|
||||
foreach ($this->data as $r) {
|
||||
$cid = (int) $r->city_id;
|
||||
$name = $r->city_name;
|
||||
|
||||
if ($cid === -1) {
|
||||
$province = [
|
||||
'city_name' => $name,
|
||||
'total' => (int) ($r->total ?? 0),
|
||||
'khareg_mahdode' => (int) ($r->khareg_mahdode ?? 0),
|
||||
'gps' => (int) ($r->gps ?? 0),
|
||||
'durations' => (int) ($r->durations ?? 0),
|
||||
'bafarayand_saeti' => (int) ($r->far_h ?? 0),
|
||||
'bafarayand_rozaneh' => (int) ($r->far_d ?? 0),
|
||||
'bedon_bafarayand_saeti' => (int) ($r->un_far_h ?? 0),
|
||||
'bedon_bafarayand_rozaneh' => (int) ($r->un_far_d ?? 0),
|
||||
'item' => (int) ($r->item ?? 0),
|
||||
'patrol' => (int) ($r->patrol ?? 0),
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($grid[$cid])) {
|
||||
$grid[$cid] = [
|
||||
'city_name' => $name,
|
||||
];
|
||||
}
|
||||
|
||||
$grid[$cid]['total'] = (int) ($r->total ?? 0);
|
||||
$grid[$cid]['khareg_mahdode'] = ($r->khareg_mahdode ?? 0);
|
||||
$grid[$cid]['gps'] = (int) ($r->gps ?? 0);
|
||||
$grid[$cid]['durations'] = (int) ($r->durations ?? 0);
|
||||
$grid[$cid]['bafarayand_saeti'] = (int) ($r->far_h ?? 0);
|
||||
$grid[$cid]['bafarayand_rozaneh'] = (int) ($r->far_d ?? 0);
|
||||
$grid[$cid]['bedon_bafarayand_saeti'] = (int) ($r->un_far_h ?? 0);
|
||||
$grid[$cid]['bedon_bafarayand_rozaneh'] = (int) ($r->un_far_d ?? 0);
|
||||
$grid[$cid]['item'] = (int) ($r->item ?? 0);
|
||||
$grid[$cid]['patrol'] = (int) ($r->patrol ?? 0);
|
||||
|
||||
}
|
||||
|
||||
$exportRows = [];
|
||||
if ($province) {
|
||||
$exportRows[] = $province;
|
||||
}
|
||||
foreach ($grid as $row) {
|
||||
$exportRows[] = $row;
|
||||
}
|
||||
|
||||
return view('v3.Reports.Mission.Report.ProvinceActivityReport', [
|
||||
'rows' => $exportRows,
|
||||
]);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function drawings(): array
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('J1');
|
||||
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\Mission\Report;
|
||||
namespace App\Exports\V3\Mission\Report\Violation;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
@@ -28,8 +28,12 @@ class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvent
|
||||
if ($pid === -1) {
|
||||
$national = [
|
||||
'province_name' => $name,
|
||||
'no_mission_count' => (int) ($r->no_mission_count ?? 0),
|
||||
'out_of_area_count' => (int) ($r->out_of_area_count ?? 0),
|
||||
'total' => (int) ($r->total ?? 0),
|
||||
'egdam_shode' => (int) ($r->done ?? 0),
|
||||
'bedone_egdam' => (int) ($r->undon ?? 0),
|
||||
'sabt_gps' => (int) ($r->gps ?? 0),
|
||||
'sabt_herasat' => (int) ($r->herasat ?? 0),
|
||||
'mil_gps' => (int) ($r->mil_gps ?? 0),
|
||||
];
|
||||
|
||||
continue;
|
||||
@@ -40,10 +44,12 @@ class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvent
|
||||
'province_name' => $name,
|
||||
];
|
||||
}
|
||||
|
||||
$grid[$pid]['no_mission_count'] = (int) ($r->no_mission_count ?? 0);
|
||||
$grid[$pid]['out_of_area_count'] = (int) ($r->out_of_area_count ?? 0);
|
||||
|
||||
$grid[$pid]['total'] = (int) ($r->total ?? 0);
|
||||
$grid[$pid]['egdam_shode'] = (int) ($r->done ?? 0);
|
||||
$grid[$pid]['bedone_egdam'] = (int) ($r->undone ?? 0);
|
||||
$grid[$pid]['sabt_gps'] = (int) ($r->gps ?? 0);
|
||||
$grid[$pid]['sabt_herasat'] = (int) ($r->herasat ?? 0);
|
||||
$grid[$pid]['mil_gps'] = (int) ($r->mil_gps ?? 0);
|
||||
}
|
||||
|
||||
$exportRows = [];
|
||||
@@ -88,7 +94,7 @@ class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvent
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('C1');
|
||||
$drawing2->setCoordinates('E1');
|
||||
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\Mission\Report;
|
||||
namespace App\Exports\V3\Mission\Report\Violation;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
@@ -29,8 +29,12 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEven
|
||||
if ($cid === -1) {
|
||||
$province = [
|
||||
'city_name' => $name,
|
||||
'no_mission_count' => (int) ($r->no_mission_count ?? 0),
|
||||
'out_of_area_count' => (int) ($r->out_of_area_count ?? 0),
|
||||
'total' => (int) ($r->total ?? 0),
|
||||
'egdam_shode' => (int) ($r->done ?? 0),
|
||||
'bedone_egdam' => (int) ($r->undon ?? 0),
|
||||
'sabt_gps' => (int) ($r->gps ?? 0),
|
||||
'sabt_herasat' => (int) ($r->herasat ?? 0),
|
||||
'mil_gps' => (int) ($r->mil_gps ?? 0),
|
||||
];
|
||||
|
||||
continue;
|
||||
@@ -41,10 +45,12 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEven
|
||||
'city_name' => $name,
|
||||
];
|
||||
}
|
||||
|
||||
$grid[$cid]['no_mission_count'] = (int) ($r->no_mission_count ?? 0);
|
||||
$grid[$cid]['out_of_area_count'] = (int) ($r->out_of_area_count ?? 0);
|
||||
|
||||
$grid[$cid]['total'] = (int) ($r->total ?? 0);
|
||||
$grid[$cid]['egdam_shode'] = (int) ($r->done ?? 0);
|
||||
$grid[$cid]['bedone_egdam'] = (int) ($r->undone ?? 0);
|
||||
$grid[$cid]['sabt_gps'] = (int) ($r->gps ?? 0);
|
||||
$grid[$cid]['sabt_herasat'] = (int) ($r->herasat ?? 0);
|
||||
$grid[$cid]['mil_gps'] = (int) ($r->mil_gps ?? 0);
|
||||
}
|
||||
|
||||
$exportRows = [];
|
||||
@@ -92,7 +98,7 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEven
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('C1');
|
||||
$drawing2->setCoordinates('E1');
|
||||
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class ControlUnitController extends Controller
|
||||
$mission->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => MissionStates::name($state),
|
||||
'start_time' => now(),
|
||||
'start_time' => $request->time,
|
||||
'km' => $request->km,
|
||||
]);
|
||||
});
|
||||
@@ -56,7 +56,7 @@ class ControlUnitController extends Controller
|
||||
*/
|
||||
public function finish(FinishRequest $request, Mission $mission, GetErrorRateService $getErrorRateService): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($mission, $getErrorRateService) {
|
||||
DB::transaction(function () use ($mission, $getErrorRateService, $request) {
|
||||
$mission->histories()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'previous_state_id' => $mission->state_id,
|
||||
@@ -68,8 +68,8 @@ class ControlUnitController extends Controller
|
||||
$mission->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => MissionStates::name($state),
|
||||
'finish_time' => now(),
|
||||
'mission_duration' => strtotime(now()) - strtotime($mission->start_time),
|
||||
'finish_time' => $request->time,
|
||||
'mission_duration' => strtotime($request->time) - strtotime($mission->start_time),
|
||||
]);
|
||||
|
||||
$getErrorRateService->setInputParameters($mission);
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Mission\Report;
|
||||
|
||||
use App\Exports\V3\Mission\Report\Violation\CountryReport;
|
||||
use App\Exports\V3\Mission\Report\Violation\ProvinceReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\City;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\Mission\Report\ReportTradodService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class ReportTradodController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function countryActivity(Request $request, ReportTradodService $reportMissionService): JsonResponse
|
||||
{
|
||||
return $this->successResponse([
|
||||
'activities' => $reportMissionService->countryActivity($request),
|
||||
'provinces' => Province::all(['id', 'name_fa']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function provinceActivity(Request $request, ReportTradodService $reportMissionService): JsonResponse
|
||||
{
|
||||
return $this->successResponse([
|
||||
'activities' =>$reportMissionService->provinceActivity($request),
|
||||
'city' => City::query()->where('province_id', $request->province_id)->get(['id', 'name_fa']),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
*/
|
||||
public function countryExcelActivity(Request $request, ReportTradodService $reportMissionService): BinaryFileResponse
|
||||
{
|
||||
$data = $reportMissionService->countryActivity($request);
|
||||
$name = 'گزارش کل تردد '.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||
|
||||
return Excel::download(new CountryReport($data), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
*/
|
||||
public function provinceExcelActivity(Request $request, ReportTradodService $reportMissionService): BinaryFileResponse
|
||||
{
|
||||
$data = $reportMissionService->provinceActivity($request);
|
||||
$name = 'گزارش کل تردد '.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||
|
||||
return Excel::download(new ProvinceReport($data), $name);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Mission;
|
||||
namespace App\Http\Controllers\V3\Dashboard\Mission\Report;
|
||||
|
||||
use App\Exports\V3\Mission\Report\CountryReport;
|
||||
use App\Exports\V3\Mission\Report\ProvinceReport;
|
||||
use App\Exports\V3\Mission\Report\Violation\CountryReport;
|
||||
use App\Exports\V3\Mission\Report\Violation\ProvinceReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\City;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\Mission\ReportService;
|
||||
use App\Services\Cartables\Mission\Report\ReportViolationService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class ReportController extends Controller
|
||||
class ReportViolationController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function countryActivity(Request $request, ReportService $reportService): JsonResponse
|
||||
public function countryActivity(Request $request, ReportViolationService $reportService): JsonResponse
|
||||
{
|
||||
return $this->successResponse([
|
||||
'activities' => $reportService->countryActivity($request),
|
||||
@@ -27,7 +27,7 @@ class ReportController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function provinceActivity(Request $request, ReportService $reportService): JsonResponse
|
||||
public function provinceActivity(Request $request, ReportViolationService $reportService): JsonResponse
|
||||
{
|
||||
return $this->successResponse([
|
||||
'activities' =>$reportService->provinceActivity($request),
|
||||
@@ -39,7 +39,7 @@ class ReportController extends Controller
|
||||
* @throws Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
*/
|
||||
public function countryExcelActivity(Request $request, ReportService $reportService): BinaryFileResponse
|
||||
public function countryExcelActivity(Request $request, ReportViolationService $reportService): BinaryFileResponse
|
||||
{
|
||||
$data = $reportService->countryActivity($request);
|
||||
$name = 'گزارش تخلفات ماموریت ها '.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||
@@ -51,7 +51,7 @@ class ReportController extends Controller
|
||||
* @throws Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
*/
|
||||
public function provinceExcelActivity(Request $request, ReportService $reportService): BinaryFileResponse
|
||||
public function provinceExcelActivity(Request $request, ReportViolationService $reportService): BinaryFileResponse
|
||||
{
|
||||
$data = $reportService->provinceActivity($request);
|
||||
$name = 'گزارش تخلفات ماموریت ها '.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||
@@ -96,6 +96,8 @@ class ViolationManagementController extends Controller
|
||||
}
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
MissionViolation::query()->create([
|
||||
'machine_id'=> CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->value('id'),
|
||||
'machine_code'=> $request->machine_code,
|
||||
@@ -104,6 +106,10 @@ class ViolationManagementController extends Controller
|
||||
'request_date' => now(),
|
||||
'km' => $request->km,
|
||||
'gps' => 0,
|
||||
'province_id' => $user->province_id,
|
||||
'province_name' => $user->province_fa,
|
||||
'city_id' => $user->city_id,
|
||||
'city_name' => $user->city_fa,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
|
||||
@@ -24,7 +24,7 @@ class FinishRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
'time' => 'required|date',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ class StartRequest extends FormRequest
|
||||
return [
|
||||
'code' => 'required|string',
|
||||
'km' => 'required',
|
||||
'time' => 'required|date',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
193
app/Services/Cartables/Mission/Report/ReportTradodService.php
Normal file
193
app/Services/Cartables/Mission/Report/ReportTradodService.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables\Mission\Report;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\MissionViolation;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ReportTradodService
|
||||
{
|
||||
public function dataTable(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$query = MissionViolation::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id);
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
|
||||
public function countryActivity(Request $request): array
|
||||
{
|
||||
$from = $request->from_date ?? today()->startOfDay();
|
||||
$to = Carbon::parse($request->to_date)->endOfDay() ?? today()->endOfDay();
|
||||
$sql = "
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل کشور' AS province_name,
|
||||
-1 AS province_id,
|
||||
SUM(t.total) AS total,
|
||||
SUM(t.khareg_mahdode) AS khareg_mahdode,
|
||||
SUM(t.gps) AS gps,
|
||||
SUM(t.durations) AS durations,
|
||||
SUM(t.far_h) AS far_h,
|
||||
SUM(t.far_d) AS far_d,
|
||||
SUM(t.un_far_h) AS un_far_h,
|
||||
SUM(t.un_far_d) AS un_far_d,
|
||||
SUM(t.item) AS item,
|
||||
SUM(t.patrol) AS patrol
|
||||
FROM (
|
||||
SELECT
|
||||
p.id AS province_id,
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(CASE WHEN m.type = 1 THEN 1 ELSE 0 END), 0) AS far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 2 THEN 1 ELSE 0 END), 0) AS far_d,
|
||||
COALESCE(SUM(CASE WHEN m.type = 3 THEN 1 ELSE 0 END), 0) AS un_far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 4 THEN 1 ELSE 0 END), 0) AS un_far_d,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 1 THEN 1 ELSE 0 END), 0) AS item,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 2 THEN 1 ELSE 0 END), 0) AS patrol
|
||||
FROM provinces p
|
||||
LEFT JOIN missions m
|
||||
ON m.province_id = p.id
|
||||
AND m.created_at >= :from_m
|
||||
AND m.created_at <= :to_m
|
||||
GROUP BY p.id
|
||||
) t
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
p.name_fa AS province_name,
|
||||
p.id AS province_id,
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(CASE WHEN m.type = 1 THEN 1 ELSE 0 END), 0) AS far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 2 THEN 1 ELSE 0 END), 0) AS far_d,
|
||||
COALESCE(SUM(CASE WHEN m.type = 3 THEN 1 ELSE 0 END), 0) AS un_far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 4 THEN 1 ELSE 0 END), 0) AS un_far_d,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 1 THEN 1 ELSE 0 END), 0) AS item,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 2 THEN 1 ELSE 0 END), 0) AS patrol
|
||||
FROM provinces p
|
||||
LEFT JOIN missions m
|
||||
ON m.province_id = p.id
|
||||
AND m.created_at >= :from_m
|
||||
AND m.created_at <= :to_m
|
||||
GROUP BY p.id, p.name_fa
|
||||
)q
|
||||
ORDER BY
|
||||
CASE WHEN province_id = -1 THEN 0 ELSE 1 END,
|
||||
province_name;
|
||||
|
||||
";
|
||||
|
||||
|
||||
return DB::select($sql, [
|
||||
'from_m' => $from,
|
||||
'to_m' => $to,
|
||||
]);
|
||||
}
|
||||
|
||||
public function provinceActivity(Request $request): array
|
||||
{
|
||||
$provinceId = $request->province_id ?? auth()->user()->province_id;
|
||||
$from = $request->from_date ?? today()->startOfDay();
|
||||
$to = Carbon::parse($request->to_date)->endOfDay() ?? today()->endOfDay();
|
||||
|
||||
$sql = "
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل استان' AS city_name,
|
||||
-1 AS city_id,
|
||||
SUM(t.total) AS total,
|
||||
SUM(t.khareg_mahdode) AS khareg_mahdode,
|
||||
SUM(t.gps) AS gps,
|
||||
SUM(t.durations) AS durations,
|
||||
SUM(t.far_h) AS far_h,
|
||||
SUM(t.far_d) AS far_d,
|
||||
SUM(t.un_far_h) AS un_far_h,
|
||||
SUM(t.un_far_d) AS un_far_d,
|
||||
SUM(t.item) AS item,
|
||||
SUM(t.patrol) AS patrol
|
||||
FROM (
|
||||
SELECT
|
||||
c.id AS city_id,
|
||||
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(m.type = 1), 0) AS far_h,
|
||||
COALESCE(SUM(m.type = 2), 0) AS far_d,
|
||||
COALESCE(SUM(m.type = 3), 0) AS un_far_h,
|
||||
COALESCE(SUM(m.type = 4), 0) AS un_far_d,
|
||||
COALESCE(SUM(m.category_id = 1), 0) AS item,
|
||||
COALESCE(SUM(m.category_id = 2), 0) AS patrol
|
||||
FROM cities c
|
||||
LEFT JOIN missions m
|
||||
ON m.city_id = c.id
|
||||
AND m.created_at >= :from_m
|
||||
AND m.created_at <= :to_m
|
||||
WHERE c.province_id = :province_id
|
||||
AND (
|
||||
c.type_id = 1
|
||||
OR c.name_fa IN ('اداره ماشينآلات', 'اداره نقلیه')
|
||||
)
|
||||
GROUP BY c.id
|
||||
) t
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
c.name_fa AS city_name,
|
||||
c.id AS city_id,
|
||||
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(m.type = 1), 0) AS far_h,
|
||||
COALESCE(SUM(m.type = 2), 0) AS far_d,
|
||||
COALESCE(SUM(m.type = 3), 0) AS un_far_h,
|
||||
COALESCE(SUM(m.type = 4), 0) AS un_far_d,
|
||||
COALESCE(SUM(m.category_id = 1), 0) AS item,
|
||||
COALESCE(SUM(m.category_id = 2), 0) AS patrol
|
||||
|
||||
FROM cities c
|
||||
LEFT JOIN missions m
|
||||
ON m.city_id = c.id
|
||||
AND m.created_at >= :from_m
|
||||
AND m.created_at <= :to_m
|
||||
WHERE c.province_id = :province_id
|
||||
AND (
|
||||
c.type_id = 1
|
||||
OR c.name_fa IN ('اداره ماشينآلات', 'اداره نقلیه')
|
||||
)
|
||||
GROUP BY c.id, c.name_fa
|
||||
) q
|
||||
ORDER BY
|
||||
CASE WHEN q.city_id = -1 THEN 0 ELSE 1 END,
|
||||
q.city_name;
|
||||
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
'province_id' => $provinceId,
|
||||
'from_m' => $from,
|
||||
'to_m' => $to,
|
||||
]);
|
||||
}
|
||||
}
|
||||
171
app/Services/Cartables/Mission/Report/ReportViolationService.php
Normal file
171
app/Services/Cartables/Mission/Report/ReportViolationService.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables\Mission\Report;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\MissionViolation;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ReportViolationService
|
||||
{
|
||||
public function dataTable(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$query = MissionViolation::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id);
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
|
||||
public function countryActivity(Request $request): array
|
||||
{
|
||||
$from = $request->from_date ?? today()->startOfDay();
|
||||
$to = Carbon::parse($request->to_date)->endOfDay() ?? today()->endOfDay();
|
||||
|
||||
$sql = "
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل کشور' AS province_name,
|
||||
-1 AS province_id,
|
||||
SUM(t.total) AS total,
|
||||
SUM(t.done) AS done,
|
||||
SUM(t.undone) AS undone,
|
||||
SUM(t.gps) AS gps,
|
||||
SUM(t.herasat) AS herasat,
|
||||
SUM(t.mil_gps) AS mil_gps
|
||||
FROM (
|
||||
SELECT
|
||||
p.id AS province_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 1 THEN 1 ELSE 0 END), 0) as done,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 0 THEN 1 ELSE 0 END), 0) as undone,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN 1 ELSE 0 END), 0) as gps,
|
||||
COALESCE(SUM(CASE WHEN gps = 0 THEN 1 ELSE 0 END), 0) as herasat,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN mileage ELSE 0 END),0) as mil_gps
|
||||
FROM provinces p
|
||||
LEFT JOIN mission_violations mv
|
||||
ON mv.province_id = p.id
|
||||
AND mv.type = 1
|
||||
AND mv.created_at >= :from_mv
|
||||
AND mv.created_at <= :to_mv
|
||||
GROUP BY p.id
|
||||
) t
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
p.name_fa AS province_name,
|
||||
p.id AS province_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 1 THEN 1 ELSE 0 END), 0) as done,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 0 THEN 1 ELSE 0 END), 0) as undone,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN 1 ELSE 0 END), 0) as gps,
|
||||
COALESCE(SUM(CASE WHEN gps = 0 THEN 1 ELSE 0 END), 0) as herasat,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN mileage ELSE 0 END),0) as mil_gps
|
||||
|
||||
FROM provinces p
|
||||
LEFT JOIN mission_violations mv
|
||||
ON mv.province_id = p.id
|
||||
AND mv.type = 1
|
||||
AND mv.created_at >= :from_mv
|
||||
AND mv.created_at <= :to_mv
|
||||
GROUP BY p.id, p.name_fa
|
||||
)q
|
||||
ORDER BY
|
||||
CASE WHEN province_id = -1 THEN 0 ELSE 1 END,
|
||||
province_name;
|
||||
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
'from_mv' => $from,
|
||||
'to_mv' => $to,
|
||||
]);
|
||||
}
|
||||
|
||||
public function provinceActivity(Request $request): array
|
||||
{
|
||||
$provinceId = $request->province_id ?? auth()->user()->province_id;
|
||||
$from = $request->from_date ?? today()->startOfDay();
|
||||
$to = Carbon::parse($request->to_date)->endOfDay() ?? today()->endOfDay();
|
||||
|
||||
$sql = "
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل استان' AS city_name,
|
||||
-1 AS city_id,
|
||||
SUM(t.total) AS total,
|
||||
SUM(t.done) AS done,
|
||||
SUM(t.undone) AS undone,
|
||||
SUM(t.gps) AS gps,
|
||||
SUM(t.herasat) AS herasat,
|
||||
SUM(t.mil_gps) AS mil_gps
|
||||
FROM (
|
||||
SELECT
|
||||
c.id AS city_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(mv.status = 1), 0) AS done,
|
||||
COALESCE(SUM(mv.status = 0), 0) AS undone,
|
||||
COALESCE(SUM(mv.gps = 1), 0) AS gps,
|
||||
COALESCE(SUM(mv.gps = 0), 0) AS herasat,
|
||||
COALESCE(SUM(CASE WHEN mv.gps = 1 THEN mv.mileage ELSE 0 END), 0) AS mil_gps
|
||||
FROM cities c
|
||||
LEFT JOIN mission_violations mv
|
||||
ON mv.city_id = c.id
|
||||
AND mv.type = 1
|
||||
AND mv.created_at >= :from_mv
|
||||
AND mv.created_at <= :to_mv
|
||||
WHERE c.province_id = :province_id
|
||||
AND (
|
||||
c.type_id = 1
|
||||
OR c.name_fa IN ('اداره ماشينآلات', 'اداره نقلیه')
|
||||
)
|
||||
GROUP BY c.id
|
||||
) t
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
c.name_fa AS city_name,
|
||||
c.id AS city_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(mv.status = 1), 0) AS done,
|
||||
COALESCE(SUM(mv.status = 0), 0) AS undone,
|
||||
COALESCE(SUM(mv.gps = 1), 0) AS gps,
|
||||
COALESCE(SUM(mv.gps = 0), 0) AS herasat,
|
||||
COALESCE(SUM(CASE WHEN mv.gps = 1 THEN mv.mileage ELSE 0 END), 0) AS mil_gps
|
||||
FROM cities c
|
||||
LEFT JOIN mission_violations mv
|
||||
ON mv.city_id = c.id
|
||||
AND mv.type = 1
|
||||
AND mv.created_at >= :from_mv
|
||||
AND mv.created_at <= :to_mv
|
||||
WHERE c.province_id = :province_id
|
||||
AND (
|
||||
c.type_id = 1
|
||||
OR c.name_fa IN ('اداره ماشينآلات', 'اداره نقلیه')
|
||||
)
|
||||
GROUP BY c.id, c.name_fa
|
||||
) q
|
||||
ORDER BY
|
||||
CASE WHEN q.city_id = -1 THEN 0 ELSE 1 END,
|
||||
q.city_name;
|
||||
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
'province_id' => $provinceId,
|
||||
'from_mv' => $from,
|
||||
'to_mv' => $to,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables\Mission;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\MissionViolation;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ReportService
|
||||
{
|
||||
public function dataTable(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$query = MissionViolation::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id);
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
|
||||
public function countryActivity(Request $request): array
|
||||
{
|
||||
$from = $request->from_date ?? today()->startOfDay();
|
||||
$to = Carbon::parse($request->to_date)->endOfDay() ?? today()->endOfDay();
|
||||
|
||||
$sql = "
|
||||
WITH r AS (
|
||||
SELECT
|
||||
p.id AS province_id,
|
||||
p.name_fa AS province_name,
|
||||
|
||||
COUNT(DISTINCT mv.id) AS no_mission_count,
|
||||
COUNT(DISTINCT m.id) AS out_of_area_count
|
||||
|
||||
FROM provinces p
|
||||
|
||||
LEFT JOIN cmms_machines cm
|
||||
ON cm.province_id = p.id
|
||||
|
||||
LEFT JOIN mission_violations mv
|
||||
ON TRIM(cm.machine_code) = TRIM(mv.machine_code)
|
||||
AND mv.type = 1
|
||||
AND mv.created_at >= :from_mv
|
||||
AND mv.created_at <= :to_mv
|
||||
|
||||
LEFT JOIN missions m
|
||||
ON m.province_id = p.id
|
||||
AND m.mission_duration != m.in_area_duration
|
||||
AND m.created_at >= :from_m
|
||||
AND m.created_at <= :to_m
|
||||
|
||||
GROUP BY p.id, p.name_fa
|
||||
)
|
||||
|
||||
SELECT
|
||||
-1 AS province_id,
|
||||
'کل کشور' AS province_name,
|
||||
SUM(no_mission_count) AS no_mission_count,
|
||||
SUM(out_of_area_count) AS out_of_area_count
|
||||
FROM r
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
province_id, province_name, no_mission_count, out_of_area_count
|
||||
FROM r
|
||||
|
||||
ORDER BY
|
||||
CASE WHEN province_id = -1 THEN 0 ELSE 1 END,
|
||||
province_name
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
'from_mv' => $from,
|
||||
'to_mv' => $to,
|
||||
'from_m' => $from,
|
||||
'to_m' => $to,
|
||||
]);
|
||||
}
|
||||
|
||||
public function provinceActivity(Request $request): array
|
||||
{
|
||||
$provinceId = $request->province_id ?? auth()->user()->province_id;
|
||||
$from = $request->from_date ?? today()->startOfDay();
|
||||
$to = Carbon::parse($request->to_date)->endOfDay() ?? today()->endOfDay();
|
||||
|
||||
$sql = "
|
||||
WITH r AS (
|
||||
SELECT
|
||||
c.id AS city_id,
|
||||
c.name_fa AS city_name,
|
||||
|
||||
COUNT(DISTINCT mv.id) AS no_mission_count,
|
||||
COUNT(DISTINCT m.id) AS out_of_area_count
|
||||
|
||||
FROM cities c
|
||||
LEFT JOIN cmms_machines cm
|
||||
ON cm.city_id = c.id
|
||||
|
||||
LEFT JOIN mission_violations mv
|
||||
ON TRIM(cm.machine_code) = TRIM(mv.machine_code)
|
||||
AND mv.type = 1
|
||||
AND mv.created_at >= :from_mv
|
||||
AND mv.created_at <= :to_mv
|
||||
|
||||
LEFT JOIN missions m
|
||||
ON m.city_id = c.id
|
||||
AND m.mission_duration != m.in_area_duration
|
||||
AND m.created_at >= :from_m
|
||||
AND m.created_at <= :to_m
|
||||
|
||||
WHERE c.province_id = :province_id
|
||||
AND (
|
||||
c.type_id = 1
|
||||
OR c.name_fa IN ('اداره ماشينآلات', 'اداره نقلیه')
|
||||
)
|
||||
GROUP BY c.id, c.name_fa
|
||||
)
|
||||
|
||||
SELECT
|
||||
-1 AS city_id,
|
||||
'کل استان' AS city_name,
|
||||
SUM(no_mission_count) AS no_mission_count,
|
||||
SUM(out_of_area_count) AS out_of_area_count
|
||||
FROM r
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
city_id, city_name, no_mission_count, out_of_area_count
|
||||
FROM r
|
||||
|
||||
ORDER BY
|
||||
CASE WHEN city_id = -1 THEN 0 ELSE 1 END,
|
||||
city_name
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
'province_id' => $provinceId,
|
||||
'from_mv' => $from,
|
||||
'to_mv' => $to,
|
||||
'from_m' => $from,
|
||||
'to_m' => $to,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('mission_violations', function (Blueprint $table) {
|
||||
$table->unsignedTinyInteger('province_id')->nullable();
|
||||
$table->string('province_name')->nullable();
|
||||
$table->unsignedSmallInteger('city_id')->nullable();
|
||||
$table->string('city_name')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('mission_violations', function (Blueprint $table) {
|
||||
$table->dropColumn(['province_id', 'province_name', 'city_id', 'city_name']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -50,11 +50,27 @@
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
خروج بدون ماموریت </th>
|
||||
کل تخلفات </th>
|
||||
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
خارج از محدوده
|
||||
اقدام شده
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
اقدام نشده
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
ثبت GPS</th>
|
||||
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
ثبت حراست
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
کیلومتر GPS
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -63,8 +79,12 @@
|
||||
@foreach ($rows as $item)
|
||||
<tr>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['province_name'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['no_mission_count'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['out_of_area_count'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['total_violations'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['egdam_shode'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bedone_egdam'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['sabt_gps'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['sabt_herasat'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['mil_gps'] ?? '-' }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
@@ -50,14 +50,28 @@
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
خروج بدون ماموریت </th>
|
||||
کل تخلفات</th>
|
||||
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
خارج از محدوده
|
||||
اقدام شده
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
اقدام نشده
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
ثبت GPS</th>
|
||||
|
||||
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
ثبت حراست
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
مسافت ثبت شده GPS
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -65,8 +79,12 @@
|
||||
@foreach ($rows as $item)
|
||||
<tr>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['city_name'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['no_mission_count'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['out_of_area_count'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['total_violations'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['egdam_shode'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bedone_egdam'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['sabt_gps'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['sabt_herasat'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['mil_gps'] ?? '-' }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
<!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>
|
||||
|
||||
<style>
|
||||
table,
|
||||
th,
|
||||
td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body dir="rtl" style="text-align: center;">
|
||||
@php
|
||||
// show a dot if key missing or value is 0/empty
|
||||
function cell($row, $key) {
|
||||
return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0';
|
||||
}
|
||||
@endphp
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"
|
||||
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="7"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="7"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||
گزارش نخلف های صورت گرفته
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
استان
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
کل ماموریت </th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
جمع ساعات GPS
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
جمع ساعات ماموریت </th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
تردد خارج از محدوده
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
با فرآیند ساعتی
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
با فرآیند روزانه </th>
|
||||
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
بدون فرآیند ساعتی
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
بدون فرآیند روزانه
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
فعالیت روزانه </th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
گشت راهداری
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($rows as $item)
|
||||
<tr>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['province_name'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['khareg_mahdode'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['gps'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['durations'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_saeti'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_rozaneh'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_saeti'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_rozaneh'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['item'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['patrol'] ?? '-' }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,110 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fa">
|
||||
|
||||
<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>
|
||||
|
||||
<style>
|
||||
table,
|
||||
th,
|
||||
td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body dir="rtl" style="text-align: center;">
|
||||
@php
|
||||
// show a dot if key missing or value is 0/empty
|
||||
function cell($row, $key) {
|
||||
return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0';
|
||||
}
|
||||
@endphp
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"
|
||||
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="7"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="7"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||
گزارش نخلف های صورت گرفته
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
شهر
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
کل ماموریت </th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
جمع ساعات GPS
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
جمع ساعات ماموریت </th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
تردد خارج از محدوده
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
با فرآیند ساعتی
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
با فرآیند روزانه </th>
|
||||
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
بدون فرآیند ساعتی
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
بدون فرآیند روزانه
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
فعالیت روزانه </th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
گشت راهداری
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($rows as $item)
|
||||
<tr>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['city_name'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['khareg_mahdode'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['gps'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['durations'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_saeti'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_rozaneh'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_saeti'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_rozaneh'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['item'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['patrol'] ?? '-' }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,6 +15,8 @@ use App\Http\Controllers\V3\Dashboard\Harim\TechnicalDeputyController;
|
||||
use App\Http\Controllers\V3\Dashboard\ItemsManagementController;
|
||||
use App\Http\Controllers\V3\Dashboard\Mission\ControlUnitController;
|
||||
use App\Http\Controllers\V3\Dashboard\Mission\DetailController;
|
||||
use App\Http\Controllers\V3\Dashboard\Mission\Report\ReportTradodController;
|
||||
use App\Http\Controllers\V3\Dashboard\Mission\Report\ReportViolationController;
|
||||
use App\Http\Controllers\V3\Dashboard\Mission\RequestPortalController;
|
||||
use App\Http\Controllers\V3\Dashboard\Mission\TransportationUnitController;
|
||||
use App\Http\Controllers\V3\Dashboard\Mission\ViolationManagementController;
|
||||
@@ -533,9 +535,9 @@ Route::prefix('missions')
|
||||
Route::post('/{violation}', 'update')->name('update');
|
||||
Route::delete('/{violation}', 'destroy')->name('destroy');
|
||||
});
|
||||
Route::prefix('report')
|
||||
->name('reports.')
|
||||
->controller(\App\Http\Controllers\V3\Dashboard\Mission\ReportController::class)
|
||||
Route::prefix('report_violation')
|
||||
->name('reportsViolation.')
|
||||
->controller(ReportViolationController::class)
|
||||
->group(function () {
|
||||
Route::get('/country_activity', 'countryActivity')->name('countryActivity')
|
||||
->middleware('permission:mission-report-country');
|
||||
@@ -544,6 +546,17 @@ Route::prefix('missions')
|
||||
Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity');
|
||||
Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity');
|
||||
});
|
||||
Route::prefix('report_tradod')
|
||||
->name('reportsTradod.')
|
||||
->controller(ReportTradodController::class)
|
||||
->group(function () {
|
||||
Route::get('/country_activity', 'countryActivity')->name('countryActivity')
|
||||
->middleware('permission:mission-report-country');
|
||||
Route::get('/province_activity', 'provinceActivity')->name('provinceActivity')
|
||||
->middleware('permission:mission-report-province');
|
||||
Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity');
|
||||
Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity');
|
||||
});
|
||||
});
|
||||
|
||||
Route::prefix('harim')
|
||||
|
||||
Reference in New Issue
Block a user