select('*')->get()->toArray(); while (true) { sleep(600); $insert = []; $jwkey = []; foreach ($list as $k=>$v){ $value = 0; $point_name = $point_name1 = ''; switch ($v['device_type_id']){ case 1: $value = $this->cgq_rand(); $point_name = strpos($v['title'], '温度') !== false ? '温度' : '湿度'; if($this->zt_rand() === 1) $point_name1 = $point_name.'异常'; break; case 2: $value = $this->kg_rand(); $point_name = '仓门行程开关'; break; case 3: $value = $this->yj_rand(); $point_name = '预警'; break; case 4: if(!isset($jwkey[$v['id']])) $jwkey[$v['id']] = [ 'j' => 120, 'w' => 30 ]; $point_name = 'GPS'; $jwkey[$v['id']]['j'] = $jwkey[$v['id']]['j']+$this->j_rand(); $jwkey[$v['id']]['w'] = $jwkey[$v['id']]['w']+$this->w_rand(); $value = (string)$jwkey[$v['id']]['j'].','.(string)$jwkey[$v['id']]['w']; break; default: break; } //获取节点名称 $detail = [ 'device_name' => $v['title'], 'time' => time()*1000, 'value' => $value, 'device_no' => $v['code'], 'data_point_id' => $k, 'data_point_name' => $point_name, 'push_time' => time()*1000, 'slave_name' => '', ]; $insert[] = $detail; if(! empty($point_name1)){ $detail['data_point_id'] = $k.$k; $detail['data_point_name'] = $point_name1; $detail['value'] = 1; $insert[] = $detail; } } unset($point_name1); // var_dump($insert);die; $a = SystemL::insert($insert); // var_dump($a);die; } } public function j_rand(){ return (rand(0,100)/1000); } public function w_rand(){ return (rand(0,100)/1000); } public function cgq_rand(){ return rand(15,25)+(rand(0,100)/100); } public function kg_rand(){ return rand(0,1); } public function yj_rand(){ return rand(0,1); } public function zt_rand(){ return rand(0,5); } }