'app_account_number', 'juese'=>'app_user_data', 'body_data'=>'app_card_body_data', 'bmi'=>'pc_bmistand', 'heigh'=>'pc_heightstand', 'weigh'=>'pc_weightstand', 'chufang1'=>'pc_childrenprescription', 'chufang2'=>'pc_childprescriptionbyage', ]; protected $age_limit = 16; protected $pagesize = 15; protected $merged_data = [ 'score' => [ 'name' => '身体得分', 'unit' => '分', 'list' => [] ], 'height' => [ 'name' => '身高', 'unit' => 'cm', 'list' => [] ], 'weight' => [ 'name' => '体重', 'unit' => 'kg', 'list' => [] ], 'bmi' => [ 'name' => 'BMI', 'unit' => '', 'list' => [] ], 'fat_r' => [ 'name' => '脂肪率', 'unit' => '%', 'list' => [ '偏低' => '#FCDB67', '标准' => '#58D268', '偏高' => '#FCAA00', '高' => '#FD5752' ] ], 'fat_w' => [ 'name' => '脂肪量', 'unit' => 'kg', 'list' => [ '偏低' => '#FCDB67', '标准' => '#58D268', '偏高' => '#FCAA00', '高' => '#FD5752' ] ], 'muscle' => [ 'name' => '肌肉率', 'unit' => '%', 'list' => [ '不足' => '#FFDA68', '标准' => '#59CD6F', '优' => '#3C64D4' ] ], 'muscleval' => [ 'name' => '肌肉量', 'unit' => 'kg', 'list' => [ '不足' => '#FFDA68', '标准' => '#59CD6F', '优' => '#3C64D4' ] ], 'water' => [ 'name' => '水分', 'unit' => 'kg', 'list' => [ '不足' => '#FED966', '标准' => '#58CF6B', '优' => '#3A68D7' ] ], 'bone' => [ 'name' => '骨重', 'unit' => 'kg', 'list' => [ '不足' => '#FED966', '标准' => '#58CF6F', '优' => '#3A68D7' ] ], 'protein' => [ 'name' => '蛋白率', 'unit' => '%', 'list' => [ '不足' => '#FED966', '标准' => '#58CF6F', '优' => '#3A68D7' ] ], 'proteinval' => [ 'name' => '蛋白量', 'unit' => 'kg', 'list' => [ '不足' => '#FED966', '标准' => '#58CF6F', '优' => '#3A68D7' ] ], 'kcal' => [ 'name' => '基础代谢', 'unit' => 'kcal', 'list' => [ '偏低' => '#FF5656', '优' => '#3A68D4' ] ], 'visceral' => [ 'name' => '内脏指数', 'unit' => '', 'list' => [ '标准' => '#55CF6C', '警惕' => '#FEAC00', '危险' => '#FB5A52' ] ], 'sfr' => [ 'name' => '皮下脂肪', 'unit' => '%', 'list' => [ '不足' => '#FCDB68', '标准' => '#59D16F', '偏高' => '#FEAB03' ] ], 'body_level' => [ 'name' => '肥胖等级', 'unit' => '', 'list' => [] ], 'body_type' => [ 'name' => '身体类型', 'unit' => '', 'list' => [] ], 'body_age' => [ 'name' => '身体年龄', 'unit' => '岁', 'list' => [] ] ]; protected $bhw_list = [ 'bmi'=>[ ['min_val'=>'0','max_val'=>'','text'=>'消瘦','color'=>'#FDDA6B'], ['min_val'=>'','max_val'=>'','text'=>'正常','color'=>'#59D06A'], ['min_val'=>'','max_val'=>'','text'=>'偏重','color'=>'#FDAA02'], ['min_val'=>'','max_val'=>'50','text'=>'肥胖','color'=>'#FB5755'], ], 'height'=>[ ['min_val'=>'0','max_val'=>'','text'=>'矮','color'=>'#FD5759'], ['min_val'=>'','max_val'=>'','text'=>'偏矮','color'=>'#FAAD01'], ['min_val'=>'','max_val'=>'','text'=>'标准','color'=>'#5BD068'], ['min_val'=>'','max_val'=>'','text'=>'偏高','color'=>'#6793F4'], ['min_val'=>'','max_val'=>'','text'=>'高','color'=>'#3D67D3'], ], 'weight'=>[ ['min_val'=>'0','max_val'=>'','text'=>'低','color'=>'#F8595D'], ['min_val'=>'','max_val'=>'','text'=>'偏低','color'=>'#FFAF04'], ['min_val'=>'','max_val'=>'','text'=>'标准','color'=>'#59D168'], ['min_val'=>'','max_val'=>'','text'=>'偏高','color'=>'#FFAF04'], ['min_val'=>'','max_val'=>'','text'=>'高','color'=>'#F8595D'], ] ]; protected $card_body_level = [ 'height'=>['value'=>1,'list'=>['矮'=>2,'偏矮'=>3,'标准'=>4,'偏高'=>5,'高'=>5]], 'weight'=>['value'=>3,'list'=>['低'=>1,'偏低'=>1,'标准'=>2,'偏高'=>3,'高'=>3]], 'bmi'=>['value'=>2,'list'=>['消瘦'=>1,'正常'=>2,'偏重'=>3,'肥胖'=>4]], ]; // 加 bcadd(,,20) // 减 bcsub(,,20) // 乘 bcmul(,,20) // 除 bcdiv(,,20) // 测试token=>'caadd1be045a65f30b92aa805f1de54a' ################################################################接口################################################################ ################################################################接口################################################################ ################################################################接口################################################################ // 获取角色报告(简要) public function body_report_brief(){ $data = input('post.'); try { if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){ return $this->msg(10001); } if(!$this->verify_data_is_ok($data['token'],'str')){ return $this->msg(10005,'token type error'); } if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ return $this->msg(10005,'aud_id type error'); } return $this->body_report_brief_action($data); } catch (\Exception $e) { // 捕获异常 $logContent["flie"] = $e->getFile(); $logContent["line"] = $e->getLine(); $logContent['all_content'] = "异常信息:\n"; $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); return $this->msg(99999); } } // 获取角色报告(详细) public function body_report_detailed(){ $data = input('post.'); try { if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){ return $this->msg(10001); } if(!$this->verify_data_is_ok($data['token'],'str')){ return $this->msg(10005,'token type error'); } if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ return $this->msg(10005,'aud_id type error'); } return $this->body_report_detailed_action($data); } catch (\Exception $e) { // 捕获异常 $logContent["flie"] = $e->getFile(); $logContent["line"] = $e->getLine(); $logContent['all_content'] = "异常信息:\n"; $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); return $this->msg(99999); } } ################################################################action################################################################ ################################################################action################################################################ public function body_report_brief_action($data){ $result_return = [ 'weight'=>[ "name"=>"体重", 'time'=>'', "value"=>"0", "unit"=>"kg", "standard"=>"", "standard_color"=>"#77E46C", 'target_weight'=>'0', 'target_weight_unit'=>'kg' ], 'height'=>[ "name"=>"身高", 'time'=>'', "value"=>"0", "unit"=>"cm", "standard"=>"", "standard_color"=>"#FEA63D", ], 'bmi'=>[ "name"=>"BMI", 'time'=>'', "value"=>"0", "unit"=>"", "standard"=>"", "standard_color"=>"#FF8072", ], 'card_list'=>[ ], ]; $body_last_data = Db::query(" select Top 1 acbd.id, acbd.acd_id, acbd.record_type, acbd.create_time, acbd.last_update_time, acbd.score, acbd.fat_r, acbd.fat_w, acbd.muscle, acbd.muscleval, acbd.water, acbd.proteinval, acbd.bone, acbd.protein, acbd.kcal, acbd.visceral, acbd.sfr, acbd.body_level, acbd.aud_id, acbd.record_time, acbd.body_type, acbd.age, acbd.is_del, acbd.height, acbd.height_val, acbd.weight, acbd.weight_val, acbd.bmi, acbd.body_age, acbd.head_circumference, aud.birthday,aud.gender,aud.target_weight,aud.initial_weight,aud.initial_date from ".$this->body_db_name['body_data']." as acbd left join ".$this->body_db_name['juese']." as aud on acbd.aud_id=aud.id where acbd.is_del=0 and acbd.aud_id='".$data['aud_id']."' order by acbd.record_time desc "); if(count($body_last_data) <= 0){ return $this->msg($result_return); } // return $this->msg($body_last_data); $record_time = substr($body_last_data[0]['record_time'], 11, 5); // 处理体重 $temporary_weight = explode(',',$body_last_data[0]['weight']); $result_return['weight']['time'] = $record_time; $result_return['weight']['value'] = $temporary_weight[0]; $result_return['weight']['standard'] = $temporary_weight[1] == '无'?'':$temporary_weight[1]; $result_return['weight']['standard_color'] = $temporary_weight[2] == '无'?'':$temporary_weight[2]; $result_return['weight']['target_weight'] = $body_last_data[0]['target_weight']; // 处理身高 $temporary_height = explode(',',$body_last_data[0]['height']); $result_return['height']['time'] = $record_time; $result_return['height']['value'] = $temporary_height[0]; $result_return['height']['standard'] = $temporary_height[1] == '无'?'':$temporary_height[1]; $result_return['height']['standard_color'] = $temporary_height[2] == '无'?'':$temporary_height[2]; // 处理BMI $temporary_bmi = explode(',',$body_last_data[0]['bmi']); $result_return['bmi']['time'] = $record_time; $result_return['bmi']['value'] = $temporary_bmi[0]; $result_return['bmi']['standard'] = $temporary_bmi[1] == '无'?'':$temporary_bmi[1]; $result_return['bmi']['standard_color'] = $temporary_bmi[2] == '无'?'':$temporary_bmi[2]; // 处理卡片数据 if($body_last_data[0]['record_type'] == 'by_hand_means'){ return $this->msg($result_return); }else{ // 设置卡片顺序 $set_order = [ 'fat_r', //体脂率 'fat_w', //脂肪量 'muscle', //肌肉率 'muscleval', //肌肉量 'protein', //蛋白率 'proteinval', //蛋白量 'water', //水分 'sfr', //皮下脂肪 'body_level', //肥胖等级☆ 'visceral', //内脏指数 'bone', //骨重 'body_type', //身体类型☆ 'score', //身体得分☆ 'body_age', //身体年龄☆ ]; foreach ($set_order as $key => $value) { if($value == 'body_level' || $value == 'body_type' || $value == 'body_age' || $value == 'score'){ // 如果是特殊数据 $result_return['card_list'][] = [ 'name'=>$this->merged_data[$value]['name'], 'icon'=>'', 'value'=>$body_last_data[0][$value], 'unit'=>$this->merged_data[$value]['unit'], 'standard'=>'', 'standard_color'=>'', ]; }else{ // 分割数据 $temporary_data_1 = explode(',',$body_last_data[0][$value]); // 设置默认标准颜色 $standard_color = '#121212'; // 处理标准颜色 if(array_key_exists($temporary_data_1[1],$this->merged_data[$value]['list'])){ $standard_color = $this->merged_data[$value]['list'][$temporary_data_1[1]]; } $result_return['card_list'][] = [ 'name'=>$this->merged_data[$value]['name'], 'icon'=>'', 'value'=>$temporary_data_1[0], 'unit'=>$this->merged_data[$value]['unit'], 'standard'=>$temporary_data_1[1], 'standard_color'=>$standard_color, ]; } } } return $this->msg($result_return); } public function body_report_detailed_action($data){ $result_return = [ 'weight'=>[ "name"=>"体重", 'time'=>'', "value"=>"0", "unit"=>"kg", "standard"=>"", "standard_color"=>"#77E46C", 'target_weight'=>'0', 'target_weight_unit'=>'kg' ], 'height'=>[ "name"=>"身高", 'time'=>'', "value"=>"0", "unit"=>"cm", "standard"=>"", "standard_color"=>"#FEA63D", ], 'bmi'=>[ "name"=>"BMI", 'time'=>'', "value"=>"0", "unit"=>"", "standard"=>"", "standard_color"=>"#FF8072", ], 'card_list'=>[ ], ]; $body_last_data = Db::query(" select Top 1 acbd.id, acbd.acd_id, acbd.record_type, acbd.create_time, acbd.last_update_time, acbd.score, acbd.fat_r, acbd.fat_w, acbd.muscle, acbd.muscleval, acbd.water, acbd.proteinval, acbd.bone, acbd.protein, acbd.kcal, acbd.visceral, acbd.sfr, acbd.body_level, acbd.aud_id, acbd.record_time, acbd.body_type, acbd.age, acbd.is_del, acbd.height, acbd.height_val, acbd.weight, acbd.weight_val, acbd.bmi, acbd.body_age, acbd.head_circumference, aud.birthday,aud.gender,aud.target_weight,aud.initial_weight,aud.initial_date from ".$this->body_db_name['body_data']." as acbd left join ".$this->body_db_name['juese']." as aud on acbd.aud_id=aud.id where acbd.is_del=0 and acbd.aud_id='".$data['aud_id']."' order by acbd.record_time desc "); if(count($body_last_data) <= 0){ return $this->msg($result_return); } // 设置卡片顺序 $set_order = [ 'weight', //体重 '', //心率 '', //BMR 静态基础代谢 'BMI', //BMI 'fat_r', //体脂率 'fat_w', //脂肪量 'muscle', //肌肉率 'muscleval', //肌肉量 'protein', //蛋白率 'proteinval', //蛋白量 'water', //水分 'sfr', //皮下脂肪 'visceral', //内脏指数 'bone', //骨重 'body_type', //身体类型☆ 'body_level', //肥胖等级☆ 'body_age', //身体年龄☆ 'score', //身体得分☆ ]; } ################################################################工具################################################################ ################################################################工具################################################################ public function body_report_brief​_action_tool1($data){ } }