From 6ee76420ebc61d4273885689bb5ce24310b1481f Mon Sep 17 00:00:00 2001 From: tsf Date: Wed, 25 Mar 2026 17:46:32 +0800 Subject: [PATCH] =?UTF-8?q?260325=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NewReedaw/controller/app/Business.php | 36 + application/NewReedaw/controller/app/Card.php | 4 +- .../NewReedaw/controller/app/Kitchenscale.php | 8 +- application/NewReedaw/controller/app/Role.php | 16 +- application/NewReedaw/controller/app/Skip.php | 122 +- .../controller/app/Sportstesting.php | 1078 +++++++++++++++ .../NewReedaw/controller/app/Userbody.php | 1191 ++++++++--------- .../app/business/business_cooperation.html | 398 ++++++ application/route.php | 11 +- 9 files changed, 2191 insertions(+), 673 deletions(-) create mode 100644 application/NewReedaw/controller/app/Business.php create mode 100644 application/NewReedaw/controller/app/Sportstesting.php create mode 100644 application/NewReedaw/view/app/business/business_cooperation.html diff --git a/application/NewReedaw/controller/app/Business.php b/application/NewReedaw/controller/app/Business.php new file mode 100644 index 0000000..37dcdbb --- /dev/null +++ b/application/NewReedaw/controller/app/Business.php @@ -0,0 +1,36 @@ +fetch(); + } + + public function business_cooperation_action(){ + $data = input(); + $result = Db::table('admin_business_cooperation_log')->insert([ + 'name'=>$data['name'], + 'tel'=>$data['phone'], + 'company'=>$data['company'], + 'intention_data'=>implode(',',$data['selectedValues']), + 'notes_data'=>$data['remark'], + 'create_time'=>date('Y-m-d H:i:s'), + ]); + if($result){ + $this->send_email_api_error(["19759414@qq.com"],['title'=>'商户合作','from_user_name'=>'reedaw商务','content'=>'有一封商户合作']); + // $this->send_email_api_error(["tsf3920322@126.com"],['title'=>'商户合作','from_user_name'=>'reedaw商务','content'=>'有一封商户合作']); + + return json(['code'=>0,'msg'=>'提交成功']); + }else{ + return json(['code'=>10001,'msg'=>'网络错误']); + // return json(['code'=>10001,'msg'=>'网络错误,请直接联系商务合作电话/微信:13590959084']); + } + } +} \ No newline at end of file diff --git a/application/NewReedaw/controller/app/Card.php b/application/NewReedaw/controller/app/Card.php index 0429754..91bf732 100644 --- a/application/NewReedaw/controller/app/Card.php +++ b/application/NewReedaw/controller/app/Card.php @@ -1312,6 +1312,7 @@ class Card extends Base{ 'v2_name'=>'时长', 'v3_name'=>'卡路里', 'record_time'=>$value['b_time'], + 'is_have_details'=>'no' ]); } } @@ -1378,7 +1379,8 @@ class Card extends Base{ 'v3_name'=>'第三次', 'v4_name'=>'平均', 'v5_name'=>'成绩', - 'record_time'=>$value['b_time'] + 'record_time'=>$value['b_time'], + 'is_have_details'=>'yes' ]); } } diff --git a/application/NewReedaw/controller/app/Kitchenscale.php b/application/NewReedaw/controller/app/Kitchenscale.php index ea123c0..a183d9b 100644 --- a/application/NewReedaw/controller/app/Kitchenscale.php +++ b/application/NewReedaw/controller/app/Kitchenscale.php @@ -391,10 +391,9 @@ class Kitchenscale extends Base{ // 添加每日摄入记录 public function add_intake_food(){ // 尝试捕获异常 + $data = input('post.'); try { - if(count(input('post.')) > 0){ - $data = input('post.'); - } + if(!array_key_exists('token', $data)){ return $this->msg(10001,'token is miss'); } @@ -2058,6 +2057,9 @@ class Kitchenscale extends Base{ if(!array_key_exists('id', $value)){ return $this->msg(10001,'id is miss'); } + if(!array_key_exists('unit', $value)){ + return $this->msg(10001,'unit is miss'); + } if(!array_key_exists('weight', $value)){ return $this->msg(10001,'weight is miss'); } diff --git a/application/NewReedaw/controller/app/Role.php b/application/NewReedaw/controller/app/Role.php index 9b18c11..1f96d85 100644 --- a/application/NewReedaw/controller/app/Role.php +++ b/application/NewReedaw/controller/app/Role.php @@ -52,9 +52,9 @@ class Role extends Base{ ]; // 阶段性称谓 protected $stage_appellation = [ - ['min'=>'0','max'=>'3','value'=>'婴儿'], - ['min'=>'3','max'=>'16','value'=>'儿童'], - ['min'=>'16','max'=>'500','value'=>'成人'] + ['min'=>'0','max'=>'3','value'=>'婴儿','identification'=>3], + ['min'=>'3','max'=>'16','value'=>'儿童','identification'=>2], + ['min'=>'16','max'=>'500','value'=>'成人','identification'=>1] ]; // 加 bcadd(,,20) // 减 bcsub(,,20) @@ -74,7 +74,7 @@ class Role extends Base{ return $this->msg(10001); } if($data['token'] == ''){ - return $this->msg(-2,'特殊状态',[]); + return $this->msg(-2,'请先登录',[]); } if(!$this->verify_data_is_ok($data['token'],'str')){ return $this->msg(10005); @@ -692,7 +692,9 @@ class Role extends Base{ // 添加阶段称谓、婴儿、儿童、成人 foreach ($this->stage_appellation as $key => $value) { if($result[$i]['age'] >= $value['min'] && $result[$i]['age'] < $value['max']){ - $result[$i]['stage'] = $value['value']; + // $result[$i]['stage'] = $value['value']; + $result[$i]['stage'] = $value['identification']; + } } } @@ -784,7 +786,9 @@ class Role extends Base{ foreach ($this->stage_appellation as $key => $value) { if($user_all_data['age'] >= $value['min'] && $user_all_data['age'] < $value['max']){ - $user_all_data['stage'] = $value['value']; + // $user_all_data['stage'] = $value['value']; + $user_all_data['stage'] = $value['identification']; + } } // if($user_all_data['gender'] == 2){ diff --git a/application/NewReedaw/controller/app/Skip.php b/application/NewReedaw/controller/app/Skip.php index de4ba72..dcc6220 100644 --- a/application/NewReedaw/controller/app/Skip.php +++ b/application/NewReedaw/controller/app/Skip.php @@ -11,6 +11,7 @@ class Skip extends Base{ 'zhanghao'=>'app_account_number', 'juese'=>'app_user_data', 'body'=>'app_card_body_data', + 'body_new'=>'app_card_body_data_new', 'skip'=>'app_card_skip_data', ]; @@ -35,9 +36,13 @@ class Skip extends Base{ // 设备记录 public function device_record(){ $data = input('post.'); - try { + try { + // 你的业务逻辑 + if(count(input('post.')) > 0){ + $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 $this->msg(10001); + $return_data = $this->msg(10001); } if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ return $this->msg(10005); @@ -49,19 +54,17 @@ class Skip extends Base{ return $this->msg(10005); } if(!$this->isValidInteger($data['num']+0) || !$this->isValidInteger($data['time_m']+0) || !$this->isValidInteger($data['time_s']+0)){ - return $this->msg(10005,'跳绳数量或者分钟、秒钟值必须为整数'); + $return_data = $this->msg(10005,'跳绳数量或者分钟、秒钟值必须为整数'); } if($data['num'] <= 0){ - return $this->msg(10005,'跳绳数不能小于等于0'); + $return_data = $this->msg(10005,'跳绳数不能小于等于0'); } if(abs($data['time_s']) >= 60){ - return $this->msg(10005,'秒钟值不能大于60'); + $return_data = $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); + + return $this->device_record_action($data); } catch (\Exception $e) { // 捕获异常 $logContent["flie"] = $e->getFile(); @@ -108,6 +111,73 @@ class Skip extends Base{ ################################################################action################################################################ ################################################################action################################################################ + public function device_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_new'])->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(); @@ -139,25 +209,25 @@ class Skip extends Base{ $result['last_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s']; return $this->msg($result); } - public function get_all_detaile_data_action($data){ + // 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); - } + // $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); + // } - } + // } ################################################################内部调用################################################################ diff --git a/application/NewReedaw/controller/app/Sportstesting.php b/application/NewReedaw/controller/app/Sportstesting.php new file mode 100644 index 0000000..6a27e11 --- /dev/null +++ b/application/NewReedaw/controller/app/Sportstesting.php @@ -0,0 +1,1078 @@ +'admin_estimate', + 'tc_jilu'=>'app_sportstesting_data', + 'juese'=>'app_user_data', + ]; + protected $page_num = 10; + protected $default_address = '上海'; + protected $city_data_rule_name = [ + 'xc'=>'现场类项目', + 'xc_1'=>'第一类:素质项目Ⅰ(8分)', + 'xc_2'=>'第二类:素质项目Ⅱ(8分)', + 'xc_3'=>'第三类:运动能力Ⅰ(8分)', + 'xc_4'=>'第四类:运动能力Ⅱ(6分)', + 'gc'=>'过程类项目', + 'gc_8_m'=>'8年级体质健康统测(10分)', + 'gc_8_r'=>'8年级体育与健康知识机考(10分)', + ]; + protected $city_data_rule_is_choice = ['xc_2','xc_3','xc_4']; + + protected $type_all = [ + '1'=>'整数填数字(例肺活量)', + '2'=>'小数(例50米跑)', + '3'=>'拖动区间(例坐位体前屈:-15至30之间,需要有小数1位)', + '4'=>'分钟秒钟(例1000米跑)', + ]; + + + protected $ceshiyongde_data_baocun_canshu = '{ + "code": 0, + "msg": "操作成功", + "data": [ + { + "name": "现场考试", + "key": "现场考试", + "list": [ + { + "name": "第一类项目(3选1)", + "key": "第一类项目", + "is_choice": "1", + "list": [ + { + "name": "1000米跑", + "proportion": "1", + "value": "4:23", + "proportion_value": null, + "unit": "分/秒", + "type": "4", + "describe": null, + "total_score": 6, + "choice_state": 1 + }, + { + "name": "200米游泳", + "proportion": "1", + "value": "6:12", + "proportion_value": null, + "unit": "分/秒", + "type": "4", + "describe": null, + "total_score": 6, + "choice_state": 0 + }, + { + "name": "4分钟跳绳", + "proportion": "1", + "value": 340, + "proportion_value": null, + "unit": "次", + "type": "1", + "describe": null, + "total_score": 6, + "choice_state": 0 + } + ] + }, + { + "name": "第二类项目(5选1)", + "key": "第二类项目", + "is_choice": "1", + "list": [ + { + "name": "50米跑", + "proportion": "1", + "value": 8.1, + "proportion_value": null, + "unit": "秒", + "type": "2", + "describe": null, + "total_score": 3, + "choice_state": 1 + }, + { + "name": "立定跳远", + "proportion": "1", + "value": 2.02, + "proportion_value": null, + "unit": "米", + "type": "2", + "describe": null, + "total_score": 3, + "choice_state": 0 + }, + { + "name": "实心球", + "proportion": "1", + "value": 7.3, + "proportion_value": null, + "unit": "米", + "type": "2", + "describe": null, + "total_score": 3, + "choice_state": 0 + }, + { + "name": "引体向上", + "proportion": "1", + "value": 6, + "proportion_value": null, + "unit": "次", + "type": "1", + "describe": null, + "total_score": 3, + "choice_state": 0 + }, + { + "name": "25米游泳", + "proportion": "1", + "value": 30, + "proportion_value": null, + "unit": "秒", + "type": "1", + "describe": null, + "total_score": 3, + "choice_state": 0 + } + ] + }, + { + "name": "第三类项目(5选1)", + "key": "第三类项目", + "is_choice": "1", + "list": [ + { + "name": "乒乓球", + "proportion": "1", + "value": 15, + "proportion_value": null, + "unit": "次", + "type": "1", + "describe": null, + "total_score": 3, + "choice_state": 1 + }, + { + "name": "羽毛球", + "proportion": "1", + "value": 60, + "proportion_value": null, + "unit": "得分", + "type": "1", + "describe": null, + "total_score": 3, + "choice_state": 0 + }, + { + "name": "网球", + "proportion": "1", + "value": 55, + "proportion_value": null, + "unit": "得分", + "type": "1", + "describe": null, + "total_score": 3, + "choice_state": 0 + }, + { + "name": "武术", + "proportion": "1", + "value": "6", + "proportion_value": null, + "unit": "得分", + "type": "2", + "describe": null, + "total_score": 3, + "choice_state": 0 + }, + { + "name": "体操", + "proportion": "1", + "value": "6", + "proportion_value": null, + "unit": "得分", + "type": "2", + "describe": null, + "total_score": 3, + "choice_state": 0 + } + ] + }, + { + "name": "第四类项目(3选1)", + "key": "第四类项目", + "is_choice": "1", + "list": [ + { + "name": "足球运球", + "proportion": "1", + "value": 15.5, + "proportion_value": null, + "unit": "秒", + "type": "2", + "describe": null, + "total_score": 3, + "choice_state": 1 + }, + { + "name": "篮球", + "proportion": "1", + "value": 31, + "proportion_value": null, + "unit": "秒", + "type": "1", + "describe": null, + "total_score": 3, + "choice_state": 0 + }, + { + "name": "排球", + "proportion": "1", + "value": 23, + "proportion_value": null, + "unit": "40秒/次", + "type": "1", + "describe": null, + "total_score": 3, + "choice_state": 0 + } + ] + } + ] + }, + { + "name": "日常考核", + "key": "日常考核", + "list": [ + { + "name": "体育与健身", + "key": "体育与健身", + "is_choice": "0", + "list": [ + { + "name": "7年级", + "proportion": "1", + "value": "60", + "proportion_value": null, + "unit": "分", + "type": "1", + "describe": "满分100分", + "total_score": "2" + }, + { + "name": "8年级", + "proportion": "1", + "value": "60", + "proportion_value": null, + "unit": "分", + "type": "1", + "describe": "满分100分", + "total_score": "2" + }, + { + "name": "9年级", + "proportion": "1", + "value": "60", + "proportion_value": null, + "unit": "分", + "type": "1", + "describe": "满分100分", + "total_score": "2" + } + ] + }, + { + "name": "体质健康综合评定", + "key": "体质健康综合评定", + "is_choice": "0", + "list": [ + { + "name": "7年级", + "proportion": "1", + "value": "60", + "proportion_value": null, + "unit": "分", + "type": "1", + "describe": "满分100分", + "total_score": "3" + }, + { + "name": "8年级", + "proportion": "1", + "value": "60", + "proportion_value": null, + "unit": "分", + "type": "1", + "describe": "满分100分", + "total_score": "3" + }, + { + "name": "9年级", + "proportion": "1", + "value": "60", + "proportion_value": null, + "unit": "分", + "type": "1", + "describe": "满分100分", + "total_score": "3" + } + ] + } + ] + } + ] + }'; + + protected $ceshi_data = [ + [ + 'name' => '现场考试', + 'key' => '现场考试', + 'list' => [ + [ + 'name' => '第一类:素质项目Ⅰ', + 'key' => '第一类:素质项目Ⅰ', + 'is_choice' => '0', + 'list' => [ + [ + 'name' => '1000米', + 'proportion' => '1', + 'value' => '4:55', + 'proportion_value' => null, + 'unit' => '分/秒', + 'type' => '4', + 'describe' => '1000米。考生参加考试时应穿着运动装、运动鞋,鞋底不得有铁钉、胶钉或塑料钉。', + 'total_score' => '8' + ] + ] + ], + [ + 'name' => '第二类:素质项目Ⅱ(6选1)', + 'key' => '第二类:素质项目Ⅱ', + 'is_choice' => '1', + 'list' => [ + [ + 'name' => '引体向上', + 'proportion' => '1', + 'value' => '5', + 'proportion_value' => null, + 'unit' => '个', + 'type' => '1', + 'describe' => null, + 'total_score' => '8', + 'choice_state' => 1 + ], + [ + 'name' => '双杠臂屈伸', + 'proportion' => '1', + 'value' => '5', + 'proportion_value' => null, + 'unit' => '个', + 'type' => '1', + 'describe' => null, + 'total_score' => '8', + 'choice_state' => 0 + ], + [ + 'name' => '实心球', + 'proportion' => '1', + 'value' => '7.0', + 'proportion_value' => null, + 'unit' => '米', + 'type' => '2', + 'describe' => null, + 'total_score' => '8', + 'choice_state' => 0 + ], + [ + 'name' => '1分钟跳绳', + 'proportion' => '1', + 'value' => '140', + 'proportion_value' => null, + 'unit' => '次', + 'type' => '1', + 'describe' => null, + 'total_score' => '8', + 'choice_state' => 0 + ], + [ + 'name' => '原地纵跳摸高', + 'proportion' => '1', + 'value' => '38', + 'proportion_value' => null, + 'unit' => '厘米', + 'type' => '1', + 'describe' => null, + 'total_score' => '8', + 'choice_state' => 0 + ], + [ + 'name' => '立定跳远', + 'proportion' => '1', + 'value' => '1.85', + 'proportion_value' => null, + 'unit' => '米', + 'type' => '2', + 'describe' => null, + 'total_score' => '8', + 'choice_state' => 0 + ] + ] + ], + [ + 'name' => '第三类:运动能力Ⅰ(5选1)', + 'key' => '第三类:运动能力Ⅰ', + 'is_choice' => '1', + 'list' => [ + [ + 'name' => '足球--运球射门', + 'proportion' => '1', + 'value' => '22.5', + 'proportion_value' => null, + 'unit' => '秒', + 'type' => '2', + 'describe' => null, + 'total_score' => '8', + 'choice_state' => 1 + ], + [ + 'name' => '篮球--运球投篮', + 'proportion' => '1', + 'value' => '38.5', + 'proportion_value' => null, + 'unit' => '秒', + 'type' => '2', + 'describe' => null, + 'total_score' => '8', + 'choice_state' => 0 + ], + [ + 'name' => '排球--垫球发球', + 'proportion' => '1', + 'value' => '8.5', + 'proportion_value' => null, + 'unit' => '积分', + 'type' => '2', + 'describe' => null, + 'total_score' => '8', + 'choice_state' => 0 + ], + [ + 'name' => '乒乓球--左推右攻发球', + 'proportion' => '1', + 'value' => '32', + 'proportion_value' => null, + 'unit' => '次数', + 'type' => '1', + 'describe' => null, + 'total_score' => '8', + 'choice_state' => 0 + ], + [ + 'name' => '羽毛球--正反手挑球发高远', + 'proportion' => '1', + 'value' => '14.0', + 'proportion_value' => null, + 'unit' => '积分', + 'type' => '2', + 'describe' => null, + 'total_score' => '8', + 'choice_state' => 0 + ] + ] + ], + [ + 'name' => '第四类:运动能力Ⅱ(5选1)', + 'key' => '第四类:运动能力Ⅱ', + 'is_choice' => '1', + 'list' => [ + [ + 'name' => '体操双杠组合Ⅰ', + 'proportion' => '1', + 'value' => '4', + 'proportion_value' => null, + 'unit' => '积分', + 'type' => '1', + 'describe' => '体操4个项目的总分均为6分,其中,动作质量5分、动作表现1分。杠端跳上成分腿坐(1 分)—前进一次成分腿坐(1 分)—弹杠举腿进杠(1 分)—支撑后摆转体180 度成分腿坐(1 分)—弹杠进杠前摆下(1 分)。', + 'total_score' => '6', + 'choice_state' => 1 + ], + [ + 'name' => '体操技巧组合Ⅰ', + 'proportion' => '1', + 'value' => '4', + 'proportion_value' => null, + 'unit' => '积分', + 'type' => '1', + 'describe' => '体操4个项目的总分均为6分,其中,动作质量5分、动作表现1分。鱼跃前滚翻(1分)—交叉转体180 度(1 分)—后滚成肩肘倒立(1分) —前滚成蹲立(1 分)—挺身跳(1 分)。', + 'total_score' => '6', + 'choice_state' => 0 + ], + [ + 'name' => '健身长拳套路', + 'proportion' => '1', + 'value' => '3.5', + 'proportion_value' => null, + 'unit' => '积分', + 'type' => '2', + 'describe' => '武术 2 个项目的总分均为6分,其中,动作质量5分、演练水平 1分。起势(0.5分)—开步双劈(0.5分)—按掌前推(0.5分)—搂手勾踢(0.5分)—缠腕斩拳(0.5分)—闪身冲拳(0.5分)—弹踢穿顶(0.5分)—掼拳戳脚(0.5分)—闪身砍推(0.5分)—收势(0.5分)。', + 'total_score' => '6', + 'choice_state' => 0 + ], + [ + 'name' => '健身南拳套路', + 'proportion' => '1', + 'value' => '3.5', + 'proportion_value' => null, + 'unit' => '积分', + 'type' => '2', + 'describe' => '武术 2 个项目的总分均为6分,其中,动作质量5分、演练水平 1分。起势(0.5分)—架桥双砸拳(0.5分)—缠桥切掌(0.5分)—麒麟步双蝶掌(1分)—踩腿撞拳(0.5分)—挡桥冲拳(0.5分)—闪身虎爪(0.5分)—上步抽拳(0.5分)—架桥双砸拳(0.5分)。', + 'total_score' => '6', + 'choice_state' => 0 + ], + [ + 'name' => '100米游泳', + 'proportion' => '1', + 'value' => '3:05', + 'proportion_value' => null, + 'unit' => '分/秒', + 'type' => '4', + 'describe' => '参加游泳项目考试时,考生穿着泳装、佩戴泳帽参加考试,泳装款式应符合中学生身份。不得使用任何有利于其速度、浮力、耐力的器材或泳衣,但可戴游泳镜。', + 'total_score' => '6', + 'choice_state' => 0 + ] + ] + ] + ] + ], + [ + 'name' => '过程性考核', + 'key' => '过程性考核', + 'list' => [ + [ + 'name' => '8 年级体质健康统测', + 'key' => '8 年级体质健康统测', + 'is_choice' => '0', + 'list' => [ + [ + 'name' => 'BMI', + 'proportion' => '0.15', + 'value' => '25.3', + 'proportion_value' => null, + 'unit' => '千克/米㎡', + 'type' => '2', + 'describe' => '请参考国家学生体质健康标准高中标准', + 'total_score' => '10' + ], + [ + 'name' => '肺活量', + 'proportion' => '0.15', + 'value' => '2000', + 'proportion_value' => null, + 'unit' => '毫升', + 'type' => '1', + 'describe' => '请参考国家学生体质健康标准高中标准', + 'total_score' => '10' + ], + [ + 'name' => '50米跑', + 'proportion' => '0.2', + 'value' => '9.9', + 'proportion_value' => null, + 'unit' => '秒', + 'type' => '2', + 'describe' => '请参考国家学生体质健康标准高中标准', + 'total_score' => '10' + ], + [ + 'name' => '坐位体前屈', + 'proportion' => '0.1', + 'value' => '-1.4', + 'proportion_value' => null, + 'unit' => '厘米', + 'type' => '2', + 'describe' => '请参考国家学生体质健康标准高中标准', + 'total_score' => '10' + ], + [ + 'name' => '立定跳远', + 'proportion' => '0.1', + 'value' => '170', + 'proportion_value' => null, + 'unit' => '厘米', + 'type' => '1', + 'describe' => '请参考国家学生体质健康标准高中标准', + 'total_score' => '10' + ], + [ + 'name' => '引体向上', + 'proportion' => '0.1', + 'value' => '5', + 'proportion_value' => null, + 'unit' => '次', + 'type' => '1', + 'describe' => '请参考国家学生体质健康标准高中标准', + 'total_score' => '10' + ], + [ + 'name' => '1000米跑', + 'proportion' => '0.2', + 'value' => '5:05', + 'proportion_value' => null, + 'unit' => '分/秒', + 'type' => '4', + 'describe' => '请参考国家学生体质健康标准高中标准', + 'total_score' => '10' + ] + ] + ], + [ + 'name' => '8 年级体育与健康知识', + 'key' => '8 年级体育与健康知识', + 'is_choice' => '0', + 'list' => [ + [ + 'name' => '机考', + 'proportion' => '1', + 'value' => '0.0', + 'proportion_value' => null, + 'unit' => '分数', + 'type' => '2', + 'describe' => '机考为8年级体育与健康知识,满分10分。', + 'total_score' => '10' + ] + ] + ] + ] + ] + ]; + + + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + ################################################################接口################################################################ + ################################################################接口################################################################ + ################################################################接口################################################################ + + // 获取地区类型列表 + public function sportstesting_get_region_list(){ + $data = input('post.'); + try { + + if(!array_key_exists('gender', $data) || !array_key_exists('parameter_data', $data)){ + return $this->msg(10001); + } + if(!$this->verify_data_is_ok($data['parameter_data'],'str')){ + return $this->msg(10005); + } + if(!$this->verify_data_is_ok($data['gender'],'intnum')){ + return $this->msg(10005); + } + // if(!$this->verify_data_is_ok($data['choice_last_time'],'intnum')){ + // return $this->msg(10005); + // }else{ + // if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ + // return $this->msg(10005); + // } + // } + $return_data = $this->sportstesting_get_region_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); + } + + } + + // 计算并存储数据 + public function sportstesting_set_once_data(){ + $data = input('post.'); + + // $data['result_data'] = $this->ceshi_data; + try { + + + // $data['result_data'] = json_decode($this->ceshiyongde_data_baocun_canshu,true)['data']; + if(!array_key_exists('aud_id', $data) || !array_key_exists('parameter_data', $data) || !array_key_exists('result_data', $data) || !array_key_exists('gender', $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['parameter_data'],'str')){ + return $this->msg(10005); + } + if(!$this->verify_data_is_ok($data['gender'],'intnum')){ + return $this->msg(10005); + } + if(is_array($data['result_data']) && !empty($data['result_data'])){ + // 是个数组且不为空数组 + foreach ($data['result_data'] as $key => $value) { + foreach ($value['list'] as $k => $v) { + if(count($v['list']) <= 0){ + return $this->msg(10010,$v['name'].'内并未选择内容'); + } + if($v['is_choice'] >= 0 && count($v['list']) < $v['is_choice']){ + return $this->msg(10010,$v['name'].'内并缺少选项,请选择'.$v['is_choice'].'个选项'); + } + foreach ($v['list'] as $c_k => $c_v) { + if(count($c_v) <= 0){ + return $this->msg(10010,$v['name'].'选项内内容异常'); + } + } + } + } + }else{ + return $this->msg(10006); + } + // die; + unset($data['token']); + // dump($data); + // die; + $return_data = $this->sportstesting_set_once_data_action2($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); + } + + + } + + + + + ################################################################业务################################################################ + + ################################################sportstesting_get_region_list + public function sportstesting_get_region_list_action($data){ + + $parameter_data = explode(',',$data['parameter_data']); + $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 + $result = false; + // if($data['choice_last_time'] == 1){ + + // $last_tiame_data = Db::table($this->sportstesting_use_db_name['tc_jilu'])->where(['aud_id'=>$data['aud_id'],'address'=>$data['parameter_data']])->order('id desc')->find(); + // if($last_tiame_data){ + // $result = json_decode($last_tiame_data['content'],true); + // }else{ + // $result = false; + // } + // } + + if($result === false){ + $rule_data = Db::table($this->sportstesting_use_db_name['tc_biaozhun'])->where($db_condition)->select(); + if(count($rule_data) > 0){ + if(count($rule_data) > 1){ + // 查到不止一条规则 + return $this->msg(10004,'查询地址不够详细,请重新选择省市地区'); + } + $rule_data = json_decode($rule_data[0]['content'],true); + $result = $this->handle_default_rule_list($rule_data,$gender); + }else{ + return $this->msg(10004,'暂无该地区的估分规则,请选择其它地区'); + } + } + + return $this->msg($result); + } + + public function sportstesting_set_once_data_action2($data){ + + $return_result['total_score'] = 0; + $return_result['max_score'] = 0; + + $parameter_data = explode(',',$data['parameter_data']); + $gender = $data['gender']; + if(count($parameter_data) == 1){ + // $db_condition = "province = '".$parameter_data[0]."'"; + $db_condition = "province = '".$parameter_data[0]."'"; + }else if(count($parameter_data) == 2){ + // $db_condition = "province = '".$parameter_data[0]."' and city = '".$parameter_data[1]."'"; + $db_condition = "province = '".$parameter_data[0]."'"; + }else if(count($parameter_data) == 3){ + // $db_condition = "province = '".$parameter_data[0]."' and city = '".$parameter_data[1]."' and area = '".$parameter_data[2]."'"; + $db_condition = "province = '".$parameter_data[0]."'"; + }else{ + return $this->msg(10005); + } + // 只根据省查找,全省一个标准 + $find_data = Db::table($this->sportstesting_use_db_name['tc_biaozhun'])->where($db_condition)->find(); + // dump($find_data); + // die; + $find_data = json_decode($find_data['content'],true); + $recognition_rule = $find_data[$gender]; + + foreach ($data['result_data'] as $key => $value) { + // 遍历一级($value['key'] = 现场考试) + foreach ($value['list'] as $k2 => $v2) { + // 遍历二级级($v2['key'] = 第一类项目 + foreach ($v2['list'] as $k3 => $v3) { + // 遍历二级级($v3['name'] = 1000米跑) + $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3); + $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result; + // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")"; + if(array_key_exists('choice_state',$v3) && $v3['choice_state'] == 0){ + continue; + } + $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2); + $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2); + // if(array_key_exists('choice_state',$v3)){ + // if($v3['choice_state'] == 1){ + + // $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3); + // $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result; + // // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")"; + // $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2); + // $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2); + // }else{ + // $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3); + // $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result; + // // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")"; + // $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2); + // $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2); + // } + // }else{ + + // $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3); + // $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result; + // // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")"; + // $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2); + // $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2); + // } + + } + } + } + + $return_result['list'] = $data['result_data']; + $user_sportstesting_set = Db::table($this->sportstesting_use_db_name['tc_jilu'])->insert([ + 'aud_id'=>$data['aud_id'], + 'content'=>json_encode($return_result['list']), + 'score'=>$return_result['total_score'], + 'max_score'=>$return_result['max_score'], + 'create_time'=>date('Y-m-d H:i:s'), + 'address'=>$data['parameter_data'], + ]); + // $user_sportstesting_set = true; + if($user_sportstesting_set){ + foreach ($return_result['list'] as $key => $value) { + foreach ($value['list'] as $v1k => $v1v) { + for( $i=0; $i < count($v1v['list']); $i++ ){ + + if(array_key_exists('choice_state',$v1v['list'][$i]) && $v1v['list'][$i]['choice_state'] == 0){ + + unset($return_result['list'][$key]['list'][$v1k]['list'][$i]); + } + } + array_unshift($return_result['list'][$key]['list'][$v1k]['list'],[ + 'name'=>'项目名', + 'value'=>'成绩', + 'total_score'=>'满分', + 'proportion_value'=>'得分', + ]); + } + } + return $this->msg($return_result); + }else{ + return $this->msg(10002); + } + + } + + + + + + + + + // 处理默认规则列表 + public function handle_default_rule_list($data,$gender){ + if($gender == 1){ + $temporary_arr = $data[$gender]; + }else{ + $temporary_arr = $data[2]; + } + + $result = []; + foreach ($temporary_arr as $key => $value) { + + $num = array_push($result,['name'=>$key,'key'=>$key,'list'=>[]]); + + foreach ($value as $s_c_k => $s_c_v) { + if($s_c_v['choose_num'] == 0){ + // 如果是必选项 + $num2 = array_push($result[$num-1]['list'],[ + 'name'=>$s_c_k, + 'key'=>$s_c_k, + 'is_choice'=>$s_c_v['choose_num'], + 'list'=>[] + ]); + foreach ($s_c_v['list'] as $x_m_k => $x_m_v) { + array_push($result[$num-1]['list'][$num2-1]['list'],[ + 'name'=>$x_m_k, + 'proportion'=>$x_m_v['proportion'], + 'value'=>$x_m_v['value'], + 'proportion_value'=>null, + 'unit'=>$x_m_v['unit_data'], + 'type'=>$x_m_v['type'], + 'describe'=>$x_m_v['describe'], + 'total_score'=>$x_m_v['score'], + ]); + } + }else{ + // 如果不是必选项 + $num2 = array_push($result[$num-1]['list'],[ + 'name'=>$s_c_k."(".count($s_c_v['list'])."选".$s_c_v['choose_num'].")", + 'key'=>$s_c_k, + 'is_choice'=>$s_c_v['choose_num'], + 'list'=>[] + ]); + $choice_state_num = $s_c_v['choose_num']; + foreach ($s_c_v['list'] as $x_m_k => $x_m_v) { + array_push($result[$num-1]['list'][$num2-1]['list'],[ + 'name'=>$x_m_k, + 'proportion'=>$x_m_v['proportion'], + 'value'=>$x_m_v['value'], + 'proportion_value'=>null, + 'unit'=>$x_m_v['unit_data'], + 'type'=>$x_m_v['type'], + 'describe'=>$x_m_v['describe'], + 'total_score'=>$x_m_v['score'], + 'choice_state'=>$choice_state_num > 0?1:0, + ]); + $choice_state_num = $choice_state_num-1; + } + } + } + } + return $result; + } + + + // 取得成绩 + public function obtaining_grades($rule,$data){ + + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + if($data['value'] != '' && $data['value'] != null && $data['value'] != '0' && $data['value'] != '0.0' && $data['value'] != '0.0' && $data['value'] != '0:00'){ + if(count($rule) > 0){ + foreach ($rule as $key => $value) { + if($data['unit'] == '分/秒'){ + $rule_result = $this->convertMinutesSecondsToStringSeconds($value[0]); + $data_result = $this->convertMinutesSecondsToStringSeconds($data['value']); + }else{ + $rule_result = $value[0]; + $data_result = $data['value']; + } + + switch ($value[1]) { + case "<=": + $result = $data_result <= $rule_result; + break; + case ">=": + $result = $data_result >= $rule_result; + break; + case "<": + $result = $data_result < $rule_result; + break; + case ">": + $result = $data_result > $rule_result; + break; + case "==": + $result = $data_result == $rule_result; + break; + case "!=": + $result = $data_result != $rule_result; + break; + default: + // 如果比较符号不是上述任何一个,可以抛出一个异常或错误 + throw new Exception("Unsupported comparison operator: " . $value[1]); + } + if($result == true){ + // 判断是不是0分 + if($data_result == 0){ + $data['score'] = 0; + }else{ + $data['score'] = $value[2]; + } + + // 计算比例后分值 + $proportional_post_score = bcmul($data['total_score'],$data['proportion'],2); + $data['proportion_value'] = bcmul($data['score'],bcdiv($proportional_post_score,100,2),2); + // 四舍五入一下结果 + $data['proportion_value'] = $this->roundToString($data['proportion_value'],1); + break; + } + } + }else{ + $data['score'] = $data['value'] <= $data['total_score']?bcmul(bcdiv($data['value'],$data['total_score'],20),100,2):100; + // 计算比例后分值 + $data['proportion_value'] = $data['value'] <= $data['total_score']?$data['value']:$data['total_score']; + } + + }else{ + $data['score'] = 0; + // 计算比例后分值 + $proportional_post_score = bcmul($data['total_score'],$data['proportion'],2); + $data['proportion_value'] = bcmul($data['score'],bcdiv($proportional_post_score,100,2),1); + } + + return $data; + } + + + + + +} \ No newline at end of file diff --git a/application/NewReedaw/controller/app/Userbody.php b/application/NewReedaw/controller/app/Userbody.php index a1b1ff2..52e43ad 100644 --- a/application/NewReedaw/controller/app/Userbody.php +++ b/application/NewReedaw/controller/app/Userbody.php @@ -54,6 +54,14 @@ class Userbody extends Base{ "description"=>"人体纵向部分的长度,源于人体的纵向生长,受遗传因素的影响较大", "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/height.png", + 'list' => [ + '异常' => '#ff0004', + '矮' => '#FD5759', + '偏矮' => '#FAAD01', + '标准' => '#5BD068', + '偏高' => '#6793F4', + '高' => '#3D67D3' + ], 'standard_list' => [ ['min_val'=>'0','max_val'=>'','text'=>'矮','color'=>'#FD5759'], ['min_val'=>'','max_val'=>'','text'=>'偏矮','color'=>'#FAAD01'], @@ -69,6 +77,14 @@ class Userbody extends Base{ "description"=>"体重指人体的重量,通常用斤、公斤或磅作为单位来衡量。体重是人体健康的重要指标,但需要结合身高、体型和体脂率等因素来综合评估。", "smart_tip_description"=>"保持均衡营养的饮食,摄入足够的碳水化合物、蛋白质、脂肪等。适度进行运动,保持良好的生活习惯。", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/weight.png", + 'list' => [ + '异常' => '#ff0004', + '低' => '#F8595D', + '偏低' => '#FFAF04', + '标准' => '#59D168', + '偏高' => '#FFAF04', + '高' => '#F8595D' + ], 'standard_list' => [ ['min_val'=>'0','max_val'=>'','text'=>'低','color'=>'#F8595D'], ['min_val'=>'','max_val'=>'','text'=>'偏低','color'=>'#FFAF04'], @@ -84,6 +100,13 @@ class Userbody extends Base{ "description"=>"BMI是身体质量指数(BodyMasslndex)的缩写,是一种常用的衡量人体肥胖程度的指标", "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/bmi10.png", + 'list' => [ + '异常' => '#ff0004', + '消瘦' => '#FDDA6B', + '正常' => '#5BD068', + '偏重' => '#FAAD01', + '肥胖' => '#FD5759' + ], 'standard_list' => [ ['min_val'=>'0','max_val'=>'','text'=>'消瘦','color'=>'#FDDA6B'], ['min_val'=>'','max_val'=>'','text'=>'正常','color'=>'#5BD068'], @@ -99,6 +122,7 @@ class Userbody extends Base{ "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/fat_r.png", 'list' => [ + '异常' => '#ff0004', '偏低' => '#FCDB67', '标准' => '#58D268', '偏高' => '#FCAA00', @@ -143,6 +167,7 @@ class Userbody extends Base{ "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/fat_w.png", 'list' => [ + '异常' => '#ff0004', '偏低' => '#FCDB67', '标准' => '#58D268', '偏高' => '#FCAA00', @@ -187,6 +212,7 @@ class Userbody extends Base{ "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/muscle.png", 'list' => [ + '异常' => '#ff0004', '不足' => '#FFDA68', '标准' => '#59CD6F', '优' => '#3C64D4' @@ -212,6 +238,7 @@ class Userbody extends Base{ "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/muscleval.png", 'list' => [ + '异常' => '#ff0004', '不足' => '#FFDA68', '标准' => '#59CD6F', '优' => '#3C64D4' @@ -237,6 +264,7 @@ class Userbody extends Base{ "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/water.png", 'list' => [ + '异常' => '#ff0004', '不足' => '#FED966', '标准' => '#58CF6B', '优' => '#3A68D7' @@ -262,6 +290,7 @@ class Userbody extends Base{ "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/bone.png", 'list' => [ + '异常' => '#ff0004', '不足' => '#FED966', '标准' => '#58CF6F', '优' => '#3A68D7' @@ -311,6 +340,7 @@ class Userbody extends Base{ "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/protein.png", 'list' => [ + '异常' => '#ff0004', '不足' => '#FED966', '标准' => '#58CF6F', '优' => '#3A68D7' @@ -336,6 +366,7 @@ class Userbody extends Base{ "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/proteinval.png", 'list' => [ + '异常' => '#ff0004', '不足' => '#FED966', '标准' => '#58CF6F', '优' => '#3A68D7' @@ -361,6 +392,7 @@ class Userbody extends Base{ "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/visceral.png", 'list' => [ + '异常' => '#ff0004', '标准' => '#55CF6C', '警惕' => '#FEAC00', '危险' => '#FB5A52' @@ -386,6 +418,7 @@ class Userbody extends Base{ "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/sfr.png", 'list' => [ + '异常' => '#ff0004', '不足' => '#FCDB68', '标准' => '#59D16F', '偏高' => '#FEAB03' @@ -490,6 +523,7 @@ class Userbody extends Base{ "smart_tip_description"=>"", "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/ideal_bmi.png", 'list' => [ + '异常' => '#ff0004', '偏低' => '#FF5656', '优' => '#3A68D4' ], @@ -655,7 +689,7 @@ class Userbody extends Base{ // 获取角色报告(简要) public function body_report_brief(){ $data = input('post.'); - try { + // try { if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){ return $this->msg(10001); } @@ -666,20 +700,20 @@ class Userbody extends Base{ return $this->msg(10005,'aud_id type error'); } return $this->body_report_brief_action($data); - } catch (\Exception $e) { - // 捕获异常 - $logContent["flie"] = $e->getFile(); - $logContent["line"] = $e->getLine(); - $logContent['all_content'] = "异常信息:\n"; - $logContent['all_content'] .= "函数: body_report_brief" . "\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'] .= "函数: body_report_brief" . "\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 body_report_detailed(){ @@ -713,7 +747,7 @@ class Userbody extends Base{ // 获取角色报告(深度) public function body_report_depth(){ $data = input('post.'); - try { + // try { if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){ return $this->msg(10001); } @@ -724,20 +758,20 @@ class Userbody extends Base{ return $this->msg(10005,'aud_id type error'); } return $this->body_report_depth_action($data); - } catch (\Exception $e) { - // 捕获异常 - $logContent["flie"] = $e->getFile(); - $logContent["line"] = $e->getLine(); - $logContent['all_content'] = "异常信息:\n"; - $logContent['all_content'] .= "函数: body_report_detailed" . "\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'] .= "函数: body_report_detailed" . "\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 set_target_weight(){ @@ -983,6 +1017,10 @@ class Userbody extends Base{ } $db_data['head_circumference'] = $data['head_data']; } + + + + $send_data['adc'] = 550; $send_data['head'] = $data['head_data']; @@ -1056,6 +1094,8 @@ class Userbody extends Base{ $send_data['adc'] = 550; $db_data['record_type'] = 'by_device'; } + }else{ + return $this->msg(10001); } if(array_key_exists('lefthand', $data) && array_key_exists('righthand', $data) && array_key_exists('leftfoot', $data) && array_key_exists('rightfoot', $data)){ // 发送请求获取照良那边的身体数据 @@ -1083,6 +1123,15 @@ class Userbody extends Base{ $db_data['body_age'] = $get_body_value['bodyage']; $db_data['8_electrode_data'] = json_encode($get_body_value); }else{ + // 判断头围数据是否存在是否合理 + if(array_key_exists('head_data', $data)){ + if(!$this->verify_data_is_ok($data['head_data'],'num')){ + return $this->msg(10005); + } + $db_data['head_circumference'] = $data['head_data']; + } + $send_data['head'] = $data['head_data']; + // 发送请求获取照良那边的身体数据 $get_body_value = $this->send_body_data($send_data,'4_electrode'); // 开始设置数据 @@ -1103,6 +1152,38 @@ class Userbody extends Base{ $db_data['body_type'] = $get_body_value['body'];//身体类型 $db_data['body_age'] = $get_body_value['bodyage']; $db_data['4_electrode_data'] = json_encode($get_body_value); + + // 如果年纪小于三岁,处理头围数据star + $standardlist = []; + + if($send_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']); + $db_data['head_circumference_val'] = $db_data['head_circumference']; + $db_data['head_circumference'] = json_encode($standardlist); + } + }else{ + if(array_key_exists('standardlist',$get_body_value)){ + unset($get_body_value['standardlist']); + } + } + // 如果年纪小于三岁,处理头围数据end } if($get_body_value === false){ @@ -1441,6 +1522,7 @@ class Userbody extends Base{ }else{ $temporary_standard_color = $this->judgment_standard_color($body_last_data[$value],$value,$user_data); + // dump($temporary_standard_color); if($temporary_standard_color){ $result_return['card_list'][] = [ @@ -1629,9 +1711,17 @@ class Userbody extends Base{ if(!$body_last_data){ return $this->msg($result_return); } + if($body_last_data['8_electrode_data']){ + $electrode_data_8 = json_decode($body_last_data['8_electrode_data'],true); + }else{ + $electrode_data_8 = []; + } + $user_data['weight'] = $body_last_data['weight']; - $temporary_data_list = $this->judgment_standard_color_detailed($body_last_data['score'],'score',$user_data); + $temporary_data_list_score = $this->judgment_standard_color_detailed($body_last_data['score'],'score',$user_data); + + // 处理顶部用户信息板块 $result_return['user_data'] = [ // 'title_key'=>'user_data', 'title_name'=>'', @@ -1640,360 +1730,346 @@ class Userbody extends Base{ 'gender'=>$user_data['gender'], 'record_time'=>$body_last_data['record_time'], 'age'=>$this->calculate_age($user_data['birthday']), - 'height'=>$body_last_data['height'], - 'weight'=>$body_last_data['weight'], - 'score'=>$temporary_data_list?$temporary_data_list['value']:0, + 'height'=>(float)$body_last_data['height'], + 'weight'=>(float)$body_last_data['weight'], + 'score'=>(float)$temporary_data_list_score?$temporary_data_list_score['value']:0, ]; - // 如果有心率 + // 如果有心率处理心率板块 if($body_last_data['heart_rate']){ - $temporary_data_list = $this->judgment_standard_color_detailed($body_last_data['heart_rate'],'heart_rate',$user_data); + $temporary_data_list_heart_rate = $this->judgment_standard_color_detailed($body_last_data['heart_rate'],'heart_rate',$user_data); $result_return['heart_rate'] = [ // 'title_key'=>'heart_rate', 'title_name'=>'心脏健康', "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/heart_rate.png", - 'value'=>"心率 ".$temporary_data_list['value'], - 'unit'=>$temporary_data_list['unit'], - 'standard'=>$temporary_data_list['standard'], - 'standard_color'=>$temporary_data_list['standard_color'], - 'standard_list'=>$temporary_data_list['standard_list'], - 'offset'=>$temporary_data_list['offset'], + 'value'=>"心率 ".$temporary_data_list_heart_rate['value'], + 'unit'=>$temporary_data_list_heart_rate['unit'], + 'standard'=>$temporary_data_list_heart_rate['standard'], + 'standard_color'=>$temporary_data_list_heart_rate['standard_color'], + 'standard_list'=>$temporary_data_list_heart_rate['standard_list'], + 'offset'=>$temporary_data_list_heart_rate['offset'], ]; }else{ $result_return['heart_rate'] = []; } - $temporary_data_list['weight'] = $this->judgment_standard_color_detailed($body_last_data['weight'],'weight',$user_data); - $temporary_data_list['fat_w'] = $this->judgment_standard_color_detailed($body_last_data['fat_w'],'fat_w',$user_data); - $temporary_data_list['muscleval'] = $this->judgment_standard_color_detailed($body_last_data['muscleval'],'muscleval',$user_data); - $temporary_data_list['proteinval'] = $this->judgment_standard_color_detailed($body_last_data['proteinval'],'proteinval',$user_data); - $temporary_data_list['water'] = $this->judgment_standard_color_detailed($body_last_data['water'],'water',$user_data); - $temporary_data_list['bone'] = $this->judgment_standard_color_detailed($body_last_data['bone'],'bone',$user_data); - // 体重 - if(count($temporary_data_list['weight']['standard_list'])){ - foreach ($temporary_data_list['weight']['standard_list'] as $key => $value) { - if($value['text'] == $temporary_data_list['weight']['standard']){ - $temporary_body_data['weight'][0] = $value['min_val']."~".$value['max_val'].")"; - $temporary_body_data['weight'][1] = ''; - } - } - }else{ - $temporary_body_data['weight'][0] = ''; - $temporary_body_data['weight'][1] = ''; - } - // 脂肪量 - if(count($temporary_data_list['fat_w']['standard_list'])){ - foreach ($temporary_data_list['fat_w']['standard_list'] as $key => $value) { - if($value['text'] == $temporary_data_list['fat_w']['standard']){ - $temporary_body_data['fat_w'][0] = "(".$value['min_val']."~".$value['max_val'].")"; - $temporary_body_data['fat_w'][1] = bcdiv($body_last_data['fat_w'],$body_last_data['weight'],2); - } - } - }else{ - $temporary_body_data['fat_w'][0] = ''; - $temporary_body_data['fat_w'][1] = bcdiv($body_last_data['fat_w'],$body_last_data['weight'],2); - } - // 肌肉量 - // if(count($temporary_data_list['muscleval']['standard_list'])){ - // foreach ($temporary_data_list['muscleval']['standard_list'] as $key => $value) { - // if($value['text'] == $temporary_data_list['muscleval']['standard']){ - // $temporary_body_data['muscleval'][0] = "(".$value['min_val']."~".$value['max_val'].")"; - // $temporary_body_data['muscleval'][1] = bcdiv($body_last_data['muscleval'],$body_last_data['weight'],2); - // } - // } - // }else{ - // $temporary_body_data['muscleval'][0] = ''; - // $temporary_body_data['muscleval'][1] = bcdiv($body_last_data['muscleval'],$body_last_data['weight'],2); - // } - // 蛋白量 - if(count($temporary_data_list['proteinval']['standard_list'])){ - foreach ($temporary_data_list['proteinval']['standard_list'] as $key => $value) { - if($value['text'] == $temporary_data_list['proteinval']['standard']){ - $temporary_body_data['proteinval'][0] = "(".$value['min_val']."~".$value['max_val'].")"; - $temporary_body_data['proteinval'][1] = bcdiv($body_last_data['proteinval'],$body_last_data['weight'],2); - } - } - }else{ - $temporary_body_data['proteinval'][0] = ''; - $temporary_body_data['proteinval'][1] = bcdiv($body_last_data['proteinval'],$body_last_data['weight'],2); - } - // 水分 - if(count($temporary_data_list['water']['standard_list'])){ - foreach ($temporary_data_list['water']['standard_list'] as $key => $value) { - if($value['text'] == $temporary_data_list['water']['standard']){ - $temporary_body_data['water'][0] = "(".$value['min_val']."~".$value['max_val'].")"; - $temporary_body_data['water'][1] = bcdiv($body_last_data['water'],$body_last_data['weight'],2); - } - } - }else{ - $temporary_body_data['water'][0] = ''; - $temporary_body_data['water'][1] = bcdiv($body_last_data['water'],$body_last_data['weight'],2); - } - // 骨重 - // if(count($temporary_data_list['bone']['standard_list'])){ - // foreach ($temporary_data_list['bone']['standard_list'] as $key => $value) { - // if($value['text'] == $temporary_data_list['bone']['standard']){ - // $temporary_body_data['bone'][0] = "(".$value['min_val']."~".$value['max_val'].")"; - // $temporary_body_data['bone'][1] = bcdiv($body_last_data['bone'],$body_last_data['weight'],2); - // } - // } - // }else{ - // $temporary_body_data['bone'][0] = ''; - // $temporary_body_data['bone'][1] = bcdiv($body_last_data['bone'],$body_last_data['weight'],2); - // } - + // 处理身体成分分析板块 + $temporary_data_list_weight = $this->judgment_standard_color_detailed($body_last_data['weight'],'weight',$user_data); + $temporary_data_list_fat_w = $this->judgment_standard_color_detailed($body_last_data['fat_w'],'fat_w',$user_data); + $temporary_data_list_proteinval = $this->judgment_standard_color_detailed($body_last_data['proteinval'],'proteinval',$user_data); + $temporary_data_list_water = $this->judgment_standard_color_detailed($body_last_data['water'],'water',$user_data); // 加 bcadd(,,20) // 减 bcsub(,,20) // 乘 bcmul(,,20) // 除 bcdiv(,,20) + // 设置临时身体成分数据变量 + $temporary_data_list = []; + // 体重获取标准信息以及标准描述 + if(count($temporary_data_list_weight['standard_list'])){ + foreach ($temporary_data_list_weight['standard_list'] as $key => $value) { + if($value['text'] == $temporary_data_list_weight['standard']){ + $temporary_body_data['weight']['standard_arr'] = "(".$value['min_val']."~".$value['max_val'].")"; + $temporary_body_data['weight']['standard_str'] = $value['text']; + } + } + }else{ + $temporary_body_data['weight']['standard_arr'] = ''; + $temporary_body_data['weight']['standard_str'] = ''; + } + // 脂肪量获取标准信息以及体重占比值 + if(count($temporary_data_list_fat_w['standard_list'])){ + foreach ($temporary_data_list_fat_w['standard_list'] as $key => $value) { + if($value['text'] == $temporary_data_list_fat_w['standard']){ + $temporary_body_data['fat_w']['standard_arr'] = "(".$value['min_val']."~".$value['max_val'].")"; + $temporary_body_data['fat_w']['standard_str'] = bcdiv($body_last_data['fat_w'],$body_last_data['weight'],2); + } + } + }else{ + $temporary_body_data['fat_w']['standard_arr'] = ''; + $temporary_body_data['fat_w']['standard_str'] = bcdiv($body_last_data['fat_w'],$body_last_data['weight'],2); + } + // 蛋白量获取标准信息以及体重占比值 + if(count($temporary_data_list_proteinval['standard_list'])){ + foreach ($temporary_data_list_proteinval['standard_list'] as $key => $value) { + if($value['text'] == $temporary_data_list_proteinval['standard']){ + $temporary_body_data['proteinval']['standard_arr'] = "(".$value['min_val']."~".$value['max_val'].")"; + $temporary_body_data['proteinval']['standard_str'] = bcdiv($body_last_data['proteinval'],$body_last_data['weight'],2); + } + } + }else{ + $temporary_body_data['proteinval']['standard_arr'] = ''; + $temporary_body_data['proteinval']['standard_str'] = bcdiv($body_last_data['proteinval'],$body_last_data['weight'],2); + } + // 水分获取标准信息以及体重占比值 + if(count($temporary_data_list_water['standard_list'])){ + foreach ($temporary_data_list_water['standard_list'] as $key => $value) { + if($value['text'] == $temporary_data_list_water['standard']){ + $temporary_body_data['water']['standard_arr'] = "(".$value['min_val']."~".$value['max_val'].")"; + $temporary_body_data['water']['standard_str'] = bcdiv($body_last_data['water'],$body_last_data['weight'],2); + } + } + }else{ + $temporary_body_data['water']['standard_arr'] = ''; + $temporary_body_data['water']['standard_str'] = bcdiv($body_last_data['water'],$body_last_data['weight'],2); + } $result_return['body_data'] = [ - // 'title_key'=>'body_data', 'title_name'=>'身体成分分析', "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/body_data.png", - "title"=>"体重(".$temporary_body_data['weight'][0]."", - 'standard'=>$temporary_data_list['weight']['standard'] == ''?'':$temporary_data_list['weight']['standard'], + "title"=>"体重".$temporary_body_data['weight']['standard_arr'], + 'standard'=>$temporary_body_data['weight']['standard_str'] == ''?'':$temporary_body_data['weight']['standard_str'], "description"=>"*总体重=体水分量+蛋白质量+脂肪量+其他", 'list'=>[ - ['color'=>'#3E7AF6','name'=>'体水分量','scope'=>$temporary_body_data['water'][0],'value'=>$body_last_data['water'],'offset'=>$temporary_body_data['water'][1]], - ['color'=>'#FFB119','name'=>'蛋白质量','scope'=>$temporary_body_data['proteinval'][0],'value'=>$body_last_data['proteinval'],'offset'=>$temporary_body_data['proteinval'][1]], - ['color'=>'#31D4F5','name'=>'脂肪量','scope'=>$temporary_body_data['fat_w'][0],'value'=>$body_last_data['fat_w'],'offset'=>$temporary_body_data['fat_w'][1]], + ['color'=>'#3E7AF6','name'=>'体水分量','scope'=>$temporary_body_data['water']['standard_arr'],'value'=>(float)$body_last_data['water'],'offset'=>$temporary_body_data['water']['standard_str']], + ['color'=>'#FFB119','name'=>'蛋白质量','scope'=>$temporary_body_data['proteinval']['standard_arr'],'value'=>(float)$body_last_data['proteinval'],'offset'=>$temporary_body_data['proteinval']['standard_str']], + ['color'=>'#31D4F5','name'=>'脂肪量','scope'=>$temporary_body_data['fat_w']['standard_arr'],'value'=>(float)$body_last_data['fat_w'],'offset'=>$temporary_body_data['fat_w']['standard_str']], // ['color'=>'#E749F5','name'=>'肌肉量','scope'=>$temporary_body_data['muscleval'][0],'value'=>$body_last_data['muscleval'],'offset'=>$temporary_body_data['muscleval'][1]], // ['color'=>'#1EA04A','name'=>'骨重','scope'=>$temporary_body_data['bone'][0],'value'=>$body_last_data['bone'],'offset'=>$temporary_body_data['bone'][1]], - [ - 'color'=>'#999999', - 'name'=>'其他', - 'scope'=>"", - 'value'=>'', - 'offset'=>'', - ], + ['color'=>'#999999','name'=>'其他','scope'=>"",'value'=>'','offset'=>bcsub(bcsub(bcsub(100,$temporary_body_data['water']['standard_str'],20),$temporary_body_data['proteinval']['standard_str'],20),$temporary_body_data['fat_w']['standard_str'],2)], ], - 'value'=>$body_last_data['weight'], - 'unit'=>$temporary_data_list['weight']['unit'], + 'value'=>(float)$body_last_data['weight'], + 'unit'=>$temporary_data_list_weight['unit'], ]; - //肌肉脂肪分析 + + + // 处理肌肉脂肪分析 + $temporary_data_list_muscleval = $this->judgment_standard_color_detailed($body_last_data['muscleval'],'muscleval',$user_data); $result_return['muscle_fat'] = [ - // 'title_key'=>'muscle_fat', 'title_name'=>'肌肉脂肪分析', "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/muscle_fat.png", - // "title"=>$temporary_body_data['weight'][0], - 'list'=>[ - [ - 'name'=>'体重', - 'unit'=>'kg', - 'description'=>$this->merged_data['weight']['description'], - 'smart_tip_description'=>'', - 'icon'=>'', - 'list'=>$this->merged_data['weight']['standard_list'], - 'standard_list'=>[ - ['min_val'=>'0','max_val'=>'20','text'=>'低','color'=>'#F8595D'], - ['min_val'=>'20','max_val'=>'40','text'=>'偏低','color'=>'#FFAF04'], - ['min_val'=>'40','max_val'=>'60','text'=>'标准','color'=>'#59D168'], - ['min_val'=>'60','max_val'=>'80','text'=>'偏高','color'=>'#FFAF04'], - ['min_val'=>'80','max_val'=>'100','text'=>'高','color'=>'#F8595D'], - ], - 'key_name'=>'weight', - 'value'=>50, - 'standard'=>'标准', - 'standard_color'=>'#59D168', - 'offset'=>'50', - ], - [ - 'name'=>'骨骼肌量(kg)', - 'unit'=>'kg', - 'description'=>$this->merged_data['weight']['description'], - 'smart_tip_description'=>'', - 'icon'=>'', - 'list'=>$this->merged_data['weight']['standard_list'], - 'standard_list'=>[ - ['min_val'=>'0','max_val'=>'20','text'=>'低','color'=>'#F8595D'], - ['min_val'=>'20','max_val'=>'40','text'=>'偏低','color'=>'#FFAF04'], - ['min_val'=>'40','max_val'=>'60','text'=>'标准','color'=>'#59D168'], - ['min_val'=>'60','max_val'=>'80','text'=>'偏高','color'=>'#FFAF04'], - ['min_val'=>'80','max_val'=>'100','text'=>'高','color'=>'#F8595D'], - ], - 'key_name'=>'weight', - 'value'=>45, - 'standard'=>'标准', - 'standard_color'=>'#59D168', - 'offset'=>'45', - ], - [ - 'name'=>'脂肪量', - 'unit'=>'kg', - 'description'=>$this->merged_data['weight']['description'], - 'smart_tip_description'=>'', - 'icon'=>'', - 'list'=>$this->merged_data['weight']['standard_list'], - 'standard_list'=>[ - ['min_val'=>'0','max_val'=>'20','text'=>'低','color'=>'#F8595D'], - ['min_val'=>'20','max_val'=>'40','text'=>'偏低','color'=>'#FFAF04'], - ['min_val'=>'40','max_val'=>'60','text'=>'标准','color'=>'#59D168'], - ['min_val'=>'60','max_val'=>'80','text'=>'偏高','color'=>'#FFAF04'], - ['min_val'=>'80','max_val'=>'100','text'=>'高','color'=>'#F8595D'], - ], - 'key_name'=>'weight', - 'value'=>70, - 'standard'=>'偏高', - 'standard_color'=>'#FFAF04', - 'offset'=>'70', - ] - ], + 'list'=>[], ]; + $result_return['muscle_fat']['list'][] = $temporary_data_list_weight; + $result_return['muscle_fat']['list'][] = $temporary_data_list_muscleval; + $result_return['muscle_fat']['list'][] = $temporary_data_list_fat_w; + foreach ($result_return['muscle_fat']['list'] as $key => $value) { + $result_return['muscle_fat']['list'][$key]['list'] = $value['standard_list']; + } + //肌肉脂肪分析 + // $ceshi = [ + // // 'title_key'=>'muscle_fat', + // 'title_name'=>'肌肉脂肪分析', + // "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/muscle_fat.png", + // // "title"=>$temporary_body_data['weight'][0], + // 'list'=>[ + // [ + // 'name'=>'体重', + // 'unit'=>'kg', + // 'description'=>$this->merged_data['weight']['description'], + // 'smart_tip_description'=>'', + // 'icon'=>'', + // 'list'=>$this->merged_data['weight']['standard_list'], + // 'standard_list'=>[ + // ['min_val'=>'0','max_val'=>'20','text'=>'低','color'=>'#F8595D'], + // ['min_val'=>'20','max_val'=>'40','text'=>'偏低','color'=>'#FFAF04'], + // ['min_val'=>'40','max_val'=>'60','text'=>'标准','color'=>'#59D168'], + // ['min_val'=>'60','max_val'=>'80','text'=>'偏高','color'=>'#FFAF04'], + // ['min_val'=>'80','max_val'=>'100','text'=>'高','color'=>'#F8595D'], + // ], + // 'key_name'=>'weight', + // 'value'=>50, + // 'standard'=>'标准', + // 'standard_color'=>'#59D168', + // 'offset'=>'50', + // ], + // [ + // 'name'=>'骨骼肌量(kg)', + // 'unit'=>'kg', + // 'description'=>$this->merged_data['weight']['description'], + // 'smart_tip_description'=>'', + // 'icon'=>'', + // 'list'=>$this->merged_data['weight']['standard_list'], + // 'standard_list'=>[ + // ['min_val'=>'0','max_val'=>'20','text'=>'低','color'=>'#F8595D'], + // ['min_val'=>'20','max_val'=>'40','text'=>'偏低','color'=>'#FFAF04'], + // ['min_val'=>'40','max_val'=>'60','text'=>'标准','color'=>'#59D168'], + // ['min_val'=>'60','max_val'=>'80','text'=>'偏高','color'=>'#FFAF04'], + // ['min_val'=>'80','max_val'=>'100','text'=>'高','color'=>'#F8595D'], + // ], + // 'key_name'=>'weight', + // 'value'=>45, + // 'standard'=>'标准', + // 'standard_color'=>'#59D168', + // 'offset'=>'45', + // ], + // [ + // 'name'=>'脂肪量', + // 'unit'=>'kg', + // 'description'=>$this->merged_data['weight']['description'], + // 'smart_tip_description'=>'', + // 'icon'=>'', + // 'list'=>$this->merged_data['weight']['standard_list'], + // 'standard_list'=>[ + // ['min_val'=>'0','max_val'=>'20','text'=>'低','color'=>'#F8595D'], + // ['min_val'=>'20','max_val'=>'40','text'=>'偏低','color'=>'#FFAF04'], + // ['min_val'=>'40','max_val'=>'60','text'=>'标准','color'=>'#59D168'], + // ['min_val'=>'60','max_val'=>'80','text'=>'偏高','color'=>'#FFAF04'], + // ['min_val'=>'80','max_val'=>'100','text'=>'高','color'=>'#F8595D'], + // ], + // 'key_name'=>'weight', + // 'value'=>70, + // 'standard'=>'偏高', + // 'standard_color'=>'#FFAF04', + // 'offset'=>'70', + // ] + // ], + // ]; + + // return $this->msg(['a'=>$result_return['muscle_fat'],'b'=>$ceshi]); + + // 处理节段脂肪分析(如果是8电极才有) + // return $this->msg($electrode_data_8); + if(count($electrode_data_8) > 0){ + $result_return['segment_fat'] = [ + // 'title_key'=>'segment_fat', + 'title_name'=>'节段脂肪分析', + "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/segment_fat.png", + "bg_img"=>"https://tc.pcxbc.com/new_reedaw/icon/segment_fat".$user_data['gender'].".png", + 'list'=>[ + [ + 'name'=>'L:', + 'value'=>$electrode_data_8['bodyfatkgleftarm'],//左手脂肪量,kg + 'unit'=>'kg', + 'value2'=>$electrode_data_8['bodyfatrateleftarm'],//左手脂肪率,% + 'unit2'=>'%', + ], + [ + 'name'=>'R:', + 'value'=>$electrode_data_8['bodyfatkgrightarm'],//右手脂肪量,kg + 'unit'=>'kg', + 'value'=>$electrode_data_8['bodyfatraterightarm'],//右手脂肪率,% + 'unit'=>'%', + ], + [ + 'name'=>'B:', + 'value'=>$electrode_data_8['bodyfatkgtrunk'],//躯干脂肪量,kg + 'unit'=>'kg', + 'value'=>$electrode_data_8['bodyfatraterunk'],//躯干脂肪率,% + 'unit'=>'%', + ], + [ + 'name'=>'L:', + 'value'=>$electrode_data_8['bodyfatkgleftleg'],//左脚脂肪量,kg + 'unit'=>'kg', + 'value'=>$electrode_data_8['bodyfatrateleftleg'],//左脚脂肪率,% + 'unit'=>'%', + ], + [ + 'name'=>'R:', + 'value'=>$electrode_data_8['bodyfatkgrightleg'],//右脚脂肪量,kg + 'unit'=>'kg', + 'value'=>$electrode_data_8['bodyfatraterightleg'],//右脚脂肪率,% + 'unit'=>'%', + ], + ], + ]; - // 节段脂肪分析 - $result_return['segment_fat'] = [ - // 'title_key'=>'segment_fat', - 'title_name'=>'节段脂肪分析', - "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/segment_fat.png", - "bg_img"=>"https://tc.pcxbc.com/new_reedaw/icon/segment_fat".$user_data['gender'].".png", - 'list'=>[ - [ - 'name'=>'L:', - 'value'=>'1', - 'unit'=>'kg', + // 肌肉平衡 + $result_return['segment_muscle'] = [ + // 'title_key'=>'segment_muscle', + 'title_name'=>'肌肉平衡', + "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/segment_muscle.png", + "bg_img"=>"https://tc.pcxbc.com/new_reedaw/icon/segment_fat".$user_data['gender'].".png", + 'list'=>[ + [ + 'name'=>'L:', + 'value'=>$electrode_data_8['musclekgleftarm'],//左手肌肉量,kg + 'unit'=>'kg', + 'value2'=>$electrode_data_8['musclerateleftarm'],//左手肌肉率,% + 'unit2'=>'%', + ], + [ + 'name'=>'R:', + 'value'=>$electrode_data_8['musclekgrightarm'],//右手肌肉量,kg + 'unit'=>'kg', + 'value'=>$electrode_data_8['muscleraterightarm'],//右手肌肉率,% + 'unit'=>'%', + ], + [ + 'name'=>'B:', + 'value'=>$electrode_data_8['musclekgtrunk'],//躯干肌肉量,kg + 'unit'=>'kg', + 'value'=>$electrode_data_8['muscleratetrunk'],//躯干肌肉率,% + 'unit'=>'%', + ], + [ + 'name'=>'L:', + 'value'=>$electrode_data_8['musclekgleftleg'],//左脚肌肉量,kg + 'unit'=>'kg', + 'value'=>$electrode_data_8['musclerateleftleg'],//左脚肌肉率,% + 'unit'=>'%', + ], + [ + 'name'=>'R:', + 'value'=>$electrode_data_8['musclekgrightleg'],//右脚肌肉量,kg + 'unit'=>'kg', + 'value'=>$electrode_data_8['muscleraterightleg'],//右脚肌肉率,% + 'unit'=>'%', + ], ], - [ - 'name'=>'R:', - 'value'=>'1', - 'unit'=>'kg', - ], - [ - 'name'=>'B:', - 'value'=>'1', - 'unit'=>'kg', - ], - [ - 'name'=>'L:', - 'value'=>'1', - 'unit'=>'kg', - ], - [ - 'name'=>'R:', - 'value'=>'1', - 'unit'=>'kg', - ], - ], - ]; - // 肌肉平衡 - $result_return['segment_muscle'] = [ - // 'title_key'=>'segment_muscle', - 'title_name'=>'肌肉平衡', - "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/segment_fat.png", - "bg_img"=>"https://tc.pcxbc.com/new_reedaw/icon/segment_fat".$user_data['gender'].".png", - 'list'=>[ - [ - 'name'=>'L:', - 'value'=>'1', - 'unit'=>'kg', - ], - [ - 'name'=>'R:', - 'value'=>'1', - 'unit'=>'kg', - ], - [ - 'name'=>'B:', - 'value'=>'1', - 'unit'=>'kg', - ], - [ - 'name'=>'L:', - 'value'=>'1', - 'unit'=>'kg', - ], - [ - 'name'=>'R:', - 'value'=>'1', - 'unit'=>'kg', - ], - ], - ]; - - //肥胖分析 + ]; + } + + + + //处理肥胖分析 + $temporary_data_list_fat_r = $this->judgment_standard_color_detailed($body_last_data['fat_r'],'fat_r',$user_data); + $temporary_data_list_bmi = $this->judgment_standard_color_detailed($body_last_data['bmi'],'bmi',$user_data); + // $temporary_data_list_muscleval = $this->judgment_standard_color_detailed($body_last_data['fat_r'],'fat_r',$user_data); $result_return['fat_analysis'] = [ // 'title_key'=>'fat_analysis', 'title_name'=>'肥胖分析', "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/fat_analysis.png", // "title"=>$temporary_body_data['weight'][0], - 'list'=>[ - [ - 'name'=>'BMI', - 'unit'=>'kg/m²', - 'description'=>$this->merged_data['weight']['description'], - 'smart_tip_description'=>'', - 'icon'=>'', - 'list'=>$this->merged_data['weight']['standard_list'], - 'standard_list'=>[ - ['min_val'=>'0','max_val'=>'20','text'=>'低','color'=>'#F8595D'], - ['min_val'=>'20','max_val'=>'40','text'=>'偏低','color'=>'#FFAF04'], - ['min_val'=>'40','max_val'=>'60','text'=>'标准','color'=>'#59D168'], - ['min_val'=>'60','max_val'=>'80','text'=>'偏高','color'=>'#FFAF04'], - ['min_val'=>'80','max_val'=>'100','text'=>'高','color'=>'#F8595D'], - ], - 'key_name'=>'weight', - 'value'=>70, - 'standard'=>'偏高', - 'standard_color'=>'#FFAF04', - 'offset'=>'70', - ], - [ - 'name'=>'体脂率', - 'unit'=>'%', - 'description'=>$this->merged_data['weight']['description'], - 'smart_tip_description'=>'', - 'icon'=>'', - 'list'=>$this->merged_data['weight']['standard_list'], - 'standard_list'=>[ - ['min_val'=>'0','max_val'=>'20','text'=>'低','color'=>'#F8595D'], - ['min_val'=>'20','max_val'=>'40','text'=>'偏低','color'=>'#FFAF04'], - ['min_val'=>'40','max_val'=>'60','text'=>'标准','color'=>'#59D168'], - ['min_val'=>'60','max_val'=>'80','text'=>'偏高','color'=>'#FFAF04'], - ['min_val'=>'80','max_val'=>'100','text'=>'高','color'=>'#F8595D'], - ], - 'key_name'=>'weight', - 'value'=>50, - 'standard'=>'标准', - 'standard_color'=>'#59D168', - 'offset'=>'50', - ], - [ - 'name'=>'肥胖水平', - 'unit'=>'', - 'description'=>$this->merged_data['weight']['description'], - 'smart_tip_description'=>'', - 'icon'=>'', - 'list'=>$this->merged_data['weight']['standard_list'], - 'standard_list'=>[ - ['min_val'=>'0','max_val'=>'20','text'=>'低','color'=>'#F8595D'], - ['min_val'=>'20','max_val'=>'40','text'=>'偏低','color'=>'#FFAF04'], - ['min_val'=>'40','max_val'=>'60','text'=>'标准','color'=>'#59D168'], - ['min_val'=>'60','max_val'=>'80','text'=>'偏高','color'=>'#FFAF04'], - ['min_val'=>'80','max_val'=>'100','text'=>'高','color'=>'#F8595D'], - ], - 'key_name'=>'weight', - 'value'=>9, - 'standard'=>'低', - 'standard_color'=>'#F8595D', - 'offset'=>'9', - ] - ], + 'list'=>[], ]; + $result_return['fat_analysis']['list'][] = $temporary_data_list_fat_r; + $result_return['fat_analysis']['list'][] = $temporary_data_list_bmi; + foreach ($result_return['fat_analysis']['list'] as $key => $value) { + $result_return['fat_analysis']['list'][$key]['list'] = $value['standard_list']; + } + + //体重控制 - $result_return['weight_controller'] = [ - // 'title_key'=>'weight_controller', - 'title_name'=>'体重控制', - "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/weight_controller.png", - // "title"=>$temporary_body_data['weight'][0], - 'list'=>[ - ['name'=>'数据','value'=>'测量值'], - ['name'=>'标准体重','value'=>'62kg'], - ['name'=>'控制体重','value'=>'-3.5kg'], - ['name'=>'BMR','value'=>'1500kcal'], - ], - ]; - //身体类型 + if($body_last_data['age'] <= 18){ + $month_num = $this->calculateAgeInMonthsWithPrecision($user_data['birthday']); + // dump($month_num); + $standard_weight = Db::table($this->body_db_name['weight']) + ->where("Month <= $month_num AND Sex = ".$user_data['gender']) + ->order('Month desc') + ->field('id,median,Month') + ->find(); + $user_BMR = $this->calculateBMR_BC($body_last_data['age'],$body_last_data['weight'],$user_data['gender']); + $result_return['weight_controller'] = [ + // 'title_key'=>'weight_controller', + 'title_name'=>'体重控制', + "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/weight_controller.png", + // "title"=>$temporary_body_data['weight'][0], + 'list'=>[ + ['name'=>'数据','value'=>'测量值'], + ['name'=>'标准体重','value'=>(float)$standard_weight.'kg'], + ['name'=>'控制体重','value'=>bcsub($standard_weight['median'],$body_last_data['weight'],2).'kg'], + ['name'=>'BMR','value'=>$user_BMR != false?$user_BMR:'异常'], + ], + ]; + }else{ + $standard_weight = $this->calculateStandardWeight($user_data['gender'],$body_last_data['age'],$body_last_data['height']); + $user_BMR = $this->calculateBMR_BC($body_last_data['age'],$body_last_data['weight'],$user_data['gender']); + $result_return['weight_controller'] = [ + 'title_name'=>'体重控制', + "icon"=>"https://tc.pcxbc.com/new_reedaw/icon/weight_controller.png", + // "title"=>$temporary_body_data['weight'][0], + 'list'=>[ + ['name'=>'数据','value'=>'测量值'], + ['name'=>'标准体重','value'=>(float)$standard_weight.'kg'], + ['name'=>'控制体重','value'=>bcsub($standard_weight,$body_last_data['weight'],2).'kg'], + ['name'=>'BMR','value'=>$user_BMR != false?$user_BMR:'异常'], + ], + ]; + } + + //身体类型(这还是假数据,需要根据接口确认正确的box_list以及value) $result_return['body_type'] = [ // 'title_key'=>'body_type', 'title_name'=>'身体类型', @@ -2013,16 +2089,14 @@ class Userbody extends Base{ // "title"=>$temporary_body_data['weight'][0], 'list'=>[ ['name'=>'项目','value'=>'测量值'], - ['name'=>'去脂体重','value'=>'47.6kg'], - ['name'=>'皮下脂肪量','value'=>'15.2kg'], - ['name'=>'身体年龄','value'=>'33'], - ['name'=>'内脏脂肪','value'=>'9'], + ['name'=>'去脂体重','value'=>bcsub($body_last_data['weight'],$body_last_data['fat_w'],2).'kg'], + ['name'=>'皮下脂肪量','value'=>$body_last_data['sfr'].'kg'], + ['name'=>'身体年龄','value'=>$body_last_data['body_age']], + ['name'=>'内脏脂肪','value'=>$body_last_data['visceral']], ], ]; - - return $this->msg($result_return); } public function set_target_weight_action($data){ @@ -2248,293 +2322,8 @@ class Userbody extends Base{ ################################################################工具################################################################ ################################################################工具################################################################ - // // 处理身高体重BMI的标准 - // public function process_hwb_standard_action($birthday,$key_name,$age,$gender_val){ - // $month_num = $this->calculateAgeInMonthsWithPrecision($birthday); - // if($age < $this->age_limit){ - // $result_data = $this->merged_data[$key_name]['standard_list']; - // if($key_name == '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){ - // $result_data[0]['max_val'] = $bhw_date[0]['f1sd']; - // $result_data[0]['max_val'] = $bhw_date[0]['f1sd']; - // $result_data[1]['min_val'] = $bhw_date[0]['f1sd']; - // $result_data[1]['max_val'] = $bhw_date[0]['z1sd']; - // $result_data[2]['min_val'] = $bhw_date[0]['z1sd']; - // $result_data[2]['max_val'] = $bhw_date[0]['z2sd']; - // $result_data[3]['min_val'] = $bhw_date[0]['z2sd']; - // } - // }else if($key_name == '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){ - // $result_data[0]['max_val'] = $bhw_date[0]['f2sd']; - // $result_data[1]['min_val'] = $bhw_date[0]['f2sd']; - // $result_data[1]['max_val'] = $bhw_date[0]['f1sd']; - // $result_data[2]['min_val'] = $bhw_date[0]['f1sd']; - // $result_data[2]['max_val'] = $bhw_date[0]['z1sd']; - // $result_data[3]['min_val'] = $bhw_date[0]['z1sd']; - // $result_data[3]['max_val'] = $bhw_date[0]['z2sd']; - // $result_data[4]['min_val'] = $bhw_date[0]['z2sd']; - // $result_data[4]['max_val'] = $bhw_date[0]['z3sd']; - // } - // }else if($key_name == 'weight'){ - // $bhw_date = Db::table($this->body_db_name['weigh'])->where("Month <= $month_num and Sex = '$gender_val'")->order('Month desc')->limit(1)->select(); - // // dump($bhw_date); - // if($bhw_date){ - // $result_data[0]['max_val'] = $bhw_date[0]['f2sd']; - // $result_data[1]['min_val'] = $bhw_date[0]['f2sd']; - // $result_data[1]['max_val'] = $bhw_date[0]['f1sd']; - // $result_data[2]['min_val'] = $bhw_date[0]['f1sd']; - // $result_data[2]['max_val'] = $bhw_date[0]['z1sd']; - // $result_data[3]['min_val'] = $bhw_date[0]['z1sd']; - // $result_data[3]['max_val'] = $bhw_date[0]['z2sd']; - // $result_data[4]['min_val'] = $bhw_date[0]['z2sd']; - // $result_data[4]['max_val'] = $bhw_date[0]['z3sd']; - // } - // } - // }else{ - // $result_data = []; - // } - // return $result_data; - // } - - // // 处理其他的标注列表 - // public function process_other_standard_action($data,$key_name){ - // if($key_name == 'body_age'){ - // $result_data = [ - // ['min_val'=>'0','max_val'=>$data['age'],'text'=>'年轻','color'=>'#14CBAD'], //淡黄 - // ['min_val'=>$data['age'],'max_val'=>bcadd(bcsub($data['age'],0,2),$data['age'],2),'text'=>'偏大','color'=>'#F53F31'], //绿 - // ]; - // }else if($key_name == 'score'){ - // $result_data = $this->merged_data['score']['standard_list']; - // }else{ - // $gender_val = $data['gender'] == 2?'woman':'man'; - // if($key_name == 'fat_r'){ - // if($data['age'] < 30){ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]['29']; - // }else{ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]['30']; - // } - // }else if($key_name == 'fat_w'){ - // if($data['age'] < 30){ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]['29']; - // }else{ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]['30']; - // } - // $result_data = $this->calculate_new_standard($result_data,$data['weight_val'],$key_name,$data['age'],$gender_val); - // }else if($key_name == 'muscle' || $key_name == 'protein' || $key_name == 'water' || $key_name == 'sfr' || $key_name == 'visceral'){ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]; - // }else if($key_name == 'muscleval' || $key_name == 'proteinval'){ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]; - // $result_data = $this->calculate_new_standard($result_data,$data['weight_val'],$key_name,$data['age'],$gender_val); - // }else if($key_name == 'bone'){ - // if($gender_val == 'man'){ - // if($data['weight_val'] < 60){ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]['60']; - // }else if($data['weight_val'] >= 60 && $data['weight_val'] < 75){ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]['60_75']; - // }else{ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]['75']; - // } - // }else{ - // if($data['weight_val'] < 45){ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]['45']; - // }else if($data['weight_val'] >= 45 && $data['weight_val'] < 60){ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]['45_60']; - // }else{ - // $result_data = $this->merged_data[$key_name]['standard_list'][$gender_val]['60']; - // } - // } - // } - // } - // return $result_data; - // } - - // // 处理特殊落点下的标准值 - // public function process_special_offset_action($val, $list) { - // $return_data['standard'] = ''; - // $return_data['standard_color'] = '#000000'; - // if($val<$list[0]['min_val']){ - // $return_data['standard'] = $list[0]['text']; - // $return_data['standard_color'] = $list[0]['color']; - // return $return_data; - // } - - // if($val>$list[count($list)-1]['max_val']){ - // $return_data['standard'] = $list[count($list)-1]['text']; - // $return_data['standard_color'] = $list[count($list)-1]['color']; - // return $return_data; - // } - // foreach ($list as $key => $value) { - // if($val >= $value['min_val'] && $val <= $value['max_val']){ - // $return_data['standard'] = $value['text']; - // $return_data['standard_color'] = $value['color']; - // break; - // } - // } - // return $return_data; - // } - - // 计算新标准 - public function calculate_new_standard($data,$w,$k,$age=0,$gender='man'){ - $temporary_arr = []; - if($k != 'kcal'){ - foreach ($data as $key => $value) { - array_push($temporary_arr,[ - 'min_val'=>bcmul($w,bcdiv($value['min_val'],100,2),2), - 'max_val'=>bcmul($w,bcdiv($value['max_val'],100,2),2), - 'text'=>$value['text'], - 'color'=>$value['color'] - ]); - } - }else{ - // BMR标准值(男) BMR标准值(女) - // 60.9*体重(kg)-54 61.0*体重(kg)-51 - // 22.7*体重(kg)+495 22.5*体重(kg)+499 - // 17.5*体重(kg)+651 12.2*体重(kg)+746 - // 15.3*体重(kg)+679 14.7*体重(kg)+496 - // 11.6*体重(kg)+879 8.7*体重(kg)+820 - $vv_val = 0; - if($age < 3){ - if($gender == 'man'){ - $vv_val = bcsub(bcmul(60.9,$w,2),54,2); - }else{ - $vv_val = bcsub(bcmul(61.0,$w,2),51,2); - } - }else if($age >= 3 && $age < 10){ - if($gender == 'man'){ - $vv_val = bcadd(bcmul(22.7,$w,2),495,2); - }else{ - $vv_val = bcadd(bcmul(22.5,$w,2),499,2); - } - }else if($age >= 10 && $age < 18){ - if($gender == 'man'){ - $vv_val = bcadd(bcmul(17.5,$w,2),651,2); - }else{ - $vv_val = bcadd(bcmul(12.2,$w,2),746,2); - } - }else if($age >= 18 && $age < 30){ - if($gender == 'man'){ - $vv_val = bcadd(bcmul(15.3,$w,2),679,2); - }else{ - $vv_val = bcadd(bcmul(14.7,$w,2),496,2); - } - }else{ - if($gender == 'man'){ - $vv_val = bcadd(bcmul(11.6,$w,2),879,2); - }else{ - $vv_val = bcadd(bcmul(8.7,$w,2),820,2); - } - } - $data[0]['max_val'] = $vv_val; - $data[1]['min_val'] = $vv_val; - $temporary_arr = $data; - } - return $temporary_arr; - } - - // - // 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->merged_data['height']['standard_list']; - // $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->merged_data['weight']['standard_list']; - // $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->merged_data['bmi']['standard_list']; - // $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; - // } - - // // 处理异常 - // public function handling_exceptions($data){ - // for ($i=0; $i < count($data['list']); $i++) { - // if($data['value']>=$data['list'][$i]['min_val'] && $data['value']<$data['list'][$i]['max_val']){ - // $data['standard'] = $data['list'][$i]['text']; - // $data['color'] = $data['list'][$i]['color']; - // break; - // } - // } - // if($data['standard'] == '异常'){ - // if($data['value'] <= $data['list'][0]['min_val']){ - // $data['standard'] = $data['list'][0]['text']; - // $data['color'] = $data['list'][0]['color']; - // }else if($data['value'] >= $data['list'][count($data['list'])-1]['max_val']){ - // $data['standard'] = $data['list'][count($data['list'])-1]['text']; - // $data['color'] = $data['list'][count($data['list'])-1]['color']; - // } - // } - // return $data; - // } - // 处理一般落点 @@ -3429,6 +3218,136 @@ class Userbody extends Base{ } } + /** + * 根据Broca改良公式计算标准体重参考值 + * @param int $gender 性别: 1=男, 2=女 + * @param int $age 年龄(周岁) + * @param float $height 身高(厘米) + * @return string 标准体重(kg),保留2位小数 + * @throws InvalidArgumentException 当参数无效时抛出异常 + */ + public function calculateStandardWeight($gender, $age, $height) { + // 1. 参数校验 + if (!in_array($gender, [1, 2])) { + return false; + } + if ($age <= 0 || $age > 120) { + return false; + } + if ($height < 50 || $height > 250) { + return false; + } + + // 2. 根据性别和年龄确定系数K + if ($age < 30) { + $k = ($gender === 1) ? '0.90' : '0.85'; // 1=男, 2=女 + } elseif ($age <= 50) { + $k = ($gender === 1) ? '0.88' : '0.82'; + } else { // age > 50 + $k = ($gender === 1) ? '0.86' : '0.80'; + } + + // 3. 使用BC数学函数计算:标准体重 = (身高 - 100) × K + // 身高减去100 + $heightMinus100 = bcsub((string)$height, '100', 20); + + // 乘以系数K + $standardWeight = bcmul($heightMinus100, $k, 2); + + // 4. 格式化为保留2位小数 + return $standardWeight; + } + + /** + * 使用BC数学函数的精确版本 + * @param int $age 年龄(岁),数字类型 + * @param float $weight 体重(kg),数字类型 + * @param int $gender 性别: 1=男, 2=女 + * @return string BMR值(千卡/天),保留2位小数 + */ + function calculateBMR_BC($age, $weight, $gender) { + // 参数校验 + if (!is_numeric($age) || $age < 0 || $age > 100) { + return false; + } + + if (!is_numeric($weight) || $weight <= 0 || $weight > 300) { + return false; + } + + if (!in_array($gender, [1, 2])) { + return false; + } + + $isMale = ($gender === 1); + $weightStr = (string)$weight; + $bmr = '0'; + + // WHO/FAO/UNU公式分段计算(使用BC函数) + if ($age < 3) { + // 0-3岁婴儿 + if ($isMale) { + $temp = bcmul('60.9', $weightStr, 4); + $bmr = bcsub($temp, '54', 2); + } else { + $temp = bcmul('61.0', $weightStr, 4); + $bmr = bcsub($temp, '51', 2); + } + } elseif ($age < 10) { + // 3-10岁儿童 + if ($isMale) { + $temp = bcmul('22.7', $weightStr, 4); + $bmr = bcadd($temp, '495', 2); + } else { + $temp = bcmul('22.5', $weightStr, 4); + $bmr = bcadd($temp, '499', 2); + } + } elseif ($age < 18) { + // 10-18岁青少年 + if ($isMale) { + $temp = bcmul('17.5', $weightStr, 4); + $bmr = bcadd($temp, '651', 2); + } else { + $temp = bcmul('12.2', $weightStr, 4); + $bmr = bcadd($temp, '746', 2); + } + } elseif ($age < 30) { + // 18-30岁成年人 + if ($isMale) { + $temp = bcmul('15.3', $weightStr, 4); + $bmr = bcadd($temp, '679', 2); + } else { + $temp = bcmul('14.7', $weightStr, 4); + $bmr = bcadd($temp, '496', 2); + } + } elseif ($age < 60) { + // 30-60岁中年人 + if ($isMale) { + $temp = bcmul('11.6', $weightStr, 4); + $bmr = bcadd($temp, '879', 2); + } else { + $temp = bcmul('8.7', $weightStr, 4); + $bmr = bcadd($temp, '820', 2); + } + } else { + // 60岁以上老年人 + if ($isMale) { + $temp = bcmul('13.5', $weightStr, 4); + $bmr = bcadd($temp, '487', 2); + } else { + $temp = bcmul('10.5', $weightStr, 4); + $bmr = bcadd($temp, '596', 2); + } + } + + // 确保BMR不为负值 + if (bccomp($bmr, '0', 2) < 0) { + $bmr = '0.00'; + } + + return $bmr; + } + diff --git a/application/NewReedaw/view/app/business/business_cooperation.html b/application/NewReedaw/view/app/business/business_cooperation.html new file mode 100644 index 0000000..886d7f3 --- /dev/null +++ b/application/NewReedaw/view/app/business/business_cooperation.html @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + 商务合作 + + + + + + + +
+
+ +
+
商务合作意向登记表
+
+ 智能设备产品包含身高测量仪、体重体脂秤、宠物秤, 母婴秤,厨房秤,商业秤,身高体重/体脂秤,八电极体脂秤,运动训练设备等;软件包含就智能健康管理系统,智能硬件管理系统等,支持智能设备选购/定制、健康系统对接/定制,行业解决方案等,期待与您合作! +
+
+
+ *  1.客户姓名 +
+
+ +
+
+
+
+ *  2.联系电话 +
+
+ +
+
+
+
+ *  3.公司名称 +
+
+ +
+
+
+
+ *  4.合作意向 +
+
+
+
此题已选择 0/6 项
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+ *  5.备注 +
+
+ +
+
+ + +
+
提交
+
+
+ + + + \ No newline at end of file diff --git a/application/route.php b/application/route.php index 0609356..6dbb6e2 100644 --- a/application/route.php +++ b/application/route.php @@ -975,7 +975,11 @@ Route::any('/reedaw/skip/data_report', 'app/NewReedaw/app.skip/data_report'); 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/sportstesting/sportstesting_get_region_list', 'app/NewReedaw/app.sportstesting/sportstesting_get_region_list'); +// 计算获取结果 +Route::any('/reedaw/sportstesting/sportstesting_set_once_data', 'app/NewReedaw/app.sportstesting/sportstesting_set_once_data'); @@ -1000,6 +1004,11 @@ Route::any('/reedaw/update_my_account_msg', 'app/NewReedaw/app.role/update_my_ac Route::any('/reedaw/update_my_password', 'app/NewReedaw/app.role/update_my_password'); // 修改账号信息 Route::any('/reedaw/set_my_account_msg', 'app/NewReedaw/app.role/set_my_account_msg'); +// 商务合作页面 +Route::any('/reedaw/business_cooperation', 'app/NewReedaw/app.business/business_cooperation'); +// 商务合作提交 +Route::any('/reedaw/business_cooperation_action', 'app/NewReedaw/app.business/business_cooperation_action'); + // https://tc.pcxbc.comreedaw/pdate_my_nickname