260318
This commit is contained in:
parent
0c45349f09
commit
543be63799
|
|
@ -83,14 +83,7 @@ class Base extends Controller{
|
|||
return false;//跟数据库比对过,存在无效数值
|
||||
}
|
||||
}
|
||||
public function validate_user_identity($data) {
|
||||
$validate_user = Db::table($this->base_use_db_name['3'])->where(['id'=>$data])->count();
|
||||
if($validate_user<=0){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断字符串是手机还是邮箱(有用)
|
||||
public function is_tel_email($str) {
|
||||
// 手机号码的正则表达式(中国大陆格式)(下面正则实际判断的是是否为11位数字)
|
||||
|
|
@ -124,7 +117,7 @@ class Base extends Controller{
|
|||
return false;
|
||||
}
|
||||
}
|
||||
// 秒转化格式,00:00:00
|
||||
// 秒转化格式,00:00:00(有用)
|
||||
public function handle_hour_branch_second($data = '2000'){
|
||||
$data = abs($data);
|
||||
$hours = intval($data / 3600);
|
||||
|
|
@ -192,7 +185,7 @@ class Base extends Controller{
|
|||
}
|
||||
}
|
||||
|
||||
// 计算天数
|
||||
// 计算天数(有用)
|
||||
public function daysSince($pastDate,$now = false)
|
||||
{
|
||||
// 创建一个表示过去日期的 DateTime 对象
|
||||
|
|
@ -604,6 +597,13 @@ class Base extends Controller{
|
|||
$filtered = filter_var($data, FILTER_VALIDATE_INT);
|
||||
return $filtered !== false && $filtered > 0;
|
||||
|
||||
case 'intnum_0':
|
||||
// 整数验证 - 必须是整型或纯整数字符串
|
||||
// 使用 filter_var 同时验证整型和整数字符串
|
||||
// 必须是 >0 的整数或字符串整数
|
||||
$filtered = filter_var($data, FILTER_VALIDATE_INT);
|
||||
return $filtered !== false;
|
||||
|
||||
case 'arr_intnum':
|
||||
// 一维整数数组验证 - 必须是非空数组,且所有元素都是整数
|
||||
// 1. 先检查是否是数组
|
||||
|
|
@ -634,7 +634,7 @@ class Base extends Controller{
|
|||
|
||||
case 'datetime':
|
||||
// 日期时间验证 - 保持原有逻辑不变
|
||||
$formats = ['Y-m-d', 'Y-m-d H:i:s'];
|
||||
$formats = ['Y', 'Y-m', 'Y-m-d', 'Y-m-d H:i:s'];
|
||||
foreach ($formats as $format) {
|
||||
$dateTime = \DateTime::createFromFormat($format, $data);
|
||||
if ($dateTime && $dateTime->format($format) === $data) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -222,6 +222,7 @@ class Index extends Base{
|
|||
'《WHO 5~19岁身高/体重判定标准》',
|
||||
],
|
||||
'bmi_evaluation'=>[
|
||||
"BMI是身体质量指数,是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。",
|
||||
'*数据参考:',
|
||||
'《WHO 5~19岁身高/体重判定标准》'
|
||||
],
|
||||
|
|
@ -445,11 +446,6 @@ class Index extends Base{
|
|||
$return_data['cookbook_label'] = $cookbook_label;
|
||||
// 添加菜谱类型end
|
||||
|
||||
// foreach ($cf_confog as $key => $value) {
|
||||
// // dump($key);
|
||||
// $return_data[$key] = $value;
|
||||
// }
|
||||
|
||||
// $return_data['cfc'] = $cf_confog;
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,51 +31,7 @@ class Skip extends Base{
|
|||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
|
||||
// 手动记录
|
||||
public function manual_record(){
|
||||
$data = input('post.');
|
||||
try {
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('r_time', $data) || !array_key_exists('num', $data) || !array_key_exists('time_m', $data) || !array_key_exists('time_s', $data) || !array_key_exists('type', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['r_time'],'datetime')){
|
||||
return $this->msg(10005,'r_time type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['type'],'str')){
|
||||
return $this->msg(10005,'type type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['num'],'intnum') || !$this->verify_data_is_ok($data['time_m'],'intnum') || !$this->verify_data_is_ok($data['time_s'],'intnum')){
|
||||
return $this->msg(10005,'跳绳数量或者分钟、秒钟值必须为整数');
|
||||
}
|
||||
if($data['num'] <= 0){
|
||||
return $this->msg(10005,'跳绳数不能小于等于0');
|
||||
}
|
||||
if(abs($data['time_s']) >= 60){
|
||||
return $this->msg(10005,'秒钟值不能大于60');
|
||||
}
|
||||
unset($data['token']);
|
||||
if($this->validate_user_identity($data['aud_id']) === false){
|
||||
return $this->msg(10003);
|
||||
}
|
||||
return $this->manual_record_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 设备记录
|
||||
public function device_record(){
|
||||
$data = input('post.');
|
||||
|
|
@ -147,267 +103,12 @@ class Skip extends Base{
|
|||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 曲线
|
||||
public function curve_chart(){
|
||||
$data = input('post.');
|
||||
try {
|
||||
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('time', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
unset($data['token']);
|
||||
return $this->curve_chart_action($data);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 获取历史列表(分页)
|
||||
public function record_list_page(){
|
||||
$data = input('post.');
|
||||
try {
|
||||
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('page', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['page'],'intnum')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
return $this->record_list_page_or_group_action($data,'page');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 获取历史列表(分组)
|
||||
public function record_list_group(){
|
||||
$data = input('post.');
|
||||
try {
|
||||
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['s_time'],'datetime')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['e_time'],'datetime')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
return $this->record_list_page_or_group_action($data,'group');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 历史记录(详细)
|
||||
public function detailed_record(){
|
||||
$data = input('post.');
|
||||
try {
|
||||
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('id', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||
return $this->msg(10005,'id type error');
|
||||
}
|
||||
return $this->get_all_detaile_data_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 删除历史数据
|
||||
public function del_record(){
|
||||
$data = input('post.');
|
||||
try {
|
||||
|
||||
if(!array_key_exists('id', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
// unset($data['token']);
|
||||
// 核实账号
|
||||
$zh_data = Db::table($this->skip_db_name['zhanghao'])->where(['token'=>$data['token'],'is_del'=>0])->field('id,token')->find();
|
||||
if(!$zh_data){
|
||||
return $this->msg(10003);
|
||||
}
|
||||
// dump($zh_data);
|
||||
// 核实角色
|
||||
$js_data = Db::table($this->skip_db_name['juese'])->where(['aan_id'=>$zh_data['id'],'is_del'=>0])->field('id')->select();
|
||||
if(!$js_data){
|
||||
return $this->msg(10003);
|
||||
}
|
||||
|
||||
|
||||
// dump($js_data);
|
||||
$skip_data = Db::table($this->skip_db_name['skip'])->where(['id'=>$data['id']])->field('id,aud_id')->find();
|
||||
|
||||
if(!$skip_data){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
|
||||
// dump($skip_data);
|
||||
$pd = false;
|
||||
|
||||
foreach ($js_data as $key => $value) {
|
||||
if($value['id'] == $skip_data['aud_id']){
|
||||
$pd = true;
|
||||
}
|
||||
}
|
||||
|
||||
if($pd == true){
|
||||
$user_data = Db::table($this->skip_db_name['skip'])->where(['id'=>$data['id']])->update(['is_del'=>1]);
|
||||
if($user_data){
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
}
|
||||
}else{
|
||||
return $this->msg(10002,'请勿操作他人数据');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
|
||||
################################################################action################################################################
|
||||
################################################################action################################################################
|
||||
public function manual_record_action($data){
|
||||
// 分秒转换为秒
|
||||
$data['time'] = abs($data['time_m'])*60+abs($data['time_s']);
|
||||
$user_msg_content = Db::table($this->skip_db_name['juese'])->where(['id'=>$data['aud_id']])->count();
|
||||
if($user_msg_content<=0){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
if(!array_key_exists('kcal', $data)){
|
||||
$last_data_body = Db::table($this->skip_db_name['body'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->order('record_time desc,id desc')->field('id,weight_val,record_time')->find();
|
||||
if(!$last_data_body){
|
||||
$last_data_body = Db::table($this->skip_db_name['juese'])->where(['id'=>$data['aud_id']])->field('id,weight as weight_val')->find();
|
||||
if(!$last_data_body){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
}
|
||||
$kcal_data = $this->skip_kcal_calculate($data['num'],$data['time'],$last_data_body['weight_val']);
|
||||
}else{
|
||||
// 将时间从秒转换为分钟
|
||||
$minutes = bcdiv($data['time'],60,20);
|
||||
// 计算每分钟的跳绳次数
|
||||
$jumpsPerMinute = bcdiv($data['num'],$minutes,2);
|
||||
$kcal_data['totalCalories'] = $data['kcal'];
|
||||
$kcal_data['averageAchievement'] = $jumpsPerMinute;
|
||||
$kcal_data['caloriesPerMinute'] = bcdiv($kcal_data['totalCalories'],$minutes,2);
|
||||
}
|
||||
|
||||
|
||||
$data_set = [
|
||||
'create_time'=>date('Y-m-d H:i:s'),
|
||||
'last_update_time'=>date('Y-m-d H:i:s'),
|
||||
'jump_num'=>$data['num'],
|
||||
|
||||
'jump_time'=>$data['time'],
|
||||
'jump_kcal'=>$kcal_data['totalCalories'],
|
||||
'average_num'=>$kcal_data['averageAchievement'],
|
||||
'average_kcal'=>$kcal_data['caloriesPerMinute'],
|
||||
'aud_id'=>$data['aud_id'],
|
||||
'record_time'=>array_key_exists('r_time', $data)?$data['r_time']:date('Y-m-d H:i:s'),
|
||||
'jump_type'=>$data['type']
|
||||
];
|
||||
if(strlen($data_set['record_time']) <= 12){
|
||||
$data_set['record_time'] = $this->addCurrentTimeToDateString($data_set['record_time']);
|
||||
}
|
||||
$last_data_body = Db::table($this->skip_db_name['skip'])->insert($data_set);
|
||||
$result = [
|
||||
'today_jump_num'=>0,
|
||||
'today_jump_time'=>0,
|
||||
'today_jump_kcal'=>0,
|
||||
];
|
||||
$all_data = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id']])->whereTime('record_time','today')->field('jump_num,jump_time,jump_kcal')->select();
|
||||
foreach ($all_data as $key => $value) {
|
||||
$result['today_jump_num'] = $result['today_jump_num']+$value['jump_num'];
|
||||
$result['today_jump_time'] = $result['today_jump_time']+$value['jump_time'];
|
||||
$result['today_jump_kcal'] = bcadd($result['today_jump_kcal'],$value['jump_kcal'],2);
|
||||
}
|
||||
$result['last_jump_num'] = $data['num'];
|
||||
$result['last_jump_time'] = $data['time'];
|
||||
$result['last_jump_kcal'] = $data_set['jump_kcal'];
|
||||
// $result['last_record_time'] = str_replace('-', '/', $data_set['record_time']);
|
||||
$result['last_record_time'] = $data_set['record_time'];
|
||||
$time_conversion = $this->handle_hour_branch_second($result['today_jump_time']);
|
||||
$result['today_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'];
|
||||
$time_conversion = $this->handle_hour_branch_second($result['last_jump_time']);
|
||||
$result['last_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'];
|
||||
return $this->msg($result);
|
||||
}
|
||||
|
||||
public function data_report_action($data){
|
||||
$all_data = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id']])->whereTime('record_time','today')->field('jump_num,jump_time,jump_kcal')->select();
|
||||
$last_data = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id']])->order('record_time desc,id desc')->field('id,jump_num,jump_time,jump_kcal,record_time')->find();
|
||||
|
|
@ -438,131 +139,6 @@ class Skip extends Base{
|
|||
$result['last_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'];
|
||||
return $this->msg($result);
|
||||
}
|
||||
public function curve_chart_action($data){
|
||||
$audid = $data['aud_id'];
|
||||
$timeData = explode('-', $data['time']);
|
||||
// 根据$timeData的长度构建不同的查询条件
|
||||
$map = ['aud_id' => $audid,'is_del'=>0];
|
||||
switch (count($timeData)) {
|
||||
case 3: // 年月日
|
||||
$map['record_time'] = ['between', [date('Y-m-d 00:00:00', strtotime($timeData[0] . '-' . $timeData[1] . '-' . $timeData[2])), date('Y-m-d 23:59:59', strtotime($timeData[0] . '-' . $timeData[1] . '-' . $timeData[2]))]];
|
||||
break;
|
||||
case 2: // 年月
|
||||
$map['record_time'] = ['between', [date('Y-m-01 00:00:00', strtotime($timeData[0] . '-' . $timeData[1])), date('Y-m-t 23:59:59', strtotime($timeData[0] . '-' . $timeData[1]))]];
|
||||
break;
|
||||
case 1: // 年
|
||||
$map['record_time'] = ['between', [date('Y-01-01 00:00:00', strtotime($timeData[0])), date('Y-12-31 23:59:59', strtotime($timeData[0]))]];
|
||||
break;
|
||||
default:
|
||||
return $this->msg(10005); // 无效的时间数据格式
|
||||
}
|
||||
|
||||
// 使用查询构造器进行查询
|
||||
$result = Db::name($this->skip_db_name['skip'])->where($map)->field('jump_num,jump_time,jump_kcal,aud_id,record_time,jump_type,DATEPART(hour, record_time) AS hour,DATEPART(minute, record_time) AS minute,DATEPART(day, record_time) AS day,DATEPART(month, record_time) AS month')->order('record_time')->select();
|
||||
$return_data = [];
|
||||
if(count($timeData) == 3){
|
||||
$key_condition = 'hour';
|
||||
}else if(count($timeData) == 2){
|
||||
$key_condition = 'day';
|
||||
}else if(count($timeData) == 1){
|
||||
$key_condition = 'month';
|
||||
}
|
||||
foreach ($this->curve_data_format as $key => $value) {
|
||||
$temporary_arr['title'] = $value[0].'('.$value[1].')';
|
||||
$temporary_arr['key'] = $key;
|
||||
$temporary_arr['line']['categories'] = [];
|
||||
$temporary_arr['line']['series'][0]['color'] = $value[2];
|
||||
$temporary_arr['line']['series'][0]['name'] = $value[0].'('.$value[1].')';
|
||||
$temporary_arr['line']['series'][0]['data'] = [];
|
||||
foreach ($result as $k => $v) {
|
||||
if($key_condition == 'hour'){
|
||||
// 每一次的记录都添加进去
|
||||
array_push($temporary_arr['line']['categories'],$result[$k]['hour'].':'.$result[$k]['minute']);
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}else if($key_condition == 'day'){
|
||||
// 根据天分组
|
||||
if(in_array($result[$k]['month'].'/'.$result[$k][$key_condition],$temporary_arr['line']['categories'])){
|
||||
$num = array_search($result[$k]['month'].'/'.$result[$k][$key_condition], $temporary_arr['line']['categories']);
|
||||
$temporary_arr['line']['series'][0]['data'][$num] = bcadd($temporary_arr['line']['series'][0]['data'][$num],$result[$k][$key],2);
|
||||
}else{
|
||||
array_push($temporary_arr['line']['categories'],$result[$k]['month'].'/'.$result[$k][$key_condition]);
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}
|
||||
|
||||
}else{
|
||||
// 根据年分组
|
||||
if(in_array($result[$k]['month'].'月',$temporary_arr['line']['categories'])){
|
||||
$num = array_search($result[$k]['month'].'月', $temporary_arr['line']['categories']);
|
||||
$temporary_arr['line']['series'][0]['data'][$num] = bcadd($temporary_arr['line']['series'][0]['data'][$num],$result[$k][$key],2);
|
||||
}else{
|
||||
array_push($temporary_arr['line']['categories'],$result[$k]['month'].'月');
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
array_push($return_data,$temporary_arr);
|
||||
}
|
||||
foreach ($return_data[1]['line']['series'][0]['data'] as $key => $value) {
|
||||
$return_data[1]['line']['series'][0]['data'][$key] = bcdiv($return_data[1]['line']['series'][0]['data'][$key],60,2);
|
||||
}
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
public function record_list_page_or_group_action($data,$type){
|
||||
$return_result = [];
|
||||
|
||||
if($type == 'group'){
|
||||
$data['s_time'] = $data['s_time'].' 00:00:00';
|
||||
$data['e_time'] = $data['e_time'].' 23:59:59';
|
||||
$result = Db::query("
|
||||
select
|
||||
id,
|
||||
CONVERT(varchar(10), record_time, 120) AS r_t,
|
||||
CONVERT(varchar(19), record_time, 120) AS record_time,
|
||||
jump_num as v1,
|
||||
jump_time as v2,
|
||||
jump_kcal as v3
|
||||
from ".$this->skip_db_name['skip']."
|
||||
where aud_id='".$data['aud_id']."'
|
||||
and record_time between '".$data['s_time']."' and '".$data['e_time']."'
|
||||
and is_del = 0
|
||||
order by record_time desc");
|
||||
foreach ($result as $key => $value) {
|
||||
$time_t = $this->handle_hour_branch_second($value['v2']);
|
||||
array_push($return_result, [
|
||||
'id'=>$value['id'],
|
||||
'v1'=>$value['v1'],
|
||||
'v2'=>$time_t['h'].':'.$time_t['m'].':'.$time_t['s'],
|
||||
'v3'=>$value['v3'],
|
||||
'v1_name'=>'个数',
|
||||
'v2_name'=>'时长',
|
||||
'v3_name'=>'卡路里',
|
||||
// 'r_t'=>str_replace('-', '/', $value['r_t'])
|
||||
'r_t'=>$value['r_t']
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
$result = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->field("id,record_time,REPLACE(record_time, '-', '-') AS b_time,jump_num,jump_time,jump_kcal")->order('record_time desc')->page($data['page'],$this->pagesize)->select();
|
||||
$return_result['totalrows'] = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id']])->count();
|
||||
$return_result['rows'] = [];
|
||||
$return_result['pageno'] = $data['page'];
|
||||
$return_result['pagesize'] = $this->pagesize;
|
||||
$return_result['totalpage'] = ceil($return_result['totalrows']/$this->pagesize);
|
||||
foreach ($result as $key => $value) {
|
||||
$time_t = $this->handle_hour_branch_second($value['jump_time']);
|
||||
array_push($return_result['rows'],[
|
||||
'id'=>$value['id'],
|
||||
'v1'=>$value['jump_num'],
|
||||
'v2'=>$time_t['h'].':'.$time_t['m'].':'.$time_t['s'],
|
||||
'v3'=>$value['jump_kcal'],
|
||||
'v1_name'=>'个数',
|
||||
'v2_name'=>'时长',
|
||||
'v3_name'=>'卡路里',
|
||||
'record_time'=>$value['b_time'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
return $this->msg($return_result);
|
||||
}
|
||||
public function get_all_detaile_data_action($data){
|
||||
|
||||
$result = $result = Db::table($this->skip_db_name['skip'])->where(['id'=>$data['id'],'is_del'=>0])->find();
|
||||
|
|
@ -582,6 +158,7 @@ class Skip extends Base{
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
################################################################内部调用################################################################
|
||||
################################################################内部调用################################################################
|
||||
|
|
|
|||
|
|
@ -27,49 +27,6 @@ class Vitalcapacity extends Base{
|
|||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
|
||||
// 手动记录
|
||||
public function manual_record(){
|
||||
try {
|
||||
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('one', $data) || !array_key_exists('two', $data) || !array_key_exists('three', $data) || !array_key_exists('time', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
unset($data['token']);
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['one'],'intnum')){
|
||||
return $this->msg(10005,'one type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['two'],'intnum')){
|
||||
return $this->msg(10005,'two type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['three'],'intnum')){
|
||||
return $this->msg(10005,'three type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['time'],'datetime')){
|
||||
return $this->msg(10005,'time type error');
|
||||
}
|
||||
if(strlen($data['time']) <= 12){
|
||||
// 时间日期转换,把'Y-m-d'转换成'Y-m-d H:i:s'格式
|
||||
$data['time'] = $this->addCurrentTimeToDateString($data['time']);
|
||||
}
|
||||
return $this->manual_record_action($data,'by_hand_means');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 设备记录
|
||||
public function device_record(){
|
||||
try {
|
||||
|
|
@ -108,10 +65,11 @@ class Vitalcapacity extends Base{
|
|||
}
|
||||
// 数据报告
|
||||
public function data_report(){
|
||||
$data = input('post.');
|
||||
try {
|
||||
$data = input('post.');
|
||||
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data)){
|
||||
$return_data = $this->msg(10001);
|
||||
return $this->msg(10001);
|
||||
}
|
||||
unset($data['token']);
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
|
|
@ -132,162 +90,8 @@ class Vitalcapacity extends Base{
|
|||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 曲线
|
||||
public function curve_chart(){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('time', $data) || !array_key_exists('token', $data)){
|
||||
$return_data = $this->msg(10001);
|
||||
}
|
||||
unset($data['token']);
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['time'],'datetime')){
|
||||
return $this->msg(10005,'time type error');
|
||||
}
|
||||
return $this->curve_chart_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 获取历史列表(分页)
|
||||
public function record_list_page(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('page', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['page'],'intnum')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
return $this->record_list_page_or_group_action($data,'page');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 获取历史列表(分组)
|
||||
public function record_list_group(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
return $this->msg(10005,'aud_id type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['s_time'],'datetime')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['e_time'],'datetime')){
|
||||
return $this->msg(10005,'page type error');
|
||||
}
|
||||
return $this->record_list_page_or_group_action($data,'group');
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 历史记录(详细)
|
||||
public function detailed_record(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('id', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||
return $this->msg(10005,'id type error');
|
||||
}
|
||||
return $this->get_all_detaile_data_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 删除历史数据
|
||||
public function del_record(){
|
||||
try {
|
||||
$data = input('post.');
|
||||
if(!array_key_exists('id', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
unset($data['token']);
|
||||
$user_data = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->where(['id'=>$data['id']])->update(['is_del'=>1]);
|
||||
if($user_data){
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
################################################################action################################################################
|
||||
################################################################action################################################################
|
||||
|
|
@ -304,7 +108,7 @@ class Vitalcapacity extends Base{
|
|||
$temporary_arr['three_val'] = $data['three'];
|
||||
$temporary_arr['average_val'] = $temporary_arr['average'];
|
||||
$temporary_arr['flow_val'] = array_key_exists('flow', $data)?$data['flow']:'0.00';//流速
|
||||
$temporary_arr['record_type'] = $type;//流速
|
||||
$temporary_arr['record_type'] = $type;
|
||||
// die;
|
||||
// 处理记录时间
|
||||
|
||||
|
|
@ -409,163 +213,6 @@ class Vitalcapacity extends Base{
|
|||
]);
|
||||
}
|
||||
}
|
||||
public function curve_chart_action($data){
|
||||
$audid = $data['aud_id'];
|
||||
$timeData = explode('-', $data['time']);
|
||||
|
||||
// 根据$timeData的长度构建不同的查询条件
|
||||
$map = ['aud_id' => $audid];
|
||||
switch (count($timeData)) {
|
||||
case 3: // 年月日
|
||||
$map['record_time'] = ['between', [date('Y-m-d 00:00:00', strtotime($timeData[0] . '-' . $timeData[1] . '-' . $timeData[2])), date('Y-m-d 23:59:59', strtotime($timeData[0] . '-' . $timeData[1] . '-' . $timeData[2]))]];
|
||||
break;
|
||||
case 2: // 年月
|
||||
$map['record_time'] = ['between', [date('Y-m-01 00:00:00', strtotime($timeData[0] . '-' . $timeData[1])), date('Y-m-t 23:59:59', strtotime($timeData[0] . '-' . $timeData[1]))]];
|
||||
break;
|
||||
case 1: // 年
|
||||
$map['record_time'] = ['between', [date('Y-01-01 00:00:00', strtotime($timeData[0])), date('Y-12-31 23:59:59', strtotime($timeData[0]))]];
|
||||
break;
|
||||
default:
|
||||
return $this->msg(10005); // 无效的时间数据格式
|
||||
}
|
||||
// 使用查询构造器进行查询
|
||||
$result = Db::name($this->vitalcapacity_db_name['vitalcapacity'])->where($map)->field('id,one_val,two_val,three_val,average_val,score_val,aud_id,record_time,DATEPART(hour, record_time) AS hour,DATEPART(day, record_time) AS day,DATEPART(month, record_time) AS month')->order('record_time')->select();
|
||||
$return_data = [];
|
||||
if(count($timeData) == 3){
|
||||
$key_condition = 'hour';
|
||||
}else if(count($timeData) == 2){
|
||||
$key_condition = 'day';
|
||||
}else if(count($timeData) == 1){
|
||||
$key_condition = 'month';
|
||||
}
|
||||
foreach ($this->curve_data_format as $key => $value) {
|
||||
$temporary_arr['title'] = $value[0].'('.$value[1].')';
|
||||
$temporary_arr['key'] = $key;
|
||||
$temporary_arr['line']['categories'] = [];
|
||||
$temporary_arr['line']['series'][0]['color'] = $value[2];
|
||||
$temporary_arr['line']['series'][0]['name'] = $value[0].'('.$value[1].')';
|
||||
$temporary_arr['line']['series'][0]['data'] = [];
|
||||
foreach ($result as $k => $v) {
|
||||
if($key_condition == 'hour'){
|
||||
if(in_array($result[$k][$key_condition].'时',$temporary_arr['line']['categories'])){
|
||||
|
||||
$num = array_search($result[$k][$key_condition].'时', $temporary_arr['line']['categories']);
|
||||
// $temporary_arr['line']['series'][0]['data'][$num] = bcadd($temporary_arr['line']['series'][0]['data'][$num],$result[$k][$key],2);
|
||||
$temporary_arr['line']['series'][0]['data'][$num] = $temporary_arr['line']['series'][0]['data'][$num] >= $result[$k][$key]?$temporary_arr['line']['series'][0]['data'][$num]:$result[$k][$key];
|
||||
|
||||
}else{
|
||||
array_push($temporary_arr['line']['categories'],$result[$k][$key_condition].'时');
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}
|
||||
}else if($key_condition == 'day'){
|
||||
if(in_array($result[$k]['month'].'-'.$result[$k][$key_condition],$temporary_arr['line']['categories'])){
|
||||
$num = array_search($result[$k]['month'].'-'.$result[$k][$key_condition], $temporary_arr['line']['categories']);
|
||||
// $temporary_arr['line']['series'][0]['data'][$num] = bcadd($temporary_arr['line']['series'][0]['data'][$num],$result[$k][$key],2);
|
||||
$temporary_arr['line']['series'][0]['data'][$num] = $temporary_arr['line']['series'][0]['data'][$num] >= $result[$k][$key]?$temporary_arr['line']['series'][0]['data'][$num]:$result[$k][$key];
|
||||
}else{
|
||||
array_push($temporary_arr['line']['categories'],$result[$k]['month'].'-'.$result[$k][$key_condition]);
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}
|
||||
}else{
|
||||
if(in_array($result[$k]['month'].'月',$temporary_arr['line']['categories'])){
|
||||
$num = array_search($result[$k]['month'].'月', $temporary_arr['line']['categories']);
|
||||
// $temporary_arr['line']['series'][0]['data'][$num] = bcadd($temporary_arr['line']['series'][0]['data'][$num],$result[$k][$key],2);
|
||||
$temporary_arr['line']['series'][0]['data'][$num] = $temporary_arr['line']['series'][0]['data'][$num] >= $result[$k][$key]?$temporary_arr['line']['series'][0]['data'][$num]:$result[$k][$key];
|
||||
}else{
|
||||
array_push($temporary_arr['line']['categories'],$result[$k]['month'].'月');
|
||||
array_push($temporary_arr['line']['series'][0]['data'],$result[$k][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
array_push($return_data,$temporary_arr);
|
||||
}
|
||||
return $this->msg($return_data);
|
||||
}
|
||||
public function record_list_page_or_group_action($data,$type){
|
||||
$return_result = [];
|
||||
|
||||
if($type == 'group'){
|
||||
$data['s_time'] = $data['s_time'].' 00:00:00';
|
||||
$data['e_time'] = $data['e_time'].' 23:59:59';
|
||||
$result = Db::query("
|
||||
select
|
||||
id,
|
||||
CONVERT(varchar(10), record_time, 120) AS r_t,
|
||||
CONVERT(varchar(19), record_time, 120) AS record_time,
|
||||
one_val as v1,
|
||||
two_val as v2,
|
||||
three_val as v3,
|
||||
average_val as v4,
|
||||
score as v5
|
||||
from ".$this->vitalcapacity_db_name['vitalcapacity']."
|
||||
where aud_id='".$data['aud_id']."'
|
||||
and record_time between '".$data['s_time']."' and '".$data['e_time']."'
|
||||
and is_del = 0
|
||||
order by record_time desc");
|
||||
foreach ($result as $key => $value) {
|
||||
// $time_t = $this->handle_hour_branch_second($value['v2']);
|
||||
array_push($return_result, [
|
||||
'id'=>$value['id'],
|
||||
'v1'=>$value['v1'] == '.00'?'0':$value['v1'],
|
||||
'v2'=>$value['v2'] == '.00'?'0':$value['v2'],
|
||||
'v3'=>$value['v3'] == '.00'?'0':$value['v3'],
|
||||
'v4'=>$value['v4'] == '.00'?'0':$value['v4'],
|
||||
'v5'=>explode(',',$value['v5'])[0],
|
||||
'v1_name'=>'第一次',
|
||||
'v2_name'=>'第二次',
|
||||
'v3_name'=>'第三次',
|
||||
'v4_name'=>'平均',
|
||||
'v5_name'=>'成绩',
|
||||
// 'r_t'=>str_replace('-', '/', $value['r_t'])
|
||||
'r_t'=>$value['r_t']
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
$result = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->field("id,record_time,REPLACE(record_time, '-', '-') AS b_time,one_val,two_val,three_val,average_val,score")->order('record_time desc')->page($data['page'],$this->pagesize)->select();
|
||||
$return_result['totalrows'] = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->where(['aud_id'=>$data['aud_id']])->count();
|
||||
$return_result['rows'] = [];
|
||||
$return_result['pageno'] = $data['page'];
|
||||
$return_result['pagesize'] = $this->pagesize;
|
||||
$return_result['totalpage'] = ceil($return_result['totalrows']/$this->pagesize);
|
||||
foreach ($result as $key => $value) {
|
||||
// $time_t = $this->handle_hour_branch_second($value['jump_time']);
|
||||
array_push($return_result['rows'],[
|
||||
'id'=>$value['id'],
|
||||
'v1'=>$value['one_val'] == '.00'?'0':$value['one_val'],
|
||||
'v2'=>$value['two_val'] == '.00'?'0':$value['two_val'],
|
||||
'v3'=>$value['three_val'] == '.00'?'0':$value['three_val'],
|
||||
'v4'=>$value['average_val'] == '.00'?'0':$value['average_val'],
|
||||
'v5'=>explode(',',$value['score'])[0],
|
||||
'v1_name'=>'第一次',
|
||||
'v2_name'=>'第二次',
|
||||
'v3_name'=>'第三次',
|
||||
'v4_name'=>'平均',
|
||||
'v5_name'=>'成绩',
|
||||
'record_time'=>$value['b_time']
|
||||
]);
|
||||
}
|
||||
}
|
||||
return $this->msg($return_result);
|
||||
}
|
||||
public function get_all_detaile_data_action($data){
|
||||
|
||||
$result = $result = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->where(['id'=>$data['id'],'is_del'=>0])->find();
|
||||
$for_data_arr = ['one_val'=>['第一次','ml'],'two_val'=>['第二次','ml'],'three_val'=>['第三次','ml'],'average_val'=>['三次平均','ml'],'score'=>['最后成绩','分']];
|
||||
if($result){
|
||||
$result_data = [];
|
||||
foreach ($for_data_arr as $key => $value) {
|
||||
$temporary_arr['key_name'] = $key;
|
||||
$temporary_arr['name'] = $value[0];
|
||||
$temporary_arr['value'] = explode(',',$result[$key])[0];
|
||||
$temporary_arr['unit'] = $value[1];
|
||||
array_push($result_data,$temporary_arr);
|
||||
}
|
||||
return $this->msg($result_data);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
################################################################内部调用################################################################
|
||||
################################################################内部调用################################################################
|
||||
|
|
|
|||
|
|
@ -936,40 +936,47 @@ Route::any('/reedaw/set_up_content', 'app/NewReedaw/app.Kitchenscale/set_up_cont
|
|||
// 本次添加食材的营养统计
|
||||
Route::any('/reedaw/current_food_statistics', 'app/NewReedaw/app.Kitchenscale/current_food_statistics');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 使用国内轻厨记的
|
||||
################################################################首页(健康工具)
|
||||
// 卡片列表
|
||||
Route::any('/reedaw/card_list_all', 'app/NewReedaw/app.Card/card_list_all');
|
||||
// 保存用户所选的卡片列表
|
||||
Route::any('/reedaw/save_card_list', 'app/NewReedaw/app.Card/save_card_list');
|
||||
// 角色卡片列表信息
|
||||
Route::any('/reedaw/user_card_list', 'app/NewReedaw/app.Card/user_card_list');
|
||||
// // BMI评测
|
||||
Route::any('/reedaw/bmi_evaluation', 'app/NewReedaw/app.Card/bmi_evaluation');
|
||||
// // 遗传身高
|
||||
Route::any('/reedaw/genetic_height', 'app/NewReedaw/app.Card/genetic_height');
|
||||
// ###############################跳绳部分
|
||||
// 获取手动记录内容
|
||||
Route::any('/reedaw/obtain_manual_record_content', 'app/NewReedaw/app.Card/obtain_manual_record_content');
|
||||
|
||||
|
||||
// ###############################跳绳&肺活通用部分
|
||||
// 手动记录
|
||||
Route::any('/reedaw/skip/manual_record', 'app/NewReedaw/app.skip/manual_record');
|
||||
Route::any('/reedaw/card/manual_record', 'app/NewReedaw/app.card/manual_record');
|
||||
// 曲线
|
||||
Route::any('/reedaw/card/curve_chart', 'app/NewReedaw/app.card/curve_chart');
|
||||
// 数据对比列表(分组)
|
||||
Route::any('/reedaw/card/record_list_group', 'app/NewReedaw/app.card/record_list_group');
|
||||
// 数据对比详情
|
||||
Route::any('/reedaw/card/data_compare', 'app/NewReedaw/app.card/data_compare');
|
||||
// 历史记录(分页)
|
||||
Route::any('/reedaw/card/record_list_page', 'app/NewReedaw/app.card/record_list_page');
|
||||
// 删除历史记录
|
||||
Route::any('/reedaw/card/del_record', 'app/NewReedaw/app.card/del_record');
|
||||
// 历史记录(详细)
|
||||
Route::any('/reedaw/card/detailed_record', 'app/NewReedaw/app.card/detailed_record');
|
||||
|
||||
// ###############################跳绳部分
|
||||
// 设备记录
|
||||
Route::any('/reedaw/skip/device_record', 'app/NewReedaw/app.skip/device_record');
|
||||
// 上一次数据
|
||||
Route::any('/reedaw/skip/data_report', 'app/NewReedaw/app.skip/data_report');
|
||||
// 曲线
|
||||
Route::any('/reedaw/skip/curve_chart', 'app/NewReedaw/app.skip/curve_chart');
|
||||
// 历史记录(分页)
|
||||
Route::any('/reedaw/skip/record_list_page', 'app/NewReedaw/app.skip/record_list_page');
|
||||
// 历史记录(分组)
|
||||
Route::any('/reedaw/skip/record_list_group', 'app/NewReedaw/app.skip/record_list_group');
|
||||
// 历史记录(详细)
|
||||
Route::any('/reedaw/skip/detailed_record', 'app/NewReedaw/app.skip/detailed_record');
|
||||
// 删除历史记录
|
||||
Route::any('/reedaw/skip/del_record', 'app/NewReedaw/app.skip/del_record');
|
||||
// ###############################肺活部分
|
||||
// 设备记录
|
||||
Route::any('/reedaw/vitalcapacity/device_record', 'app/NewReedaw/app.vitalcapacity/device_record');
|
||||
// 上一次数据
|
||||
Route::any('/reedaw/vitalcapacity/data_report', 'app/NewReedaw/app.vitalcapacity/data_report');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue