123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083 |
- <?php
- /**
- * 考试全流程
- * Created by 上海互教教育科技有限公司.
- * User: li
- * Date: 2022/8/8
- * Time: 上午 10:32
- */
- class ExamController extends Controller
- {
- const PRODUCT_WB = 1;//错题本
- const PRODUCT_ISP = 2;//两步个性化学习宝
- const PRODUCT_WBISP = 3;//三步个性化学习宝
- const PRODUCT_METHOD = 31;//考后方法宝(高中)
- public $signatureType=array(
- 1=>7,
- 2=>8,
- 3=>9,
- 31=>31
- );
- // 首页 考试流程时间节点
- public function actionIndex(){
- $examGroupId = Req::post("examGroupId");
- if(!$examGroupId || !is_numeric($examGroupId)){
- $this->returnMsg(0,'考试Id格式不正确');
- }
- $result=array();
- $examGroup=SExamGroup::model()->find("exam_group_id=:id",array(":id"=>$examGroupId));
- if(!$examGroup) $this->returnMsg(0,'考试Id不正确');
- $result['exam_create']=array(); //组卷
- $result['exam_create']['is_third']=$examGroup['is_third'];
- $result['exam_create']['mark_type']=$examGroup['mark_type'];;
- $exam=Exam::model()->findAll("exam_group_id=:id",array(":id"=>$examGroupId));
- $result['exam_create']['create_time']=$exam[0]['create_time']; //发送打印,创建时间
- $result['exam_create']['order_time']=$exam[0]['create_time']; //排序字段
- $result['exam_create']['exam_name']=$exam[0]['name'];
- $result['exam_create']['import_score_type']=$examGroup['import_score_type'];
- $tplData=json_decode($exam[0]['tpl_data'],true);
- $result['exam_create']['exam_date']=$tplData['examDate'];
- $result['exam_create']['teacher']=$tplData['author'];
- $lastTime=$exam[0]['create_time']; //最后操作时间
- $examIds=array();
- $classIds=array();
- $classNames=array();
- $classExam=array();
- foreach ($exam as $value){
- $examIds[]=$value['exam_id'];
- $classIds[]=$value['class_id'];
- $classExam[(string)$value['exam_id']]=$value['class_id'];
- }
- $criteria = new CDbCriteria();
- $criteria->addInCondition('class_id',$classIds);
- $classes = ClassModel::model()->findAll($criteria);
- unset($criteria);
- $result['backlog']=array();
- $result['backlog']['order_time']=0;
- foreach ($classes as $class){
- $classNames[(string)$class['class_id']]=$class['class_name'];
- if($examGroup['mark_type']==0 || $examGroup['import_score_type']>0){
- $result['backlog']['classes'][(string)$class['class_id']]=array(
- 'class_id'=>$class['class_id'],
- 'time'=>0,
- 'class_name'=>$class['class_name']
- );
- }
- }
- $criteria = new CDbCriteria();
- $criteria->select = 'student_id';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->addCondition('is_del = 0');
- $allStudentPaper=SStudentPaperRelation::model()->count($criteria);
- //答题卡类型
- $thirdAnswerSheet=SThirdAnswerSheet::model()->find("exam_group_id=:id",array(":id"=>$examGroupId));
- if(!$thirdAnswerSheet){
- if($examGroup['is_third']==1){
- $this->returnMsg(1,'success',$result); //还没创建答题卡,流程结束
- }else{
- //查询下载答题卡时间
- $examPrint= ClassExamPrinter::model()->find("exam_id in (:ids)",array(':ids'=>implode(',',$examIds)));
- $result['card']['print_time']=$examPrint['print_time'];
- $result['card']['order_time']=$examPrint['print_time'];
- $lastTime<$examPrint['print_time'] && $lastTime=$examPrint['print_time'];
- }
- }else{
- $result['card']['online_card']=$thirdAnswerSheet['online_card']; //是否在线答题卡
- $result['card']['create_answer_card_time']=$thirdAnswerSheet['update_time']; //保存答题卡时间
- $result['card']['order_time']=$thirdAnswerSheet['create_time'];
- $lastTime<$thirdAnswerSheet['create_time'] && $lastTime=$thirdAnswerSheet['create_time'];
- if($thirdAnswerSheet['online_card']==1){
- $onlineCard=SOnlineCardMultiplex::model()->find("multiplex_id=:id",array(":id"=>$thirdAnswerSheet['multiplex_id']));
- if($onlineCard['is_download']==1 && !$thirdAnswerSheet['is_qrcode_online']){
- $result['card']['print_time']=$onlineCard['update_time'];
- $lastTime<$onlineCard['update_time'] && $lastTime=$onlineCard['update_time'];
- }
- //生成时间
- if($onlineCard['is_download']==1 && $thirdAnswerSheet['is_qrcode_online']==1){
- $criteria = new CDbCriteria();
- $criteria->select = 'create_time';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->addCondition('answer_card_online_created = 1');
- $criteria->order="create_time asc";
- $studentCard=SStudentAnswerCardOnline::model()->find($criteria);
- if($studentCard){
- $result['card']['generate_card_start_time']=$studentCard['create_time'];
- }
- $criteria = new CDbCriteria();
- $criteria->select = 'create_time';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->addCondition('answer_card_online_created = 1');
- $createdStudent=SStudentAnswerCardOnline::model()->count($criteria);
- if($createdStudent==$allStudentPaper){
- $criteria = new CDbCriteria();
- $criteria->select = 'create_time';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->addCondition('answer_card_online_created = 1');
- $criteria->order="create_time desc";
- $studentCardLast=SStudentAnswerCardOnline::model()->find($criteria);
- if($studentCardLast){
- $result['card']['generate_card_end_time']=$studentCardLast['create_time'];
- }
- }
- }
- }
- }
- //时间节点
- $examProcess=SExamProcess::model()->findAll("exam_group_id=:id",array(':id'=>$examGroupId));
- $cardPrintClass=array(); //答题卡打印班级
- if($examProcess){
- foreach ($examProcess as $val){
- $lastTime<$val['action_time'] && $lastTime=$val['action_time'];
- switch ($val['action_type']){
- case 1:
- if(!isset($result['label']['send_label_time']) || $val['action_time']<$result['label']['send_label_time']){
- $result['label']['send_label_time']=$val['action_time'];
- if(!isset($result['label']['order_time'])){
- $result['label']['order_time']=$val['action_time'];
- }
- }
- break;
- case 2:
- if($val['action_time']){
- $result['label']['label_complete_time'][]=$val['action_time'];
- }
- break;
- case 3:
- if(!isset($result['parse']['upload_topic_time']) || $result['parse']['upload_topic_time']>$val['action_time']){
- $result['parse']['upload_topic_time']=$val['action_time'];
- $result['parse']['upload_answer_time']=$val['action_time'];
- $result['parse']['order_time']=$val['action_time'];
- }
- break;
- case 4:
- $result['parse']['parse_complete_time']=$val['action_time'];
- break;
- case 5:
- if(!isset($result['parse']['upload_topic_time']) || $result['parse']['upload_topic_time']<$val['action_time']){
- $result['parse']['upload_topic_time']=$val['action_time'];
- $result['parse']['order_time']=$val['action_time'];
- }
- break;
- case 6:
- if(!isset($result['parse']['upload_answer_time']) || $result['parse']['upload_answer_time']<$val['action_time']){
- $result['parse']['upload_answer_time']=$val['action_time'];
- $result['parse']['order_time']=$val['action_time'];
- }
- break;
- case 7:
- //待办
- if(isset($result['backlog']['classes'][(string)$val['class_id']])){
- $result['backlog']['classes'][(string)$val['class_id']]['time']=$val['action_time'];
- }
- if($result['backlog']['order_time']>$val['action_time'] || $result['backlog']['order_time']==0){
- $result['backlog']['order_time']=$val['action_time'];
- }
- break;
- case 8:
- if(!isset($result['card']['create_answer_card_time']) || $result['card']['create_answer_card_time']<$val['action_time']){
- $result['card']['create_answer_card_time']=$val['action_time']; //保存答题卡时间
- }
- break;
- case 9:
- //答题卡下载
- $result['card']['print_time']=$val['action_time'];
- if(!isset($result['card']['print_start_time']) || $result['card']['print_start_time']>$val['action_time']){
- $result['card']['print_start_time']=$val['action_time'];
- }
- if(!isset($result['card']['print_end_time']) || $result['card']['print_end_time']<$val['action_time']){
- $result['card']['print_end_time']=$val['action_time'];
- }
- if($val['exam_id']){
- $cardPrintClass[$val['exam_id']]=$val['action_time'];
- }
- break;
- case 10:
- //重置
- break;
- case 11:
- //切换扫描方式
- $result['card']['change_scan_time']=$val['action_time'];
- if(!isset($result['card']['order_time']) || !$result['card']['order_time']){
- $result['card']['order_time']=$val['action_time'];
- }
- break;
- case 13:
- //在线答题卡生成开始排队时间
- if(!isset($result['card']['create_line_up_time']) || $result['card']['create_line_up_time']>$val['action_time']){
- $result['card']['create_line_up_time']=$val['action_time'];
- }
- break;
- case 14:
- //下载试卷时间
- $result['card']['download_paper_time']=$val['action_time'];
- default:
- }
- }
- }
- //判断是否打印答题卡完成
- if(count($cardPrintClass)!=count($examIds) && isset($result['card']['print_end_time'])){
- $result['card']['print_end_time']=0;
- }
- if(isset($result['backlog']['classes'])){
- $result['backlog']['classes']=array_values($result['backlog']['classes']);
- $lastOrder = $this->_array_column( $result['backlog']['classes'],'time');
- array_multisort($lastOrder,SORT_DESC,$result['backlog']['classes']);
- }
- if(isset($result['label']) ){
- if(isset($tplData["estimateTime"])){
- $result['label']['estimate_time'] = date('Y-m-d H:i:s',$tplData["estimateTime"]);
- }
- //判断标注类型
- $paper=SPaper::model()->find('exam_id=:eid',array(":eid"=>$exam[0]['exam_id']));
- if($paper['labelled_type']==2 && $paper['finish_labelled_time']){
- $result['label']['label_complete_time'][]=$paper['finish_labelled_time'];
- }
- if(isset($result['label']['label_complete_time']) && $result['label']['label_complete_time']){
- sort($result['label']['label_complete_time']);
- }
- }
- if($examGroup['is_third']==1 && isset($result['parse'])){
- $topicWord= STopicWord::model()->find('exam_group_id=:exam_group_id',array(':exam_group_id'=>$examGroupId));
- $result['exam_create']['topic_status']=$topicWord['status'];
- if($topicWord && !$topicWord['allsubject_file_path'] && isset($result['parse']['upload_answer_time'])){
- unset($result['parse']['upload_answer_time']);
- }
- }
- //扫描上传,第一个
- $criteria = new CDbCriteria();
- $criteria->select = 'feedback_time';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->addCondition('is_del = 0 and is_feedback=1');
- $criteria->order="feedback_time asc";
- $studentPaper=SStudentPaperRelation::model()->find($criteria);
- unset($criteria);
- if($studentPaper){
- $result['scan']['start_upload_card_time']=$studentPaper['feedback_time'];
- $result['scan']['order_time']=$studentPaper['feedback_time'];
- $lastTime<$studentPaper['feedback_time'] && $lastTime=$studentPaper['feedback_time'];
- $result['scan']['all_student']=$allStudentPaper;
- unset($criteria);
- $criteria = new CDbCriteria();
- $criteria->select = 'student_id,class_id';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->addCondition('is_del = 0 and is_feedback=1');
- $allUploadStudentPaper=SStudentPaperRelation::model()->count($criteria);
- $result['scan']['uploaded_student']=$allUploadStudentPaper;
- $allUploadStudentClass=SStudentPaperRelation::model()->findAll($criteria);
- $studentClass=array();
- foreach ($allUploadStudentClass as $item){
- $studentClass[(string)$item['class_id']]=$item['class_id'];
- }
- unset($criteria);
- $result['scan']['class_count']=count($studentClass);
- }
- //扫描上传,判断最后一个
- $theLast=false;
- if($examGroup['mark_type']==0 || $examGroup['import_score_type']>0){
- //判断全部点待办
- $isBacklog=false; //待办
- if($result['backlog']){
- $isBacklog=true;
- foreach ($result['backlog']['classes'] as $value){
- if(!$value['time']){
- $isBacklog=false;
- break;
- }
- }
- }
- if($isBacklog){
- $theLast=true;
- }
- }elseif($examGroup['mark_type']==3 && $examGroup['mark_status']==2){
- //混合阅卷
- $theLast=true;
- }elseif($examGroup['mark_type']==4){
- //单独阅卷
- $theLast=true;
- foreach ($exam as $value){
- if($value['status']!=1){
- $theLast=false;
- break;
- }
- }
- }
- if($theLast){
- $criteria = new CDbCriteria();
- $criteria->select = 'feedback_time';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->addCondition('is_del = 0 and is_feedback=1');
- $criteria->order="feedback_time desc";
- $studentPaper=SStudentPaperRelation::model()->find($criteria);
- unset($criteria);
- if($studentPaper){
- $result['scan']['end_upload_card_time']=$studentPaper['feedback_time'];
- $lastTime<$studentPaper['feedback_time'] && $lastTime=$studentPaper['feedback_time'];
- }
- //查询耗时
- $clientScanSpeed=ClientScanSpeedLog::model()->findAll("exam_group_id=:id",array(':id'=>$examGroupId));
- if($clientScanSpeed){
- $scanTimeAvg=0;
- $uploadCardTimeTotal=0;
- $uploadCardCount=0;
- $uploadPaperTimeTotal=0;
- $uploadPaperCount=0;
- foreach ($clientScanSpeed as $item){
- $scanTimeAvg+=$item['scan_time_avg'];
- $uploadCardTimeTotal+=$item['upload_card_time_total'];
- $uploadCardCount+=$item['upload_card_count'];
- $uploadPaperTimeTotal+=$item['upload_paper_time_total'];
- $uploadPaperCount+=$item['upload_paper_count'];
- }
- $result['scan']['scan_time_avg']=ceil($scanTimeAvg/count($clientScanSpeed)); //平均扫描时间
- if($uploadCardTimeTotal && $uploadCardCount){
- $result['scan']['upload_card_time_avg']=ceil($uploadCardTimeTotal/$uploadCardCount); //平均上传答卷耗时
- }
- if($uploadPaperTimeTotal && $uploadPaperCount){
- $result['scan']['upload_paper_time_avg']=ceil($uploadPaperTimeTotal/$uploadPaperCount); //平均上传原卷耗时
- }
- }
- }
- //阅卷
- if($examGroup['mark_type']>0){
- $markParam=array(
- 'examGroupIds'=>array($examGroupId),
- 'schoolId'=>$this->schoolId
- );
- $rs = http('/teacher/marking/v2/marking-info','POST',$this->schoolId,$markParam,'cgi');
- $rs=json_decode($rs,true);
- if(isset($rs['errCode']) && $rs['errCode']=='00' && $rs['data']){
- $result['marking']['marking_start_time']=strtotime($rs['data'][0]['markingStartTime']); //阅卷开始时间
- $result['marking']['marking_end_time']=strtotime($rs['data'][0]['markingEndTime']); //阅卷结束时间
- $result['marking']['marking_process']=$rs['data'][0]['markingProgress']['process']*100; //阅卷进度百分比
- $result['marking']['order_time']=strtotime($rs['data'][0]['markingStartTime']);
- $result['marking']['marking_start_time'] && $lastTime<$result['marking']['marking_start_time'] && $lastTime=$result['marking']['marking_start_time'];
- $result['marking']['marking_end_time'] && $lastTime<$result['marking']['marking_end_time'] && $lastTime=$result['marking']['marking_end_time'];
- if($rs['data'][0]['classMarkingInfos']){
- //单独阅卷
- foreach ($rs['data'][0]['classMarkingInfos'] as $val){
- $result['marking']['class_marking_info'][]=array(
- 'class_name'=>$classNames[(string)$val['classId']],
- 'class_marking_start_time'=>strtotime($val['markingStartTime']),
- 'class_marking_end_time'=>strtotime($val['markingEndTime']),
- 'class_marking_process'=>$val['markingProgress']['process']*100
- );
- }
- $lastOrder = $this->_array_column($result['marking']['class_marking_info'],'class_marking_process');
- array_multisort($lastOrder,SORT_DESC,$result['marking']['class_marking_info']);
- }
- }
- }
- //产品生成,下载
- if(!isset($result['label']) || ($paper['is_labelled']!=5 && $examGroup['is_tagging']!=5)){
- $productTimes=$this->getProduct($examIds);
- if($productTimes){
- $result['product']=$productTimes;
- if($productTimes['product_create_start_time']){
- $result['product']['order_time']=$productTimes['product_create_start_time'];
- }elseif(isset($productTimes['queue_create_time'])){
- $result['product']['order_time']=$productTimes['queue_create_time'];
- }
- if(isset($productTimes['product_last_download_time']) && $productTimes['product_last_download_time'] && $lastTime<$productTimes['product_last_download_time'] ){
- $lastTime=$productTimes['product_last_download_time'];
- }elseif(isset($productTimes['product_first_download_time']) && $productTimes['product_first_download_time'] && $lastTime<$productTimes['product_first_download_time']){
- $lastTime=$productTimes['product_first_download_time'];
- }elseif(isset($productTimes['product_create_last']) && $productTimes['product_create_last'] && $lastTime<$productTimes['product_create_last']){
- $lastTime=$productTimes['product_create_last'];
- }elseif(isset($productTimes['product_create_start_time']) && $productTimes['product_create_start_time'] && $lastTime<$productTimes['product_create_start_time']){
- $lastTime=$productTimes['product_create_start_time'];
- }
- //签收
- $imsClass=array();
- foreach ($productTimes['product_class_type'] as $eid => $v){
- $imsProductType=array();
- foreach ($v as $t){
- $imsProductType[]=$this->signatureType[$t];
- }
- $imsClass[]=array(
- 'clazzId'=>$classExam[$eid],
- 'productTypes'=>$imsProductType
- );
- }
- // $classExam
- $imsParam=array(
- 'businessId'=>$examGroupId,
- 'clazzList'=>$imsClass,
- );
- $http = http('order/deliver/coach/query/signature-time', 'POST', $this->authUsername,$imsParam);
-
- $response = formatResponse($http);
- if ($response['status']) {
- $result['product']['signature']['signature_begin_time']=strtotime($response['data']['beginTime']);
- $result['product']['signature']['signature_end_time']=strtotime($response['data']['endTime']);
- $response['data']['endTime'] && $lastTime<strtotime($response['data']['endTime']) && $lastTime=strtotime($response['data']['endTime']);
- $response['data']['beginTime'] && $lastTime<strtotime($response['data']['beginTime']) && $lastTime=strtotime($response['data']['beginTime']);
- }
- }
- }
- //按开始时间排序
- $lastOrder = $this->_array_column($result,'order_time');
- array_multisort($lastOrder,SORT_ASC,$result);
- //计算总耗时
- $result['exam_total_time_consuming']=consuming($lastTime,$exam[0]['create_time']);
- $this->returnMsg(1,'success',$result);
- }
- //产品生成详情,下载,签收
- public function actionProductDetail(){
- $examGroupId = Req::post("examGroupId");
- if(!$examGroupId || !is_numeric($examGroupId)){
- $this->returnMsg(0,'考试Id格式不正确');
- }
- $result=array();
- $examGroup=SExamGroup::model()->find("exam_group_id=:id",array(":id"=>$examGroupId));
- if(!$examGroup) $this->returnMsg(0,'考试Id不正确');
- $exam=Exam::model()->findAll("exam_group_id=:id",array(":id"=>$examGroupId));
- $examIds=array();
- $classIds=array();
- $classExam=array();
- foreach ($exam as $value){
- $examIds[]=$value['exam_id'];
- $classIds[]=$value['class_id'];
- $classExam[(string)$value['exam_id']]=$value['class_id'];
- }
- $criteria = new CDbCriteria();
- $criteria->addInCondition('class_id',$classIds);
- $classes = ClassModel::model()->findAll($criteria);
- unset($criteria);
- $result['backlog']=array();
- foreach ($classes as $class){
- $classNames[]=array(
- 'clazzId'=>$class['class_name'],
- 'clazzName'=>$class['class_name']
- );
- }
- $criteria = new CDbCriteria();
- $criteria->select = 'pdf_first_time,pdf_last_time,pdf_queue_time,queue_create_time,product_type,download_last_time,download_first_time,exam_id';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->order="pdf_last_time asc";
- $product=SProductProcessTime::model()->findAll($criteria);
- unset($criteria);
- $result=array();
- $downloadType=array();
- $productType=array();
- if($product){
- foreach ($product as $value){
- if(!isset($downloadType[$value['product_type']])){
- if($value['download_last_time']){
- $downloadType[$value['product_type']]=1; //已全部下载
- }else{
- $downloadType[$value['product_type']]=0; //未全部下载
- }
- }elseif($downloadType[$value['product_type']]==1 && !$value['download_last_time']){
- $downloadType[$value['product_type']]=0;
- }
- if(!isset($productType[$value['product_type']])){
- if($value['pdf_last_time']){
- $productType[$value['product_type']]=1; //已全部下载
- }else{
- $productType[$value['product_type']]=0; //未全部下载
- }
- }elseif($productType[$value['product_type']]==1 && !$value['pdf_last_time']){
- $productType[$value['product_type']]=0;
- }
- if(!isset($result[$value['product_type']])){
- $result[$value['product_type']]=array(
- 'create_start_time'=>$value['pdf_first_time'],
- 'create_end_time'=>$value['pdf_last_time'],
- 'student_count'=>1,
- 'download_first_time'=>$value['download_first_time'],
- 'download_last_time'=>$value['download_last_time'],
- 'signature'=>array(
- 'signature_begin_time'=>0,
- 'signature_end_time'=>0
- ),
- );
- }else{
- $result[$value['product_type']]['create_end_time']=$value['pdf_last_time'];
- $result[$value['product_type']]['student_count']++;
- if((!$result[$value['product_type']]['download_first_time'] || $value['download_first_time']< $result[$value['product_type']]['download_first_time']) && $value['download_first_time'] ){
- $result[$value['product_type']]['download_first_time']=$value['download_first_time'];
- }
- if((!$result[$value['product_type']]['download_last_time'] || $value['download_last_time']> $result[$value['product_type']]['download_last_time']) && $value['download_last_time'] ){
- $result[$value['product_type']]['download_last_time']=$value['download_last_time'];
- }
- if((!$result[$value['product_type']]['create_start_time'] || $value['pdf_first_time']< $result[$value['product_type']]['create_start_time']) && $value['pdf_first_time'] ){
- $result[$value['product_type']]['create_start_time']=$value['pdf_first_time'];
- }
- if((!$result[$value['product_type']]['create_end_time'] || $value['pdf_last_time']< $result[$value['product_type']]['create_end_time']) && $value['pdf_last_time'] ){
- $result[$value['product_type']]['create_end_time']=$value['pdf_last_time'];
- }
- }
- $productTypeClassCount[$value['product_type']][$value['exam_id']]=$value['exam_id'];
- }
- //签收
- foreach ($result as $type=>$item){
- if($productType[$type]==0){
- $result[$type]['create_end_time']=0;
- }
- if($downloadType[$type]==0){
- $result[$type]['download_last_time']=0;
- }
- $imsClass=array();
- foreach ($productTypeClassCount[$type] as $eid){
- $imsClass[]=$classExam[$eid];
- }
- $imsParam=array(
- 'businessId'=>$examGroupId,
- 'clazzList'=>$imsClass,
- 'productType'=>$this->signatureType[$type]
- );
- $http = http('order/deliver/coach/query/clazz/signature-time', 'POST', $this->authUsername,$imsParam);
- $response = formatResponse($http);
-
- if ($response['status']) {
- $result[$type]['signature']=array(
- 'signature_begin_time'=>$response['data']['beginTime'],
- 'signature_end_time'=>$response['data']['endTime'],
- );
- }else{
- $result[$type]['signature']=array(
- 'signature_begin_time'=>null,
- 'signature_end_time'=>null
- );
- }
- }
- }
- $this->returnMsg(1,'success',$result);
- }
- //产品班级生成详情,下载,签收
- public function actionProductClassDetail(){
- $examGroupId = Req::post("examGroupId");
- if(!$examGroupId || !is_numeric($examGroupId)){
- $this->returnMsg(0,'考试Id格式不正确');
- }
- $result=array();
- $examGroup=SExamGroup::model()->find("exam_group_id=:id",array(":id"=>$examGroupId));
- if(!$examGroup) $this->returnMsg(0,'考试Id不正确');
- $exam=Exam::model()->findAll("exam_group_id=:id",array(":id"=>$examGroupId));
- $examIds=array();
- $classIds=array();
- $classExam=array();
- foreach ($exam as $value){
- $examIds[]=$value['exam_id'];
- $classIds[]=$value['class_id'];
- $classExam[(string)$value['exam_id']]=$value['class_id'];
- }
- $criteria = new CDbCriteria();
- $criteria->addInCondition('class_id',$classIds);
- $classes = ClassModel::model()->findAll($criteria);
- unset($criteria);
- $classNames=array();
- foreach ($classes as $class){
- $classNames[(string)$class['class_id']]=$class['class_name'];
- $classParams[]=array(
- 'clazzId'=>$class['class_name'],
- 'clazzName'=>$class['class_name']
- );
- }
- $criteria = new CDbCriteria();
- $criteria->select = 'pdf_first_time,pdf_last_time,pdf_queue_time,queue_create_time,product_type,download_last_time,download_first_time,exam_id';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->order="pdf_last_time asc";
- $product=SProductProcessTime::model()->findAll($criteria);
- unset($criteria);
- $result=array();
- $typeStudentCount=0; //共需生成人数
- $typeConsuming=0; //耗时
- if($product){
- $productTypeClass=array();
- foreach ($product as $value){
- $productTypeClass[$value['product_type']][(string)$classExam[$value['exam_id']]]=$classExam[$value['exam_id']];
- if(!isset($result[$value['product_type']]['student_count'])){
- $result[$value['product_type']]['student_count']=1;
- }else{
- $result[$value['product_type']]['student_count']++;
- }
- if((!isset($result[$value['product_type']]['product_create_start_time']) || $value['pdf_first_time']<$result[$value['product_type']]['product_create_start_time']) && $value['pdf_first_time'] ){
- $result[$value['product_type']]['product_create_start_time']=$value['pdf_first_time'];
- }
- if((!isset($result[$value['product_type']]['product_create_end_time']) || $value['pdf_last_time']>$result[$value['product_type']]['product_create_end_time']) && $value['pdf_last_time']){
- $result[$value['product_type']]['product_create_end_time']=$value['pdf_last_time'];
- }
- if((!isset($result[$value['product_type']]['product_download_start_time']) || $value['download_first_time']<$result[$value['product_type']]['product_download_start_time']) && $value['download_first_time']){
- $result[$value['product_type']]['product_download_start_time']=$value['download_first_time'];
- }
- if((!isset($result[$value['product_type']]['product_download_end_time']) || $value['download_last_time']>$result[$value['product_type']]['product_download_end_time']) && $value['download_last_time']){
- $result[$value['product_type']]['product_download_end_time']=$value['download_last_time'];
- }
- if(!isset($result[$value['product_type']]['create'][(string)$classExam[$value['exam_id']]])){
- $result[$value['product_type']]['create'][(string)$classExam[$value['exam_id']]]=array(
- 'class_name'=>$classNames[(string)$classExam[$value['exam_id']]], //班级名称
- 'all_created'=>1, //默认全部生成
- 'product_create_time'=>0, //生成时间
- );
- }
- if(!isset($result[$value['product_type']]['download'][(string)$classExam[$value['exam_id']]])){
- $result[$value['product_type']]['download'][(string)$classExam[$value['exam_id']]]=array(
- 'class_name'=>$classNames[(string)$classExam[$value['exam_id']]], //班级名称
- 'all_downloaded'=>1, //默认全部下载
- 'product_download_time'=>0 //下载时间
- );
- }
- if($value['pdf_last_time']>$result[$value['product_type']]['create'][(string)$classExam[$value['exam_id']]]['product_create_time']){
- $result[$value['product_type']]['create'][(string)$classExam[$value['exam_id']]]['product_create_time']=$value['pdf_last_time'];
- }
- if(!$value['pdf_last_time']){
- $result[$value['product_type']]['create'][(string)$classExam[$value['exam_id']]]['all_created']=0; //未全部生成
- }
- if($value['download_last_time']>$result[$value['product_type']]['download'][(string)$classExam[$value['exam_id']]]['product_download_time']){
- $result[$value['product_type']]['download'][(string)$classExam[$value['exam_id']]]['product_download_time']=$value['download_last_time'];
- }
- if(!$value['download_last_time']){
- $result[$value['product_type']]['download'][(string)$classExam[$value['exam_id']]]['all_downloaded']=0; //未全部下载
- }
- }
- foreach ($result as $type =>$val){
- if($val['create']){
- foreach ($val['create'] as $item){
- if($item['all_created']==0){
- $result[$type]['product_create_end_time']=0;
- break;
- }
- }
- }
- if($val['download']){
- foreach ($val['download'] as $item){
- if($item['all_downloaded']==0){
- $result[$type]['product_download_end_time']=0;
- break;
- }
- }
- }
- }
- //签收
- foreach ($productTypeClass as $type=>$classes){
- $classTypeParams=array();
- foreach ($classes as $class){
- $classTypeParams[]=array(
- 'clazzId'=>$class,
- 'clazzName'=>$classNames[$class],
- );
- }
- $imsParam=array(
- 'businessId'=>$examGroupId,
- 'clazzReqList'=>$classTypeParams,
- 'productType'=>$this->signatureType[$type]
- );
- $http = http('order/deliver/coach/query/clazz-signature', 'POST', $this->authUsername,$imsParam);
- $response = formatResponse($http);
- if ($response['status'] && $response['data']) {
- $signStart=0;
- $signEnd=0;
- $notEnd=0;
- foreach ($response['data'] as $datum){
- if((!$signStart || $signStart>$datum['signatureTime']) && $datum['signatureTime']){
- $signStart=$datum['signatureTime'];
- }
- if(!$datum['signatureTime']){
- //有班级未签收
- $signEnd=0;
- $notEnd=1;
- }
- if((!$signEnd || $signEnd<$datum['signatureTime']) && !$notEnd && $datum['signatureTime']){
- $signEnd= $datum['signatureTime'];
- }
- $result[$type]['signature'][]=$datum;
- }
- $result[$type]['signature_begin_time']=$signStart;
- $result[$type]['signature_end_time']=$signEnd;
- }
- }
- //班级生成排序
- foreach ($result as $type =>$item){
- if(isset($item['create'])){
- $lastOrder = $this->_array_column($item['create'],'all_created');
- array_multisort($lastOrder,SORT_DESC,$result[$type]['create']);
- }
- if(isset($item['download'])){
- $lastOrder = $this->_array_column($item['download'],'all_downloaded');
- array_multisort($lastOrder,SORT_DESC,$result[$type]['download']);
- }
- if(isset($item['signature'])){
- $lastOrder = $this->_array_column($item['signature'],'signatureTime');
- array_multisort($lastOrder,SORT_DESC,$result[$type]['signature']);
- }
- }
- }
- $this->returnMsg(1,'success',$result);
- }
- function returnMsg($status = 0, $message = '', $data = false, $extendData = null)
- {
- header("Cache-Control:no-cache,no-store,max-age=0,must-revalidate");
- $msgData = array('status' => $status, 'message' => $message);
- if ($data !== false) {
- $msgData['data'] = $data;
- }
- if ($extendData) {
- $msgData['extend_data'] = $extendData;
- }
- exit(jsonEncode($msgData));
- }
- public function getProduct($examIds){
- $criteria = new CDbCriteria();
- $criteria->select = 'pdf_first_time,pdf_last_time,pdf_queue_time,queue_create_time,product_type,download_last_time,download_first_time,exam_id';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->order="pdf_last_time asc";
- $product=SProductProcessTime::model()->findAll($criteria);
- if(!$product) return null;
- unset($criteria);
- $productCreateStart=0; //是否开始生成
- $productAllCreated=1; //是否全部生成
- $productTypeCount=array(); //产品种类数量
- $startCreateTime=0; //开始生成时间
- $firstRecorder=array(); //第一条记录
- $lastRecorder=$product[count($product)-1]; //最后一条记录
- $firstDownload=0; //第一次下载时间
- $lastDownload=0; //最后一次下载时间
- $allDownload=1; //是否全部下载
- foreach ($product as $value){
- if($value['pdf_first_time']){
- $productCreateStart=1;
- if(!$startCreateTime || $startCreateTime>$value['pdf_first_time']){
- $startCreateTime=$value['pdf_first_time']; //开始生成时间
- $firstRecorder=$value;
- }
- }
- if($value['pdf_last_time']==0){
- $productAllCreated=0;
- }
- if($value['download_last_time']==0){
- $allDownload=0;
- }
- $productTypeClassCount[$value['exam_id']][$value['product_type']]=$value['product_type'];
- $productTypeCount[$value['product_type']]=$value['product_type'];
- if(!$firstDownload || ($firstDownload>$value['download_first_time'] && $value['download_first_time'])){
- $firstDownload=$value['download_first_time'];
- }
- if(!$lastDownload || ($lastDownload<$value['download_last_time'] && $value['download_last_time'])){
- $lastDownload=$value['download_last_time'];
- }
- }
- if(!$allDownload){
- $lastDownload=0;
- }
- $result=array();
- $result['student_count']=count($product);
- $result['product_create_start']=$productCreateStart;
- $queue=$this->sConn->createCommand("select pdf_queue_time,queue_create_time from product_process_time where exam_id in(".implode(',',$examIds).") and pdf_queue_time>0 order by html_start_time asc ")->queryRow();
- $result['queue_create_time']=(string)$queue['queue_create_time'];
- if(!$productCreateStart){
- if(time()>($queue['queue_create_time']+$queue['pdf_queue_time'])){
- $result['product_create_estimate']=0;
- }else{
- $result['product_create_estimate']=consuming(($queue['queue_create_time']+$queue['pdf_queue_time']),time()); //预计生成时间
- }
-
- }
- $result['product_create_start_time']=$startCreateTime;
- if($productAllCreated){
- $result['product_create_last']=$lastRecorder['pdf_last_time']; //最后一条生成时间
- $result['product_create_time_total']=consuming($lastRecorder['pdf_last_time'],$firstRecorder['pdf_first_time']); //耗时
- }
- $result['product_type']=array_values($productTypeCount); //产品种类
- $result['product_class_type']=$productTypeClassCount;
- $result['product_first_download_time']=$firstDownload;
- $result['product_last_download_time']=$lastDownload;
- //查询重置记录
- $criteria = new CDbCriteria();
- $criteria->select = 'exam_id';
- $criteria->addInCondition('exam_id',$examIds);
- $productReset=SProductResetLog::model()->find($criteria);
- if($productReset){
- $result['product_reset']=1;
- }else{
- $result['product_reset']=0;
- }
- return $result;
- }
- function _array_column(array $array, $column_key, $index_key=null){
- $result = array();
- foreach($array as $arr) {
- if(!is_array($arr)) continue;
- if(is_null($column_key)){
- $value = $arr;
- }else{
- $value = $arr[$column_key];
- }
- if(!is_null($index_key)){
- $key = $arr[$index_key];
- $result[$key] = $value;
- }else{
- $result[] = $value;
- }
- }
- return $result;
- }
- /*在线答题卡生成班级详情*/
- public function actionCardGenerate(){
- $examGroupId = Req::post("examGroupId");
- if(!$examGroupId || !is_numeric($examGroupId)){
- $this->returnMsg(0,'考试Id格式不正确');
- }
- $result=array();
- $examGroup=SExamGroup::model()->find("exam_group_id=:id",array(":id"=>$examGroupId));
- if(!$examGroup) $this->returnMsg(0,'考试Id不正确');
- $exam=Exam::model()->findAll("exam_group_id=:id",array(":id"=>$examGroupId));
- $examIds=array();
- $classIds=array();
- foreach ($exam as $value){
- $examIds[]=$value['exam_id'];
- $classIds[]=$value['class_id'];
- }
- $criteria = new CDbCriteria();
- $criteria->addInCondition('class_id',$classIds);
- $classes = ClassModel::model()->findAll($criteria);
- unset($criteria);
- foreach ($classes as $class){
- $classNames[(string)$class['class_id']]=$class['class_name'];
- }
- //生成时间
- $criteria = new CDbCriteria();
- $criteria->select = 'create_time';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->addCondition('answer_card_online_created = 1');
- $criteria->order="create_time asc";
- $studentCard=SStudentAnswerCardOnline::model()->find($criteria);
- if($studentCard){
- $result['generate_card_time']=$studentCard['create_time'];
- }
- //生成情况
- $model=new SStudentAnswerCardOnline();
- $generateData=$model->getTimeByExamId($examIds);
- $generateCount=array();
- if($generateData){
- foreach ($generateData as $item){
- $generateCount[$item['class_id']]=array(
- 'count'=>$item['count'],
- 'time'=>$item['create_time']
- );
- }
- }
- //获取班级考试的上传成绩
- $criteria = new CDbCriteria();
- $criteria->select= 'student_id,is_feedback,class_id';
- $criteria->addInCondition('exam_id',$examIds);
- $criteria->addCondition('is_del = 0');
- $student_paper_data = SStudentPaperRelation::model()->findAll($criteria);
- $classInfo=array();
- foreach ($student_paper_data as $datum){
- if(!isset($classInfo[$datum['class_id']])){
- $classInfo[$datum['class_id']]=array(
- 'all_student'=>0,
- 'generate_count'=>0,
- 'generate_time'=>0,
- 'class_name'=>$classNames[(string)$datum['class_id']],
- 'order'=>'9999999999'
- );
- }
- $classInfo[$datum['class_id']]['all_student']++;
- if(!$classInfo[$datum['class_id']]['generate_count'] && isset($generateCount[(string)$datum['class_id']])){
- $classInfo[$datum['class_id']]['generate_count'] =$generateCount[(string)$datum['class_id']]['count'];
- $classInfo[$datum['class_id']]['generate_time'] =$generateCount[(string)$datum['class_id']]['time'];
- $classInfo[$datum['class_id']]['order'] =$generateCount[(string)$datum['class_id']]['time'];
- $classInfo[$datum['class_id']]['date'] =date('Y-m-d H:i:s',$generateCount[(string)$datum['class_id']]['time']);
- }
- }
- $lastOrder = $this->_array_column($classInfo,'order');
- array_multisort($lastOrder,SORT_ASC,$classInfo);
- $result['class_list']=array_values($classInfo);
- $this->returnMsg(1,'success',$result);
- }
- /*在线答题卡打印班级详情*/
- public function actionCardPrint(){
- $examGroupId = Req::post("examGroupId");
- if(!$examGroupId || !is_numeric($examGroupId)){
- $this->returnMsg(0,'考试Id格式不正确');
- }
- $result=array();
- $examGroup=SExamGroup::model()->find("exam_group_id=:id",array(":id"=>$examGroupId));
- if(!$examGroup) $this->returnMsg(0,'考试Id不正确');
- $exam=Exam::model()->findAll("exam_group_id=:id",array(":id"=>$examGroupId));
- $examIds=array();
- $classIds=array();
- foreach ($exam as $value){
- $examIds[]=$value['exam_id'];
- $classIds[]=$value['class_id'];
- }
- $criteria = new CDbCriteria();
- $criteria->addInCondition('class_id',$classIds);
- $classes = ClassModel::model()->findAll($criteria);
- unset($criteria);
- $classInfo=array();
- foreach ($classes as $class){
- $classInfo[(string)$class['class_id']]=array(
- "class_name"=>$class['class_name'],
- "print_time"=>0,
- 'order'=>'9999999999'
- );
- $classNames[(string)$class['class_id']]=$class['class_name'];
- }
- $examProcess=SExamProcess::model()->findAll("exam_group_id=:id and action_type=9",array(':id'=>$examGroupId));
- if($examProcess){
- foreach ($examProcess as $item){
- if($item['class_id'] && isset($classInfo[(string)$item['class_id']])){
- $classInfo[$item['class_id']]['print_time']=$item['action_time'];
- $classInfo[$item['class_id']]['order'] =$item['action_time'];
- $classInfo[$item['class_id']]['date'] =date('Y-m-d H:i:s',$item['action_time']);
- }
- }
- }
- $lastOrder = $this->_array_column($classInfo,'order');
- array_multisort($lastOrder,SORT_ASC,$classInfo);
- $this->returnMsg(1,'success',array_values($classInfo));
- }
- }
|