部分更新
|
|
@ -38,9 +38,9 @@ class Base extends Controller{
|
|||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
################################################################接口监控################################################################
|
||||
################################################################接口监控################################################################
|
||||
################################################################接口监控################################################################
|
||||
// 接口记录
|
||||
public function record_api_log($params, $error = null, $response = null){
|
||||
// dump($params);
|
||||
|
|
@ -62,6 +62,62 @@ class Base extends Controller{
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* 接口说明(发邮件)
|
||||
* $address(收件人的邮箱地址) 数组 格式: ['460834639@qq.com','460834639@qq.com'.......]
|
||||
* $content(邮件的主题数据信息) 数组 格式:['title'=>'123','from_user_name'=>'123','content'=>'123']
|
||||
* $annex(附件路径信息) 字符串
|
||||
*/
|
||||
public function send_email_api_error($address,$content,$annex=''){
|
||||
// $ad = '460834639@qq.com';
|
||||
$ad1 = '295155911@qq.com';
|
||||
$mail = new PHPMailer(); //实例化
|
||||
$mail->IsSMTP(); // 启用SMTP
|
||||
$mail->Host = "smtp.126.com"; //SMTP服务器 163邮箱例子
|
||||
$mail->Port = 465; //邮件发送端口
|
||||
$mail->SMTPAuth = true; //启用SMTP认证
|
||||
$mail->SMTPSecure = 'ssl';
|
||||
$mail->CharSet = "UTF-8"; //字符集
|
||||
$mail->Encoding = "base64"; //编码方式
|
||||
$mail->Username = "tsf3920322@126.com"; //你的邮箱
|
||||
$mail->Password = "HLWXNRPUCTHJFIIX"; //你的密码(邮箱后台的授权密码)
|
||||
$mail->From = "tsf3920322@126.com"; //发件人地址(也就是你的邮箱)
|
||||
|
||||
// $mail->Subject = "微盟测试邮件"; //邮件标题
|
||||
$mail->Subject = $content['title']; //邮件标题
|
||||
|
||||
// $mail->FromName = "微盟体测中心"; //发件人姓名
|
||||
$mail->FromName = $content['from_user_name']; //发件人姓名
|
||||
|
||||
|
||||
for ($i=0; $i < count($address); $i++) {
|
||||
$mail->AddAddress($address[$i], ""); //添加收件人(地址,昵称)
|
||||
}
|
||||
|
||||
if($annex != ''){
|
||||
// $url = ROOT_PATH. 'public' . DS . 'tsf' . DS .'demoooo.jpg';
|
||||
$mail->AddAttachment($annex,''); // 添加附件,并指定名称
|
||||
}
|
||||
|
||||
$mail->IsHTML(true); //支持html格式内容
|
||||
|
||||
$neirong = $content['content'];
|
||||
|
||||
$mail->Body = $neirong; //邮件主体内容
|
||||
//发送
|
||||
if (!$mail->Send()) {
|
||||
|
||||
return ['code' => 10003,'msg'=>$mail->ErrorInfo];
|
||||
// return $mail->ErrorInfo;
|
||||
} else {
|
||||
return ['code' => 0];
|
||||
// return 'success';
|
||||
}
|
||||
}
|
||||
|
||||
################################################################通用工具################################################################
|
||||
################################################################通用工具################################################################
|
||||
################################################################通用工具################################################################
|
||||
// 判断token是否过期
|
||||
public function token_time_validate($token){
|
||||
// 591b70e0d80b5fa6d77e6e1384453ab9
|
||||
|
|
@ -116,60 +172,7 @@ class Base extends Controller{
|
|||
|
||||
}
|
||||
}
|
||||
/* 接口说明(发邮件)
|
||||
* $address(收件人的邮箱地址) 数组 格式: ['460834639@qq.com','460834639@qq.com'.......]
|
||||
* $content(邮件的主题数据信息) 数组 格式:['title'=>'123','from_user_name'=>'123','content'=>'123']
|
||||
* $annex(附件路径信息) 字符串
|
||||
*/
|
||||
public function send_email_api_error($address,$content,$annex=''){
|
||||
// $ad = '460834639@qq.com';
|
||||
$ad1 = '295155911@qq.com';
|
||||
$mail = new PHPMailer(); //实例化
|
||||
$mail->IsSMTP(); // 启用SMTP
|
||||
$mail->Host = "smtp.126.com"; //SMTP服务器 163邮箱例子
|
||||
$mail->Port = 465; //邮件发送端口
|
||||
$mail->SMTPAuth = true; //启用SMTP认证
|
||||
$mail->SMTPSecure = 'ssl';
|
||||
$mail->CharSet = "UTF-8"; //字符集
|
||||
$mail->Encoding = "base64"; //编码方式
|
||||
$mail->Username = "tsf3920322@126.com"; //你的邮箱
|
||||
$mail->Password = "HLWXNRPUCTHJFIIX"; //你的密码(邮箱后台的授权密码)
|
||||
$mail->From = "tsf3920322@126.com"; //发件人地址(也就是你的邮箱)
|
||||
|
||||
// $mail->Subject = "微盟测试邮件"; //邮件标题
|
||||
$mail->Subject = $content['title']; //邮件标题
|
||||
|
||||
// $mail->FromName = "微盟体测中心"; //发件人姓名
|
||||
$mail->FromName = $content['from_user_name']; //发件人姓名
|
||||
|
||||
|
||||
for ($i=0; $i < count($address); $i++) {
|
||||
$mail->AddAddress($address[$i], ""); //添加收件人(地址,昵称)
|
||||
}
|
||||
|
||||
if($annex != ''){
|
||||
// $url = ROOT_PATH. 'public' . DS . 'tsf' . DS .'demoooo.jpg';
|
||||
$mail->AddAttachment($annex,''); // 添加附件,并指定名称
|
||||
}
|
||||
|
||||
$mail->IsHTML(true); //支持html格式内容
|
||||
|
||||
$neirong = $content['content'];
|
||||
|
||||
$mail->Body = $neirong; //邮件主体内容
|
||||
//发送
|
||||
if (!$mail->Send()) {
|
||||
|
||||
return ['code' => 10003,'msg'=>$mail->ErrorInfo];
|
||||
// return $mail->ErrorInfo;
|
||||
} else {
|
||||
return ['code' => 0];
|
||||
// return 'success';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 验证
|
||||
// 验证数据类型
|
||||
public function verify_data_is_ok($data = 2,$type){
|
||||
if($type == 'str'){
|
||||
if (is_string($data)) {
|
||||
|
|
@ -225,6 +228,54 @@ class Base extends Controller{
|
|||
return false;
|
||||
}
|
||||
}
|
||||
// 计算常规卡路里
|
||||
public function count_user_nutrition_all($data){
|
||||
// 计算基础代谢率(BMR)
|
||||
if($data['gender'] == 1){
|
||||
// 男性:BMR = 10 × 体重(kg) + 6.25 × 身高(cm) - 5 × 年龄(岁) + 5
|
||||
$bmr = bcmul(10,$data['weight'],20);
|
||||
$bmr = bcadd($bmr,bcmul(6.25,$data['height'],20),20);
|
||||
$bmr = bcsub($bmr,bcmul(5,$data['age_num'],20),20);
|
||||
$bmr = bcadd($bmr,5,2);
|
||||
}else if($data['gender'] == 2){
|
||||
// 女性:BMR = 10 × 体重(kg) + 6.25 × 身高(cm) - 5 × 年龄(岁) - 161
|
||||
$bmr = bcmul(10,$data['weight'],20);
|
||||
$bmr = bcadd($bmr,bcmul(6.25,$data['height'],20),20);
|
||||
$bmr = bcsub($bmr,bcmul(5,$data['age_num'],20),20);
|
||||
$bmr = bcsub($bmr,161,2);
|
||||
}else{
|
||||
return $this->msg(10003,'性别未知');
|
||||
}
|
||||
|
||||
// 每日总能量消耗(TDEE)
|
||||
// 久坐(很少或没有运动):BMR × 1.2
|
||||
// 轻度活动(每周1-3天轻度运动):BMR × 1.375
|
||||
// 中度活动(每周3-5天中度运动):BMR × 1.55
|
||||
// 高度活动(每周6-7天高强度运动):BMR × 1.725
|
||||
// 极高活动(体力劳动或每天高强度训练):BMR × 1.9
|
||||
$tdee = bcmul($bmr,1.55,2);
|
||||
|
||||
// 碳水化合物:通常占总热量的45-65%
|
||||
// 蛋白质:通常占总热量的10-35%
|
||||
// 脂肪:通常占总热量的20-35%
|
||||
// 孩子&成年人:碳水化合物50%,蛋白质20%,脂肪30%。
|
||||
// 老人:碳水化合物50%,蛋白质25%,脂肪25%。
|
||||
// 建议每日摄入量计算:
|
||||
// 1.碳水化合物(克): (TDEE × 碳水化合物比例) / 4
|
||||
// 2.蛋白质(克):(TDEE × 蛋白质比例) / 4
|
||||
// 3.脂肪(克): (TDEE × 脂肪比例) / 9
|
||||
$carbohydrate = bcdiv(bcmul($tdee,0.5,20),4,2);
|
||||
if($data['age_num'] < 65){
|
||||
$protein = bcdiv(bcmul($tdee,0.2,20),4,2);
|
||||
$fat = bcdiv(bcmul($tdee,0.3,20),9,2);
|
||||
}else{
|
||||
$protein = bcdiv(bcmul($tdee,0.25,20),4,2);
|
||||
$fat =bcdiv(bcmul($tdee,0.25,20),9,2);
|
||||
}
|
||||
return ['kcal'=>$tdee,'carbohydrate'=>$carbohydrate,'protein'=>$protein,'fat'=>$fat,'bmr'=>$bmr];
|
||||
}
|
||||
####################################################图片选择上传start##############################################################
|
||||
####################################################图片选择上传start##############################################################
|
||||
####################################################图片选择上传start##############################################################
|
||||
public function pic_chose_list($page = 1) {
|
||||
$data = input();
|
||||
|
|
@ -344,7 +395,13 @@ class Base extends Controller{
|
|||
}
|
||||
}
|
||||
####################################################图片选择上传end##############################################################
|
||||
####################################################图片选择上传end##############################################################
|
||||
####################################################图片选择上传end##############################################################
|
||||
|
||||
|
||||
########################################################其他工具########################################################
|
||||
########################################################其他工具########################################################
|
||||
########################################################其他工具########################################################
|
||||
public function msg($data,$str='',$result = []){
|
||||
if(is_array($data)){
|
||||
if($str != ''){
|
||||
|
|
@ -376,4 +433,6 @@ class Base extends Controller{
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ class Countfood extends Base{
|
|||
}
|
||||
}
|
||||
// 获取记食器板块内容
|
||||
public function get_countfoot_content($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>1,'time'=>'2025-09-17']){
|
||||
public function get_countfoot_content(){
|
||||
// 尝试捕获异常
|
||||
// try {
|
||||
if(count(input('post.')) > 0){
|
||||
|
|
@ -393,14 +393,16 @@ class Countfood extends Base{
|
|||
|
||||
$user_data = $cfc->table($this->kitchenscale_db_msg['user'])
|
||||
->where(["id"=>$data['aud_id']])
|
||||
->field('weight,height,gender,age,is_use_set_kcal,set_kcal')
|
||||
->field('weight,height,gender,age,birthday,is_use_set_kcal,set_kcal')
|
||||
->find();
|
||||
if(!$user_data){
|
||||
return $this->msg(10003);
|
||||
}
|
||||
|
||||
if($user_data['birthday']){
|
||||
$user_data['age_num'] = $this->calculate_age($user_data['birthday']);
|
||||
}else{
|
||||
$user_data['age_num'] = $user_data['age'];
|
||||
|
||||
}
|
||||
$nutrition_data = $this->count_user_nutrition_all($user_data);
|
||||
if($user_data['is_use_set_kcal'] == 1){
|
||||
// 加 bcadd(,,20)
|
||||
|
|
@ -809,51 +811,51 @@ class Countfood extends Base{
|
|||
#######################################################################工具#######################################################################
|
||||
#######################################################################工具#######################################################################
|
||||
|
||||
public function count_user_nutrition_all($data){
|
||||
// 计算基础代谢率(BMR)
|
||||
if($data['gender'] == 1){
|
||||
// 男性:BMR = 10 × 体重(kg) + 6.25 × 身高(cm) - 5 × 年龄(岁) + 5
|
||||
$bmr = bcmul(10,$data['weight'],20);
|
||||
$bmr = bcadd($bmr,bcmul(6.25,$data['height'],20),20);
|
||||
$bmr = bcsub($bmr,bcmul(5,$data['age_num'],20),20);
|
||||
$bmr = bcadd($bmr,5,2);
|
||||
}else if($data['gender'] == 2){
|
||||
// 女性:BMR = 10 × 体重(kg) + 6.25 × 身高(cm) - 5 × 年龄(岁) - 161
|
||||
$bmr = bcmul(10,$data['weight'],20);
|
||||
$bmr = bcadd($bmr,bcmul(6.25,$data['height'],20),20);
|
||||
$bmr = bcsub($bmr,bcmul(5,$data['age_num'],20),20);
|
||||
$bmr = bcsub($bmr,161,2);
|
||||
}else{
|
||||
return $this->msg(10003,'性别未知');
|
||||
}
|
||||
// public function count_user_nutrition_all($data){
|
||||
// // 计算基础代谢率(BMR)
|
||||
// if($data['gender'] == 1){
|
||||
// // 男性:BMR = 10 × 体重(kg) + 6.25 × 身高(cm) - 5 × 年龄(岁) + 5
|
||||
// $bmr = bcmul(10,$data['weight'],20);
|
||||
// $bmr = bcadd($bmr,bcmul(6.25,$data['height'],20),20);
|
||||
// $bmr = bcsub($bmr,bcmul(5,$data['age_num'],20),20);
|
||||
// $bmr = bcadd($bmr,5,2);
|
||||
// }else if($data['gender'] == 2){
|
||||
// // 女性:BMR = 10 × 体重(kg) + 6.25 × 身高(cm) - 5 × 年龄(岁) - 161
|
||||
// $bmr = bcmul(10,$data['weight'],20);
|
||||
// $bmr = bcadd($bmr,bcmul(6.25,$data['height'],20),20);
|
||||
// $bmr = bcsub($bmr,bcmul(5,$data['age_num'],20),20);
|
||||
// $bmr = bcsub($bmr,161,2);
|
||||
// }else{
|
||||
// return $this->msg(10003,'性别未知');
|
||||
// }
|
||||
|
||||
// 每日总能量消耗(TDEE)
|
||||
// 久坐(很少或没有运动):BMR × 1.2
|
||||
// 轻度活动(每周1-3天轻度运动):BMR × 1.375
|
||||
// 中度活动(每周3-5天中度运动):BMR × 1.55
|
||||
// 高度活动(每周6-7天高强度运动):BMR × 1.725
|
||||
// 极高活动(体力劳动或每天高强度训练):BMR × 1.9
|
||||
$tdee = bcmul($bmr,1.55,2);
|
||||
// // 每日总能量消耗(TDEE)
|
||||
// // 久坐(很少或没有运动):BMR × 1.2
|
||||
// // 轻度活动(每周1-3天轻度运动):BMR × 1.375
|
||||
// // 中度活动(每周3-5天中度运动):BMR × 1.55
|
||||
// // 高度活动(每周6-7天高强度运动):BMR × 1.725
|
||||
// // 极高活动(体力劳动或每天高强度训练):BMR × 1.9
|
||||
// $tdee = bcmul($bmr,1.55,2);
|
||||
|
||||
// 碳水化合物:通常占总热量的45-65%
|
||||
// 蛋白质:通常占总热量的10-35%
|
||||
// 脂肪:通常占总热量的20-35%
|
||||
// 孩子&成年人:碳水化合物50%,蛋白质20%,脂肪30%。
|
||||
// 老人:碳水化合物50%,蛋白质25%,脂肪25%。
|
||||
// 建议每日摄入量计算:
|
||||
// 1.碳水化合物(克): (TDEE × 碳水化合物比例) / 4
|
||||
// 2.蛋白质(克):(TDEE × 蛋白质比例) / 4
|
||||
// 3.脂肪(克): (TDEE × 脂肪比例) / 9
|
||||
$carbohydrate = bcdiv(bcmul($tdee,0.5,20),4,2);
|
||||
if($data['age_num'] < 65){
|
||||
$protein = bcdiv(bcmul($tdee,0.2,20),4,2);
|
||||
$fat = bcdiv(bcmul($tdee,0.3,20),9,2);
|
||||
}else{
|
||||
$protein = bcdiv(bcmul($tdee,0.25,20),4,2);
|
||||
$fat =bcdiv(bcmul($tdee,0.25,20),9,2);
|
||||
}
|
||||
return ['kcal'=>$tdee,'carbohydrate'=>$carbohydrate,'protein'=>$protein,'fat'=>$fat,'bmr'=>$bmr];
|
||||
}
|
||||
// // 碳水化合物:通常占总热量的45-65%
|
||||
// // 蛋白质:通常占总热量的10-35%
|
||||
// // 脂肪:通常占总热量的20-35%
|
||||
// // 孩子&成年人:碳水化合物50%,蛋白质20%,脂肪30%。
|
||||
// // 老人:碳水化合物50%,蛋白质25%,脂肪25%。
|
||||
// // 建议每日摄入量计算:
|
||||
// // 1.碳水化合物(克): (TDEE × 碳水化合物比例) / 4
|
||||
// // 2.蛋白质(克):(TDEE × 蛋白质比例) / 4
|
||||
// // 3.脂肪(克): (TDEE × 脂肪比例) / 9
|
||||
// $carbohydrate = bcdiv(bcmul($tdee,0.5,20),4,2);
|
||||
// if($data['age_num'] < 65){
|
||||
// $protein = bcdiv(bcmul($tdee,0.2,20),4,2);
|
||||
// $fat = bcdiv(bcmul($tdee,0.3,20),9,2);
|
||||
// }else{
|
||||
// $protein = bcdiv(bcmul($tdee,0.25,20),4,2);
|
||||
// $fat =bcdiv(bcmul($tdee,0.25,20),9,2);
|
||||
// }
|
||||
// return ['kcal'=>$tdee,'carbohydrate'=>$carbohydrate,'protein'=>$protein,'fat'=>$fat,'bmr'=>$bmr];
|
||||
// }
|
||||
public function calculateDateRange($n) {
|
||||
// 获取当前日期和时间
|
||||
$today = new \DateTime();
|
||||
|
|
|
|||
|
|
@ -25,7 +25,10 @@ class Index extends Base{
|
|||
'collect_list'=>'app_user_collect_list',//点赞表
|
||||
'banner'=>'app_banner_data',//banner
|
||||
'version'=>'app_version_log',//版本表
|
||||
'user'=>'app_user_data',//banner
|
||||
'user'=>'app_user_data',//用户表
|
||||
'kcal_log'=>'app_user_kcal_log',//饮食记录表
|
||||
'search_log'=>'app_user_search_log',//搜索历史表
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
|
@ -157,33 +160,31 @@ class Index extends Base{
|
|||
}
|
||||
|
||||
// 获取默认配置信息(包含:食材的分类列表,用户角色信息)(OK)
|
||||
public function get_default_config($data = ['token'=>'']){
|
||||
try {
|
||||
if(count(input('post.')) > 0){
|
||||
public function get_default_config(){
|
||||
// try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
// if(!array_key_exists('token', $data)){
|
||||
// return $this->msg(10001);
|
||||
// }
|
||||
// if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
// return $this->msg(10005);
|
||||
// }
|
||||
$return_data = $this->get_default_config_action($data);
|
||||
return $return_data;
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "接口: (get_default_config)\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
// } catch (\Exception $e) {
|
||||
// // 捕获异常
|
||||
// $logContent["flie"] = $e->getFile();
|
||||
// $logContent["line"] = $e->getLine();
|
||||
// $logContent['all_content'] = "异常信息:\n";
|
||||
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
// $logContent['all_content'] .= "接口: (get_default_config)\n";
|
||||
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
// $this->record_api_log($data, $logContent, null);
|
||||
// return $this->msg(99999);
|
||||
// }
|
||||
}
|
||||
|
||||
// 首页搜索接口(OK)
|
||||
|
|
@ -227,55 +228,123 @@ class Index extends Base{
|
|||
#######################################################################action#######################################################################
|
||||
#######################################################################action#######################################################################
|
||||
|
||||
// 老版
|
||||
// public function get_default_config_action($data){
|
||||
// $return_data = [
|
||||
// 'cook_label'=>[],
|
||||
// // 'account'=>[],
|
||||
// 'food_list'=>[],
|
||||
// 'banner'=>[],
|
||||
// 'jingang_region'=>[
|
||||
// ['name'=>'菜谱分类','jump_url'=>'/pages/menu/menu','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra1.png'],
|
||||
// ['name'=>'我的收藏','jump_url'=>'/pageTwo/me/mymenu','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra2.png'],
|
||||
// ['name'=>'热量计算','jump_url'=>'/pages/count/count','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra3.png'],
|
||||
// ['name'=>'健康食谱','jump_url'=>'/pages/menu/menu','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra4.png'],
|
||||
// ],
|
||||
// ];
|
||||
|
||||
// $cfc = Db::connect('cfc_db');
|
||||
// // // 获取食材分类列表start
|
||||
// // $foodlist1 = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->where("is_del = 0")->order('sort_num desc')->field('id,name')->select();
|
||||
|
||||
// $foodlist1 = $cfc->query("SELECT id,name FROM ".$this->kitchenscale_db_msg['foodlist1']." WHERE is_del = 0 ORDER BY sort_num");
|
||||
// // dump($foodlist1);
|
||||
// // die;
|
||||
// $foodlist2 = $cfc->table($this->kitchenscale_db_msg['foodlist2'])->where("is_del = 0")->field('id,name,one_id')->select();
|
||||
// // dump($foodlist3);
|
||||
// foreach ($foodlist1 as $key => $value) {
|
||||
// unset($foodlist1[$key]['ROW_NUMBER']);
|
||||
// $foodlist1[$key]['list'] = [];
|
||||
// foreach ($foodlist2 as $k => $v) {
|
||||
// if($v['one_id'] == $value['id']){
|
||||
// unset($foodlist2[$k]['ROW_NUMBER']);
|
||||
// array_push($foodlist1[$key]['list'],$foodlist2[$k]);
|
||||
// // unset($foodlist2[$k]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// $return_data['food_list'] = $foodlist1;
|
||||
// // // 获取食材分类列表end
|
||||
// // 获取菜谱分类标签start
|
||||
// $cook_label = $cfc->table($this->kitchenscale_db_msg['cookbook_label'])
|
||||
// ->where("is_del = 0")
|
||||
// ->field('id,name')
|
||||
// ->select();
|
||||
// foreach ($cook_label as $key => $value) {
|
||||
// unset($cook_label[$key]['ROW_NUMBER']);
|
||||
// }
|
||||
// $return_data['cook_label'] = $cook_label;
|
||||
// // 获取菜谱分类标签end
|
||||
|
||||
// // 获取首页信息start
|
||||
// // 获取banner
|
||||
// $banner_list = $cfc->query("select b.id,b.title,b.cover,b.create_user_head_pic,b.create_user_nickname,c.pic_url
|
||||
// from ".$this->kitchenscale_db_msg['banner']." as a
|
||||
// LEFT JOIN ".$this->kitchenscale_db_msg['cookbook']." as b on a.cookbook_id = b.id
|
||||
// LEFT JOIN ".$this->kitchenscale_db_msg['uploadimg']." as c on b.cover = c.id
|
||||
// where a.is_del=0 AND b.is_del=0
|
||||
// ORDER BY a.sort_num desc,a.id desc
|
||||
// ");
|
||||
// // dump($banner_list);
|
||||
// // die;
|
||||
// if($data['token'] != ''){
|
||||
// // 获取账号下信息以及用户信息
|
||||
// $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic,tel,email')->find();
|
||||
// if(!$user_data){
|
||||
// return $this->msg(20001,'账号信息错误');
|
||||
// }
|
||||
// if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
// return $this->msg(10005);
|
||||
// }
|
||||
// // 获取账号下信息以及用户信息
|
||||
// $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find();
|
||||
// if(!$user_data){
|
||||
// return $this->msg(20001,'账号信息错误');
|
||||
// }
|
||||
// $collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list'])->where(['token'=>$data['token'],'is_del'=>0])->column('cookbook_id');
|
||||
// foreach ($banner_list as $key => $value) {
|
||||
// if(array_key_exists($value['id'],$collect_list)){
|
||||
// $banner_list[$key]['is_me_like_it'] = 'yes';
|
||||
// }else{
|
||||
// $banner_list[$key]['is_me_like_it'] = 'no';
|
||||
// }
|
||||
// unset($banner_list[$key]['ROW_NUMBER']);
|
||||
// }
|
||||
// }else{
|
||||
// foreach ($banner_list as $key => $value) {
|
||||
// $banner_list[$key]['is_me_like_it'] = 'no';
|
||||
// unset($banner_list[$key]['ROW_NUMBER']);
|
||||
// }
|
||||
// }
|
||||
// $return_data['banner'] = $banner_list;
|
||||
// // return $this->msg($return_data);
|
||||
// // 获取首页信息end
|
||||
// return $this->msg($return_data);
|
||||
// }
|
||||
// 新版
|
||||
public function get_default_config_action($data){
|
||||
|
||||
$return_data = [
|
||||
'cook_label'=>[],
|
||||
// 'account'=>[],
|
||||
'food_list'=>[],
|
||||
'banner'=>[],
|
||||
'jingang_region'=>[
|
||||
['name'=>'菜谱分类','jump_url'=>'/pages/menu/menu','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra1.png'],
|
||||
['name'=>'我的收藏','jump_url'=>'/pageTwo/me/mymenu','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra2.png'],
|
||||
['name'=>'热量计算','jump_url'=>'/pages/count/count','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra3.png'],
|
||||
['name'=>'健康食谱','jump_url'=>'/pages/menu/menu','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra4.png'],
|
||||
'user_data'=>[],
|
||||
'kcal_data'=>[
|
||||
'title'=>'今日已摄入热量(千卡)',
|
||||
'kcal'=>['value'=>0,'unit'=>'kcal','standard'=>'不达标','color'=>'#F0AD4E'],
|
||||
'other_elements'=>[
|
||||
'carbohydrate'=>['value'=>0,'unit'=>'g'],
|
||||
'protein'=>['value'=>0,'unit'=>'g'],
|
||||
'fat'=>['value'=>0,'unit'=>'g'],
|
||||
],
|
||||
'list'=>[
|
||||
['title'=>'早餐(千卡)','icon'=>'','value'=>0,'unit'=>'kcal'],
|
||||
['title'=>'午餐(千卡)','icon'=>'','value'=>0,'unit'=>'kcal'],
|
||||
['title'=>'晚餐(千卡)','icon'=>'','value'=>0,'unit'=>'kcal'],
|
||||
['title'=>'加餐(千卡)','icon'=>'','value'=>0,'unit'=>'kcal'],
|
||||
],
|
||||
],
|
||||
'banner_data'=>[],
|
||||
'search_history'=>[],
|
||||
'search_guess'=>[],
|
||||
];
|
||||
|
||||
$cfc = Db::connect('cfc_db');
|
||||
// // 获取食材分类列表start
|
||||
// $foodlist1 = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->where("is_del = 0")->order('sort_num desc')->field('id,name')->select();
|
||||
|
||||
$foodlist1 = $cfc->query("SELECT id,name FROM ".$this->kitchenscale_db_msg['foodlist1']." WHERE is_del = 0 ORDER BY sort_num");
|
||||
// dump($foodlist1);
|
||||
// die;
|
||||
$foodlist2 = $cfc->table($this->kitchenscale_db_msg['foodlist2'])->where("is_del = 0")->field('id,name,one_id')->select();
|
||||
// dump($foodlist3);
|
||||
foreach ($foodlist1 as $key => $value) {
|
||||
unset($foodlist1[$key]['ROW_NUMBER']);
|
||||
$foodlist1[$key]['list'] = [];
|
||||
foreach ($foodlist2 as $k => $v) {
|
||||
if($v['one_id'] == $value['id']){
|
||||
unset($foodlist2[$k]['ROW_NUMBER']);
|
||||
array_push($foodlist1[$key]['list'],$foodlist2[$k]);
|
||||
// unset($foodlist2[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$return_data['food_list'] = $foodlist1;
|
||||
// // 获取食材分类列表end
|
||||
// 获取菜谱分类标签start
|
||||
$cook_label = $cfc->table($this->kitchenscale_db_msg['cookbook_label'])
|
||||
->where("is_del = 0")
|
||||
->field('id,name')
|
||||
->select();
|
||||
foreach ($cook_label as $key => $value) {
|
||||
unset($cook_label[$key]['ROW_NUMBER']);
|
||||
}
|
||||
$return_data['cook_label'] = $cook_label;
|
||||
// 获取菜谱分类标签end
|
||||
|
||||
// 获取首页信息start
|
||||
// 获取banner
|
||||
$banner_list = $cfc->query("select b.id,b.title,b.cover,b.create_user_head_pic,b.create_user_nickname,c.pic_url
|
||||
from ".$this->kitchenscale_db_msg['banner']." as a
|
||||
|
|
@ -284,22 +353,71 @@ class Index extends Base{
|
|||
where a.is_del=0 AND b.is_del=0
|
||||
ORDER BY a.sort_num desc,a.id desc
|
||||
");
|
||||
// dump($banner_list);
|
||||
// die;
|
||||
// 如果有账号信息
|
||||
if($data['token'] != ''){
|
||||
// 获取账号下信息以及用户信息
|
||||
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic,tel,email')->find();
|
||||
if(!$user_data){
|
||||
return $this->msg(20001,'账号信息错误');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
// 获取账号下信息以及用户信息
|
||||
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find();
|
||||
if(!$user_data){
|
||||
// 获取账号下信息以及用户信息 start
|
||||
$user = $cfc->table($this->kitchenscale_db_msg['user'])->where(["token"=>$data['token']])->find();
|
||||
if(!$user){
|
||||
return $this->msg(20001,'账号信息错误');
|
||||
}
|
||||
$return_data['user_data'] = $user;
|
||||
if($return_data['user_data']['birthday']){
|
||||
$return_data['user_data']['age'] = $this->calculate_age($return_data['user_data']['birthday']);
|
||||
}
|
||||
unset($return_data['user_data']['id']);
|
||||
unset($return_data['user_data']['token']);
|
||||
unset($return_data['user_data']['update_time']);
|
||||
unset($return_data['user_data']['ROW_NUMBER']);
|
||||
// 获取账号下信息以及用户信息 end
|
||||
// 处理计食器信息 start
|
||||
$kcal = $cfc->table($this->kitchenscale_db_msg['kcal_log'])->where(["aud_id"=>$user['id'],'is_del'=>0])->whereTime('create_time', 'today')->order('id desc')->select();
|
||||
if(count($kcal)>0){
|
||||
$return_data['kcal_data']['title'] = '今日已摄入热量(千卡)'.$kcal[0]['create_time'];
|
||||
foreach ($kcal as $key => $value) {
|
||||
|
||||
$return_data['kcal_data']['kcal']['value'] = bcadd($return_data['kcal_data']['kcal']['value'],$value['kcal_val'],2);
|
||||
$return_data['kcal_data']['other_elements']['carbohydrate']['value'] = bcadd($return_data['kcal_data']['other_elements']['carbohydrate']['value'],$value['carbohydrate_val'],2);
|
||||
$return_data['kcal_data']['other_elements']['protein']['value'] = bcadd($return_data['kcal_data']['other_elements']['protein']['value'],$value['protein_val'],2);
|
||||
$return_data['kcal_data']['other_elements']['fat']['value'] = bcadd($return_data['kcal_data']['other_elements']['fat']['value'],$value['fat_val'],2);
|
||||
if($value['meals_type'] == '早餐'){
|
||||
$return_data['kcal_data']['list'][0]['value'] = bcadd($return_data['kcal_data']['list'][0]['value'],$value['kcal_val'],2);
|
||||
}else if($value['meals_type'] == '午餐'){
|
||||
$return_data['kcal_data']['list'][1]['value'] = bcadd($return_data['kcal_data']['list'][1]['value'],$value['kcal_val'],2);
|
||||
}else if($value['meals_type'] == '晚餐'){
|
||||
$return_data['kcal_data']['list'][2]['value'] = bcadd($return_data['kcal_data']['list'][2]['value'],$value['kcal_val'],2);
|
||||
}else{
|
||||
$return_data['kcal_data']['list'][3]['value'] = bcadd($return_data['kcal_data']['list'][3]['value'],$value['kcal_val'],2);
|
||||
}
|
||||
}
|
||||
foreach ($return_data['kcal_data']['list'] as $key => $value) {
|
||||
if($value['value'] <= 0){
|
||||
$return_data['kcal_data']['list'][$key]['value'] = '-';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($user['is_use_set_kcal'] == 1){
|
||||
$nutrition_data['kcal'] = $user['set_kcal'];
|
||||
}else{
|
||||
$user['age_num'] = $return_data['user_data']['age'];
|
||||
$nutrition_data = $this->count_user_nutrition_all($user);
|
||||
}
|
||||
|
||||
if(bcdiv($return_data['kcal_data']['kcal']['value'],$nutrition_data['kcal'],2) < 0.9){
|
||||
$return_data['kcal_data']['kcal']['standard'] = '不达标';
|
||||
$return_data['kcal_data']['kcal']['color'] = '#F0AD4E';
|
||||
}else if(bcdiv($return_data['kcal_data']['kcal']['value'],$nutrition_data['kcal'],2) >= 0.9 && bcdiv($return_data['kcal_data']['kcal']['value'],$nutrition_data['kcal'],2) < 1.1){
|
||||
$return_data['kcal_data']['kcal']['standard'] = '达标';
|
||||
$return_data['kcal_data']['kcal']['color'] = '#4CD964';
|
||||
}else{
|
||||
$return_data['kcal_data']['kcal']['standard'] = '超标';
|
||||
$return_data['kcal_data']['kcal']['color'] = '#FF0000';
|
||||
}
|
||||
// 处理计食器信息 end
|
||||
// 处理banner信息 start
|
||||
$collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list'])->where(['token'=>$data['token'],'is_del'=>0])->column('cookbook_id');
|
||||
foreach ($banner_list as $key => $value) {
|
||||
if(array_key_exists($value['id'],$collect_list)){
|
||||
|
|
@ -309,19 +427,26 @@ class Index extends Base{
|
|||
}
|
||||
unset($banner_list[$key]['ROW_NUMBER']);
|
||||
}
|
||||
|
||||
// 处理banner信息 end
|
||||
// 处理搜索历史 start
|
||||
$search_log = $cfc->table($this->kitchenscale_db_msg['search_log'])->where(["aud_id"=>$user['id'],'is_del'=>0])->order('id desc')->limit(30)->select();
|
||||
|
||||
$return_data['search_history'] = $search_log;
|
||||
// 处理搜索历史 end
|
||||
}else{
|
||||
foreach ($banner_list as $key => $value) {
|
||||
$banner_list[$key]['is_me_like_it'] = 'no';
|
||||
unset($banner_list[$key]['ROW_NUMBER']);
|
||||
}
|
||||
}
|
||||
$return_data['banner'] = $banner_list;
|
||||
// return $this->msg($return_data);
|
||||
// 获取首页信息end
|
||||
|
||||
$return_data['banner_data'] = $banner_list;
|
||||
|
||||
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
|
||||
|
||||
public function search_column_action($data){
|
||||
|
||||
// $cookbook = new Cookbook();
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class Usercenter extends Base{
|
|||
}
|
||||
}
|
||||
// 修改用户
|
||||
public function update_user_msg($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','nickname'=>'测试人员001','gender'=>'1','age'=>'18','height'=>'165.34','weight'=>'55.55']){
|
||||
public function update_user_msg(){
|
||||
try {
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
|
|
@ -79,8 +79,8 @@ class Usercenter extends Base{
|
|||
if(!array_key_exists('gender', $data)){
|
||||
return $this->msg(10001,'gender is miss');
|
||||
}
|
||||
if(!array_key_exists('age', $data)){
|
||||
return $this->msg(10001,'age is miss');
|
||||
if(!array_key_exists('birthday', $data)){
|
||||
return $this->msg(10001,'birthday is miss');
|
||||
}
|
||||
if(!array_key_exists('height', $data)){
|
||||
return $this->msg(10001,'height is miss');
|
||||
|
|
@ -97,8 +97,8 @@ class Usercenter extends Base{
|
|||
if(!$this->verify_data_is_ok($data['gender'],'intnum')){
|
||||
return $this->msg(10005,'gender type is error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['age'],'intnum')){
|
||||
return $this->msg(10005,'age type is error');
|
||||
if(!$this->verify_data_is_ok($data['birthday'],'datetime')){
|
||||
return $this->msg(10005,'birthday type is error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['height'],'num')){
|
||||
return $this->msg(10005,'height type is error');
|
||||
|
|
@ -305,7 +305,7 @@ class Usercenter extends Base{
|
|||
$user_msg['nickname'] = $data['nickname'];
|
||||
$user_msg['head_pic'] = $data['gender'] == 1?'https://tc.pcxbc.com/tsf/1.png':'https://tc.pcxbc.com/tsf/2.png';
|
||||
$user_msg['gender'] = $data['gender'];
|
||||
$user_msg['age'] = $data['age'];
|
||||
$user_msg['birthday'] = $data['birthday'];
|
||||
$user_msg['height'] = $data['height'];
|
||||
$user_msg['weight'] = $data['weight'];
|
||||
|
||||
|
|
|
|||
|
|
@ -593,7 +593,9 @@ class Base extends Controller{
|
|||
case 'intnum':
|
||||
// 整数验证 - 必须是整型或纯整数字符串
|
||||
// 使用 filter_var 同时验证整型和整数字符串
|
||||
return filter_var($data, FILTER_VALIDATE_INT) !== false;
|
||||
// 必须是 >0 的整数或字符串整数
|
||||
$filtered = filter_var($data, FILTER_VALIDATE_INT);
|
||||
return $filtered !== false && $filtered > 0;
|
||||
|
||||
case 'datetime':
|
||||
// 日期时间验证 - 保持原有逻辑不变
|
||||
|
|
|
|||
|
|
@ -2,12 +2,9 @@
|
|||
|
||||
namespace app\NewReedaw\controller\app;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Cache;
|
||||
use think\Log;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use app\NewReedaw\controller\app\Cardparts;
|
||||
use app\NewReedaw\controller\app\Calculatebody;
|
||||
|
||||
class Body extends Base{
|
||||
|
||||
|
|
@ -30,6 +27,7 @@ class Body extends Base{
|
|||
'list'=>[]
|
||||
];
|
||||
protected $age_limit = 16;
|
||||
protected $pagesize = 15;
|
||||
protected $unit_name = ['score'=>'身体得分','height'=>'身高','weight'=>'体重','bmi'=>'BMI','fat_r'=>'脂肪率','fat_w'=>'脂肪量','muscle'=>'肌肉率','muscleval'=>'肌肉量','water'=>'水分','bone'=>'骨重','protein'=>'蛋白率','proteinval'=>'蛋白量','kcal'=>'基础代谢','visceral'=>'内脏指数','sfr'=>'皮下脂肪','body_level'=>'肥胖等级','body_type'=>'身体类型'];
|
||||
protected $unit_symbol = ['score'=>'分','height'=>'CM','weight'=>'公斤','bmi'=>'','fat_r'=>'%','fat_w'=>'kg','muscle'=>'%','muscleval'=>'kg','water'=>'kg','bone'=>'kg','protein'=>'%','proteinval'=>'kg','kcal'=>'kcal','visceral'=>'','sfr'=>'%',];
|
||||
protected $standard_color = [
|
||||
|
|
@ -85,7 +83,7 @@ class Body extends Base{
|
|||
public function body_report(){
|
||||
// phpinfo();
|
||||
// die;
|
||||
// try {
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){
|
||||
return $this->msg(10001);
|
||||
|
|
@ -97,20 +95,243 @@ class Body extends Base{
|
|||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
return $this->body_report_action_detailed($data);
|
||||
// } catch (\Exception $e) {
|
||||
// // 捕获异常
|
||||
// $logContent["flie"] = $e->getFile();
|
||||
// $logContent["line"] = $e->getLine();
|
||||
// $logContent['all_content'] = "异常信息:\n";
|
||||
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
// $this->record_api_log($data, $logContent, null);
|
||||
// return $this->msg(99999);
|
||||
// }
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 手动记录
|
||||
public function manual_record(){
|
||||
try {
|
||||
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('time', $data) || !array_key_exists('height', $data) || !array_key_exists('weight', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
unset($data['token']);
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['time'],'datetime')){
|
||||
return $this->msg(10005,'time type error');
|
||||
}
|
||||
$temporary_data = $this->convertHeightAndWeight($data['height'],$data['weight']);
|
||||
if($temporary_data['height_in_cm'] == false){
|
||||
return $this->msg(10005,'身高单位错误');
|
||||
}
|
||||
if($temporary_data['weight_in_kg'] == false){
|
||||
return $this->msg(10005,'体重单位错误');
|
||||
}
|
||||
$data['height'] = $temporary_data['height_in_cm'];
|
||||
$data['weight'] = $temporary_data['weight_in_kg'];
|
||||
if(strlen($data['time']) <= 12){
|
||||
// 时间日期转换,把'Y-m-d'转换成'Y-m-d H:i:s'格式
|
||||
$data['time'] = $this->addCurrentTimeToDateString($data['time']);
|
||||
}
|
||||
// $data['acd_id'] = '2';
|
||||
return $this->set_user_body_data($data,'by_hand_means');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
|
||||
}
|
||||
// 设备记录
|
||||
public function device_record(){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
$data = input('post.');
|
||||
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->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['adc'],'num')){
|
||||
return $this->msg(10005,'adc type error');
|
||||
}
|
||||
$temporary_data = $this->convertHeightAndWeight($data['height'],$data['weight']);
|
||||
if($temporary_data['height_in_cm'] == false){
|
||||
return $this->msg(10005,'身高单位错误');
|
||||
}
|
||||
if($temporary_data['weight_in_kg'] == false){
|
||||
return $this->msg(10005,'体重单位错误');
|
||||
}
|
||||
// 检测设备传过来的info信息
|
||||
if(array_key_exists('info', $data)){
|
||||
if (!is_array($data['info'])) {
|
||||
return $this->msg(10005,'info参数格式错误');
|
||||
}else{
|
||||
$info_data_arr =['bodyage','fat_r','muscle','kcal','visceral','sfr','water','bone','fatlevlval','protein','bmi'];
|
||||
foreach ($data['info'] as $key => $value) {
|
||||
if (!in_array($key, $info_data_arr)) {
|
||||
return $this->msg(10005,'info参数格式错误-2');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$data['height'] = $temporary_data['height_in_cm'];
|
||||
$data['weight'] = $temporary_data['weight_in_kg'];
|
||||
$data['time'] = date('Y-m-d H:i:s');
|
||||
return $this->set_user_body_data($data,'by_device');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
|
||||
}
|
||||
// 获取历史列表(分页)
|
||||
public function record_list_page(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('page', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['page'],'intnum')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
return $this->record_list_page_or_group_action($data,'page');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 获取历史列表(分组)
|
||||
public function record_list_group(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['s_time'],'datetime')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['e_time'],'datetime')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
return $this->record_list_page_or_group_action($data,'group');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 历史记录(详细)
|
||||
public function detailed_record(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('id', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||
return $this->msg(10005,'id type error');
|
||||
}
|
||||
return $this->get_all_detaile_data_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 删除历史数据
|
||||
public function del_record(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('id', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
unset($data['token']);
|
||||
$user_data = Db::table($this->body_db_name['body_data'])->where(['id'=>$data['id']])->update(['is_del'=>1]);
|
||||
if($user_data){
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
################################################################action################################################################
|
||||
################################################################action################################################################
|
||||
|
|
@ -344,7 +565,318 @@ class Body extends Base{
|
|||
// dump($result_end);
|
||||
|
||||
}
|
||||
// 用户身体数据卡片记录
|
||||
public function set_user_body_data($data,$type){
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
|
||||
// 判断头围数据是否存在是否合理
|
||||
if(array_key_exists('head_data', $data)){
|
||||
if(!$this->verify_data_is_ok($data['head_data'],'num')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
$data['head_circumference'] = $data['head_data'];
|
||||
}else{
|
||||
$data['head_circumference'] = 0;
|
||||
}
|
||||
|
||||
// 查询用户信息
|
||||
$user_data = Db::table($this->body_db_name['juese'])->where(['id'=>$data['aud_id']])->field('birthday,gender,target_weight,initial_weight,initial_date')->find();
|
||||
|
||||
if(!$user_data){
|
||||
return $this->msg(10003);
|
||||
}
|
||||
// 如果最初体重设置为null
|
||||
if($user_data['initial_date'] == null){
|
||||
Db::table($this->body_db_name['juese'])->where(['id'=>$data['aud_id']])->update(['initial_weight'=>$data['weight'],'initial_date'=>$data['time']]);
|
||||
$target_current = $this->base_target_initial_cumulative_weight([
|
||||
'weight'=>$data['weight'],
|
||||
'target_weight'=>$user_data['target_weight'],
|
||||
'initial_weight'=>$data['weight'],
|
||||
'initial_date'=>$data['time'],
|
||||
]);
|
||||
}else{
|
||||
$target_current = $this->base_target_initial_cumulative_weight([
|
||||
'weight'=>$data['weight'],
|
||||
'target_weight'=>$user_data['target_weight'],
|
||||
'initial_weight'=>$user_data['initial_weight'],
|
||||
'initial_date'=>$user_data['initial_date'],
|
||||
]);
|
||||
}
|
||||
// 设置身高、体重、年龄、性别、阶段称谓、头围、生日、阻抗
|
||||
$result_data['height'] = $data['height'];
|
||||
$result_data['weight'] = $data['weight'];
|
||||
$result_data['age'] = $this->calculate_age($user_data['birthday']);
|
||||
$result_data['gender'] = $user_data['gender'];
|
||||
$result_data['head_circumference'] = $data['head_circumference'];
|
||||
$result_data['birthday'] = $user_data['birthday'];
|
||||
if(array_key_exists('adc', $data)){
|
||||
if($data['adc'] > 0){
|
||||
$result_data['adc'] = $data['adc'];
|
||||
$type = "by_device_adc";
|
||||
}else{
|
||||
$result_data['adc'] = 550;
|
||||
$type = "by_device";
|
||||
}
|
||||
}
|
||||
$calculate_body_formula = new Calculatebody();
|
||||
|
||||
// 计算身体数据
|
||||
$get_body_value = $calculate_body_formula->calculate_body_data_result($result_data);
|
||||
|
||||
if($get_body_value === false){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
|
||||
// 如果年纪小于三岁,处理头围数据star
|
||||
$standardlist = [];
|
||||
if($result_data['age'] < 3){
|
||||
if(array_key_exists('standardlist',$get_body_value)){
|
||||
$standardlist = $get_body_value['standardlist'];
|
||||
foreach ($standardlist as $key => $value) {
|
||||
if($value['name'] == 'head' && count($value['list'] ) > 0){
|
||||
$standardlist = $value;
|
||||
}
|
||||
}
|
||||
$standardlist['list2'] = [];
|
||||
foreach ($standardlist['list'] as $key => $value) {
|
||||
array_push($standardlist['list2'],[
|
||||
'min_val'=>$value['minvalue'],
|
||||
'max_val'=>$value['maxvalue'],
|
||||
'text'=>$value['text'],
|
||||
'color'=>$value['color']
|
||||
]);
|
||||
}
|
||||
unset($standardlist['list']);
|
||||
unset($get_body_value['standardlist']);
|
||||
}
|
||||
}else{
|
||||
if(array_key_exists('standardlist',$get_body_value)){
|
||||
unset($get_body_value['standardlist']);
|
||||
}
|
||||
}
|
||||
// 如果年纪小于三岁,处理头围数据end
|
||||
$get_body_value['gender'] = $user_data['gender'];
|
||||
$get_body_value['birthday'] = $user_data['birthday'];
|
||||
// 添加身高、体重、bmi、头围(如果有)的标尺标准
|
||||
$get_body_value = $this->hwb_standard($get_body_value);
|
||||
|
||||
|
||||
$enumeration_data = [
|
||||
'fat_r'=>'脂肪率',
|
||||
'muscle'=>'肌肉率',
|
||||
'kcal'=>'基础代谢',
|
||||
'visceral'=>'内脏指数',
|
||||
'sfr'=>'皮下脂肪',
|
||||
'water'=>'水分',
|
||||
'bone'=>'骨重',
|
||||
'protein'=>'蛋白率',
|
||||
'bodyage'=>'身体年龄'
|
||||
];
|
||||
|
||||
// return $this->msg($get_body_value);
|
||||
// 根据秤传过来的数据,去处理要存的结果
|
||||
if(array_key_exists('info', $data)){
|
||||
|
||||
|
||||
foreach ($data['info'] as $key => $value) {
|
||||
if($key == 'bmi'){
|
||||
if($value > 0){
|
||||
$get_body_value['BMI'] = $value;
|
||||
$get_body_value['BMI2'] = explode(',',$get_body_value['BMI2']);
|
||||
$get_body_value['BMI2'][0] = $value;
|
||||
$get_body_value['BMI2'] = implode(',',$get_body_value['BMI2']);
|
||||
}
|
||||
}else if($key == 'bodyage'){
|
||||
$get_body_value[$enumeration_data[$key]] = $value;
|
||||
}else if($key == 'fatlevlval'){
|
||||
continue;
|
||||
}else{
|
||||
if($value > 0){
|
||||
$get_body_value[$enumeration_data[$key]][0] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$set_data = [
|
||||
'acd_id'=>2,
|
||||
'aud_id'=>$data['aud_id'],
|
||||
'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'),
|
||||
'last_update_time'=>date('Y-m-d H:i:s'),
|
||||
'age'=>$get_body_value['age'],
|
||||
'height'=>$get_body_value['身高2'],
|
||||
'height_val'=>$get_body_value['身高'],
|
||||
'weight'=>$get_body_value['体重2'],
|
||||
'weight_val'=>$get_body_value['体重'],
|
||||
'bmi'=>$get_body_value['BMI2'],
|
||||
'bmi_val'=>$get_body_value['BMI'],
|
||||
'score'=>$get_body_value['身体得分'],
|
||||
'fat_r'=> implode(',',$get_body_value['脂肪率']),
|
||||
'fat_w'=>implode(',',$get_body_value['脂肪量']),
|
||||
'muscle'=>implode(',',$get_body_value['肌肉率']),
|
||||
'muscleval'=>implode(',',$get_body_value['肌肉量']),
|
||||
'water'=>implode(',',$get_body_value['水分']),
|
||||
'proteinval'=>implode(',',$get_body_value['蛋白量']),
|
||||
'bone'=>implode(',',$get_body_value['骨重']),
|
||||
'protein'=>implode(',',$get_body_value['蛋白率']),
|
||||
'kcal'=>implode(',',$get_body_value['基础代谢']),
|
||||
'visceral'=>implode(',',$get_body_value['内脏指数']),
|
||||
'sfr'=>implode(',',$get_body_value['皮下脂肪']),
|
||||
'body_level'=>$get_body_value['肥胖等级'],
|
||||
'body_type'=>$get_body_value['身体类型'],
|
||||
'body_age'=>$get_body_value['身体年龄'],
|
||||
'record_type' => $type,
|
||||
'head_circumference' => $result_data['age'] < 3?json_encode($standardlist):"",
|
||||
];
|
||||
if(strlen($set_data['record_time']) <= 12){
|
||||
// 时间日期转换,把'Y-m-d'转换成'Y-m-d H:i:s'格式
|
||||
$set_data['record_time'] = $this->addCurrentTimeToDateString($set_data['record_time']);
|
||||
}
|
||||
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try{
|
||||
$set_user_data = Db::table($this->body_db_name['body_data'])->insert($set_data);
|
||||
$update_arr = [
|
||||
'height'=>$get_body_value['身高'],
|
||||
'weight'=>$get_body_value['体重']
|
||||
];
|
||||
if($data['head_circumference']>0){
|
||||
$update_arr['head_data'] = $data['head_circumference'];
|
||||
}
|
||||
$update_user_data = Db::table($this->body_db_name['juese'])->where(['id'=>$data['aud_id']])->update($update_arr);
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return $this->msg([
|
||||
'acd_id'=>2,
|
||||
'height'=>$get_body_value['身高'].',CM',
|
||||
'weight'=>$get_body_value['体重'].',公斤',
|
||||
'bmi'=>$get_body_value['BMI'],
|
||||
'target_current'=>$target_current,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return $this->msg(10002);
|
||||
}
|
||||
}
|
||||
public function record_list_page_or_group_action($data,$type){
|
||||
$return_result = [];
|
||||
|
||||
if($type == 'group'){
|
||||
$data['s_time'] = $data['s_time'].' 00:00:00';
|
||||
$data['e_time'] = $data['e_time'].' 23:59:59';
|
||||
$result = Db::query("
|
||||
select
|
||||
id,
|
||||
CONVERT(varchar(10), record_time, 120) AS r_t,
|
||||
CONVERT(varchar(19), record_time, 120) AS record_time,
|
||||
height_val as v1,
|
||||
weight_val as v2,
|
||||
bmi_val as v3
|
||||
from ".$this->body_db_name['body_data']."
|
||||
where aud_id='".$data['aud_id']."'
|
||||
and record_time between '".$data['s_time']."' and '".$data['e_time']."'
|
||||
and is_del = 0
|
||||
order by record_time desc");
|
||||
foreach ($result as $key => $value) {
|
||||
array_push($return_result, [
|
||||
'id'=>$value['id'],
|
||||
'v1'=>floatval(sprintf("%.2f", $value['v1'])),
|
||||
'v2'=>floatval(sprintf("%.2f", $value['v2'])),
|
||||
'v3'=>floatval(sprintf("%.2f", $value['v3'])),
|
||||
'v1_name'=>'身高',
|
||||
'v2_name'=>'体重',
|
||||
'v3_name'=>'BMI',
|
||||
// 'r_t'=>str_replace('-', '/', $value['r_t'])
|
||||
'r_t'=>$value['r_t']
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
$result = Db::table($this->body_db_name['body_data'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->field("id,record_time,REPLACE(record_time, '-', '-') AS b_time,height_val,weight_val,bmi_val")->order('record_time desc')->page($data['page'],$this->pagesize)->select();
|
||||
$return_result['totalrows'] = Db::table($this->body_db_name['body_data'])->where(['aud_id'=>$data['aud_id']])->count();
|
||||
$return_result['rows'] = [];
|
||||
$return_result['pageno'] = $data['page'];
|
||||
$return_result['pagesize'] = $this->pagesize;
|
||||
$return_result['totalpage'] = ceil($return_result['totalrows']/$this->pagesize);
|
||||
foreach ($result as $key => $value) {
|
||||
array_push($return_result['rows'],[
|
||||
'id'=>$value['id'],
|
||||
'v1'=>floatval(sprintf("%.2f", $value['height_val'])),
|
||||
'v2'=>floatval(sprintf("%.2f", $value['weight_val'])),
|
||||
'v3'=>floatval(sprintf("%.2f", $value['bmi_val'])),
|
||||
'v1_name'=>'身高',
|
||||
'v2_name'=>'体重',
|
||||
'v3_name'=>'BMI',
|
||||
'record_time'=>$value['b_time'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
return $this->msg($return_result);
|
||||
}
|
||||
// 获取详细历史数据信息
|
||||
public function get_all_detaile_data_action($data){
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
// 设置排除在外的数据类型start
|
||||
$exclude_data_arr = ['height','weight','age','bmi'];
|
||||
// 设置排除在外的数据类型end
|
||||
$result = Db::table($this->body_db_name['body_data'])->where(['id'=>$data['id']])->find();
|
||||
$for_data_arr = ['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI',''],'head'=>['头围',''],'fat_w'=>['脂肪量','kg'],'fat_r'=>['脂肪率','%'],'muscleval'=>['肌肉量','kg'],'muscle'=>['肌肉率','%'],'proteinval'=>['蛋白量','kg'],'protein'=>['蛋白率','%'],'water'=>['水分',''],'bone'=>['骨重','kg'],'visceral'=>['内脏指数',''],'sfr'=>['皮下脂肪','%'],'kcal'=>['基础代谢','kcal'],'un_fat_w_weight'=>['去脂体重','kg'],'body_age'=>['体龄',''],'body_level'=>['肥胖等级',''],'body_type'=>['体型','']];
|
||||
if($result){
|
||||
$result_data = [];
|
||||
foreach ($for_data_arr as $key => $value) {
|
||||
$temporary_arr['key_name'] = $key;
|
||||
$temporary_arr['name'] = $value[0];
|
||||
// 身体数据处理,如果没有阻抗,则只显示四项$exclude_data_arr
|
||||
if($result['record_type'] != 'by_device_adc'){
|
||||
if(!in_array($key, $exclude_data_arr)){
|
||||
continue;
|
||||
}else{
|
||||
$temporary_arr['value'] = explode(',',$result[$key])[0];
|
||||
}
|
||||
}else{
|
||||
|
||||
if($key == 'un_fat_w_weight'){
|
||||
$temporary_arr['value'] = bcsub(explode(',',$result['weight'])[0],explode(',',$result['fat_w'])[0],2);
|
||||
}else{
|
||||
if(array_key_exists($key,$result)){
|
||||
$temporary_arr['value'] = explode(',',$result[$key])[0];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$temporary_arr['unit'] = $value[1];
|
||||
array_push($result_data,$temporary_arr);
|
||||
}
|
||||
//
|
||||
// 添加头围详细start
|
||||
if($result['head_circumference'] != null){
|
||||
array_unshift($result_data,[
|
||||
'key_name'=>'head_circumference',
|
||||
'name'=>'头围',
|
||||
'value'=>json_decode($result['head_circumference'],true)['value'] == 0?"0":json_decode($result['head_circumference'],true)['value'],
|
||||
'unit'=>'cm',
|
||||
]);
|
||||
}
|
||||
// 添加头围详细end
|
||||
return $this->msg($result_data);
|
||||
}else{
|
||||
return $this->msg(10004);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
################################################################内部调用################################################################
|
||||
################################################################内部调用################################################################
|
||||
public function processing_return_data_new($data){
|
||||
$result_end_data = [];
|
||||
$month_num = $this->calculateAgeInMonthsWithPrecision($data['birthday']);
|
||||
|
|
@ -655,9 +1187,86 @@ class Body extends Base{
|
|||
}
|
||||
return $return_data;
|
||||
}
|
||||
// public function body_report_action_detailed($data){
|
||||
|
||||
// }
|
||||
// 添加身高体重bmi的标准
|
||||
public function hwb_standard($data){
|
||||
$linshi_data = [];
|
||||
$month_num = $this->calculateAgeInMonthsWithPrecision($data['birthday']);
|
||||
$gender_val = $data['gender'];
|
||||
if($data['age'] < $this->age_limit){
|
||||
foreach ($data as $key => $value) {
|
||||
if($key =='身高'){
|
||||
$linshi_data['身高'] = $this->bhw_list['height'];
|
||||
$bhw_date = Db::table($this->body_db_name['heigh'])->where("Month <= $month_num and Sex = '$gender_val'")->order('Month desc')->limit(1)->select();
|
||||
|
||||
if($bhw_date){
|
||||
$linshi_data['身高'][0]['max_val'] = $bhw_date[0]['f2sd'];
|
||||
$linshi_data['身高'][1]['min_val'] = $bhw_date[0]['f2sd'];
|
||||
$linshi_data['身高'][1]['max_val'] = $bhw_date[0]['f1sd'];
|
||||
$linshi_data['身高'][2]['min_val'] = $bhw_date[0]['f1sd'];
|
||||
$linshi_data['身高'][2]['max_val'] = $bhw_date[0]['z1sd'];
|
||||
$linshi_data['身高'][3]['min_val'] = $bhw_date[0]['z1sd'];
|
||||
$linshi_data['身高'][3]['max_val'] = $bhw_date[0]['z2sd'];
|
||||
$linshi_data['身高'][4]['min_val'] = $bhw_date[0]['z2sd'];
|
||||
$linshi_data['身高'][4]['max_val'] = $bhw_date[0]['z3sd'];
|
||||
}
|
||||
|
||||
}else if($key =='体重'){
|
||||
$linshi_data['体重'] = $this->bhw_list['weight'];
|
||||
$bhw_date = Db::table($this->body_db_name['weigh'])->where("Month <= $month_num and Sex = '$gender_val'")->order('Month desc')->limit(1)->select();
|
||||
if($bhw_date){
|
||||
$linshi_data['体重'][0]['max_val'] = $bhw_date[0]['f2sd'];
|
||||
$linshi_data['体重'][1]['min_val'] = $bhw_date[0]['f2sd'];
|
||||
$linshi_data['体重'][1]['max_val'] = $bhw_date[0]['f1sd'];
|
||||
$linshi_data['体重'][2]['min_val'] = $bhw_date[0]['f1sd'];
|
||||
$linshi_data['体重'][2]['max_val'] = $bhw_date[0]['z1sd'];
|
||||
$linshi_data['体重'][3]['min_val'] = $bhw_date[0]['z1sd'];
|
||||
$linshi_data['体重'][3]['max_val'] = $bhw_date[0]['z2sd'];
|
||||
$linshi_data['体重'][4]['min_val'] = $bhw_date[0]['z2sd'];
|
||||
$linshi_data['体重'][4]['max_val'] = $bhw_date[0]['z3sd'];
|
||||
}
|
||||
}else if($key =='BMI'){
|
||||
$linshi_data['BMI'] = $this->bhw_list['bmi'];
|
||||
$bhw_date = Db::table($this->body_db_name['bmi'])->where("Month <= $month_num and Sex = '$gender_val'")->order('Month desc')->limit(1)->select();
|
||||
if($bhw_date){
|
||||
$linshi_data['BMI'][0]['max_val'] = $bhw_date[0]['f1sd'];
|
||||
$linshi_data['BMI'][1]['min_val'] = $bhw_date[0]['f1sd'];
|
||||
$linshi_data['BMI'][1]['max_val'] = $bhw_date[0]['z1sd'];
|
||||
$linshi_data['BMI'][2]['min_val'] = $bhw_date[0]['z1sd'];
|
||||
$linshi_data['BMI'][2]['max_val'] = $bhw_date[0]['z2sd'];
|
||||
$linshi_data['BMI'][3]['min_val'] = $bhw_date[0]['z2sd'];
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($linshi_data as $key => $value) {
|
||||
foreach ($value as $k => $v) {
|
||||
if($data[$key] >= $v['min_val'] && $data[$key] < $v['max_val']){
|
||||
// 如果落在区间内
|
||||
$data[$key.'2'] = $data[$key].','.$v['text'].','.$v['color'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 如果$key.'2'没有被设置
|
||||
if(!array_key_exists($key.'2', $data)){
|
||||
if($data[$key] < $value[0]['min_val']){
|
||||
// 如果小于最小值
|
||||
$data[$key.'2'] = $data[$key].','.$value[0]['text'].','.$value[0]['color'];
|
||||
}else if($data[$key] >= $value[count($value)-1]['max_val']){
|
||||
// 如果大于最大值
|
||||
$data[$key.'2'] = $data[$key].','.$value[count($value)-1]['text'].','.$value[count($value)-1]['color'];
|
||||
}
|
||||
}
|
||||
}
|
||||
// die;
|
||||
}else{
|
||||
$data['身高2'] = $data['身高'].',无,无';
|
||||
$data['体重2'] = $data['体重'].',无,无';
|
||||
$data['BMI2'] = $data['BMI'].',无,无';
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,641 @@
|
|||
<?php
|
||||
|
||||
namespace app\NewReedaw\controller\app;
|
||||
|
||||
|
||||
|
||||
class Calculatebody extends Base{
|
||||
|
||||
// 默认阻抗值
|
||||
protected $default_adc = 550;
|
||||
// 体重 = weight weight
|
||||
// 身高 = height height
|
||||
// BMI = bmi bmi
|
||||
// age = age age
|
||||
// 身体得分 = cmi cmi
|
||||
// 脂肪量 = fat_w bfrval
|
||||
// 脂肪率 = fat_r bfr
|
||||
// 肌肉量 = muscleval romval
|
||||
// 肌肉率 = muscle rom
|
||||
// 水分 = water vwc
|
||||
// 蛋白量 = proteinval ppval
|
||||
// 蛋白率 = protein pp
|
||||
// 骨重 = bone bm
|
||||
// 基础代谢 = kcal bmr
|
||||
// 内脏指数 = visceral uvi
|
||||
// 皮下脂肪 = sfr sfr
|
||||
// 肥胖等级 = standard_level fatlevel (fatlevelName)
|
||||
// 身体年龄 = bodyage bodyage
|
||||
// 去脂体重 = lbm lbm
|
||||
// 身体类型 = body body
|
||||
|
||||
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['adc'] = array_key_exists('adc', $data)?$data['adc']:$this->default_adc;
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
|
||||
// 青测自己写的计算start
|
||||
// $result = $this->calculate_body_data($data['height'],$data['weight'],$data['age'],$data['gender'],$data['adc']);
|
||||
// // $result['fat_w'] = $result['fat_r'] / 100 * $data['weight'];
|
||||
// $result['fat_w'] = bcmul(bcdiv($result['fat_r'],'100',20),$data['weight'],2);
|
||||
// // $result['proteinval'] = $result['protein'] / 100 * $data['weight'];
|
||||
// $result['proteinval'] = bcmul(bcdiv($result['protein'],'100',20),$data['weight'],2);
|
||||
// //肌肉量=体重-脂肪量-骨量
|
||||
// // $result['muscleval'] = $result['weight'] - $result['fat_w'] - $result['bone'];
|
||||
// $result['muscleval'] = bcsub(bcsub($result['weight'],$result['fat_w'],20),$result['bone'],2);
|
||||
// // $result['muscle'] = $result['muscleval'] / $data['weight'] * 100.0;
|
||||
// $result['muscle'] = bcmul(bcdiv($result['muscleval'],$data['weight'],20),'100.0',2);
|
||||
// // 水份=肌肉量-蛋白量
|
||||
// // $result['water'] = $result['muscleval'] - $result['proteinval'];
|
||||
// $result['water'] = bcsub($result['muscleval'],$result['proteinval'],2);
|
||||
// // $result['lbm'] = (1 - $result['fat_r'] / 100) * $data['weight'];
|
||||
// $result['lbm'] = bcmul(bcsub('1',bcdiv($result['fat_r'],'100',20),20),$data['weight'],2);
|
||||
// 青测自己写的计算end
|
||||
|
||||
// 使用接口调用之前的进行计算start
|
||||
$url = 'https://klcz.pcxbc.com/open-api/calc/healthcalc/bodyfat3';
|
||||
if($data['age'] < '3'){
|
||||
$temporary_parameter = [
|
||||
'weight'=>$data['weight'],
|
||||
'height'=>$data['height'],
|
||||
'age'=>round($data['age']),//四舍五入取整
|
||||
'adc'=>round($data['adc']),//四舍五入取整
|
||||
'gender'=>$data['gender'],
|
||||
'head'=>$data['head_circumference'],
|
||||
'hasStandardList'=>true,
|
||||
'birthDay'=>$data['birthday'],
|
||||
];
|
||||
}else{
|
||||
$temporary_parameter = [
|
||||
'weight'=>$data['weight'],
|
||||
'height'=>$data['height'],
|
||||
'age'=>round($data['age']),//四舍五入取整
|
||||
'adc'=>round($data['adc']),//四舍五入取整
|
||||
'gender'=>$data['gender'],
|
||||
];
|
||||
}
|
||||
$request_result = $this->postRequest($url,$temporary_parameter);
|
||||
if($request_result['code'] != 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
$result['weight'] = $request_result['data']['weight'];
|
||||
$result['height'] = $request_result['data']['height'];
|
||||
$result['bmi'] = $request_result['data']['bmi'];
|
||||
$result['age'] = $request_result['data']['age'];
|
||||
$result['cmi'] = $request_result['data']['cmi'];
|
||||
$result['fat_w'] = $request_result['data']['bfrval'];
|
||||
$result['fat_r'] = $request_result['data']['bfr'];
|
||||
$result['muscleval'] = $request_result['data']['romval'];
|
||||
$result['muscle'] = $request_result['data']['rom'];
|
||||
$result['water'] = $request_result['data']['vwc'];
|
||||
$result['proteinval'] = $request_result['data']['ppval'];
|
||||
$result['protein'] = $request_result['data']['pp'];
|
||||
$result['bone'] = $request_result['data']['bm'];
|
||||
$result['kcal'] = $request_result['data']['bmr'];
|
||||
$result['visceral'] = $request_result['data']['uvi'];
|
||||
$result['sfr'] = $request_result['data']['sfr'];
|
||||
$result['standard_level'] = $request_result['data']['fatlevelname'];
|
||||
$result['bodyage'] = $request_result['data']['bodyage'];
|
||||
$result['lbm'] = $request_result['data']['lbm'];
|
||||
$result['body'] = $request_result['data']['body'];
|
||||
// 使用接口调用之前的进行计算end
|
||||
|
||||
$return_data['standardlist'] = $request_result['data']['standardlist'];
|
||||
$return_data['体重'] = $data['weight'];
|
||||
$return_data['身高'] = $data['height'];
|
||||
$return_data['BMI'] = $result['bmi'];
|
||||
$return_data['age'] = $result['age'];
|
||||
|
||||
// 身体得分修改start
|
||||
// if($result['bmi']<21.6){
|
||||
// $return_data['身体得分'] = bcmul(bcdiv($result['bmi'],'21.6',20),'100',0);
|
||||
// }else{
|
||||
// $return_data['身体得分'] = bcmul(bcdiv('21.6',$result['bmi'],20),'100',0);
|
||||
// }
|
||||
$return_data['身体得分'] = $result['cmi'];
|
||||
// 身体得分修改end
|
||||
|
||||
$return_data['脂肪量'][0] = $result['fat_w'];
|
||||
$return_data['脂肪率'][0] = $result['fat_r'];
|
||||
if(
|
||||
($data['gender']==1 && $data['age']<30 && $result['fat_r']<10) ||
|
||||
($data['gender']==1 && $data['age']>=30 && $result['fat_r']<11) ||
|
||||
($data['gender']==2 && $data['age']<30 && $result['fat_r']<20) ||
|
||||
($data['gender']==2 && $data['age']>=30 && $result['fat_r']<21)){
|
||||
$return_data['脂肪率'][1] = '偏低';
|
||||
$return_data['脂肪量'][1] = '偏低';
|
||||
}else if(
|
||||
($data['gender']==1 && $data['age']<30 && $result['fat_r']>=10 && $result['fat_r']<21) ||
|
||||
($data['gender']==1 && $data['age']>=30 && $result['fat_r']>=11 && $result['fat_r']<22) ||
|
||||
($data['gender']==2 && $data['age']<30 && $result['fat_r']>=20 && $result['fat_r']<31) ||
|
||||
($data['gender']==2 && $data['age']>=30 && $result['fat_r']>=21 && $result['fat_r']<32)){
|
||||
$return_data['脂肪率'][1] = '标准';
|
||||
$return_data['脂肪量'][1] = '标准';
|
||||
}else if(
|
||||
($data['gender']==1 && $data['age']<30 && $result['fat_r']>=21 && $result['fat_r']<26) ||
|
||||
($data['gender']==1 && $data['age']>=30 && $result['fat_r']>=22 && $result['fat_r']<27) ||
|
||||
($data['gender']==2 && $data['age']<30 && $result['fat_r']>=31 && $result['fat_r']<38) ||
|
||||
($data['gender']==2 && $data['age']>=30 && $result['fat_r']>=32 && $result['fat_r']<39)){
|
||||
$return_data['脂肪率'][1] = '偏高';
|
||||
$return_data['脂肪量'][1] = '偏高';
|
||||
}else if(
|
||||
($data['gender']==1 && $data['age']<30 && $result['fat_r']>=26) ||
|
||||
($data['gender']==1 && $data['age']>=30 && $result['fat_r']>=27) ||
|
||||
($data['gender']==2 && $data['age']<30 && $result['fat_r']<38) ||
|
||||
($data['gender']==2 && $data['age']>=30 && $result['fat_r']<39)){
|
||||
$return_data['脂肪率'][1] = '高';
|
||||
$return_data['脂肪量'][1] = '高';
|
||||
}else{
|
||||
$return_data['脂肪率'][1] = '异常';
|
||||
$return_data['脂肪量'][1] = '异常';
|
||||
}
|
||||
|
||||
$return_data['肌肉量'][0] = $result['muscleval'];
|
||||
$return_data['肌肉率'][0] = $result['muscle'];
|
||||
if(
|
||||
($data['gender']==1 && $result['muscle']<40) ||
|
||||
($data['gender']==2 && $result['muscle']<30)){
|
||||
$return_data['肌肉量'][1] = '不足';
|
||||
$return_data['肌肉率'][1] = '不足';
|
||||
}else if(
|
||||
($data['gender']==1 && $result['muscle']>=40 && $result['muscle']<60) ||
|
||||
($data['gender']==2 && $result['muscle']>=30 && $result['muscle']<50)){
|
||||
$return_data['肌肉量'][1] = '标准';
|
||||
$return_data['肌肉率'][1] = '标准';
|
||||
}else if(
|
||||
($data['gender']==1 && $result['muscle']>=60) ||
|
||||
($data['gender']==2 && $result['muscle']>=50)){
|
||||
$return_data['肌肉量'][1] = '优';
|
||||
$return_data['肌肉率'][1] = '优';
|
||||
}else{
|
||||
$return_data['肌肉量'][1] = '异常';
|
||||
$return_data['肌肉率'][1] = '异常';
|
||||
}
|
||||
|
||||
$return_data['水分'][0] = $result['water'];
|
||||
if(
|
||||
($data['gender']==1 && $result['water']<55) ||
|
||||
($data['gender']==2 && $result['water']<45)){
|
||||
$return_data['水分'][1] = '不足';
|
||||
}else if(
|
||||
($data['gender']==1 && $result['water']>=55 && $result['water']<65) ||
|
||||
($data['gender']==2 && $result['water']>=45 && $result['water']<60)){
|
||||
$return_data['水分'][1] = '标准';
|
||||
}else if(
|
||||
($data['gender']==1 && $result['water']>65) ||
|
||||
($data['gender']==2 && $result['water']>60)){
|
||||
$return_data['水分'][1] = '优';
|
||||
}else{
|
||||
$return_data['水分'][1] = '异常';
|
||||
}
|
||||
|
||||
$return_data['蛋白量'][0] = $result['proteinval'];
|
||||
$return_data['蛋白率'][0] = $result['protein'];
|
||||
if(
|
||||
($data['gender']==1 && $result['protein']<16) ||
|
||||
($data['gender']==2 && $result['protein']<14)){
|
||||
$return_data['蛋白量'][1] = '不足';
|
||||
$return_data['蛋白率'][1] = '不足';
|
||||
}else if(
|
||||
($data['gender']==1 && $result['protein']>=16 && $result['protein']<18) ||
|
||||
($data['gender']==2 && $result['protein']>=14 && $result['protein']<16)){
|
||||
$return_data['蛋白量'][1] = '标准';
|
||||
$return_data['蛋白率'][1] = '标准';
|
||||
}else if(
|
||||
($data['gender']==1 && $result['protein']>18) ||
|
||||
($data['gender']==2 && $result['protein']>16)){
|
||||
$return_data['蛋白量'][1] = '优';
|
||||
$return_data['蛋白率'][1] = '优';
|
||||
}else{
|
||||
$return_data['蛋白量'][1] = '异常';
|
||||
$return_data['蛋白率'][1] = '异常';
|
||||
}
|
||||
|
||||
$return_data['骨重'][0] = $result['bone'];
|
||||
if(
|
||||
($data['gender']==1 && $data['weight']<60 && $result['bone']<2.4) ||
|
||||
($data['gender']==1 && $data['weight']>=60 && $data['weight']<75 && $result['bone']<2.8) ||
|
||||
($data['gender']==1 && $data['weight']>=75 && $result['bone']<3.1) ||
|
||||
($data['gender']==2 && $data['weight']<45 && $result['bone']<1.7) ||
|
||||
($data['gender']==2 && $data['weight']>=45 && $data['weight']<60 && $result['bone']<2.1) ||
|
||||
($data['gender']==2 && $data['weight']>=60 && $result['bone']<2.4)){
|
||||
$return_data['骨重'][1] = '不足';
|
||||
}else if(
|
||||
($data['gender']==1 && $data['weight']<60 && $result['bone']>=2.4 && $result['bone']<=2.6) ||
|
||||
($data['gender']==1 && $data['weight']>=60 && $data['weight']<75 && $result['bone']>=2.8 && $result['bone']<=3) ||
|
||||
($data['gender']==1 && $data['weight']>=75 && $result['bone']>=3.1 && $result['bone']<=3.3) ||
|
||||
($data['gender']==2 && $data['weight']<45 && $result['bone']>=1.7 && $result['bone']<=1.9) ||
|
||||
($data['gender']==2 && $data['weight']>=45 && $data['weight']<60 && $result['bone']>=2.1 && $result['bone']<=2.3) ||
|
||||
($data['gender']==2 && $data['weight']>=60 && $result['bone']>=2.4 && $result['bone']<=2.6)){
|
||||
$return_data['骨重'][1] = '标准';
|
||||
}else if(
|
||||
($data['gender']==1 && $data['weight']<60 && $result['bone']>2.6) ||
|
||||
($data['gender']==1 && $data['weight']>=60 && $data['weight']<75 && $result['bone']>3) ||
|
||||
($data['gender']==1 && $data['weight']>=75 && $result['bone']<3.3) ||
|
||||
($data['gender']==2 && $data['weight']<45 && $result['bone']>1.9) ||
|
||||
($data['gender']==2 && $data['weight']>=45 && $data['weight']<60 && $result['bone']>2.3) ||
|
||||
($data['gender']==2 && $data['weight']>=60 && $result['bone']>2.6)){
|
||||
$return_data['骨重'][1] = '优';
|
||||
}else{
|
||||
$return_data['骨重'][1] = '异常';
|
||||
}
|
||||
|
||||
$return_data['基础代谢'][0] = $result['kcal'];
|
||||
if(
|
||||
($data['gender']==1 && $data['age']>0 && $data['age']<3 && (60.9*$data['weight']-54)>$result['kcal']) ||
|
||||
($data['gender']==1 && $data['age']>=3 && $data['age']<10 && (22.7*$data['weight']+495)>$result['kcal']) ||
|
||||
($data['gender']==1 && $data['age']>=10 && $data['age']<18 && (17.5*$data['weight']+651)>$result['kcal']) ||
|
||||
($data['gender']==1 && $data['age']>=18 && $data['age']<30 && (15.3*$data['weight']+679)>$result['kcal']) ||
|
||||
($data['gender']==1 && $data['age']>=30 && (11.6*$data['weight']+879)>$result['kcal']) ||
|
||||
($data['gender']==2 && $data['age']>0 && $data['age']<3 && (61*$data['weight']-51)>$result['kcal']) ||
|
||||
($data['gender']==2 && $data['age']>=3 && $data['age']<10 && (22.5*$data['weight']+499)>$result['kcal']) ||
|
||||
($data['gender']==2 && $data['age']>=10 && $data['age']<18 && (12.2*$data['weight']+746)>$result['kcal']) ||
|
||||
($data['gender']==2 && $data['age']>=18 && $data['age']<30 && (14.7*$data['weight']+496)>$result['kcal']) ||
|
||||
($data['gender']==2 && $data['age']>=30 && (8.7*$data['weight']+820)>$result['kcal'])){
|
||||
$return_data['基础代谢'][1] = '偏低';
|
||||
}else if(
|
||||
($data['gender']==1 && $data['age']>0 && $data['age']<3 && (60.9*$data['weight']-54)<=$result['kcal']) ||
|
||||
($data['gender']==1 && $data['age']>=3 && $data['age']<10 && (22.7*$data['weight']+495)<=$result['kcal']) ||
|
||||
($data['gender']==1 && $data['age']>=10 && $data['age']<18 && (17.5*$data['weight']+651)<=$result['kcal']) ||
|
||||
($data['gender']==1 && $data['age']>=18 && $data['age']<30 && (15.3*$data['weight']+679)<=$result['kcal']) ||
|
||||
($data['gender']==1 && $data['age']>=30 && (11.6*$data['weight']+879)<=$result['kcal']) ||
|
||||
($data['gender']==2 && $data['age']>0 && $data['age']<3 && (61*$data['weight']-51)<=$result['kcal']) ||
|
||||
($data['gender']==2 && $data['age']>=3 && $data['age']<10 && (22.5*$data['weight']+499)<=$result['kcal']) ||
|
||||
($data['gender']==2 && $data['age']>=10 && $data['age']<18 && (12.2*$data['weight']+746)<=$result['kcal']) ||
|
||||
($data['gender']==2 && $data['age']>=18 && $data['age']<30 && (14.7*$data['weight']+496)<=$result['kcal']) ||
|
||||
($data['gender']==2 && $data['age']>=30 && (8.7*$data['weight']+820)<=$result['kcal'])){
|
||||
$return_data['基础代谢'][1] = '优';
|
||||
}else{
|
||||
$return_data['基础代谢'][1] = '异常';
|
||||
}
|
||||
|
||||
$return_data['内脏指数'][0] = $result['visceral'];
|
||||
if($result['visceral']<9){
|
||||
$return_data['内脏指数'][1] = '标准';
|
||||
}else if($result['visceral']>=9 && $result['visceral']<14){
|
||||
$return_data['内脏指数'][1] = '警惕';
|
||||
}else if($result['visceral']>=14){
|
||||
$return_data['内脏指数'][1] = '危险';
|
||||
}else{
|
||||
$return_data['内脏指数'][1] = '异常';
|
||||
}
|
||||
|
||||
$return_data['皮下脂肪'][0] = $result['sfr'];
|
||||
if(
|
||||
($data['gender']==1 && $result['sfr']<7) ||
|
||||
($data['gender']==2 && $result['sfr']<11)){
|
||||
$return_data['皮下脂肪'][1] = '不足';
|
||||
}else if(
|
||||
($data['gender']==1 && $result['sfr']>=7 && $result['sfr']<15) ||
|
||||
($data['gender']==2 && $result['sfr']>=11 && $result['sfr']<17)){
|
||||
$return_data['皮下脂肪'][1] = '标准';
|
||||
}else if(
|
||||
($data['gender']==1 && $result['sfr']>=15) ||
|
||||
($data['gender']==2 && $result['sfr']>=17)){
|
||||
$return_data['皮下脂肪'][1] = '偏高';
|
||||
}else{
|
||||
$return_data['皮下脂肪'][1] = '异常';
|
||||
}
|
||||
// 脂肪率:偏低 标准 偏高 高
|
||||
// 肌肉率:不足 标准 优
|
||||
|
||||
// 肥胖等级修改start
|
||||
// // if($data['age']>=16){
|
||||
// if($result['standard_level']<-0.2){
|
||||
// $return_data['肥胖等级'] = '体重不足';
|
||||
// }else if($result['standard_level']>=-0.2 && $result['standard_level']<-0.1){
|
||||
// $return_data['肥胖等级'] = '偏瘦';
|
||||
// }else if($result['standard_level']>=-0.1 && $result['standard_level']<=0.1){
|
||||
// $return_data['肥胖等级'] = '标准';
|
||||
// }else if($result['standard_level']>0.1 && $result['standard_level']<=0.2){
|
||||
// $return_data['肥胖等级'] = '偏重';
|
||||
// }else if($result['standard_level']>0.2){
|
||||
// $return_data['肥胖等级'] = '超重';
|
||||
// }else{
|
||||
// $return_data['肥胖等级'] = '暂无数据';
|
||||
// }
|
||||
// // }else{
|
||||
// // $return_data['肥胖等级'] = '儿童';
|
||||
// // }
|
||||
$return_data['肥胖等级'] = $result['standard_level'];
|
||||
// 肥胖等级修改end
|
||||
|
||||
|
||||
// 身体类型修改start
|
||||
// // if($data['age']>=16){
|
||||
// if(($return_data['脂肪率'][1] == '高' || $return_data['脂肪率'][1] == '偏高') && $return_data['肌肉率'][1] == '不足'){
|
||||
// $return_data['身体类型'] = '隐形肥胖';
|
||||
// }else if(($return_data['脂肪率'][1] == '高' || $return_data['脂肪率'][1] == '偏高') && $return_data['肌肉率'][1] == '标准'){
|
||||
// $return_data['身体类型'] = '偏胖';
|
||||
// }else if(($return_data['脂肪率'][1] == '高' || $return_data['脂肪率'][1] == '偏高') && $return_data['肌肉率'][1] == '优'){
|
||||
// $return_data['身体类型'] = '结实型偏胖';
|
||||
// }else if($return_data['脂肪率'][1] == '标准' && $return_data['肌肉率'][1] == '不足'){
|
||||
// $return_data['身体类型'] = '缺乏肌肉型';
|
||||
// }else if($return_data['脂肪率'][1] == '标准' && $return_data['肌肉率'][1] == '标准'){
|
||||
// $return_data['身体类型'] = '标准型';
|
||||
// }else if($return_data['脂肪率'][1] == '标准' && $return_data['肌肉率'][1] == '优'){
|
||||
// $return_data['身体类型'] = '标准肌肉型';
|
||||
// }else if($return_data['脂肪率'][1] == '偏低' && $return_data['肌肉率'][1] == '不足'){
|
||||
// $return_data['身体类型'] = '偏瘦';
|
||||
// }else if($return_data['脂肪率'][1] == '偏低' && $return_data['肌肉率'][1] == '标准'){
|
||||
// $return_data['身体类型'] = '偏瘦肌肉型';
|
||||
// }else if($return_data['脂肪率'][1] == '偏低' && $return_data['肌肉率'][1] == '优'){
|
||||
// $return_data['身体类型'] = '健美肌肉型';
|
||||
// }else{
|
||||
// $return_data['身体类型'] = '暂无数据';
|
||||
// }
|
||||
// // }else{
|
||||
// // $return_data['身体类型'] = '儿童';
|
||||
// // }
|
||||
$return_data['身体类型'] = $result['body'];
|
||||
// 身体类型修改end
|
||||
|
||||
$return_data['身体年龄'] = $result['bodyage'];
|
||||
|
||||
// $result_end['fat_r'] = $result['fat_r'];
|
||||
// $result_end['muscle'] = $result['muscle'];
|
||||
// $result_end['water'] = $result['water'];
|
||||
// $result_end['bone'] = $result['bone'];
|
||||
// $result_end['kcal'] = $result['kcal'];
|
||||
// $result_end['fat_w'] = $result['fat_w'];
|
||||
// $result_end['visceral'] = $result['visceral'];
|
||||
// $result_end['protein'] = $result['protein'];
|
||||
// $result_end['bodyage'] = $result['bodyage'];
|
||||
// $result_end['bmi'] = $result['bmi'];
|
||||
// // $result_end['cmi'] = $result['cmi'];
|
||||
// $result_end['sfr'] = $result['sfr'];
|
||||
// // $result_end['sfrval'] = $result['sfrval'];
|
||||
// $result_end['skeletalmuscle'] = $result['skeletalmuscle'];
|
||||
// $result_end['muscleval'] = $result['muscleval'];
|
||||
// $result_end['proteinval'] = $result['proteinval'];
|
||||
// $result_end['lbm'] = $result['lbm'];
|
||||
// $result_end['weight'] = $result['weight'];
|
||||
// $result_end['height'] = $result['height'];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
|
||||
// 计算身体数据,BMI、脂肪率、脂肪量、肌肉率、肌肉量....
|
||||
public function calculate_body_data($height,$weight,$age,$gender,$impedance){
|
||||
|
||||
$result_data = [];
|
||||
$mheight = bcdiv($height, '100', 20); // 假设我们保留20位小数
|
||||
$gender = $gender == 0 ? 1 : $gender;
|
||||
|
||||
if (($weight <= 0) || ($weight > 220) || ($height <= 0) || ($height > 270) || ($age <= 0) || ($age > 120) || ($impedance <= 0) || ($impedance > 1000) || !in_array($gender, [1, 2])) {
|
||||
if ($weight != 0 && $height != 0) {
|
||||
// 计算BMI
|
||||
$bmi = bcdiv($weight, bcmul($mheight, $mheight,20), 2);
|
||||
$result_data['bmi'] = $bmi;
|
||||
$result_data['bone'] = 0;
|
||||
$result_data['muscle'] = 0;
|
||||
$result_data['water'] = 0;
|
||||
$result_data['fat_r'] = 0;
|
||||
$result_data['sfr'] = 0;
|
||||
$result_data['skeletalmuscle'] = 0;
|
||||
$result_data['protein'] = 0;
|
||||
$result_data['visceral'] = 0;
|
||||
$result_data['kcal'] = 0;
|
||||
$result_data['bodyage'] = 0;
|
||||
$result_data['weight'] = $weight;
|
||||
$result_data['height'] = $height;
|
||||
$result_data['age'] = $age;
|
||||
$result_data['adc'] = $impedance;
|
||||
$result_data['gender'] = $gender;
|
||||
$result_data['standard_level'] = 0.0;
|
||||
return $result_data;
|
||||
}
|
||||
}
|
||||
$num = intval(bcmul(bcdiv($weight,bcmul($mheight,$mheight,20),20),'10',20))/10;
|
||||
$num2 = 0.0;
|
||||
$num3 = 0.0;
|
||||
$num4 = 0.0;
|
||||
$num5 = 0.0;
|
||||
$num6 = 0.0;
|
||||
$num7 = 0.0;
|
||||
$num8 = 0.0;
|
||||
$num9 = 0.0;
|
||||
$num10 = 0.0;
|
||||
$num11 = 0.0;
|
||||
// 根据男女计算脂肪率、脂肪量、肌肉率、肌肉量等等....
|
||||
$standard_weight = 0.0;
|
||||
$standard_level = 0.0;
|
||||
if ($gender == 1){
|
||||
// $num2 = 0.015 * $weight + (2.0 - 0.00055 * $impedance) * $height / 100 - 1.15;
|
||||
$num2 = bcsub(bcadd(bcmul('0.015',$weight,20),bcdiv(bcmul(bcsub('2.0',bcmul('0.00055',$impedance,20),20),$height,20),'100.0',20),20),'1.15',2);
|
||||
// $num3 = (0.0 - (0.00115 * $impedance + 0.01)) * $weight + (49.64 - 0.031 * $impedance) * $height / 100.0 + $impedance * 0.08 + $age * 0.04 + 15.4;
|
||||
$num3 = bcsub(bcsub(bcsub(bcsub(bcmul(bcsub('0.0',bcadd(bcmul('0.00115',$impedance,20),'0.01',20),20),$weight,20),bcdiv(bcmul(bcsub('49.64',bcmul('0.031',$impedance,20)),$height,20),'100.0',20),20),bcmul($impedance,'0.08'),20),bcmul($age,'0.04'),20),'15.4',2);
|
||||
// $num4 = 1000000.0/($num*(2.688*$impedance-78.28))-(10058/$impedance)-0.22*$age+52.6;
|
||||
$num4 = bcadd(bcsub(bcsub(bcdiv('1000000.0',bcmul($num,bcsub(bcmul('2.688',$impedance,20),'78.28',20),20),20),bcdiv('10058',$impedance,20),20),bcmul('0.22',$age,20),20),'52.6',20);
|
||||
// $num5 = -930000.0 / $num / (1.966 * $impedance - 58.46) + (13176 / $impedance) - 0.06 * $age + 40.0;
|
||||
$num5 = bcadd(bcsub(bcadd(bcdiv(bcdiv('-930000.0',$num,20),bcsub(bcmul('1.966',$impedance,20),'58.46',20),20),bcdiv('13176',$impedance,0),20),bcmul('0.06',$age,20),20),'40.0',20);
|
||||
// $num6 = 0.898 * $num5;
|
||||
$num6 = bcmul('0.898',$num5,1);
|
||||
// $num7 = 0.895 * $num4;
|
||||
$num7 = bcmul('0.895',$num4,20);
|
||||
// $num8 = 0.8 * (100.0 - $num5 - $num4 - $num2 / $weight);
|
||||
$num8 = bcmul('0.8',bcsub(bcsub(bcsub('100.0',$num5,20),$num4,20),bcdiv($num2,$weight,20),20),2);
|
||||
// $num9 = 0.304 * $weight - 25.58 * $height / 100.0 + 0.131 * $age + 0.005 * $impedance + 22.0;
|
||||
$num9 = bcadd(bcadd(bcadd(bcsub(bcmul('0.304',$weight,20),bcdiv(bcmul('25.58',$height,20),'100.0',20),20),bcmul('0.131',$age,20),20),bcmul('0.005',$impedance,20),20),'22.0',0);
|
||||
// $num10 = (9.0 + 0.0015 * $impedance) * $weight + (1350.0 - 0.88 * $impedance) * $height / 100.0 + (188 / $age) + 0.748 * $impedance - 1053.0;
|
||||
$num10 = bcsub(bcadd(bcadd(bcadd(bcmul(bcadd('9.0',bcmul('0.0015',$impedance,20),20),$weight,20),bcdiv(bcmul(bcsub('1350.0',bcmul('0.88',$impedance,20),20),$height,20),'100.0',20),20),bcdiv('188',$age,20),20),bcmul('0.748',$impedance,20),20),'1053.0',0);
|
||||
// $num11 = $age * (1.0 + 0.012 * ($num - 1.0)) - 21.0 + (30 - $age) * 0.35 + ($impedance - 450) * 0.02 + 11.0;
|
||||
$num11 = bcadd(bcadd(bcadd(bcsub(bcmul($age,bcadd('1.0',bcmul('0.012',bcsub($num,'1.0',20),20),20),20),'21.0',20),bcmul(bcsub('30',$age,20),'0.35',20),20),bcmul(bcsub($impedance,'450',20),'0.02',20),20),'11.0',0);
|
||||
|
||||
// $standard_weight = ($height-80)*0.7;
|
||||
$standard_weight = bcmul(bcsub($height,'80',20),'0.7',20);
|
||||
|
||||
}else{
|
||||
// $num2 = 2.2E-05 * $impedance * $weight + (4.99 - 0.00284 * $impedance) * $height / 100.0 + 0.0012 * $impedance - 4.45;
|
||||
$num2 = bcsub(bcadd(bcadd(bcmul(bcmul('0.000022',$impedance,20),$weight,20),bcdiv(bcmul(bcsub('4.99',bcmul('0.00284',$impedance,20),20),$height,20),'100.0',20),20),bcmul('0.0012',$impedance,20),20),'4.45',2);
|
||||
// $num3 = (0.0 - (0.00115 * $impedance + 0.01)) * $weight + (49.64 - 0.031 * $impedance) * $height / 100.0 + $impedance * 0.08 + $age * 0.04 + 6.0;
|
||||
$num3 = bcadd(bcadd(bcadd(bcadd(bcmul(bcsub('0.0',bcadd(bcmul('0.00115',$impedance,20),'0.01',20),20),$weight,20),bcdiv(bcmul(bcsub('49.64',bcmul('0.031',$impedance,20),20),$height,20),'100.0',20),20),bcmul($impedance,'0.08',20),20),bcmul($age,'0.04',20),20),'6.0',2);
|
||||
// $num4 = 1000000.0 / ($num * (2.467 * $impedance - 75.37)) - (14215 / $impedance) - 0.034 * $age + 43.2;
|
||||
$num4 = bcadd(bcsub(bcsub(bcdiv('1000000.0',bcmul($num,bcsub(bcmul('2.467',$impedance,20),'75.37',20),20),20),bcdiv('14215',$impedance,20),20),bcmul('0.034',$age,20),20),'43.2',20);
|
||||
// $num5 = -3030000.0 / ($num + 20.0) / (1.966 * $impedance - 58.46) + (28176 / $impedance) - 0.06 * $age + 51.0;
|
||||
$num5 = bcadd(bcsub(bcadd(bcdiv(bcdiv('-3030000.0',bcadd($num,'20.0',20),20),bcsub(bcmul('1.966',$impedance,20),'58.46',20),20),bcdiv('28176',$impedance,20),20),bcmul('0.06',$age,20),20),'51.0',20);
|
||||
// $num6 = 0.876 * $num5 + 1.66;
|
||||
$num6 = bcadd(bcmul('0.876',$num5,20),'1.66',1);
|
||||
// $num7 = 0.857 * $num4 - 0.36;
|
||||
$num7 = bcsub(bcmul('0.857',$num4,20),'0.36',20);
|
||||
// $num8 = 0.75 * (100.0 - $num5 - $num4 - $num2 / $weight);
|
||||
$num8 = bcmul('0.75',bcsub('100.0',bcsub($num5,bcsub($num4,bcdiv($num2,$weight,20),20),20),20),2);
|
||||
// $num9 = 0.304 * $weight - 25.58 * $height / 100.0 + 0.131 * $age + 0.005 * $impedance + 22.0;
|
||||
$num9 = bcadd(bcadd(bcadd(bcsub(bcmul(0.304,$weight,20),bcdiv(bcmul(25.58,$height,20),'100.0',20),20),bcmul('0.131',$age,20),20),bcmul('0.005',$impedance,20),20),'22.0',0);
|
||||
// $num10 = (0.00307 * $impedance + 1.5) * $weight + (1459.0 - 0.989 * $impedance) * $height / 100.0 + $age * 0.9 + 0.923 * $impedance - 950.0;
|
||||
$num10 = bcsub(bcadd(bcadd(bcadd(bcmul(bcadd(bcmul('0.00307',$impedance,20),'1.5',20),$weight,20),bcdiv(bcmul(bcsub('1459.0',bcmul('0.989',$impedance,20),20),$height,20),'100.0',20),20),bcmul($age,'0.9',20),20),bcmul('0.923',$impedance,20),20),'950.0',0);
|
||||
// $num11 = $age * (0.95 + 0.02 * ($num - 21.2)) + ($impedance - 500) * 0.02;
|
||||
$num11 = bcadd(bcmul($age,bcadd(0.95,bcmul('0.02',bcsub($num,'21.2',20),20),20),20),bcmul(bcsub($impedance,'500',20),'0.02',20),0);
|
||||
|
||||
// $standard_weight = ($height-80)*0.7;
|
||||
$standard_weight = bcmul(bcsub($height,'80',20),'0.6',20);
|
||||
}
|
||||
|
||||
$result_data['bmi'] = $num;
|
||||
// $num2 = (($num2 > $weight * 0.15) ? ($weight * 0.15) : $num2);
|
||||
if(bccomp($num2, bcmul($weight,'0.15',20), 20) === 1){
|
||||
$num2 = bcmul($weight,'0.15',2);
|
||||
}
|
||||
// $result_data['bone'] = ($num2 < $weight * 0.02) ? ($weight * 0.02) : $num2;
|
||||
if(bccomp($num2, bcmul($weight,'0.02',20), 20) === -1){
|
||||
$result_data['bone'] = bcmul($weight,'0.02',2);
|
||||
}else{
|
||||
$result_data['bone'] = $num2;
|
||||
}
|
||||
// $num3 = (($num3 > 75.0) ? 75.0 : $num3);
|
||||
if(bccomp($num3, '75.0', 20) === 1){
|
||||
$num3 = '75.0';
|
||||
}
|
||||
// $result_data['muscle'] = ($num3 < 15.0) ? 15.0 : $num3;
|
||||
if(bccomp($num3, '15.0', 20) === -1){
|
||||
$result_data['muscle'] = '15.00';
|
||||
}else{
|
||||
$result_data['muscle'] = $num3;
|
||||
}
|
||||
// $num4 = (($num4 > 70.0) ? 70.0 : $num4);
|
||||
if(bccomp($num4, '70.0', 20) === 1){
|
||||
$num4 = '70.0';
|
||||
}
|
||||
// $result_data['water'] = ($num4 < 20.0) ? 20.0 : $num4;
|
||||
if(bccomp($num4, '20.0', 20) === -1){
|
||||
$result_data['water'] = '20.00';
|
||||
}else{
|
||||
$result_data['water'] = $num4;
|
||||
}
|
||||
// $num5 = (($num5 > 50.0) ? 50.0 : $num5);
|
||||
if(bccomp($num5, '50.0', 20) === 1){
|
||||
$num5 = '50.0';
|
||||
}
|
||||
// $result_data['fat_r'] = ($num5 < 5.0) ? 5.0 : $num5;
|
||||
|
||||
if(bccomp($num5, '5.0', 20) === -1){
|
||||
$result_data['fat_r'] = '5.00';
|
||||
}else{
|
||||
// $result_data['fat_r'] = $num5;
|
||||
$result_data['fat_r'] = substr($num5, 0, strpos($num5, ".") + 3);
|
||||
}
|
||||
// $result_data['sfr'] = $num6 <= 0 ? "0" : $num6;
|
||||
if(bccomp($num6, '0.0', 20) === -1){
|
||||
$result_data['sfr'] = '0.00';
|
||||
}else{
|
||||
$result_data['sfr'] = $num6;
|
||||
}
|
||||
// $result_data['skeletalmuscle'] = $num7;
|
||||
$result_data['skeletalmuscle'] = substr($num7, 0, strpos($num7, ".") + 3);
|
||||
// $num8 = (($num8 > 50.0) ? 50.0 : $num8);
|
||||
if(bccomp($num8, '50.0', 20) === 1){
|
||||
$num8 = '50.00';
|
||||
}
|
||||
// $result_data['protein'] = ($num8 < 10.0) ? 10.0 : $num8;
|
||||
if(bccomp($num8, '10.0', 20) === -1){
|
||||
$result_data['protein'] = '10.00';
|
||||
}else{
|
||||
$result_data['protein'] = $num8;
|
||||
}
|
||||
// $num9 = (($num9 > 20.0) ? 20.0 : $num9);
|
||||
if(bccomp($num9, '20.0', 20) === 1){
|
||||
$num9 = '20.0';
|
||||
}
|
||||
// $result_data['visceral'] = ($num9 < 1.0) ? 1.0 : $num9;
|
||||
if(bccomp($num9, '1.0', 20) === -1){
|
||||
$result_data['visceral'] = '1.0';
|
||||
}else{
|
||||
$result_data['visceral'] = $num9;
|
||||
}
|
||||
// $result_data['kcal'] = $num10 <= 0 ? "0" : $num10;
|
||||
if(bccomp($num10, '0', 20) !== 1){
|
||||
$result_data['kcal'] = '0';
|
||||
}else{
|
||||
$result_data['kcal'] = $num10;
|
||||
}
|
||||
|
||||
// $standard_level = ($weight-$standard_weight)/$standard_weight;
|
||||
$standard_level = bcdiv(bcsub($weight,$standard_weight,20),$standard_weight,2);
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
if ($age < 18){
|
||||
$num11 = $age;
|
||||
}else{
|
||||
// $num11 = (($num11 > ($age + 10)) ? (($age + 10)) : $num11);
|
||||
if(bccomp($num11, $age + 10, 20) === 1){
|
||||
$num11 = $age + 10;
|
||||
}
|
||||
// $num11 = (($num11 < ($age - 10)) ? (($age - 10)) : $num11);
|
||||
if(bccomp($num11, $age - 10, 20) === -1){
|
||||
$num11 = $age - 10;
|
||||
}
|
||||
}
|
||||
|
||||
$result_data['bodyage'] = $num11;
|
||||
$result_data['weight'] = $weight;
|
||||
$result_data['height'] = $height;
|
||||
$result_data['age'] = $age;
|
||||
$result_data['adc'] = $impedance;
|
||||
$result_data['gender'] = $gender;
|
||||
$result_data['standard_level'] = $standard_level;
|
||||
return $result_data;
|
||||
}
|
||||
// 计算脂肪率
|
||||
function calculate_fat_r(){
|
||||
}
|
||||
// 计算脂肪量
|
||||
function calculate_zhifangliang(){
|
||||
|
||||
}
|
||||
// 计算肌肉率
|
||||
function calculate_jiroulv(){
|
||||
|
||||
}
|
||||
// 计算肌肉量
|
||||
function calculate_jirouliang(){
|
||||
|
||||
}
|
||||
// 计算水分
|
||||
function calculate_shuifen(){
|
||||
|
||||
}
|
||||
// 计算蛋白量
|
||||
function calculate_danbailiang(){
|
||||
|
||||
}
|
||||
// 计算骨重
|
||||
function calculate_guzhong(){
|
||||
|
||||
}
|
||||
// 计算蛋白率
|
||||
function calculate_danbailv(){
|
||||
|
||||
}
|
||||
// 计算基础代谢
|
||||
function calculate_jichudaixie(){
|
||||
|
||||
}
|
||||
// 计算内脏指数
|
||||
function calculate_neizangzhishu(){
|
||||
|
||||
}
|
||||
// 计算皮下脂肪
|
||||
function calculate_pixiazhifang(){
|
||||
|
||||
}
|
||||
// 计算肥胖等级
|
||||
function calculate_feipangdengji(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function msg($code,$msg='',$data=[]){
|
||||
return json(['code'=>$code,'msg'=>$msg,'data'=>$data]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
namespace app\NewReedaw\controller\app;
|
||||
|
||||
use think\Db;
|
||||
use think\Cache;
|
||||
|
||||
class Card extends Base{
|
||||
|
||||
protected $card_db_name = [
|
||||
'zhanghao'=>'app_account_number',
|
||||
'juese'=>'app_user_data',
|
||||
'card'=>'app_card_data'
|
||||
];
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
// 测试token=>'caadd1be045a65f30b92aa805f1de54a'
|
||||
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
|
||||
// 卡片列表信息
|
||||
public function card_list_msg(){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
return $this->card_list_msg_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 卡片列表信息
|
||||
public function card_user_order(){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('card_data', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
return $this->card_user_order_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
################################################################action################################################################
|
||||
################################################################action################################################################
|
||||
public function card_list_msg_action($data){
|
||||
// 检查角色
|
||||
$user_data = Db::table($this->card_db_name['juese'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,card_order')->find();
|
||||
if(!$user_data){
|
||||
return $this->msg(10003,'未核实到角色信息');
|
||||
}
|
||||
// 获取卡片信息
|
||||
$card_data = Db::table($this->card_db_name['card'])->where(['is_del'=>0])->field('id,name,content,page_url_report,is_sub_item,background_color,background_pic,key_word')->cache(86400)->select();
|
||||
// 根据用户处理卡片信息
|
||||
$return_data = [
|
||||
'chosen_yes'=>[],
|
||||
'chosen_no'=>[],
|
||||
];
|
||||
if($user_data['card_order'] != ''){
|
||||
$user_data['card_order'] = explode(',',$user_data['card_order']);
|
||||
}else{
|
||||
$user_data['card_order'] = [];
|
||||
}
|
||||
for ($i=0; $i < count($card_data); $i++) {
|
||||
if(!in_array($card_data[$i]['id'],$user_data['card_order'])){
|
||||
$return_data['chosen_no'][] = $card_data[$i];
|
||||
}else{
|
||||
$key = array_search($card_data[$i]['id'], $user_data['card_order']);
|
||||
$return_data['chosen_yes'][$key] = $card_data[$i];
|
||||
}
|
||||
}
|
||||
ksort($return_data['chosen_yes']);
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
public function card_user_order_action($data){
|
||||
|
||||
if($data['card_data'] != ''){
|
||||
$data['card_data2'] = explode(',',$data['card_data']);
|
||||
}else{
|
||||
$data['card_data2'] = [];
|
||||
}
|
||||
|
||||
foreach ($data['card_data2'] as $key => $value) {
|
||||
if(!$this->verify_data_is_ok($value,'intnum')){
|
||||
return $this->msg(10005,'卡片id错误');
|
||||
}
|
||||
}
|
||||
$user_data = Db::table($this->card_db_name['juese'])->where(['id'=>$data['aud_id'],'is_del'=>0])->count();
|
||||
if($user_data <= 0){
|
||||
return $this->msg(10003,'未核实到角色信息');
|
||||
}
|
||||
$result = Db::table($this->card_db_name['juese'])->where(['id'=>$data['aud_id']])->update(['card_order' => $data['card_data']]);
|
||||
if($result){
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace app\NewReedaw\controller\app;
|
||||
|
||||
use think\Db;
|
||||
use think\Cache;
|
||||
|
||||
class Countfood extends Base{
|
||||
|
||||
protected $card_db_name = [
|
||||
'zhanghao'=>'app_account_number',
|
||||
];
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
// 测试token=>'caadd1be045a65f30b92aa805f1de54a'
|
||||
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
|
||||
// 卡片列表信息
|
||||
public function card_list_msg(){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
return $this->card_list_msg_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
################################################################action################################################################
|
||||
################################################################action################################################################
|
||||
public function card_list_msg_action($data){
|
||||
// 检查角色
|
||||
$user_data = Db::table($this->card_db_name['juese'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,card_order')->find();
|
||||
if(!$user_data){
|
||||
return $this->msg(10003,'未核实到角色信息');
|
||||
}
|
||||
// 获取卡片信息
|
||||
$card_data = Db::table($this->card_db_name['card'])->where(['is_del'=>0])->field('id,name,content,page_url_report,is_sub_item,background_color,background_pic,key_word')->cache(86400)->select();
|
||||
// 根据用户处理卡片信息
|
||||
$return_data = [
|
||||
'chosen_yes'=>[],
|
||||
'chosen_no'=>[],
|
||||
];
|
||||
if($user_data['card_order'] != ''){
|
||||
$user_data['card_order'] = explode(',',$user_data['card_order']);
|
||||
}else{
|
||||
$user_data['card_order'] = [];
|
||||
}
|
||||
for ($i=0; $i < count($card_data); $i++) {
|
||||
if(!in_array($card_data[$i]['id'],$user_data['card_order'])){
|
||||
$return_data['chosen_no'][] = $card_data[$i];
|
||||
}else{
|
||||
$key = array_search($card_data[$i]['id'], $user_data['card_order']);
|
||||
$return_data['chosen_yes'][$key] = $card_data[$i];
|
||||
}
|
||||
}
|
||||
ksort($return_data['chosen_yes']);
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
namespace app\NewReedaw\controller\app;
|
||||
|
||||
use think\Db;
|
||||
use think\Cache;
|
||||
|
||||
class Gufen extends Base{
|
||||
|
||||
protected $card_db_name = [
|
||||
'zhanghao'=>'app_account_number',
|
||||
'guize'=>'admin_estimate',
|
||||
|
||||
];
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
// 测试token=>'caadd1be045a65f30b92aa805f1de54a'
|
||||
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
|
||||
// 获取单个类型列表
|
||||
public function get_single_data($data = ['address'=>'上海','gender'=>'1','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('address', $data) || !array_key_exists('gender', $data) || !array_key_exists('token', $data)){
|
||||
$return_data = $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['address'],'str')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['gender'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
unset($data['token']);
|
||||
$return_data = $this->sportstesting_get_type_list_action($data);
|
||||
|
||||
// 成功
|
||||
$this->record_api_log($data, null, $return_data);
|
||||
return $return_data;
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
################################################################action################################################################
|
||||
################################################################action################################################################
|
||||
public function sportstesting_get_type_list_action($data){
|
||||
|
||||
$parameter_data = explode(',',$data['address']);
|
||||
$gender = $data['gender'];
|
||||
// 精准查询地市规则start
|
||||
// if(count($parameter_data) == 1){
|
||||
// $db_condition = "province = '".$parameter_data[0]."'";
|
||||
// }else if(count($parameter_data) == 2){
|
||||
// $db_condition = "province = '".$parameter_data[0]."' and city = '".$parameter_data[1]."'";
|
||||
// }else if(count($parameter_data) == 3){
|
||||
// $db_condition = "province = ".$parameter_data[0]."' and city = '".$parameter_data[1]."' and area = '".$parameter_data[2]."'";
|
||||
// }else{
|
||||
// return $this->msg(10005);
|
||||
// }
|
||||
// 精准查询地市规则end
|
||||
// 全省地市一个规则start
|
||||
$db_condition = "province = '".$parameter_data[0]."'";
|
||||
// 全省地市一个规则end
|
||||
$data = Db::table($this->card_db_name['guize'])->where($db_condition)->find();
|
||||
$data = json_decode($data['content'],true);
|
||||
$result = $this->handle_default_rule_list_content($data,$gender);
|
||||
return $this->msg($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
namespace app\NewReedaw\controller\app;
|
||||
|
||||
use think\Controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Cache;
|
||||
use think\Log;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use app\NewReedaw\controller\app\Role;
|
||||
use app\app\controller\Language;
|
||||
|
||||
class Index extends Base{
|
||||
|
||||
|
|
@ -15,7 +16,67 @@ class Index extends Base{
|
|||
'zhanghao'=>'app_account_number',
|
||||
'juese'=>'app_user_data',
|
||||
'body_data'=>'app_card_body_data',
|
||||
|
||||
'banben'=>'app_version_log',
|
||||
'shangwuhezuo'=>'admin_business_cooperation',
|
||||
'diqu'=>'admin_estimate',
|
||||
'banner'=>'admin_notice_banner',
|
||||
'skip'=>'app_card_skip_data',
|
||||
'vitalcapacity'=>'app_card_vitalcapacity_data',
|
||||
];
|
||||
protected $request_result = [
|
||||
'2'=>['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI',''],'head'=>['头围',''],'fat_w'=>['脂肪量','kg'],'fat_r'=>['脂肪率','%'],'muscleval'=>['肌肉量','kg'],'muscle'=>['肌肉率','%'],'proteinval'=>['蛋白量','kg'],'protein'=>['蛋白率','%'],'water'=>['水分',''],'bone'=>['骨重','kg'],'visceral'=>['内脏指数',''],'sfr'=>['皮下脂肪','%'],'kcal'=>['基础代谢','kcal'],'un_fat_w_weight'=>['去脂体重','kg'],'body_age'=>['体龄',''],'body_level'=>['肥胖等级',''],'body_type'=>['体型','']],
|
||||
'6'=>['jump_num'=>['个数',''],'jump_time'=>['时长',''],'jump_kcal'=>['卡路里','kcal']],
|
||||
'8'=>['one_val'=>['第一次','ml'],'two_val'=>['第二次','ml'],'three_val'=>['第三次','ml'],'average_val'=>['三次平均','ml'],'score'=>['最后成绩','分']]
|
||||
];
|
||||
protected $identity_list = ['P0'=>'陌生人','P1'=>'爸爸','P2'=>'妈妈','P3'=>'大宝','P4'=>'二宝','P5'=>'三宝','P6'=>'四宝','P7'=>'爷爷','P8'=>'奶奶'];
|
||||
protected $grade_list = [
|
||||
['id'=>'nothing','name'=>'无'],
|
||||
['id'=>'grade_s_1','name'=>'小学一年级'],
|
||||
['id'=>'grade_s_2','name'=>'小学二年级'],
|
||||
['id'=>'grade_s_3','name'=>'小学三年级'],
|
||||
['id'=>'grade_s_4','name'=>'小学四年级'],
|
||||
['id'=>'grade_s_5','name'=>'小学五年级'],
|
||||
['id'=>'grade_s_6','name'=>'小学六年级'],
|
||||
['id'=>'grade_m_1','name'=>'初中一年级'],
|
||||
['id'=>'grade_m_2','name'=>'初中二年级'],
|
||||
['id'=>'grade_m_3','name'=>'初中三年级'],
|
||||
['id'=>'grade_h_1','name'=>'高中一年级'],
|
||||
['id'=>'grade_h_2','name'=>'高中二年级'],
|
||||
['id'=>'grade_h_3','name'=>'高中三年级'],
|
||||
['id'=>'grade_u_12','name'=>'大学一、二年级'],
|
||||
['id'=>'grade_u_34','name'=>'大学三、四年级']
|
||||
];
|
||||
protected $language_country = [
|
||||
'en' => 'English', // 英语(通用)★
|
||||
'zh-Hans' => '中文', // 中文(简体)★
|
||||
// 'es' => 'Español', // 西班牙语(西班牙)★
|
||||
// 'fr' => 'Français', // 法语(法国)★
|
||||
// 'pt' => 'Português', // 葡萄牙语(巴西)★
|
||||
// 'ar' => 'العربية', // 阿拉伯语(标准)★
|
||||
// 'ru' => 'Русский', // 俄语(俄罗斯)★
|
||||
// 'de' => 'Deutsch', // 德语(德国)★
|
||||
// 'ja' => '日本語', // 日语
|
||||
// 'ko' => '한국어', // 韩语
|
||||
// 'it' => 'Italiano', // 意大利语
|
||||
// 'nl' => 'Nederlands', // 荷兰语
|
||||
// 'hi' => 'हिन्दी', // 印地语
|
||||
// 'tr' => 'Türkçe', // 土耳其语
|
||||
// 'vi' => 'Tiếng Việt', // 越南语
|
||||
// 'th' => 'ไทย', // 泰语
|
||||
// 'pl' => 'Polski', // 波兰语
|
||||
// 'sv' => 'Svenska', // 瑞典语
|
||||
// 'fi' => 'Suomi', // 芬兰语
|
||||
// 'da' => 'Dansk', // 丹麦语
|
||||
// 'no' => 'Norsk', // 挪威语
|
||||
// 'he' => 'עברית', // 希伯来语
|
||||
// 'id' => 'Bahasa Indonesia', // 印尼语
|
||||
// 'ms' => 'Bahasa Melayu', // 马来语
|
||||
// 'cs' => 'Čeština', // 捷克语
|
||||
// 'hu' => 'Magyar', // 匈牙利语
|
||||
// 'el' => 'Ελληνικά', // 希腊语
|
||||
// 'ro' => 'Română', // 罗马尼亚语
|
||||
// 'sk' => 'Slovenčina', // 斯洛伐克语
|
||||
// 'uk' => 'Українська', // 乌克兰语
|
||||
];
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
|
|
@ -30,16 +91,7 @@ class Index extends Base{
|
|||
// 配置信息
|
||||
public function config($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
return $this->config_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
|
|
@ -55,20 +107,41 @@ class Index extends Base{
|
|||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 获取首页角色信息
|
||||
public function get_user_data_information(){
|
||||
|
||||
// 身高预测
|
||||
public function genetic_height(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){
|
||||
if(!is_array($data)){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
if(!array_key_exists('dadHeight', $data) || !array_key_exists('momHeight', $data) || !array_key_exists('birthday', $data) || !array_key_exists('sex', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
unset($data['token']);
|
||||
if(!$this->verify_data_is_ok($data['birthday'],'datetime')){
|
||||
return $this->msg(10005,'birthday type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
if(!$this->verify_data_is_ok($data['dadHeight'],'num')){
|
||||
return $this->msg(10005,'dadHeight type error');
|
||||
}
|
||||
return $this->get_user_data_information_action($data);
|
||||
if(!$this->verify_data_is_ok($data['momHeight'],'num')){
|
||||
return $this->msg(10005,'momHeight type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['sex'],'intnum')){
|
||||
return $this->msg(10005,'sex type error');
|
||||
}
|
||||
|
||||
// 直接开始业务,请求外部接口start
|
||||
$url = 'https://ybapi.pcxbc.com/api/child/predictheight';
|
||||
$temporary_parameter = [
|
||||
'dadHeight'=>$data['dadHeight'],
|
||||
'momHeight'=>$data['momHeight'],
|
||||
'birthday'=>$data['birthday'],
|
||||
'sex'=>$data['sex'],
|
||||
];
|
||||
$request_result = $this->postRequest($url,$temporary_parameter,array('Content-Type:application/json','Origin:http://ybdevice.pcxbc.com'));
|
||||
return json($request_result);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
|
|
@ -84,6 +157,128 @@ class Index extends Base{
|
|||
}
|
||||
}
|
||||
|
||||
// BMI测评
|
||||
public function bmi_evaluation(){
|
||||
try {
|
||||
$cbe_data = input('post.');
|
||||
if(!is_array($cbe_data)){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
if(!array_key_exists('height', $cbe_data) || !array_key_exists('weight', $cbe_data) || !array_key_exists('birthday', $cbe_data) || !array_key_exists('sex', $cbe_data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
unset($cbe_data['token']);
|
||||
if(!$this->verify_data_is_ok($cbe_data['birthday'],'datetime')){
|
||||
return $this->msg(10005,'birthday type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($cbe_data['height'],'num')){
|
||||
return $this->msg(10005,'height type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($cbe_data['weight'],'num')){
|
||||
return $this->msg(10005,'weight type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($cbe_data['sex'],'intnum')){
|
||||
return $this->msg(10005,'sex type error');
|
||||
}
|
||||
|
||||
// 直接开始业务,请求外部接口start
|
||||
$url = 'http://ybdevice.pcxbc.com/api/result/calcbmi';
|
||||
$temporary_parameter = [
|
||||
'height'=>$cbe_data['height'],
|
||||
'weight'=>$cbe_data['weight'],
|
||||
'birthday'=>$cbe_data['birthday'],
|
||||
'sex'=>$cbe_data['sex'],
|
||||
];
|
||||
$request_result = $this->postRequest($url,$temporary_parameter,array('Content-Type:application/json','Origin:http://ybdevice.pcxbc.com'));
|
||||
// 直接开始业务,请求外部接口end
|
||||
|
||||
// 处理进度点
|
||||
$request_result =$this->bmi_evaluation_action($request_result);
|
||||
return $request_result;
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($cbe_data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
|
||||
// 数据对比(包含身体、跳绳、肺活量)
|
||||
public function all_data_contrast($data = ['before_id'=>'171','after_id'=>'174','type'=>'2','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('before_id', $data) || !array_key_exists('after_id', $data) || !array_key_exists('type', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['before_id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['after_id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['type'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
unset($data['token']);
|
||||
if($data['type'] == '2'){
|
||||
return $this->get_body_data_contrast($data);
|
||||
}else if($data['type'] == '6'){
|
||||
return $this->get_skip_data_contrast($data);
|
||||
}else if($data['type'] == '8'){
|
||||
return $this->get_vitalcapacity_data_contrast($data);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// // 获取首页角色信息
|
||||
// public function get_user_data_information(){
|
||||
// try {
|
||||
// $data = input('post.');
|
||||
// if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){
|
||||
// return $this->msg(10001);
|
||||
// }
|
||||
// if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
// return $this->msg(10005,'token type error');
|
||||
// }
|
||||
// if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
// return $this->msg(10005,'aud_id type error');
|
||||
// }
|
||||
// return $this->get_user_data_information_action($data);
|
||||
// } catch (\Exception $e) {
|
||||
// // 捕获异常
|
||||
// $logContent["flie"] = $e->getFile();
|
||||
// $logContent["line"] = $e->getLine();
|
||||
// $logContent['all_content'] = "异常信息:\n";
|
||||
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
// $this->record_api_log($data, $logContent, null);
|
||||
// return $this->msg(99999);
|
||||
// }
|
||||
// }
|
||||
|
||||
################################################################action################################################################
|
||||
################################################################action################################################################
|
||||
|
||||
|
|
@ -112,30 +307,498 @@ class Index extends Base{
|
|||
]
|
||||
],
|
||||
'king_kong_region'=>[
|
||||
['title'=>'增量对比','icon'=>'','jump'=>''],
|
||||
['title'=>'中招估分','icon'=>'','jump'=>''],
|
||||
['title'=>'遗传身高','icon'=>'','jump'=>''],
|
||||
['title'=>'BMI测评','icon'=>'','jump'=>''],
|
||||
['title'=>'减值对比','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/contrast.png','jump'=>'/pageTwo/compk/contrast'],
|
||||
['title'=>'中招估分','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/report.png','jump'=>'/pageTwo/score/report'],
|
||||
['title'=>'遗传身高','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/inheritHeighet.png','jump'=>'/pageTwo/home/inheritHeighet'],
|
||||
['title'=>'BMI测评','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/bmi.png','jump'=>'/pageTwo/home/bmi'],
|
||||
],
|
||||
'role_list'=>[
|
||||
]
|
||||
'version_msg'=>[],
|
||||
'login_status'=>[],
|
||||
'business_cooperation_url'=>[],
|
||||
'area_list'=>[],
|
||||
'identity_list'=>[],
|
||||
'grade_list'=>[],
|
||||
'banner'=>[],
|
||||
|
||||
];
|
||||
$role = new Role;
|
||||
$return_data['role_list'] = $role->role_list_action(['token'=>$data['token'],'type'=>2])->getData()['data'];
|
||||
|
||||
$temporary = $this->login_invalid_version($data);
|
||||
$return_data['version_msg'] = $temporary[1];
|
||||
$return_data['login_status'] = $temporary[0];
|
||||
|
||||
$return_data['business_cooperation_url'] = Db::table($this->index_db_name['shangwuhezuo'])->where(['is_del'=>0])->field('title,data_url as url')->select();
|
||||
|
||||
$address_data = Db::table($this->index_db_name['diqu'])->where(['type' => '2'])->cache(86400)->field('id,content,city,area')->find();
|
||||
$return_data['area_list'] = json_decode($address_data['content'],true);
|
||||
$return_data['identity_list'] = [];
|
||||
foreach ($this->identity_list as $key => $value) {
|
||||
array_push($return_data['identity_list'],['id'=>$key,'name'=>$value]);
|
||||
}
|
||||
$return_data['grade_list'] = $this->grade_list;
|
||||
|
||||
$return_data['banner'] = Db::table($this->index_db_name['banner'])->where(['scene_data' => '3','is_del'=>0])->cache(3600)->order('sort_num desc')->field('id,type,pic,jump_url,parameter_data,sort_num')->select();
|
||||
|
||||
for ($i=0; $i < count($return_data['banner']); $i++) {
|
||||
if($return_data['banner'][$i]['type'] != 1){
|
||||
$return_data['banner'][$i]['parameter_data'] = '';
|
||||
}
|
||||
unset($return_data['banner'][$i]['sort_num']);
|
||||
unset($return_data['banner'][$i]['ROW_NUMBER']);
|
||||
}
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
public function get_user_data_information_action($data){
|
||||
$return_result = [
|
||||
'body_data'=>[],
|
||||
'kcal_data'=>[],
|
||||
'card_data'=>[]
|
||||
public function bmi_evaluation_action($data){
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
if(!array_key_exists('code',$data) || !array_key_exists('data',$data)){
|
||||
return $this->msg(99999,'网络异常,请稍后重试1');
|
||||
}
|
||||
if($data['code'] != 0){
|
||||
return $this->msg(99999,'网络异常,请稍后重试2');
|
||||
}
|
||||
if(!is_array($data['data'])){
|
||||
return $this->msg(99999,'网络异常,请稍后重试3');
|
||||
}
|
||||
if(!array_key_exists('bmi',$data['data']) || !array_key_exists('bmilevel',$data['data']) || !array_key_exists('bmilevelcolor',$data['data']) || !array_key_exists('bmilevellist',$data['data'])){
|
||||
return $this->msg(99999,'网络异常,请稍后重试4');
|
||||
}
|
||||
if(!is_array($data['data']['bmilevellist'])){
|
||||
return $this->msg(99999,'网络异常,请稍后重试5');
|
||||
}
|
||||
$num = 0;
|
||||
$subsection_val = 0;
|
||||
$temporary_subsection_val = null;
|
||||
foreach ($data['data']['bmilevellist'] as $key => $value) {
|
||||
if(!array_key_exists('maxvalue',$value) || !array_key_exists('minvalue',$value)){
|
||||
return $this->msg(99999,'网络异常,请稍后重试6');
|
||||
}
|
||||
// 判断是否可以进行比较,规则是否正确
|
||||
if(is_numeric($value['maxvalue']) && is_numeric($value['minvalue'])){
|
||||
if($data['data']['bmi'] >= $value['minvalue'] && $data['data']['bmi'] < $value['maxvalue']){
|
||||
// 在落点内
|
||||
$subsection_val = bcsub($value['maxvalue'],$value['minvalue'],1);//获取最大最小值差
|
||||
$temporary_subsection_val = bcsub($data['data']['bmi'],$value['minvalue'],1);//获取当前值与最小值差
|
||||
$temporary_subsection_val = bcdiv($temporary_subsection_val,$subsection_val,1);//获取当前值与最小值差与最大最小值差之比
|
||||
$subsection_val = bcdiv(100,count($data['data']['bmilevellist']),1);//每段应该的百分比
|
||||
$temporary_subsection_val = bcmul($subsection_val,$temporary_subsection_val,1);//获取当前值与最小值差与最大最小值差之比与总段数之比
|
||||
$temporary_subsection_val = bcadd($temporary_subsection_val,bcmul($subsection_val,$num,1),1);
|
||||
}else{
|
||||
$num = $num + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($temporary_subsection_val === null){
|
||||
if($data['data']['bmi'] >= $data['data']['bmilevellist'][count($data['data']['bmilevellist'])-1]['maxvalue']){
|
||||
$temporary_subsection_val = 100;
|
||||
}else{
|
||||
return $this->msg(99999,'网络异常,请稍后重试7');
|
||||
}
|
||||
}
|
||||
$data['data']['offset'] = $temporary_subsection_val;
|
||||
$data = $data['data'];
|
||||
// 处理key名称一致start
|
||||
foreach ($data['bmilevellist'] as $key => $value) {
|
||||
$data['bmilevellist'][$key]['max_val'] = $value['maxvalue'];
|
||||
$data['bmilevellist'][$key]['min_val'] = $value['minvalue'];
|
||||
unset($data['bmilevellist'][$key]['minvalue']);
|
||||
unset($data['bmilevellist'][$key]['maxvalue']);
|
||||
}
|
||||
// 处理key名称一致end
|
||||
return $this->msg($data);
|
||||
}
|
||||
// 数据对比(身体)
|
||||
public function get_body_data_contrast($data){
|
||||
$data2 = [$data['before_id'],$data['after_id']];
|
||||
$data3 = implode(',',$data2);
|
||||
$calculate_arr = [];
|
||||
$result = Db::query("
|
||||
select
|
||||
acbd.id,
|
||||
acbd.height,
|
||||
acbd.weight,
|
||||
acbd.bmi,
|
||||
acbd.fat_r,
|
||||
acbd.fat_w,
|
||||
acbd.muscle,
|
||||
acbd.muscleval,
|
||||
acbd.water,
|
||||
acbd.proteinval,
|
||||
acbd.bone,
|
||||
acbd.protein,
|
||||
acbd.kcal,
|
||||
acbd.visceral,
|
||||
acbd.sfr,
|
||||
acbd.record_time,
|
||||
acbd.record_type,
|
||||
acbd.head_circumference,
|
||||
REPLACE(CONVERT(varchar(10), acbd.record_time, 23), '-', '-') AS b_time,
|
||||
aud.nickname,
|
||||
aud.gender,
|
||||
aud.birthday,
|
||||
aud.head_pic
|
||||
from ".$this->index_db_name['body_data']." as acbd
|
||||
left join ".$this->index_db_name['juese']." as aud on acbd.aud_id=aud.id
|
||||
where acbd.id in ($data3)
|
||||
and acbd.is_del = 0
|
||||
");
|
||||
|
||||
if(!$result || count($result)<2){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
// 调整顺序
|
||||
foreach ($result as $key => $value) {
|
||||
if($value['id'] == $data2[0]){
|
||||
$calculate_arr['before'] = $value;
|
||||
}else{
|
||||
$calculate_arr['after'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$return_data['time'] = $calculate_arr['before']['b_time'].'与'.$calculate_arr['after']['b_time'];
|
||||
$return_data['headimg'] = $calculate_arr['before']['head_pic'];
|
||||
$return_data['name'] = $calculate_arr['before']['nickname'];
|
||||
$return_data['gender'] = $calculate_arr['before']['gender'];
|
||||
$return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
|
||||
$return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
|
||||
$return_data['list'] = [];
|
||||
// 处理如果没有阻抗的数据为0,显示异常start;同步处理,如果两个对比数据,都没有阻抗数据,则只显示基础信息
|
||||
if($calculate_arr['before']['record_type'] != 'by_device_adc' && $calculate_arr['after']['record_type'] != 'by_device_adc'){
|
||||
foreach ($calculate_arr['before'] as $key => $value) {
|
||||
if(!in_array($key, ['height','weight','bmi','head_circumference'])){
|
||||
unset($calculate_arr['before'][$key]);
|
||||
unset($calculate_arr['after'][$key]);
|
||||
}
|
||||
}
|
||||
if($return_data['age']>=3){
|
||||
unset($calculate_arr['before']['head_circumference']);
|
||||
unset($calculate_arr['after']['head_circumference']);
|
||||
}else{
|
||||
$calculate_arr['before']['head_circumference'] = json_decode($calculate_arr['before']['head_circumference'],true);
|
||||
$calculate_arr['after']['head_circumference'] = json_decode($calculate_arr['after']['head_circumference'],true);
|
||||
foreach ($calculate_arr as $key => $value) {
|
||||
if(array_key_exists('value',$value['head_circumference'])){
|
||||
$calculate_arr[$key]['head'][0] = $value['head_circumference']['value'];
|
||||
}else{
|
||||
$calculate_arr[$key]['head'][0] = 0;
|
||||
}
|
||||
if(array_key_exists('level',$value['head_circumference'])){
|
||||
$calculate_arr[$key]['head'][1] = $value['head_circumference']['level'];
|
||||
}else{
|
||||
$calculate_arr[$key]['head'][1] = '异常';
|
||||
}
|
||||
if(array_key_exists('color',$value['head_circumference'])){
|
||||
$calculate_arr[$key]['head'][2] = $value['head_circumference']['color'];
|
||||
}else{
|
||||
$calculate_arr[$key]['head'][2] = '';
|
||||
}
|
||||
$calculate_arr[$key]['head'] = implode(',',$calculate_arr[$key]['head']);
|
||||
unset($calculate_arr['before']['head_circumference']);
|
||||
unset($calculate_arr['after']['head_circumference']);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($calculate_arr as $key => $value) {
|
||||
if($value['record_type'] != 'by_device_adc'){
|
||||
$calculate_arr[$key]['fat_r'] = "0,异常";
|
||||
$calculate_arr[$key]['fat_w'] = "0,异常";
|
||||
$calculate_arr[$key]['muscle'] = "0,异常";
|
||||
$calculate_arr[$key]['muscleval'] = "0,异常";
|
||||
$calculate_arr[$key]['water'] = "0,异常";
|
||||
$calculate_arr[$key]['proteinval'] = "0,异常";
|
||||
$calculate_arr[$key]['bone'] = "0,异常";
|
||||
$calculate_arr[$key]['protein'] = "0,异常";
|
||||
$calculate_arr[$key]['kcal'] = "0,异常";
|
||||
$calculate_arr[$key]['visceral'] = "0,异常";
|
||||
$calculate_arr[$key]['sfr'] = "0,异常";
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理如果没有阻抗的数据为0,显示异常end;同步处理,如果两个对比数据,都没有阻抗数据,则只显示基础信息
|
||||
foreach ($calculate_arr['before'] as $key => $value) {
|
||||
if(in_array($key, ['height','weight','bmi','head','fat_r','fat_w','muscle','muscleval','water','proteinval','bone','protein','kcal','visceral','sfr'])){
|
||||
$before_arr = explode(',', $value);
|
||||
$after_arr = explode(',', $calculate_arr['after'][$key]);
|
||||
array_push($return_data['list'], [
|
||||
'firstresult'=>[
|
||||
'color'=>'',
|
||||
'level'=>$before_arr[1],
|
||||
'value'=>$before_arr[0],
|
||||
'title'=>$this->request_result['2'][$key][0],
|
||||
'unit'=>$this->request_result['2'][$key][1],
|
||||
'name'=>$key,
|
||||
],
|
||||
'secondresult'=>[
|
||||
'color'=>'',
|
||||
'level'=>$after_arr[1],
|
||||
'value'=>$after_arr[0],
|
||||
'title'=>$this->request_result['2'][$key][0],
|
||||
'unit'=>$this->request_result['2'][$key][1],
|
||||
'name'=>$key,
|
||||
],
|
||||
'diffval'=>bcsub($after_arr[0],$before_arr[0],2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
// 添加头围数据(如果需要的话)end
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
// 数据对比(跳绳)
|
||||
public function get_skip_data_contrast($data){
|
||||
$data2 = [$data['before_id'],$data['after_id']];
|
||||
$data3 = implode(',',$data2);
|
||||
$calculate_arr = [];
|
||||
$result = Db::query("
|
||||
select
|
||||
acsd.id,
|
||||
acsd.jump_num,
|
||||
acsd.jump_time,
|
||||
acsd.jump_kcal,
|
||||
acsd.record_time,
|
||||
REPLACE(CONVERT(varchar(10), acsd.record_time, 23), '-', '-') AS b_time,
|
||||
aud.nickname,
|
||||
aud.gender,
|
||||
aud.birthday,
|
||||
aud.head_pic
|
||||
from ".$this->index_db_name['skip']." as acsd
|
||||
left join ".$this->index_db_name['juese']." as aud on acsd.aud_id=aud.id
|
||||
where acsd.id in ($data3)
|
||||
and acsd.is_del = 0
|
||||
");
|
||||
|
||||
if(!$result || count($result)<2){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
// 调整顺序
|
||||
foreach ($result as $key => $value) {
|
||||
if($value['id'] == $data2[0]){
|
||||
$calculate_arr['before'] = $value;
|
||||
}else{
|
||||
$calculate_arr['after'] = $value;
|
||||
}
|
||||
}
|
||||
$return_data['time'] = $calculate_arr['before']['b_time'].'-'.$calculate_arr['after']['b_time'];
|
||||
$return_data['headimg'] = $calculate_arr['before']['head_pic'];
|
||||
$return_data['name'] = $calculate_arr['before']['nickname'];
|
||||
$return_data['gender'] = $calculate_arr['before']['gender'];
|
||||
$return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
|
||||
$return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
|
||||
|
||||
$return_data['list'] = [];
|
||||
foreach ($calculate_arr['before'] as $key => $value) {
|
||||
if(in_array($key, ['jump_num','jump_time','jump_kcal'])){
|
||||
$before_arr = $value;
|
||||
$after_arr = $calculate_arr['after'][$key];
|
||||
$temporary_arr = [
|
||||
'firstresult'=>[
|
||||
'color'=>'',
|
||||
'level'=>'',
|
||||
'value'=>$key=='jump_time'?implode(':',$this->handle_hour_branch_second($before_arr)):$before_arr,
|
||||
'title'=>$this->request_result['6'][$key][0],
|
||||
'unit'=>$this->request_result['6'][$key][1],
|
||||
'name'=>$key,
|
||||
],
|
||||
'secondresult'=>[
|
||||
'color'=>'',
|
||||
'level'=>'',
|
||||
'value'=>$key=='jump_time'?implode(':',$this->handle_hour_branch_second($after_arr)):$after_arr,
|
||||
'title'=>$this->request_result['6'][$key][0],
|
||||
'unit'=>$this->request_result['6'][$key][1],
|
||||
'name'=>$key,
|
||||
],
|
||||
'diffval'=>bcsub($after_arr,$before_arr,2)
|
||||
];
|
||||
$aud_data = Db::table($this->index_db_name['juese'])->where(['id'=>$data['aud_id']])->find();
|
||||
|
||||
$body_data = Db::table($this->index_db_name['body_data'])->where(['id'=>$data['aud_id']])->find();
|
||||
|
||||
if($key=='jump_time'){
|
||||
$temporary_arr['diffval'] = $temporary_arr['diffval'] >= 0?implode(':',$this->handle_hour_branch_second($temporary_arr['diffval'])):'-'.implode(':',$this->handle_hour_branch_second($temporary_arr['diffval']));
|
||||
}
|
||||
array_push($return_data['list'], $temporary_arr);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
// 数据对比(肺活)
|
||||
public function get_vitalcapacity_data_contrast($data){
|
||||
$data2 = [$data['before_id'],$data['after_id']];
|
||||
$data3 = implode(',',$data2);
|
||||
$calculate_arr = [];
|
||||
$result = Db::query("
|
||||
select
|
||||
acsd.id,
|
||||
acsd.one_val,
|
||||
acsd.two_val,
|
||||
acsd.three_val,
|
||||
acsd.average_val,
|
||||
acsd.score_val as score,
|
||||
acsd.record_time,
|
||||
REPLACE(CONVERT(varchar(10), acsd.record_time, 23), '-', '-') AS b_time,
|
||||
aud.nickname,
|
||||
aud.gender,
|
||||
aud.birthday,
|
||||
aud.head_pic
|
||||
from ".$this->index_db_name['vitalcapacity']." as acsd
|
||||
left join ".$this->index_db_name['juese']." as aud on acsd.aud_id=aud.id
|
||||
where acsd.id in ($data3)
|
||||
and acsd.is_del = 0
|
||||
");
|
||||
|
||||
if(!$result || count($result)<2){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
// 调整顺序
|
||||
foreach ($result as $key => $value) {
|
||||
if($value['id'] == $data2[0]){
|
||||
$calculate_arr['before'] = $value;
|
||||
}else{
|
||||
$calculate_arr['after'] = $value;
|
||||
}
|
||||
}
|
||||
$return_data['time'] = $calculate_arr['before']['b_time'].'-'.$calculate_arr['after']['b_time'];
|
||||
$return_data['headimg'] = $calculate_arr['before']['head_pic'];
|
||||
$return_data['name'] = $calculate_arr['before']['nickname'];
|
||||
$return_data['gender'] = $calculate_arr['before']['gender'];
|
||||
$return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
|
||||
$return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
|
||||
|
||||
$return_data['list'] = [];
|
||||
foreach ($calculate_arr['before'] as $key => $value) {
|
||||
if(in_array($key, ['one_val','two_val','three_val','average_val','score_val'])){
|
||||
$before_arr = $value;
|
||||
$after_arr = $calculate_arr['after'][$key];
|
||||
$temporary_arr = [
|
||||
'firstresult'=>[
|
||||
'color'=>'',
|
||||
'level'=>'',
|
||||
'value'=>$before_arr,
|
||||
'title'=>$this->request_result['8'][$key][0],
|
||||
'unit'=>$this->request_result['8'][$key][1],
|
||||
'name'=>$key,
|
||||
],
|
||||
'secondresult'=>[
|
||||
'color'=>'',
|
||||
'level'=>'',
|
||||
'value'=>$after_arr,
|
||||
'title'=>$this->request_result['8'][$key][0],
|
||||
'unit'=>$this->request_result['8'][$key][1],
|
||||
'name'=>$key,
|
||||
],
|
||||
'diffval'=>bcsub($after_arr,$before_arr,2)
|
||||
];
|
||||
array_push($return_data['list'], $temporary_arr);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
|
||||
|
||||
################################################################内部调用################################################################
|
||||
################################################################内部调用################################################################
|
||||
// 检测版本及判断是否登录失效
|
||||
public function login_invalid_version($data){
|
||||
// 获取客户端IP
|
||||
$ip = request()->ip();
|
||||
// 调用IP识别方法
|
||||
$region = $this->getIpInfo($ip);
|
||||
// 解析地区信息
|
||||
$regionParts = explode('|', $region);
|
||||
$country = $regionParts[0] ?? '';
|
||||
// 判断国家是否在支持的语言列表中
|
||||
$language = '';
|
||||
if ($country && $country !== '0') {
|
||||
$languageMap = [
|
||||
'中国' => 'zh-Hans',
|
||||
'美国' => 'en',
|
||||
'英国' => 'en',
|
||||
'西班牙' => 'es',
|
||||
'法国' => 'fr',
|
||||
'葡萄牙' => 'pt',
|
||||
'阿拉伯联合酋长国' => 'ar',
|
||||
'俄罗斯' => 'ru',
|
||||
'德国' => 'de'
|
||||
];
|
||||
$language = $languageMap[$country] ?? '';
|
||||
}
|
||||
// 检查语言是否在支持列表中
|
||||
$language_all = new Language();
|
||||
$isSupportedLanguage = array_key_exists($language, $language_all->getSupportedLanguages());
|
||||
|
||||
$result = Db::table($this->index_db_name['banben'])->order('is_del,id desc')->find();
|
||||
if($result){
|
||||
$version = $result['version_num_original'];
|
||||
$url = $result['download_url'];
|
||||
}else{
|
||||
$version = '';
|
||||
$url = '';
|
||||
}
|
||||
if(!array_key_exists('token', $data)){
|
||||
return [['code'=>-1,'description'=>'已过期'],['version'=>$version,'url'=>$url,'language'=>'zh-Hans','language_arr'=>$this->process_Language()]];
|
||||
}else{
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
$user_token_state = $this->token_time_validate($data['token']);
|
||||
$language_data = $this->pd_language($user_token_state['language'],$isSupportedLanguage,$language);
|
||||
if($user_token_state['state'] === false){
|
||||
return [['code'=>-1,'description'=>'已过期'],['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->process_Language()]];
|
||||
}else{
|
||||
return [['code'=>0,'description'=>'未过期'],['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->process_Language()]];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 添加IP信息获取方法
|
||||
protected function getIpInfo($ip) {
|
||||
// 默认IP
|
||||
$ip = $ip ?: request()->ip();
|
||||
try {
|
||||
$ip2region = new \Ip2Region();
|
||||
$info = $ip2region->memorySearch($ip);
|
||||
// 返回国家信息
|
||||
return $info['region'] ?: '未知';
|
||||
} catch (\Exception $e) {
|
||||
return '未知';
|
||||
}
|
||||
}
|
||||
public function pd_language($user_language,$isSupportedLanguage,$language){
|
||||
if(!$user_language){
|
||||
if($isSupportedLanguage){
|
||||
$result = $language;
|
||||
}else{
|
||||
$result = 'zh-Hans'; // 默认语言为中文
|
||||
}
|
||||
}else{
|
||||
$result = $user_language;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
// 处理返回的语言数组
|
||||
protected function process_Language(){
|
||||
$temporary_arr = [];
|
||||
foreach ($this->language_country as $key => $value) {
|
||||
array_push($temporary_arr,['key'=>$key,'value'=>$value]);
|
||||
}
|
||||
return $temporary_arr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public function get_user_data_information_action($data){
|
||||
// $return_result = [
|
||||
// 'body_data'=>[],
|
||||
// 'kcal_data'=>[],
|
||||
// 'card_data'=>[]
|
||||
// ];
|
||||
// $aud_data = Db::table($this->index_db_name['juese'])->where(['id'=>$data['aud_id']])->find();
|
||||
|
||||
// $body_data = Db::table($this->index_db_name['body_data'])->where(['id'=>$data['aud_id']])->find();
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
<?php
|
||||
|
||||
namespace app\app\controller;
|
||||
|
||||
class Language extends Base
|
||||
{
|
||||
// 支持的语言列表
|
||||
protected $supportedLanguages = [
|
||||
'en' => 'English',
|
||||
'zh-Hans' => 'Chinese',
|
||||
'es' => 'Spanish',
|
||||
'fr' => 'French',
|
||||
'pt' => 'Portuguese',
|
||||
'ar' => 'Arabic',
|
||||
'ru' => 'Russian',
|
||||
'de' => 'German'
|
||||
];
|
||||
|
||||
// 语言映射表
|
||||
protected $languageMap = [
|
||||
'en' => [
|
||||
'操作成功' => 'Success',
|
||||
'体重' => 'Weight',
|
||||
'身高' => 'Height',
|
||||
'消瘦' => 'Slim',
|
||||
'正常' => 'Normal',
|
||||
'偏重' => 'Overweight',
|
||||
'肥胖' => 'Obesity',
|
||||
'反映和衡量一个人健康状况的重要标志之一' => "One of the important indicators reflecting and measuring a person's health status",
|
||||
'人体纵向部分的长度,源于人体的纵向生长,受遗传因素的影响较大' => "The length of the longitudinal part of the human body is derived from its longitudinal growth and is greatly influenced by genetic factors",
|
||||
'BMI是身体质量指数,是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。' => "BMI is the body mass index, which is currently a commonly used international standard for measuring the degree of body fat, thinness, and health.",
|
||||
'公斤' => "kg",
|
||||
'CM' => "cm",
|
||||
'年' => "-",
|
||||
'月' => "-",
|
||||
'日' => "",
|
||||
'身体得分' => "Physical score",
|
||||
'分' => "score",
|
||||
'身体类型' => "body type",
|
||||
'健美肌肉型' => "Bodybuilding muscle type",
|
||||
'低' => "Low",
|
||||
'偏低' => "Slightly low",
|
||||
'标准' => "Standard",
|
||||
'偏高' => "Slightly high",
|
||||
'高' => "High",
|
||||
'矮' => "Short",
|
||||
'偏矮' => "Slightly short",
|
||||
'脂肪率' => "Body Fat Percentage",
|
||||
'体脂率是指身体成分中,脂肪组织所占的比率。测量体脂率比单纯的只测量体重更能反映我们身体的脂肪水平(肥胖程度)。' => "Body fat percentage refers to the proportion of fat tissue in body composition. Measuring it provides a more accurate reflection of body fat levels (degree of obesity) than weight measurement alone.",
|
||||
'脂肪量' => "Fat Mass",
|
||||
'人体脂肪的重量' => "Body Fat Weight",
|
||||
'肌肉率' => "Muscle Percentage",
|
||||
'优' => "Excellent",
|
||||
'根据人体肌肉总量和人体体重、身高等相结合得到的人体的一个比例值,这个值的范围决定一个人的身体健康状况以及力量的多少。' => "Muscle percentage is a ratio derived from total muscle mass, body weight, height, etc. Its range determines a person's health status and strength level.",
|
||||
'肌肉量' => "Muscle Mass",
|
||||
'不足' => "Insufficient",
|
||||
'肌肉量=实际体重*肌肉率' => "Muscle Mass = Actual Weight × Muscle Percentage",
|
||||
'水分' => "Body Water",
|
||||
'指人体内水分比例。' => "Refers to the proportion of water in the human body.",
|
||||
'蛋白量' => "Protein Mass",
|
||||
'蛋白量=实际体重*蛋白率' => "Protein Mass = Actual Weight × Protein Percentage",
|
||||
'骨重' => "Bone Mass",
|
||||
'单位体积内,骨组织、骨矿物质(钙、磷等)和骨基质(骨胶原、蛋白率、无机盐等等)含量,骨量代表它们骨骼健康的情况。' => "Bone mass refers to the content of bone tissue, minerals (calcium, phosphorus, etc.), and bone matrix (collagen, proteins, inorganic salts, etc.) per unit volume, reflecting skeletal health.",
|
||||
'蛋白率' => "Protein Percentage",
|
||||
'人体内蛋白率含量。' => "The proportion of protein in the human body.",
|
||||
'基础代谢' => "Basal Metabolic Rate (BMR)",
|
||||
'指人体在清醒而又极端安静的状态下,不受肌肉活动、环境温度、食物及精神紧张等影响时的能量代谢率' => "The energy expenditure rate when the body is awake, completely at rest, and unaffected by muscle activity, ambient temperature, food intake, or mental stress.",
|
||||
'内脏指数' => "Visceral Fat Index",
|
||||
'警惕' => "Caution",
|
||||
'危险' => "Danger",
|
||||
'内脏脂肪指数' => "Visceral Fat Level",
|
||||
'皮下脂肪' => "Subcutaneous Fat",
|
||||
'皮下脂脂肪就是贮存于皮下的脂肪组织,人体的脂肪大约有2/3贮存在皮下组织' => "Subcutaneous fat refers to adipose tissue stored under the skin. About two-thirds of body fat is stored subcutaneously.",
|
||||
'肥胖等级' => "Obesity Level",
|
||||
'体重不足' => "Underweight",
|
||||
'肥胖的程度,表现实际体重与理想体重的差距。肥胖等级是判定肥胖症的一个指标。' => "Obesity level indicates the disparity between actual and ideal weight, serving as a diagnostic criterion for obesity.",
|
||||
'孩子可能存在营养不良:对于处在生长发育期的孩子而言,蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、钙、铁、维生素D、赖氨酸等营养。建议补充含鸡内金山楂膏健脾开胃类药食同源食物。' => "The child may be malnourished: For growing children, protein, carbohydrates, vitamins, and minerals are critical. Ensure adequate intake of protein, zinc, calcium, iron, vitamin D, lysine, etc. Consider herbal foods like chicken gizzard-hawthorn paste to improve digestion and appetite.",
|
||||
'孩子可能存在营养不良:对于处在生长发育期的孩子而言,最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养。' => "The child may be malnourished: For children in their growth and development stage, the most beneficial nutrients for height growth are proteins, carbohydrates, vitamins, and minerals. It is recommended to ensure adequate intake of nutrients such as protein, zinc, iron, calcium, vitamin D, and lysine.",
|
||||
'坚持适当、科学的跳跃运动能够科学地增加学生体重,能够改善学 生体重过低的情况;同时运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子增重。' => "Moderate, scientifically designed jumping exercises can help underweight students gain weight by boosting energy expenditure and gastrointestinal motility, thereby increasing appetite. Combined with balanced nutrition, this supports healthy weight gain.",
|
||||
'3-7岁的孩子:骑两轮车、拍踢球、打篮球、游泳、爬山,每天高强度运动不超过30分钟。' => "Ages 3–7: Bicycling, ball games, basketball, swimming, hiking. Limit high-intensity exercise to 30 minutes daily.",
|
||||
'该年龄段睡眠时间建议:9-11小时' => "Recommended sleep duration for this age group: 9–11 hours.",
|
||||
'孩子开始对于赞赏、鼓励、认同和肯定有需求,而且此阶段父亲在孩子的性格塑造、情绪控制以及责任感培养方面扮演着重要的角色,必须告诉孩子什么事应该做、什么事不应该做,并经常性地给孩子一些积极地暗示。例如,可以时常向孩子表达“我会一直在你身边,不要害怕””我对你的进步都看在眼里等类似的话语。' => "Children begin to crave praise, encouragement, and validation. Fathers play a key role in shaping character, emotional regulation, and responsibility during this phase. Clearly define boundaries while offering positive affirmations (e.g., 'I’m always here for you,' 'I see your progress').",
|
||||
'《中华人民共和国卫生行业标准WS 423-2013》' => "《Chinese Health Industry Standard WS 423-2013》",
|
||||
'《中华人民共和国卫生行业标准WS/T 612-2018》' => "《Chinese Health Industry Standard WS/T 612-2018》",
|
||||
'《中华人民共和国卫生行业标准WS/T1586-2018》' => "《Chinese Health Industry Standard WS/T 1586-2018》",
|
||||
'《WHO 5~19岁身高/体重判定标准》' => "《WHO Growth Reference for Children and Adolescents (5–19 Years)》",
|
||||
'头围' => "Head Circumference",
|
||||
'头围是指绕头部一周的最大长度,头围的大小与脑的发育密切相关' => "Head circumference refers to the maximum length around the head. Its measurement is closely related to brain development.",
|
||||
|
||||
],
|
||||
// 可以添加更多语言映射
|
||||
];
|
||||
|
||||
/**
|
||||
* 处理多国语言翻译
|
||||
*
|
||||
* @param string $language 目标语言代码
|
||||
* @param mixed $data 要翻译的数据(字符串或数组)
|
||||
* @return mixed 翻译后的数据
|
||||
*/
|
||||
public function handling_languages_from_multiple_countries($language, $data)
|
||||
{
|
||||
|
||||
// dump($data);
|
||||
// 验证语言是否支持
|
||||
if (!$this->isLanguageSupported($language)) {
|
||||
return $this->msg($data['data']);
|
||||
}
|
||||
|
||||
// 如果是数组,递归处理每个元素
|
||||
if (is_array($data)) {
|
||||
// dump(2);
|
||||
$data = $this->translateArray($language, $data);
|
||||
return $this->msg($data['data']);
|
||||
}
|
||||
|
||||
// 如果是字符串,直接翻译
|
||||
if (is_string($data)) {
|
||||
// dump(3);
|
||||
return $this->translateString($language, $data);
|
||||
}
|
||||
|
||||
// dump($data);
|
||||
// 其他类型直接返回
|
||||
return $this->msg($data['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查语言是否支持
|
||||
*
|
||||
* @param string $language 语言代码
|
||||
* @return bool
|
||||
*/
|
||||
protected function isLanguageSupported($language)
|
||||
{
|
||||
return isset($this->supportedLanguages[$language]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译数组
|
||||
*
|
||||
* @param string $language 目标语言
|
||||
* @param array $array 要翻译的数组
|
||||
* @return array 翻译后的数组
|
||||
*/
|
||||
protected function translateArray($language, array $array)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($array as $key => $value) {
|
||||
// 保持键不变,只翻译值
|
||||
$result[$key] = is_array($value)
|
||||
? $this->translateArray($language, $value)
|
||||
: $this->translateString($language, $value);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译字符串
|
||||
*
|
||||
* @param string $language 目标语言
|
||||
* @param string $string 要翻译的字符串
|
||||
* @return string 翻译后的字符串
|
||||
*/
|
||||
protected function translateString($language, $string)
|
||||
{
|
||||
// dump($string);
|
||||
// 检查是否有该语言的映射表
|
||||
if (!isset($this->languageMap[$language])) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
// 检查是否有对应的翻译
|
||||
return $this->languageMap[$language][$string] ?? $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支持的语言列表
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSupportedLanguages()
|
||||
{
|
||||
return $this->supportedLanguages;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加新的语言翻译
|
||||
*
|
||||
* @param string $language 语言代码
|
||||
* @param array $translations 翻译映射数组
|
||||
* @return bool
|
||||
*/
|
||||
public function addTranslations($language, array $translations)
|
||||
{
|
||||
if (!$this->isLanguageSupported($language)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($this->languageMap[$language])) {
|
||||
$this->languageMap[$language] = [];
|
||||
}
|
||||
|
||||
$this->languageMap[$language] = array_merge(
|
||||
$this->languageMap[$language],
|
||||
$translations
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ class Role extends Base{
|
|||
try {
|
||||
// 你的业务逻辑
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('nickname', $data) || !array_key_exists('birthday', $data) || !array_key_exists('gender', $data) || !array_key_exists('height', $data) || !array_key_exists('weight', $data) || !array_key_exists('measure_model', $data)){
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('id', $data) || !array_key_exists('nickname', $data) || !array_key_exists('birthday', $data) || !array_key_exists('gender', $data) || !array_key_exists('height', $data) || !array_key_exists('weight', $data) || !array_key_exists('measure_model', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if($data['measure_model'] != '1' && $data['measure_model'] != '2'){
|
||||
|
|
@ -121,8 +121,8 @@ class Role extends Base{
|
|||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||
return $this->msg(10005,'id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['birthday'],'datetime')){
|
||||
return $this->msg(10005,'birthday type error');
|
||||
|
|
@ -151,7 +151,7 @@ class Role extends Base{
|
|||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 添加角色
|
||||
// 获取角色列表
|
||||
public function role_list(){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
|
|
@ -273,7 +273,7 @@ class Role extends Base{
|
|||
$parameter['card_order'] = $address_data['recommend_cards'];
|
||||
}
|
||||
|
||||
$return_result = Db::table($this->role_db_name['juese'])->where(['id'=>$data['aud_id']])->update($parameter);
|
||||
$return_result = Db::table($this->role_db_name['juese'])->where(['id'=>$data['id']])->update($parameter);
|
||||
if($return_result){
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,582 @@
|
|||
<?php
|
||||
|
||||
namespace app\NewReedaw\controller\app;
|
||||
|
||||
use think\Db;
|
||||
use think\Cache;
|
||||
|
||||
class Skip extends Base{
|
||||
|
||||
protected $skip_db_name = [
|
||||
'zhanghao'=>'app_account_number',
|
||||
'juese'=>'app_user_data',
|
||||
'body'=>'app_card_body_data',
|
||||
'skip'=>'app_card_skip_data',
|
||||
|
||||
];
|
||||
protected $curve_data_format = ['jump_num'=>['跳绳个数','个','#009DFF'],'jump_time'=>['跳绳时长','分钟','#009DFF'],'jump_kcal'=>['消耗卡路里','kcal','#009DFF']];
|
||||
// protected $skip_use_db_name = [
|
||||
// '1'=>'app_card_skip_data',
|
||||
// '2'=>'app_user_data',
|
||||
// '3'=>'app_card_body_data',
|
||||
// ];
|
||||
protected $pagesize = 15;
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
// 测试token=>'caadd1be045a65f30b92aa805f1de54a'
|
||||
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
|
||||
// 手动记录
|
||||
public function manual_record(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('r_time', $data) || !array_key_exists('num', $data) || !array_key_exists('time_m', $data) || !array_key_exists('time_s', $data) || !array_key_exists('type', $data) || !array_key_exists('token', $data)){
|
||||
$return_data = $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['r_time'],'datetime')){
|
||||
return $this->msg(10005,'r_time type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['type'],'str')){
|
||||
return $this->msg(10005,'type type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['num'],'intnum') || !$this->verify_data_is_ok($data['time_m'],'intnum') || !$this->verify_data_is_ok($data['time_s'],'intnum')){
|
||||
return $this->msg(10005,'跳绳数量或者分钟、秒钟值必须为整数');
|
||||
}
|
||||
if($data['num'] <= 0){
|
||||
return $this->msg(10005,'跳绳数不能小于等于0');
|
||||
}
|
||||
if(abs($data['time_s']) >= 60){
|
||||
return $this->msg(10005,'秒钟值不能大于60');
|
||||
}
|
||||
unset($data['token']);
|
||||
if($this->validate_user_identity($data['aud_id']) === false){
|
||||
return $this->msg(10003);
|
||||
}
|
||||
return $this->manual_record_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
|
||||
}
|
||||
// 设备记录
|
||||
public function device_record(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('kcal', $data) || !array_key_exists('num', $data) || !array_key_exists('time_m', $data) || !array_key_exists('time_s', $data) || !array_key_exists('type', $data) || !array_key_exists('token', $data)){
|
||||
$return_data = $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['kcal'],'num')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['type'],'str')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
if(!$this->isValidInteger($data['num']+0) || !$this->isValidInteger($data['time_m']+0) || !$this->isValidInteger($data['time_s']+0)){
|
||||
$return_data = $this->msg(10005,'跳绳数量或者分钟、秒钟值必须为整数');
|
||||
}
|
||||
if($data['num'] <= 0){
|
||||
$return_data = $this->msg(10005,'跳绳数不能小于等于0');
|
||||
}
|
||||
if(abs($data['time_s']) >= 60){
|
||||
$return_data = $this->msg(10005,'秒钟值不能大于60');
|
||||
}
|
||||
unset($data['token']);
|
||||
if($this->validate_user_identity($data['aud_id']) === false){
|
||||
$return_data = $this->msg(10003);
|
||||
}
|
||||
$return_data = $this->manual_record_action($data);
|
||||
|
||||
// 成功
|
||||
$this->record_api_log($data, null, $return_data);
|
||||
return $return_data;
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 数据报告
|
||||
public function data_report(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
unset($data['token']);
|
||||
return $this->data_report_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 曲线
|
||||
public function curve_chart(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('time', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
unset($data['token']);
|
||||
return $this->curve_chart_action($data);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 获取历史列表(分页)
|
||||
public function record_list_page(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('page', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['page'],'intnum')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
return $this->record_list_page_or_group_action($data,'page');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 获取历史列表(分组)
|
||||
public function record_list_group(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['s_time'],'datetime')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['e_time'],'datetime')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
return $this->record_list_page_or_group_action($data,'group');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 历史记录(详细)
|
||||
public function detailed_record(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('id', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||
return $this->msg(10005,'id type error');
|
||||
}
|
||||
return $this->get_all_detaile_data_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 删除历史数据
|
||||
public function del_record(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('id', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
unset($data['token']);
|
||||
$user_data = Db::table($this->skip_db_name['skip'])->where(['id'=>$data['id']])->update(['is_del'=>1]);
|
||||
if($user_data){
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
|
||||
################################################################action################################################################
|
||||
################################################################action################################################################
|
||||
public function manual_record_action($data){
|
||||
// 分秒转换为秒
|
||||
$data['time'] = abs($data['time_m'])*60+abs($data['time_s']);
|
||||
$user_msg_content = Db::table($this->skip_db_name['juese'])->where(['id'=>$data['aud_id']])->count();
|
||||
if($user_msg_content<=0){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
if(!array_key_exists('kcal', $data)){
|
||||
$last_data_body = Db::table($this->skip_db_name['body'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->order('record_time desc,id desc')->field('id,weight_val,record_time')->find();
|
||||
if(!$last_data_body){
|
||||
$last_data_body = Db::table($this->skip_db_name['juese'])->where(['id'=>$data['aud_id']])->field('id,weight as weight_val')->find();
|
||||
if(!$last_data_body){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
}
|
||||
$kcal_data = $this->skip_kcal_calculate($data['num'],$data['time'],$last_data_body['weight_val']);
|
||||
}else{
|
||||
// 将时间从秒转换为分钟
|
||||
$minutes = bcdiv($data['time'],60,20);
|
||||
// 计算每分钟的跳绳次数
|
||||
$jumpsPerMinute = bcdiv($data['num'],$minutes,2);
|
||||
$kcal_data['totalCalories'] = $data['kcal'];
|
||||
$kcal_data['averageAchievement'] = $jumpsPerMinute;
|
||||
$kcal_data['caloriesPerMinute'] = bcdiv($kcal_data['totalCalories'],$minutes,2);
|
||||
}
|
||||
|
||||
|
||||
$data_set = [
|
||||
'create_time'=>date('Y-m-d H:i:s'),
|
||||
'last_update_time'=>date('Y-m-d H:i:s'),
|
||||
'jump_num'=>$data['num'],
|
||||
|
||||
'jump_time'=>$data['time'],
|
||||
'jump_kcal'=>$kcal_data['totalCalories'],
|
||||
'average_num'=>$kcal_data['averageAchievement'],
|
||||
'average_kcal'=>$kcal_data['caloriesPerMinute'],
|
||||
'aud_id'=>$data['aud_id'],
|
||||
'record_time'=>array_key_exists('r_time', $data)?$data['r_time']:date('Y-m-d H:i:s'),
|
||||
'jump_type'=>$data['type']
|
||||
];
|
||||
if(strlen($data_set['record_time']) <= 12){
|
||||
$data_set['record_time'] = $this->addCurrentTimeToDateString($data_set['record_time']);
|
||||
}
|
||||
$last_data_body = Db::table($this->skip_db_name['skip'])->insert($data_set);
|
||||
$result = [
|
||||
'today_jump_num'=>0,
|
||||
'today_jump_time'=>0,
|
||||
'today_jump_kcal'=>0,
|
||||
];
|
||||
$all_data = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id']])->whereTime('record_time','today')->field('jump_num,jump_time,jump_kcal')->select();
|
||||
foreach ($all_data as $key => $value) {
|
||||
$result['today_jump_num'] = $result['today_jump_num']+$value['jump_num'];
|
||||
$result['today_jump_time'] = $result['today_jump_time']+$value['jump_time'];
|
||||
$result['today_jump_kcal'] = bcadd($result['today_jump_kcal'],$value['jump_kcal'],2);
|
||||
}
|
||||
$result['last_jump_num'] = $data['num'];
|
||||
$result['last_jump_time'] = $data['time'];
|
||||
$result['last_jump_kcal'] = $data_set['jump_kcal'];
|
||||
// $result['last_record_time'] = str_replace('-', '/', $data_set['record_time']);
|
||||
$result['last_record_time'] = $data_set['record_time'];
|
||||
$time_conversion = $this->handle_hour_branch_second($result['today_jump_time']);
|
||||
$result['today_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'];
|
||||
$time_conversion = $this->handle_hour_branch_second($result['last_jump_time']);
|
||||
$result['last_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'];
|
||||
return $this->msg($result);
|
||||
}
|
||||
public function data_report_action($data){
|
||||
$all_data = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id']])->whereTime('record_time','today')->field('jump_num,jump_time,jump_kcal')->select();
|
||||
$last_data = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id']])->order('record_time desc,id desc')->field('id,jump_num,jump_time,jump_kcal,record_time')->find();
|
||||
$result = [
|
||||
'today_jump_num'=>0,
|
||||
'today_jump_time'=>0,
|
||||
'today_jump_kcal'=>0,
|
||||
];
|
||||
foreach ($all_data as $key => $value) {
|
||||
$result['today_jump_num'] = $result['today_jump_num']+$value['jump_num'];
|
||||
$result['today_jump_time'] = $result['today_jump_time']+$value['jump_time'];
|
||||
$result['today_jump_kcal'] = bcadd($result['today_jump_kcal'],$value['jump_kcal'],2);
|
||||
}
|
||||
if($last_data){
|
||||
$result['last_jump_num'] = $last_data['jump_num'];
|
||||
$result['last_jump_time'] = $last_data['jump_time'];
|
||||
$result['last_jump_kcal'] = $last_data['jump_kcal'];
|
||||
$result['last_record_time'] = $last_data['record_time'];
|
||||
}else{
|
||||
$result['last_jump_num'] = 0;
|
||||
$result['last_jump_time'] = 0;
|
||||
$result['last_jump_kcal'] = 0;
|
||||
$result['last_record_time'] = '';
|
||||
}
|
||||
$time_conversion = $this->handle_hour_branch_second($result['today_jump_time']);
|
||||
$result['today_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'];
|
||||
$time_conversion = $this->handle_hour_branch_second($result['last_jump_time']);
|
||||
$result['last_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'];
|
||||
return $this->msg($result);
|
||||
}
|
||||
public function curve_chart_action($data){
|
||||
$audid = $data['aud_id'];
|
||||
$timeData = explode('-', $data['time']);
|
||||
// 根据$timeData的长度构建不同的查询条件
|
||||
$map = ['aud_id' => $audid,'is_del'=>0];
|
||||
switch (count($timeData)) {
|
||||
case 3: // 年月日
|
||||
$map['record_time'] = ['between', [date('Y-m-d 00:00:00', strtotime($timeData[0] . '-' . $timeData[1] . '-' . $timeData[2])), date('Y-m-d 23:59:59', strtotime($timeData[0] . '-' . $timeData[1] . '-' . $timeData[2]))]];
|
||||
break;
|
||||
case 2: // 年月
|
||||
$map['record_time'] = ['between', [date('Y-m-01 00:00:00', strtotime($timeData[0] . '-' . $timeData[1])), date('Y-m-t 23:59:59', strtotime($timeData[0] . '-' . $timeData[1]))]];
|
||||
break;
|
||||
case 1: // 年
|
||||
$map['record_time'] = ['between', [date('Y-01-01 00:00:00', strtotime($timeData[0])), date('Y-12-31 23:59:59', strtotime($timeData[0]))]];
|
||||
break;
|
||||
default:
|
||||
return $this->msg(10005); // 无效的时间数据格式
|
||||
}
|
||||
|
||||
// 使用查询构造器进行查询
|
||||
$result = Db::name($this->skip_db_name['skip'])->where($map)->field('jump_num,jump_time,jump_kcal,aud_id,record_time,jump_type,DATEPART(hour, record_time) AS hour,DATEPART(minute, record_time) AS minute,DATEPART(day, record_time) AS day,DATEPART(month, record_time) AS month')->order('record_time')->select();
|
||||
$return_data = [];
|
||||
if(count($timeData) == 3){
|
||||
$key_condition = 'hour';
|
||||
}else if(count($timeData) == 2){
|
||||
$key_condition = 'day';
|
||||
}else if(count($timeData) == 1){
|
||||
$key_condition = 'month';
|
||||
}
|
||||
foreach ($this->curve_data_format as $key => $value) {
|
||||
$temporary_arr['title'] = $value[0].'('.$value[1].')';
|
||||
$temporary_arr['key'] = $key;
|
||||
$temporary_arr['line']['categories'] = [];
|
||||
$temporary_arr['line']['series'][0]['color'] = $value[2];
|
||||
$temporary_arr['line']['series'][0]['name'] = $value[0].'('.$value[1].')';
|
||||
$temporary_arr['line']['series'][0]['data'] = [];
|
||||
foreach ($result as $k => $v) {
|
||||
if($key_condition == 'hour'){
|
||||
// 每一次的记录都添加进去
|
||||
array_push($temporary_arr['line']['categories'],$result[$k]['hour'].':'.$result[$k]['minute']);
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}else if($key_condition == 'day'){
|
||||
// 根据天分组
|
||||
if(in_array($result[$k]['month'].'/'.$result[$k][$key_condition],$temporary_arr['line']['categories'])){
|
||||
$num = array_search($result[$k]['month'].'/'.$result[$k][$key_condition], $temporary_arr['line']['categories']);
|
||||
$temporary_arr['line']['series'][0]['data'][$num] = bcadd($temporary_arr['line']['series'][0]['data'][$num],$result[$k][$key],2);
|
||||
}else{
|
||||
array_push($temporary_arr['line']['categories'],$result[$k]['month'].'/'.$result[$k][$key_condition]);
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}
|
||||
|
||||
}else{
|
||||
// 根据年分组
|
||||
if(in_array($result[$k]['month'].'月',$temporary_arr['line']['categories'])){
|
||||
$num = array_search($result[$k]['month'].'月', $temporary_arr['line']['categories']);
|
||||
$temporary_arr['line']['series'][0]['data'][$num] = bcadd($temporary_arr['line']['series'][0]['data'][$num],$result[$k][$key],2);
|
||||
}else{
|
||||
array_push($temporary_arr['line']['categories'],$result[$k]['month'].'月');
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
array_push($return_data,$temporary_arr);
|
||||
}
|
||||
foreach ($return_data[1]['line']['series'][0]['data'] as $key => $value) {
|
||||
$return_data[1]['line']['series'][0]['data'][$key] = bcdiv($return_data[1]['line']['series'][0]['data'][$key],60,2);
|
||||
}
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
public function record_list_page_or_group_action($data,$type){
|
||||
$return_result = [];
|
||||
|
||||
if($type == 'group'){
|
||||
$data['s_time'] = $data['s_time'].' 00:00:00';
|
||||
$data['e_time'] = $data['e_time'].' 23:59:59';
|
||||
$result = Db::query("
|
||||
select
|
||||
id,
|
||||
CONVERT(varchar(10), record_time, 120) AS r_t,
|
||||
CONVERT(varchar(19), record_time, 120) AS record_time,
|
||||
jump_num as v1,
|
||||
jump_time as v2,
|
||||
jump_kcal as v3
|
||||
from ".$this->skip_db_name['skip']."
|
||||
where aud_id='".$data['aud_id']."'
|
||||
and record_time between '".$data['s_time']."' and '".$data['e_time']."'
|
||||
and is_del = 0
|
||||
order by record_time desc");
|
||||
foreach ($result as $key => $value) {
|
||||
$time_t = $this->handle_hour_branch_second($value['v2']);
|
||||
array_push($return_result, [
|
||||
'id'=>$value['id'],
|
||||
'v1'=>$value['v1'],
|
||||
'v2'=>$time_t['h'].':'.$time_t['m'].':'.$time_t['s'],
|
||||
'v3'=>$value['v3'],
|
||||
'v1_name'=>'个数',
|
||||
'v2_name'=>'时长',
|
||||
'v3_name'=>'卡路里',
|
||||
// 'r_t'=>str_replace('-', '/', $value['r_t'])
|
||||
'r_t'=>$value['r_t']
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
$result = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->field("id,record_time,REPLACE(record_time, '-', '-') AS b_time,jump_num,jump_time,jump_kcal")->order('record_time desc')->page($data['page'],$this->pagesize)->select();
|
||||
$return_result['totalrows'] = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id']])->count();
|
||||
$return_result['rows'] = [];
|
||||
$return_result['pageno'] = $data['page'];
|
||||
$return_result['pagesize'] = $this->pagesize;
|
||||
$return_result['totalpage'] = ceil($return_result['totalrows']/$this->pagesize);
|
||||
foreach ($result as $key => $value) {
|
||||
$time_t = $this->handle_hour_branch_second($value['jump_time']);
|
||||
array_push($return_result['rows'],[
|
||||
'id'=>$value['id'],
|
||||
'v1'=>$value['jump_num'],
|
||||
'v2'=>$time_t['h'].':'.$time_t['m'].':'.$time_t['s'],
|
||||
'v3'=>$value['jump_kcal'],
|
||||
'v1_name'=>'个数',
|
||||
'v2_name'=>'时长',
|
||||
'v3_name'=>'卡路里',
|
||||
'record_time'=>$value['b_time'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
return $this->msg($return_result);
|
||||
}
|
||||
public function get_all_detaile_data_action($data){
|
||||
|
||||
$result = $result = Db::table($this->skip_db_name['skip'])->where(['id'=>$data['id'],'is_del'=>0])->find();
|
||||
$for_data_arr = ['jump_num'=>['个数',''],'jump_time'=>['时长',''],'jump_kcal'=>['卡路里','kcal']];
|
||||
if($result){
|
||||
$result_data = [];
|
||||
foreach ($for_data_arr as $key => $value) {
|
||||
$temporary_arr['key_name'] = $key;
|
||||
$temporary_arr['name'] = $value[0];
|
||||
$temporary_arr['value'] = explode(',',$result[$key])[0];
|
||||
$temporary_arr['unit'] = $value[1];
|
||||
array_push($result_data,$temporary_arr);
|
||||
}
|
||||
return $this->msg($result_data);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
################################################################内部调用################################################################
|
||||
################################################################内部调用################################################################
|
||||
// 跳绳卡路里计算
|
||||
public function skip_kcal_calculate($num=143, $time=222, $weight=70) {
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
// 将时间从秒转换为分钟
|
||||
$minutes = bcdiv($time,60,20);
|
||||
// 计算每分钟的跳绳次数
|
||||
$jumpsPerMinute = bcdiv($num,$minutes,2);
|
||||
// 根据跳绳次数确定MET值
|
||||
// $met = 11.8;
|
||||
if ($jumpsPerMinute < 100) {
|
||||
$met = 8.8;
|
||||
} else if ($jumpsPerMinute >= 100 && $jumpsPerMinute < 120) {
|
||||
$met = 11.8;
|
||||
} else {
|
||||
$met = 12.3;
|
||||
}
|
||||
// 计算每分钟燃烧的卡路里
|
||||
$caloriesPerMinute = bcdiv(bcmul(bcmul($met,$weight,20),3.5,20),200,2);
|
||||
// 计算总卡路里消耗
|
||||
$totalCalories = bcmul($caloriesPerMinute,$minutes,2);
|
||||
// 返回结果
|
||||
return [
|
||||
'averageAchievement' => $jumpsPerMinute,
|
||||
'caloriesPerMinute' => $caloriesPerMinute,
|
||||
'totalCalories' => $totalCalories
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,639 @@
|
|||
<?php
|
||||
|
||||
namespace app\NewReedaw\controller\app;
|
||||
|
||||
use think\Db;
|
||||
use think\Cache;
|
||||
|
||||
class Vitalcapacity extends Base{
|
||||
|
||||
protected $vitalcapacity_db_name = [
|
||||
'zhanghao'=>'app_account_number',
|
||||
'juese'=>'app_user_data',
|
||||
'vitalcapacity'=>'app_card_vitalcapacity_data',
|
||||
'biaozhun'=>'pc_vitalcapacity_standard',
|
||||
|
||||
];
|
||||
protected $color = ['无效'=>'#FF5656','不及格'=>'#FF5656','及格'=>'#FFAB00','良好'=>'#5AD06D','优秀'=>'#6492F6','牛逼'=>'#3967D6'];
|
||||
protected $curve_data_format = ['one_val'=>['第一次','容积/ml','#009DFF'],'two_val'=>['第二次','容积/ml','#009DFF'],'three_val'=>['第三次','容积/ml','#009DFF'],'average_val'=>['平均','容积/ml','#009DFF']];
|
||||
protected $pagesize = 15;
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
// 测试token=>'caadd1be045a65f30b92aa805f1de54a'
|
||||
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
|
||||
// 手动记录
|
||||
public function manual_record(){
|
||||
try {
|
||||
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('one', $data) || !array_key_exists('two', $data) || !array_key_exists('three', $data) || !array_key_exists('time', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
unset($data['token']);
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['one'],'intnum')){
|
||||
return $this->msg(10005,'one type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['two'],'intnum')){
|
||||
return $this->msg(10005,'two type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['three'],'intnum')){
|
||||
return $this->msg(10005,'three type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['time'],'datetime')){
|
||||
return $this->msg(10005,'time type error');
|
||||
}
|
||||
if(strlen($data['time']) <= 12){
|
||||
// 时间日期转换,把'Y-m-d'转换成'Y-m-d H:i:s'格式
|
||||
$data['time'] = $this->addCurrentTimeToDateString($data['time']);
|
||||
}
|
||||
return $this->manual_record_action($data,'by_hand_means');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 设备记录
|
||||
public function device_record(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('one', $data) || !array_key_exists('two', $data) || !array_key_exists('three', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
unset($data['token']);
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['one'],'intnum')){
|
||||
return $this->msg(10005,'one type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['two'],'intnum')){
|
||||
return $this->msg(10005,'two type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['three'],'intnum')){
|
||||
return $this->msg(10005,'three type error');
|
||||
}
|
||||
$data['time'] = date('Y-m-d H:i:s');
|
||||
return $this->manual_record_action($data,'by_device');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 数据报告
|
||||
public function data_report(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data)){
|
||||
$return_data = $this->msg(10001);
|
||||
}
|
||||
unset($data['token']);
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
return $this->data_report_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 曲线
|
||||
public function curve_chart(){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('time', $data) || !array_key_exists('token', $data)){
|
||||
$return_data = $this->msg(10001);
|
||||
}
|
||||
unset($data['token']);
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['time'],'datetime')){
|
||||
return $this->msg(10005,'time type error');
|
||||
}
|
||||
return $this->curve_chart_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 获取历史列表(分页)
|
||||
public function record_list_page(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('page', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['page'],'intnum')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
return $this->record_list_page_or_group_action($data,'page');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 获取历史列表(分组)
|
||||
public function record_list_group(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['s_time'],'datetime')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['e_time'],'datetime')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
return $this->record_list_page_or_group_action($data,'group');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 历史记录(详细)
|
||||
public function detailed_record(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('id', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||
return $this->msg(10005,'id type error');
|
||||
}
|
||||
return $this->get_all_detaile_data_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 删除历史数据
|
||||
public function del_record(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('id', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
unset($data['token']);
|
||||
$user_data = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->where(['id'=>$data['id']])->update(['is_del'=>1]);
|
||||
if($user_data){
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
|
||||
################################################################action################################################################
|
||||
################################################################action################################################################
|
||||
public function manual_record_action($data,$type){
|
||||
$temporary_arr['aud_id'] = $data['aud_id'];
|
||||
$temporary_arr['record_time'] = $data['time'];
|
||||
$temporary_arr['one'] = $data['one'];
|
||||
$temporary_arr['two'] = $data['two'];
|
||||
$temporary_arr['three'] = $data['three'];
|
||||
$temporary_arr['average'] = bcdiv(bcadd(bcadd($data['one'],$data['two'],2),$data['three'],2),3,2);
|
||||
$temporary_arr['create_time'] = date('Y-m-d H:i:s');
|
||||
$temporary_arr['one_val'] = $data['one'];
|
||||
$temporary_arr['two_val'] = $data['two'];
|
||||
$temporary_arr['three_val'] = $data['three'];
|
||||
$temporary_arr['average_val'] = $temporary_arr['average'];
|
||||
$temporary_arr['flow_val'] = array_key_exists('flow', $data)?$data['flow']:'0.00';//流速
|
||||
$temporary_arr['record_type'] = $type;//流速
|
||||
// die;
|
||||
// 处理记录时间
|
||||
|
||||
$user_msg = Db::name($this->vitalcapacity_db_name['juese'])->where(['id'=>$data['aud_id']])->field('id,grade,gender,birthday')->find();
|
||||
// die;
|
||||
if($user_msg){
|
||||
// 根据性别&年级&年龄查规则
|
||||
if($user_msg['grade'] == 'nothing'){
|
||||
// 计算年龄判断是属于哪个年级
|
||||
$user_age = $this->calculate_age($user_msg['birthday']);
|
||||
if($user_age <= 7){
|
||||
$user_msg['grade'] = 'grade_s_1';
|
||||
}else if($user_age == 8){
|
||||
$user_msg['grade'] = 'grade_s_2';
|
||||
}else if($user_age == 9){
|
||||
$user_msg['grade'] = 'grade_s_3';
|
||||
}else if($user_age == 10){
|
||||
$user_msg['grade'] = 'grade_s_4';
|
||||
}else if($user_age == 11){
|
||||
$user_msg['grade'] = 'grade_s_5';
|
||||
}else if($user_age == 12){
|
||||
$user_msg['grade'] = 'grade_s_6';
|
||||
}else if($user_age == 13){
|
||||
$user_msg['grade'] = 'grade_m_1';
|
||||
}else if($user_age == 14){
|
||||
$user_msg['grade'] = 'grade_m_2';
|
||||
}else if($user_age == 15){
|
||||
$user_msg['grade'] = 'grade_m_3';
|
||||
}else if($user_age == 16){
|
||||
$user_msg['grade'] = 'grade_h_1';
|
||||
}else if($user_age == 17){
|
||||
$user_msg['grade'] = 'grade_h_2';
|
||||
}else if($user_age == 18){
|
||||
$user_msg['grade'] = 'grade_h_3';
|
||||
}else if($user_age == 19 || $user_age == 20){
|
||||
$user_msg['grade'] = 'grade_u_12';
|
||||
}else if($user_age >= 21){
|
||||
$user_msg['grade'] = 'grade_u_34';
|
||||
}
|
||||
}
|
||||
$sql_str = "sex = ".$user_msg['gender']." and ".$user_msg['grade']." <= ".$temporary_arr['average_val'];
|
||||
$user_achievement = Db::name($this->vitalcapacity_db_name['biaozhun'])->where($sql_str)->order($user_msg['grade'] .' desc')->field('level,score,'.$user_msg['grade'])->limit(1)->cache(86400)->select();
|
||||
if(count($user_achievement)<=0){
|
||||
$user_achievement[0] = ['level'=>'无效','score'=>'0'];
|
||||
}
|
||||
$temporary_arr['score'] = $user_achievement[0]['score'].','.$user_achievement[0]['level'].','.$this->color[$user_achievement[0]['level']];
|
||||
$temporary_arr['score_val'] = $user_achievement[0]['score'];
|
||||
|
||||
}else{
|
||||
return $this->msg(10004,'未找到有效数据');
|
||||
}
|
||||
$standard_data = $this->get_vitalcapacity_data($data['aud_id']);
|
||||
$temporary_arr['standard_data'] = json_encode($standard_data);
|
||||
$result = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->insert($temporary_arr);
|
||||
|
||||
if($result){
|
||||
$time = $result[0]['record_time'];
|
||||
$time = strtotime($time);
|
||||
$time = date('Y年m月d日 H:i:s', $time);
|
||||
return $this->msg([
|
||||
'average'=>$temporary_arr['average'].'ml',
|
||||
'level'=>$user_achievement[0]['level'],
|
||||
'time'=>$time,
|
||||
'flow_val'=>$temporary_arr['flow_val'],
|
||||
'list'=>$standard_data,
|
||||
'offset'=>$this->vitalcapacity_standard_interval($temporary_arr['average'],$standard_data)
|
||||
]);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
}
|
||||
}
|
||||
public function data_report_action($data){
|
||||
$result = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->where(['aud_id'=>$data['aud_id']])->order('record_time desc')->field('record_time,score,average,flow_val,standard_data')->limit(1)->select();
|
||||
|
||||
if(count($result) <= 0){
|
||||
// return $this->msg(10004);
|
||||
return $this->msg([
|
||||
'average'=>'',
|
||||
'level'=>'',
|
||||
'time'=>'',
|
||||
'flow_val'=>'',
|
||||
'list'=>'',
|
||||
'offset'=>''
|
||||
]);
|
||||
|
||||
}else{
|
||||
|
||||
$time = $result[0]['record_time'];
|
||||
$time = strtotime($time);
|
||||
$time = date('Y年m月d日 H:i:s', $time);
|
||||
$o_l = explode(',',$result[0]['score']);
|
||||
// $standard_data = $this->get_vitalcapacity_data($data['aud_id']);
|
||||
$standard_data = json_decode($result[0]['standard_data'],true);
|
||||
|
||||
return $this->msg([
|
||||
'average'=>$result[0]['average'].'ml',
|
||||
'level'=>$o_l[1],
|
||||
'time'=>$time,
|
||||
'flow_val'=>$result[0]['flow_val'] == '.00'?'0.00':$result[0]['flow_val'],
|
||||
'list'=>$standard_data,
|
||||
'offset'=>$this->vitalcapacity_standard_interval($result[0]['average'],$standard_data)
|
||||
]);
|
||||
}
|
||||
}
|
||||
public function curve_chart_action($data){
|
||||
$audid = $data['aud_id'];
|
||||
$timeData = explode('-', $data['time']);
|
||||
|
||||
// 根据$timeData的长度构建不同的查询条件
|
||||
$map = ['aud_id' => $audid];
|
||||
switch (count($timeData)) {
|
||||
case 3: // 年月日
|
||||
$map['record_time'] = ['between', [date('Y-m-d 00:00:00', strtotime($timeData[0] . '-' . $timeData[1] . '-' . $timeData[2])), date('Y-m-d 23:59:59', strtotime($timeData[0] . '-' . $timeData[1] . '-' . $timeData[2]))]];
|
||||
break;
|
||||
case 2: // 年月
|
||||
$map['record_time'] = ['between', [date('Y-m-01 00:00:00', strtotime($timeData[0] . '-' . $timeData[1])), date('Y-m-t 23:59:59', strtotime($timeData[0] . '-' . $timeData[1]))]];
|
||||
break;
|
||||
case 1: // 年
|
||||
$map['record_time'] = ['between', [date('Y-01-01 00:00:00', strtotime($timeData[0])), date('Y-12-31 23:59:59', strtotime($timeData[0]))]];
|
||||
break;
|
||||
default:
|
||||
return $this->msg(10005); // 无效的时间数据格式
|
||||
}
|
||||
// 使用查询构造器进行查询
|
||||
$result = Db::name($this->vitalcapacity_db_name['vitalcapacity'])->where($map)->field('id,one_val,two_val,three_val,average_val,score_val,aud_id,record_time,DATEPART(hour, record_time) AS hour,DATEPART(day, record_time) AS day,DATEPART(month, record_time) AS month')->order('record_time')->select();
|
||||
$return_data = [];
|
||||
if(count($timeData) == 3){
|
||||
$key_condition = 'hour';
|
||||
}else if(count($timeData) == 2){
|
||||
$key_condition = 'day';
|
||||
}else if(count($timeData) == 1){
|
||||
$key_condition = 'month';
|
||||
}
|
||||
foreach ($this->curve_data_format as $key => $value) {
|
||||
$temporary_arr['title'] = $value[0].'('.$value[1].')';
|
||||
$temporary_arr['key'] = $key;
|
||||
$temporary_arr['line']['categories'] = [];
|
||||
$temporary_arr['line']['series'][0]['color'] = $value[2];
|
||||
$temporary_arr['line']['series'][0]['name'] = $value[0].'('.$value[1].')';
|
||||
$temporary_arr['line']['series'][0]['data'] = [];
|
||||
foreach ($result as $k => $v) {
|
||||
if($key_condition == 'hour'){
|
||||
if(in_array($result[$k][$key_condition].'时',$temporary_arr['line']['categories'])){
|
||||
|
||||
$num = array_search($result[$k][$key_condition].'时', $temporary_arr['line']['categories']);
|
||||
// $temporary_arr['line']['series'][0]['data'][$num] = bcadd($temporary_arr['line']['series'][0]['data'][$num],$result[$k][$key],2);
|
||||
$temporary_arr['line']['series'][0]['data'][$num] = $temporary_arr['line']['series'][0]['data'][$num] >= $result[$k][$key]?$temporary_arr['line']['series'][0]['data'][$num]:$result[$k][$key];
|
||||
|
||||
}else{
|
||||
array_push($temporary_arr['line']['categories'],$result[$k][$key_condition].'时');
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}
|
||||
}else if($key_condition == 'day'){
|
||||
if(in_array($result[$k]['month'].'-'.$result[$k][$key_condition],$temporary_arr['line']['categories'])){
|
||||
$num = array_search($result[$k]['month'].'-'.$result[$k][$key_condition], $temporary_arr['line']['categories']);
|
||||
// $temporary_arr['line']['series'][0]['data'][$num] = bcadd($temporary_arr['line']['series'][0]['data'][$num],$result[$k][$key],2);
|
||||
$temporary_arr['line']['series'][0]['data'][$num] = $temporary_arr['line']['series'][0]['data'][$num] >= $result[$k][$key]?$temporary_arr['line']['series'][0]['data'][$num]:$result[$k][$key];
|
||||
}else{
|
||||
array_push($temporary_arr['line']['categories'],$result[$k]['month'].'-'.$result[$k][$key_condition]);
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}
|
||||
}else{
|
||||
if(in_array($result[$k]['month'].'月',$temporary_arr['line']['categories'])){
|
||||
$num = array_search($result[$k]['month'].'月', $temporary_arr['line']['categories']);
|
||||
// $temporary_arr['line']['series'][0]['data'][$num] = bcadd($temporary_arr['line']['series'][0]['data'][$num],$result[$k][$key],2);
|
||||
$temporary_arr['line']['series'][0]['data'][$num] = $temporary_arr['line']['series'][0]['data'][$num] >= $result[$k][$key]?$temporary_arr['line']['series'][0]['data'][$num]:$result[$k][$key];
|
||||
}else{
|
||||
array_push($temporary_arr['line']['categories'],$result[$k]['month'].'月');
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
array_push($return_data,$temporary_arr);
|
||||
}
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
public function record_list_page_or_group_action($data,$type){
|
||||
$return_result = [];
|
||||
|
||||
if($type == 'group'){
|
||||
$data['s_time'] = $data['s_time'].' 00:00:00';
|
||||
$data['e_time'] = $data['e_time'].' 23:59:59';
|
||||
$result = Db::query("
|
||||
select
|
||||
id,
|
||||
CONVERT(varchar(10), record_time, 120) AS r_t,
|
||||
CONVERT(varchar(19), record_time, 120) AS record_time,
|
||||
one_val as v1,
|
||||
two_val as v2,
|
||||
three_val as v3,
|
||||
average_val as v4,
|
||||
score as v5
|
||||
from ".$this->vitalcapacity_db_name['vitalcapacity']."
|
||||
where aud_id='".$data['aud_id']."'
|
||||
and record_time between '".$data['s_time']."' and '".$data['e_time']."'
|
||||
and is_del = 0
|
||||
order by record_time desc");
|
||||
foreach ($result as $key => $value) {
|
||||
// $time_t = $this->handle_hour_branch_second($value['v2']);
|
||||
array_push($return_result, [
|
||||
'id'=>$value['id'],
|
||||
'v1'=>$value['v1'] == '.00'?'0':$value['v1'],
|
||||
'v2'=>$value['v2'] == '.00'?'0':$value['v2'],
|
||||
'v3'=>$value['v3'] == '.00'?'0':$value['v3'],
|
||||
'v4'=>$value['v4'] == '.00'?'0':$value['v4'],
|
||||
'v5'=>explode(',',$value['v5'])[0],
|
||||
'v1_name'=>'第一次',
|
||||
'v2_name'=>'第二次',
|
||||
'v3_name'=>'第三次',
|
||||
'v4_name'=>'平均',
|
||||
'v5_name'=>'成绩',
|
||||
// 'r_t'=>str_replace('-', '/', $value['r_t'])
|
||||
'r_t'=>$value['r_t']
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
$result = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->field("id,record_time,REPLACE(record_time, '-', '-') AS b_time,one_val,two_val,three_val,average_val,score")->order('record_time desc')->page($data['page'],$this->pagesize)->select();
|
||||
$return_result['totalrows'] = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->where(['aud_id'=>$data['aud_id']])->count();
|
||||
$return_result['rows'] = [];
|
||||
$return_result['pageno'] = $data['page'];
|
||||
$return_result['pagesize'] = $this->pagesize;
|
||||
$return_result['totalpage'] = ceil($return_result['totalrows']/$this->pagesize);
|
||||
foreach ($result as $key => $value) {
|
||||
// $time_t = $this->handle_hour_branch_second($value['jump_time']);
|
||||
array_push($return_result['rows'],[
|
||||
'id'=>$value['id'],
|
||||
'v1'=>$value['one_val'] == '.00'?'0':$value['one_val'],
|
||||
'v2'=>$value['two_val'] == '.00'?'0':$value['two_val'],
|
||||
'v3'=>$value['three_val'] == '.00'?'0':$value['three_val'],
|
||||
'v4'=>$value['average_val'] == '.00'?'0':$value['average_val'],
|
||||
'v5'=>explode(',',$value['score'])[0],
|
||||
'v1_name'=>'第一次',
|
||||
'v2_name'=>'第二次',
|
||||
'v3_name'=>'第三次',
|
||||
'v4_name'=>'平均',
|
||||
'v5_name'=>'成绩',
|
||||
'record_time'=>$value['b_time']
|
||||
]);
|
||||
}
|
||||
}
|
||||
return $this->msg($return_result);
|
||||
}
|
||||
public function get_all_detaile_data_action($data){
|
||||
|
||||
$result = $result = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->where(['id'=>$data['id'],'is_del'=>0])->find();
|
||||
$for_data_arr = ['one_val'=>['第一次','ml'],'two_val'=>['第二次','ml'],'three_val'=>['第三次','ml'],'average_val'=>['三次平均','ml'],'score'=>['最后成绩','分']];
|
||||
if($result){
|
||||
$result_data = [];
|
||||
foreach ($for_data_arr as $key => $value) {
|
||||
$temporary_arr['key_name'] = $key;
|
||||
$temporary_arr['name'] = $value[0];
|
||||
$temporary_arr['value'] = explode(',',$result[$key])[0];
|
||||
$temporary_arr['unit'] = $value[1];
|
||||
array_push($result_data,$temporary_arr);
|
||||
}
|
||||
return $this->msg($result_data);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
################################################################内部调用################################################################
|
||||
################################################################内部调用################################################################
|
||||
// 肺活量判断区间
|
||||
public function vitalcapacity_standard_interval($val,$data){
|
||||
// 缓存一周
|
||||
$result = '';
|
||||
if(!$data || count($data) <= 0){
|
||||
return $result;
|
||||
}
|
||||
$temporary_qj = $data;
|
||||
$max = 0;
|
||||
$min = 0;
|
||||
$num = 0;
|
||||
foreach ($temporary_qj as $key => $value) {
|
||||
if($val >= $value['min_val'] && $val <= $value['max_val']){
|
||||
$max = $value['max_val'];
|
||||
$min = $value['min_val'];
|
||||
$num = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$num = count($temporary_qj)-1-$num;
|
||||
|
||||
if($max == 0){
|
||||
if($val >= $temporary_qj[0]['max_val']){
|
||||
$result = 100;
|
||||
}
|
||||
}else{
|
||||
$temporary_num = bcmul(bcdiv(bcsub($val,$min,20),bcsub($max,$min,20),2),bcdiv(100,count($temporary_qj),2),2);
|
||||
$result = bcadd(bcmul(bcdiv(100,count($temporary_qj),2),$num,2),$temporary_num,2);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
// 肺活量判断区间(根据得分)
|
||||
public function vitalcapacity_standard_interval2($val,$data){
|
||||
// 缓存一周
|
||||
$result = '';
|
||||
if(count($data) <= 0){
|
||||
return $result;
|
||||
}
|
||||
$temporary_qj = $data;
|
||||
$max = 0;
|
||||
$min = 0;
|
||||
$num = 0;
|
||||
foreach ($temporary_qj as $key => $value) {
|
||||
if($val >= $value['min_val'] && $val <= $value['max_val']){
|
||||
$max = $value['max_val'];
|
||||
$min = $value['min_val'];
|
||||
$num = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 计算每份占比
|
||||
$share_value = bcdiv($temporary_qj[0]['max_val'],count($temporary_qj),1);
|
||||
// 计算在这一段中占多少
|
||||
$result = bcsub($val,$min,1);
|
||||
$result = bcdiv($result,bcsub($max,$min,1),1);
|
||||
$num = count($temporary_qj)-1-$num;
|
||||
$num = bcmul($num,$share_value,1);
|
||||
$result = bcadd($num,$result,1);
|
||||
// $num = count($temporary_qj)-1-$num;
|
||||
// $temporary_num = bcmul(bcdiv(bcsub($val,$min,20),bcsub($max,$min,20),2),bcdiv(100,count($temporary_qj),2),2);
|
||||
// $result = bcadd(bcmul(bcdiv(100,count($temporary_qj),2),$num,2),$temporary_num,2);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -46,6 +46,7 @@ class Printaction extends Base
|
|||
a.mac_code,
|
||||
a.sn_code,
|
||||
b.box_code,
|
||||
b.is_del,
|
||||
FORMAT(b.box_num, '000') AS box_num
|
||||
FROM
|
||||
sn_code_all AS a
|
||||
|
|
@ -62,10 +63,10 @@ class Printaction extends Base
|
|||
return $result;
|
||||
}else{
|
||||
$result2 = [
|
||||
['Mac码','Sn码','箱号']
|
||||
['Mac码','Sn码','箱号','是否注销']
|
||||
];
|
||||
for ($i=0; $i < count($result); $i++) {
|
||||
$result2[] = [$result[$i]['mac_code'],$result[$i]['sn_code'],$result[$i]['box_code'].'-'.$result[$i]['box_num']];
|
||||
$result2[] = [$result[$i]['mac_code'],$result[$i]['sn_code'],$result[$i]['box_code'].'-'.$result[$i]['box_num'],$result[$i]['is_del']==0?'否':'是'];
|
||||
}
|
||||
$excel = new \app\download\controller\Excel();
|
||||
$excel->export($result2, $pc['box_code']);
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class Savemsg extends Base{
|
|||
|
||||
public function save_box_msg($data = ['sn_code_all'=>'564654564654654,564654564654654','box_serial_number'=>'996589585']){
|
||||
|
||||
// try {
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
|
|
@ -115,22 +115,22 @@ class Savemsg extends Base{
|
|||
}
|
||||
$result = $this->save_box_msg_action($data);
|
||||
return $result;
|
||||
// } catch (\Exception $e) {
|
||||
// // 捕获异常
|
||||
// $logContent["flie"] = $e->getFile();
|
||||
// $logContent["line"] = $e->getLine();
|
||||
// $logContent['all_content'] = "异常信息:\n";
|
||||
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
// $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n";
|
||||
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
// // dump($data);
|
||||
// // die;
|
||||
// $this->record_api_log($data, $logContent, null);
|
||||
// return $this->msg(99999);
|
||||
// }
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
// dump($data);
|
||||
// die;
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -175,6 +175,11 @@ class Savemsg extends Base{
|
|||
}
|
||||
|
||||
|
||||
public function logout_outbox_code(){
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
########################################################################action########################################################################
|
||||
|
|
@ -212,9 +217,20 @@ class Savemsg extends Base{
|
|||
public function save_sn_msg_action($data){
|
||||
$data = $this->chuli_str_kongbai($data);
|
||||
$zengjie = Db::connect('zengjie_db');
|
||||
$sn_code = $zengjie->table('sn_code_all')->where(['sn_code'=>$data['sn_code']])->count();
|
||||
if($sn_code > 0){
|
||||
$sn_code = $zengjie->table('sn_code_all')->where(['sn_code'=>$data['sn_code']])->find();
|
||||
|
||||
if($sn_code){
|
||||
$box_state = $zengjie->table('box_code_all')->where(['id'=>$sn_code['batch_id']])->field('id,is_del')->find();
|
||||
if($box_state['is_del'] == 0){
|
||||
return $this->msg(10002,'该码已录入');
|
||||
}else{
|
||||
$sn_del_state = $zengjie->table('sn_code_all')->where(['id'=>$sn_code['id']])->delete();
|
||||
if ($sn_del_state) {
|
||||
// return $this->msg(10000, '删除成功'); // 假设10000是成功代码
|
||||
} else {
|
||||
return $this->msg(10002, '数据错误请重新尝试');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = $zengjie->table('sn_code_all')->insert([
|
||||
|
|
@ -354,6 +370,24 @@ class Savemsg extends Base{
|
|||
return $data;
|
||||
}
|
||||
|
||||
public function logout_outbox_code_action(){
|
||||
$data = input();
|
||||
// 处理前导零
|
||||
$boxNumber = ltrim($data['boxNumber'], '0');
|
||||
$boxNumber = $boxNumber === '' ? '0' : $boxNumber;
|
||||
$zengjie = Db::connect('zengjie_db');
|
||||
$box_result = $zengjie->table('box_code_all')->where(['box_code'=>$data['boxCode'],'box_num'=>$boxNumber])->count();
|
||||
if($box_result <= 0){
|
||||
return $this->msg(10002,'未找到对应外箱编码');
|
||||
}
|
||||
$result = $zengjie->table('box_code_all')->where(['box_code'=>$data['boxCode'],'box_num'=>$boxNumber])->update(['is_del'=>1]);
|
||||
if($result){
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
return $this->msg(10002,'注销失败');
|
||||
}
|
||||
}
|
||||
|
||||
######################################################测试#########################################################
|
||||
######################################################测试#########################################################
|
||||
######################################################测试#########################################################
|
||||
|
|
|
|||
|
|
@ -32,12 +32,20 @@
|
|||
<th>MAC地址</th>
|
||||
<th>SN码</th>
|
||||
<th>箱号</th>
|
||||
<th>是否注销</th>
|
||||
</tr>
|
||||
{volist name="data" id="item"}
|
||||
<tr>
|
||||
<td>{$item.mac_code|default='未分配'}</td>
|
||||
<td>{$item.sn_code}</td>
|
||||
<td>{$item.box_code}-{$item.box_num}</td>
|
||||
<td>
|
||||
{if condition="$item.is_del == 0"}
|
||||
否
|
||||
{else /}
|
||||
是
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ class Base extends Controller{
|
|||
return ['state'=>false,'language'=>null];
|
||||
}
|
||||
|
||||
$user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->field('id,login_time,language')->find();
|
||||
$user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token,'is_del'=>0])->field('id,login_time,language')->find();
|
||||
if(!$user_login){
|
||||
Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,未找到用户token', 'token_log');
|
||||
return ['state'=>false,'language'=>null];
|
||||
|
|
@ -177,8 +177,8 @@ class Base extends Controller{
|
|||
return ['state'=>false,'language'=>$user_login['language']];
|
||||
} else {
|
||||
// echo "未超过 {$specifiedDays} 天";
|
||||
$user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->update(['login_time'=>date('Y-m-d H:i:s')]);
|
||||
if($user_login){
|
||||
$result = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->update(['login_time'=>date('Y-m-d H:i:s')]);
|
||||
if($result){
|
||||
Log::record('用户尝试更新token时间,token:' . $token.',记录成功,最新的时间为'.date('Y-m-d H:i:s'), 'token_log');
|
||||
return ['state'=>true,'language'=>$user_login['language']];
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -100,10 +100,17 @@ class Card extends Base{
|
|||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
$user_languages = Db::table('app_account_number')->where(['token'=>$data['token'],'is_del'=>0])->field('id,language')->find();
|
||||
if(!$user_languages){
|
||||
return $this->msg(10003);
|
||||
}
|
||||
// $return_data;
|
||||
$return_data = $this->get_user_body_data($data);
|
||||
// $language_data = new Language();
|
||||
// $return_data = $language_data->handling_languages_from_multiple_countries('en', $return_data->getData());
|
||||
// 处理多语言
|
||||
if($user_languages['language'] != 'zh-Hans' || $user_languages['language'] != ''){
|
||||
$language_data = new Language();
|
||||
$return_data = $language_data->handling_languages_from_multiple_countries($user_languages['language'], $return_data->getData());
|
||||
}
|
||||
return $return_data;
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
|
|
|
|||
|
|
@ -147,8 +147,8 @@ class Index extends Base{
|
|||
$url = '';
|
||||
}
|
||||
$user_token_state = $this->token_time_validate($data['token']);
|
||||
|
||||
$language_data = $this->pd_language($user_token_state['language'],$isSupportedLanguage,$language);
|
||||
|
||||
if($user_token_state['state'] === false){
|
||||
return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->process_Language()]);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -20,6 +20,19 @@ class Language extends Base
|
|||
protected $languageMap = [
|
||||
'en' => [
|
||||
'操作成功' => 'Success',
|
||||
'关键参数缺失' => 'Required parameter missing',
|
||||
'操作失败' => 'Operation failed',
|
||||
'信息核实错误' => 'Information verification error',
|
||||
'未找到有效数据' => 'No valid data found',
|
||||
'参数格式错误' => 'Parameter format error',
|
||||
'参数不能为空' => 'Parameter cannot be empty',
|
||||
'参数错误' => 'Parameter error',
|
||||
'自定义信息' => 'Custom message',
|
||||
'登录失效' => 'Login invalid',
|
||||
'网络异常,请稍后重试' => 'Network error, please try again later',
|
||||
'年龄' => 'Age',
|
||||
'岁' => '',
|
||||
'无' => 'none',
|
||||
'体重' => 'Weight',
|
||||
'身高' => 'Height',
|
||||
'消瘦' => 'Slim',
|
||||
|
|
@ -80,9 +93,9 @@ class Language extends Base
|
|||
'3-7岁的孩子:骑两轮车、拍踢球、打篮球、游泳、爬山,每天高强度运动不超过30分钟。' => "Ages 3–7: Bicycling, ball games, basketball, swimming, hiking. Limit high-intensity exercise to 30 minutes daily.",
|
||||
'该年龄段睡眠时间建议:9-11小时' => "Recommended sleep duration for this age group: 9–11 hours.",
|
||||
'孩子开始对于赞赏、鼓励、认同和肯定有需求,而且此阶段父亲在孩子的性格塑造、情绪控制以及责任感培养方面扮演着重要的角色,必须告诉孩子什么事应该做、什么事不应该做,并经常性地给孩子一些积极地暗示。例如,可以时常向孩子表达“我会一直在你身边,不要害怕””我对你的进步都看在眼里等类似的话语。' => "Children begin to crave praise, encouragement, and validation. Fathers play a key role in shaping character, emotional regulation, and responsibility during this phase. Clearly define boundaries while offering positive affirmations (e.g., 'I’m always here for you,' 'I see your progress').",
|
||||
'《中华人民共和国卫生行业标准WS 423-2013》' => "《Chinese Health Industry Standard WS 423-2013》",
|
||||
'《中华人民共和国卫生行业标准WS/T 423-2022》' => "《Chinese Health Industry Standard WS 423-2022》",
|
||||
'《中华人民共和国卫生行业标准WS/T 612-2018》' => "《Chinese Health Industry Standard WS/T 612-2018》",
|
||||
'《中华人民共和国卫生行业标准WS/T1586-2018》' => "《Chinese Health Industry Standard WS/T 1586-2018》",
|
||||
'《中华人民共和国卫生行业标准WS/T 586-2018》' => "《Chinese Health Industry Standard WS/T 586-2018》",
|
||||
'《WHO 5~19岁身高/体重判定标准》' => "《WHO Growth Reference for Children and Adolescents (5–19 Years)》",
|
||||
'头围' => "Head Circumference",
|
||||
'头围是指绕头部一周的最大长度,头围的大小与脑的发育密切相关' => "Head circumference refers to the maximum length around the head. Its measurement is closely related to brain development.",
|
||||
|
|
@ -90,7 +103,6 @@ class Language extends Base
|
|||
],
|
||||
// 可以添加更多语言映射
|
||||
];
|
||||
|
||||
/**
|
||||
* 处理多国语言翻译
|
||||
*
|
||||
|
|
|
|||
|
|
@ -87,14 +87,24 @@ class Pagingcontrast extends Base{
|
|||
if(!$this->verify_data_is_ok($data['type'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
$token = $data['token'];
|
||||
$user_languages = Db::table('app_account_number')->where(['token'=>$token,'is_del'=>0])->field('id,language')->find();
|
||||
if(!$user_languages){
|
||||
return $this->msg(10003);
|
||||
}
|
||||
unset($data['token']);
|
||||
if(array_key_exists($data['type'],$this->db_name)){
|
||||
$return_data = $this->jump_transfer_interface_record($data,'page');
|
||||
}else{
|
||||
$return_data = $this->msg(10005);
|
||||
}
|
||||
// 处理多语言
|
||||
if($user_languages['language'] != 'zh-Hans' || $user_languages['language'] != ''){
|
||||
$language_data = new Language();
|
||||
$return_data = $language_data->handling_languages_from_multiple_countries($user_languages['language'], $return_data->getData());
|
||||
}
|
||||
// 成功
|
||||
$this->record_api_log($data, null, $return_data);
|
||||
// $this->record_api_log($data, null, $return_data);
|
||||
return $return_data;
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
|
|
@ -127,10 +137,19 @@ class Pagingcontrast extends Base{
|
|||
if(!$this->verify_data_is_ok($data['type'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
$token = $data['token'];
|
||||
$user_languages = Db::table('app_account_number')->where(['token'=>$token,'is_del'=>0])->field('id,language')->find();
|
||||
if(!$user_languages){
|
||||
return $this->msg(10003);
|
||||
}
|
||||
unset($data['token']);
|
||||
$return_data = $this->jump_transfer_interface_detailed($data);
|
||||
// 成功
|
||||
$this->record_api_log($data, null, $return_data);
|
||||
// 处理多语言
|
||||
if($user_languages['language'] != 'zh-Hans' || $user_languages['language'] != ''){
|
||||
$language_data = new Language();
|
||||
$return_data = $language_data->handling_languages_from_multiple_countries($user_languages['language'], $return_data->getData());
|
||||
}
|
||||
return $return_data;
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
|
|
|
|||
|
|
@ -621,6 +621,10 @@ Route::any('/z/print_scan_barcode', 'app/ZengJieCode/admin.printaction/print_sca
|
|||
// 获取大箱没打印的条码
|
||||
Route::any('/z/print_combined_code', 'app/ZengJieCode/admin.printaction/print_combined_code');
|
||||
|
||||
// 大箱注销重新录入
|
||||
Route::any('/z/logout_outbox_code', 'app/ZengJieCode/app.savemsg/logout_outbox_code');
|
||||
Route::any('/z/logout_outbox_code_action', 'app/ZengJieCode/app.savemsg/logout_outbox_code_action');
|
||||
|
||||
|
||||
|
||||
################################################################下面是设备入库录入################################################################
|
||||
|
|
@ -658,6 +662,14 @@ Route::any('/de/admin/device/device_all', 'app/DeviceEnter/admin.device/device_a
|
|||
################################################################接口(API)
|
||||
// 默认配置
|
||||
Route::any('/reedaw/config', 'app/NewReedaw/app.index/config');
|
||||
// 通用数据对比
|
||||
Route::any('/reedaw/all_data_contrast', 'app/NewReedaw/app.index/all_data_contrast');
|
||||
|
||||
################################################################金刚区部分
|
||||
// 遗传身高
|
||||
Route::any('/reedaw/genetic_height', 'app/NewReedaw/app.index/genetic_height');
|
||||
// BMI评测
|
||||
Route::any('/reedaw/bmi_evaluation', 'app/NewReedaw/app.index/bmi_evaluation');
|
||||
|
||||
################################################################登录注册部分
|
||||
// 注册账号
|
||||
|
|
@ -671,11 +683,63 @@ Route::any('/reedaw/add_member', 'app/NewReedaw/app.role/add_member');
|
|||
Route::any('/reedaw/update_member', 'app/NewReedaw/app.role/update_member');
|
||||
// 获取角色列表
|
||||
Route::any('/reedaw/role_list', 'app/NewReedaw/app.role/role_list');
|
||||
################################################################卡片部分
|
||||
// 卡片列表
|
||||
Route::any('/reedaw/card/card_list_msg', 'app/NewReedaw/app.card/card_list_msg');
|
||||
// 用户卡片排序
|
||||
Route::any('/reedaw/card/card_user_order', 'app/NewReedaw/app.card/card_user_order');
|
||||
################################################################身体报告部分
|
||||
// 获取角色报告
|
||||
Route::any('/reedaw/body_report', 'app/NewReedaw/app.body/body_report');
|
||||
|
||||
|
||||
Route::any('/reedaw/body/body_report', 'app/NewReedaw/app.body/body_report');
|
||||
// 手动记录
|
||||
Route::any('/reedaw/body/manual_record', 'app/NewReedaw/app.body/manual_record');
|
||||
// 设备记录
|
||||
Route::any('/reedaw/body/device_record', 'app/NewReedaw/app.body/device_record');
|
||||
// 历史记录(分页)
|
||||
Route::any('/reedaw/body/record_list_page', 'app/NewReedaw/app.body/record_list_page');
|
||||
// 历史记录(分组)
|
||||
Route::any('/reedaw/body/record_list_group', 'app/NewReedaw/app.body/record_list_group');
|
||||
// 历史记录(详细)
|
||||
Route::any('/reedaw/body/detailed_record', 'app/NewReedaw/app.body/detailed_record');
|
||||
// 历史记录(详细)
|
||||
Route::any('/reedaw/body/del_record', 'app/NewReedaw/app.body/del_record');
|
||||
################################################################肺活部分
|
||||
// 手动记录
|
||||
Route::any('/reedaw/vitalcapacity/manual_record', 'app/NewReedaw/app.vitalcapacity/manual_record');
|
||||
// 设备记录
|
||||
Route::any('/reedaw/vitalcapacity/device_record', 'app/NewReedaw/app.vitalcapacity/device_record');
|
||||
// 上一次数据
|
||||
Route::any('/reedaw/vitalcapacity/data_report', 'app/NewReedaw/app.vitalcapacity/data_report');
|
||||
// 曲线
|
||||
Route::any('/reedaw/vitalcapacity/curve_chart', 'app/NewReedaw/app.vitalcapacity/curve_chart');
|
||||
// 历史记录(分页)
|
||||
Route::any('/reedaw/vitalcapacity/record_list_page', 'app/NewReedaw/app.vitalcapacity/record_list_page');
|
||||
// 历史记录(分组)
|
||||
Route::any('/reedaw/vitalcapacity/record_list_group', 'app/NewReedaw/app.vitalcapacity/record_list_group');
|
||||
// 历史记录(详细)
|
||||
Route::any('/reedaw/vitalcapacity/detailed_record', 'app/NewReedaw/app.vitalcapacity/detailed_record');
|
||||
// 历史记录(详细)
|
||||
Route::any('/reedaw/vitalcapacity/del_record', 'app/NewReedaw/app.vitalcapacity/del_record');
|
||||
################################################################跳绳部分
|
||||
// 手动记录
|
||||
Route::any('/reedaw/skip/manual_record', 'app/NewReedaw/app.skip/manual_record');
|
||||
// 设备记录
|
||||
Route::any('/reedaw/skip/device_record', 'app/NewReedaw/app.skip/device_record');
|
||||
// 上一次数据
|
||||
Route::any('/reedaw/skip/data_report', 'app/NewReedaw/app.skip/data_report');
|
||||
// 曲线
|
||||
Route::any('/reedaw/skip/curve_chart', 'app/NewReedaw/app.skip/curve_chart');
|
||||
// 历史记录(分页)
|
||||
Route::any('/reedaw/skip/record_list_page', 'app/NewReedaw/app.skip/record_list_page');
|
||||
// 历史记录(分组)
|
||||
Route::any('/reedaw/skip/record_list_group', 'app/NewReedaw/app.skip/record_list_group');
|
||||
// 历史记录(详细)
|
||||
Route::any('/reedaw/skip/detailed_record', 'app/NewReedaw/app.skip/detailed_record');
|
||||
// 历史记录(详细)
|
||||
Route::any('/reedaw/skip/del_record', 'app/NewReedaw/app.skip/del_record');
|
||||
################################################################跳绳部分
|
||||
// 获取单个地区数据
|
||||
Route::any('/reedaw/gf/get_single_data', 'app/NewReedaw/app.gufen/get_single_data');
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.6 KiB |