session['user']['role']!=2){
exit();
}
if(!$page) $page=1;
$where = array();
$param=array();
$where[]=" (answer_sheet_task in(1,2,3) or paper_task in(1,2,3) or parse_task in(1,2,3))";
if($subjectId){
if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
$where[] = "subject_id in (".implode(',',Yii::app()->params['mathSubjectId']).")";
}else{
$where[] = "subject_id = '{$subjectId}'";
}
}
if ($AnswerTask) {
$where[]= " answer_sheet_task='".$AnswerTask."'";
}
if ($PaperTask) {
$where[]= " paper_task='".$PaperTask."'";
}
if ($ParseTask) {
$where[]= " parse_task='".$ParseTask."'";
}
if ($searchName) {
$where[]= " (exam_name like '%".$searchName."%' or school_name like '%".$searchName."%' or coach_name like'%".$searchName."%' )";
$param[':searchName']='%'.$searchName.'%';
}
$ATask=new ATask();
// 任务列表
$totalCount = $ATask->countTask($where);
$pageLimit=10;
$pages['page']=$page;
$pages['totalPage']=ceil($totalCount/$pageLimit);
$pages['total']=$totalCount;
//$pages = new Pagination(['totalCount' => $totalCount, 'pageSize' => 10]);
//$dataList=ATask::model()->find(implode(' and ',$where),$param)->offset($pages->offset)->limit($pages->limit)->asArray()->all();
$dataList=$ATask->getList($where,$param,$page,$pageLimit);
if($dataList){
foreach ($dataList as $key => $val){
if($val['operator']){
$user=AssistUser::model()->find('user_id=:uid',array(':uid'=>$val['operator']));
$dataList[$key]['operator']=$user['real_name'].'-'.$user['user_name'];
}else{
$dataList[$key]['operator']='--';
}
$taskTextTips=array();
if($val['answer_sheet_task'] && $val['answer_sheet_task']!=4){
$taskTextTips[]='答题卡:'.date('Y-m-d H:i:s',$val['ast_update_time']);
}
if($val['paper_task'] && $val['paper_task']!=4){
$taskTextTips[]='试卷:'.date('Y-m-d H:i:s',$val['ppt_update_time']);
}
if($val['parse_task'] && $val['parse_task']!=4){
$taskTextTips[]='答案解析:'.date('Y-m-d H:i:s',$val['pat_update_time']);
}
if($taskTextTips){
$dataList[$key]['tips']=implode('
',$taskTextTips);
}
//读取省市区
$schoolInfo=BusinessSchool::model()->find('school_id=:sid',array(':sid'=>$val['school_id']));
if($schoolInfo){
$province=BusinessRegion::model()->findByPk($schoolInfo->province_id);
$city=BusinessRegion::model()->findByPk($schoolInfo->city_id);
$area=BusinessRegion::model()->findByPk($schoolInfo->area_id);
$dataList[$key]['address']=$province->region_name.'-'.$city->region_name.'-'.$area->region_name;
}
}
}
//查询用户
// $users=AssistUser::model()->find('status=1 and role=1');
$AUser=new AssistUser();
$users=$AUser->getAllUserByLimit("cutting_limit=1");
if(isset(Yii::app()->params['subjectId']) && Yii::app()->params['subjectId']){
$subjects=Yii::app()->params['subjectId'];
unset($subjects[3]);
unset($subjects[51]);
if(isset($subjects[20])) unset($subjects[20]);
}
$data=array(
'pages' => $pages,
'dataList' => $dataList,
'condition' => array(
'answer_sheet_task' => $AnswerTask,
'paper_task' => $PaperTask,
'parse_task' => $ParseTask,
'search_name' => $searchName,
'subject_id'=>$subjectId
),
'users'=>$users,
'subjects'=>$subjects,
'subjectId'=>$subjectId
);
return $this->render('cooperate', $data);
}
//扫描任务总台
public function actionScanTask()
{
$scanTask = (int)Req::get('scan_task');
$searchName = trim(Req::get('search_name'));
$subjectId = trim(Req::get('subject_id'));
$page = (int)Req::get('page');
if(Yii::app()->session['user']['role']!=2){
exit();
}
if(!$page) $page=1;
$where = array();
$param=array();
$where[]=" scan_task in(1,2,3)";
if($subjectId){
if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
$where[] = "subject_id in (".implode(',',Yii::app()->params['mathSubjectId']).")";
}else{
$where[] = "subject_id = '{$subjectId}'";
}
}
if ($scanTask) {
$where[]= " scan_task='".$scanTask."'";
}
if ($searchName) {
$where[]= " (exam_name like '%".$searchName."%' or school_name like '%".$searchName."%' or coach_name like'%".$searchName."%' )";
$param[':searchName']='%'.$searchName.'%';
}
$ATask=new AScanTask();
// 任务列表
$totalCount = $ATask->countTask($where);
$pageLimit=10;
$pages['page']=$page;
$pages['totalPage']=ceil($totalCount/$pageLimit);
$pages['total']=$totalCount;
$dataList=$ATask->getList($where,$param,$page,$pageLimit);
if($dataList){
$AStudentScanTask=new AStudentScanTask();
foreach ($dataList as $key => $val){
if($val['operator']){
$user=AssistUser::model()->find('user_id=:uid',array(':uid'=>$val['operator']));
$dataList[$key]['operator']=$user['real_name'].'-'.$user['user_name'];
}else{
$dataList[$key]['operator']='--';
}
//查询任务类型
$dataList[$key]['taskType']=$AStudentScanTask->getTaskTypesByExamGroupId($val['exam_group_id']);
//查询任务数量
$dataList[$key]['taskCount']=$AStudentScanTask->getTaskCount($val['exam_group_id']);
//读取省市区
$schoolInfo=BusinessSchool::model()->find('school_id=:sid',array(':sid'=>$val['school_id']));
if($schoolInfo){
$province=BusinessRegion::model()->findByPk($schoolInfo->province_id);
$city=BusinessRegion::model()->findByPk($schoolInfo->city_id);
$area=BusinessRegion::model()->findByPk($schoolInfo->area_id);
$dataList[$key]['address']=$province->region_name.'-'.$city->region_name.'-'.$area->region_name;
}
}
}
//查询用户
// $users=AssistUser::model()->find('status=1 and role=1');
$AUser=new AssistUser();
$users=$AUser->getAllUserByLimit("scan_limit=1");
if(isset(Yii::app()->params['subjectId']) && Yii::app()->params['subjectId']){
$subjects=Yii::app()->params['subjectId'];
unset($subjects[3]);
unset($subjects[51]);
if(isset($subjects[20])) unset($subjects[20]);
}
$data=array(
'pages' => $pages,
'dataList' => $dataList,
'condition' => array(
'scan_task' => $scanTask,
'search_name' => $searchName,
'subject_id'=>$subjectId
),
'users'=>$users,
'subjects'=>$subjects,
'subjectId'=>$subjectId,
);
return $this->render('cooperate_scan', $data);
}
//我的任务
public function actionMyTask(){
$AnswerTask = (int)Req::get('answer_sheet_task');
$PaperTask = (int)Req::get('paper_task');
$ParseTask = (int)Req::get('parse_task');
$searchName = trim(Req::get('search_name'));
$subjectId = trim(Req::get('subject_id'));
$page = (int)Req::get('page');
if(!$page) $page=1;
if(isset(Yii::app()->params['subjectId']) && Yii::app()->params['subjectId']){
$subjects=Yii::app()->params['subjectId'];
unset($subjects[3]);
unset($subjects[51]);
if(isset($subjects[20])) unset($subjects[20]);
}
// if(!isset(Yii::app()->session['user']['cutting_limit']) || Yii::app()->session['user']['cutting_limit']==0){
//
// return $this->render('mytask', array(
// 'pages' => array(),
// 'dataList' => array(),
// 'condition' => array(
// 'answer_sheet_task' => 0,
// 'paper_task' => 0,
// 'parse_task' => 0,
// 'search_name' => '',
// 'subject_id'=>$subjectId
// ),
// 'subjects'=>$subjects,
// 'subjectId'=>$subjectId,
// 'isNoLimit'=>1
// ));
// }
$where[]='operator='.Yii::app()->session['user']['user_id'];
$param[':userid']=Yii::app()->session['user']['user_id'];
if($subjectId){
if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
$where[] = "subject_id in (".implode(',',Yii::app()->params['mathSubjectId']).")";
}else{
$where[] = "subject_id = '{$subjectId}'";
}
}
if ($AnswerTask) {
$where[]= " answer_sheet_task='".$AnswerTask."'";
}
if ($PaperTask) {
$where[]= " paper_task='".$PaperTask."'";
}
if ($ParseTask) {
$where[]= " parse_task='".$ParseTask."'";
}
if ($searchName) {
$where[]= " (exam_name like '%".$searchName."%' or school_name like '%".$searchName."%' or coach_name like'%".$searchName."%' )";
}
// 任务列表
$taskModel=new ATask();
$totalCount=$taskModel->countTask($where);
//判断受理中任务
$handleCount=$taskModel->getHandleTask(Yii::app()->session['user']['user_id']);
if($handleCount==0 && Yii::app()->session['user']['role']==1 && Yii::app()->session['user']['cutting_limit']==1){
//领取任务
$apply=$taskModel->autoApply(Yii::app()->session['user']['user_id']);
if(!$apply){
$totalCount = $taskModel->countTask($where);
}
}
$pageLimit=10;
$pages['page']=$page;
$pages['totalPage']=ceil($totalCount/$pageLimit);
$pages['total']=$totalCount;
$ATask=new ATask();
$dataList=$ATask->getList($where,$param,$page,$pageLimit);
if($dataList){
foreach ($dataList as $key => $val){
$taskTextTips=array();
if($val['answer_sheet_task'] && $val['answer_sheet_task']!=4){
$taskTextTips[]='答题卡:'.date('Y-m-d H:i:s',$val['ast_update_time']);
}
if($val['paper_task'] && $val['paper_task']!=4){
$taskTextTips[]='试卷:'.date('Y-m-d H:i:s',$val['ppt_update_time']);
}
if($val['parse_task'] && $val['parse_task']!=4){
$taskTextTips[]='答案解析:'.date('Y-m-d H:i:s',$val['pat_update_time']);
}
if($taskTextTips){
$dataList[$key]['tips']=implode('
',$taskTextTips);
}else{
$dataList[$key]['tips']='';
}
//读取省市区
$schoolInfo=BusinessSchool::model()->find('school_id=:sid',array(':sid'=>$val['school_id']));
if($schoolInfo){
$province=BusinessRegion::model()->findByPk($schoolInfo->province_id);
$city=BusinessRegion::model()->findByPk($schoolInfo->city_id);
$area=BusinessRegion::model()->findByPk($schoolInfo->area_id);
$dataList[$key]['address']=$province->region_name.'-'.$city->region_name.'-'.$area->region_name;
}
}
}
return $this->render('mytask', array(
'pages' => $pages,
'dataList' => $dataList,
'condition' => array(
'answer_sheet_task' => $AnswerTask,
'paper_task' => $PaperTask,
'parse_task' => $ParseTask,
'search_name' => $searchName,
'subject_id'=>$subjectId
),
'subjects'=>$subjects,
'subjectId'=>$subjectId
));
}
//我的扫描任务
public function actionMyScanTask(){
$scanTask = (int)Req::get('scan_task');
$searchName = trim(Req::get('search_name'));
$subjectId = trim(Req::get('subject_id'));
$page = (int)Req::get('page');
if(isset(Yii::app()->params['subjectId']) && Yii::app()->params['subjectId']){
$subjects=Yii::app()->params['subjectId'];
unset($subjects[3]);
unset($subjects[51]);
if(isset($subjects[20])) unset($subjects[20]);
}
// if(!isset(Yii::app()->session['user']['scan_limit']) || Yii::app()->session['user']['scan_limit']==0){
//
// return $this->render('my_scan_task', array(
// 'pages' => array(),
// 'dataList' => array(),
// 'condition' => array(
// 'scan_task' => 0,
// 'search_name' => '',
// 'subject_id'=>$subjectId
// ),
// 'subjects'=>$subjects,
// 'subjectId'=>$subjectId,
// 'isNoLimit'=>1
// ));
// }
if(!$page) $page=1;
$where = array();
$param=array();
$where[]=" scan_task in(1,2,3)";
$where[]='operator='.Yii::app()->session['user']['user_id'];
$param[':userid']=Yii::app()->session['user']['user_id'];
if($subjectId){
if(in_array($subjectId,Yii::app()->params['mathSubjectId'])){
$where[] = "subject_id in (".implode(',',Yii::app()->params['mathSubjectId']).")";
}else{
$where[] = "subject_id = '{$subjectId}'";
}
}
if ($scanTask) {
$where[]= " scan_task='".$scanTask."'";
}
if ($searchName) {
$where[]= " (exam_name like '%".$searchName."%' or school_name like '%".$searchName."%' or coach_name like'%".$searchName."%' )";
$param[':searchName']='%'.$searchName.'%';
}
$ATask=new AScanTask();
// 任务列表
$totalCount = $ATask->countTask($where);
//判断受理中任务
$handleCount=$ATask->getHandleTask(Yii::app()->session['user']['user_id']);
if($handleCount==0 && Yii::app()->session['user']['role']==1 && Yii::app()->session['user']['scan_limit']==1){
//领取任务
$apply=$ATask->autoApply(Yii::app()->session['user']['user_id']);
if(!$apply){
$totalCount = $ATask->countTask($where);
}
}
$pageLimit=10;
$pages['page']=$page;
$pages['totalPage']=ceil($totalCount/$pageLimit);
$pages['total']=$totalCount;
$dataList=$ATask->getList($where,$param,$page,$pageLimit);
if($dataList){
$AStudentScanTask=new AStudentScanTask();
foreach ($dataList as $key => $val){
if($val['operator']){
$user=AssistUser::model()->find('user_id=:uid',array(':uid'=>$val['operator']));
$dataList[$key]['operator']=$user['real_name'].'-'.$user['user_name'];
}else{
$dataList[$key]['operator']='--';
}
//查询任务类型
$dataList[$key]['taskType']=$AStudentScanTask->getTaskTypesByExamGroupId($val['exam_group_id']);
//查询任务数量
$dataList[$key]['taskCount']=$AStudentScanTask->getTaskCount($val['exam_group_id']);
//读取省市区
$schoolInfo=BusinessSchool::model()->find('school_id=:sid',array(':sid'=>$val['school_id']));
if($schoolInfo){
$province=BusinessRegion::model()->findByPk($schoolInfo->province_id);
$city=BusinessRegion::model()->findByPk($schoolInfo->city_id);
$area=BusinessRegion::model()->findByPk($schoolInfo->area_id);
$dataList[$key]['address']=$province->region_name.'-'.$city->region_name.'-'.$area->region_name;
}
}
}
//查询用户
// $users=AssistUser::model()->find('status=1 and role=1');
$AUser=new AssistUser();
$users=$AUser->getAllUserByLimit("scan_limit=1");
$data=array(
'pages' => $pages,
'dataList' => $dataList,
'condition' => array(
'scan_task' => $scanTask,
'search_name' => $searchName,
'subject_id'=>$subjectId
),
'users'=>$users,
'subjects'=>$subjects,
'subjectId'=>$subjectId
);
return $this->render('my_scan_task', $data);
}
//分配操作员
public function actionApply(){
$examGroupId = Req::post('exam_group_id');
$userId = (int)Req::post('user_id');
$return['status']=0;
//分配
$taskModel=new ATask();
if($taskModel->apply($examGroupId,$userId)){
$return['status']=1;
exit(json_encode($return));
}else{
exit(json_encode($return));
}
}
//任务详情
public function actionDetail(){
$examGroupId = Req::get('exam_group_id');
$taskModel=new ATask();
$task=$taskModel->getTaskByExamGroupId($examGroupId)->attributes;
// $task= Task::find()->where('exam_group_id=:eid',array(':eid'=>$examGroupId))->asArray()->one();
if(!$task){
Yii::app()->jump->error('任务数据异常!');
}
if($task['operator']){
$user=AssistUser::model()->findByPk($task['operator']);
$task['user']=$user->real_name;
}else{
$task['user']='--';
}
//答题卡任务耗时
if($task['ast_apply_time']){
if($task['answer_sheet_task']>2){
if($task['ast_update_time'] && ($task['ast_update_time']-$task['ast_apply_time'])>0){
$task['AstConsuming']=$this->consuming($task['ast_update_time'],$task['ast_apply_time']);
}else{
$task['AstConsuming']='--';
}
}elseif($task['answer_sheet_task']==2){
if($task['ast_apply_time'] && (time()-$task['ast_apply_time'])>0){
$task['AstConsuming']=$this->consuming(time(),$task['ast_apply_time']);
}else{
$task['AstConsuming']='--';
}
}
}else{
$task['AstConsuming']='--';
}
//试卷任务耗时
if($task['ppt_apply_time']){
if($task['paper_task']>2){
if($task['ppt_update_time'] && ($task['ppt_update_time']-$task['ppt_apply_time'])>0){
$task['PptConsuming']=$this->consuming($task['ppt_update_time'],$task['ppt_apply_time']);
}else{
$task['PptConsuming']='';
}
}elseif($task['paper_task']==2){
if($task['ppt_apply_time'] && (time()-$task['ppt_apply_time'])>0){
$task['PptConsuming']=$this->consuming(time(),$task['ppt_apply_time']);
}else{
$task['PptConsuming']='';
}
}
}else{
$task['PptConsuming']='';
}
//答案解析任务耗时
if($task['pat_apply_time']){
if($task['parse_task']>2){
if($task['pat_update_time'] && ($task['pat_update_time']-$task['pat_apply_time'])>0){
$task['PatConsuming']=$this->consuming($task['pat_update_time'],$task['pat_apply_time']);
}else{
$task['PatConsuming']='';
}
}elseif($task['parse_task']==2){
if($task['pat_apply_time'] && (time()-$task['pat_apply_time'])>0){
$task['PatConsuming']=$this->consuming(time(),$task['pat_apply_time']);
}else{
$task['PatConsuming']='';
}
}
}else{
$task['PatConsuming']='';
}
$CoachModel=new ThirdAnswerSheet();
$tplData=$CoachModel->getExamTplData($task['dsn'],$task['database_user'],$task['database_password'],$examGroupId);
if($tplData){
$tplData=json_decode($tplData,true);
if(isset($tplData['new_items'])){
$items=array();
foreach ($tplData['new_items'] as $item){
if(isset($item['alias'])){
$items[$item['topic_type']]['no'][]=$item['alias'];
}else{
$items[$item['topic_type']]['no'][]=$item['id'];
}
}
$tplData['items']=$items;
}
$task['paper_topic']=$tplData;
}
//读取省市区
$schoolInfo=BusinessSchool::model()->find('school_id=:sid',array(':sid'=>$task['school_id']));
if($schoolInfo){
$province=BusinessRegion::model()->findByPk($schoolInfo->province_id);
$city=BusinessRegion::model()->findByPk($schoolInfo->city_id);
$area=BusinessRegion::model()->findByPk($schoolInfo->area_id);
$task['address']=$province->region_name.'-'.$city->region_name.'-'.$area->region_name;
}
$data['our']=0;
//是否是自己的任务
if(Yii::app()->session['user']['user_id']==$task['operator']){
$data['our']=1;
//读取模板
$ThirdAnswerTemplate=new ThirdAnswerSheet();
$template=$ThirdAnswerTemplate->getTemplate($task['dsn'],$task['database_user'],$task['database_password'],$examGroupId);
if($template){
$task['paper_template']=$template['paper_template'];
$task['parse_template']=$template['parse_template'];
}
}
$data['task']=$task;
return $this->render('detail',$data);
}
//扫描处理任务详情
public function actionScanTaskDetail(){
$examGroupId = Req::get('exam_group_id');
$taskModel=new AScanTask();
$task=$taskModel->getTaskByExamGroupId($examGroupId)->attributes;
// $task= Task::find()->where('exam_group_id=:eid',array(':eid'=>$examGroupId))->asArray()->one();
$pushStudentData=array(); //待处理学生数据
if(!$task){
Yii::app()->jump->error('任务数据异常!');
}
if($task['operator']){
$user=AssistUser::model()->findByPk($task['operator']);
$task['user']=$user->real_name;
}else{
$task['user']='--';
}
//答题卡任务耗时
if($task['scan_task_apply_time']){
if($task['scan_task']>2){
if($task['scan_task_update_time'] && ($task['scan_task_update_time']-$task['scan_task_apply_time'])>0){
$task['AstConsuming']=$this->consuming($task['scan_task_update_time'],$task['scan_task_apply_time']);
}else{
$task['AstConsuming']='--';
}
}elseif($task['scan_task']==2){
if($task['scan_task_apply_time'] && (time()-$task['scan_task_apply_time'])>0){
$task['AstConsuming']=$this->consuming(time(),$task['scan_task_apply_time']);
}else{
$task['AstConsuming']='--';
}
}
}else{
$task['AstConsuming']='--';
}
//读取扫描数量
$AssistSchoolManager=new AssistSchoolManager($task['school_id']);
$count=$AssistSchoolManager->getStudentCountByExamGroupId($task['exam_group_id'],1);
$task['count']=$count;
if($count['surplus']>0){
//查询待处理数据,准备处理
//$pushStudentData=$AssistSchoolManager->getSurplusDataByExamGroupId($task['exam_group_id']);
}
//读取省市区
$schoolInfo=BusinessSchool::model()->find('school_id=:sid',array(':sid'=>$task['school_id']));
if($schoolInfo){
$province=BusinessRegion::model()->findByPk($schoolInfo->province_id);
$city=BusinessRegion::model()->findByPk($schoolInfo->city_id);
$area=BusinessRegion::model()->findByPk($schoolInfo->area_id);
$task['address']=$province->region_name.'-'.$city->region_name.'-'.$area->region_name;
}
$data['our']=0;
//是否是自己的任务
if(Yii::app()->session['user']['user_id']==$task['operator']){
$data['our']=1;
}
$data['task']=$task;
// $data['pushStudentData']=$pushStudentData;
$AUser=new AssistUser();
$users=$AUser->getAllUserByLimit("scan_limit=1");
$data['users']=$users;
$coachInfo=BusinessDatabase::model()->find('school_id=:id',array(':id'=>$task['school_id']));
$groupServer=$this->getServerGroup();
$data['api_url']=$groupServer[$coachInfo->group_id];
return $this->render('scan_detail',$data);
}
//读取答题卡id
public function actionGetSheet(){
$examGroupId = Req::post('exam_group_id');
$data['status']=0;
$taskModel=new ATask();
$task=$taskModel->getTaskByExamGroupId($examGroupId)->attributes;
if(!$task){
$data['msg']='参数错误2';
exit(json_encode($data));
}
//读取答题卡
$ThirdAnswerTemplate=new ThirdAnswerSheet();
$sheet=$ThirdAnswerTemplate->getAnswerSheet($task['dsn'],$task['database_user'],$task['database_password'],$examGroupId);
exit(json_encode(array('status'=>1,'msg'=>'success','data'=>$sheet)));
}
//分配操作员
public function actionApplyScan(){
$examGroupId = Req::post('exam_group_id');
$userId = (int)Req::post('user_id');
$return['status']=0;
//分配
$taskModel=new AScanTask();
if($taskModel->apply($examGroupId,$userId)){
$return['status']=1;
exit(json_encode($return));
}else{
exit(json_encode($return));
}
}
//读取任务设置情况
public function actionGetDetail(){
$examGroupId = Req::post('exam_group_id');
$data['status']=0;
if(!$examGroupId){
$data['msg']='参数错误1';
exit(json_encode($data));
}
$taskModel=new ATask();
$task=$taskModel->getTaskByExamGroupId($examGroupId)->attributes;
if(!$task){
$data['msg']='参数错误2';
exit(json_encode($data));
}
$CoachModel=new ThirdAnswerSheet();
$return=$CoachModel->getDetail($task['dsn'],$task['database_user'],$task['database_password'],$examGroupId);
if($task['answer_sheet_task']==3 || $task['answer_sheet_task']==4 || $return['answer_card']==0){
$return['answer_card_input_status']=0;
}else{
$return['answer_card_input_status']=1;
}
if($task['paper_task']==3 || $task['paper_task']==4 || $return['paper']==0){
$return['paper_input_status']=0;
}else{
$return['paper_input_status']=1;
}
if($task['parse_task']==3 || $task['parse_task']==4 || $return['parse']==0){
$return['parse_input_status']=0;
}else{
$return['parse_input_status']=1;
}
if($return){
$data['data']=$return;
}
$data['status']=1;
$data['msg']='success';
exit(json_encode($data));
}
//读取扫描异常任务设置情况
public function actionGetScanDetail(){
$examGroupId = Req::post('exam_group_id');
$data['status']=0;
if(!$examGroupId){
$data['msg']='参数错误1';
exit(json_encode($data));
}
$taskModel=new AScanTask();
$task=$taskModel->getTaskByExamGroupId($examGroupId)->attributes;
if(!$task){
$data['msg']='参数错误2';
exit(json_encode($data));
}
if($task['scan_task']==3 || $task['scan_task']==4 ){
$return['scan_task']=0;
}else{
$return['scan_task']=1;
}
//统计处理数量
$AssistSchoolManager=new AssistSchoolManager($task['school_id']);
$return['count']=$AssistSchoolManager->getStudentCountByExamGroupId($task['exam_group_id']);
if($return){
$data['data']=$return;
}
$data['status']=1;
$data['msg']='success';
exit(json_encode($data));
}
//任务完成
public function actionComplete(){
$examGroupId = Req::post('exam_group_id');
$answerCardStatus =Req::post('answer_card');
$paperStatus = Req::post('paper');
$parseStatus = Req::post('parse');
$data['status']=0;
if(!$examGroupId){
$data['msg']='参数错误';
exit(json_encode($data));
}
$taskModel=new ATask();
$task=$taskModel->getTaskByExamGroupId($examGroupId);
if(!$task){
$data['msg']='没找到相关任务';
exit(json_encode($data));
}
$time=time();
if($answerCardStatus==1){
$updateArr['answer_sheet_task']=3;
$updateArr['ast_update_time']=$time;
}
if($paperStatus==1){
$updateArr['paper_task']=3;
$updateArr['ppt_update_time']=$time;
}
if($parseStatus==1){
$updateArr['parse_task']=3;
$updateArr['pat_update_time']=$time;
}
$updateArr['update_time']=$time;
if($taskModel->updateTask($examGroupId,$updateArr)){
//判断受理中任务
$handleCount=$taskModel->getHandleTask(Yii::app()->session['user']['user_id']);
if($handleCount==0 && Yii::app()->session['user']['role']==1){
//领取任务
$taskModel->autoApply(Yii::app()->session['user']['user_id']);
}
$data['status']=1;
$data['msg']='提交成功';
}
exit(json_encode($data));
}
//任务完成
public function actionScanTaskComplete(){
$examGroupId = Req::post('exam_group_id');
$data['status']=0;
if(!$examGroupId){
$data['msg']='参数错误';
exit(json_encode($data));
}
$taskModel=new AScanTask();
$task=$taskModel->getTaskByExamGroupId($examGroupId);
if(!$task){
$data['msg']='没找到相关任务';
exit(json_encode($data));
}
$time=time();
$updateArr['scan_task']=3;
$updateArr['scan_task_update_time']=$time;
$updateArr['update_time']=$time;
if($taskModel->updateTask($examGroupId,$updateArr)){
//判断受理中任务
$handleCount=$taskModel->getHandleTask(Yii::app()->session['user']['user_id']);
if($handleCount==0 && Yii::app()->session['user']['role']==1){
//领取任务
$taskModel->autoApply(Yii::app()->session['user']['user_id']);
}
$data['status']=1;
$data['msg']='提交成功';
}
exit(json_encode($data));
}
//计算耗时
public function consuming($now,$time){
$return='';
$date=floor(($now-$time)/86400);
if($date){
$return.=$date.'天';
}
$hour=floor(($now-$time)%86400/3600);
if($hour){
$return.=$hour.'小时';
}
$minute=floor((($now-$time)%86400)%3600/60);
if($minute){
$return.=$minute.'分种';
}
$second=floor(($now-$time)%86400%3600%60);
if($second){
$return.=$second.'秒';
}
return $return;
}
public function actionDownload()
{
$url = Req::get('url');
$title = Req::get('title');
if (!$url) return false;
$info = get_headers($url, true);
$size = $info['Content-Length'];
header("Content-type:application/octet-stream");
$filename = $url;
if (false !== stripos($url, '?')) {
$filename = substr($url, 0, stripos($url, '?'));
}
if($title){
$origin_name = $title;
}else{
$origin_name = basename($filename);
}
header("Content-Disposition:attachment;filename = " . $origin_name);
header("Accept-ranges:bytes");
header("Accept-length:" . $size);
readfile($url);
exit;
}
public function getServerGroup(){
$taskModel=new ATask();
switch (YII_ENV) {
case 'local':
case 'development':
$improve_url = array();
$static_url = array();
$group_server=$taskModel->getGroupServer('group_server_development');
if ($group_server) {
foreach ($group_server as $v) {
$improve_url[$v['group_id']] = $v['api_url'];
$static_url[$v['group_id']] = $v['static_url'];
}
}
break;
case 'testing':
//报告运行时错误
$improve_url = array();
$static_url = array();
$group_server=$taskModel->getGroupServer('group_server_testing');
if ($group_server) {
foreach ($group_server as $v) {
$improve_url[$v['group_id']] = $v['api_url'];
$static_url[$v['group_id']] = $v['static_url'];
}
}
break;
case 'production':
$improve_url = array();
$static_url = array();
$group_server=$taskModel->getGroupServer('group_server');
if ($group_server) {
foreach ($group_server as $v) {
$improve_url[$v['group_id']] = $v['api_url'];
$static_url[$v['group_id']] = $v['static_url'];
}
}
break;
default:
$improve_url = array();
$static_url = array();
$group_server=$taskModel->getGroupServer('group_server');
if ($group_server) {
foreach ($group_server as $v) {
$improve_url[$v['group_id']] = $v['api_url'];
$static_url[$v['group_id']] = $v['static_url'];
}
}
}
return $improve_url;
}
//查询剩余任务量
public function actionGetSurplus(){
$examGroupId = Req::post('exam_group_id');
$aStudentScanTask=new AStudentScanTask();
$count=$aStudentScanTask->getTaskCount($examGroupId);
if($count['surplus']==0){
$data['status']=0;
$data['msg']='当前已无异常数据';
exit(json_encode($data));
}else{
$data['status']=1;
$data['msg']='';
exit(json_encode($data));
}
}
}