测试新版
This commit is contained in:
parent
79d87dce79
commit
6714ccf4dc
|
|
@ -10,7 +10,7 @@ use think\Log;
|
|||
class Base extends Controller{
|
||||
|
||||
protected $ceshiyong_token = 'caadd1be045a65f30b92aa805f1de54a';
|
||||
protected $token_time = 86400*3;
|
||||
protected $token_time = 86400*30;//天
|
||||
protected $return_data_all = [
|
||||
// '0' => ['success',[]],
|
||||
'10001'=>'关键参数缺失',
|
||||
|
|
@ -117,7 +117,7 @@ class Base extends Controller{
|
|||
// 判断token是否过期
|
||||
public function token_time_validate($token){
|
||||
// cache($token,time());
|
||||
// return true;
|
||||
|
||||
$time = cache($token);
|
||||
// dump($time);
|
||||
if($time === false){
|
||||
|
|
@ -205,11 +205,19 @@ class Base extends Controller{
|
|||
}
|
||||
|
||||
|
||||
public function ceshiyong(){
|
||||
$result = Db::query("select * from app_card_data");
|
||||
dump($result);
|
||||
$result2 = Db::table('app_card_data')->select();
|
||||
dump($result2);
|
||||
|
||||
####################################################测试用接口##############################################################
|
||||
|
||||
|
||||
public function use_test(){
|
||||
|
||||
$this->token_time_validate($this->ceshiyong_token);
|
||||
$token='caadd1be045a65f30b92aa805f1de54a';
|
||||
|
||||
// $result = Db::query("select * from app_card_data");
|
||||
// dump($result);
|
||||
// $result2 = Db::table('app_card_data')->select();
|
||||
// dump($result2);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,13 @@ class Estimate extends Base{
|
|||
public function estimate_add(){
|
||||
return $this->fetch();
|
||||
}
|
||||
public function estimate_edit(){
|
||||
$data = input();
|
||||
$this->assign([
|
||||
'id' => $data['id'],
|
||||
]);
|
||||
return $this->fetch();
|
||||
}
|
||||
// 规则详情页面
|
||||
public function estimate_content_observe(){
|
||||
$data = input();
|
||||
|
|
@ -151,7 +158,7 @@ class Estimate extends Base{
|
|||
if($name['type'] == 'create'){
|
||||
$result = Db::table('admin_estimate')->insert($handle_data);
|
||||
}else{
|
||||
$result = Db::table('admin_estimate')->where(['id'=>$name['id']])->update($handle_data);
|
||||
$result = Db::table('admin_estimate')->where(['id'=>$name['update_id']])->update($handle_data);
|
||||
}
|
||||
|
||||
// return $this->msg(10002);
|
||||
|
|
@ -237,78 +244,82 @@ class Estimate extends Base{
|
|||
$gender = explode(',',$value[5]);
|
||||
foreach ($gender as $gk => $gv) {
|
||||
if(!array_key_exists($gv,$temporary_array)){
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['score'] = $value[2];
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['score'] = $value[2];
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['choose_num'] = $value[9];
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]] = [
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]] = [
|
||||
'unit_data'=>$value[4],
|
||||
'proportion'=>$value[10],
|
||||
'value'=>$value[11],
|
||||
'type'=>$value[12],
|
||||
'score'=>$value[2],
|
||||
];
|
||||
if($value[6] == null){
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['score'] = $value[8];
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['content'] = [];
|
||||
}else{
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
}
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
// if($value[6] == null){
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [];
|
||||
// }else{
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
// }
|
||||
}else{
|
||||
// 如果性别已经存在
|
||||
if(!array_key_exists($value[0],$temporary_array[$gv])){
|
||||
// 如果第一分类不存在
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['score'] = $value[2];
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['score'] = $value[2];
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['choose_num'] = $value[9];
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]] = [
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]] = [
|
||||
'unit_data'=>$value[4],
|
||||
'proportion'=>$value[10],
|
||||
'value'=>$value[11],
|
||||
'type'=>$value[12],
|
||||
'score'=>$value[2],
|
||||
];
|
||||
if($value[6] == null){
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['score'] = $value[8];
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['content'] = [];
|
||||
}else{
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
}
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
// if($value[6] == null){
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [];
|
||||
// }else{
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
// }
|
||||
}else{
|
||||
// 第一分类存在
|
||||
if(!array_key_exists($value[1],$temporary_array[$gv][$value[0]])){
|
||||
// 如果第二分类不存在
|
||||
// array_push($temporary_array[$value[0]]);
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['score'] = $value[2];
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['score'] = $value[2];
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['choose_num'] = $value[9];
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]] = [
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]] = [
|
||||
'unit_data'=>$value[4],
|
||||
'proportion'=>$value[10],
|
||||
'value'=>$value[11],
|
||||
'type'=>$value[12],
|
||||
'score'=>$value[2],
|
||||
];
|
||||
if($value[6] == null){
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['score'] = $value[8];
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['content'] = [];
|
||||
}else{
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
}
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
// if($value[6] == null){
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [];
|
||||
// }else{
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
// }
|
||||
}else{
|
||||
// 第二分类存在
|
||||
|
||||
if(!array_key_exists($value[3],$temporary_array[$gv][$value[0]][$value[1]])){
|
||||
if(!array_key_exists($value[3],$temporary_array[$gv][$value[0]][$value[1]]['list'])){
|
||||
// 如果项目名不存在
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['score'] = $value[2];
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['score'] = $value[2];
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['choose_num'] = $value[9];
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]] = [
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]] = [
|
||||
'unit_data'=>$value[4],
|
||||
'proportion'=>$value[10],
|
||||
'value'=>$value[11],
|
||||
'type'=>$value[12],
|
||||
'score'=>$value[2],
|
||||
];
|
||||
if($value[6] == null){
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['score'] = $value[8];
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['content'] = [];
|
||||
}else{
|
||||
$temporary_array[$gv][$value[0]][$value[1]][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
}
|
||||
$temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
// if($value[6] == null){
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [];
|
||||
// }else{
|
||||
// $temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'] = [[$value[6],$value[7],$value[8]]];
|
||||
// }
|
||||
}else{
|
||||
array_push($temporary_array[$gv][$value[0]][$value[1]][$value[3]]['content'],[$value[6],$value[7],$value[8]]);
|
||||
array_push($temporary_array[$gv][$value[0]][$value[1]]['list'][$value[3]]['content'],[$value[6],$value[7],$value[8]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@
|
|||
</div> -->
|
||||
<div class="layui-form-item">
|
||||
<label for="L_repass" class="layui-form-label"></label>
|
||||
<button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
|
||||
<button class="layui-btn" lay-filter="add" lay-submit="">修改</button>
|
||||
<!-- <button lay-filter="add" lay-submit="" v-on:click="asdaa">增加 {{num_test}}</button> -->
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -150,6 +150,7 @@
|
|||
</div>
|
||||
<script type="text/javascript" src="/x_admin/js/xcity.js"></script>
|
||||
<script>
|
||||
var update_id="{$id}"
|
||||
var form
|
||||
var file_name_all = ''
|
||||
var file_name = ''
|
||||
|
|
@ -320,7 +321,9 @@
|
|||
var formdata = new FormData();
|
||||
formdata.append('execl',$('#upload_file_app')[0].files[0])
|
||||
formdata.append('address',address_arr)
|
||||
formdata.append('type','create')
|
||||
formdata.append('type','update')
|
||||
formdata.append('update_id',update_id)
|
||||
|
||||
// formdata.append('bluetooth_type',$('#bluetooth_type').val())
|
||||
// formdata.append('page_measure',$('#page_measure').val())
|
||||
// formdata.append('content',$('#content').val())
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@
|
|||
</td> -->
|
||||
<td>
|
||||
<button class="layui-btn" onclick="xadmin.open('查看','/estimate/estimate_content_observe?id={$vo.id}','100%','100%')">查看</button>
|
||||
<button class="layui-btn" onclick="xadmin.open('修改','/device/device_edit?id={$vo.id}','50%','70%')">修改</button>
|
||||
<button class="layui-btn" onclick="xadmin.open('修改','/estimate/estimate_edit?id={$vo.id}','50%','70%')">修改</button>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class Base extends Controller{
|
|||
|
||||
protected $ceshiyong_token = 'caadd1be045a65f30b92aa805f1de54a';
|
||||
protected $base_call_method = ['内部'];
|
||||
protected $token_time = 86400*3;
|
||||
protected $token_time = 86400*30;
|
||||
protected $return_data_all = [
|
||||
// '0' => ['success',[]],
|
||||
'10001'=>'关键参数缺失',
|
||||
|
|
@ -117,8 +117,9 @@ class Base extends Controller{
|
|||
|
||||
// 判断token是否过期
|
||||
public function token_time_validate($token){
|
||||
// cache($token,time());
|
||||
// return true;
|
||||
if($token == $this->ceshiyong_token){
|
||||
return true;
|
||||
}
|
||||
$time = cache($token);
|
||||
// dump($time);
|
||||
if($time === false){
|
||||
|
|
|
|||
|
|
@ -598,11 +598,11 @@ class Sportstesting extends Base{
|
|||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
// 获取单个类型列表
|
||||
public function sportstesting_get_type_list($data = ['aud_id'=>'25','parameter_data'=>'北京','gender'=>'1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||
public function sportstesting_get_type_list($data = ['address'=>'河南,郑州市','parameter_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('token', $data)){
|
||||
if(!array_key_exists('address', $data) || !array_key_exists('parameter_data', $data) || !array_key_exists('gender', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
// cache($data['token'], time());
|
||||
|
|
@ -614,11 +614,11 @@ class Sportstesting extends Base{
|
|||
return $this->sportstesting_get_type_list_action($data);
|
||||
}
|
||||
// 获取地区类型列表
|
||||
public function sportstesting_get_region_list($data = ['aud_id'=>'25','parameter_data'=>'北京','gender'=>'1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||
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('aud_id', $data) || !array_key_exists('parameter_data', $data) || !array_key_exists('token', $data)){
|
||||
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());
|
||||
|
|
@ -626,7 +626,6 @@ class Sportstesting extends Base{
|
|||
return $this->msg(20001);
|
||||
}
|
||||
unset($data['token']);
|
||||
// cache('sportstesting_get_region_list',json_encode($data));
|
||||
return $this->sportstesting_get_region_list_action($data);
|
||||
}
|
||||
// 获取估分最后一次数据
|
||||
|
|
@ -646,7 +645,7 @@ class Sportstesting extends Base{
|
|||
}
|
||||
|
||||
// 计算并存储数据
|
||||
public function sportstesting_set_once_data($data = ['aud_id'=>'25','parameter_data'=>'北京市,province','result_data'=>'','gender'=>'1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||
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.');
|
||||
}
|
||||
|
|
@ -659,7 +658,9 @@ class Sportstesting extends Base{
|
|||
// cache('sportstesting_set_once_data',json_encode($data));
|
||||
// return $this->msg($data);
|
||||
unset($data['token']);
|
||||
return $this->sportstesting_set_once_data_action($data);
|
||||
|
||||
return $this->sportstesting_set_once_data_action2($data);
|
||||
// return $this->sportstesting_set_once_data_action($data);
|
||||
}
|
||||
|
||||
// 获取估分历史列表
|
||||
|
|
@ -695,9 +696,56 @@ class Sportstesting extends Base{
|
|||
return $this->sportstesting_get_one_details_action($data);
|
||||
}
|
||||
|
||||
// 获取估分已有的地区列表
|
||||
public function sportstesting_get_city_list($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!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_city_list_action();
|
||||
}
|
||||
|
||||
################################################################业务################################################################
|
||||
################################################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);
|
||||
|
||||
$result = $this->handle_default_rule_list_content($data,$gender);
|
||||
// die;
|
||||
return $this->msg($result);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// $parameter_data = explode('-',$data['parameter_data']);
|
||||
// if(count($parameter_data) < 3){
|
||||
// return $this->msg(10005);
|
||||
|
|
@ -742,37 +790,57 @@ class Sportstesting extends Base{
|
|||
// 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)){
|
||||
|
||||
$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);
|
||||
$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) {
|
||||
$data = Db::table('admin_estimate')->where($db_condition)->find();
|
||||
$data = json_decode($data['content'],true);
|
||||
$result = $this->handle_default_rule_list($data,$gender);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
// 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();
|
||||
|
|
@ -890,7 +958,6 @@ class Sportstesting extends Base{
|
|||
return $this->msg(10004);
|
||||
}
|
||||
}
|
||||
|
||||
################################################sportstesting_set_once_data
|
||||
public function sportstesting_set_once_data_action($data){
|
||||
$region = explode(',',$data['parameter_data']);
|
||||
|
|
@ -1244,17 +1311,103 @@ class Sportstesting extends Base{
|
|||
}
|
||||
|
||||
}
|
||||
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();
|
||||
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'] = $return_result['total_score']+$temporary_result['proportion_value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return_result['list'] = $data['result_data'];
|
||||
|
||||
return $this->msg($return_result);
|
||||
|
||||
}
|
||||
################################################sportstesting_get_city_list
|
||||
public function sportstesting_get_city_list_action(){
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################其他################################################################
|
||||
|
||||
public function calculate_minutes_seconds($a,$b){
|
||||
// dump($a);
|
||||
// dump($b);
|
||||
|
||||
// if($b == '00:00'){
|
||||
|
||||
// }
|
||||
// 分解时间字符串
|
||||
$sjA = explode(':', $a);
|
||||
$sjB = explode(':', $b);
|
||||
|
|
@ -1278,45 +1431,184 @@ class Sportstesting extends Base{
|
|||
// 比较两个时间(秒)
|
||||
// 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'),
|
||||
// ]);
|
||||
// 处理分秒变秒
|
||||
function convertMinutesSecondsToStringSeconds($timeString) {
|
||||
// 分割字符串获取分钟和秒
|
||||
list($minutes, $seconds) = explode(':', $timeString);
|
||||
// 将分钟和秒转换为秒
|
||||
$totalSeconds = ($minutes * 60) + intval($seconds); // 确保秒是整数
|
||||
return $totalSeconds;
|
||||
}
|
||||
public function aaaaaaaaaaaaaaa(){
|
||||
// $this->set_rule_action();
|
||||
|
||||
// 处理默认规则列表
|
||||
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'=>[]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
// 获取所有选择项内容
|
||||
public function handle_default_rule_list_content($data,$gender){
|
||||
$temporary_arr = $data[$gender];
|
||||
$result = [];
|
||||
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();
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 取得成绩
|
||||
public function obtaining_grades($rule,$data){
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
// dump($data['total_score']);
|
||||
// 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']);
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -46,6 +46,8 @@ Route::any('/card/card_del', 'admin/card/card_del');
|
|||
// 估分功能管理
|
||||
Route::any('/estimate/index', 'admin/estimate/index');
|
||||
Route::any('/estimate/estimate_add', 'admin/estimate/estimate_add');
|
||||
Route::any('/estimate/estimate_edit', 'admin/estimate/estimate_edit');
|
||||
|
||||
Route::any('/estimate/submit_rule', 'admin/estimate/submit_rule');
|
||||
Route::any('/estimate/estimate_content_observe', 'admin/estimate/estimate_content_observe');
|
||||
// Route::any('/estimate/index', 'admin/estimate/index');
|
||||
|
|
@ -167,6 +169,8 @@ Route::any('/sportstesting_get_all_list', 'app/sportstesting/sportstesting_get_a
|
|||
Route::any('/sportstesting_get_one_details', 'app/sportstesting/sportstesting_get_one_details');
|
||||
// 计算并存储数据
|
||||
Route::any('/sportstesting_set_once_data', 'app/sportstesting/sportstesting_set_once_data');
|
||||
// 获取估分已有的地区列表
|
||||
Route::any('/sportstesting_get_city_list', 'app/sportstesting/sportstesting_get_city_list');
|
||||
|
||||
// ################################设备管理################################
|
||||
// 获取系统设备列表
|
||||
|
|
@ -198,7 +202,7 @@ Route::any('/update_my_password', 'app/myinformation/update_my_password');
|
|||
|
||||
// // ################################################################其它测试################################################################
|
||||
// // ################################################################其它测试################################################################
|
||||
// Route::any('/generateRandomJumpData', 'app/skip/generateRandomJumpData');
|
||||
Route::any('/use_test', 'admin/base/use_test');
|
||||
// Route::any('/skip_kcal_calculate', 'app/skip/skip_kcal_calculate');
|
||||
// Route::any('/readexcel', 'admin/execlaa/readexcel');
|
||||
// Route::any('/vitalcapacity_standard_interval', 'app/vitalcapacity/vitalcapacity_standard_interval');
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue