row->id; $device_name = $this->row->device_name; if(empty($device_name)) return true; $lock_info = LockInfo::where(['device_id'=>$id,'status'=>1])->orderBy('box_type','asc')->get()->GroupBy('box_type'); foreach ($lock_info as $lock){ if(empty($lock)) continue; $send_rule = []; foreach ($lock as $protol){ $data = [ 'open'=>$protol->open_time, 'close'=>$protol->close_time, 'start'=>$protol->start_time, 'type'=>$protol['type'], ]; if(empty($protol->value[0])) { $data['value']= ''; } else { $data['value']= $protol->value; } $send_rule["box".$protol->box_type][] = $data; } if(!empty($send_rule)) { $send_rule['query'] = 3600; $res = (new DeviceServer())->sendMsg($device_name,json_encode($send_rule)); sleep('22'); // if($res['Success'] != true){ // return $this->response()->error($device_name.'下发失败'); // continue; // } Log::info('执行规则'.json_encode($send_rule).PHP_EOL); } } return $this->response()->success('下发成功')->refresh(); } }