Shouhuan.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. namespace app\api\controller;
  3. use app\api\logic\Shouhuanlogic;
  4. //use app\common\server\ShouhuanCommand;
  5. use think\Controller;
  6. /**
  7. * 套餐配送
  8. *
  9. * @author wj
  10. * @date 2022-12-03
  11. */
  12. class Shouhuan extends Controller
  13. {
  14. protected $middleware = [\app\common\middleware\checkfacility::class];
  15. /**
  16. * 创建命令
  17. *
  18. * @return void
  19. * @author wj
  20. * @date 2023-09-02
  21. */
  22. public function createcommand()
  23. {
  24. $commandlist = [
  25. 'init', //初始化
  26. 'cr', //定位
  27. 'poweroff', //关机
  28. 'sos', //sos
  29. 'interval', //间隔
  30. 'falldown', //跌倒
  31. 'pedo', //计步开关
  32. 'phl', //电话本
  33. 'remind', //闹钟
  34. 'silencetime2', //静默时间
  35. 'remove', //佩戴提醒
  36. 'bootoff', //开关机时间
  37. ];
  38. $data = request()->post();
  39. $command = $data['command'];
  40. if (in_array($command, $commandlist)) {
  41. $functionname = 'ctreate' . ucwords($command) . "Command";
  42. if (method_exists($this, $functionname)) {
  43. $facility_id = $data['facility_id'];
  44. $device_id_code = $data['device_id_code'];
  45. $param = !isset($data['param']) || empty($data['param']) ? [] : $data['param'];
  46. $userinfo = request()->suinfo;
  47. $sys_user_id = $userinfo['id'];
  48. $result = $this->$functionname($facility_id, $device_id_code, $param, $sys_user_id);
  49. $this->successjson($result['msg']);
  50. }
  51. }
  52. $this->errorjson("命令错误");
  53. }
  54. private function ctreateInitCommand($facility_id, $device_id_code, $param = [], $sys_user_id)
  55. {
  56. $l_s = new Shouhuanlogic();
  57. $result = $l_s->facilityinit($facility_id, $device_id_code, $param, $sys_user_id);
  58. return $result;
  59. }
  60. private function ctreateCrCommand($facility_id, $device_id_code, $param = [], $sys_user_id)
  61. {
  62. $l_s = new Shouhuanlogic();
  63. $result = $l_s->createcrcommand($facility_id, $device_id_code, $param, $sys_user_id);
  64. return $result;
  65. }
  66. private function ctreatePoweroffCommand($facility_id, $device_id_code, $param, $sys_user_id)
  67. {
  68. $l_s = new Shouhuanlogic();
  69. $result = $l_s->createpoweroffcommand($facility_id, $device_id_code, $param, $sys_user_id);
  70. return $result;
  71. }
  72. private function ctreateSosCommand($facility_id, $device_id_code, $param = [], $sys_user_id)
  73. {
  74. $l_s = new Shouhuanlogic();
  75. $result = $l_s->createsoscommand($facility_id, $device_id_code, $param, $sys_user_id);
  76. return $result;
  77. }
  78. private function ctreateIntervalCommand($facility_id, $device_id_code, $param = [], $sys_user_id)
  79. {
  80. $l_s = new Shouhuanlogic();
  81. $result = $l_s->ctreateintervalcommand($facility_id, $device_id_code, $param, $sys_user_id);
  82. return $result;
  83. }
  84. private function ctreateFalldownCommand($facility_id, $device_id_code, $param, $sys_user_id)
  85. {
  86. $l_s = new Shouhuanlogic();
  87. $result = $l_s->createfalldowncommand($facility_id, $device_id_code, $param, $sys_user_id);
  88. return $result;
  89. }
  90. private function ctreatePedoCommand($facility_id, $device_id_code, $param, $sys_user_id)
  91. {
  92. $l_s = new Shouhuanlogic();
  93. $result = $l_s->createpedocommand($facility_id, $device_id_code, $param, $sys_user_id);
  94. return $result;
  95. }
  96. private function ctreatePhlCommand($facility_id, $device_id_code, $param = [], $sys_user_id)
  97. {
  98. $l_s = new Shouhuanlogic();
  99. $result = $l_s->createphlcommand($facility_id, $device_id_code, $param, $sys_user_id);
  100. return $result;
  101. }
  102. private function ctreateRemindCommand($facility_id, $device_id_code, $param, $sys_user_id)
  103. {
  104. $l_s = new Shouhuanlogic();
  105. $result = $l_s->createremindcommand($facility_id, $device_id_code, $param, $sys_user_id);
  106. return $result;
  107. }
  108. private function ctreateSilencetime2Command($facility_id, $device_id_code, $param, $sys_user_id)
  109. {
  110. $l_s = new Shouhuanlogic();
  111. $result = $l_s->createsilencetime2command($facility_id, $device_id_code, $param, $sys_user_id);
  112. return $result;
  113. }
  114. private function ctreateRemoveCommand($facility_id, $device_id_code, $param = [], $sys_user_id)
  115. {
  116. $l_s = new Shouhuanlogic();
  117. $result = $l_s->createremovecommand($facility_id, $device_id_code, $param, $sys_user_id);
  118. return $result;
  119. }
  120. private function ctreateBootoffCommand($facility_id, $device_id_code, $param, $sys_user_id)
  121. {
  122. $l_s = new Shouhuanlogic();
  123. $result = $l_s->createbootoffcommand($facility_id, $device_id_code, $param, $sys_user_id);
  124. return $result;
  125. }
  126. /**
  127. * 返回正确信息
  128. *
  129. * @return void
  130. * @author wj
  131. * @date 2023-09-02
  132. */
  133. private function successjson($msg, $data = [])
  134. {
  135. return backjson2(200, $msg, $data);
  136. }
  137. /**
  138. * 返回错误信息
  139. *
  140. * @return void
  141. * @author wj
  142. * @date 2023-09-02
  143. */
  144. private function errorjson($msg)
  145. {
  146. backjson2(500, $msg);
  147. }
  148. }