change some item in command
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\ActivityMachineType;
|
||||
use App\Models\CMMSMachine;
|
||||
use App\Models\Mission;
|
||||
use App\Models\MissionViolation;
|
||||
use App\Services\CMMS\DailyMovingMachinesService;
|
||||
@@ -30,7 +31,7 @@ class DailyMovingMachineCommand extends Command
|
||||
* Execute the console command.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handle(DailyMovingMachinesService $dailyMovingMachines): void
|
||||
public function handle(DailyMovingMachinesService $dailyMovingMachines,CMMSMachine $machine): void
|
||||
{
|
||||
$vehiclesInfo = $dailyMovingMachines->run();
|
||||
$response = collect($vehiclesInfo['vehiclesInfo']);
|
||||
@@ -39,12 +40,17 @@ class DailyMovingMachineCommand extends Command
|
||||
|
||||
$cmms = $response->pluck('machineCode');
|
||||
|
||||
$mission = Mission::query()
|
||||
$missions = Mission::query()
|
||||
->whereDate('start_time',$date)
|
||||
->pluck('machine_code');
|
||||
->with('machine')
|
||||
->where('machine_id', '=',$machine->id )
|
||||
->get();
|
||||
|
||||
$cmmsOnly = $cmms->diff($mission);
|
||||
$missionOnly = $mission->diff($cmms);
|
||||
$missionCodes = $missions->pluck('machine.machine_code')->filter();
|
||||
|
||||
|
||||
$cmmsOnly = $cmms->diff($missionCodes);
|
||||
$missionOnly = $missionCodes->diff($cmms);
|
||||
|
||||
foreach ($cmmsOnly as $code) {
|
||||
$cmm = $response->firstWhere('machineCode', '=', $code);
|
||||
@@ -60,13 +66,9 @@ class DailyMovingMachineCommand extends Command
|
||||
}
|
||||
|
||||
foreach ($missionOnly as $code) {
|
||||
$missionId = Mission::query()->where('machine_code', $code)
|
||||
->whereDate('start_time', $date)
|
||||
->value('id');
|
||||
|
||||
MissionViolation::query()->create([
|
||||
'machine_code' => $code,
|
||||
'mission_id' => $missionId,
|
||||
'mission_id' => $missions->id,
|
||||
'type' => ActivityMachineType::ADAM_TAHAROK->value,
|
||||
'request_date' => $date,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user