SchoolPhysicalExamination/application/NewReedaw/controller/app/Sportstesting.php

1078 lines
49 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\NewReedaw\controller\app;
use think\Db;
use Exception;
class Sportstesting extends Base{
protected $color = ['#FF5656','#FF5656','#5AD06D','#6492F6','#3967D6'];
protected $sportstesting_use_db_name = [
'tc_biaozhun'=>'admin_estimate',
'tc_jilu'=>'app_sportstesting_data',
'juese'=>'app_user_data',
];
protected $page_num = 10;
protected $default_address = '上海';
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 $ceshiyongde_data_baocun_canshu = '{
"code": 0,
"msg": "操作成功",
"data": [
{
"name": "现场考试",
"key": "现场考试",
"list": [
{
"name": "第一类项目(3选1)",
"key": "第一类项目",
"is_choice": "1",
"list": [
{
"name": "1000米跑",
"proportion": "1",
"value": "4:23",
"proportion_value": null,
"unit": "分/秒",
"type": "4",
"describe": null,
"total_score": 6,
"choice_state": 1
},
{
"name": "200米游泳",
"proportion": "1",
"value": "6:12",
"proportion_value": null,
"unit": "分/秒",
"type": "4",
"describe": null,
"total_score": 6,
"choice_state": 0
},
{
"name": "4分钟跳绳",
"proportion": "1",
"value": 340,
"proportion_value": null,
"unit": "次",
"type": "1",
"describe": null,
"total_score": 6,
"choice_state": 0
}
]
},
{
"name": "第二类项目(5选1)",
"key": "第二类项目",
"is_choice": "1",
"list": [
{
"name": "50米跑",
"proportion": "1",
"value": 8.1,
"proportion_value": null,
"unit": "秒",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 1
},
{
"name": "立定跳远",
"proportion": "1",
"value": 2.02,
"proportion_value": null,
"unit": "米",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "实心球",
"proportion": "1",
"value": 7.3,
"proportion_value": null,
"unit": "米",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "引体向上",
"proportion": "1",
"value": 6,
"proportion_value": null,
"unit": "次",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "25米游泳",
"proportion": "1",
"value": 30,
"proportion_value": null,
"unit": "秒",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
}
]
},
{
"name": "第三类项目(5选1)",
"key": "第三类项目",
"is_choice": "1",
"list": [
{
"name": "乒乓球",
"proportion": "1",
"value": 15,
"proportion_value": null,
"unit": "次",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 1
},
{
"name": "羽毛球",
"proportion": "1",
"value": 60,
"proportion_value": null,
"unit": "得分",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "网球",
"proportion": "1",
"value": 55,
"proportion_value": null,
"unit": "得分",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "武术",
"proportion": "1",
"value": "6",
"proportion_value": null,
"unit": "得分",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "体操",
"proportion": "1",
"value": "6",
"proportion_value": null,
"unit": "得分",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
}
]
},
{
"name": "第四类项目(3选1)",
"key": "第四类项目",
"is_choice": "1",
"list": [
{
"name": "足球运球",
"proportion": "1",
"value": 15.5,
"proportion_value": null,
"unit": "秒",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 1
},
{
"name": "篮球",
"proportion": "1",
"value": 31,
"proportion_value": null,
"unit": "秒",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "排球",
"proportion": "1",
"value": 23,
"proportion_value": null,
"unit": "40秒/次",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
}
]
}
]
},
{
"name": "日常考核",
"key": "日常考核",
"list": [
{
"name": "体育与健身",
"key": "体育与健身",
"is_choice": "0",
"list": [
{
"name": "7年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "分",
"type": "1",
"describe": "满分100分",
"total_score": "2"
},
{
"name": "8年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "分",
"type": "1",
"describe": "满分100分",
"total_score": "2"
},
{
"name": "9年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "分",
"type": "1",
"describe": "满分100分",
"total_score": "2"
}
]
},
{
"name": "体质健康综合评定",
"key": "体质健康综合评定",
"is_choice": "0",
"list": [
{
"name": "7年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "分",
"type": "1",
"describe": "满分100分",
"total_score": "3"
},
{
"name": "8年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "分",
"type": "1",
"describe": "满分100分",
"total_score": "3"
},
{
"name": "9年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "分",
"type": "1",
"describe": "满分100分",
"total_score": "3"
}
]
}
]
}
]
}';
protected $ceshi_data = [
[
'name' => '现场考试',
'key' => '现场考试',
'list' => [
[
'name' => '第一类:素质项目Ⅰ',
'key' => '第一类:素质项目Ⅰ',
'is_choice' => '0',
'list' => [
[
'name' => '1000米',
'proportion' => '1',
'value' => '4:55',
'proportion_value' => null,
'unit' => '分/秒',
'type' => '4',
'describe' => '1000米。考生参加考试时应穿着运动装、运动鞋鞋底不得有铁钉、胶钉或塑料钉。',
'total_score' => '8'
]
]
],
[
'name' => '第二类:素质项目Ⅱ(6选1)',
'key' => '第二类:素质项目Ⅱ',
'is_choice' => '1',
'list' => [
[
'name' => '引体向上',
'proportion' => '1',
'value' => '5',
'proportion_value' => null,
'unit' => '个',
'type' => '1',
'describe' => null,
'total_score' => '8',
'choice_state' => 1
],
[
'name' => '双杠臂屈伸',
'proportion' => '1',
'value' => '5',
'proportion_value' => null,
'unit' => '个',
'type' => '1',
'describe' => null,
'total_score' => '8',
'choice_state' => 0
],
[
'name' => '实心球',
'proportion' => '1',
'value' => '7.0',
'proportion_value' => null,
'unit' => '米',
'type' => '2',
'describe' => null,
'total_score' => '8',
'choice_state' => 0
],
[
'name' => '1分钟跳绳',
'proportion' => '1',
'value' => '140',
'proportion_value' => null,
'unit' => '次',
'type' => '1',
'describe' => null,
'total_score' => '8',
'choice_state' => 0
],
[
'name' => '原地纵跳摸高',
'proportion' => '1',
'value' => '38',
'proportion_value' => null,
'unit' => '厘米',
'type' => '1',
'describe' => null,
'total_score' => '8',
'choice_state' => 0
],
[
'name' => '立定跳远',
'proportion' => '1',
'value' => '1.85',
'proportion_value' => null,
'unit' => '米',
'type' => '2',
'describe' => null,
'total_score' => '8',
'choice_state' => 0
]
]
],
[
'name' => '第三类:运动能力Ⅰ(5选1)',
'key' => '第三类:运动能力Ⅰ',
'is_choice' => '1',
'list' => [
[
'name' => '足球--运球射门',
'proportion' => '1',
'value' => '22.5',
'proportion_value' => null,
'unit' => '秒',
'type' => '2',
'describe' => null,
'total_score' => '8',
'choice_state' => 1
],
[
'name' => '篮球--运球投篮',
'proportion' => '1',
'value' => '38.5',
'proportion_value' => null,
'unit' => '秒',
'type' => '2',
'describe' => null,
'total_score' => '8',
'choice_state' => 0
],
[
'name' => '排球--垫球发球',
'proportion' => '1',
'value' => '8.5',
'proportion_value' => null,
'unit' => '积分',
'type' => '2',
'describe' => null,
'total_score' => '8',
'choice_state' => 0
],
[
'name' => '乒乓球--左推右攻发球',
'proportion' => '1',
'value' => '32',
'proportion_value' => null,
'unit' => '次数',
'type' => '1',
'describe' => null,
'total_score' => '8',
'choice_state' => 0
],
[
'name' => '羽毛球--正反手挑球发高远',
'proportion' => '1',
'value' => '14.0',
'proportion_value' => null,
'unit' => '积分',
'type' => '2',
'describe' => null,
'total_score' => '8',
'choice_state' => 0
]
]
],
[
'name' => '第四类:运动能力Ⅱ(5选1)',
'key' => '第四类:运动能力Ⅱ',
'is_choice' => '1',
'list' => [
[
'name' => '体操双杠组合Ⅰ',
'proportion' => '1',
'value' => '4',
'proportion_value' => null,
'unit' => '积分',
'type' => '1',
'describe' => '体操4个项目的总分均为6分其中动作质量5分、动作表现1分。杠端跳上成分腿坐1 分—前进一次成分腿坐1 分—弹杠举腿进杠1 分—支撑后摆转体180 度成分腿坐1 分—弹杠进杠前摆下1 分)。',
'total_score' => '6',
'choice_state' => 1
],
[
'name' => '体操技巧组合Ⅰ',
'proportion' => '1',
'value' => '4',
'proportion_value' => null,
'unit' => '积分',
'type' => '1',
'describe' => '体操4个项目的总分均为6分其中动作质量5分、动作表现1分。鱼跃前滚翻1分—交叉转体180 度1 分—后滚成肩肘倒立1分 —前滚成蹲立1 分—挺身跳1 分)。',
'total_score' => '6',
'choice_state' => 0
],
[
'name' => '健身长拳套路',
'proportion' => '1',
'value' => '3.5',
'proportion_value' => null,
'unit' => '积分',
'type' => '2',
'describe' => '武术 2 个项目的总分均为6分其中动作质量5分、演练水平 1分。起势0.5分—开步双劈0.5分—按掌前推0.5分—搂手勾踢0.5分—缠腕斩拳0.5分—闪身冲拳0.5分—弹踢穿顶0.5分—掼拳戳脚0.5分—闪身砍推0.5分—收势0.5分)。',
'total_score' => '6',
'choice_state' => 0
],
[
'name' => '健身南拳套路',
'proportion' => '1',
'value' => '3.5',
'proportion_value' => null,
'unit' => '积分',
'type' => '2',
'describe' => '武术 2 个项目的总分均为6分其中动作质量5分、演练水平 1分。起势0.5分—架桥双砸拳0.5分—缠桥切掌0.5分—麒麟步双蝶掌1分—踩腿撞拳0.5分—挡桥冲拳0.5分—闪身虎爪0.5分—上步抽拳0.5分—架桥双砸拳0.5分)。',
'total_score' => '6',
'choice_state' => 0
],
[
'name' => '100米游泳',
'proportion' => '1',
'value' => '3:05',
'proportion_value' => null,
'unit' => '分/秒',
'type' => '4',
'describe' => '参加游泳项目考试时,考生穿着泳装、佩戴泳帽参加考试,泳装款式应符合中学生身份。不得使用任何有利于其速度、浮力、耐力的器材或泳衣,但可戴游泳镜。',
'total_score' => '6',
'choice_state' => 0
]
]
]
]
],
[
'name' => '过程性考核',
'key' => '过程性考核',
'list' => [
[
'name' => '8 年级体质健康统测',
'key' => '8 年级体质健康统测',
'is_choice' => '0',
'list' => [
[
'name' => 'BMI',
'proportion' => '0.15',
'value' => '25.3',
'proportion_value' => null,
'unit' => '千克/米㎡',
'type' => '2',
'describe' => '请参考国家学生体质健康标准高中标准',
'total_score' => '10'
],
[
'name' => '肺活量',
'proportion' => '0.15',
'value' => '2000',
'proportion_value' => null,
'unit' => '毫升',
'type' => '1',
'describe' => '请参考国家学生体质健康标准高中标准',
'total_score' => '10'
],
[
'name' => '50米跑',
'proportion' => '0.2',
'value' => '9.9',
'proportion_value' => null,
'unit' => '秒',
'type' => '2',
'describe' => '请参考国家学生体质健康标准高中标准',
'total_score' => '10'
],
[
'name' => '坐位体前屈',
'proportion' => '0.1',
'value' => '-1.4',
'proportion_value' => null,
'unit' => '厘米',
'type' => '2',
'describe' => '请参考国家学生体质健康标准高中标准',
'total_score' => '10'
],
[
'name' => '立定跳远',
'proportion' => '0.1',
'value' => '170',
'proportion_value' => null,
'unit' => '厘米',
'type' => '1',
'describe' => '请参考国家学生体质健康标准高中标准',
'total_score' => '10'
],
[
'name' => '引体向上',
'proportion' => '0.1',
'value' => '5',
'proportion_value' => null,
'unit' => '次',
'type' => '1',
'describe' => '请参考国家学生体质健康标准高中标准',
'total_score' => '10'
],
[
'name' => '1000米跑',
'proportion' => '0.2',
'value' => '5:05',
'proportion_value' => null,
'unit' => '分/秒',
'type' => '4',
'describe' => '请参考国家学生体质健康标准高中标准',
'total_score' => '10'
]
]
],
[
'name' => '8 年级体育与健康知识',
'key' => '8 年级体育与健康知识',
'is_choice' => '0',
'list' => [
[
'name' => '机考',
'proportion' => '1',
'value' => '0.0',
'proportion_value' => null,
'unit' => '分数',
'type' => '2',
'describe' => '机考为8年级体育与健康知识,满分10分。',
'total_score' => '10'
]
]
]
]
]
];
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
################################################################接口################################################################
################################################################接口################################################################
################################################################接口################################################################
// 获取地区类型列表
public function sportstesting_get_region_list(){
$data = input('post.');
try {
if(!array_key_exists('gender', $data) || !array_key_exists('parameter_data', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['parameter_data'],'str')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['gender'],'intnum')){
return $this->msg(10005);
}
// if(!$this->verify_data_is_ok($data['choice_last_time'],'intnum')){
// return $this->msg(10005);
// }else{
// if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
// return $this->msg(10005);
// }
// }
$return_data = $this->sportstesting_get_region_list_action($data);
// 成功
$this->record_api_log($data, null, $return_data);
return $return_data;
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
$logContent["line"] = $e->getLine();
$logContent['all_content'] = "异常信息:\n";
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
return $this->msg(99999);
}
}
// 计算并存储数据
public function sportstesting_set_once_data(){
$data = input('post.');
// $data['result_data'] = $this->ceshi_data;
try {
// $data['result_data'] = json_decode($this->ceshiyongde_data_baocun_canshu,true)['data'];
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_data = $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['parameter_data'],'str')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['gender'],'intnum')){
return $this->msg(10005);
}
if(is_array($data['result_data']) && !empty($data['result_data'])){
// 是个数组且不为空数组
foreach ($data['result_data'] as $key => $value) {
foreach ($value['list'] as $k => $v) {
if(count($v['list']) <= 0){
return $this->msg(10010,$v['name'].'内并未选择内容');
}
if($v['is_choice'] >= 0 && count($v['list']) < $v['is_choice']){
return $this->msg(10010,$v['name'].'内并缺少选项,请选择'.$v['is_choice'].'个选项');
}
foreach ($v['list'] as $c_k => $c_v) {
if(count($c_v) <= 0){
return $this->msg(10010,$v['name'].'选项内内容异常');
}
}
}
}
}else{
return $this->msg(10006);
}
// die;
unset($data['token']);
// dump($data);
// die;
$return_data = $this->sportstesting_set_once_data_action2($data);
return $return_data;
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
$logContent["line"] = $e->getLine();
$logContent['all_content'] = "异常信息:\n";
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
return $this->msg(99999);
}
}
################################################################业务################################################################
################################################sportstesting_get_region_list
public function sportstesting_get_region_list_action($data){
$parameter_data = explode(',',$data['parameter_data']);
$gender = $data['gender'];
// 精准查询地市规则start
// 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);
// }
// 精准查询地市规则end
// 全省地市一个规则start
$db_condition = "province = '".$parameter_data[0]."'";
// 全省地市一个规则end
$result = false;
// if($data['choice_last_time'] == 1){
// $last_tiame_data = Db::table($this->sportstesting_use_db_name['tc_jilu'])->where(['aud_id'=>$data['aud_id'],'address'=>$data['parameter_data']])->order('id desc')->find();
// if($last_tiame_data){
// $result = json_decode($last_tiame_data['content'],true);
// }else{
// $result = false;
// }
// }
if($result === false){
$rule_data = Db::table($this->sportstesting_use_db_name['tc_biaozhun'])->where($db_condition)->select();
if(count($rule_data) > 0){
if(count($rule_data) > 1){
// 查到不止一条规则
return $this->msg(10004,'查询地址不够详细,请重新选择省市地区');
}
$rule_data = json_decode($rule_data[0]['content'],true);
$result = $this->handle_default_rule_list($rule_data,$gender);
}else{
return $this->msg(10004,'暂无该地区的估分规则,请选择其它地区');
}
}
return $this->msg($result);
}
public function sportstesting_set_once_data_action2($data){
$return_result['total_score'] = 0;
$return_result['max_score'] = 0;
$parameter_data = explode(',',$data['parameter_data']);
$gender = $data['gender'];
if(count($parameter_data) == 1){
// $db_condition = "province = '".$parameter_data[0]."'";
$db_condition = "province = '".$parameter_data[0]."'";
}else if(count($parameter_data) == 2){
// $db_condition = "province = '".$parameter_data[0]."' and city = '".$parameter_data[1]."'";
$db_condition = "province = '".$parameter_data[0]."'";
}else if(count($parameter_data) == 3){
// $db_condition = "province = '".$parameter_data[0]."' and city = '".$parameter_data[1]."' and area = '".$parameter_data[2]."'";
$db_condition = "province = '".$parameter_data[0]."'";
}else{
return $this->msg(10005);
}
// 只根据省查找,全省一个标准
$find_data = Db::table($this->sportstesting_use_db_name['tc_biaozhun'])->where($db_condition)->find();
// dump($find_data);
// die;
$find_data = json_decode($find_data['content'],true);
$recognition_rule = $find_data[$gender];
foreach ($data['result_data'] as $key => $value) {
// 遍历一级($value['key'] = 现场考试)
foreach ($value['list'] as $k2 => $v2) {
// 遍历二级级($v2['key'] = 第一类项目
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;
// $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
if(array_key_exists('choice_state',$v3) && $v3['choice_state'] == 0){
continue;
}
$return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
$return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// if(array_key_exists('choice_state',$v3)){
// if($v3['choice_state'] == 1){
// $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;
// // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
// $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
// $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// }else{
// $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;
// // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
// $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
// $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// }
// }else{
// $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;
// // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
// $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
// $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// }
}
}
}
$return_result['list'] = $data['result_data'];
$user_sportstesting_set = Db::table($this->sportstesting_use_db_name['tc_jilu'])->insert([
'aud_id'=>$data['aud_id'],
'content'=>json_encode($return_result['list']),
'score'=>$return_result['total_score'],
'max_score'=>$return_result['max_score'],
'create_time'=>date('Y-m-d H:i:s'),
'address'=>$data['parameter_data'],
]);
// $user_sportstesting_set = true;
if($user_sportstesting_set){
foreach ($return_result['list'] as $key => $value) {
foreach ($value['list'] as $v1k => $v1v) {
for( $i=0; $i < count($v1v['list']); $i++ ){
if(array_key_exists('choice_state',$v1v['list'][$i]) && $v1v['list'][$i]['choice_state'] == 0){
unset($return_result['list'][$key]['list'][$v1k]['list'][$i]);
}
}
array_unshift($return_result['list'][$key]['list'][$v1k]['list'],[
'name'=>'项目名',
'value'=>'成绩',
'total_score'=>'满分',
'proportion_value'=>'得分',
]);
}
}
return $this->msg($return_result);
}else{
return $this->msg(10002);
}
}
// 处理默认规则列表
public function handle_default_rule_list($data,$gender){
if($gender == 1){
$temporary_arr = $data[$gender];
}else{
$temporary_arr = $data[2];
}
$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'],
'describe'=>$x_m_v['describe'],
'total_score'=>$x_m_v['score'],
]);
}
}else{
// 如果不是必选项
$num2 = array_push($result[$num-1]['list'],[
'name'=>$s_c_k."(".count($s_c_v['list'])."".$s_c_v['choose_num'].")",
'key'=>$s_c_k,
'is_choice'=>$s_c_v['choose_num'],
'list'=>[]
]);
$choice_state_num = $s_c_v['choose_num'];
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'],
'describe'=>$x_m_v['describe'],
'total_score'=>$x_m_v['score'],
'choice_state'=>$choice_state_num > 0?1:0,
]);
$choice_state_num = $choice_state_num-1;
}
}
}
}
return $result;
}
// 取得成绩
public function obtaining_grades($rule,$data){
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
if($data['value'] != '' && $data['value'] != null && $data['value'] != '0' && $data['value'] != '0.0' && $data['value'] != '0.0' && $data['value'] != '0:00'){
if(count($rule) > 0){
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: " . $value[1]);
}
if($result == true){
// 判断是不是0分
if($data_result == 0){
$data['score'] = 0;
}else{
$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),2);
// 四舍五入一下结果
$data['proportion_value'] = $this->roundToString($data['proportion_value'],1);
break;
}
}
}else{
$data['score'] = $data['value'] <= $data['total_score']?bcmul(bcdiv($data['value'],$data['total_score'],20),100,2):100;
// 计算比例后分值
$data['proportion_value'] = $data['value'] <= $data['total_score']?$data['value']:$data['total_score'];
}
}else{
$data['score'] = 0;
// 计算比例后分值
$proportional_post_score = bcmul($data['total_score'],$data['proportion'],2);
$data['proportion_value'] = bcmul($data['score'],bcdiv($proportional_post_score,100,2),1);
}
return $data;
}
}