2024-09-30 16:52:40 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\app\controller;
|
|
|
|
|
|
|
|
|
|
use think\Db;
|
|
|
|
|
|
|
|
|
|
class Pagingcontrast extends Base{
|
|
|
|
|
|
|
|
|
|
protected $color = ['#FF5656','#FFAB00','#5AD06D','#6492F6','#3967D6'];
|
|
|
|
|
protected $db_name = ['2'=>'app_card_body_data','6'=>'app_card_skip_data','8'=>'app_card_vitalcapacity_data'];
|
2024-11-23 16:46:38 +08:00
|
|
|
protected $pagingcontrast_use_db_name = [
|
|
|
|
|
'1'=>'app_card_body_data',
|
|
|
|
|
'2'=>'app_card_skip_data',
|
|
|
|
|
'3'=>'app_card_vitalcapacity_data',
|
|
|
|
|
'4'=>'app_user_data',
|
|
|
|
|
];
|
2024-09-30 16:52:40 +08:00
|
|
|
protected $request_result = [
|
|
|
|
|
'2'=>['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI',''],'fat_w'=>['脂肪量','kg'],'fat_r'=>['脂肪率','%'],'muscleval'=>['肌肉量','kg'],'muscle'=>['肌肉率','%'],'proteinval'=>['蛋白量','kg'],'protein'=>['蛋白率','%'],'water'=>['水分',''],'bone'=>['骨重','kg'],'visceral'=>['内脏指数',''],'sfr'=>['皮下脂肪','%'],'kcal'=>['基础代谢','kcal'],'un_fat_w_weight'=>['去脂体重','kg'],'body_age'=>['体龄',''],'body_level'=>['肥胖等级',''],'body_type'=>['体型','']],
|
|
|
|
|
'6'=>['jump_num'=>['个数',''],'jump_time'=>['时长',''],'jump_kcal'=>['卡路里','kcal']],
|
|
|
|
|
'8'=>['one_val'=>['第一次','ml'],'two_val'=>['第二次','ml'],'three_val'=>['第三次','ml'],'average_val'=>['三次平均','ml'],'score'=>['最后成绩','分']]
|
|
|
|
|
];
|
|
|
|
|
protected $pagesize = 10;
|
|
|
|
|
################################################请求接口################################################
|
|
|
|
|
################################################请求接口################################################
|
|
|
|
|
################################################请求接口################################################
|
|
|
|
|
// 获取记录信息(分组)(包含身体、跳绳、肺活量)
|
|
|
|
|
public function get_all_record_data_group($data = ['aud_id'=>'26','s_time'=>'2024-04-01','e_time'=>'2024-06-12','token'=>'0dafb98a10995c98b5a33b7d59d986ca','type'=>'6']){
|
2024-11-23 16:46:38 +08:00
|
|
|
try {
|
|
|
|
|
// 你的业务逻辑
|
|
|
|
|
if(count(input('post.')) > 0){
|
|
|
|
|
$data = input('post.');
|
|
|
|
|
}
|
|
|
|
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data) || !array_key_exists('token', $data) || !array_key_exists('type', $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['s_time'],'datetime')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
if(!$this->verify_data_is_ok($data['e_time'],'datetime')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
if(!$this->verify_data_is_ok($data['type'],'intnum')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
unset($data['token']);
|
|
|
|
|
if(array_key_exists($data['type'],$this->db_name)){
|
|
|
|
|
$return_data = $this->jump_transfer_interface_record($data,'group');
|
|
|
|
|
}else{
|
|
|
|
|
$return_data = $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
// 成功
|
|
|
|
|
$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);
|
2024-09-30 16:52:40 +08:00
|
|
|
}
|
2024-11-23 16:46:38 +08:00
|
|
|
|
2024-09-30 16:52:40 +08:00
|
|
|
}
|
|
|
|
|
// 获取记录信息(分页)(包含身体、跳绳、肺活量)
|
|
|
|
|
public function get_all_record_data_page($data = ['aud_id'=>'25','page'=>1,'token'=>'0dafb98a10995c98b5a33b7d59d986ca','type'=>'2']){
|
2024-11-23 16:46:38 +08:00
|
|
|
try {
|
|
|
|
|
// 你的业务逻辑
|
|
|
|
|
if(count(input('post.')) > 0){
|
|
|
|
|
$data = input('post.');
|
|
|
|
|
}
|
|
|
|
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('page', $data) || !array_key_exists('token', $data) || !array_key_exists('type', $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['page'],'num')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
if(!$this->verify_data_is_ok($data['type'],'intnum')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
unset($data['token']);
|
|
|
|
|
if(array_key_exists($data['type'],$this->db_name)){
|
|
|
|
|
$return_data = $this->jump_transfer_interface_record($data,'page');
|
|
|
|
|
}else{
|
|
|
|
|
$return_data = $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
// 成功
|
|
|
|
|
$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);
|
2024-09-30 16:52:40 +08:00
|
|
|
}
|
2024-11-23 16:46:38 +08:00
|
|
|
|
2024-09-30 16:52:40 +08:00
|
|
|
}
|
|
|
|
|
// 获取详细历史数据信息(包含身体、跳绳、肺活量)
|
|
|
|
|
public function get_all_record_detailed_information($data = ['id'=>'39','type'=>'2','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
2024-11-23 16:46:38 +08:00
|
|
|
try {
|
|
|
|
|
// 你的业务逻辑
|
|
|
|
|
if(count(input('post.')) > 0){
|
|
|
|
|
$data = input('post.');
|
|
|
|
|
}
|
|
|
|
|
if(!array_key_exists('id', $data) || !array_key_exists('type', $data) || !array_key_exists('token', $data)){
|
|
|
|
|
return $this->msg(10001);
|
|
|
|
|
}
|
|
|
|
|
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
if(!$this->verify_data_is_ok($data['type'],'intnum')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
unset($data['token']);
|
|
|
|
|
$return_data = $this->jump_transfer_interface_detailed($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);
|
2024-09-30 16:52:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 数据对比(包含身体、跳绳、肺活量)
|
|
|
|
|
public function get_all_card_data_contrast($data = ['before_id'=>'837','after_id'=>'836','type'=>'6','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
2024-11-23 16:46:38 +08:00
|
|
|
try {
|
|
|
|
|
// 你的业务逻辑
|
|
|
|
|
if(count(input('post.')) > 0){
|
|
|
|
|
$data = input('post.');
|
|
|
|
|
}
|
|
|
|
|
if(!array_key_exists('before_id', $data) || !array_key_exists('after_id', $data) || !array_key_exists('type', $data) || !array_key_exists('token', $data)){
|
|
|
|
|
return $this->msg(10001);
|
|
|
|
|
}
|
|
|
|
|
if(!$this->verify_data_is_ok($data['before_id'],'intnum')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
if(!$this->verify_data_is_ok($data['after_id'],'intnum')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
if(!$this->verify_data_is_ok($data['type'],'intnum')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
unset($data['token']);
|
|
|
|
|
$return_data = $this->jump_transfer_interface_data_contrast($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);
|
2024-09-30 16:52:40 +08:00
|
|
|
}
|
2024-11-23 16:46:38 +08:00
|
|
|
|
2024-09-30 16:52:40 +08:00
|
|
|
}
|
|
|
|
|
// 删除历史数据
|
|
|
|
|
public function del_all_record_data($data = ['id'=>'29','type'=>'2','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
2024-11-23 16:46:38 +08:00
|
|
|
try {
|
|
|
|
|
// 你的业务逻辑
|
|
|
|
|
if(count(input('post.')) > 0){
|
|
|
|
|
$data = input('post.');
|
|
|
|
|
}
|
|
|
|
|
if(!array_key_exists('id', $data) || !array_key_exists('type', $data) || !array_key_exists('token', $data)){
|
|
|
|
|
return $this->msg(10001);
|
|
|
|
|
}
|
|
|
|
|
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
if(!$this->verify_data_is_ok($data['type'],'intnum')){
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
}
|
|
|
|
|
unset($data['token']);
|
|
|
|
|
$user_data = Db::table($this->db_name[$data['type']])->where(['id'=>$data['id']])->update(['is_del'=>1]);
|
|
|
|
|
if($user_data){
|
|
|
|
|
$return_data = $this->msg([]);
|
|
|
|
|
}else{
|
|
|
|
|
$return_data = $this->msg(10002);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 成功
|
|
|
|
|
$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);
|
2024-09-30 16:52:40 +08:00
|
|
|
}
|
2024-11-23 16:46:38 +08:00
|
|
|
|
2024-09-30 16:52:40 +08:00
|
|
|
}
|
|
|
|
|
################################################请求接口################################################
|
|
|
|
|
################################################请求接口################################################
|
|
|
|
|
################################################请求接口################################################
|
|
|
|
|
|
|
|
|
|
public function jump_transfer_interface_record($data,$str){
|
|
|
|
|
if($data['type'] == '2'){
|
|
|
|
|
return $this->get_body_record_data($data,$str);
|
|
|
|
|
}else if($data['type'] == '6'){
|
|
|
|
|
return $this->get_skip_record_data($data,$str);
|
|
|
|
|
}else if($data['type'] == '8'){
|
|
|
|
|
return $this->get_vitalcapacity_record_data($data,$str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public function jump_transfer_interface_detailed($data){
|
|
|
|
|
return $this->get_all_detaile_data_msg($data);
|
|
|
|
|
}
|
|
|
|
|
public function jump_transfer_interface_data_contrast($data){
|
|
|
|
|
if($data['type'] == '2'){
|
|
|
|
|
return $this->get_body_data_contrast($data);
|
|
|
|
|
}else if($data['type'] == '6'){
|
|
|
|
|
return $this->get_skip_data_contrast($data);
|
|
|
|
|
}else if($data['type'] == '8'){
|
|
|
|
|
return $this->get_vitalcapacity_data_contrast($data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
################################################业务部分################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取记录信息列表(分组)-身体
|
|
|
|
|
// 获取记录信息列表(分页)-身体
|
|
|
|
|
public function get_body_record_data($data,$type){
|
|
|
|
|
$return_result = [];
|
|
|
|
|
|
|
|
|
|
if($type == 'group'){
|
|
|
|
|
$data['s_time'] = $data['s_time'].' 00:00:00';
|
|
|
|
|
$data['e_time'] = $data['e_time'].' 23:59:59';
|
|
|
|
|
$result = Db::query("
|
|
|
|
|
select
|
|
|
|
|
id,
|
|
|
|
|
CONVERT(varchar(10), record_time, 120) AS r_t,
|
|
|
|
|
CONVERT(varchar(19), record_time, 120) AS record_time,
|
|
|
|
|
height_val as v1,
|
|
|
|
|
weight_val as v2,
|
|
|
|
|
bmi_val as v3
|
2024-11-23 16:46:38 +08:00
|
|
|
from ".$this->pagingcontrast_use_db_name['1']."
|
2024-09-30 16:52:40 +08:00
|
|
|
where aud_id='".$data['aud_id']."'
|
|
|
|
|
and record_time between '".$data['s_time']."' and '".$data['e_time']."'
|
|
|
|
|
and is_del = 0
|
|
|
|
|
order by record_time desc");
|
|
|
|
|
foreach ($result as $key => $value) {
|
|
|
|
|
array_push($return_result, [
|
|
|
|
|
'id'=>$value['id'],
|
|
|
|
|
'v1'=>$value['v1'],
|
|
|
|
|
'v2'=>$value['v2'],
|
|
|
|
|
'v3'=>$value['v3'],
|
|
|
|
|
'v1_name'=>'身高',
|
|
|
|
|
'v2_name'=>'体重',
|
|
|
|
|
'v3_name'=>'BMI',
|
|
|
|
|
// 'r_t'=>str_replace('-', '/', $value['r_t'])
|
|
|
|
|
'r_t'=>$value['r_t']
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
2024-11-23 16:46:38 +08:00
|
|
|
$result = Db::table($this->pagingcontrast_use_db_name['1'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->field("id,record_time,REPLACE(record_time, '-', '-') AS b_time,height_val,weight_val,bmi_val")->order('record_time desc')->page($data['page'],$this->pagesize)->select();
|
|
|
|
|
$return_result['totalrows'] = Db::table($this->pagingcontrast_use_db_name['1'])->where(['aud_id'=>$data['aud_id']])->count();
|
2024-09-30 16:52:40 +08:00
|
|
|
$return_result['rows'] = [];
|
|
|
|
|
$return_result['pageno'] = $data['page'];
|
|
|
|
|
$return_result['pagesize'] = $this->pagesize;
|
|
|
|
|
$return_result['totalpage'] = ceil($return_result['totalrows']/$this->pagesize);
|
|
|
|
|
foreach ($result as $key => $value) {
|
|
|
|
|
array_push($return_result['rows'],[
|
|
|
|
|
'id'=>$value['id'],
|
|
|
|
|
'v1'=>$value['height_val'],
|
|
|
|
|
'v2'=>$value['weight_val'],
|
|
|
|
|
'v3'=>$value['bmi_val'],
|
|
|
|
|
'v1_name'=>'身高',
|
|
|
|
|
'v2_name'=>'体重',
|
|
|
|
|
'v3_name'=>'BMI',
|
|
|
|
|
'record_time'=>$value['b_time'],
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->msg($return_result);
|
|
|
|
|
}
|
|
|
|
|
// 获取记录信息列表(分组)-跳绳
|
|
|
|
|
// 获取记录信息列表(分页)-跳绳
|
|
|
|
|
public function get_skip_record_data($data,$type){
|
|
|
|
|
$return_result = [];
|
|
|
|
|
|
|
|
|
|
if($type == 'group'){
|
|
|
|
|
$data['s_time'] = $data['s_time'].' 00:00:00';
|
|
|
|
|
$data['e_time'] = $data['e_time'].' 23:59:59';
|
|
|
|
|
$result = Db::query("
|
|
|
|
|
select
|
|
|
|
|
id,
|
|
|
|
|
CONVERT(varchar(10), record_time, 120) AS r_t,
|
|
|
|
|
CONVERT(varchar(19), record_time, 120) AS record_time,
|
|
|
|
|
jump_num as v1,
|
|
|
|
|
jump_time as v2,
|
|
|
|
|
jump_kcal as v3
|
2024-11-23 16:46:38 +08:00
|
|
|
from ".$this->pagingcontrast_use_db_name['2']."
|
2024-09-30 16:52:40 +08:00
|
|
|
where aud_id='".$data['aud_id']."'
|
|
|
|
|
and record_time between '".$data['s_time']."' and '".$data['e_time']."'
|
|
|
|
|
and is_del = 0
|
|
|
|
|
order by record_time desc");
|
|
|
|
|
foreach ($result as $key => $value) {
|
|
|
|
|
$time_t = $this->handle_hour_branch_second($value['v2']);
|
|
|
|
|
array_push($return_result, [
|
|
|
|
|
'id'=>$value['id'],
|
|
|
|
|
'v1'=>$value['v1'],
|
|
|
|
|
'v2'=>$time_t['h'].':'.$time_t['m'].':'.$time_t['s'],
|
|
|
|
|
'v3'=>$value['v3'],
|
|
|
|
|
'v1_name'=>'个数',
|
|
|
|
|
'v2_name'=>'时长',
|
|
|
|
|
'v3_name'=>'卡路里',
|
|
|
|
|
// 'r_t'=>str_replace('-', '/', $value['r_t'])
|
|
|
|
|
'r_t'=>$value['r_t']
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
2024-11-23 16:46:38 +08:00
|
|
|
$result = Db::table($this->pagingcontrast_use_db_name['2'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->field("id,record_time,REPLACE(record_time, '-', '-') AS b_time,jump_num,jump_time,jump_kcal")->order('record_time desc')->page($data['page'],$this->pagesize)->select();
|
|
|
|
|
$return_result['totalrows'] = Db::table($this->pagingcontrast_use_db_name['2'])->where(['aud_id'=>$data['aud_id']])->count();
|
2024-09-30 16:52:40 +08:00
|
|
|
$return_result['rows'] = [];
|
|
|
|
|
$return_result['pageno'] = $data['page'];
|
|
|
|
|
$return_result['pagesize'] = $this->pagesize;
|
|
|
|
|
$return_result['totalpage'] = ceil($return_result['totalrows']/$this->pagesize);
|
|
|
|
|
foreach ($result as $key => $value) {
|
|
|
|
|
$time_t = $this->handle_hour_branch_second($value['jump_time']);
|
|
|
|
|
array_push($return_result['rows'],[
|
|
|
|
|
'id'=>$value['id'],
|
|
|
|
|
'v1'=>$value['jump_num'],
|
|
|
|
|
'v2'=>$time_t['h'].':'.$time_t['m'].':'.$time_t['s'],
|
|
|
|
|
'v3'=>$value['jump_kcal'],
|
|
|
|
|
'v1_name'=>'个数',
|
|
|
|
|
'v2_name'=>'时长',
|
|
|
|
|
'v3_name'=>'卡路里',
|
|
|
|
|
'record_time'=>$value['b_time'],
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->msg($return_result);
|
|
|
|
|
}
|
|
|
|
|
// 获取记录信息列表(分组)-肺活量
|
|
|
|
|
// 获取记录信息列表(分页)-肺活量
|
|
|
|
|
public function get_vitalcapacity_record_data($data,$type){
|
|
|
|
|
$return_result = [];
|
|
|
|
|
|
|
|
|
|
if($type == 'group'){
|
|
|
|
|
$data['s_time'] = $data['s_time'].' 00:00:00';
|
|
|
|
|
$data['e_time'] = $data['e_time'].' 23:59:59';
|
|
|
|
|
$result = Db::query("
|
|
|
|
|
select
|
|
|
|
|
id,
|
|
|
|
|
CONVERT(varchar(10), record_time, 120) AS r_t,
|
|
|
|
|
CONVERT(varchar(19), record_time, 120) AS record_time,
|
|
|
|
|
one_val as v1,
|
|
|
|
|
two_val as v2,
|
|
|
|
|
three_val as v3,
|
|
|
|
|
average_val as v4,
|
|
|
|
|
score as v5
|
2024-11-23 16:46:38 +08:00
|
|
|
from ".$this->pagingcontrast_use_db_name['3']."
|
2024-09-30 16:52:40 +08:00
|
|
|
where aud_id='".$data['aud_id']."'
|
|
|
|
|
and record_time between '".$data['s_time']."' and '".$data['e_time']."'
|
|
|
|
|
and is_del = 0
|
|
|
|
|
order by record_time desc");
|
|
|
|
|
foreach ($result as $key => $value) {
|
|
|
|
|
// $time_t = $this->handle_hour_branch_second($value['v2']);
|
|
|
|
|
array_push($return_result, [
|
|
|
|
|
'id'=>$value['id'],
|
|
|
|
|
'v1'=>$value['v1'],
|
|
|
|
|
'v2'=>$value['v2'],
|
|
|
|
|
'v3'=>$value['v3'],
|
|
|
|
|
'v4'=>$value['v4'],
|
|
|
|
|
'v5'=>explode(',',$value['v5'])[0],
|
|
|
|
|
'v1_name'=>'第一次',
|
|
|
|
|
'v2_name'=>'第二次',
|
|
|
|
|
'v3_name'=>'第三次',
|
|
|
|
|
'v4_name'=>'平均',
|
|
|
|
|
'v5_name'=>'成绩',
|
|
|
|
|
// 'r_t'=>str_replace('-', '/', $value['r_t'])
|
|
|
|
|
'r_t'=>$value['r_t']
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
2024-11-23 16:46:38 +08:00
|
|
|
$result = Db::table($this->pagingcontrast_use_db_name['3'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->field("id,record_time,REPLACE(record_time, '-', '-') AS b_time,one_val,two_val,three_val,average_val,score")->order('record_time desc')->page($data['page'],$this->pagesize)->select();
|
|
|
|
|
$return_result['totalrows'] = Db::table($this->pagingcontrast_use_db_name['3'])->where(['aud_id'=>$data['aud_id']])->count();
|
2024-09-30 16:52:40 +08:00
|
|
|
$return_result['rows'] = [];
|
|
|
|
|
$return_result['pageno'] = $data['page'];
|
|
|
|
|
$return_result['pagesize'] = $this->pagesize;
|
|
|
|
|
$return_result['totalpage'] = ceil($return_result['totalrows']/$this->pagesize);
|
|
|
|
|
foreach ($result as $key => $value) {
|
|
|
|
|
// $time_t = $this->handle_hour_branch_second($value['jump_time']);
|
|
|
|
|
array_push($return_result['rows'],[
|
|
|
|
|
'id'=>$value['id'],
|
|
|
|
|
'v1'=>$value['one_val'],
|
|
|
|
|
'v2'=>$value['two_val'],
|
|
|
|
|
'v3'=>$value['three_val'],
|
|
|
|
|
'v4'=>$value['average_val'],
|
|
|
|
|
'v5'=>explode(',',$value['score'])[0],
|
|
|
|
|
'v1_name'=>'第一次',
|
|
|
|
|
'v2_name'=>'第二次',
|
|
|
|
|
'v3_name'=>'第三次',
|
|
|
|
|
'v4_name'=>'平均',
|
|
|
|
|
'v5_name'=>'成绩',
|
|
|
|
|
'record_time'=>$value['b_time']
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->msg($return_result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取详细历史数据信息
|
|
|
|
|
public function get_all_detaile_data_msg($data){
|
|
|
|
|
$result = Db::table($this->db_name[$data['type']])->where(['id'=>$data['id']])->find();
|
|
|
|
|
if($result){
|
|
|
|
|
$result_data = [];
|
|
|
|
|
foreach ($this->request_result[$data['type']] as $key => $value) {
|
|
|
|
|
$temporary_arr['key_name'] = $key;
|
|
|
|
|
$temporary_arr['name'] = $value[0];
|
|
|
|
|
if($data['type'] == 2){
|
|
|
|
|
if($key == 'un_fat_w_weight'){
|
|
|
|
|
$temporary_arr['value'] = bcsub(explode(',',$result['weight'])[0],explode(',',$result['fat_w'])[0],2);
|
|
|
|
|
}else{
|
|
|
|
|
$temporary_arr['value'] = explode(',',$result[$key])[0];
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
$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(10004);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 数据对比
|
|
|
|
|
public function get_body_data_contrast($data){
|
|
|
|
|
$data2 = [$data['before_id'],$data['after_id']];
|
|
|
|
|
$data3 = implode(',',$data2);
|
|
|
|
|
$calculate_arr = [];
|
|
|
|
|
$result = Db::query("
|
|
|
|
|
select
|
|
|
|
|
acbd.id,
|
|
|
|
|
acbd.height,
|
|
|
|
|
acbd.weight,
|
|
|
|
|
acbd.bmi,
|
|
|
|
|
acbd.fat_r,
|
|
|
|
|
acbd.fat_w,
|
|
|
|
|
acbd.muscle,
|
|
|
|
|
acbd.muscleval,
|
|
|
|
|
acbd.water,
|
|
|
|
|
acbd.proteinval,
|
|
|
|
|
acbd.bone,
|
|
|
|
|
acbd.protein,
|
|
|
|
|
acbd.kcal,
|
|
|
|
|
acbd.visceral,
|
|
|
|
|
acbd.sfr,
|
|
|
|
|
acbd.record_time,
|
|
|
|
|
REPLACE(CONVERT(varchar(10), acbd.record_time, 23), '-', '-') AS b_time,
|
|
|
|
|
aud.nickname,
|
|
|
|
|
aud.gender,
|
|
|
|
|
aud.birthday,
|
|
|
|
|
aud.head_pic
|
2024-11-23 16:46:38 +08:00
|
|
|
from ".$this->pagingcontrast_use_db_name['1']." as acbd
|
|
|
|
|
left join ".$this->pagingcontrast_use_db_name['4']." as aud on acbd.aud_id=aud.id
|
2024-09-30 16:52:40 +08:00
|
|
|
where acbd.id in ($data3)
|
|
|
|
|
and acbd.is_del = 0
|
|
|
|
|
");
|
|
|
|
|
if(!$result || count($result)<2){
|
|
|
|
|
return $this->msg(10004);
|
|
|
|
|
}
|
|
|
|
|
// 调整顺序
|
|
|
|
|
foreach ($result as $key => $value) {
|
|
|
|
|
if($value['id'] == $data2[0]){
|
|
|
|
|
$calculate_arr['before'] = $value;
|
|
|
|
|
}else{
|
|
|
|
|
$calculate_arr['after'] = $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$return_data['time'] = $calculate_arr['before']['b_time'].'-'.$calculate_arr['after']['b_time'];
|
|
|
|
|
$return_data['headimg'] = $calculate_arr['before']['head_pic'];
|
|
|
|
|
$return_data['name'] = $calculate_arr['before']['nickname'];
|
|
|
|
|
$return_data['gender'] = $calculate_arr['before']['gender'];
|
|
|
|
|
$return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
|
|
|
|
|
$return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
|
|
|
|
|
|
|
|
|
|
$return_data['list'] = [];
|
|
|
|
|
|
|
|
|
|
foreach ($calculate_arr['before'] as $key => $value) {
|
|
|
|
|
if(in_array($key, ['height','weight','bmi','fat_r','fat_w','muscle','muscleval','water','proteinval','bone','protein','kcal','visceral','sfr'])){
|
|
|
|
|
$before_arr = explode(',', $value);
|
|
|
|
|
$after_arr = explode(',', $calculate_arr['after'][$key]);
|
|
|
|
|
// $calculate_arr['before'][$key] = explode(',', $value);
|
|
|
|
|
|
|
|
|
|
array_push($return_data['list'], [
|
|
|
|
|
'firstresult'=>[
|
|
|
|
|
'color'=>'',
|
|
|
|
|
'level'=>$before_arr[1],
|
|
|
|
|
'value'=>$before_arr[0],
|
|
|
|
|
'title'=>$this->request_result['2'][$key][0],
|
|
|
|
|
'unit'=>$this->request_result['2'][$key][1],
|
|
|
|
|
'name'=>$key,
|
|
|
|
|
],
|
|
|
|
|
'secondresult'=>[
|
|
|
|
|
'color'=>'',
|
|
|
|
|
'level'=>$after_arr[1],
|
|
|
|
|
'value'=>$after_arr[0],
|
|
|
|
|
'title'=>$this->request_result['2'][$key][0],
|
|
|
|
|
'unit'=>$this->request_result['2'][$key][1],
|
|
|
|
|
'name'=>$key,
|
|
|
|
|
],
|
|
|
|
|
'diffval'=>bcsub($after_arr[0],$before_arr[0],2),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->msg($return_data);
|
|
|
|
|
}
|
|
|
|
|
// 数据对比
|
|
|
|
|
public function get_skip_data_contrast($data){
|
|
|
|
|
$data2 = [$data['before_id'],$data['after_id']];
|
|
|
|
|
$data3 = implode(',',$data2);
|
|
|
|
|
$calculate_arr = [];
|
|
|
|
|
$result = Db::query("
|
|
|
|
|
select
|
|
|
|
|
acsd.id,
|
|
|
|
|
acsd.jump_num,
|
|
|
|
|
acsd.jump_time,
|
|
|
|
|
acsd.jump_kcal,
|
|
|
|
|
acsd.record_time,
|
|
|
|
|
REPLACE(CONVERT(varchar(10), acsd.record_time, 23), '-', '-') AS b_time,
|
|
|
|
|
aud.nickname,
|
|
|
|
|
aud.gender,
|
|
|
|
|
aud.birthday,
|
|
|
|
|
aud.head_pic
|
2024-11-23 16:46:38 +08:00
|
|
|
from ".$this->pagingcontrast_use_db_name['2']." as acsd
|
|
|
|
|
left join ".$this->pagingcontrast_use_db_name['4']." as aud on acsd.aud_id=aud.id
|
2024-09-30 16:52:40 +08:00
|
|
|
where acsd.id in ($data3)
|
|
|
|
|
and acsd.is_del = 0
|
|
|
|
|
");
|
|
|
|
|
|
|
|
|
|
if(!$result || count($result)<2){
|
|
|
|
|
return $this->msg(10004);
|
|
|
|
|
}
|
|
|
|
|
// 调整顺序
|
|
|
|
|
foreach ($result as $key => $value) {
|
|
|
|
|
if($value['id'] == $data2[0]){
|
|
|
|
|
$calculate_arr['before'] = $value;
|
|
|
|
|
}else{
|
|
|
|
|
$calculate_arr['after'] = $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$return_data['time'] = $calculate_arr['before']['b_time'].'-'.$calculate_arr['after']['b_time'];
|
|
|
|
|
$return_data['headimg'] = $calculate_arr['before']['head_pic'];
|
|
|
|
|
$return_data['name'] = $calculate_arr['before']['nickname'];
|
|
|
|
|
$return_data['gender'] = $calculate_arr['before']['gender'];
|
|
|
|
|
$return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
|
|
|
|
|
$return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
|
|
|
|
|
|
|
|
|
|
$return_data['list'] = [];
|
|
|
|
|
foreach ($calculate_arr['before'] as $key => $value) {
|
|
|
|
|
if(in_array($key, ['jump_num','jump_time','jump_kcal'])){
|
|
|
|
|
$before_arr = $value;
|
|
|
|
|
$after_arr = $calculate_arr['after'][$key];
|
|
|
|
|
$temporary_arr = [
|
|
|
|
|
'firstresult'=>[
|
|
|
|
|
'color'=>'',
|
|
|
|
|
'level'=>'',
|
|
|
|
|
'value'=>$key=='jump_time'?implode(':',$this->handle_hour_branch_second($before_arr)):$before_arr,
|
|
|
|
|
'title'=>$this->request_result['6'][$key][0],
|
|
|
|
|
'unit'=>$this->request_result['6'][$key][1],
|
|
|
|
|
'name'=>$key,
|
|
|
|
|
],
|
|
|
|
|
'secondresult'=>[
|
|
|
|
|
'color'=>'',
|
|
|
|
|
'level'=>'',
|
|
|
|
|
'value'=>$key=='jump_time'?implode(':',$this->handle_hour_branch_second($after_arr)):$after_arr,
|
|
|
|
|
'title'=>$this->request_result['6'][$key][0],
|
|
|
|
|
'unit'=>$this->request_result['6'][$key][1],
|
|
|
|
|
'name'=>$key,
|
|
|
|
|
],
|
|
|
|
|
'diffval'=>bcsub($after_arr,$before_arr,2)
|
|
|
|
|
];
|
|
|
|
|
if($key=='jump_time'){
|
|
|
|
|
$temporary_arr['diffval'] = $temporary_arr['diffval'] >= 0?implode(':',$this->handle_hour_branch_second($temporary_arr['diffval'])):'-'.implode(':',$this->handle_hour_branch_second($temporary_arr['diffval']));
|
|
|
|
|
}
|
|
|
|
|
array_push($return_data['list'], $temporary_arr);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return $this->msg($return_data);
|
|
|
|
|
}
|
|
|
|
|
// 数据对比
|
|
|
|
|
public function get_vitalcapacity_data_contrast($data){
|
|
|
|
|
$data2 = [$data['before_id'],$data['after_id']];
|
|
|
|
|
$data3 = implode(',',$data2);
|
|
|
|
|
$calculate_arr = [];
|
|
|
|
|
$result = Db::query("
|
|
|
|
|
select
|
|
|
|
|
acsd.id,
|
|
|
|
|
acsd.one_val,
|
|
|
|
|
acsd.two_val,
|
|
|
|
|
acsd.three_val,
|
|
|
|
|
acsd.average_val,
|
|
|
|
|
acsd.score_val as score,
|
|
|
|
|
acsd.record_time,
|
|
|
|
|
REPLACE(CONVERT(varchar(10), acsd.record_time, 23), '-', '-') AS b_time,
|
|
|
|
|
aud.nickname,
|
|
|
|
|
aud.gender,
|
|
|
|
|
aud.birthday,
|
|
|
|
|
aud.head_pic
|
2024-11-23 16:46:38 +08:00
|
|
|
from ".$this->pagingcontrast_use_db_name['3']." as acsd
|
|
|
|
|
left join ".$this->pagingcontrast_use_db_name['4']." as aud on acsd.aud_id=aud.id
|
2024-09-30 16:52:40 +08:00
|
|
|
where acsd.id in ($data3)
|
|
|
|
|
and acsd.is_del = 0
|
|
|
|
|
");
|
|
|
|
|
|
|
|
|
|
if(!$result || count($result)<2){
|
|
|
|
|
return $this->msg(10004);
|
|
|
|
|
}
|
|
|
|
|
// 调整顺序
|
|
|
|
|
foreach ($result as $key => $value) {
|
|
|
|
|
if($value['id'] == $data2[0]){
|
|
|
|
|
$calculate_arr['before'] = $value;
|
|
|
|
|
}else{
|
|
|
|
|
$calculate_arr['after'] = $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$return_data['time'] = $calculate_arr['before']['b_time'].'-'.$calculate_arr['after']['b_time'];
|
|
|
|
|
$return_data['headimg'] = $calculate_arr['before']['head_pic'];
|
|
|
|
|
$return_data['name'] = $calculate_arr['before']['nickname'];
|
|
|
|
|
$return_data['gender'] = $calculate_arr['before']['gender'];
|
|
|
|
|
$return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
|
|
|
|
|
$return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
|
|
|
|
|
|
|
|
|
|
$return_data['list'] = [];
|
|
|
|
|
foreach ($calculate_arr['before'] as $key => $value) {
|
|
|
|
|
if(in_array($key, ['one_val','two_val','three_val','average_val','score_val'])){
|
|
|
|
|
$before_arr = $value;
|
|
|
|
|
$after_arr = $calculate_arr['after'][$key];
|
|
|
|
|
$temporary_arr = [
|
|
|
|
|
'firstresult'=>[
|
|
|
|
|
'color'=>'',
|
|
|
|
|
'level'=>'',
|
|
|
|
|
'value'=>$before_arr,
|
|
|
|
|
'title'=>$this->request_result['8'][$key][0],
|
|
|
|
|
'unit'=>$this->request_result['8'][$key][1],
|
|
|
|
|
'name'=>$key,
|
|
|
|
|
],
|
|
|
|
|
'secondresult'=>[
|
|
|
|
|
'color'=>'',
|
|
|
|
|
'level'=>'',
|
|
|
|
|
'value'=>$after_arr,
|
|
|
|
|
'title'=>$this->request_result['8'][$key][0],
|
|
|
|
|
'unit'=>$this->request_result['8'][$key][1],
|
|
|
|
|
'name'=>$key,
|
|
|
|
|
],
|
|
|
|
|
'diffval'=>bcsub($after_arr,$before_arr,2)
|
|
|
|
|
];
|
|
|
|
|
array_push($return_data['list'], $temporary_arr);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return $this->msg($return_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|