i donot know
This commit is contained in:
@@ -19,6 +19,15 @@ class DetailController extends Controller
|
||||
|
||||
public function rahdaran(Mission $mission): JsonResponse
|
||||
{
|
||||
return $this->successResponse($mission->rahdaran()->get(['rahdaran.id', 'rahdaran.name', 'rahdaran.code']));
|
||||
$rahdars = $mission->rahdaran->map(function ($request) {
|
||||
return [
|
||||
'id' => $request->id,
|
||||
'name' => $request->name,
|
||||
'code' => $request->code,
|
||||
'is_driver' => (bool) $request->pivot->is_driver,
|
||||
];
|
||||
});
|
||||
|
||||
return $this->successResponse($rahdars);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class RequestPortalController extends Controller
|
||||
'code' => rand(100000, 999999),
|
||||
]);
|
||||
|
||||
$mission->rahdaran()->attach($request->rahdaran);
|
||||
$mission->rahdaran()->sync($request->rahdaran);
|
||||
|
||||
if ($request->category_id == 2) {
|
||||
$rpc = new OperatorController();
|
||||
|
||||
@@ -65,7 +65,6 @@ class ObservedItemController extends Controller
|
||||
'item_name' => $info_item->item_str,
|
||||
'sub_item_id' => $info_item->sub_item,
|
||||
'sub_item_name' => $info_item->sub_item_str,
|
||||
'local_name' => $item['local_name'],
|
||||
'description' => $item['description'] ?? null,
|
||||
'start_lat' => $start[0],
|
||||
'start_lon' => $start[1],
|
||||
|
||||
@@ -11,10 +11,12 @@ use App\Http\Requests\V3\RoadItem\Operator\UpdateRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\Mission;
|
||||
use App\Models\ObservedItem;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Services\Cartables\RoadItem\OperatorService;
|
||||
use App\Services\NominatimService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -49,6 +51,17 @@ class OperatorController extends Controller
|
||||
*/
|
||||
public function store(StoreRequest $request, NominatimService $nominatimService): JsonResponse
|
||||
{
|
||||
$activityDateTime = Carbon::parse($request->activity_date . ' ' . $request->activity_time);
|
||||
$mission = Mission::findOrFail($request->mission_id);
|
||||
if ($activityDateTime->lt($mission->start_date) || $activityDateTime->gt($mission->end_date)) {
|
||||
throw ValidationException::withMessages([
|
||||
'activity_date_time' => __('زمان گزارش باید بین :start تا :end (بازه مأموریت) باشد.', [
|
||||
'start' => verta($mission->start_date)->format('Y/m/d H:i'),
|
||||
'end' => verta($mission->end_date)->format('Y/m/d H:i'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
$info_item = InfoItem::query()->where('item', $request->item_id)
|
||||
->where('sub_item', $request->sub_item_id)
|
||||
->firstOrFail();
|
||||
|
||||
@@ -42,7 +42,7 @@ class OperatorController extends Controller
|
||||
'status_fa' => 'در حال بررسی',
|
||||
]);
|
||||
|
||||
$road_patrol->mission()->attach($mission->id);
|
||||
$road_patrol->missions()->attach($mission->id);
|
||||
|
||||
auth()->user()->addActivityComplete(1147);
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy;
|
||||
|
||||
use App\Exports\V3\SafetyAndPrivacy\CountryActivityReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\ProvinceActivityReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\SafetyAndPrivacy\OperatorService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class AccessRoadActivityController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
public function countryActivity(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$request->merge(['info_id' => 90]);
|
||||
|
||||
$data = $operatorService->countryActivity($request);
|
||||
|
||||
return $this->successResponse([
|
||||
'activities' => $data,
|
||||
'provinces' => Province::all(['id', 'name_fa']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function provinceActivity(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$request->merge(['info_id' => 90]);
|
||||
|
||||
$data = $operatorService->provinceActivity($request);
|
||||
|
||||
return $this->successResponse([
|
||||
'activities' => $data,
|
||||
'edarateShahri' => EdarateShahri::where('province_id', $request->province_id)->get(['id', 'name_fa']),
|
||||
]);
|
||||
}
|
||||
public function countryExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse
|
||||
{
|
||||
$data = $operatorService->countryActivity($request);
|
||||
$name = 'گزارش نگهداری حریم راه برای راه دسترسی غیر مجاز ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
return Excel::download(new CountryActivityReport($data), $name);
|
||||
}
|
||||
|
||||
public function provinceExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse
|
||||
{
|
||||
$data = $operatorService->provinceActivity($request);
|
||||
$name = 'گزارش نگهداری حریم راه برای راه دسترسی غیر مجاز ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
return Excel::download(new ProvinceActivityReport($data, $request), $name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy;
|
||||
|
||||
use App\Exports\V3\SafetyAndPrivacy\CountryActivityReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\ProvinceActivityReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\SafetyAndPrivacy\OperatorService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class ConstructionActivityController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
public function countryActivity(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$request->merge(['info_id' => 89]);
|
||||
|
||||
$data = $operatorService->countryActivity($request);
|
||||
|
||||
return $this->successResponse([
|
||||
'activities' => $data,
|
||||
'provinces' => Province::all(['id', 'name_fa']),
|
||||
]);
|
||||
}
|
||||
public function provinceActivity(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$request->merge(['info_id' => 89]);
|
||||
|
||||
$data = $operatorService->provinceActivity($request);
|
||||
|
||||
return $this->successResponse([
|
||||
'activities' => $data,
|
||||
'edarateShahri' => EdarateShahri::where('province_id', $request->province_id)->get(['id', 'name_fa']),
|
||||
]);
|
||||
}
|
||||
public function countryExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse
|
||||
{
|
||||
$data = $operatorService->countryActivity($request);
|
||||
$name = ' گزارش نگهداری حریم راه برای ساخت و ساز غیر مجاز' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
return Excel::download(new CountryActivityReport($data), $name);
|
||||
}
|
||||
|
||||
public function provinceExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse
|
||||
{
|
||||
$data = $operatorService->provinceActivity($request);
|
||||
$name = ' گزارش نگهداری حریم راه برای ساخت و ساز غیر مجاز' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
return Excel::download(new ProvinceActivityReport($data, $request), $name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy;
|
||||
|
||||
use App\Exports\V3\SafetyAndPrivacy\CountryActivityReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\ProvinceActivityReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\SafetyAndPrivacy\OperatorService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class UtilityPassingActivityController extends Controller
|
||||
{
|
||||
public function countryActivity(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$request->merge(['info_id' => 91]);
|
||||
|
||||
$data = $operatorService->countryActivity($request);
|
||||
|
||||
return $this->successResponse([
|
||||
'activities' => $data,
|
||||
'provinces' => Province::all(['id', 'name_fa']),
|
||||
]);
|
||||
}
|
||||
public function provinceActivity(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$request->merge(['info_id' => 91]);
|
||||
|
||||
$data = $operatorService->provinceActivity($request);
|
||||
|
||||
return $this->successResponse([
|
||||
'activities' => $data,
|
||||
'edarateShahri' => EdarateShahri::where('province_id', $request->province_id)->get(['id', 'name_fa']),
|
||||
]);
|
||||
}
|
||||
public function countryExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse
|
||||
{
|
||||
$data = $operatorService->countryActivity($request);
|
||||
$name = 'گزارش نگهداری حریم راه برای عبور تاسیسات زیربنایی غیر مجاز ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
return Excel::download(new CountryActivityReport($data), $name);
|
||||
}
|
||||
|
||||
public function provinceExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse
|
||||
{
|
||||
$data = $operatorService->provinceActivity($request);
|
||||
$name = 'گزارش نگهداری حریم راه برای عبور تاسیسات زیربنایی غیر مجاز ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
return Excel::download(new ProvinceActivityReport($data, $request), $name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class StoreRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'rahdaran' => 'required|array',
|
||||
'rahdaran' => 'array',
|
||||
'rahdaran.*' => 'exists:rahdaran,id',
|
||||
'requested_machines' => 'required|array',
|
||||
'type' => 'required|in:1,2',
|
||||
|
||||
@@ -24,14 +24,10 @@ class StoreRequest extends FormRequest
|
||||
return [
|
||||
'road_patrol_id' => 'required|integer|exists:road_patrols,id',
|
||||
'observed_items' => 'required|array|min:1',
|
||||
|
||||
'observed_items.*.item_id' => 'required|integer|exists:info_items,item',
|
||||
'observed_items.*.sub_item_id' => 'required|integer',
|
||||
'observed_items.*.start_point' => 'required|string',
|
||||
|
||||
'observed_items.*.local_name' => 'nullable|string',
|
||||
'observed_items.*.description' => 'nullable|string',
|
||||
|
||||
'observed_items.*.instant_action' => 'required|in:0,1',
|
||||
'observed_items.*.priority' => 'required_if:observed_items.*.instant_action,0|in:1,2,3',
|
||||
'observed_items.*.end_point' => 'required_if:observed_items.*.instant_action,1|string',
|
||||
|
||||
@@ -66,7 +66,7 @@ class Mission extends Model
|
||||
'rahdarables',
|
||||
'rahdarable_id',
|
||||
'rahdar_id',
|
||||
);
|
||||
)->withPivot('is_driver');
|
||||
}
|
||||
|
||||
public function roadObserved(): MorphToMany
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Services\Cartables\SafetyAndPrivacy;
|
||||
|
||||
use App\Exceptions\ProhibitedAction;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\SafetyAndPrivacy;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -35,14 +36,14 @@ class OperatorService
|
||||
public function countryActivity(Request $request): array
|
||||
{
|
||||
$activities = [];
|
||||
$countryQuery = SafetyAndPrivacy::query()->selectRaw('COUNT(*) as qty,info_id, step');
|
||||
$countryQuery = SafetyAndPrivacy::query()->selectRaw('COUNT(*) as qty,axis_type_id, step');
|
||||
|
||||
$country = DataTableFacade::run(
|
||||
$countryQuery,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedGroupBy: ['info_id', 'step']
|
||||
allowedGroupBy: ['axis_type_id', 'step']
|
||||
);
|
||||
|
||||
$countryTotalSum = 0;
|
||||
@@ -50,9 +51,11 @@ class OperatorService
|
||||
'name_fa' => 'کشوری',
|
||||
'province_id' => -1,
|
||||
'sum' => 0,
|
||||
'89' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'90' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'91' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'1' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'2' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'3' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'4' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'5' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
];
|
||||
foreach ($country['data'] as $key => $value) {
|
||||
$countryTotalSum += $value->qty;
|
||||
@@ -61,13 +64,13 @@ class OperatorService
|
||||
}
|
||||
|
||||
$activities[] = (object) $countryData;
|
||||
$provinceQuery = SafetyAndPrivacy::query()->selectRaw('province_id, province_fa, COUNT(*) as qty,info_id, step');
|
||||
$provinceQuery = SafetyAndPrivacy::query()->selectRaw('province_id, province_fa, COUNT(*) as qty,axis_type_id, step');
|
||||
$provinces = DataTableFacade::run(
|
||||
$provinceQuery,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedGroupBy: ['info_id', 'step', 'province_id', 'province_fa']
|
||||
allowedGroupBy: ['axis_type_id', 'step', 'province_id', 'province_fa']
|
||||
);
|
||||
|
||||
foreach ($provinces['data'] as $value)
|
||||
@@ -78,9 +81,11 @@ class OperatorService
|
||||
'province_id' => $provinceId,
|
||||
'name_fa' => $value->province_fa,
|
||||
'sum' => 0,
|
||||
'89' => ['1' => 0, '2' => 0, '3' => 0],
|
||||
'90' => ['1' => 0, '2' => 0, '3' => 0],
|
||||
'91' => ['1' => 0, '2' => 0, '3' => 0],
|
||||
'1' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'2' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'3' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'4' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'5' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
];
|
||||
}
|
||||
$activities[$provinceId]->{$value->info_id}[$value->step] = $value->qty;
|
||||
@@ -93,13 +98,13 @@ class OperatorService
|
||||
public function provinceActivity(Request $request): array
|
||||
{
|
||||
$activities = [];
|
||||
$provinceQuery = SafetyAndPrivacy::query()->selectRaw('COUNT(*) as qty,info_id, step');
|
||||
$provinceQuery = SafetyAndPrivacy::query()->selectRaw('COUNT(*) as qty,axis_type_id, step');
|
||||
$province = DataTableFacade::run(
|
||||
$provinceQuery,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedGroupBy: ['info_id', 'step']
|
||||
allowedGroupBy: ['axis_type_id', 'step']
|
||||
);
|
||||
|
||||
$provinceTotalSum = 0;
|
||||
@@ -107,9 +112,11 @@ class OperatorService
|
||||
'name_fa' => 'استانی',
|
||||
'edare_shahri_id' => -1,
|
||||
'sum' => 0,
|
||||
'89' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'90' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'91' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'1' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'2' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'3' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'4' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'5' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
];
|
||||
foreach ($province['data'] as $key => $value) {
|
||||
$provinceTotalSum += $value->qty;
|
||||
@@ -118,13 +125,13 @@ class OperatorService
|
||||
}
|
||||
$activities[] = (object) $provinceData;
|
||||
|
||||
$citiesQuery = SafetyAndPrivacy::query()->selectRaw('edare_shahri_id, COUNT(*) as qty,info_id, step');
|
||||
$citiesQuery = SafetyAndPrivacy::query()->selectRaw('edare_shahri_id, COUNT(*) as qty,axis_type_id, step');
|
||||
$cities = DataTableFacade::run(
|
||||
$citiesQuery,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedGroupBy: ['info_id', 'step', 'edare_shahri_id']
|
||||
allowedGroupBy: ['axis_type_id', 'step', 'edare_shahri_id']
|
||||
);
|
||||
|
||||
foreach ($cities['data'] as $value)
|
||||
@@ -133,12 +140,14 @@ class OperatorService
|
||||
if (!isset($activities[$cityId])) {
|
||||
$activities[$cityId] = (object) [
|
||||
'edare_shahri_id' => $cityId,
|
||||
'name_fa' => \App\Models\EdarateShahri::query()->find($cityId)->name_fa,
|
||||
'name_fa' => EdarateShahri::query()->find($cityId)->name_fa,
|
||||
'sum' => 0,
|
||||
'89' => ['1' => 0, '2' => 0, '3' => 0],
|
||||
'90' => ['1' => 0, '2' => 0, '3' => 0],
|
||||
'91' => ['1' => 0, '2' => 0, '3' => 0],
|
||||
];
|
||||
'1' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'2' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'3' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'4' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
'5' => ['1' => 0, '2' => 0, '3' => 0,],
|
||||
];
|
||||
}
|
||||
$activities[$cityId]->{$value->info_id}[$value->step] = $value->qty;
|
||||
$activities[$cityId]->sum += $value->qty;
|
||||
|
||||
Reference in New Issue
Block a user