1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048 |
- <?php
- class AssistTaskController extends AssistController
- {
- //素材切割任务总台
- public function actionIndex()
- {
- $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(Yii::app()->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('<br>',$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('<br>',$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));
- }
- }
- }
|