123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- <?php
- namespace app\api\logic;
- use app\common\model\SettingModel;
- use app\common\server\ShouhuanCommand;
- /**
- * 手环处理
- * 低电报警开关 跌倒报警开关 睡眠时间段设置 立即定位 设置翻滚时间 设置sos电话 设置电话本
- * 发送间隔 设备初始化
- *
- * @author wj
- * @date 2023-08-29
- */
- class Shouhuanlogic
- {
- /**
- * 设备初始化
- *
- * @return void
- * @author wj
- * @date 2023-08-29
- */
- public function facilityinit($facility_id, $device_id_code, $sys_user_id)
- {
- $m_s = new SettingModel();
- $s_sc = new ShouhuanCommand();
- $zone = $m_s->getvalue('shouhuan_zone'); //时区
- $upload_interval = $m_s->getvalue('shouhuan_local_space'); //定位间隔
- $fd_is_open = $m_s->getvalue('shouhuan_fall_call'); //定位间隔
- $pedo_is_open = $m_s->getvalue('shouhuan_step_status'); //计步开关
- $remove_is_open = $m_s->getvalue('shouhuan_wear_call'); //佩戴开关
- $param = [
- 'zone' => $zone,
- 'upload_interval' => $upload_interval,
- 'fd_is_open' => $fd_is_open,
- 'lowbat_is_open' => 1,
- 'pedo_is_open' => $pedo_is_open,
- 'remove_is_open' => $remove_is_open,
- ];
- $s_sc->facilityinit($facility_id, $device_id_code, $param, $sys_user_id);
- return backarr(1, "操作成功");
- }
- /**
- * 低电报警开关
- *
- * @param [type] $arr
- * @return void
- * @author wj
- * @date 2023-08-29
- */
- public function createlowbatcommand($facility_id, $device_id_code, $param, $sys_user_id)
- {
- if (!isset($param['is_open'])) {
- throw new \Exception("参数错误");
- }
- $is_open = empty($param['is_open']) ? 0 : 1;
- $s_sc = new ShouhuanCommand();
- $s_sc->createlowbatcommand($facility_id, $device_id_code, $is_open, $sys_user_id);
- return backarr(1, "操作成功");
- }
- /**
- * 设置 跌倒报警开关
- *
- * @param [type] $arr
- * @return void
- * @author wj
- * @date 2023-08-29
- * lsset_type 灵敏度类型 1高 2中 3低
- */
- public function createfalldowncommand($facility_id, $device_id_code, $param, $sys_user_id)
- {
- if (!isset($param['is_open']) || !isset($param['lsset_type'])) {
- throw new \Exception("参数错误");
- }
- $lsset_type = [1, 2, 3];
- if (!in_array($param['lsset_type'], $lsset_type)) {
- $param['lsset_type'] = 1;
- }
- $param['is_open'] = empty($param['is_open']) ? 0 : 1;
- $s_sc = new ShouhuanCommand();
- $s_sc->createfalldowncommand($facility_id, $device_id_code, $param, $sys_user_id);
- return backarr(1, "操作成功");
- }
- //['starttime'=>'21:00','endtime'=>'6:00'];
- /**
- * 设置睡眠/翻滚时间段
- *
- * @param [type] $arr
- * @return void
- * @author wj
- * @date 2023-08-29
- * 参数格式 ['starttime'=>'21:00','endtime'=>'6:00'];
- */
- public function createsleeptimecommand($facility_id, $device_id_code, $data, $sys_user_id)
- {
- $param = ['starttime' => $data['starttime'], 'endtime' => $data['endtime']];
- $s_sc = new ShouhuanCommand();
- $s_sc->createsleeptimecommand($facility_id, $device_id_code, $param, $sys_user_id);
- return backarr(1, "操作成功");
- }
- //立即定位
- public function createcrcommand($facility_id, $device_id_code, $sys_user_id)
- {
- $s_sc = new ShouhuanCommand();
- $s_sc->createcrcommand($facility_id, $device_id_code, $sys_user_id);
- return backarr(1, "操作成功");
- }
- //设置sos 电话
- /**
- * 设置sos 电话
- * tels 一维数组 未验证是否为手机号
- * @param [type] $arr
- * @return void
- * @author wj
- * @date 2023-08-29
- */
- public function createsoscommand($facility_id, $device_id_code, $data, $sys_user_id)
- {
- if (!isset($data['tels'])) {
- throw new \Exception("参数错误");
- }
- $param = $data['tels'];
- $s_sc = new ShouhuanCommand();
- $s_sc->createsoscommand($facility_id, $device_id_code, $param, $sys_user_id);
- return backarr(1, "操作成功");
- }
- //设置电话本
- /**
- * 设置电话本
- * 参数格式
- * $phldata = [
- * ['telno' => '12344', 'name' => '测试2'],
- * ['telno' => '123', 'name' => '测试'],
- * ];
- * @param [type] $arr
- * @return void
- * @author wj
- * @date 2023-08-29
- */
- public function createphlcommand($facility_id, $device_id_code, $data, $sys_user_id)
- {
- $param = $data;
- $s_sc = new ShouhuanCommand();
- $s_sc->createphlcommand($facility_id, $device_id_code, $param, $sys_user_id);
- return backarr(1, "操作成功");
- }
- /**
- * 数据间隔设置
- *
- * @param [type] $facility_id
- * @param [type] $device_id_code
- * @param [type] $data
- * @param [type] $sys_user_id
- * @return void
- * @author wj
- * @date 2023-09-05
- */
- public function ctreateintervalcommand($facility_id, $device_id_code, $data, $sys_user_id)
- {
- $m_s = new SettingModel();
- $s_sc = new ShouhuanCommand();
- $usedata = [];
- //定位
- if (!isset($data['cr_interval']) || empty($data['cr_interval'])) {
- $cr_interval = $m_s->getvalue('shouhuan_local_space'); //分钟
- } else {
- $cr_interval = $data['cr_interval'];
- }
- $usedata['cr_interval'] = bcmul((int) $cr_interval, 60);
- //心率
- if (!isset($data['hrt_interval']) || empty($data['hrt_interval'])) {
- $hrt_interval = $m_s->getvalue('shouhuan_heart_space'); //分钟
- } else {
- $hrt_interval = $data['hrt_interval'];
- }
- $usedata['hrt_interval'] = bcmul((int) $hrt_interval, 60);
- //体温
- if (!isset($data['wd_interval']) || empty($data['wd_interval'])) {
- $wd_interval = $m_s->getvalue('shouhuan_body_space'); //分钟
- } else {
- $wd_interval = $data['wd_interval'];
- }
- $usedata['wd_interval'] = bcmul((int) $wd_interval, 60);
- //血压
- if (!isset($data['bld_interval']) || empty($data['bld_interval'])) {
- $bld_interval = $m_s->getvalue('shouhuan_blood_space'); //分钟
- } else {
- $bld_interval = $data['bld_interval'];
- }
- $usedata['bld_interval'] = bcmul((int) $bld_interval, 60);
- //血氧
- if (!isset($data['ox_interval']) || empty($data['ox_interval'])) {
- $ox_interval = $m_s->getvalue('shouhuan_oxygen_space'); //分钟
- } else {
- $ox_interval = $data['ox_interval'];
- }
- $usedata['ox_interval'] = bcmul((int) $ox_interval, 60);
- $s_sc->setdatainterval($facility_id, $device_id_code, $usedata, $sys_user_id);
- return backarr(1, "操作成功");
- }
- /**
- * 关机
- *
- * @param [type] $facility_id
- * @param [type] $device_id_code
- * @param [type] $sys_user_id
- * @return void
- * @author wj
- * @date 2023-09-05
- */
- public function createpoweroffcommand($facility_id, $device_id_code, $sys_user_id)
- {
- $s_sc = new ShouhuanCommand();
- $s_sc->createpoweroffcommand($facility_id, $device_id_code, $sys_user_id);
- return backarr(1, "操作成功");
- }
- /**
- * 静默时间
- *
- * @param [type] $facility_id
- * @param [type] $device_id_code
- * @param [type] $param
- * @param [type] $sys_user_id
- * @return void
- * @author wj
- * @date 2023-09-05
- */
- public function createsilencetime2command($facility_id, $device_id_code, $param, $sys_user_id)
- {
- $s_sc = new ShouhuanCommand();
- $s_sc->createsilencetime2command($facility_id, $device_id_code, $param, $sys_user_id);
- return backarr(1, "操作成功");
- }
- /**
- * 开关机时间
- *
- * @return void
- * @author wj
- * @date 2023-09-05
- */
- public function createbootoffcommand($facility_id, $device_id_code, $param, $sys_user_id)
- {
- $s_sc = new ShouhuanCommand();
- $s_sc->createbootoffcommand($facility_id, $device_id_code, $param, $sys_user_id);
- return backarr(1, "操作成功");
- }
- /**
- * 佩戴提醒
- *
- * @param [type] $facility_id
- * @param [type] $device_id_code
- * @param [type] $param
- * @param [type] $sys_user_id
- * @return void
- * @author wj
- * @date 2023-09-05
- */
- public function createremovecommand($facility_id, $device_id_code, $param, $sys_user_id)
- {
- if (!isset($param['is_open'])) {
- throw new \Exception("参数错误");
- }
- $is_open = empty($param['is_open']) ? 0 : 1;
- $s_sc = new ShouhuanCommand();
- $s_sc->createremovecommand($facility_id, $device_id_code, $is_open, $sys_user_id);
- return backarr(1, "操作成功");
- }
- /**
- * 闹钟
- *
- * @param [type] $facility_id
- * @param [type] $device_id_code
- * @param [type] $param
- * @param [type] $sys_user_id
- * @return void
- * @author wj
- * @date 2023-09-05
- */
- public function createremindcommand($facility_id, $device_id_code, $param, $sys_user_id)
- {
- $s_sc = new ShouhuanCommand();
- $s_sc->createremindcommand($facility_id, $device_id_code, $param, $sys_user_id);
- return backarr(1, "操作成功");
- }
- /**
- * 计步开关
- *
- * @return void
- * @author wj
- * @date 2023-09-05
- */
- public function createpedocommand($facility_id, $device_id_code, $param, $sys_user_id)
- {
- if (!isset($param['is_open'])) {
- throw new \Exception("参数错误");
- }
- $is_open = empty($param['is_open']) ? 0 : 1;
- $s_sc = new ShouhuanCommand();
- $s_sc->createpedocommand($facility_id, $device_id_code, $is_open, $sys_user_id);
- return backarr(1, "操作成功");
- }
- /**
- * 拨打电话
- *
- * @param [type] $facility_id
- * @param [type] $device_id_code
- * @param [type] $param
- * @param [type] $sys_user_id
- * @return void
- * @author wj
- * @date 2023-09-15
- */
- public function createcallcommand($facility_id, $device_id_code, $param, $sys_user_id)
- {
- if (!isset($param['telno']) || empty($param['telno'])) {
- throw new \Exception("参数错误");
- }
- $telno = $param['telno'];
- $s_sc = new ShouhuanCommand();
- $s_sc->createcallcommand($facility_id, $device_id_code, $telno, $sys_user_id);
- return backarr(1, "操作成功");
- }
- }
|