debug the accident module

This commit is contained in:
2025-08-30 14:07:37 +03:30
parent ab24f8502c
commit bb8262b896
7 changed files with 199 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Console\Commands;
use App\Models\City;
use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
@@ -27,8 +28,9 @@ class ExtractGeometryForCities extends Command
/**
* Execute the console command.
* @throws FileNotFoundException
*/
public function handle()
public function handle(): int
{
$jsonPath = $this->argument('jsonPath');
@@ -103,8 +105,6 @@ class ExtractGeometryForCities extends Command
continue;
}
$query = City::query()
->find($cityId);
@@ -122,8 +122,6 @@ class ExtractGeometryForCities extends Command
{
$this->error("Something went wrong: $th");
}
}
return parent::SUCCESS;

View File

@@ -26,7 +26,8 @@ class CountryReport implements FromView, ShouldAutoSize, WithEvents, WithDrawing
$country = array_search(-1, array_column($data['data'], 'province_id'));
$activities[] = [
'name' => 'کل کشور',
'province_id' => -1,
'province_fa' => 'کل کشور',
'tedade' => $data['data'][$country]->tedade,
'police_rah' => $data['data'][$country]->police_rah,
'gozaresh_gasht' => $data['data'][$country]->gozaresh_gasht,
@@ -35,6 +36,9 @@ class CountryReport implements FromView, ShouldAutoSize, WithEvents, WithDrawing
'vasel_shode_bimeh' => $data['data'][$country]->vasel_shode_bimeh ?? 0,
'vasel_shode_daghi' => $data['data'][$country]->vasel_shode_daghi ?? 0,
'vasel_shode_final' => $data['data'][$country]->vasel_shode_final ?? 0,
'egdam' => $data['data'][$country]->egdam ?? 0,
'khatm' => $data['data'][$country]->khatm ?? 0,
'pardakht' => $data['data'][$country]->pardakht ?? 0,
];
foreach (Province::all() as $province) {
@@ -43,7 +47,8 @@ class CountryReport implements FromView, ShouldAutoSize, WithEvents, WithDrawing
if ($existingProvince) {
$activities[] = [
'name' => $province->name_fa,
'province_id' => $province->id,
'province_fa' => $province->name_fa,
'tedade' => $data['data'][$existingProvince]->tedade,
'police_rah' => $data['data'][$existingProvince]->police_rah,
'gozaresh_gasht' => $data['data'][$existingProvince]->gozaresh_gasht,
@@ -52,10 +57,14 @@ class CountryReport implements FromView, ShouldAutoSize, WithEvents, WithDrawing
'vasel_shode_bimeh' => $data['data'][$existingProvince]->vasel_shode_bimeh ?? 0,
'vasel_shode_daghi' => $data['data'][$existingProvince]->vasel_shode_daghi ?? 0,
'vasel_shode_final' => $data['data'][$existingProvince]->vasel_shode_final ?? 0,
'egdam' => $data['data'][$country]->egdam ?? 0,
'khatm' => $data['data'][$country]->khatm ?? 0,
'pardakht' => $data['data'][$country]->pardakht ?? 0,
];
} else {
$activities[] = [
'name' => $province->name_fa,
'province_id' => $province->id,
'province_fa' => $province->name_fa,
'tedade' => "",
'police_rah' => "",
'gozaresh_gasht' => "",
@@ -64,6 +73,9 @@ class CountryReport implements FromView, ShouldAutoSize, WithEvents, WithDrawing
'vasel_shode_bimeh' => "",
'vasel_shode_daghi' => "",
'vasel_shode_final' => "",
'egdam' => "",
'khatm' => "",
'pardakht' => "",
];
}
}

View File

@@ -26,7 +26,8 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithEvents, WithDrawin
$province = array_search(-1, array_column($reportData, 'province_id'));
$activities[] = [
'name' => 'کل استان',
'city_id' => -1,
'city_fa' => 'کل استان',
'tedade' => $reportData['data'][$province]->tedade,
'police_rah' => $reportData['data'][$province]->police_rah,
'gozaresh_gasht' => $reportData['data'][$province]->gozaresh_gasht,
@@ -35,6 +36,9 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithEvents, WithDrawin
'vasel_shode_bimeh' => $reportData['data'][$province]->vasel_shode_bimeh ?? 0,
'vasel_shode_daghi' => $reportData['data'][$province]->vasel_shode_daghi ?? 0,
'vasel_shode_final' => $reportData['data'][$province]->vasel_shode_final ?? 0,
'egdam' => $reportData['data'][$province]->egdam ?? 0,
'khatm' => $reportData['data'][$province]->khatm ?? 0,
'pardakht' => $reportData['data'][$province]->pardakht ?? 0,
];
foreach ($inputData['cities'] as $city) {
@@ -43,7 +47,8 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithEvents, WithDrawin
if ($existingCity) {
$activities[] = [
'name' => $city->name_fa,
'city_id' => -1,
'city_fa' => 'کل استان',
'tedade' => $reportData['data'][$existingCity]->tedade,
'police_rah' => $reportData['data'][$existingCity]->police_rah,
'gozaresh_gasht' => $reportData['data'][$existingCity]->gozaresh_gasht,
@@ -52,6 +57,9 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithEvents, WithDrawin
'vasel_shode_bimeh' => $reportData['data'][$existingCity]->vasel_shode_bimeh ?? 0,
'vasel_shode_daghi' => $reportData['data'][$existingCity]->vasel_shode_daghi ?? 0,
'vasel_shode_final' => $reportData['data'][$existingCity]->vasel_shode_final ?? 0,
'egdam' => $reportData['data'][$province]->egdam ?? 0,
'khatm' => $reportData['data'][$province]->khatm ?? 0,
'pardakht' => $reportData['data'][$province]->pardakht ?? 0,
];
} else {
$activities[] = [
@@ -64,6 +72,9 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithEvents, WithDrawin
'vasel_shode_bimeh' => "",
'vasel_shode_daghi' => "",
'vasel_shode_final' => "",
'egdam' => "",
'khatm' => "",
'pardakht' => "",
];
}
}

View File

@@ -12,6 +12,7 @@ use App\Services\Cartables\AccidentReceiptTableService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use PhpOffice\PhpSpreadsheet\Exception;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class AccidentReceiptReportController extends Controller
@@ -38,6 +39,10 @@ class AccidentReceiptReportController extends Controller
]);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function countryExcelReport(Request $request, AccidentReceiptTableService $accidentReceiptTableService): BinaryFileResponse
{
$data = $accidentReceiptTableService->countryReport($request);
@@ -45,6 +50,10 @@ class AccidentReceiptReportController extends Controller
return Excel::download(new CountryReport($data), $name);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function provinceExcelReport(Request $request, AccidentReceiptTableService $accidentReceiptTableService): BinaryFileResponse
{
$data = $accidentReceiptTableService->provinceReport($request);