'c03', ], ]; protected $name_default = 0; // 加 bcadd(,,20) // 减 bcsub(,,20) // 乘 bcmul(,,20) // 除 bcdiv(,,20) ################################################################百度接口################################################################ ################################################################百度接口################################################################ ################################################################百度接口################################################################ // 获取配置信息 public function config_msg(){ try { $result = $this->config_msg_action(); return $this->msg($result); } catch (\Exception $e) { // 捕获异常 $logContent["flie"] = $e->getFile(); $logContent["line"] = $e->getLine(); $logContent['all_content'] = "异常信息:\n"; $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); return $this->msg(99999); } } public function save_device_msg($data = ['mac'=>'564654564654654','device_name'=>'bl_5520','batch_code'=>'bc250826']){ try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); } if(!array_key_exists('mac', $data)){ return $this->msg(10001); } if(!array_key_exists('device_name', $data)){ return $this->msg(10001); } if(!array_key_exists('batch_code', $data)){ return $this->msg(10001); } if(!$this->verify_data_is_ok($data['mac'],'str')){ return $this->msg(10005); } if(!$this->verify_data_is_ok($data['device_name'],'str')){ return $this->msg(10005); } if(!$this->verify_data_is_ok($data['batch_code'],'str')){ return $this->msg(10005); } $result = $this->save_device_msg_action($data); return $result; } catch (\Exception $e) { // 捕获异常 $logContent["flie"] = $e->getFile(); $logContent["line"] = $e->getLine(); $logContent['all_content'] = "异常信息:\n"; $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; // dump($data); // die; $this->record_api_log($data, $logContent, null); return $this->msg(99999); } } public function device_batch_list(){ // try { $result = $this->device_batch_list_action(); return $result; // } catch (\Exception $e) { // // 捕获异常 // $logContent["flie"] = $e->getFile(); // $logContent["line"] = $e->getLine(); // $logContent['all_content'] = "异常信息:\n"; // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; // $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n"; // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; // // dump($data); // // die; // $this->record_api_log([], $logContent, null); // return $this->msg(99999); // } } ########################################################################action######################################################################## ########################################################################action######################################################################## ########################################################################action######################################################################## public function config_msg_action(){ $data = [ 'name_list'=>$this->name_list, 'name_default_key'=>$this->name_default, ]; return $data; } public function save_device_msg_action($data){ $device_enter = Db::connect('device_enter_db'); $mac_code = $device_enter->table('device_C02pro')->where(['device_mac'=>$data['mac']])->count(); if($mac_code > 0){ return $this->msg(10002,'该MAC地址已录入'); } $result = $device_enter->table('device_C02pro')->insert([ 'device_mac'=>$data['mac'], 'device_name'=>$data['device_name'], 'batch_code'=>$data['batch_code'], 'create_time'=>date('Y-m-d H:i:s'), ]); if($result){ return $this->msg([]); }else{ return $this->msg(10002); } } public function device_batch_list_action(){ $device_enter = Db::connect('device_enter_db'); $result = $device_enter->query(" SELECT device_name, batch_code, COUNT(*) as num FROM device_C02pro GROUP BY batch_code,device_name ORDER BY MAX(id) desc "); return $this->msg($result); } }