fix bugs
This commit is contained in:
@@ -18,7 +18,7 @@ enum CmmsMachineStatus: int
|
|||||||
self::AMADE => 'آماده',
|
self::AMADE => 'آماده',
|
||||||
self::RESERVE => 'رزرو',
|
self::RESERVE => 'رزرو',
|
||||||
self::DAR_MAMORIAT => 'در ماموریت',
|
self::DAR_MAMORIAT => 'در ماموریت',
|
||||||
self::KHAREGE_AZ_RADE => 'خارج از محدوده',
|
self::KHAREGE_AZ_RADE => 'خارج از رده',
|
||||||
self::DAR_TAMIR => 'در تعمیر',
|
self::DAR_TAMIR => 'در تعمیر',
|
||||||
self::FOROKHTEH_SHODE => ' فروخته شده',
|
self::FOROKHTEH_SHODE => ' فروخته شده',
|
||||||
self::NIZE_BE_TAMIR => 'نیاز به تعمیر',
|
self::NIZE_BE_TAMIR => 'نیاز به تعمیر',
|
||||||
|
|||||||
@@ -2,16 +2,20 @@
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
|
use function Symfony\Component\String\s;
|
||||||
|
|
||||||
enum MissionViolationStatus: int
|
enum MissionViolationStatus: int
|
||||||
{
|
{
|
||||||
case BEDON_EGHDAM = 0;
|
case BEDON_EGHDAM = 0;
|
||||||
case EGHDAM_SHODE = 1;
|
case EGHDAM_SHODE = 1;
|
||||||
|
case SABT_SHODE = 2;
|
||||||
|
|
||||||
public function label(): string
|
public function label(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::BEDON_EGHDAM => "بدون اقدام",
|
self::BEDON_EGHDAM => "بدون اقدام",
|
||||||
self::EGHDAM_SHODE => "اقدام شده",
|
self::EGHDAM_SHODE => "اقدام شده",
|
||||||
|
self::SABT_SHODE => "ثبت شده توسط حراست"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ class RequestPortalController extends Controller
|
|||||||
'request_date' => now(),
|
'request_date' => now(),
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'area' => json_encode($request->area),
|
'area' => $request->area,
|
||||||
'category_id' => $request->category_id,
|
'category_id' => $request->category_id,
|
||||||
'category_name' => MissionCategory::name($request->category_id),
|
'category_name' => MissionCategory::name($request->category_id),
|
||||||
'explanation' => $request->explanation,
|
'explanation' => $request->explanation,
|
||||||
@@ -136,7 +136,7 @@ class RequestPortalController extends Controller
|
|||||||
'request_date' => now(),
|
'request_date' => now(),
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'area' => json_encode($request->area),
|
'area' => $request->area,
|
||||||
'category_id' => $request->category_id,
|
'category_id' => $request->category_id,
|
||||||
'category_name' => MissionCategory::name($request->category_id),
|
'category_name' => MissionCategory::name($request->category_id),
|
||||||
'explanation' => $request->explanation,
|
'explanation' => $request->explanation,
|
||||||
@@ -174,7 +174,7 @@ class RequestPortalController extends Controller
|
|||||||
'end_date' => $request->end_date,
|
'end_date' => $request->end_date,
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'area' => json_encode($request->area),
|
'area' => $request->area,
|
||||||
'category_id' => $request->category_id,
|
'category_id' => $request->category_id,
|
||||||
'category_name' => MissionCategory::name($request->category_id),
|
'category_name' => MissionCategory::name($request->category_id),
|
||||||
'explanation' => $request->explanation,
|
'explanation' => $request->explanation,
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class ViolationManagementController extends Controller
|
|||||||
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
||||||
'zone' => $zone,
|
'zone' => $zone,
|
||||||
'zone_fa' => MissionZones::name($zone),
|
'zone_fa' => MissionZones::name($zone),
|
||||||
|
'area' => $request->area,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'type_fa' => MissionTypes::name($type),
|
'type_fa' => MissionTypes::name($type),
|
||||||
'start_date' => $request->start_date,
|
'start_date' => $request->start_date,
|
||||||
@@ -103,7 +104,7 @@ class ViolationManagementController extends Controller
|
|||||||
'machine_id'=> CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->value('id'),
|
'machine_id'=> CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->value('id'),
|
||||||
'machine_code'=> $request->machine_code,
|
'machine_code'=> $request->machine_code,
|
||||||
'type'=> MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
'type'=> MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
||||||
'status' => MissionViolationStatus::BEDON_EGHDAM->value,
|
'status' => MissionViolationStatus::SABT_SHODE->value,
|
||||||
'request_date' => now(),
|
'request_date' => now(),
|
||||||
'km' => $request->km,
|
'km' => $request->km,
|
||||||
'gps' => 0,
|
'gps' => 0,
|
||||||
@@ -111,6 +112,9 @@ class ViolationManagementController extends Controller
|
|||||||
'province_name' => $user->province_fa,
|
'province_name' => $user->province_fa,
|
||||||
'city_id' => $user->city_id,
|
'city_id' => $user->city_id,
|
||||||
'city_name' => $user->city_fa,
|
'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();
|
return $this->successResponse();
|
||||||
@@ -125,7 +129,6 @@ class ViolationManagementController extends Controller
|
|||||||
{
|
{
|
||||||
$violation->update([
|
$violation->update([
|
||||||
'enter_time' => $request->enter_time,
|
'enter_time' => $request->enter_time,
|
||||||
'exit_time' => $request->exit_time,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
|
|||||||
@@ -35,12 +35,9 @@ class ContinueMissionRequest extends FormRequest
|
|||||||
'end_date' => 'required|date',
|
'end_date' => 'required|date',
|
||||||
'description' => 'string',
|
'description' => 'string',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'required|array',
|
'area' => 'required|string',
|
||||||
'area.type' => 'required|string',
|
|
||||||
'area.coordinates' => 'required|array',
|
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,9 @@ class StoreRequest extends FormRequest
|
|||||||
'end_date' => 'required|date',
|
'end_date' => 'required|date',
|
||||||
'description' => 'string',
|
'description' => 'string',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'required|array',
|
'area' => 'required|string',
|
||||||
'area.type' => 'required|string',
|
|
||||||
'area.coordinates' => 'required|array',
|
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +55,12 @@ class StoreRequest extends FormRequest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (strtotime($this->end_date) < strtotime($this->start_date)) {
|
||||||
|
$validator->errors()->add(
|
||||||
|
'time',
|
||||||
|
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,9 @@ class UpdateRequest extends FormRequest
|
|||||||
'end_date' => 'required|date',
|
'end_date' => 'required|date',
|
||||||
'description' => 'string',
|
'description' => 'string',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'required|array',
|
'area' => 'required|string',
|
||||||
'area.type' => 'required|string',
|
|
||||||
'area.coordinates' => 'required|array',
|
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +56,12 @@ class UpdateRequest extends FormRequest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (strtotime($this->end_date) < strtotime($this->start_date)) {
|
||||||
|
$validator->errors()->add(
|
||||||
|
'time',
|
||||||
|
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Http\Requests\V3\Mission\Violation;
|
namespace App\Http\Requests\V3\Mission\Violation;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Validator;
|
||||||
|
|
||||||
class NoProcessRequest extends FormRequest
|
class NoProcessRequest extends FormRequest
|
||||||
{
|
{
|
||||||
@@ -30,9 +32,7 @@ class NoProcessRequest extends FormRequest
|
|||||||
'start_date' => 'required|date',
|
'start_date' => 'required|date',
|
||||||
'end_date' => 'required|date|after:start_date|before:now',
|
'end_date' => 'required|date|after:start_date|before:now',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'array',
|
'area' => 'required|string',
|
||||||
'area.type' => 'string',
|
|
||||||
'area.coordinates' => 'array',
|
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ class StoreRequest extends FormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'machine_code' => 'required',
|
'exit_time' => 'required|date',
|
||||||
|
'machine_code' => 'required',
|
||||||
'km'=> 'string',
|
'km'=> 'string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ class UpdateRequest extends FormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'exit_time' => 'date',
|
'enter_time' => 'required|date',
|
||||||
'enter_time' => 'date',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,13 +28,6 @@ class Mission extends Model
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function area(): Attribute
|
|
||||||
{
|
|
||||||
return Attribute::make(
|
|
||||||
get: fn($value) => json_decode($value, true)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function histories(): HasMany
|
public function histories(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(MissionHistory::class);
|
return $this->hasMany(MissionHistory::class);
|
||||||
|
|||||||
88
app/Services/PolylineEncoder.php
Normal file
88
app/Services/PolylineEncoder.php
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user