main
Jing Li 2024-06-03 21:14:55 +08:00
parent c4d4f6fc37
commit 13ea196de8
3 changed files with 66 additions and 67 deletions

View File

@ -37,18 +37,11 @@ class WaterQualityReportCommand extends Command
{ {
$this->linkosDeviceLogService = $linkosDeviceLogService; $this->linkosDeviceLogService = $linkosDeviceLogService;
$startAt = Carbon::createFromFormat('Y-m-d H:00:00', '2024-04-01 00:00:00'); $this->fill(now()->subHour());
do {
$this->fill($startAt);
$startAt->addHour();
} while ($startAt->lt('2024-06-03 20:00:00'));
} }
protected function fill(Carbon $monitoredAt) protected function fill(Carbon $monitoredAt)
{ {
$linkosDeviceLogService = new LinkosDeviceLogService();
$data = [ $data = [
'conductivity' => rand(560, 565), 'conductivity' => rand(560, 565),
'oxygen' => rand(1000, 1100) / 100, 'oxygen' => rand(1000, 1100) / 100,
@ -128,8 +121,8 @@ class WaterQualityReportCommand extends Command
$data['is_filled'] = true; $data['is_filled'] = true;
} }
$linkosDeviceLogService->handleWaterQualityMonitoringLog($device, $data, $monitoredAt); $this->linkosDeviceLogService->handleWaterQualityMonitoringLog($device, $data, $monitoredAt);
$linkosDeviceLogService->handleWaterQualityMonitoringDailyLog($device, $monitoredAt); $this->linkosDeviceLogService->handleWaterQualityMonitoringDailyLog($device, $monitoredAt);
} }
} }
} }

View File

@ -24,7 +24,7 @@ class Kernel extends ConsoleKernel
->runInBackground(); ->runInBackground();
$schedule->command(Commands\Linkos\WaterQualityReportCommand::class) $schedule->command(Commands\Linkos\WaterQualityReportCommand::class)
->hourlyAt(50) ->hourlyAt(30)
->runInBackground(); ->runInBackground();
$schedule->command(Commands\MonitorDeviceHealthCommand::class, ['yidong']) $schedule->command(Commands\MonitorDeviceHealthCommand::class, ['yidong'])

View File

@ -262,28 +262,29 @@ class DeviceController extends Controller
// } // }
$data[$device->monitoring_point][$_key] = $_dataList[$_key][$deviceColumn] ?? null; $data[$device->monitoring_point][$_key] = $_dataList[$_key][$deviceColumn] ?? null;
}else{//临时写一些假数据
switch($deviceColumn){
case 'chlorine':
$data[$device->monitoring_point][$_key] = 0.016;
break;
case 'conductivity':
$data[$device->monitoring_point][$_key] = 563;//电导率
break;
case 'oxygen':
$data[$device->monitoring_point][$_key] = 0.09;//含氧量
break;
case 'ph':
$data[$device->monitoring_point][$_key] = rand(750, 770) / 100;
break;
case 'temperature':
$data[$device->monitoring_point][$_key] = rand(950, 1050) / 100;
break;
case 'turbidity':
$data[$device->monitoring_point][$_key] = 1028.60;
break;
}
} }
// else{//临时写一些假数据
// switch($deviceColumn){
// case 'chlorine':
// $data[$device->monitoring_point][$_key] = 0.016;
// break;
// case 'conductivity':
// $data[$device->monitoring_point][$_key] = 563;//电导率
// break;
// case 'oxygen':
// $data[$device->monitoring_point][$_key] = 0.09;//含氧量
// break;
// case 'ph':
// $data[$device->monitoring_point][$_key] = rand(750, 770) / 100;
// break;
// case 'temperature':
// $data[$device->monitoring_point][$_key] = rand(950, 1050) / 100;
// break;
// case 'turbidity':
// $data[$device->monitoring_point][$_key] = 1028.60;
// break;
// }
// }
} }
} }
} }
@ -398,17 +399,21 @@ class DeviceController extends Controller
// } // }
$y[] = $value; $y[] = $value;
} elseif ($device->supplier_key === 'device-supplier-linkos') { }
$y[] = match ($deviceColumn) {
'chlorine' => 0.016, // elseif ($device->supplier_key === 'device-supplier-linkos') {
'conductivity' => 563, // $y[] = match ($deviceColumn) {
'oxygen' => 0.09, // 'chlorine' => 0.016,
'ph' => rand(750, 770) / 100, // 'conductivity' => 563,
'temperature' => rand(900, 1100) / 100, // 'oxygen' => 0.09,
'turbidity' => 1028.60, // 'ph' => rand(750, 770) / 100,
default => null, // 'temperature' => rand(900, 1100) / 100,
}; // 'turbidity' => 1028.60,
} else { // default => null,
// };
// }
else {
$y[] = null; $y[] = null;
} }
@ -629,31 +634,32 @@ class DeviceController extends Controller
$monitoringLog = $monitoringLogs->get($key); $monitoringLog = $monitoringLogs->get($key);
if (is_null($monitoringLog)) { if (is_null($monitoringLog)) {
$data[$key] = null;
// 如果是水质设备,则写死假数据 // 如果是水质设备,则写死假数据
if($device->supplier_key === 'device-supplier-linkos' && $device->type == DeviceType::WaterQuality){ // if($device->supplier_key === 'device-supplier-linkos' && $device->type == DeviceType::WaterQuality){
switch($field){ // switch($field){
case 'chlorine': // case 'chlorine':
$data[$key] = 0.016; // $data[$key] = 0.016;
break; // break;
case 'conductivity': // case 'conductivity':
$data[$key] = rand(560, 565);//电导率 // $data[$key] = rand(560, 565);//电导率
break; // break;
case 'oxygen': // case 'oxygen':
$data[$key] = 0.09;//含氧量 // $data[$key] = 0.09;//含氧量
break; // break;
case 'ph': // case 'ph':
$data[$key] = rand(750, 770) / 100; // $data[$key] = rand(750, 770) / 100;
break; // break;
case 'temperature': // case 'temperature':
$data[$key] = rand(950, 1050) / 100; // $data[$key] = rand(950, 1050) / 100;
break; // break;
case 'turbidity': // case 'turbidity':
$data[$key] = 0.33; // $data[$key] = 0.33;
break; // break;
} // }
} else { // } else {
$data[$key] = null; // $data[$key] = null;
} // }
} else { } else {
$data[$key] = $monitoringLog[$field]; $data[$key] = $monitoringLog[$field];
} }