where('user_name=:username',[':username'=>$username])->asArray()->one(); $user=AssistUser::model()->find('user_name=:username',array(':username'=>$username)); if(!$user){ $return['msg']='用户名不正确'; exit(json_encode($return)); }else{ if($this->producePassword($password)!=$user['password']){ $return['msg']='密码不正确'; exit(json_encode($return)); } if($user["status"]==0) { $return['msg']='此账号被冻结'; exit(json_encode($return)); } $data=array( 'user_id' => $user['user_id'], 'username' => $user['user_name'], 'real_name' => $user['real_name'], 'role'=>$user['role'], 'cutting_limit'=>$user['cutting_limit'], 'scan_limit'=>$user['scan_limit'], ); Yii::app()->session['user'] = $data; $token=Yii::app()->getSecurityManager()->generateRandomString(32,true); $data['sig']=$token; //更新用户登录信息到redis Yii::app()->cache->setValue($token,json_encode($data),86400); // if(AssistUser::model()->updateAll(array('token'=>$token),'user_id=:id',array(':id'=>$user['user_id']))){ $return['status']=1; $return['msg']='登录成功'; $return['data']=$data; // } exit(json_encode($return)); } } // 系统用户退出 public function actionOut() { Yii::app()->user->logout(); return $this->redirect(array('login/index')); } //系统设置 public function actionSetting(){ $cutting_task=(int)Req::post('cutting_task'); $open_cutting_upper_limit=(int)Req::post('open_cutting_upper_limit'); $cutting_task_upper_limit_num=(int)Req::post('cutting_task_upper_limit_num'); $scan_task=(int)Req::post('scan_task'); $open_scan_upper_limit=(int)Req::post('open_scan_upper_limit'); $scan_task_upper_limit_num=(int)Req::post('scan_task_upper_limit_num'); $return['status']=0; $data=array( 'cutting_task'=>$cutting_task, 'open_cutting_upper_limit'=>$open_cutting_upper_limit, 'cutting_task_upper_limit_num'=>$cutting_task_upper_limit_num, 'scan_task'=>$scan_task, 'open_scan_upper_limit'=>$open_scan_upper_limit, 'scan_task_upper_limit_num'=>$scan_task_upper_limit_num, ); $rs=AssistSetting::model()->updateAssistSetting($data); if($rs){ $return['status']=1; $return['msg']='设置成功'; exit(json_encode($return)); }else{ $return['msg']='设置失败'; exit(json_encode($return)); } } //读取系统设置 public function actionGetSetting(){ $setting=AssistSetting::model()->getAssistSetting(); if($setting){ $return['status']=1; $return['msg']='读取成功'; $return['data']=array( 'cutting_task'=>$setting['cutting_task'], 'open_cutting_upper_limit'=>$setting['open_cutting_upper_limit'], 'cutting_task_upper_limit_num'=>$setting['cutting_task_upper_limit_num'], 'scan_task'=>$setting['scan_task'], 'open_scan_upper_limit'=>$setting['open_scan_upper_limit'], 'scan_task_upper_limit_num'=>$setting['scan_task_upper_limit_num'], ); exit(json_encode($return)); }else{ $return['status']=1; $return['msg']='读取成功'; $return['data']=array( 'cutting_task'=>1, 'open_cutting_upper_limit'=>0, 'cutting_task_upper_limit_num'=>0, 'scan_task'=>1, 'open_scan_upper_limit'=>0, 'scan_task_upper_limit_num'=>0, ); exit(json_encode($return)); } } //修改密码 public function actionChangepassword(){ $currPwd=Req::post('currPwd'); $newPwd=Req::post('newPwd'); $userId=Req::post('user_id'); $return['status']=0; if(!$userId) { $return['msg']='未指定用户'; exit(json_encode($return)); } if(!$currPwd){ $return['msg']='请输入旧密码'; exit(json_encode($return)); } if(!$newPwd){ $return['msg']='请输入新密码'; exit(json_encode($return)); } if($currPwd == $newPwd){ $return['msg']='新密码和旧密码相同,未修改'; exit(json_encode($return)); } $findUser = AssistUser::model()->findByPk($userId)->attributes; if(!$findUser){ $return['msg']='用户不存在'; exit(json_encode($return)); } if($findUser['password']!=$this->producePassword($currPwd)){ $return['msg']='旧密码不正确'; exit(json_encode($return)); } if(AssistUser::model()->updateAll(array('password'=>$this->producePassword($newPwd)),'user_id=:uid',array(':uid'=>$userId))){ $return['status']=1; $return['msg']='修改成功'; exit(json_encode($return)); }else{ $return['msg']='修改失败'; exit(json_encode($return)); } } //读取附件地址 public function actionGetTaskImg(){ $examGroupId=Req::post('exam_group_id'); $type=(int)Req::post('type'); $return['status']=0; if(!in_array($type,array(1,2,3))){ $return['msg']='类型错误'; exit(json_encode($return)); } $taskModel=new ATask(); $task=$taskModel->getTaskByExamGroupId($examGroupId)->attributes; if(!$task){ $return['msg']='任务不存在'; exit(json_encode($return)); } $data=array(); switch ($type){ case 1: $data=explode(',',$task['answer_card_img']); break; case 2: $data=explode(',',$task['paper_img']); break; case 3: $data=explode(',',$task['parse_img']); break; } $return['status']=1; $return['msg']='修改成功'; $return['data']=$data; exit(json_encode($return)); } //读取科目列表 public function actionGetSubjects(){ $subjects=Yii::app()->params['subjectId']; if(isset($subjects[20])){ unset($subjects[20]); } $return['status']=1; $return['msg']='成功'; $return['data']=$subjects; exit(json_encode($return)); } //发送在线答题卡测试数据 public function actionSendTestData(){ $item=array( array( 'student_id'=>'17536408539753897824', 'paper_id'=>'570614822981877760', 'class_id'=>'17536408539753896731', 'student_card'=>'47649726', 'exam_id'=>'570614822926188544', 'student_name'=>'黄陈希', 'class_name'=>'22' ), array( 'student_id'=>'17536408539753897825', 'paper_id'=>'570614822981877760', 'class_id'=>'17536408539753896731', 'student_card'=>'47649727', 'exam_id'=>'570614822926188544', 'student_name'=>'雷汝芬', 'class_name'=>'22' ), array( 'student_id'=>'17536408539753897826', 'paper_id'=>'570614822981877760', 'class_id'=>'17536408539753896731', 'student_card'=>'47649728', 'exam_id'=>'570614822926188544', 'student_name'=>'黎政丰', 'class_name'=>'22' ), ); $arr=array( 'schoolId'=>476, 'examGroupId'=>'570614821953171456', 'savedInfoUrl'=>'http://zxhx.cn-bj.ufileos.com/zsyas2%2Fcardonline%2F476%2F2020%2F04%2F28%2F570614821953171456.zip?r=303', 'students'=>$item, 'qrcode'=>1, 'semesterId'=>'17535877358591649378' ); $key='zsyas2-online-card-notify'; $return=sendDataToKafka($key,$arr); if($return){ exit('发送成功'); }else{ exit('发送失败'); } } }