Compare commits
11 Commits
a8c71de069
...
feature/Po
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ac07692a2 | |||
| 0f65437bfa | |||
| 0b7b22ff87 | |||
| e7ced6267d | |||
| 17a6e903ae | |||
| 55c736ac3e | |||
| 5f2d214a56 | |||
| 1e106a0c87 | |||
| 1937f57dd3 | |||
| 72462e8016 | |||
| b5aa3371da |
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Mission;
|
||||
use App\Services\PolylineEncoder;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@@ -12,7 +13,7 @@ class EncodePolyLineCommand extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:encode-poly-line-command';
|
||||
protected $signature = 'polyline:encode';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -24,8 +25,16 @@ class EncodePolyLineCommand extends Command
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(PolylineEncoder $polylineEncoder)
|
||||
public function handle(PolylineEncoder $polylineEncoder): void
|
||||
{
|
||||
Mission::query()->whereNotNull('area')->each(function ($mission) use ($polylineEncoder) {
|
||||
$area = json_decode($mission->area, true);
|
||||
$encodedValue = $polylineEncoder->encodePolyLine($area['coordinates'], lng_lat_format:true);
|
||||
$mission->update([
|
||||
'encoded_route' => $encodedValue,
|
||||
]);
|
||||
});
|
||||
|
||||
$this->info("updated successfully");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ class CMMSMachinesController extends Controller
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: ['machine_code', 'id', 'plak_number', 'car_name', 'car_type', 'status'],
|
||||
allowedSelects: ['machine_code', 'id', 'plak_number', 'car_name', 'car_type', 'status',
|
||||
'province_id', 'city_id', 'station_id', 'status','driver_name'],
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
19
app/Http/Controllers/V3/CityController.php
Normal file
19
app/Http/Controllers/V3/CityController.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\City;
|
||||
use App\Models\Province;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CityController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
return $this->successResponse(City::query()->where('cities.province_id', $request->query('province_id'))->get(['id', 'name_fa']));
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,18 @@ class ReportMachineController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
*/
|
||||
public function countryMachineTypesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
|
||||
{
|
||||
$data = $reportMachineService->countryMachineTypesActivity($request);
|
||||
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||
|
||||
return Excel::download(new machineReport($data), $name);
|
||||
}
|
||||
|
||||
public function provinceMachineTypesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
|
||||
{
|
||||
return $this->successResponse([
|
||||
@@ -97,8 +109,42 @@ class ReportMachineController extends Controller
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: [
|
||||
'id', 'province_id', 'province_name', 'city_id', 'city_name',
|
||||
'end_km', 'km', 'driver_name', 'state_name',
|
||||
'end_km', 'km', 'driver_name', 'state_id', 'station_name'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
*/
|
||||
public function provinceMachineTypesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
|
||||
{
|
||||
$data = $reportMachineService->provinceMachineTypesActivity($request);
|
||||
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||
|
||||
return Excel::download(new machineReport($data), $name);
|
||||
}
|
||||
|
||||
public function countryMachineDriversActivity(Request $request, ReportMachineService $reportMachineService)
|
||||
{
|
||||
return $this->successResponse([
|
||||
'activities' => $reportMachineService->countryMachineDriversActivity($request),
|
||||
// 'provinces' => Province::all(['id', 'name_fa']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function provinceMachineDriversActivity(Request $request, ReportMachineService $reportMachineService)
|
||||
{
|
||||
return $this->successResponse([
|
||||
'activities' => $reportMachineService->provinceMachineDriversActivity($request),
|
||||
// 'city' => City::query()
|
||||
// ->where('province_id', $request->province_id)
|
||||
// ->where(function ($query) {
|
||||
// $query->where('type_id', 1)
|
||||
// ->orWhereIn('name_fa', ['اداره ماشينآلات', 'اداره نقلیه']);
|
||||
// })
|
||||
// ->get(['id', 'name_fa'])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class RequestPortalController extends Controller
|
||||
return response()->json($requestPortalService->datatable($request));
|
||||
}
|
||||
|
||||
public function violations(Request $request): JsonResponse
|
||||
public function violations(Request $request): array
|
||||
{
|
||||
$query = MissionViolation::query()->where([
|
||||
['status', '=', MissionViolationStatus::BEDON_EGHDAM->value],
|
||||
@@ -236,8 +236,8 @@ class RequestPortalController extends Controller
|
||||
{
|
||||
DB::transaction(function () use ($request, $violation) {
|
||||
|
||||
$start = Carbon::parse($violation->exit_station);
|
||||
$end = Carbon::parse($violation->enter_station);
|
||||
$start = Carbon::parse($violation->exit_time);
|
||||
$end = Carbon::parse($violation->enter_time);
|
||||
$type = $start->diffInMinutes($end) > 480 ? MissionTypes::NO_PROCESS_ROZANE->value : MissionTypes::NO_PROCESS_SAATY->value;
|
||||
$user = auth()->user();
|
||||
$zone = $request->zone;
|
||||
@@ -257,14 +257,14 @@ class RequestPortalController extends Controller
|
||||
'encoded_route' => $request->encoded_route,
|
||||
'type' => $type,
|
||||
'type_fa' => MissionTypes::name($type),
|
||||
'start_date' => $violation->exit_station,
|
||||
'end_date' => $violation->enter_station,
|
||||
'start_date' => $violation->exit_time,
|
||||
'end_date' => $violation->enter_time,
|
||||
'end_point' => $request->end_point,
|
||||
'category_id' => $request->category_id,
|
||||
'category_name' => MissionCategory::name($request->category_id),
|
||||
'start_time' => $violation->exit_station,
|
||||
'finish_time' => $violation->enter_station,
|
||||
'mission_duration' => strtotime($violation->enter_station) - strtotime($violation->exit_station),
|
||||
'start_time' => $violation->exit_time,
|
||||
'finish_time' => $violation->enter_time,
|
||||
'mission_duration' => strtotime($violation->enter_time) - strtotime($violation->exit_time),
|
||||
'state_id' => MissionStates::END_MISSION->value,
|
||||
'state_name' => MissionStates::END_MISSION->label(),
|
||||
'explanation' => $request->explanation,
|
||||
|
||||
@@ -54,7 +54,7 @@ class ViolationManagementController extends Controller
|
||||
'city_name' => $user->city_fa,
|
||||
'station_id' => $user->station_id,
|
||||
'station_name' => RahdariPoint::query()->find($user->station_id)->name,
|
||||
'exit_station' => $request->exit_station,
|
||||
'exit_time' => $request->exit_time,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
@@ -68,7 +68,7 @@ class ViolationManagementController extends Controller
|
||||
public function update(UpdateRequest $request, MissionViolation $violation): JsonResponse
|
||||
{
|
||||
$violation->update([
|
||||
'enter_station' => $request->enter_station,
|
||||
'enter_time' => $request->enter_time,
|
||||
'status' => MissionViolationStatus::BEDON_EGHDAM->value,
|
||||
]);
|
||||
|
||||
|
||||
19
app/Http/Controllers/V3/ProvinceController.php
Normal file
19
app/Http/Controllers/V3/ProvinceController.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\City;
|
||||
use App\Models\Province;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProvinceController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function list()
|
||||
{
|
||||
return $this->successResponse(Province::all(['id', 'name_fa']));
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class StoreRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'exit_station' => 'required|date',
|
||||
'exit_time' => 'required|date',
|
||||
'machine_code' => 'required',
|
||||
'km'=> 'string',
|
||||
];
|
||||
|
||||
@@ -26,7 +26,21 @@ class UpdateRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'enter_station' => 'required|date',
|
||||
'enter_time' => 'required|date',
|
||||
];
|
||||
}
|
||||
|
||||
public function after(): array
|
||||
{
|
||||
return [
|
||||
function (Validator $validator) {
|
||||
if (strtotime($this->enter_time) < strtotime($this->violation->exit_time)) {
|
||||
$validator->errors()->add(
|
||||
'time',
|
||||
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
|
||||
);
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ class City extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id'];
|
||||
protected $hidden = [
|
||||
'name_en',
|
||||
'feature_id',
|
||||
|
||||
@@ -13,6 +13,7 @@ class Province extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id'];
|
||||
protected $hidden = [
|
||||
'feature_id',
|
||||
//'center_lat',
|
||||
|
||||
@@ -20,7 +20,7 @@ class ReportMachineService
|
||||
m.machine_code,
|
||||
cm.car_name,
|
||||
COUNT(*) AS missions,
|
||||
SUM(m.end_km - m.km) AS func,
|
||||
SUM(m.end_km - m.km) AS func
|
||||
FROM missions m
|
||||
JOIN cmms_machines cm ON cm.id = m.machine_id
|
||||
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to
|
||||
@@ -59,7 +59,7 @@ class ReportMachineService
|
||||
$sql = "SELECT
|
||||
cm.car_type,
|
||||
COUNT(*) AS missions,
|
||||
SUM(m.end_km - m.km) AS func,
|
||||
SUM(m.end_km - m.km) AS func
|
||||
FROM missions m
|
||||
JOIN cmms_machines cm ON cm.id = m.machine_id
|
||||
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to
|
||||
@@ -80,7 +80,7 @@ class ReportMachineService
|
||||
$sql = "SELECT
|
||||
cm.car_type,
|
||||
COUNT(*) AS missions,
|
||||
SUM(m.end_km - m.km) AS func,
|
||||
SUM(m.end_km - m.km) AS func
|
||||
FROM missions m
|
||||
JOIN cmms_machines cm ON cm.id = m.machine_id
|
||||
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to AND province_id = :province_id
|
||||
@@ -102,7 +102,7 @@ class ReportMachineService
|
||||
m.driver_id,
|
||||
m.driver_name,
|
||||
COUNT(*) AS missions,
|
||||
SUM(m.end_km - m.km) AS func,
|
||||
SUM(m.end_km - m.km) AS func
|
||||
FROM missions m
|
||||
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to
|
||||
GROUP BY m.driver_id;";
|
||||
@@ -123,7 +123,7 @@ class ReportMachineService
|
||||
m.driver_id,
|
||||
m.driver_name,
|
||||
COUNT(*) AS missions,
|
||||
SUM(m.end_km - m.km) AS func,
|
||||
SUM(m.end_km - m.km) AS func
|
||||
FROM missions m
|
||||
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to AND province_id = :province_id
|
||||
GROUP BY m.driver_id;";
|
||||
|
||||
@@ -34,6 +34,7 @@ class RequestPortalService
|
||||
'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id',
|
||||
'end_date', 'request_date', 'end_point', 'encoded_route', 'zone', 'zone_fa', 'start_time', 'finish_time',
|
||||
'code', 'category_id', 'category_name', 'explanation', 'city_id', 'city_name', 'province_id', 'station_name',
|
||||
'driver_id', 'driver_name'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('mission_violations', function (Blueprint $table) {
|
||||
$table->dateTime('exit_station')->nullable();
|
||||
$table->dateTime('enter_station')->nullable();
|
||||
$table->unsignedInteger('station_id')->nullable();
|
||||
$table->string('station_name')->nullable();
|
||||
});
|
||||
@@ -25,7 +23,7 @@ return new class extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('mission_violations', function (Blueprint $table) {
|
||||
$table->dropColumn(['exit_station', 'enter_station']);
|
||||
$table->dropColumn(['station_id', 'station_name']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\V3\Auth\LogoutController;
|
||||
use App\Http\Controllers\V3\CityController;
|
||||
use App\Http\Controllers\V3\CMMSMachinesController;
|
||||
use App\Http\Controllers\V3\DamageManagementController;
|
||||
use App\Http\Controllers\V3\Dashboard\Accident\AccidentReceiptController;
|
||||
@@ -38,6 +39,7 @@ use App\Http\Controllers\V3\LogListManagementController;
|
||||
use App\Http\Controllers\V3\NotificationController;
|
||||
use App\Http\Controllers\V3\PermissionManagementController;
|
||||
use App\Http\Controllers\V3\ProfileController;
|
||||
use App\Http\Controllers\V3\ProvinceController;
|
||||
use App\Http\Controllers\V3\RahdaranController;
|
||||
use App\Http\Controllers\V3\WebServices\RoadItemController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@@ -495,7 +497,7 @@ Route::prefix('missions')
|
||||
Route::get('/', 'index')->name('index');
|
||||
Route::get('/violations', 'violations')->name('violations');
|
||||
Route::post('/', 'store')->name('store');
|
||||
Route::post('/clarifyUnauthorizedExit/{violation}','clarifyUnauthorizedExit')->name('clarifyUnauthorizedExit');
|
||||
Route::post('/clarify_unauthorized_exit/{violation}','clarifyUnauthorizedExit')->name('clarifyUnauthorizedExit');
|
||||
Route::post('/continue/{mission}','continueMission')->name('continueMission');
|
||||
Route::get('/{mission}', 'show')->name('show');
|
||||
Route::post('/{mission}', 'update')->name('update');
|
||||
@@ -571,6 +573,8 @@ Route::prefix('missions')
|
||||
Route::get('/country_machine_types_activity', 'countryMachineTypesActivity')->name('countryMachineTypesActivity');
|
||||
Route::get('/province_machine_types_activity', 'provinceMachineTypesActivity')->name('provinceMachineTypesActivity');
|
||||
Route::get('/machine_details_report', 'machineDetailsReport')->name('machineDetailsReport');
|
||||
Route::get('/country_machine_drivers_activity', 'countryMachineDriversActivity')->name('countryMachineDriversActivity');
|
||||
Route::get('/province_machine_drivers_activity', 'provinceMachineDriversActivity')->name('provinceMachineDriversActivity');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -683,4 +687,18 @@ Route::prefix('role')
|
||||
Route::get('/test', function () {
|
||||
$csvExporter = new \Laracsv\Export();
|
||||
$csvExporter->build(\App\Models\User::all(), ['id' => 'کد یکتا', 'username' => 'نام کاربری'])->download();
|
||||
});
|
||||
});
|
||||
|
||||
Route::prefix('provinces')
|
||||
->name('provinces.')
|
||||
->controller(ProvinceController::class)
|
||||
->group(function () {
|
||||
Route::get('/list', 'list')->name('list');
|
||||
});
|
||||
|
||||
Route::prefix('cities')
|
||||
->name('cities.')
|
||||
->controller(CityController::class)
|
||||
->group(function () {
|
||||
Route::get('/list', 'list')->name('list');
|
||||
});
|
||||
Reference in New Issue
Block a user