123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?php
- namespace app\api\controller;
- use app\api\logic\Shouhuanlogic;
- //use app\common\server\ShouhuanCommand;
- use think\Controller;
- /**
- * 套餐配送
- *
- * @author wj
- * @date 2022-12-03
- */
- class Shouhuan extends Controller
- {
- protected $middleware = [\app\common\middleware\checkfacility::class];
- /**
- * 创建命令
- *
- * @return void
- * @author wj
- * @date 2023-09-02
- */
- public function createcommand()
- {
- $commandlist = [
- 'init', //初始化
- 'cr', //定位
- 'poweroff', //关机
- 'sos', //sos
- 'interval', //间隔
- 'falldown', //跌倒
- 'pedo', //计步开关
- 'phl', //电话本
- 'remind', //闹钟
- 'silencetime2', //静默时间
- 'remove', //佩戴提醒
- 'bootoff', //开关机时间
- ];
- $data = request()->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);
- }
- }
|