'现场类项目', '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 = ['address'=>'上海','gender'=>'1','token'=>'caadd1be045a65f30b92aa805f1de54a']){ if(count(input('post.')) > 0){ $data = input('post.'); } if(!array_key_exists('address', $data) || !array_key_exists('gender', $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']); return $this->sportstesting_get_type_list_action($data); } // 获取地区类型列表 public function sportstesting_get_region_list($data = ['parameter_data'=>'上海','gender'=>'1','token'=>'caadd1be045a65f30b92aa805f1de54a']){ if(count(input('post.')) > 0){ $data = input('post.'); } if(!array_key_exists('gender', $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']); return $this->sportstesting_get_region_list_action($data); } // 获取估分最后一次数据 public function sportstesting_get_last_data($data = ['aud_id'=>'61','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'=>'上海','result_data'=>'','gender'=>'1','token'=>'caadd1be045a65f30b92aa805f1de54a']){ 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_action2($data); // 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'=>'caadd1be045a65f30b92aa805f1de54a']){ 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']); return $this->sportstesting_get_one_details_action($data); } // 获取估分已有的地区列表 public function sportstesting_get_city_list($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','type'=>'1']){ if(count(input('post.')) > 0){ $data = input('post.'); } if(!array_key_exists('token', $data) || !array_key_exists('type', $data)){ return $this->msg(10001); } // cache($data['token'], time()); if($this->token_time_validate($data['token']) === false){ return $this->msg(20001); } unset($data['token']); return $this->sportstesting_get_city_list_action($data); } ################################################################业务################################################################ ################################################sportstesting_get_type_list public function sportstesting_get_type_list_action($data){ $parameter_data = explode(',',$data['address']); $gender = $data['gender']; if(count($parameter_data) == 1){ $db_condition = "province = '".$parameter_data[0]."'"; }else if(count($parameter_data) == 2){ $db_condition = "province = '".$parameter_data[0]."' and city = '".$parameter_data[1]."'"; }else if(count($parameter_data) == 3){ $db_condition = "province = ".$parameter_data[0]."' and city = '".$parameter_data[1]."' and area = '".$parameter_data[2]."'"; }else{ return $this->msg(10005); } $data = Db::table('admin_estimate')->where($db_condition)->find(); $data = json_decode($data['content'],true); // dump($data); // die; $result = $this->handle_default_rule_list_content($data,$gender); // die; return $this->msg($result); } ################################################sportstesting_get_region_list public function sportstesting_get_region_list_action($data){ $parameter_data = explode(',',$data['parameter_data']); $gender = $data['gender']; if(count($parameter_data) == 1){ $db_condition = "province = '".$parameter_data[0]."'"; }else if(count($parameter_data) == 2){ $db_condition = "province = '".$parameter_data[0]."' and city = '".$parameter_data[1]."'"; }else if(count($parameter_data) == 3){ $db_condition = "province = ".$parameter_data[0]."' and city = '".$parameter_data[1]."' and area = '".$parameter_data[2]."'"; }else{ return $this->msg(10005); } // dump($db_condition); // die; $result['list'] = []; $result['total_score'] = 0; $data = Db::table('admin_estimate')->where($db_condition)->find(); // dump($data); // die; if($data){ // dump(568); // die; $data = json_decode($data['content'],true); $result = $this->handle_default_rule_list($data,$gender); return $this->msg($result); }else{ return $this->msg(10004,'暂无该地区的估分规则,请选择其它地区'); } } ################################################sportstesting_get_last_data public function sportstesting_get_last_data_action($data){ $user_data = Db::table('app_sportstesting_data')->where(['aud_id'=>$data['aud_id']])->order('id desc')->find(); if($user_data){ $address = explode(',',$user_data['address']); $temporary_data = json_decode($user_data['content'],true); $result['list'] = $temporary_data; $result['total_score'] = $user_data['score']; $result['province'] = count($address)>=1?$address[0]:''; $result['city'] = count($address)>=2?$address[1]:''; $result['area'] = count($address)>=3?$address[2]:''; return $this->msg($result); }else{ $user_msg_data = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('id,gender')->find(); if(!$user_msg_data){ return $this->msg(10004); } $address = $this->default_address; // dump($address); // die; $address_data = $this->sportstesting_get_region_list_action(['parameter_data'=>$address,'gender'=>$user_msg_data['gender']]); // dump(json_decode($address_data->getContent(),true)); // dump(get_object_vars($address_data)); // die; $address_data = json_decode($address_data->getContent(),true); // return $this->msg($address_data); if($address_data['code'] == 10004){ return $this->msg(10004); } $address = explode(',',$address); $result['list'] = $address_data['data']; $result['total_score'] = 0; $result['province'] = count($address)>=1?$address[0]:''; $result['city'] = count($address)>=2?$address[1]:''; $result['area'] = count($address)>=3?$address[2]:''; return $this->msg($result); } } ################################################sportstesting_get_all_list public function sportstesting_get_all_list_action($data){ $user_data_num = Db::table('app_sportstesting_data')->where(['aud_id'=>$data['aud_id']])->count(); $user_data = Db::table('app_sportstesting_data')->where(['aud_id'=>$data['aud_id']])->page($data['page'],$this->page_num)->order('id desc')->select(); // dump($user_data); // die; 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'], 'address'=>$value['address'], ]); } 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_sportstesting_data')->where(['id'=>$data['id']])->find(); if($user_data){ $temporary_data['list'] = json_decode($user_data['content'],true); // 压入表头 foreach ($temporary_data['list'] as $key => $value) { foreach ($value['list'] as $v1k => $v1v) { array_unshift($temporary_data['list'][$key]['list'][$v1k]['list'],[ 'name'=>'项目名', 'value'=>'成绩', 'score'=>'分值', 'proportion_value'=>'得分', ]); } } $temporary_data['score'] = $user_data['score']; $temporary_data['address'] = $user_data['address']; $temporary_data['create_time'] = $user_data['create_time']; return $this->msg($temporary_data); }else{ return $this->msg(10004); } } public function sportstesting_set_once_data_action2($data){ $return_result['total_score'] = 0; $parameter_data = explode(',',$data['parameter_data']); $gender = $data['gender']; if(count($parameter_data) == 1){ $db_condition = "province = '".$parameter_data[0]."'"; }else if(count($parameter_data) == 2){ $db_condition = "province = '".$parameter_data[0]."' and city = '".$parameter_data[1]."'"; }else if(count($parameter_data) == 3){ $db_condition = "province = '".$parameter_data[0]."' and city = '".$parameter_data[1]."' and area = '".$parameter_data[2]."'"; }else{ return $this->msg(10005); } $find_data = Db::table('admin_estimate')->where($db_condition)->find(); $find_data = json_decode($find_data['content'],true); $recognition_rule = $find_data[$gender]; // dump($recognition_rule); // 测试用删掉s // $data['result_data'] = $this->handle_default_rule_list2($find_data,$gender); // 测试用删掉e // dump($data); // die; foreach ($data['result_data'] as $key => $value) { // 遍历一级($value['key'] = 现场考试) // dump($value); foreach ($value['list'] as $k2 => $v2) { // 遍历二级级($v2['key'] = 第一类项目 // dump($v2); foreach ($v2['list'] as $k3 => $v3) { // 遍历二级级($v3['name'] = 1000米跑) $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3); $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result; $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2); } } } $return_result['list'] = $data['result_data']; $user_sportstesting_set = Db::table('app_sportstesting_data')->insert([ 'aud_id'=>$data['aud_id'], 'content'=>json_encode($return_result['list']), 'score'=>$return_result['total_score'], 'create_time'=>date('Y-m-d H:i:s'), 'address'=>$data['parameter_data'], ]); if($user_sportstesting_set){ foreach ($return_result['list'] as $key => $value) { foreach ($value['list'] as $v1k => $v1v) { array_unshift($return_result['list'][$key]['list'][$v1k]['list'],[ 'name'=>'项目名', 'value'=>'成绩', 'score'=>'分值', 'proportion_value'=>'得分', ]); } } return $this->msg($return_result); }else{ return $this->msg(10002); } } ################################################sportstesting_get_city_list public function sportstesting_get_city_list_action($type){ if($type['type'] == '1'){ // 已有地区列表 $data = Db::table('admin_estimate')->field('id,province,city,area')->select(); $result = []; // 添加省份 foreach ($data as $key => $value) { if(!array_key_exists($value['province'],$result)){ $result[$value['province']] = []; } } // 添加市 foreach ($data as $key => $value) { if($value['city'] == '无'){ continue; }else{ if(array_key_exists($value['province'],$result)){ if(!array_key_exists($value['city'],$result[$value['province']])){ $result[$value['province']][$value['city']] = []; } } } } // 添加区县 foreach ($data as $key => $value) { if($value['area'] == '无'){ continue; }else{ if(array_key_exists($value['province'],$result)){ if(array_key_exists($value['city'],$result[$value['province']])){ if(!array_key_exists($value['area'],$result[$value['province']][$value['city']])){ array_push($result[$value['province']][$value['city']],$value['area']); } } } } } $return_result = []; foreach ($result as $key => $value) { $num = array_push($return_result,['name'=>$key,'list'=>[]]); if(count($value)>0){ foreach ($value as $city_k => $city_v) { $num2 = array_push($return_result[$num-1]['list'],['name'=>$city_k,'list'=>$city_v]); } } } return $this->msg($result); }else if($type['type'] == '2'){ $data = Db::table('admin_estimate')->where(['type' => '2'])->field('id,content,city,area')->find(); $result = json_decode($data['content'],true); return $this->msg($result); }else{ return $this->msg(10005); } } ################################################################其他################################################################ public function calculate_minutes_seconds($a,$b){ // 分解时间字符串 $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; } // 处理分秒变秒 function convertMinutesSecondsToStringSeconds($timeString) { // 分割字符串获取分钟和秒 list($minutes, $seconds) = explode(':', $timeString); // 将分钟和秒转换为秒 $totalSeconds = ($minutes * 60) + intval($seconds); // 确保秒是整数 return $totalSeconds; } // 处理默认规则列表 public function handle_default_rule_list($data,$gender){ $temporary_arr = $data[$gender]; $result = []; foreach ($temporary_arr as $key => $value) { $num = array_push($result,['name'=>$key,'key'=>$key,'list'=>[]]); foreach ($value as $s_c_k => $s_c_v) { if($s_c_v['choose_num'] == 0){ $num2 = array_push($result[$num-1]['list'],[ 'name'=>$s_c_k, 'key'=>$s_c_k, 'is_choice'=>$s_c_v['choose_num'], 'list'=>[] ]); foreach ($s_c_v['list'] as $x_m_k => $x_m_v) { array_push($result[$num-1]['list'][$num2-1]['list'],[ 'name'=>$x_m_k, 'proportion'=>$x_m_v['proportion'], 'value'=>$x_m_v['value'], 'proportion_value'=>null, 'unit'=>$x_m_v['unit_data'], 'type'=>$x_m_v['type'], 'total_score'=>$x_m_v['score'], ]); } }else{ $num2 = array_push($result[$num-1]['list'],['name'=>$s_c_k,'key'=>$s_c_k,'is_choice'=>$s_c_v['choose_num'],'list'=>[]]); } } } // dump($result); // die; return $result; } // 获取所有选择项内容 public function handle_default_rule_list_content($data,$gender){ $temporary_arr = $data[$gender]; $result['list'] = []; foreach ($temporary_arr as $key => $value) { foreach ($value as $k2 => $v2) { if($v2['choose_num'] != 0){ $temporary_arr = []; $temporary_arr['key'] = $k2; $temporary_arr['list'] = []; // dump($v2); foreach ($v2['list'] as $k3 => $v3) { // dump($v3); array_push($temporary_arr['list'],[ 'name'=>$k3, 'proportion'=>$v3['proportion'], 'value'=>$v3['value'], 'proportion_value'=>null, 'unit'=>$v3['unit_data'], 'type'=>$v3['type'], 'total_score'=>$v3['score'], ]); } // dump($temporary_arr); array_push($result['list'],$temporary_arr); } } } return $result; } // 取得成绩 public function obtaining_grades($rule,$data){ // 加 bcadd(,,20) // 减 bcsub(,,20) // 乘 bcmul(,,20) // 除 bcdiv(,,20) // dump($data['total_score']); // die; foreach ($rule as $key => $value) { if($data['unit'] == '分/秒'){ $rule_result = $this->convertMinutesSecondsToStringSeconds($value[0]); $data_result = $this->convertMinutesSecondsToStringSeconds($data['value']); }else{ $rule_result = $value[0]; $data_result = $data['value']; } switch ($value[1]) { case "<=": $result = $data_result <= $rule_result; break; case ">=": $result = $data_result >= $rule_result; break; case "<": $result = $data_result < $rule_result; break; case ">": $result = $data_result > $rule_result; break; case "==": $result = $data_result == $rule_result; break; case "!=": $result = $data_result != $rule_result; break; default: // 如果比较符号不是上述任何一个,可以抛出一个异常或错误 throw new Exception("Unsupported comparison operator: " . $a[1]); } // dump($result); if($result == true){ $data['score'] = $value[2]; // 计算比例后分值 $proportional_post_score = bcmul($data['total_score'],$data['proportion'],2); $data['proportion_value'] = bcmul($data['score'],bcdiv($proportional_post_score,100,2),1); break; } } return $data; } // 弄一套可以计算的返回数据(删) public function handle_default_rule_list2($data,$gender){ $temporary_arr = $data[$gender]; $result = []; foreach ($temporary_arr as $key => $value) { $num = array_push($result,['name'=>$key,'key'=>$key,'list'=>[]]); foreach ($value as $s_c_k => $s_c_v) { if($s_c_v['choose_num'] == 0){ $num2 = array_push($result[$num-1]['list'],[ 'name'=>$s_c_k, 'key'=>$s_c_k, 'is_choice'=>$s_c_v['choose_num'], 'list'=>[] ]); foreach ($s_c_v['list'] as $x_m_k => $x_m_v) { array_push($result[$num-1]['list'][$num2-1]['list'],[ 'name'=>$x_m_k, 'proportion'=>$x_m_v['proportion'], 'value'=>2, 'proportion_value'=>null, 'unit'=>$x_m_v['unit_data'], 'type'=>$x_m_v['type'], 'total_score'=>$x_m_v['score'], ]); } }else{ $num2 = array_push($result[$num-1]['list'],['name'=>$s_c_k,'key'=>$s_c_k,'is_choice'=>$s_c_v['choose_num'],'list'=>[]]); foreach ($s_c_v['list'] as $x_m_k => $x_m_v) { array_push($result[$num-1]['list'][$num2-1]['list'],[ 'name'=>$x_m_k, 'proportion'=>$x_m_v['proportion'], 'value'=>$x_m_v['value'], 'proportion_value'=>null, 'unit'=>$x_m_v['unit_data'], 'type'=>$x_m_v['type'], 'total_score'=>$x_m_v['score'], ]); if($x_m_k == '1000米跑'){ $result[$num-1]['list'][$num2-1]['list'][0]['value'] = '4:07'; }else if($x_m_k == '50米跑'){ $result[$num-1]['list'][$num2-1]['list'][0]['value'] = '7.3'; }else if($x_m_k == '乒乓球'){ $result[$num-1]['list'][$num2-1]['list'][0]['value'] = '25'; }else if($x_m_k == '足球运球'){ $result[$num-1]['list'][$num2-1]['list'][0]['value'] = '9.5'; } break; } } } } return $result; } }