124 lines
5.7 KiB
PHP
124 lines
5.7 KiB
PHP
<?php
|
|
|
|
namespace app\app\controller;
|
|
|
|
use think\Controller;
|
|
use think\Db;
|
|
use \think\Validate;
|
|
use app\app\controller\Calculatebody;
|
|
use app\app\controller\Skip;
|
|
|
|
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'];
|
|
protected $request_name = ['2'=>'get_body_record_data','6'=>'app_card_skip_data','8'=>'app_card_vitalcapacity_data'];
|
|
protected $pagesize = 10;
|
|
|
|
################################################请求接口################################################
|
|
################################################请求接口################################################
|
|
################################################请求接口################################################
|
|
// 获取记录信息(分组)(包含身体、跳绳、肺活量)
|
|
public function get_all_record_data_group($data = ['aud_id'=>'25','s_time'=>'2024-04-01 10:10:10','e_time'=>'2024-06-12 10:10:10','token'=>'0dafb98a10995c98b5a33b7d59d986ca','type'=>'2']){
|
|
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 $this->msg(10001);
|
|
}
|
|
if($this->token_time_validate($data['token']) === false){
|
|
return $this->msg(20001);
|
|
}
|
|
unset($data['token']);
|
|
if(array_key_exists($data['type'],$this->request_name)){
|
|
return $this->jump_transfer_interface($data,'group');
|
|
}else{
|
|
return $this->msg(10005);
|
|
}
|
|
}
|
|
// 获取记录信息(分页)(包含身体、跳绳、肺活量)
|
|
public function get_all_record_data_page($data = ['aud_id'=>'25','page'=>1,'token'=>'0dafb98a10995c98b5a33b7d59d986ca','type'=>'2']){
|
|
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 $this->msg(10001);
|
|
}
|
|
if($this->token_time_validate($data['token']) === false){
|
|
return $this->msg(20001);
|
|
}
|
|
unset($data['token']);
|
|
if(array_key_exists($data['type'],$this->request_name)){
|
|
return $this->jump_transfer_interface($data,'page');
|
|
}else{
|
|
return $this->msg(10005);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
################################################请求接口################################################
|
|
################################################请求接口################################################
|
|
################################################请求接口################################################
|
|
|
|
public function jump_transfer_interface($data,$str){
|
|
if($data['type'] == '2'){
|
|
return $this->get_body_record_data($data,$str);
|
|
}else if($data['type'] == '6'){
|
|
return $this->get_body_record_data($data,$str);
|
|
}else if($data['type'] == '8'){
|
|
return $this->get_body_record_data($data,$str);
|
|
}
|
|
}
|
|
|
|
################################################业务部分################################################
|
|
|
|
// 获取记录信息列表(分组)-身体
|
|
// 获取记录信息列表(分页)-身体
|
|
public function get_body_record_data($data,$type){
|
|
$return_result = [];
|
|
if($type == 'group'){
|
|
$result = Db::query("
|
|
select
|
|
id,
|
|
CONVERT(varchar(10), record_time, 120) AS r_t,
|
|
CONVERT(varchar(19), record_time, 120) AS record_time,
|
|
height as v1,
|
|
weight as v2,
|
|
bmi as v3
|
|
from app_card_body_data
|
|
where aud_id='".$data['aud_id']."'
|
|
and record_time between '".$data['s_time']."' and '".$data['e_time']."'
|
|
and is_del = 0
|
|
order by record_time desc");
|
|
foreach ($result as $key => $value) {
|
|
if(array_key_exists($value['r_t'], $return_result)){
|
|
array_push($return_result[$value['r_t']], ['id'=>$value['id'],'v1'=>$value['v1'],'v2'=>$value['v2'],'v3'=>$value['v3'],'v1_name'=>'身高','v2_name'=>'体重','v3_name'=>'BMI']);
|
|
}else{
|
|
$return_result[$value['r_t']] = [['id'=>$value['id'],'v1'=>$value['v1'],'v2'=>$value['v2'],'v3'=>$value['v3'],'v1_name'=>'身高','v2_name'=>'体重','v3_name'=>'BMI']];
|
|
}
|
|
}
|
|
}else{
|
|
$result = Db::table('app_card_body_data')->where(['aud_id'=>$data['aud_id']])->field('id,record_time,height,weight,bmi')->order('record_time desc')->page($data['page'],$this->pagesize)->select();
|
|
$return_result['totalrows'] = Db::table('app_card_body_data')->where(['aud_id'=>$data['aud_id']])->count();
|
|
$return_result['rows'] = [];
|
|
$return_result['pageno'] = $data['page'];
|
|
$return_result['pagesize'] = $this->pagesize;
|
|
$return_result['totalpage'] = ceil($return_result['totalrows']/$this->pagesize);
|
|
foreach ($result as $key => $value) {
|
|
array_push($return_result['rows'],[
|
|
'id'=>$value['id'],
|
|
'v1_name'=>'身高',
|
|
'v1'=>$value['height'],
|
|
'v2_name'=>'体重',
|
|
'v2'=>$value['weight'],
|
|
'v3_name'=>'BMI',
|
|
'v3'=>$value['bmi'],
|
|
]);
|
|
}
|
|
}
|
|
return $this->msg($return_result);
|
|
}
|
|
|
|
} |