Compare commits
1 Commits
5d2a6d045b
...
feature/Ma
| Author | SHA1 | Date | |
|---|---|---|---|
| 72462e8016 |
@@ -18,7 +18,7 @@ enum CmmsMachineStatus: int
|
||||
self::AMADE => 'آماده',
|
||||
self::RESERVE => 'رزرو',
|
||||
self::DAR_MAMORIAT => 'در ماموریت',
|
||||
self::KHAREGE_AZ_RADE => 'خارج از رده',
|
||||
self::KHAREGE_AZ_RADE => 'خارج از محدوده',
|
||||
self::DAR_TAMIR => 'در تعمیر',
|
||||
self::FOROKHTEH_SHODE => ' فروخته شده',
|
||||
self::NIZE_BE_TAMIR => 'نیاز به تعمیر',
|
||||
|
||||
@@ -2,20 +2,16 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use function Symfony\Component\String\s;
|
||||
|
||||
enum MissionViolationStatus: int
|
||||
{
|
||||
case BEDON_EGHDAM = 0;
|
||||
case EGHDAM_SHODE = 1;
|
||||
case SABT_SHODE = 2;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::BEDON_EGHDAM => "بدون اقدام",
|
||||
self::EGHDAM_SHODE => "اقدام شده",
|
||||
self::SABT_SHODE => "ثبت شده توسط حراست"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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']));
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,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([
|
||||
@@ -85,4 +97,16 @@ class ReportMachineController extends Controller
|
||||
// ->get(['id', 'name_fa'])
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class RequestPortalController extends Controller
|
||||
'request_date' => now(),
|
||||
'description' => $request->description,
|
||||
'end_point' => $request->end_point,
|
||||
'area' => $request->area,
|
||||
'area' => json_encode($request->area),
|
||||
'category_id' => $request->category_id,
|
||||
'category_name' => MissionCategory::name($request->category_id),
|
||||
'explanation' => $request->explanation,
|
||||
@@ -136,7 +136,7 @@ class RequestPortalController extends Controller
|
||||
'request_date' => now(),
|
||||
'description' => $request->description,
|
||||
'end_point' => $request->end_point,
|
||||
'area' => $request->area,
|
||||
'area' => json_encode($request->area),
|
||||
'category_id' => $request->category_id,
|
||||
'category_name' => MissionCategory::name($request->category_id),
|
||||
'explanation' => $request->explanation,
|
||||
@@ -174,7 +174,7 @@ class RequestPortalController extends Controller
|
||||
'end_date' => $request->end_date,
|
||||
'description' => $request->description,
|
||||
'end_point' => $request->end_point,
|
||||
'area' => $request->area,
|
||||
'area' => json_encode($request->area),
|
||||
'category_id' => $request->category_id,
|
||||
'category_name' => MissionCategory::name($request->category_id),
|
||||
'explanation' => $request->explanation,
|
||||
|
||||
@@ -61,7 +61,6 @@ class ViolationManagementController extends Controller
|
||||
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
||||
'zone' => $zone,
|
||||
'zone_fa' => MissionZones::name($zone),
|
||||
'area' => $request->area,
|
||||
'type' => $type,
|
||||
'type_fa' => MissionTypes::name($type),
|
||||
'start_date' => $request->start_date,
|
||||
@@ -104,7 +103,7 @@ class ViolationManagementController extends Controller
|
||||
'machine_id'=> CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->value('id'),
|
||||
'machine_code'=> $request->machine_code,
|
||||
'type'=> MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
||||
'status' => MissionViolationStatus::SABT_SHODE->value,
|
||||
'status' => MissionViolationStatus::BEDON_EGHDAM->value,
|
||||
'request_date' => now(),
|
||||
'km' => $request->km,
|
||||
'gps' => 0,
|
||||
@@ -112,9 +111,6 @@ class ViolationManagementController extends Controller
|
||||
'province_name' => $user->province_fa,
|
||||
'city_id' => $user->city_id,
|
||||
'city_name' => $user->city_fa,
|
||||
'station_id' => $user->station_id,
|
||||
'station_name' => RahdariPoint::query()->find($user->station_id)->name,
|
||||
'exit_time' => $request->exit_time,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
@@ -129,6 +125,7 @@ class ViolationManagementController extends Controller
|
||||
{
|
||||
$violation->update([
|
||||
'enter_time' => $request->enter_time,
|
||||
'exit_time' => $request->exit_time,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
|
||||
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']));
|
||||
}
|
||||
}
|
||||
@@ -35,9 +35,12 @@ class ContinueMissionRequest extends FormRequest
|
||||
'end_date' => 'required|date',
|
||||
'description' => 'string',
|
||||
'end_point' => 'required|string',
|
||||
'area' => 'required|string',
|
||||
'area' => 'required|array',
|
||||
'area.type' => 'required|string',
|
||||
'area.coordinates' => 'required|array',
|
||||
'explanation' => 'required|string',
|
||||
'category_id' => 'required|in:1,2,3',
|
||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,12 @@ class StoreRequest extends FormRequest
|
||||
'end_date' => 'required|date',
|
||||
'description' => 'string',
|
||||
'end_point' => 'required|string',
|
||||
'area' => 'required|string',
|
||||
'area' => 'required|array',
|
||||
'area.type' => 'required|string',
|
||||
'area.coordinates' => 'required|array',
|
||||
'explanation' => 'required|string',
|
||||
'category_id' => 'required|in:1,2,3',
|
||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -55,12 +58,6 @@ class StoreRequest extends FormRequest
|
||||
);
|
||||
}
|
||||
}
|
||||
if (strtotime($this->end_date) < strtotime($this->start_date)) {
|
||||
$validator->errors()->add(
|
||||
'time',
|
||||
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
|
||||
);
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -35,9 +35,12 @@ class UpdateRequest extends FormRequest
|
||||
'end_date' => 'required|date',
|
||||
'description' => 'string',
|
||||
'end_point' => 'required|string',
|
||||
'area' => 'required|string',
|
||||
'area' => 'required|array',
|
||||
'area.type' => 'required|string',
|
||||
'area.coordinates' => 'required|array',
|
||||
'explanation' => 'required|string',
|
||||
'category_id' => 'required|in:1,2,3',
|
||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -56,12 +59,6 @@ class UpdateRequest extends FormRequest
|
||||
);
|
||||
}
|
||||
}
|
||||
if (strtotime($this->end_date) < strtotime($this->start_date)) {
|
||||
$validator->errors()->add(
|
||||
'time',
|
||||
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
|
||||
);
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
namespace App\Http\Requests\V3\Mission\Violation;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class NoProcessRequest extends FormRequest
|
||||
{
|
||||
@@ -32,7 +30,9 @@ class NoProcessRequest extends FormRequest
|
||||
'start_date' => 'required|date',
|
||||
'end_date' => 'required|date|after:start_date|before:now',
|
||||
'end_point' => 'required|string',
|
||||
'area' => 'required|string',
|
||||
'area' => 'array',
|
||||
'area.type' => 'string',
|
||||
'area.coordinates' => 'array',
|
||||
'category_id' => 'required|in:1,2,3',
|
||||
'explanation' => 'required|string',
|
||||
];
|
||||
|
||||
@@ -25,8 +25,7 @@ class StoreRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'exit_time' => 'required|date',
|
||||
'machine_code' => 'required',
|
||||
'machine_code' => 'required',
|
||||
'km'=> 'string',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ class UpdateRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'enter_time' => 'required|date',
|
||||
'exit_time' => 'date',
|
||||
'enter_time' => 'date',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ class City extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id'];
|
||||
protected $hidden = [
|
||||
'name_en',
|
||||
'feature_id',
|
||||
|
||||
@@ -28,6 +28,13 @@ class Mission extends Model
|
||||
);
|
||||
}
|
||||
|
||||
protected function area(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value) => json_decode($value, true)
|
||||
);
|
||||
}
|
||||
|
||||
public function histories(): HasMany
|
||||
{
|
||||
return $this->hasMany(MissionHistory::class);
|
||||
|
||||
@@ -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;";
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
/**
|
||||
* Class PolylineEncoder
|
||||
*
|
||||
* Encodes a list of latitude/longitude coordinates into an encoded polyline string.
|
||||
*
|
||||
* This implementation is compatible with Google's Polyline Algorithm Format:
|
||||
* https://developers.google.com/maps/documentation/utilities/polylinealgorithm
|
||||
*
|
||||
* Example input:
|
||||
* [
|
||||
* [lat, lng],
|
||||
* [lat, lng]
|
||||
* ]
|
||||
*
|
||||
* or if `$lng_lat_format = true`:
|
||||
* [
|
||||
* [lng, lat],
|
||||
* [lng, lat]
|
||||
* ]
|
||||
*
|
||||
* @package App\Services
|
||||
*/
|
||||
class PolylineEncoder
|
||||
{
|
||||
/**
|
||||
* Encode an array of coordinates into a polyline string.
|
||||
*
|
||||
* Each coordinate is encoded as a delta from the previous point,
|
||||
* scaled by the given precision factor.
|
||||
*
|
||||
* @param array $coords Array of coordinate pairs:
|
||||
* - default: [lat, lng]
|
||||
* - if $lng_lat_format = true: [lng, lat]
|
||||
* @param int $precision Number of decimal places to preserve (default: 6)
|
||||
* @param bool $lng_lat_format If true, input is treated as [lng, lat] instead of [lat, lng]
|
||||
*
|
||||
* @return string Encoded polyline string
|
||||
*/
|
||||
public function encodePolyline(array $coords, int $precision = 6, bool $lng_lat_format = false): string
|
||||
{
|
||||
$factor = 10 ** $precision;
|
||||
$output = '';
|
||||
$prevLat = 0;
|
||||
$prevLng = 0;
|
||||
|
||||
foreach ($coords as [$a, $b]) {
|
||||
[$lat, $lng] = $lng_lat_format ? [$b, $a] : [$a, $b];
|
||||
|
||||
$output .= $this->encodeValue((int)round($lat * $factor) - $prevLat);
|
||||
$output .= $this->encodeValue((int)round($lng * $factor) - $prevLng);
|
||||
|
||||
$prevLat = (int)round($lat * $factor);
|
||||
$prevLng = (int)round($lng * $factor);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a single integer value using Google's polyline encoding algorithm.
|
||||
*
|
||||
* Steps:
|
||||
* - Left shift the value
|
||||
* - Invert bits if negative
|
||||
* - Split into 5-bit chunks
|
||||
* - Convert to ASCII characters
|
||||
*
|
||||
* @param int $value Signed integer delta to encode
|
||||
*
|
||||
* @return string Encoded character sequence
|
||||
*/
|
||||
public function encodeValue(int $value): string
|
||||
{
|
||||
$value = $value < 0 ? ~($value << 1) : ($value << 1);
|
||||
$result = '';
|
||||
|
||||
while ($value >= 0x20) {
|
||||
$result .= chr((0x20 | ($value & 0x1f)) + 63);
|
||||
$value >>= 5;
|
||||
}
|
||||
|
||||
return $result . chr($value + 63);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -683,3 +685,17 @@ 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