身体数据接口:新增设备记录、优化接口阻抗记录时间等数值判断
设备管理接口:系统设备列表,用户设备列表,绑定列表,解绑列表
This commit is contained in:
parent
cc045787ca
commit
ead5060b5c
|
|
@ -12,7 +12,7 @@ class Calculatebody extends Controller{
|
||||||
public function calculate_body_data_result($data = ['weight'=>52.5,'height'=>165,'age'=>30,'gender'=>1]){
|
public function calculate_body_data_result($data = ['weight'=>52.5,'height'=>165,'age'=>30,'gender'=>1]){
|
||||||
$data['gender'] = $data['gender'] == 0 ? 1 : $data['gender'];
|
$data['gender'] = $data['gender'] == 0 ? 1 : $data['gender'];
|
||||||
|
|
||||||
$data['adc'] = $this->default_adc;
|
$data['adc'] = array_key_exists('adc', $data)?$data['adc']:$this->default_adc;
|
||||||
// 加 bcadd(,,20)
|
// 加 bcadd(,,20)
|
||||||
// 减 bcsub(,,20)
|
// 减 bcsub(,,20)
|
||||||
// 乘 bcmul(,,20)
|
// 乘 bcmul(,,20)
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,26 @@ class Card extends Base{
|
||||||
$data['acd_id'] = '2';
|
$data['acd_id'] = '2';
|
||||||
return $this->set_user_body_data($data);
|
return $this->set_user_body_data($data);
|
||||||
}
|
}
|
||||||
|
// 设备记录
|
||||||
|
// $data = ['id'=>'2','time'=>'1991-04-20 10:10:10','height'=>'15.1','weight'=>'75.1']
|
||||||
|
public function card_manual_recording_device($data = ['aud_id'=>'58','time'=>'2024-06-06 10:10:15','height'=>'175','weight'=>'68','adc'=>'550','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||||
|
if(count(input('post.')) > 0){
|
||||||
|
$data = input('post.');
|
||||||
|
}else{
|
||||||
|
$data['time'] = date('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
// dump($data);
|
||||||
|
// die;
|
||||||
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('height', $data) || !array_key_exists('weight', $data) || !array_key_exists('adc', $data) || !array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if($this->token_time_validate($data['token']) === false){
|
||||||
|
return $this->msg(20001);
|
||||||
|
}
|
||||||
|
unset($data['token']);
|
||||||
|
$data['acd_id'] = '2';
|
||||||
|
return $this->set_user_body_data($data);
|
||||||
|
}
|
||||||
|
|
||||||
// 修改初始体重/目标体重
|
// 修改初始体重/目标体重
|
||||||
public function card_modify_weight($data = ['aud_id'=>'25','weight'=>'25','type'=>1,'time'=>'','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
public function card_modify_weight($data = ['aud_id'=>'25','weight'=>'25','type'=>1,'time'=>'','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||||
|
|
@ -425,7 +445,10 @@ class Card extends Base{
|
||||||
$result_data['weight'] = $data['weight'];
|
$result_data['weight'] = $data['weight'];
|
||||||
$result_data['age'] = $this->calculate_age($user_data['birthday']);
|
$result_data['age'] = $this->calculate_age($user_data['birthday']);
|
||||||
$result_data['gender'] = $user_data['gender'];
|
$result_data['gender'] = $user_data['gender'];
|
||||||
$result_data['adc'] = array_key_exists('impedance', $data)?$data['impedance']:550;
|
if(array_key_exists('adc', $data)){
|
||||||
|
$result_data['adc'] = $data['adc'];
|
||||||
|
}
|
||||||
|
// $result_data['adc'] = array_key_exists('adc', $data)?$data['adc']:550;
|
||||||
$calculate_body_formula = new Calculatebody();
|
$calculate_body_formula = new Calculatebody();
|
||||||
$get_body_value = $calculate_body_formula->calculate_body_data_result($result_data);
|
$get_body_value = $calculate_body_formula->calculate_body_data_result($result_data);
|
||||||
// dump($get_body_value);
|
// dump($get_body_value);
|
||||||
|
|
@ -439,7 +462,7 @@ class Card extends Base{
|
||||||
$set_user_data = Db::table('app_card_body_data')->insert([
|
$set_user_data = Db::table('app_card_body_data')->insert([
|
||||||
'acd_id'=>$data['acd_id'],
|
'acd_id'=>$data['acd_id'],
|
||||||
'aud_id'=>$data['aud_id'],
|
'aud_id'=>$data['aud_id'],
|
||||||
'record_time'=>$data['time'],
|
'record_time'=>array_key_exists('time', $data)?$data['time']:date('Y-m-d H:i:s'),
|
||||||
'create_time'=>date('Y-m-d H:i:s'),
|
'create_time'=>date('Y-m-d H:i:s'),
|
||||||
'last_update_time'=>date('Y-m-d H:i:s'),
|
'last_update_time'=>date('Y-m-d H:i:s'),
|
||||||
'age'=>$get_body_value['age'],
|
'age'=>$get_body_value['age'],
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,208 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\app\controller;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use think\Log;
|
||||||
|
|
||||||
|
|
||||||
|
class Device extends Base{
|
||||||
|
|
||||||
|
protected $color = ['#FF5656','#FFAB00','#5AD06D','#6492F6','#3967D6'];
|
||||||
|
|
||||||
|
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 获取系统设备列表
|
||||||
|
public function device_data_list($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||||
|
if(count(input('post.')) > 0){
|
||||||
|
$data = input('post.');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
// cache($data['token'],time());
|
||||||
|
if($this->token_time_validate($data['token']) === false){
|
||||||
|
return $this->msg(20001);
|
||||||
|
}
|
||||||
|
unset($data['token']);
|
||||||
|
return $this->device_data_list_action($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 绑定系统设备
|
||||||
|
public function device_binding($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','device_id'=>'3','device_mac'=>'54654654']){
|
||||||
|
if(count(input('post.')) > 0){
|
||||||
|
$data = input('post.');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('token', $data) || !array_key_exists('device_id', $data) || !array_key_exists('device_mac', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
// cache($data['token'],time());
|
||||||
|
if($this->token_time_validate($data['token']) === false){
|
||||||
|
return $this->msg(20001);
|
||||||
|
}
|
||||||
|
// unset($data['token']);
|
||||||
|
return $this->device_binding_action($data);
|
||||||
|
}
|
||||||
|
// 获取用户设备列表
|
||||||
|
public function device_user_data_list($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||||
|
if(count(input('post.')) > 0){
|
||||||
|
$data = input('post.');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
// cache($data['token'],time());
|
||||||
|
if($this->token_time_validate($data['token']) === false){
|
||||||
|
return $this->msg(20001);
|
||||||
|
}
|
||||||
|
// unset($data['token']);
|
||||||
|
return $this->device_user_data_list_action($data);
|
||||||
|
}
|
||||||
|
// 解绑系统设备
|
||||||
|
public function device_unbinding($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','id'=>'3']){
|
||||||
|
if(count(input('post.')) > 0){
|
||||||
|
$data = input('post.');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('token', $data) || !array_key_exists('id', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
// cache($data['token'],time());
|
||||||
|
if($this->token_time_validate($data['token']) === false){
|
||||||
|
return $this->msg(20001);
|
||||||
|
}
|
||||||
|
// unset($data['token']);
|
||||||
|
return $this->device_unbinding_action($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################业务接口################################################################
|
||||||
|
################################################################业务接口################################################################
|
||||||
|
|
||||||
|
################################################device_data_list
|
||||||
|
public function device_data_list_action($data){
|
||||||
|
$result = Db::table('app_device_data')->where(['is_del'=>0])->field('id,name,pic,content,page_measure,bluetooth_type,device_model')->select();
|
||||||
|
foreach ($result as $key => $value) {
|
||||||
|
unset($result[$key]['ROW_NUMBER']);
|
||||||
|
}
|
||||||
|
if(empty($result)){
|
||||||
|
return $this->msg(10004);
|
||||||
|
}else{
|
||||||
|
return $this->msg(['list'=>$result]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################device_binding
|
||||||
|
public function device_binding_action($data){
|
||||||
|
$result_user = Db::table('app_account_number')->where(['token'=>$data['token']])->field('id,token')->find();
|
||||||
|
if(!$result_user){
|
||||||
|
return $this->msg(10003);
|
||||||
|
}
|
||||||
|
$device_code_data = Db::table('app_device_code_data')->where(['machine_code'=>$data['device_mac']])->find();
|
||||||
|
if($device_code_data){
|
||||||
|
if($device_code_data['bind_account_id']){
|
||||||
|
return $this->msg(10003,'设备已被绑定');
|
||||||
|
}else{
|
||||||
|
$device_binding = Db::table('app_device_code_data')->where(['machine_code'=>$data['device_mac']])->update([
|
||||||
|
'bind_account_id'=>$result_user['id'],
|
||||||
|
]);
|
||||||
|
if($device_binding){
|
||||||
|
return $this->msg([]);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002,'更新失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$device_binding = Db::table('app_device_code_data')->insert([
|
||||||
|
'add_id'=>$data['device_id'],
|
||||||
|
'machine_code'=>$data['device_mac'],
|
||||||
|
'create_time'=>date('Y-m-d H:i:s'),
|
||||||
|
'bind_account_id'=>$result_user['id'],
|
||||||
|
]);
|
||||||
|
if($device_binding){
|
||||||
|
return $this->msg([]);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################device_user_data_list
|
||||||
|
public function device_user_data_list_action($data){
|
||||||
|
$result_user = Db::table('app_account_number')->where(['token'=>$data['token']])->field('id,token')->find();
|
||||||
|
if(!$result_user){
|
||||||
|
return $this->msg(10003);
|
||||||
|
}
|
||||||
|
$device_code_data = Db::table('app_device_code_data')
|
||||||
|
->alias('adcd')
|
||||||
|
->join('app_device_data add','adcd.add_id = add.id','LEFT')
|
||||||
|
->where(['adcd.bind_account_id'=>$result_user['id']])
|
||||||
|
->field('adcd.id,adcd.add_id,adcd.machine_code,add.name,add.pic,add.content,add.page_measure,add.bluetooth_type,add.device_model')
|
||||||
|
->select();
|
||||||
|
if(count($device_code_data) <= 0){
|
||||||
|
return $this->msg([]);
|
||||||
|
}
|
||||||
|
$device_code_data1 = [];
|
||||||
|
$result = [];
|
||||||
|
foreach ($device_code_data as $key => $value) {
|
||||||
|
if(!array_key_exists($value['add_id'], $device_code_data1)){
|
||||||
|
$device_code_data1[$value['add_id']] = [
|
||||||
|
'add_id'=>$value['add_id'],
|
||||||
|
'name'=>$value['name'],
|
||||||
|
'pic'=>$value['pic'],
|
||||||
|
'content'=>$value['content'],
|
||||||
|
'page_measure'=>$value['page_measure'],
|
||||||
|
'bluetooth_type'=>$value['bluetooth_type'],
|
||||||
|
'device_model'=>$value['device_model'],
|
||||||
|
'list'=>[[
|
||||||
|
'id'=>$value['id'],
|
||||||
|
'mac'=>$value['machine_code']
|
||||||
|
]]
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
array_push($device_code_data1[$value['add_id']]['list'],['id'=>$value['id'],'mac'=>$value['machine_code']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($device_code_data1 as $key => $value) {
|
||||||
|
array_push($result,$value);
|
||||||
|
}
|
||||||
|
return $this->msg(['list'=>$result]);
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################device_binding
|
||||||
|
public function device_unbinding_action($data){
|
||||||
|
$result_user = Db::table('app_account_number')->where(['token'=>$data['token']])->field('id,token')->find();
|
||||||
|
if(!$result_user){
|
||||||
|
return $this->msg(10003);
|
||||||
|
}
|
||||||
|
$device_binding = Db::table('app_device_code_data')->where(['id'=>$data['id'],'bind_account_id'=>$result_user['id']])->update([
|
||||||
|
'bind_account_id'=>'',
|
||||||
|
]);
|
||||||
|
if($device_binding){
|
||||||
|
return $this->msg([]);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################其他接口################################################################
|
||||||
|
################################################################其他接口################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -113,6 +113,9 @@ Route::any('/get_grade_list', 'app/index/get_grade_list');
|
||||||
Route::any('/card_data_detailed', 'app/card/card_data_detailed');
|
Route::any('/card_data_detailed', 'app/card/card_data_detailed');
|
||||||
// 手动记录接口
|
// 手动记录接口
|
||||||
Route::any('/card_manual_recording', 'app/card/card_manual_recording');
|
Route::any('/card_manual_recording', 'app/card/card_manual_recording');
|
||||||
|
// 设备记录
|
||||||
|
Route::any('/card_manual_recording_device', 'app/card/card_manual_recording_device');
|
||||||
|
|
||||||
// 修改初始体重/目标体重
|
// 修改初始体重/目标体重
|
||||||
Route::any('/card_modify_weight', 'app/card/card_modify_weight');
|
Route::any('/card_modify_weight', 'app/card/card_modify_weight');
|
||||||
// 曲线页面图表
|
// 曲线页面图表
|
||||||
|
|
@ -149,7 +152,19 @@ Route::any('/sportstesting_get_one_details', 'app/sportstesting/sportstesting_ge
|
||||||
// 计算并存储数据
|
// 计算并存储数据
|
||||||
Route::any('/sportstesting_set_once_data', 'app/sportstesting/sportstesting_set_once_data');
|
Route::any('/sportstesting_set_once_data', 'app/sportstesting/sportstesting_set_once_data');
|
||||||
|
|
||||||
|
// ################################设备管理################################
|
||||||
|
// 获取系统设备列表
|
||||||
|
Route::any('/device_data_list', 'app/device/device_data_list');
|
||||||
|
// 绑定系统设备
|
||||||
|
Route::any('/device_binding', 'app/device/device_binding');
|
||||||
|
// 获取用户设备列表
|
||||||
|
Route::any('/device_user_data_list', 'app/device/device_user_data_list');
|
||||||
|
// 解绑系统设备
|
||||||
|
Route::any('/device_unbinding', 'app/device/device_unbinding');
|
||||||
|
// // 获取估分历史详情
|
||||||
|
// Route::any('/device_data_list', 'app/device/device_data_list');
|
||||||
|
// // 计算并存储数据
|
||||||
|
// Route::any('/device_data_list', 'app/device/device_data_list');
|
||||||
// ################################我的接口################################
|
// ################################我的接口################################
|
||||||
|
|
||||||
// 获取账号信息
|
// 获取账号信息
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue