getStatus(); //判断是否离线,或者状态异常; if($status && $status['error'] == 0 && $status['status'] == 1){ //获取所有喷雾监控点,对应的自动喷雾配置 $deviceList = Device::where('type', Device::TYPE_ATOMIZING)->get(); $time = now()->format('H:i');//获取当前时间(时,分) 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']); } }elseif($time == $end){ if($status['is_running']){ if( ($item['value'] == 'a' && $status['yv1'] == 1) ||($item['value'] == 'b' && $status['yv2'] == 1) ){ $service->close(); } } } } } } } return Command::SUCCESS; } }