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