post(); $command = $data['command']; if (in_array($command, $commandlist)) { $functionname = 'ctreate' . ucwords($command) . "Command"; if (method_exists($this, $functionname)) { try { $facility_id = $data['facility_id']; $device_id_code = $data['device_id_code']; $param = !isset($data['param']) || empty($data['param']) ? [] : $data['param']; if (is_string($param)) { $param = json_decode($param, true); } $userinfo = request()->suinfo; $sys_user_id = $userinfo['user_id']; $result = $this->$functionname($facility_id, $device_id_code, $param, $sys_user_id); return $this->successjson($result['msg']); } catch (\Exception $e) { return $this->errorjson($e->getMessage()); } } } $this->errorjson("命令错误"); } private function ctreateInitCommand($facility_id, $device_id_code, $param = [], $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->facilityinit($facility_id, $device_id_code, $param, $sys_user_id); return $result; } private function ctreateCrCommand($facility_id, $device_id_code, $param = [], $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->createcrcommand($facility_id, $device_id_code, $param, $sys_user_id); return $result; } private function ctreatePoweroffCommand($facility_id, $device_id_code, $param, $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->createpoweroffcommand($facility_id, $device_id_code, $param, $sys_user_id); return $result; } private function ctreateSosCommand($facility_id, $device_id_code, $param = [], $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->createsoscommand($facility_id, $device_id_code, $param, $sys_user_id); return $result; } private function ctreateIntervalCommand($facility_id, $device_id_code, $param = [], $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->ctreateintervalcommand($facility_id, $device_id_code, $param, $sys_user_id); return $result; } private function ctreateFalldownCommand($facility_id, $device_id_code, $param, $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->createfalldowncommand($facility_id, $device_id_code, $param, $sys_user_id); return $result; } private function ctreatePedoCommand($facility_id, $device_id_code, $param, $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->createpedocommand($facility_id, $device_id_code, $param, $sys_user_id); return $result; } private function ctreatePhlCommand($facility_id, $device_id_code, $param = [], $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->createphlcommand($facility_id, $device_id_code, $param, $sys_user_id); return $result; } private function ctreateRemindCommand($facility_id, $device_id_code, $param, $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->createremindcommand($facility_id, $device_id_code, $param, $sys_user_id); return $result; } private function ctreateSilencetime2Command($facility_id, $device_id_code, $param, $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->createsilencetime2command($facility_id, $device_id_code, $param, $sys_user_id); return $result; } private function ctreateRemoveCommand($facility_id, $device_id_code, $param = [], $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->createremovecommand($facility_id, $device_id_code, $param, $sys_user_id); return $result; } private function ctreateBootoffCommand($facility_id, $device_id_code, $param, $sys_user_id) { $l_s = new Shouhuanlogic(); $result = $l_s->createbootoffcommand($facility_id, $device_id_code, $param, $sys_user_id); return $result; } /** * 返回正确信息 * * @return void * @author wj * @date 2023-09-02 */ private function successjson($msg, $data = []) { return backjson2(200, $msg, $data); } /** * 返回错误信息 * * @return void * @author wj * @date 2023-09-02 */ private function errorjson($msg) { return backjson2(500, $msg); } }