Shouhuanlogic.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <?php
  2. namespace app\api\logic;
  3. use app\common\model\SettingModel;
  4. use app\common\server\ShouhuanCommand;
  5. /**
  6. * 手环处理
  7. * 低电报警开关 跌倒报警开关 睡眠时间段设置 立即定位 设置翻滚时间 设置sos电话 设置电话本
  8. * 发送间隔 设备初始化
  9. *
  10. * @author wj
  11. * @date 2023-08-29
  12. */
  13. class Shouhuanlogic
  14. {
  15. /**
  16. * 设备初始化
  17. *
  18. * @return void
  19. * @author wj
  20. * @date 2023-08-29
  21. */
  22. public function facilityinit($facility_id, $device_id_code, $sys_user_id)
  23. {
  24. $m_s = new SettingModel();
  25. $s_sc = new ShouhuanCommand();
  26. $zone = $m_s->getvalue('shouhuan_zone'); //时区
  27. $upload_interval = $m_s->getvalue('shouhuan_local_space'); //定位间隔
  28. $fd_is_open = $m_s->getvalue('shouhuan_fall_call'); //定位间隔
  29. $pedo_is_open = $m_s->getvalue('shouhuan_step_status'); //计步开关
  30. $remove_is_open = $m_s->getvalue('shouhuan_wear_call'); //佩戴开关
  31. $param = [
  32. 'zone' => $zone,
  33. 'upload_interval' => $upload_interval,
  34. 'fd_is_open' => $fd_is_open,
  35. 'lowbat_is_open' => 1,
  36. 'pedo_is_open' => $pedo_is_open,
  37. 'remove_is_open' => $remove_is_open,
  38. ];
  39. $s_sc->facilityinit($facility_id, $device_id_code, $param, $sys_user_id);
  40. return backarr(1, "操作成功");
  41. }
  42. /**
  43. * 低电报警开关
  44. *
  45. * @param [type] $arr
  46. * @return void
  47. * @author wj
  48. * @date 2023-08-29
  49. */
  50. public function createlowbatcommand($facility_id, $device_id_code, $param, $sys_user_id)
  51. {
  52. if (!isset($param['is_open'])) {
  53. throw new \Exception("参数错误");
  54. }
  55. $is_open = empty($param['is_open']) ? 0 : 1;
  56. $s_sc = new ShouhuanCommand();
  57. $s_sc->createlowbatcommand($facility_id, $device_id_code, $is_open, $sys_user_id);
  58. return backarr(1, "操作成功");
  59. }
  60. /**
  61. * 设置 跌倒报警开关
  62. *
  63. * @param [type] $arr
  64. * @return void
  65. * @author wj
  66. * @date 2023-08-29
  67. */
  68. public function createfalldowncommand($facility_id, $device_id_code, $param, $sys_user_id)
  69. {
  70. if (!isset($param['is_open'])) {
  71. throw new \Exception("参数错误");
  72. }
  73. $is_open = empty($param['is_open']) ? 0 : 1;
  74. $s_sc = new ShouhuanCommand();
  75. $s_sc->createfalldowncommand($facility_id, $device_id_code, $is_open, $sys_user_id);
  76. return backarr(1, "操作成功");
  77. }
  78. //['starttime'=>'21:00','endtime'=>'6:00'];
  79. /**
  80. * 设置睡眠/翻滚时间段
  81. *
  82. * @param [type] $arr
  83. * @return void
  84. * @author wj
  85. * @date 2023-08-29
  86. * 参数格式 ['starttime'=>'21:00','endtime'=>'6:00'];
  87. */
  88. public function createsleeptimecommand($facility_id, $device_id_code, $data, $sys_user_id)
  89. {
  90. $param = ['starttime' => $data['starttime'], 'endtime' => $data['endtime']];
  91. $s_sc = new ShouhuanCommand();
  92. $s_sc->createsleeptimecommand($facility_id, $device_id_code, $param, $sys_user_id);
  93. return backarr(1, "操作成功");
  94. }
  95. //立即定位
  96. public function createcrcommand($facility_id, $device_id_code, $sys_user_id)
  97. {
  98. $s_sc = new ShouhuanCommand();
  99. $s_sc->createcrcommand($facility_id, $device_id_code, $sys_user_id);
  100. return backarr(1, "操作成功");
  101. }
  102. //设置sos 电话
  103. /**
  104. * 设置sos 电话
  105. * tels 一维数组 未验证是否为手机号
  106. * @param [type] $arr
  107. * @return void
  108. * @author wj
  109. * @date 2023-08-29
  110. */
  111. public function createsoscommand($facility_id, $device_id_code, $data, $sys_user_id)
  112. {
  113. if (!isset($param['tels'])) {
  114. throw new \Exception("参数错误");
  115. }
  116. $param = $data['tels'];
  117. $s_sc = new ShouhuanCommand();
  118. $s_sc->createsoscommand($facility_id, $device_id_code, $param, $sys_user_id);
  119. return backarr(1, "操作成功");
  120. }
  121. //设置电话本
  122. /**
  123. * 设置电话本
  124. * 参数格式
  125. * $phldata = [
  126. * ['telno' => '12344', 'name' => '测试2'],
  127. * ['telno' => '123', 'name' => '测试'],
  128. * ];
  129. * @param [type] $arr
  130. * @return void
  131. * @author wj
  132. * @date 2023-08-29
  133. */
  134. public function createphlcommand($facility_id, $device_id_code, $data, $sys_user_id)
  135. {
  136. $param = $data;
  137. $s_sc = new ShouhuanCommand();
  138. $s_sc->createphlcommand($facility_id, $device_id_code, $param, $sys_user_id);
  139. return backarr(1, "操作成功");
  140. }
  141. /**
  142. * 数据间隔设置
  143. *
  144. * @param [type] $facility_id
  145. * @param [type] $device_id_code
  146. * @param [type] $data
  147. * @param [type] $sys_user_id
  148. * @return void
  149. * @author wj
  150. * @date 2023-09-05
  151. */
  152. public function ctreateintervalcommand($facility_id, $device_id_code, $data, $sys_user_id)
  153. {
  154. $m_s = new SettingModel();
  155. $s_sc = new ShouhuanCommand();
  156. $usedata = [];
  157. //定位
  158. if (!isset($data['cr_interval']) || empty($data['cr_interval'])) {
  159. $cr_interval = $m_s->getvalue('shouhuan_local_space'); //分钟
  160. } else {
  161. $cr_interval = $data['cr_interval'];
  162. }
  163. $usedata['cr_interval'] = bcmul((int) $cr_interval, 60);
  164. //心率
  165. if (!isset($data['hrt_interval']) || empty($data['hrt_interval'])) {
  166. $hrt_interval = $m_s->getvalue('shouhuan_heart_space'); //分钟
  167. } else {
  168. $hrt_interval = $data['hrt_interval'];
  169. }
  170. $usedata['hrt_interval'] = bcmul((int) $hrt_interval, 60);
  171. //体温
  172. if (!isset($data['wd_interval']) || empty($data['wd_interval'])) {
  173. $wd_interval = $m_s->getvalue('shouhuan_body_space'); //分钟
  174. } else {
  175. $wd_interval = $data['wd_interval'];
  176. }
  177. $usedata['wd_interval'] = bcmul((int) $wd_interval, 60);
  178. //血压
  179. if (!isset($data['bld_interval']) || empty($data['bld_interval'])) {
  180. $bld_interval = $m_s->getvalue('shouhuan_blood_space'); //分钟
  181. } else {
  182. $bld_interval = $data['bld_interval'];
  183. }
  184. $usedata['bld_interval'] = bcmul((int) $bld_interval, 60);
  185. //血氧
  186. if (!isset($data['ox_interval']) || empty($data['ox_interval'])) {
  187. $ox_interval = $m_s->getvalue('shouhuan_oxygen_space'); //分钟
  188. } else {
  189. $ox_interval = $data['ox_interval'];
  190. }
  191. $usedata['ox_interval'] = bcmul((int) $ox_interval, 60);
  192. $s_sc->setdatainterval($facility_id, $device_id_code, $usedata, $sys_user_id);
  193. return backarr(1, "操作成功");
  194. }
  195. /**
  196. * 关机
  197. *
  198. * @param [type] $facility_id
  199. * @param [type] $device_id_code
  200. * @param [type] $sys_user_id
  201. * @return void
  202. * @author wj
  203. * @date 2023-09-05
  204. */
  205. public function createpoweroffcommand($facility_id, $device_id_code, $sys_user_id)
  206. {
  207. $s_sc = new ShouhuanCommand();
  208. $s_sc->createpoweroffcommand($facility_id, $device_id_code, $sys_user_id);
  209. return backarr(1, "操作成功");
  210. }
  211. /**
  212. * 静默时间
  213. *
  214. * @param [type] $facility_id
  215. * @param [type] $device_id_code
  216. * @param [type] $param
  217. * @param [type] $sys_user_id
  218. * @return void
  219. * @author wj
  220. * @date 2023-09-05
  221. */
  222. public function createsilencetime2command($facility_id, $device_id_code, $param, $sys_user_id)
  223. {
  224. $s_sc = new ShouhuanCommand();
  225. $s_sc->createsilencetime2command($facility_id, $device_id_code, $param, $sys_user_id);
  226. return backarr(1, "操作成功");
  227. }
  228. /**
  229. * 开关机时间
  230. *
  231. * @return void
  232. * @author wj
  233. * @date 2023-09-05
  234. */
  235. public function createbootoffcommand($facility_id, $device_id_code, $param, $sys_user_id)
  236. {
  237. $s_sc = new ShouhuanCommand();
  238. $s_sc->createbootoffcommand($facility_id, $device_id_code, $param, $sys_user_id);
  239. return backarr(1, "操作成功");
  240. }
  241. /**
  242. * 佩戴提醒
  243. *
  244. * @param [type] $facility_id
  245. * @param [type] $device_id_code
  246. * @param [type] $param
  247. * @param [type] $sys_user_id
  248. * @return void
  249. * @author wj
  250. * @date 2023-09-05
  251. */
  252. public function createremovecommand($facility_id, $device_id_code, $param, $sys_user_id)
  253. {
  254. if (!isset($param['is_open'])) {
  255. throw new \Exception("参数错误");
  256. }
  257. $is_open = empty($param['is_open']) ? 0 : 1;
  258. $s_sc = new ShouhuanCommand();
  259. $s_sc->createremovecommand($facility_id, $device_id_code, $is_open, $sys_user_id);
  260. return backarr(1, "操作成功");
  261. }
  262. /**
  263. * 闹钟
  264. *
  265. * @param [type] $facility_id
  266. * @param [type] $device_id_code
  267. * @param [type] $param
  268. * @param [type] $sys_user_id
  269. * @return void
  270. * @author wj
  271. * @date 2023-09-05
  272. */
  273. public function createremindcommand($facility_id, $device_id_code, $param, $sys_user_id)
  274. {
  275. $s_sc = new ShouhuanCommand();
  276. $s_sc->createremindcommand($facility_id, $device_id_code, $param, $sys_user_id);
  277. return backarr(1, "操作成功");
  278. }
  279. /**
  280. * 计步开关
  281. *
  282. * @return void
  283. * @author wj
  284. * @date 2023-09-05
  285. */
  286. public function createpedocommand($facility_id, $device_id_code, $param, $sys_user_id)
  287. {
  288. if (!isset($param['is_open'])) {
  289. throw new \Exception("参数错误");
  290. }
  291. $is_open = empty($param['is_open']) ? 0 : 1;
  292. $s_sc = new ShouhuanCommand();
  293. $s_sc->createpedocommand($facility_id, $device_id_code, $is_open, $sys_user_id);
  294. return backarr(1, "操作成功");
  295. }
  296. }