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

View File

@ -24,7 +24,7 @@ class Kernel extends ConsoleKernel
->runInBackground();
$schedule->command(Commands\Linkos\WaterQualityReportCommand::class)
->hourlyAt(50)
->hourlyAt(30)
->runInBackground();
$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;
}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;
} elseif ($device->supplier_key === 'device-supplier-linkos') {
$y[] = match ($deviceColumn) {
'chlorine' => 0.016,
'conductivity' => 563,
'oxygen' => 0.09,
'ph' => rand(750, 770) / 100,
'temperature' => rand(900, 1100) / 100,
'turbidity' => 1028.60,
default => null,
};
} else {
}
// elseif ($device->supplier_key === 'device-supplier-linkos') {
// $y[] = match ($deviceColumn) {
// 'chlorine' => 0.016,
// 'conductivity' => 563,
// 'oxygen' => 0.09,
// 'ph' => rand(750, 770) / 100,
// 'temperature' => rand(900, 1100) / 100,
// 'turbidity' => 1028.60,
// default => null,
// };
// }
else {
$y[] = null;
}
@ -629,31 +634,32 @@ class DeviceController extends Controller
$monitoringLog = $monitoringLogs->get($key);
if (is_null($monitoringLog)) {
// 如果是水质设备,则写死假数据
if($device->supplier_key === 'device-supplier-linkos' && $device->type == DeviceType::WaterQuality){
switch($field){
case 'chlorine':
$data[$key] = 0.016;
break;
case 'conductivity':
$data[$key] = rand(560, 565);//电导率
break;
case 'oxygen':
$data[$key] = 0.09;//含氧量
break;
case 'ph':
$data[$key] = rand(750, 770) / 100;
break;
case 'temperature':
$data[$key] = rand(950, 1050) / 100;
break;
case 'turbidity':
$data[$key] = 0.33;
break;
}
} else {
$data[$key] = null;
}
// 如果是水质设备,则写死假数据
// if($device->supplier_key === 'device-supplier-linkos' && $device->type == DeviceType::WaterQuality){
// switch($field){
// case 'chlorine':
// $data[$key] = 0.016;
// break;
// case 'conductivity':
// $data[$key] = rand(560, 565);//电导率
// break;
// case 'oxygen':
// $data[$key] = 0.09;//含氧量
// break;
// case 'ph':
// $data[$key] = rand(750, 770) / 100;
// break;
// case 'temperature':
// $data[$key] = rand(950, 1050) / 100;
// break;
// case 'turbidity':
// $data[$key] = 0.33;
// break;
// }
// } else {
// $data[$key] = null;
// }
} else {
$data[$key] = $monitoringLog[$field];
}