SchoolPhysicalExamination/application/app/controller/Sportstesting.php

1322 lines
64 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\app\controller;
use think\Controller;
use think\Db;
use app\bj\controller\Common;
use think\Log;
use \think\Validate;
use app\app\controller\Calculatebody;
use app\app\controller\Skip;
class Sportstesting extends Base{
protected $color = ['#FF5656','#FF5656','#5AD06D','#6492F6','#3967D6'];
protected $page_num = 10;
protected $city_data_rule_name = [
'xc'=>'现场类项目',
'xc_1'=>'第一类素质项目8分',
'xc_2'=>'第二类素质项目Ⅱ8分',
'xc_3'=>'第三类运动能力8分',
'xc_4'=>'第四类运动能力Ⅱ6分',
'gc'=>'过程类项目',
'gc_8_m'=>'8年级体质健康统测10分',
'gc_8_r'=>'8年级体育与健康知识机考10分',
];
protected $city_data_rule_is_choice = ['xc_2','xc_3','xc_4'];
protected $type_all = [
'1'=>'整数填数字(例肺活量)',
'2'=>'小数例50米跑',
'3'=>'拖动区间(例坐位体前屈:-15至30之间需要有小数1位',
'4'=>'分钟秒钟例1000米跑',
];
protected $city_data_rule2 = [
'北京'=>[
'xc'=>[
'xc_1'=>[
'1'=>[
'1000米'=>[
'list'=>[
'4:05'=>'8',
'4:11'=>'7.5',
'4:18'=>'7',
'4:26'=>'6.5',
'4:35'=>'6',
'4:45'=>'5.5',
'4:55'=>'5',
'5:01'=>'4.5',
'5:07'=>'4',
'5:13'=>'3.5',
'5:20'=>'3',
'5:27'=>'2.5',
'5:34'=>'2',
'5:42'=>'1.5',
'5:50'=>'1',
'5:59'=>'0.5',
'6:00'=>'0'
],
'unit'=>'分/秒',
'value'=>'00:00',
'proportion'=>'1',
'type'=>'4',
],
],
'2'=>[
'800米'=>[
'list'=>[
'3:55'=>'8',
'4:01'=>'7.5',
'4:08'=>'7',
'4:16'=>'6.5',
'4:25'=>'6',
'4:35'=>'5.5',
'4:45'=>'5',
'4:49'=>'4.5',
'4:53'=>'4',
'4:57'=>'3.5',
'5:02'=>'3',
'5:07'=>'2.5',
'5:12'=>'2',
'5:19'=>'1.5',
'5:26'=>'1',
'5:35'=>'0.5',
'5:36'=>'0',
],
'unit'=>'分/秒',
'value'=>'00:00',
'proportion'=>'1',
'type'=>'4',
]
],
],
'xc_2'=>[
'1'=>[
'引体向上'=>[
'list'=>[
'11'=>'8',
'10'=>'7.5',
'9'=>'7',
'8'=>'6.5',
'7'=>'6',
'6'=>'5.5',
'5'=>'5',
'4'=>'4.5',
'3'=>'4',
'2'=>'3.5',
'1'=>'3'
],
'unit'=>'次',
'value'=>'0',
'proportion'=>'1',
'type'=>'1',
],
'双杠臂屈伸'=>[
'list'=>[
'11'=>'8',
'10'=>'7.5',
'9'=>'7',
'8'=>'6.5',
'7'=>'6',
'6'=>'5.5',
'5'=>'5',
'4'=>'4.5',
'3'=>'4',
'2'=>'3.5',
'1'=>'3'
],
'unit'=>'次',
'value'=>'0',
'proportion'=>'1',
'type'=>'1',
],
],
'2'=>[
'斜身引体'=>[
'list'=>[
'40'=>'8',
'36'=>'7.5',
'32'=>'7',
'28'=>'6.5',
'24'=>'6',
'20'=>'5.5',
'16'=>'5',
'12'=>'4.5',
'10'=>'4',
'9'=>'3.5',
'8'=>'3',
'7'=>'2.5',
'6'=>'2',
'5'=>'1.5',
'4'=>'1',
'3'=>'0.5',
'2'=>'0'
],
'unit'=>'次',
'value'=>'0',
'proportion'=>'1',
'type'=>'1',
],
'仰卧起坐'=>[
'list'=>[
'42'=>'8',
'40'=>'7.5',
'37'=>'7',
'34'=>'6.5',
'30'=>'6',
'26'=>'5.5',
'22'=>'5',
'21'=>'4.5',
'20'=>'4',
'19'=>'3.5',
'18'=>'3',
'17'=>'2.5',
'16'=>'2',
'15'=>'1.5',
'14'=>'1',
'13'=>'0.5',
'12'=>'0'
],
'unit'=>'次',
'value'=>'0',
'proportion'=>'1',
'type'=>'1',
],
],
],
'xc_3'=>[
'1'=>[
'足球运球/射门'=>['list'=>['19.5'=>'8','20.0'=>'7.5','20.5'=>'7','21.0'=>'6.5','21.5'=>'6','22.0'=>'5.5','22.5'=>'5','23.0'=>'4.5','23.8'=>'4','24.6'=>'3.5','25.4'=>'3','26.2'=>'2.5','27.0'=>'2','27.8'=>'1.5','28.6'=>'1','29.4'=>'0.5','29.5'=>'0'],'unit'=>'秒','value'=>'00.0','proportion'=>'1','type'=>'2',],
],
'2'=>[
'足球运球/射门'=>['list'=>['21.0'=>'8','21.5'=>'7.5','22.0'=>'7','22.5'=>'6.5','23.0'=>'6','23.5'=>'5.5','24.0'=>'5','24.5'=>'4.5','25.3'=>'4','26.1'=>'3.5','26.9'=>'3','27.7'=>'2.5','28.5'=>'2','29.3'=>'1.5','30.1'=>'1','30.9'=>'0.5','31.0'=>'0'],'unit'=>'秒','value'=>'00.0','proportion'=>'1','type'=>'2',],
],
],
'xc_4'=>[
'1'=>[
'100米游泳'=>['list'=>['2:25'=>'6','2:35'=>'5.5','2:45'=>'5','2:55'=>'4.5','3:05'=>'4','3:15'=>'3.5','3:30'=>'3','3:40'=>'2.5','3:50'=>'2','4:00'=>'1.5','4:10'=>'1','4:20'=>'0.5','4:21'=>'0'],'unit'=>'分/秒','value'=>'00:00','proportion'=>'1','type'=>'4',],
],
'2'=>[
'100米游泳'=>['list'=>['2:40'=>'6','2:48'=>'5.5','2:56'=>'5','3:04'=>'4.5','3:12'=>'4','3:20'=>'3.5','3:30'=>'3','3:40'=>'2.5','3:50'=>'2','4:00'=>'1.5','4:10'=>'1','4:20'=>'0.5','4:21'=>'0'],'unit'=>'分/秒','value'=>'00:00','proportion'=>'1','type'=>'4',],
],
],
],
'gc'=>[
'gc_8_m'=>[
'1'=>[
'BMI'=>['list'=>['15.6'=>'80','22.5'=>'100','25.2'=>'80','100'=>'60'],'unit'=>'','value'=>'0','proportion'=>'0.15','type'=>'2',],
'肺活量'=>['list'=>['3940'=>'100','3820'=>'95','3700'=>'90','3450'=>'85','3200'=>'80','3080'=>'78','2960'=>'76','2840'=>'74','2720'=>'72','2600'=>'70','2480'=>'68','2360'=>'66','2240'=>'64','2120'=>'62','2000'=>'60','1890'=>'50','1780'=>'40','1670'=>'30','1560'=>'20','1450'=>'10',],'unit'=>'ml','value'=>'0','proportion'=>'0.15','type'=>'1',],
'50米跑'=>[
'list'=>[
'7.5'=>'100',
'7.6'=>'95',
'7.7'=>'90',
'7.8'=>'85',
'7.9'=>'80',
'8.1'=>'78',
'8.3'=>'76',
'8.5'=>'74',
'8.7'=>'72',
'8.9'=>'70',
'9.1'=>'68',
'9.3'=>'66',
'9.5'=>'64',
'9.7'=>'62',
'9.9'=>'60',
'10.1'=>'50',
'10.3'=>'40',
'10.5'=>'30',
'10.7'=>'20',
'10.9'=>'10',
],
'unit'=>'秒',
'value'=>'00.0',
'proportion'=>'0.2',
'type'=>'2',
],
'坐位体前屈'=>[
'list'=>[
'19.6'=>'100',
'17.7'=>'95',
'15.8'=>'90',
'13.7'=>'85',
'11.6'=>'80',
'10.3'=>'78',
'9'=>'76',
'7.7'=>'74',
'6.4'=>'72',
'5.1'=>'70',
'3.8'=>'68',
'2.5'=>'66',
'1.2'=>'64',
'-0.1'=>'62',
'-1.4'=>'60',
'-2.6'=>'50',
'-3.8'=>'40',
'-5'=>'30',
'-6.2'=>'20',
'-7.4'=>'10',
],
'unit'=>'cm',
'value'=>'00.0',
'proportion'=>'0.1',
'type'=>'3',
],
'立定跳远'=>[
'list'=>[
'240'=>'100',
'233'=>'95',
'226'=>'90',
'218'=>'85',
'210'=>'80',
'206'=>'78',
'202'=>'76',
'198'=>'74',
'194'=>'72',
'190'=>'70',
'186'=>'68',
'182'=>'66',
'178'=>'64',
'174'=>'62',
'170'=>'60',
'165'=>'50',
'160'=>'40',
'155'=>'30',
'150'=>'20',
'145'=>'10',
],
'unit'=>'cm',
'value'=>'0',
'proportion'=>'0.1',
'type'=>'1',
],
'引体向上'=>[
'list'=>[
'14'=>'100',
'13'=>'95',
'12'=>'90',
'11'=>'85',
'10'=>'80',
'9'=>'76',
'8'=>'72',
'7'=>'68',
'6'=>'64',
'5'=>'60',
'4'=>'50',
'3'=>'40',
'2'=>'30',
'1'=>'20',
'0'=>'10',
],
'unit'=>'个',
'value'=>'0',
'proportion'=>'0.1',
'type'=>'1',
'add_point'=>[
'10'=>'10',
'9'=>'9',
'8'=>'8',
'7'=>'7',
'6'=>'6',
'5'=>'5',
'4'=>'4',
'3'=>'3',
'2'=>'2',
'1'=>'1',
]
],
'男生1000米'=>[
'list'=>[
'3:50'=>'100',
'3:55'=>'95',
'4:00'=>'90',
'4:07'=>'85',
'4:15'=>'80',
'4:20'=>'78',
'4:25'=>'76',
'4:30'=>'74',
'4:35'=>'72',
'4:40'=>'70',
'4:45'=>'68',
'4:50'=>'66',
'4:55'=>'64',
'5:00'=>'62',
'5:05'=>'60',
'5:25'=>'50',
'5:45'=>'40',
'6:05'=>'30',
'6:25'=>'20',
'6:45'=>'10',
],
'unit'=>'分/秒',
'value'=>'00:00',
'proportion'=>'0.2',
'type'=>'4',
'add_point'=>[
'-35'=>'10',
'-32'=>'9',
'-29'=>'8',
'-26'=>'7',
'-23'=>'6',
'-20'=>'5',
'-16'=>'4',
'-12'=>'3',
'-8'=>'2',
'-4'=>'1',
]
],
],
'2'=>[
'BMI'=>[
'list'=>[
'15.2'=>'80',
'22.2'=>'100',
'24.8'=>'80',
'100'=>'60'
],
'unit'=>'',
'value'=>'00.0',
'proportion'=>'0.15',
'type'=>'2',
],
'肺活量'=>[
'list'=>[
'2900'=>'100',
'2850'=>'95',
'2800'=>'90',
'2650'=>'85',
'2500'=>'80',
'2400'=>'78',
'2300'=>'76',
'2200'=>'74',
'2100'=>'72',
'2000'=>'70',
'1900'=>'68',
'1800'=>'66',
'1700'=>'64',
'1600'=>'62',
'1500'=>'60',
'1460'=>'50',
'1420'=>'40',
'1380'=>'30',
'1340'=>'20',
'1300'=>'10',
],
'unit'=>'ml',
'value'=>'0',
'proportion'=>'0.15',
'type'=>'1',
],
'50米跑'=>[
'list'=>[
'8'=>'100',
'8.1'=>'95',
'8.2'=>'90',
'8.5'=>'85',
'8.8'=>'80',
'9'=>'78',
'9.2'=>'76',
'9.4'=>'74',
'9.6'=>'72',
'9.8'=>'70',
'10'=>'68',
'10.2'=>'66',
'10.4'=>'64',
'10.6'=>'62',
'10.8'=>'60',
'11'=>'50',
'11.2'=>'40',
'11.4'=>'30',
'11.6'=>'20',
'11.8'=>'10',
],
'unit'=>'秒',
'value'=>'00.0',
'proportion'=>'0.2',
'type'=>'2',
],
'坐位体前屈'=>[
'list'=>[
'22.7'=>'100',
'21'=>'95',
'19.3'=>'90',
'17.6'=>'85',
'15.9'=>'80',
'14.6'=>'78',
'13.3'=>'76',
'12'=>'74',
'10.7'=>'72',
'9.4'=>'70',
'8.1'=>'68',
'6.8'=>'66',
'5.5'=>'64',
'4.2'=>'62',
'2.9'=>'60',
'2.1'=>'50',
'1.3'=>'40',
'0.5'=>'30',
'-0.3'=>'20',
'-1.1'=>'10',
],
'unit'=>'cm',
'value'=>'00.0',
'proportion'=>'0.1',
'type'=>'3',
],
'立定跳远'=>[
'list'=>[
'240'=>'100',
'233'=>'95',
'226'=>'90',
'218'=>'85',
'210'=>'80',
'206'=>'78',
'202'=>'76',
'198'=>'74',
'194'=>'72',
'190'=>'70',
'186'=>'68',
'182'=>'66',
'178'=>'64',
'174'=>'62',
'170'=>'60',
'165'=>'50',
'160'=>'40',
'155'=>'30',
'150'=>'20',
'145'=>'10',
],
'unit'=>'cm',
'value'=>'0',
'proportion'=>'0.1',
'type'=>'1',
],
'一分钟仰卧起坐'=>[
'list'=>[
'51'=>'100',
'49'=>'95',
'47'=>'90',
'44'=>'85',
'41'=>'80',
'39'=>'78',
'37'=>'76',
'35'=>'74',
'33'=>'72',
'31'=>'70',
'29'=>'68',
'27'=>'66',
'25'=>'64',
'23'=>'62',
'21'=>'60',
'19'=>'50',
'17'=>'40',
'15'=>'30',
'13'=>'20',
'11'=>'10',
],
'unit'=>'个',
'value'=>'0',
'proportion'=>'0.1',
'type'=>'1',
'add_point'=>[
'13'=>'10',
'12'=>'9',
'11'=>'8',
'10'=>'7',
'9'=>'6',
'8'=>'5',
'7'=>'4',
'6'=>'3',
'4'=>'2',
'2'=>'1',
]
],
'女生800米'=>[
'list'=>[
'3:30'=>'100',
'3:37'=>'95',
'3:44'=>'90',
'3:52'=>'85',
'4:00'=>'80',
'4:05'=>'78',
'4:10'=>'76',
'4:15'=>'74',
'4:20'=>'72',
'4:25'=>'70',
'4:30'=>'68',
'4:35'=>'66',
'4:40'=>'64',
'4:45'=>'62',
'4:50'=>'60',
'5:00'=>'50',
'5:10'=>'40',
'5:20'=>'30',
'5:30'=>'20',
'5:40'=>'10',
],
'unit'=>'分/秒',
'value'=>'00:00',
'proportion'=>'0.2',
'type'=>'4',
'add_point'=>[
'-50'=>'10',
'-45'=>'9',
'-40'=>'8',
'-35'=>'7',
'-30'=>'6',
'-25'=>'5',
'-20'=>'4',
'-15'=>'3',
'-10'=>'2',
'-5'=>'1',
]
],
],
],
'gc_8_r'=>[
'1'=>[
'机测'=>[
'list'=>[],'unit'=>'分','value'=>'0','proportion'=>'1','type'=>'1',],
],
'2'=>[
'机测'=>[
'list'=>[],'unit'=>'分','value'=>'0','proportion'=>'1','type'=>'1',],
]
]
]
],
];
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
################################################################接口################################################################
################################################################接口################################################################
################################################################接口################################################################
// 获取单个类型列表
public function sportstesting_get_type_list($data = ['aud_id'=>'25','parameter_data'=>'北京','gender'=>'1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('aud_id', $data) || !array_key_exists('parameter_data', $data) || !array_key_exists('token', $data)){
return $this->msg(10001);
}
// cache($data['token'], time());
if($this->token_time_validate($data['token']) === false){
return $this->msg(20001);
}
unset($data['token']);
// cache('sportstesting_get_type_list',json_encode($data));
return $this->sportstesting_get_type_list_action($data);
}
// 获取地区类型列表
public function sportstesting_get_region_list($data = ['aud_id'=>'25','parameter_data'=>'北京','gender'=>'1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('aud_id', $data) || !array_key_exists('parameter_data', $data) || !array_key_exists('token', $data)){
return $this->msg(10001);
}
// cache($data['token'], time());
if($this->token_time_validate($data['token']) === false){
return $this->msg(20001);
}
unset($data['token']);
// cache('sportstesting_get_region_list',json_encode($data));
return $this->sportstesting_get_region_list_action($data);
}
// 获取估分最后一次数据
public function sportstesting_get_last_data($data = ['aud_id'=>'25','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data)){
return $this->msg(10001);
}
if($this->token_time_validate($data['token']) === false){
return $this->msg(20001);
}
unset($data['token']);
// cache('sportstesting_get_last_data',json_encode($data));
return $this->sportstesting_get_last_data_action($data);
}
// 计算并存储数据
public function sportstesting_set_once_data($data = ['aud_id'=>'25','parameter_data'=>'北京市,province','result_data'=>'','gender'=>'1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('aud_id', $data) || !array_key_exists('parameter_data', $data) || !array_key_exists('result_data', $data) || !array_key_exists('gender', $data) || !array_key_exists('token', $data)){
return $this->msg(10001);
}
if($this->token_time_validate($data['token']) === false){
return $this->msg(20001);
}
// cache('sportstesting_set_once_data',json_encode($data));
// return $this->msg($data);
unset($data['token']);
return $this->sportstesting_set_once_data_action($data);
}
// 获取估分历史列表
public function sportstesting_get_all_list($data = ['aud_id'=>'25','page'=>'1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data) || !array_key_exists('page', $data)){
return $this->msg(10001);
}
// cache($data['token'], time());
if($this->token_time_validate($data['token']) === false){
return $this->msg(20001);
}
unset($data['token']);
// cache('sportstesting_get_all_list',json_encode($data));
return $this->sportstesting_get_all_list_action($data);
}
// 获取估分历史详情
public function sportstesting_get_one_details($data = ['id'=>'2','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('id', $data) || !array_key_exists('token', $data)){
return $this->msg(10001);
}
// cache($data['token'], time());
if($this->token_time_validate($data['token']) === false){
return $this->msg(20001);
}
unset($data['token']);
// cache('sportstesting_get_one_details',json_encode($data));
return $this->sportstesting_get_one_details_action($data);
}
################################################################业务################################################################
################################################sportstesting_get_type_list
public function sportstesting_get_type_list_action($data){
// $parameter_data = explode('-',$data['parameter_data']);
// if(count($parameter_data) < 3){
// return $this->msg(10005);
// }
if(!array_key_exists($data['parameter_data'], $this->city_data_rule2)){
return $this->msg(10005);
}
// if(!array_key_exists($parameter_data[1], $this->city_data_rule2[$parameter_data[0]])){
// return $this->msg(10005);
// }
// if(!array_key_exists($parameter_data[1].'_'.$parameter_data[2], $this->city_data_rule2[$parameter_data[0]][$parameter_data[1]])){
// return $this->msg(10005);
// }
$data['gender'] = $data['gender'] == 2?$data['gender']:1;
$result['list'] = [];
// city_data_rule_is_choice
foreach ($this->city_data_rule2[$data['parameter_data']] as $key => $value) {
foreach ($value as $k1 => $v1) {
if(in_array($k1,$this->city_data_rule_is_choice)){
$temporary_arr_1 = ['key'=>$k1,'list'=>[]];
foreach ($v1[$data['gender']] as $k2 => $v2) {
array_push($temporary_arr_1['list'],[
'name'=>$k2,
'proportion'=>$v2['proportion'],
'value'=>$v2['value'],
'proportion_value'=>null,
'unit'=>$v2['unit'],
'type'=>$v2['type'],
]);
}
array_push($result['list'],$temporary_arr_1);
}
}
}
// foreach ($this->city_data_rule2[$parameter_data[0]][$parameter_data[1]][$parameter_data[1].'_'.$parameter_data[2]][$data['gender']] as $key => $value) {
// dump($key);
// dump($value);
// // $temporary_arr_1 = ['name'=>$key,'proportion'=>$value['proportion'],'value'=>$value['value'],'proportion_value'=>null,'unit'=>$value['unit']];
// // array_push($result['list'],$temporary_arr_1);
// }
// die;
// dump($result);
return $this->msg($result);
}
################################################sportstesting_get_region_list
public function sportstesting_get_region_list_action($data){
if(!array_key_exists($data['parameter_data'], $this->city_data_rule2)){
return $this->msg(10005);
}
$result['list'] = [];
$result['total_score'] = 0;
foreach ($this->city_data_rule2[$data['parameter_data']] as $key => $value) {
$temporary_arr_1 = ['name'=>$this->city_data_rule_name[$key],'key'=>$key,'list'=>[]];
foreach ($value as $k1 => $v1) {
$temporary_pd = in_array($k1,$this->city_data_rule_is_choice);
$temporary_arr_2 = ['name'=>$this->city_data_rule_name[$k1],'key'=>$k1,'is_choice'=>$temporary_pd?1:0,'list'=>[]];
if(!$temporary_pd){
foreach ($v1[$data['gender']] as $k2 => $v2) {
// dump($k2);
// dump($v2);
$temporary_arr_3 = ['name'=>$k2,'proportion'=>$v2['proportion'],'value'=>$v2['value'],'proportion_value'=>null,'unit'=>$v2['unit'],'type'=>$v2['type']];
array_push($temporary_arr_2['list'],$temporary_arr_3);
}
}
array_push($temporary_arr_1['list'],$temporary_arr_2);
}
array_push($result['list'],$temporary_arr_1);
}
// die;
return $this->msg($result);
}
################################################sportstesting_get_last_data
public function sportstesting_get_last_data_action($data){
$user_data = Db::table('app_region_scores_data')->where(['aud_id'=>$data['aud_id']])->order('id desc')->find();
if($user_data){
$temporary_data = json_decode($user_data['content'],true);
// dump($temporary_data);
$result['list'] = [];
$result['total_score'] = $temporary_data['total_score'];
unset($temporary_data['total_score']);
foreach ($temporary_data as $key => $value) {
$temporary_arr_1 = ['name'=>$this->city_data_rule_name[$key],'key'=>$key,'list'=>[]];
foreach ($value as $k => $v) {
$temporary_arr_2 = ['name'=>$this->city_data_rule_name[$k],'key'=>$k,'list'=>[]];
foreach ($v as $k1 => $v1) {
array_push($temporary_arr_2['list'],$v1);
}
array_push($temporary_arr_1['list'],$temporary_arr_2);
}
array_push($result['list'],$temporary_arr_1);
}
return $this->msg($result);
}else{
$user_data = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('id,grade')->find();
$result['list'] = [
[
'name'=>'现场类项目',
'key'=>'xc',
'list'=>[
['name'=>'第一类素质项目8分','key'=>'xc_1','list'=>[
$user_data==2?['name'=>'800米','proportion'=>'1','value'=>'0','proportion_value'=>'0']:['name'=>'1000米','proportion'=>'1','value'=>'0','proportion_value'=>'0'],
],],
['name'=>'第二类素质项目Ⅱ8分','key'=>'xc_2','list'=>[],],
['name'=>'第三类运动能力8分','key'=>'xc_3','list'=>[],],
['name'=>'第四类运动能力Ⅱ6分','key'=>'xc_4','list'=>[],],
],
],
[
'name'=>'过程类项目',
'key'=>'gc',
'list'=>[
['name'=>'8年级体质健康统测10分','key'=>'gc_8_m','list'=>[
['name'=>'BMI','proportion'=>'1','value'=>'0','proportion_value'=>'0'],
['name'=>'肺活量','proportion'=>'1','value'=>'0','proportion_value'=>'0'],
['name'=>'50米跑','proportion'=>'1','value'=>'0','proportion_value'=>'0'],
['name'=>'坐位体前屈','proportion'=>'1','value'=>'0','proportion_value'=>'0'],
['name'=>'立定跳远','proportion'=>'1','value'=>'0','proportion_value'=>'0'],
$user_data==2?['name'=>'一分钟仰卧起坐','proportion'=>'1','value'=>'0','proportion_value'=>'0']:['name'=>'引体向上','proportion'=>'1','value'=>'0','proportion_value'=>'0'],
$user_data==2?['name'=>'女生800米','proportion'=>'1','value'=>'0','proportion_value'=>'0']:['name'=>'男生1000米','proportion'=>'1','value'=>'0','proportion_value'=>'0'],
],],
['name'=>'8年级体育与健康知识机考10分','key'=>'gc_8_r','list'=>[
['name'=>'机考','proportion'=>'1','value'=>'0','proportion_value'=>'0'],
],],
],
],
];
$result['total_score'] = 0;
return $this->msg($result);
}
}
################################################sportstesting_get_all_list
public function sportstesting_get_all_list_action($data){
$user_data_num = Db::table('app_region_scores_data')->where(['aud_id'=>$data['aud_id']])->count();
$user_data = Db::table('app_region_scores_data')->where(['aud_id'=>$data['aud_id']])->page($data['page'],$this->page_num)->order('id desc')->select();
if($user_data){
$result = [];
$result['totalrows'] = $user_data_num;
$result['rows'] = [];
$result['pageno'] = $data['page'];
$result['pagesize'] = $this->page_num;
$result['totalpage'] = ceil($result['totalrows']/$this->page_num);
foreach ($user_data as $key => $value) {
array_push($result['rows'],[
'id'=>$value['id'],
'create_time'=>$value['create_time'],
'score'=>$value['score'],
]);
}
return $this->msg($result);
}else{
return $this->msg(10004);
}
}
################################################sportstesting_get_one_details
public function sportstesting_get_one_details_action($data){
$user_data = Db::table('app_region_scores_data')->where(['id'=>$data['id']])->find();
if($user_data){
$temporary_data = json_decode($user_data['content'],true);
$temporary_data['create_time'] = $user_data['create_time'];
$temporary_data['region'] = explode(',',$user_data['region'])[0];
// $temporary_data['']
// $result['list'] = [];
// $result['total_score'] = $temporary_data['total_score'];
// unset($temporary_data['total_score']);
// dump($temporary_data);
return $this->msg($temporary_data);
// foreach ($temporary_data['list'] as $key => $value) {
// // dump($this->city_data_rule_name[$key]);
// $temporary_arr_1 = ['name'=>$this->city_data_rule_name[$key],'key'=>$key,'list'=>[]];
// // dump($temporary_arr_1);
// foreach ($value as $k => $v) {
// // dump($k);
// // dump($v);
// $temporary_arr_2 = ['name'=>$this->city_data_rule_name[$k],'key'=>$k,'list'=>[]];
// foreach ($v as $k1 => $v1) {
// array_push($temporary_arr_2['list'],$v1);
// }
// array_push($temporary_arr_1['list'],$temporary_arr_2);
// }
// array_push($result['list'],$temporary_arr_1);
// }
// return $this->msg($result);
}else{
return $this->msg(10004);
}
}
################################################sportstesting_set_once_data
public function sportstesting_set_once_data_action($data){
$region = explode(',',$data['parameter_data']);
$region_rule = Db::table('app_region_scores_rule')->where($region[1]."='".$region[0]."'")->find();
$rule = json_decode($region_rule['content'],true);
$result = [];
if($region[0] == '北京市'){
$data_data = [
[
"name"=>"现场",
"key"=>"xc",
"list"=>[
[
"name"=>"第一类素质项目8分",
"key"=>"xc_1",
"is_choice"=>0,
"list"=>[
[
"name"=>"1000米",
"proportion"=>"1",
"value"=>"4:19",
"proportion_value"=>null,
"unit"=>"分/秒"
]
]
],
[
"name"=>"第二类素质项目Ⅱ8分",
"key"=>"xc_2",
"is_choice"=>1,
"list"=>[
[
"name"=>"引体向上",
"proportion"=>"1",
"value"=>"5",
"proportion_value"=>null,
"unit"=>""
]
]
],
[
"name"=>"第三类运动能力8分",
"key"=>"xc_3",
"is_choice"=>1,
"list"=>[
[
"name"=>"足球运球/射门",
"proportion"=>"1",
"value"=>"20.4",
"proportion_value"=>null,
"unit"=>""
]
]
],
[
"name"=>"第四类运动能力Ⅱ6分",
"key"=>"xc_4",
"is_choice"=>1,
"list"=>[
[
"name"=>"100米游泳",
"proportion"=>"1",
"value"=>"2:34",
"proportion_value"=>null,
"unit"=>"分/秒"
]
]
]
]
],
[
"name"=>"过程",
"key"=>"gc",
"list"=>[
[
"name"=>"8年级体质健康统测10分",
"key"=>"gc_8_m",
"is_choice"=>0,
"list"=>[
[
"name"=>"BMI",
"proportion"=>"0.15",
"value"=>"17.5",
"proportion_value"=>null,
"unit"=>""
],
[
"name"=>"肺活量",
"proportion"=>"0.15",
"value"=>"3450",
"proportion_value"=>null,
"unit"=>"ml"
],
[
"name"=>"50米跑",
"proportion"=>"0.2",
"value"=>"8.5",
"proportion_value"=>null,
"unit"=>""
],
[
"name"=>"坐位体前屈",
"proportion"=>"0.1",
"value"=>"10.3",
"proportion_value"=>null,
"unit"=>"cm"
],
[
"name"=>"立定跳远",
"proportion"=>"0.1",
"value"=>"170",
"proportion_value"=>null,
"unit"=>"cm"
],
[
"name"=>"引体向上",
"proportion"=>"0.1",
"value"=>"12",
"proportion_value"=>null,
"unit"=>""
],
[
"name"=>"男生1000米",
"proportion"=>"0.2",
"value"=>"4:00",
"proportion_value"=>null,
"unit"=>"分/秒"
]
]
],
[
"name"=>"8年级体育与健康知识机考10分",
"key"=>"gc_8_r",
"is_choice"=>0,
"list"=>[
[
"name"=>"机测",
"proportion"=>"1",
"value"=>"5",
"proportion_value"=>null,
"unit"=>""
]
]
]
]
]
];
// $data['result_data'] = '[{"name":"现场","key":"xc","list":[{"name":"第一类素质项目8分","key":"xc_1","is_choice":0,"list":[{"name":"1000米","proportion":"1","value":"10:00","proportion_value":null,"unit":"分\/秒","type":"4"}]},{"name":"第二类素质项目Ⅱ8分","key":"xc_2","is_choice":1,"list":[]},{"name":"第三类运动能力8分","key":"xc_3","is_choice":1,"list":[]},{"name":"第四类运动能力Ⅱ6分","key":"xc_4","is_choice":1,"list":[]}]},{"name":"过程","key":"gc","list":[{"name":"8年级体质健康统测10分","key":"gc_8_m","is_choice":0,"list":[{"name":"BMI","proportion":"0.15","value":"0","proportion_value":null,"unit":"","type":"4"},{"name":"肺活量","proportion":"0.15","value":"0","proportion_value":null,"unit":"ml","type":"4"},{"name":"50米跑","proportion":"0.2","value":"00.0","proportion_value":null,"unit":"秒","type":"4"},{"name":"坐位体前屈","proportion":"0.1","value":"-1","proportion_value":null,"unit":"cm","type":"4"},{"name":"立定跳远","proportion":"0.1","value":"0","proportion_value":null,"unit":"cm","type":"4"},{"name":"引体向上","proportion":"0.1","value":"0","proportion_value":null,"unit":"个","type":"4"},{"name":"男生1000米","proportion":"0.2","value":"00:00","proportion_value":null,"unit":"分\/秒","type":"4"}]},{"name":"8年级体育与健康知识机考10分","key":"gc_8_r","is_choice":0,"list":[{"name":"机测","proportion":"1","value":"10","proportion_value":null,"unit":"分","type":"4"}]}]}]';
// dump($data['result_data']);
// dump(json_encode($data['result_data']));
// die;
// return $this->msg(json_decode($data['result_data'],true));
// xc_1
$data['result_data'] = json_decode($data['result_data'],true);
foreach ($data['result_data'] as $key => $value) {
// dump($key);
if($value['key'] == 'xc'){
foreach ($value['list'] as $k1 => $v1) {
if(count($v1['list']) <= 0){
break;
}
// dump($v1);
foreach ($v1['list'] as $k2 => $v2) {
// dump($rule[$value['key']][$v1['key']][$data['gender']][$v2['name']]['list']);
foreach ($rule[$value['key']][$v1['key']][$data['gender']][$v2['name']]['list'] as $r_k => $r_v) {
// dump($r_k);
// dump($r_k);
if($v2['value'] == '00:00' || $v2['value'] == '00.0' || $v2['value'] == '0'){
$data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = '0';
break;
}
// 设默认分值为0
$data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = '0';
if($v1['key'] == 'xc_1'){
if($this->calculate_minutes_seconds($r_k,$v2['value'])[0]){
// dump($data['result_data'][$key]);
$data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = $r_v;
break;
}
}else if($v1['key'] == 'xc_2'){
if(in_array($v2['name'],['引体向上','双杠臂屈伸','斜身引体','仰卧起坐'])){
if($v2['value'] >= $r_k){
$data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = $r_v;
break;
}
}
}else if($v1['key'] == 'xc_3'){
if(in_array($v2['name'],['足球运球/射门'])){
if($v2['value'] <= $r_k){
$data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = $r_v;
break;
}
}
}else if($v1['key'] == 'xc_4'){
if(in_array($v2['name'],['100米游泳'])){
if($this->calculate_minutes_seconds($r_k,$v2['value'])[0]){
$data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = $r_v;
break;
}
}
}
}
}
}
}else{
foreach ($value['list'] as $k1 => $v1) {
if($v1['key'] == 'gc_8_m'){
foreach ($v1['list'] as $k2 => $v2) {
foreach ($rule[$value['key']][$v1['key']][$data['gender']][$v2['name']]['list'] as $r_k => $r_v) {
if($v2['value'] == '00:00' || $v2['value'] == '00.0' || $v2['value'] == '0'){
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = '0';
break;
}
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = '0';
// dump($r_k);
if($v2['name'] == 'BMI'){
if($v2['value'] <= $r_k){
// $result['gc']['gc_8'][$key]['value'] = $v1;
// $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v;
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v;
break;
}
}else if($v2['name'] == '肺活量'){
if($v2['value'] >= $r_k){
// $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v;
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v;
// $result['gc']['gc_8'][$key]['value'] = $v1;
break;
}
}else if($v2['name'] == '50米跑'){
if($v2['value'] <= $r_k){
// $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v;
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v;
// $result['gc']['gc_8'][$key]['value'] = $v1;
break;
}
}else if($v2['name'] == '坐位体前屈'){
if($v2['value'] >= $r_k){
// $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v;
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v;
// $result['gc']['gc_8'][$key]['value'] = $v1;
break;
}
}else if($v2['name'] == '立定跳远'){
if($v2['value'] >= $r_k){
// $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v;
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v;
// $result['gc']['gc_8'][$key]['value'] = $v1;
break;
}
}else if($v2['name'] == '引体向上'){
if($v2['value'] >= $r_k){
// $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v;
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v;
// $result['gc']['gc_8'][$key]['value'] = $v1;
$add_point = $v2['value'] - 14;
if(($add_point>=1) && ($add_point<=10)){
// $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $add_point + $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'];
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $add_point + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'];
}
break;
}
}else if($v2['name'] == '一分钟仰卧起坐'){
if($v2['value'] >= $r_k){
// $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v;
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v;
$add_point = $v2['value'] - 51;
if(($add_point>=2) && ($add_point<=13)){
foreach ($rule[$value['key']][$v1['key']][$data['gender']][$v2['name']]['add_point'] as $kk1 => $vv1) {
if($add_point >= $kk1){
// $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $vv1 + $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'];
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $vv1 + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'];
break;
}
}
}else{
break;
}
}
}else if($v2['name'] == '男生1000米' || $v2['name'] == '女生800米'){
$temporary_js = $this->calculate_minutes_seconds($r_k,$v2['value']);
if($temporary_js[0]){
// $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v;
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v;
if($data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] >= 100 && $temporary_js[1] < -4){
foreach ($rule[$value['key']][$v1['key']][$data['gender']][$v2['name']]['add_point'] as $kk1 => $vv1) {
if($temporary_js[1] <= $kk1){
$data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $vv1 + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'];
break;
}
}
}else{
break;
}
}
}
}
}
}else{
// dump($v1['name']);
// dump($v1['list'][0]);
if($v1['list'][0]['value'] >= '10'){
$data['result_data'][$key]['list'][$k1]['list'][0]['proportion_value'] = '10';
}else{
$data['result_data'][$key]['list'][$k1]['list'][0]['proportion_value'] = $v1['list'][0]['value'];
}
}
}
}
}
// die;
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
// dump($data['result_data'][1]['list'][0]['list']);
foreach ($data['result_data'][1]['list'][0]['list'] as $key => $value) {
$data['result_data'][1]['list'][0]['list'][$key]['proportion_value'] = bcmul(bcdiv($data['result_data'][1]['list'][0]['list'][$key]['score'],10,20),$data['result_data'][1]['list'][0]['list'][$key]['proportion'],1);
}
$num = 0;
$result['list'] = $data['result_data'];
foreach ($result['list'] as $key => $value) {
foreach ($value['list'] as $k1 => $v1) {
foreach ($v1['list'] as $k2 => $v2) {
$num = bcadd($num,$v2['proportion_value'],1);
}
}
}
$result['total_score'] = $num;
}
// die;
// return $this->msg($result);
$user_card_list = Db::table('app_region_scores_data')->insert([
'region'=>$data['parameter_data'],
'aud_id'=>$data['aud_id'],
'content'=>json_encode($result),
'score'=>$result['total_score'],
'create_time'=>date('Y-m-d H:i:s'),
]);
if($user_card_list){
return $this->msg($result);
}else{
return $this->msg(10002);
}
}
################################################################其他################################################################
public function calculate_minutes_seconds($a,$b){
// dump($a);
// dump($b);
// if($b == '00:00'){
// }
// 分解时间字符串
$sjA = explode(':', $a);
$sjB = explode(':', $b);
$minutesA = $sjA[0];
$secondsA = $sjA[1];
$minutesB = $sjB[0];
$secondsB = $sjB[1];
// list($minutesA, $secondsA) = explode(':', $a);
// list($minutesB, $secondsB) = explode(':', $b);
// 转换为秒
$totalSecondsA = intval($minutesA) * 60 + intval($secondsA);
$totalSecondsB = intval($minutesB) * 60 + intval($secondsB);
$result = $totalSecondsB - $totalSecondsA;
if($result <= 0){
return [true,$result];
}else{
return [false,$result];
}
// 比较两个时间(秒)
// return $totalSecondsB <= $totalSecondsA;
}
public function set_rule_action(){
$user_card_list = Db::table('app_region_scores_rule')->insert([
'province'=>'北京市',
'city'=>'',
'area'=>'',
'content'=>json_encode($this->city_data_rule2['北京']),
'create_time'=>date('Y-m-d H:i:s'),
'update_time'=>date('Y-m-d H:i:s'),
]);
// $user_card_list = Db::table('app_region_scores_rule')->insert([
// 'province'=>'北京市',
// 'city'=>'',
// 'area'=>'',
// 'content'=>json_encode($this->city_data_rule2),
// 'create_time'=>date('Y-m-d H:i:s'),
// 'update_time'=>date('Y-m-d H:i:s'),
// ]);
}
public function aaaaaaaaaaaaaaa(){
// $this->set_rule_action();
// die;
// return $this->msg($this->city_data_rule2);
// wuyong
// dump('111');
$aa = cache('ceshiyong');
dump($aa);
$bb = json_decode($aa,true);
dump($bb['result_data']);
$cc = json_decode($bb['result_data'],true);
dump($cc);
// return $this->msg($bb['result_data']);
}
}