diff --git a/app/Console/Commands/SoilMonitoringLogFixCommand.php b/app/Console/Commands/SoilMonitoringLogFixCommand.php deleted file mode 100644 index d82fce2..0000000 --- a/app/Console/Commands/SoilMonitoringLogFixCommand.php +++ /dev/null @@ -1,93 +0,0 @@ -subHour()->startOfHour(); - - if ($hour = $this->argument('hour')) { - $time = Carbon::createFromFormat('Y-m-d H:i:s', $hour)->startOfHour(); - } - - $devices = Device::where('type', DeviceType::Soil) - ->where('status', DeviceStatus::Online) - ->get(); - - foreach ($devices as $device) { - $last = SoilMonitoringLog::where('device_id', $device->id) - ->where('monitored_at', $time->copy()->subHour()) - ->first(); - - if ($last === null) { - continue; - } - - try { - $log = SoilMonitoringLog::firstOrCreate([ - 'device_id' => $device->id, - 'monitored_at' => $time, - ], [ - 'agricultural_base_id' => $device->agricultural_base_id, - ]); - - foreach ([ - 'conductivity', - 'humidity', - 'temperature', - 'n', - 'p', - 'k', - ] as $key) { - if (is_null($log->{$key})) { - $log->{$key} = $last->{$key}; - } - } - - if ($log->isDirty()) { - $log->is_filled = true; - } - - $log->save(); - - if ($log->wasChanged()) { - $linkosDeviceLogService->handleSoilMonitoringDailyLog($device, $time); - } - } catch (Throwable $e) { - report($e); - } - } - - return Command::SUCCESS; - } -} diff --git a/app/Console/Commands/WaterQualityMonitoringLogFixCommand.php b/app/Console/Commands/WaterQualityMonitoringLogFixCommand.php deleted file mode 100644 index 4929839..0000000 --- a/app/Console/Commands/WaterQualityMonitoringLogFixCommand.php +++ /dev/null @@ -1,93 +0,0 @@ -subHour()->startOfHour(); - - if ($hour = $this->argument('hour')) { - $time = Carbon::createFromFormat('Y-m-d H:i:s', $hour)->startOfHour(); - } - - $devices = Device::where('type', DeviceType::WaterQuality) - ->where('status', DeviceStatus::Online) - ->get(); - - foreach ($devices as $device) { - $last = WaterQualityMonitoringLog::where('device_id', $device->id) - ->where('monitored_at', $time->copy()->subHour()) - ->first(); - - if ($last === null) { - continue; - } - - try { - $log = WaterQualityMonitoringLog::firstOrCreate([ - 'device_id' => $device->id, - 'monitored_at' => $time, - ], [ - 'agricultural_base_id' => $device->agricultural_base_id, - ]); - - foreach ([ - 'chlorine', - 'conductivity', - 'oxygen', - 'ph', - 'temperature', - 'turbidity', - ] as $key) { - if (is_null($log->{$key})) { - $log->{$key} = $last->{$key}; - } - } - - if ($log->isDirty()) { - $log->is_filled = true; - } - - $log->save(); - - if ($log->wasChanged()) { - $linkosDeviceLogService->handleWaterQualityMonitoringDailyLog($device, $time); - } - } catch (Throwable $e) { - report($e); - } - } - - return Command::SUCCESS; - } -} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 5050984..4e8a7ea 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -15,14 +15,6 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - $schedule->command(Commands\SoilMonitoringLogFixCommand::class) - ->hourly() - ->runInBackground(); - - $schedule->command(Commands\WaterQualityMonitoringLogFixCommand::class) - ->hourly() - ->runInBackground(); - $schedule->command(Commands\BiAng\WormStatisticsSyncCommand::class) ->hourly() ->runInBackground();