0 "; // $condition[] = "e.subject_id in (3,6) "; $condition[] = "e.complete_time > ".$time; $condition[] = "(eg.mark_type = 0 or eg.import_score_type=3) "; $rs = $this->schoolManager->getBacklogList($condition,array('e.create_time desc,e.exam_id')); // debug($rs); if($rs){ foreach ($rs as $v){ $group_backlog[$v['exam_group_id']][] = $v['is_backlog']; $group_exam[$v['exam_group_id']][$v['exam_id']] = $v['exam_id']; } foreach ($rs as $k=>$v){ if(isset($group_backlog[$v['exam_group_id']]) && isset($group_exam[$v['exam_group_id']])){ $num = array_sum($group_backlog[$v['exam_group_id']]); $count = count($group_exam[$v['exam_group_id']]); if($num == $count){ unset($rs[$k]); }else{ $_rs[$v['exam_group_id']]['result'][] = $v; $_rs[$v['exam_group_id']]['exam_name'] = $v['exam_name']; $_rs[$v['exam_group_id']]['exam_group_id'] = $v['exam_group_id']; } } } } $data['rs'] = $_rs; $this->render("index",$data); } public function actionAjaxSend(){ $exam_id = Req::post("exam_id"); $is_uploaded_count = Req::post("is_uploaded_count"); $students_count = Req::post("students_count"); $class_id = Req::post("class_id"); $_num = 0; if($exam_id>0){ $rs = Exam::model()->updateAll(array('is_backlog'=>1,'update_time'=>time()),'exam_id=:exam_id',array(':exam_id'=>$exam_id)); if($rs){ $exam_data = Exam::model()->find('exam_id=:exam_id',array(':exam_id'=>$exam_id)); if(Yii::app()->params['handle_log_on_off']) { if($exam_data){ writeFileLog(jsonEncode(array( "exam_group_id" => $exam_data->exam_group_id, "school_id" => $this->schoolId, "coach_id" => $this->coachId, "exam_id" => $exam_id, "class_id" => $exam_data->class_id, "upload_num" => $is_uploaded_count, "total_num" => $students_count, "title" => '发送待办', "type" => 0, "date"=>date('Y-m-d H:i:s'), ))); } } $this->schoolManager->saveExamProcess($exam_data->exam_group_id,7,time(),$exam_id,$exam_data->class_id); $time = time()-24*3600*14; $condition[] = "e.is_backlog = 0 "; $condition[] = "e.upload_status > 0 "; $condition[] = "e.complete_time > ".$time; $condition[] = "(eg.mark_type = 0 or eg.import_score_type=3)"; $rs = $this->schoolManager->getBacklogList($condition,array('e.create_time desc,e.exam_id')); if($rs){ foreach ($rs as $v){ $group_backlog[$v['exam_group_id']][] = $v['is_backlog']; $group_exam[$v['exam_group_id']][$v['exam_id']] = $v['exam_id']; } foreach ($rs as $k=>$v){ if(isset($group_backlog[$v['exam_group_id']]) && isset($group_exam[$v['exam_group_id']])){ $num = array_sum($group_backlog[$v['exam_group_id']]); $count = count($group_exam[$v['exam_group_id']]); if($num == $count){ unset($rs[$k]); } } } foreach ($rs as $k=>$v){ if($v['is_uploaded_count'] == 0){ unset($rs[$k]); } } }else{ $rs = array(); } //发送消息队列 if (isset($exam_data->exam_group_id)) { $stomp_data = array('schoolId'=>$this->schoolId,'examGroupId'=>$exam_data->exam_group_id,'examIds'=>array($exam_id)); $this->sendStomp($stomp_data); //发送消息 $sendMsg=array( 'school_id'=>$this->schoolId, 'msg_type'=>3, 'subject_id'=>$exam_data->subject_id, 'send_type'=>'exam', 'exam_group_id'=>$exam_data->exam_group_id, 'exam_ids'=>array($exam_id) ); sendDataToKafka('xbkc-php-product-html',$sendMsg); } unset($exam_data); echo json_encode(array('status'=>1,'count'=>count($rs)));exit; } } echo json_encode(array('status'=>0));exit; } public function actionAjaxAllSend(){ $exam_group_id = Req::post("exam_group_id"); if($exam_group_id>0){ $subjectId=0; $condition[] = "e.is_backlog = 0 "; $condition[] = "e.upload_status > 0 "; $condition[] = "(eg.mark_type = 0 or eg.import_score_type=3)"; $condition[] = "e.exam_group_id = ".$exam_group_id; $rs = $this->schoolManager->getBacklogList($condition,array('e.create_time desc,e.exam_id')); $exam_ids = array(); $class_ids = array(); $name = ''; $batchExamProcess=array(); if($rs){ foreach ($rs as $v){ $name = $v['exam_name']; $subjectId=$v['subject_id']; if($v['is_uploaded_count'] == $v['students_count']){ $exam_ids[$v['exam_id']] = $v['exam_id']; $class_ids[$v['class_id']] = $v['class_id']; $batchExamProcess[]=array( 'exam_id'=>$v['exam_id'], 'class_id'=>$v['class_id'], 'action_type'=>7, 'action_time'=>time() ); } } } $criteria = new CDbCriteria(); $criteria->addInCondition('exam_id',$exam_ids); $rs = Exam::model()->updateAll(array('is_backlog'=>1,'update_time'=>time()),$criteria); if($rs){ if(Yii::app()->params['handle_log_on_off']) { writeFileLog(jsonEncode(array( "exam_group_id" => $exam_group_id, "school_id" => $this->schoolId, "coach_id" => $this->coachId, "exam_id" => implode(',',$exam_ids), "class_id" => implode(',',$class_ids), "upload_num" => 0, "total_num" => 0, "title" => '待办', "type" => 1, "date"=>date('Y-m-d H:i:s') ))); } $this->schoolManager->saveExamProcessBatch($exam_group_id,$batchExamProcess); $time = time()-24*3600*14; $condition[] = "e.is_backlog = 0 "; $condition[] = "e.upload_status > 0 "; $condition[] = "e.complete_time > ".$time; $condition[] = "(eg.mark_type = 0 or eg.import_score_type=3)"; $rs = $this->schoolManager->getBacklogList($condition,array('e.create_time desc,e.exam_id')); if($rs){ foreach ($rs as $v){ $group_backlog[$v['exam_group_id']][] = $v['is_backlog']; $group_exam[$v['exam_group_id']][$v['exam_id']] = $v['exam_id']; } foreach ($rs as $k=>$v){ if(isset($group_backlog[$v['exam_group_id']]) && isset($group_exam[$v['exam_group_id']])){ $num = array_sum($group_backlog[$v['exam_group_id']]); $count = count($group_exam[$v['exam_group_id']]); if($num == $count){ unset($rs[$k]); } } } foreach ($rs as $k=>$v){ if($v['is_uploaded_count'] == 0){ unset($rs[$k]); } } }else{ $rs = array(); } //发送消息队列 if ($exam_ids) { $stomp_data = array('schoolId'=>$this->schoolId,'examGroupId'=>$exam_group_id,'examIds'=>array_keys($exam_ids)); $this->sendStomp($stomp_data); //发送消息 $sendMsg=array( 'school_id'=>$this->schoolId, 'msg_type'=>3, 'subject_id'=>$subjectId, 'send_type'=>'exam', 'exam_group_id'=>$exam_group_id, 'exam_ids'=>array_values($exam_ids) ); sendDataToKafka('xbkc-php-product-html',$sendMsg); } echo json_encode(array('status'=>1,'count'=>count($rs)));exit; } } echo json_encode(array('status'=>0));exit; } /** * 发送消息队列 * @return mixed */ private function sendStomp($data = array()) { if ($data) { $conf = new RdKafka\Conf(); $conf->set('metadata.broker.list', Yii::app()->params['kafka']); $producer = new RdKafka\Producer($conf); $topic = $producer->newTopic("zsyte-marking-finished-notify"); $topic->produce(RD_KAFKA_PARTITION_UA, 0, json_encode($data)); $producer->poll(0); $result = $producer->flush(10000); if($result===0){ return true; } // $destination = 'zsyte.markingFinishedNotify'; // // $stomp_address = Yii::app()->params['markingFinishedNotifyAddress']; // // $stomp = new Stomp($stomp_address); // $stomp->subscribe($destination); // //// $data = array('schoolId'=>123,'examGroupId'=>45679794,'examIds'=>array('54646465')); // // $bool = $stomp->send($destination, json_encode($data)); } return false; } //搜索已发送待办考试 public function actionAjaxGetBacklogExam(){ $examName = Req::post("examName"); $time = time()-24*3600*14; $condition[] = "e.is_backlog =1 "; $condition[] = "e.name ='".$examName."' "; $condition[] = "e.complete_time > ".$time; $sql="SELECT e.exam_group_id,e.exam_id,e.name,e.is_backlog,c.class_name,complete_time,e.tpl_data FROM `exam` e "; $sql.="join class c on c.class_id=e.class_id "; if($condition){ $sql.=" where ".implode(' and ',$condition); } $sql.=" order by e.create_time desc "; $exam = $this->sConn->createCommand($sql)->queryAll(); $result=array(); $list=array(); if($exam){ foreach ($exam as $val){ $tplData=json_decode($val['tpl_data'],true); $val['exam_date']=$tplData['examDate']; unset($val['tpl_data']); $list[$val['exam_group_id']][]=$val; } } //生成Html $html='