develop #7
@@ -47,11 +47,17 @@ class DailyMovingMachineCommand extends Command
|
||||
$missionCodes = $missions->pluck('machine_code');
|
||||
|
||||
$cmmsOnly = $cmms->diff($missionCodes);
|
||||
$missionOnly = $missionCodes->diff($cmms);
|
||||
// $missionOnly = $missionCodes->diff($cmms);
|
||||
|
||||
$violationMachineCodes = MissionViolation::query()->whereDate('request_date', $date)->pluck('machine_code');
|
||||
|
||||
foreach ($cmmsOnly as $code) {
|
||||
$cmm = $response->firstWhere('machineCode', '=', $code);
|
||||
|
||||
if ($violationMachineCodes->contains($cmm->machine_code)) {
|
||||
break;
|
||||
}
|
||||
|
||||
MissionViolation::query()->create([
|
||||
'machine_code' => $code,
|
||||
'machine_id' => CMMSMachine::query()->firstWhere('machine_code', '=', $code)->id,
|
||||
@@ -63,16 +69,16 @@ class DailyMovingMachineCommand extends Command
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($missionOnly as $code) {
|
||||
MissionViolation::query()->create([
|
||||
'machine_code' => $code,
|
||||
'mission_id' => $missions->where('machine_code', '=', $code)->value('id'),
|
||||
'type' => MissionViolationType::ADAM_TAHAROK->value,
|
||||
'request_date' => $date,
|
||||
]);
|
||||
}
|
||||
// foreach ($missionOnly as $code) {
|
||||
// MissionViolation::query()->create([
|
||||
// 'machine_code' => $code,
|
||||
// 'mission_id' => $missions->where('machine_code', '=', $code)->value('id'),
|
||||
// 'type' => MissionViolationType::ADAM_TAHAROK->value,
|
||||
// 'request_date' => $date,
|
||||
// ]);
|
||||
// }
|
||||
|
||||
$this->info("ماشینهای متحرک بدون مأموریت: " . $cmmsOnly->count());
|
||||
$this->info("مأموریتهای بدون حرکت در CMMS: " . $missionOnly->count());
|
||||
// $this->info("مأموریتهای بدون حرکت در CMMS: " . $missionOnly->count());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +198,7 @@ class RequestPortalController extends Controller
|
||||
{
|
||||
DB::transaction(function () use ($mission) {
|
||||
$mission->rahdaran()->detach();
|
||||
$mission->histories()->delete();
|
||||
$mission->delete();
|
||||
});
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ class ViolationManagementController extends Controller
|
||||
'machine_code' => $machine->machine_code,//
|
||||
'station_id' => $user->station_id,
|
||||
'station_name' => RahdariPoint::query()->find( $user->station_id)->name,
|
||||
'km' => $violation->km ?? null,
|
||||
]);
|
||||
|
||||
$mission->rahdaran()->sync($request->rahdaran);
|
||||
@@ -101,6 +102,8 @@ class ViolationManagementController extends Controller
|
||||
'type'=> MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
||||
'status' => MissionViolationStatus::BEDON_EGHDAM->value,
|
||||
'request_date' => now(),
|
||||
'km' => $request->km,
|
||||
'gps' => 0,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
|
||||
@@ -26,7 +26,7 @@ class StoreRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'machine_code' => 'required',
|
||||
'km'=> 'string',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ class UpdateRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'exit_time' => 'required',
|
||||
'enter_time' => 'required',
|
||||
'exit_time' => 'date',
|
||||
'enter_time' => 'date',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class DailyMoveMachineService
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$query = MissionViolation::query();
|
||||
$query = MissionViolation::query()->with('machine:id,car_name');
|
||||
|
||||
if ($user->hasPermissionTo('manage-violation-station')) {
|
||||
$query->whereRelation('machine', 'station_id', '=', $user->station_id);
|
||||
@@ -26,7 +26,7 @@ class DailyMoveMachineService
|
||||
}
|
||||
|
||||
return DataTableFacade::run(
|
||||
MissionViolation::query(),
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('mission_violations', function (Blueprint $table) {
|
||||
$table->string('km')->nullable();
|
||||
$table->unsignedTinyInteger('gps')->default(1);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('mission_violations', function (Blueprint $table) {
|
||||
$table->dropColumn(['km', 'gps']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user