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_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)); } }