getStatus(); //判断是否离线,或者状态异常; if($status && $status['error'] == 0 && $status['status'] == 1){ //获取所有喷雾监控点,对应的自动喷雾配置 $deviceList = Device::where('type', Device::TYPE_ATOMIZING)->get(); $time = now()->format('H:i');//获取当前时间(时,分) $time = '01:00'; foreach($deviceList as $device){ $_config = $device->extends ?? []; if($_config && $_config['is_enable']){//判断该配置是否开启 foreach($_config['config'] as $item){ list($start, $end) = explode(',', $item['time_zone']); //决定开启,关闭, if($time == $start){//相等 // 如果当前对应位置已开启,则不作为 if( ($item['value'] == 'a' && $status['yv1'] == 0) ||($item['value'] == 'b' && $status['yv2'] == 0) ){ $service->open($item['value'], $item['input']); //记录触发日志 AtomizingLog::create([ 'device_id' => $device->id, 'type' => 1, 'content' => '自动开启【区域'.strtoupper($item['value']).'】,喷雾量'.$item['input'].'%', ]); } }elseif($time == $end){ if($status['is_running']){ if( ($item['value'] == 'a' && $status['yv1'] == 1) ||($item['value'] == 'b' && $status['yv2'] == 1) ){ $service->close(); //记录触发日志 AtomizingLog::create([ 'device_id' => $device->id, 'type' => 2, 'content' => '自动关闭【区域'.strtoupper($item['value']).'】', ]); } } } } } } } return Command::SUCCESS; } }