PrintToolsController.php 139 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201
  1. <?php
  2. class PrintToolsController extends Controller
  3. {
  4. /**
  5. * 下载错题本/二步/三步产品文件
  6. */
  7. public function actionGetImproveFile()
  8. {
  9. $examId = Req::get("examId");
  10. $classId = Req::get("classId");
  11. $type = Req::get("type");
  12. $studentsIds = Req::get("studentsIds");
  13. $printType = Req::get("printType");
  14. $absentFilter = Req::get("absent_filter");
  15. $classDownload = $studentsIds ? false : true;
  16. if (!$examId || !$classId || !$type) {
  17. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  18. exit();
  19. }
  20. if (!in_array($type, array(1, 2, 3))) {
  21. echo json_encode(array("success" => 0, "message" => "参数错误[1]"));
  22. exit();
  23. }
  24. $groupInfo = Exam::model()->getGroupInfo($examId);
  25. if (empty($groupInfo)) exit(json_encode(array("success" => 0, "message" => "考试信息错误")));
  26. $params = array(
  27. "schoolId" => $this->schoolId,
  28. "examId" => $examId,
  29. "classId" => $classId,
  30. "type" => $type,
  31. "studentIds" => array(),
  32. );
  33. $classinfo = ClassModel::model()->find("class_id=:id", array(":id" => $classId));
  34. $Sem = new SSemester();
  35. $code = $Sem->conn->createQuery()->from('semester')->where("semester_id = '" . $classinfo['semester_id'] . "'")
  36. ->limit(1)
  37. ->query()
  38. ->read();
  39. $print_time = ClassExamPrinter::model()->findAll('exam_id=:exam_id and class_id=:classid and type=0', array(':exam_id' => $examId, ':classid' => $classId));
  40. $intarr = array(
  41. "schoolId" => $this->schoolId,
  42. "clazzId" => $classId,
  43. "semester" => $code['refer_code'],
  44. "grade" => $classinfo['grade'],
  45. "students" => array(),
  46. "examTime" => $print_time[0]->add_time,
  47. "classify" => $type,
  48. );
  49. //判断学科
  50. $examInfo = Exam::model()->findByPk($examId);
  51. $intarr['subject'] = $examInfo['subject_id'];
  52. if (in_array($intarr['subject'], $this->mathSubjectId)) {
  53. $intarr['subject'] = 3;
  54. }
  55. if ($type == 1) {
  56. $pdfPathColumn = 'wrongbook_pdf_path';
  57. $isGenerateColumn = 'is_wrongbook_pdf';
  58. $isDownloadColumn = 'is_wrongbook_download';
  59. $downloadTimeCoulmn = 'download_wrongbook_time';
  60. } elseif ($type == 2) {
  61. $pdfPathColumn = 'isp_pdf_path';
  62. $isGenerateColumn = 'is_isp_pdf';
  63. $isDownloadColumn = 'is_two_isp_download';
  64. $downloadTimeCoulmn = 'download_two_isp_time';
  65. } else {
  66. $pdfPathColumn = 'wbisp_pdf_path';
  67. $isGenerateColumn = 'is_wbisp_pdf';
  68. $isDownloadColumn = 'is_three_isp_download';
  69. $downloadTimeCoulmn = 'download_three_isp_time';
  70. }
  71. $productDownload = new ProductDownload($type);
  72. //*****获取生成的学生***//
  73. $generateStu = $productDownload->getGenerateStu('student_paper_relation', 'exam_id', $pdfPathColumn, $isGenerateColumn, $examId, $studentsIds, $absentFilter);
  74. if(!$generateStu){
  75. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  76. }
  77. $separate=0;
  78. if($generateStu['pathArr']){
  79. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  80. if(count($checkTopicAnswer)>1){
  81. $separate=1;
  82. }
  83. }
  84. $params['studentIds'] = $generateStu['studentIds'];
  85. if ($printType == 'third_isp') {
  86. $params["subjectId"] = 8;
  87. $params["type"] = 3;
  88. }
  89. if (Yii::app()->params["limit_open"]) {
  90. $params["studentIds"] = $productDownload->getCanDownloadStu($generateStu['studentIds'], $intarr, $this->schoolId);
  91. }
  92. $this->updateIspDownloadStatus($params["studentIds"],$classId,$examId,$isDownloadColumn,$downloadTimeCoulmn);
  93. ProductProcessTime::model()->updateDownloadTime($params["studentIds"],$type,$examId);
  94. $printData=array();
  95. $printData['typeId']=$type;
  96. $printData['params']=array(
  97. 'examIds'=>array($examId),
  98. 'classIds'=>array($classId),
  99. 'studentIds'=>$params["studentIds"]
  100. );
  101. $printData['separate']=$separate;
  102. $printData['absentFilter']=$absentFilter;
  103. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  104. }
  105. //
  106. //批量下载错题本 提分方案 个性化学习宝
  107. public function actionBatchIsp()
  108. {
  109. $json_params = file_get_contents('php://input');
  110. $params_arr = json_decode($json_params, true);
  111. $notFound = 0;
  112. $printData=array();
  113. $examIds=array();
  114. $classIds=array();
  115. $studentIds=array();
  116. $separate=0;
  117. $absentFilter=0;
  118. foreach ($params_arr as $param) {
  119. $examId = isset($param['examId']) ? $param['examId'] : null;
  120. $classId = isset($param['classId']) ? $param['classId'] : null;
  121. $type = isset($param['type']) ? $param['type'] : null;
  122. $printType = isset($param['printType']) ? $param['printType'] : null;
  123. $absentFilter = isset($param['absent_filter']) ? $param['absent_filter'] : false;
  124. $printData['typeId']=$type;
  125. if (!$examId || !$classId || !$type) {
  126. echo json_encode(array("success" => 0, "message" => "缺少参数"));exit();
  127. }
  128. if (!in_array($type, array(1, 2, 3))) {
  129. echo json_encode(array("success" => 0, "message" => "参数错误[1]"));exit();
  130. }
  131. if ($type == 1) {
  132. $pdfPathColumn = 'wrongbook_pdf_path';
  133. $isGenerateColumn = 'is_wrongbook_pdf';
  134. $isDownloadColumn = 'is_wrongbook_download';
  135. $downloadTimeCoulmn = 'download_wrongbook_time';
  136. } elseif ($type == 2) {
  137. $pdfPathColumn = 'isp_pdf_path';
  138. $isGenerateColumn = 'is_isp_pdf';
  139. $isDownloadColumn = 'is_two_isp_download';
  140. $downloadTimeCoulmn = 'download_two_isp_time';
  141. } else {
  142. $pdfPathColumn = 'wbisp_pdf_path';
  143. $isGenerateColumn = 'is_wbisp_pdf';
  144. $isDownloadColumn = 'is_three_isp_download';
  145. $downloadTimeCoulmn = 'download_three_isp_time';
  146. }
  147. $productDownload = new ProductDownload($type);
  148. //*****获取生成的学生***//
  149. $generateStu = $productDownload->getGenerateStu('student_paper_relation', 'exam_id', $pdfPathColumn, $isGenerateColumn, $examId, array(), $absentFilter);
  150. if(!$generateStu){
  151. $notFound++;
  152. continue;
  153. }
  154. if(!$separate && $generateStu['pathArr']){
  155. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  156. if(count($checkTopicAnswer)>1){
  157. $separate=1;
  158. }
  159. }
  160. $examIds[]=$examId;
  161. $classIds[]=$classId;
  162. $studentIds=array_merge($studentIds,$generateStu['studentIds']);
  163. $this->updateIspDownloadStatus($generateStu["studentIds"],$classId,$examId,$isDownloadColumn,$downloadTimeCoulmn);
  164. }
  165. if($notFound == count($params_arr)){
  166. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  167. }
  168. $printData['params']=array(
  169. 'examIds'=>$examIds,
  170. 'classIds'=>$classIds,
  171. 'studentIds'=>$studentIds
  172. );
  173. $printData['separate']=$separate;
  174. $printData['absentFilter']=$absentFilter;
  175. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  176. }
  177. //阶段复习个性化学习宝下载
  178. public function actionDownloadStudentProduct()
  179. {
  180. $classId = Req::get("classId");
  181. $type = Req::get("type");
  182. $studentsIds = Req::get("studentsIds");
  183. if (!$classId || !$type) {
  184. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  185. exit();
  186. }
  187. if (!in_array($type, array(1, 2, 3))) {
  188. echo json_encode(array("success" => 0, "message" => "参数错误[1]"));
  189. exit();
  190. }
  191. $student_class_data = SStudentClassRelation::model()->findAll('class_id=:class_id and status=:status', array(':class_id' => $classId, ':status' => 0));
  192. if ($student_class_data) {
  193. if (!$studentsIds) {
  194. $studentsIds = array();
  195. foreach ($student_class_data as $v) {
  196. $studentsIds[] = $v->student_id;
  197. }
  198. }
  199. }else{
  200. echo json_encode(array("success" => 0, "message" => "班级暂无学生"));
  201. exit;
  202. }
  203. if ($studentsIds) {
  204. if (!is_array($studentsIds)) {
  205. $studentsIds = explode(',', $studentsIds);
  206. }
  207. if(in_array($this->subjectId,$this->mathSubjectId)){
  208. $subjectId=3;
  209. }else{
  210. $subjectId=$this->subjectId;
  211. }
  212. $_student_product_data=SStudentProductModel::model()->getStudentCreate($studentsIds,$subjectId,$type,$this->semesterId);
  213. if (!$_student_product_data) {
  214. echo json_encode(array("success" => 0, "message" => "无生成的学生"));
  215. exit;
  216. }
  217. $_stu=array();
  218. foreach ($_student_product_data as $datum){
  219. $_stu[]=$datum['student_id'];
  220. }
  221. }
  222. $planId=SStudentProductModel::model()->getPlanId($classId,$subjectId,$type);
  223. $this->updateSpDownloadStatus($_stu,$type,$planId);
  224. $printData['typeId']=4;
  225. $printData['params'][]=array(
  226. 'classId'=>$classId,
  227. 'studentIds'=>$_stu,
  228. 'type'=>$type
  229. );
  230. $printData['separate']=0;
  231. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  232. }
  233. //批量打印阶段复习个性化学习宝
  234. public function actionBatchSp()
  235. {
  236. $json_params = file_get_contents('php://input');
  237. $params_arr = json_decode($json_params, true);
  238. $notFound = 0;
  239. $_stu=array();
  240. $classIds=array();
  241. $separate=0;
  242. $sendParams=array();
  243. foreach ($params_arr as $param) {
  244. $classId = isset($param['classId'])?$param['classId']:null;
  245. $type = isset($param['type'])?$param['type']:null;
  246. if (!$classId || !$type) {
  247. echo json_encode(array("success" => 0, "message" => "缺少参数"));exit();
  248. }
  249. if (!in_array($type, array(1, 2, 3))) {
  250. echo json_encode(array("success" => 0, "message" => "参数错误[1]"));exit();
  251. }
  252. $studentsIds = array();
  253. $student_class_data = SStudentClassRelation::model()->findAll('class_id=:class_id and status=:status', array(':class_id' => $classId, ':status' => 0));
  254. if ($student_class_data) {
  255. foreach ($student_class_data as $v) {
  256. $studentsIds[] = $v->student_id;
  257. }
  258. } else {
  259. echo json_encode(array("success" => 0, "message" => "班级暂无学生"));
  260. exit;
  261. }
  262. $params['studentIds'] = $studentsIds;
  263. if(in_array($this->subjectId,$this->mathSubjectId)){
  264. $subjectId=3;
  265. }else{
  266. $subjectId=$this->subjectId;
  267. }
  268. $_student_product_data=SStudentProductModel::model()->getStudentCreate($studentsIds,$subjectId,$type,$this->semesterId);
  269. if (!$_student_product_data) {
  270. $notFound++;
  271. continue;
  272. }
  273. $planId=SStudentProductModel::model()->getPlanId($classId,$subjectId,$type);
  274. foreach ($_student_product_data as $datum){
  275. $_stu[]=$datum['student_id'];
  276. }
  277. $classIds[]=$classId;
  278. $sendParams[]=array(
  279. 'classId'=>$classId,
  280. 'studentIds'=>$_stu,
  281. 'type'=>$type
  282. );
  283. $this->updateSpDownloadStatus($params['studentIds'], $type,$planId);
  284. }
  285. if($notFound == count($params_arr)){
  286. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  287. }
  288. $printData['separate']=$separate;
  289. $printData['typeId']=4;
  290. $printData['params']=$sendParams;
  291. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));
  292. }
  293. /**
  294. * 打印二轮复习个性化提分手册
  295. */
  296. public function actionGetMathReviewFile()
  297. {
  298. $mrId = (string)Req::get("mrId");
  299. $classId = (string)Req::get("cid");
  300. $studentsIds = Req::get("studentsIds");
  301. $params = array();
  302. if (!$mrId) {
  303. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  304. exit();
  305. }
  306. //*****获取生成的学生***//
  307. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_SECOND_RUN);
  308. $generateStu = $productDownload->getGenerateStu('math_review_student', 'mr_id', 'review_pdf_path', 'is_review_pdf', $mrId, $studentsIds);
  309. if(!$generateStu){
  310. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  311. }
  312. $params['studentIds'] = $generateStu['studentIds'];
  313. $params['mrId'] = $mrId;
  314. $sql = "select class_id,grade,create_time,semester_id,school_group_id,`name` from math_review_setting where mr_id = '{$mrId}'";
  315. $msg = $this->sConn->createCommand($sql)->queryRow();
  316. $Sem = new SSemester();
  317. $code = $Sem->conn->createQuery()
  318. ->from('semester')
  319. ->where("semester_id = '" . $msg['semester_id'] . "'")
  320. ->limit(1)
  321. ->query()
  322. ->read();
  323. $intarr = array(
  324. "schoolId" => $this->schoolId,
  325. "clazzId" => $msg['class_id'],
  326. "semester" => $code['refer_code'],
  327. "grade" => $msg['grade'],
  328. "students" => $studentsIds,
  329. "examTime" => $msg['create_time'],
  330. "classify" => 5,
  331. "subject" => 3
  332. );
  333. //************ Step-1 判断是否有订单 *************//
  334. if (Yii::app()->params["limit_open"]) {
  335. if (Yii::app()->params["limit_open"]) {
  336. $params["studentIds"] = $productDownload->getCanDownloadStu($params['studentIds'], $intarr, $this->schoolId);
  337. }
  338. }
  339. $this->updateSecondRunDownloadStatus($params['studentIds'],$mrId);
  340. $printData=array();
  341. $printData['typeId']=5;
  342. $sendParams['mrId']=$mrId;
  343. $sendParams['classId']=$msg['class_id'];
  344. $sendParams['studentIds']=$params["studentIds"];
  345. $printData['params'][]=$sendParams;
  346. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  347. }
  348. //批量下载二轮复习提分手册
  349. public function actionBatchMathReview(){
  350. $json_params = file_get_contents('php://input');
  351. $params_arr = json_decode($json_params, true);
  352. $notFound = 0;
  353. $printData=array();
  354. $printData['typeId']=5;
  355. foreach ($params_arr as $param) {
  356. $sendParams=array();
  357. $mrId = isset($param['mrId'])?$param['mrId']:null;
  358. $params = array();
  359. if (!$mrId) {
  360. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  361. exit();
  362. }
  363. //*****获取生成的学生***//
  364. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_SECOND_RUN);
  365. $generateStu = $productDownload->getGenerateStu('math_review_student', 'mr_id', 'review_pdf_path', 'is_review_pdf', $mrId, array());
  366. if(!$generateStu){
  367. $notFound++;
  368. continue;
  369. }
  370. $params['studentIds'] = $generateStu['studentIds'];
  371. $sql = "select class_id,grade,create_time,semester_id,school_group_id,`name` from math_review_setting where mr_id = '{$mrId}'";
  372. $msg = $this->sConn->createCommand($sql)->queryRow();
  373. $sendParams['mrId']=$mrId;
  374. $sendParams['classId']=$msg['class_id'];
  375. $sendParams['studentIds']=$params['studentIds'];
  376. $printData['params'][]=$sendParams;
  377. $this->updateSecondRunDownloadStatus($params['studentIds'], $mrId);
  378. }
  379. if($notFound == count($params_arr)){
  380. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  381. }
  382. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  383. }
  384. /**
  385. * 打印好题本
  386. */
  387. public function actionGetHtbFile()
  388. {
  389. $htbId = (string)Req::get("htbId");
  390. $studentsIds = Req::get("studentsIds");
  391. $params = array();
  392. if (!$htbId) {
  393. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  394. exit();
  395. }
  396. //*****获取生成的学生***//
  397. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_HTB);
  398. $generateStu = $productDownload->getGenerateStu('math_htb_student', 'htb_id', 'htb_pdf_path', 'is_htb_pdf', $htbId, $studentsIds);
  399. if(!$generateStu){
  400. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  401. }
  402. $params['studentIds'] = $generateStu['studentIds'];
  403. $separate=0;
  404. if($generateStu['pathArr']){
  405. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  406. if(count($checkTopicAnswer)>1){
  407. $separate=1;
  408. }
  409. }
  410. $sql = "select class_id,grade,create_time,semester_id,school_group_id,name from math_htb_setting where htb_id = '{$htbId}'";
  411. $msg = $this->sConn->createCommand($sql)->queryRow();
  412. $Sem = new SSemester();
  413. $code = $Sem->conn->createQuery()
  414. ->from('semester')
  415. ->where("semester_id = '" . $msg['semester_id'] . "'")
  416. ->limit(1)
  417. ->query()
  418. ->read();
  419. $intarr = array(
  420. "schoolId" => $this->schoolId,
  421. "clazzId" => $msg['class_id'],
  422. "semester" => $code['refer_code'],
  423. "grade" => $msg['grade'],
  424. "examTime" => $msg['create_time'],
  425. "classify" => 9,
  426. "subject" => 3
  427. );
  428. //************ Step-1 判断是否有订单 *************//
  429. if (Yii::app()->params["limit_open"]) {
  430. if (Yii::app()->params["limit_open"]) {
  431. $params["studentIds"] = $productDownload->getCanDownloadStu($params['studentIds'], $intarr, $this->schoolId);
  432. }
  433. }
  434. $this->updateHtbDownloadStatus($params['studentIds'],$htbId);
  435. $printData=array();
  436. $printData['typeId']=6;
  437. $sendParams[]=array(
  438. 'htbId'=>$htbId,
  439. 'classId'=>$msg['class_id'],
  440. 'studentIds'=>$params["studentIds"]
  441. );
  442. $printData['params']=$sendParams;
  443. $printData['separate']=$separate;
  444. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  445. }
  446. //批量下载好题本
  447. public function actionBatchHtb()
  448. {
  449. $json_params = file_get_contents('php://input');
  450. $params_arr = json_decode($json_params, true);
  451. $notFound = 0;
  452. $printData=array();
  453. $sendParams=array();
  454. foreach ($params_arr as $param) {
  455. $htbId = isset($param['htbId']) ? $param['htbId'] : null;
  456. $params = array();
  457. if (!$htbId) {
  458. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  459. exit();
  460. }
  461. //*****获取生成的学生***//
  462. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_HTB);
  463. $generateStu = $productDownload->getGenerateStu('math_htb_student', 'htb_id', 'htb_pdf_path', 'is_htb_pdf', $htbId, array());
  464. if(!$generateStu){
  465. $notFound++;
  466. continue;
  467. }
  468. $params['studentIds'] = $generateStu['studentIds'];
  469. $separate=0;
  470. if($generateStu['pathArr']){
  471. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  472. if(count($checkTopicAnswer)>1){
  473. $separate=1;
  474. }
  475. }
  476. $sql = "select class_id,grade,create_time,semester_id,school_group_id from math_htb_setting where htb_id = '{$htbId}'";
  477. $msg = $this->sConn->createCommand($sql)->queryRow();
  478. $sendParams[]=array(
  479. 'htbId'=>$htbId,
  480. 'classId'=>$msg['class_id'],
  481. 'studentIds'=>$params["studentIds"]
  482. );
  483. $this->updateHtbDownloadStatus($params['studentIds'],$htbId);
  484. }
  485. if($notFound == count($params_arr)){
  486. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  487. }
  488. $printData['typeId']=6;
  489. $printData['params']=$sendParams;
  490. $printData['separate']=$separate;
  491. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  492. }
  493. /**
  494. * 下载假期报告
  495. */
  496. public function actionGetHolidayReportFile()
  497. {
  498. $reportId = (string)Req::get("reportId");
  499. $studentsIds = Req::get("studentsIds");
  500. $classDownload = $studentsIds ? false : true;
  501. $params = array();
  502. if (!$reportId) {
  503. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  504. exit();
  505. }
  506. //*****获取生成的学生***//
  507. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_HOLIDAY_REPORT);
  508. $generateStu = $productDownload->getGenerateStu('holiday_report_student', 'report_id', 'report_pdf_path', 'is_report_pdf', $reportId, $studentsIds);
  509. if(!$generateStu){
  510. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  511. }
  512. $params['studentIds'] = $generateStu['studentIds'];
  513. $sql = "select class_id,grade,create_time,semester_id from holiday_report_setting where report_id = '{$reportId}'";
  514. $msg = $this->sConn->createCommand($sql)->queryRow();
  515. $this->updateHrpDownloadStatus($params['studentIds'],$reportId);
  516. $printData=array();
  517. $printData['typeId']=7;
  518. $sendParams[]=array(
  519. 'reportId'=>$reportId,
  520. 'classId'=>$msg['class_id'],
  521. 'studentIds'=>$params["studentIds"]
  522. );
  523. $printData['params']=$sendParams;
  524. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  525. }
  526. //批量下载假期报告
  527. public function actionBatchHoliday(){
  528. $json_params = file_get_contents('php://input');
  529. $params_arr = json_decode($json_params, true);
  530. $notFound = 0;
  531. $printData=array();
  532. $sendParams=array();
  533. foreach ($params_arr as $param) {
  534. $reportId = isset($param['reportId']) ? $param['reportId'] : null;
  535. if (!$reportId) {
  536. echo json_encode(array("status" => 0, "message" => "缺少参数"));exit();
  537. }
  538. $params = array();
  539. //*****获取生成的学生***//
  540. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_HOLIDAY_REPORT);
  541. $generateStu = $productDownload->getGenerateStu('holiday_report_student', 'report_id', 'report_pdf_path', 'is_report_pdf', $reportId, array());
  542. if(!$generateStu){
  543. $notFound++;
  544. continue;
  545. }
  546. $params['studentIds'] = $generateStu['studentIds'];
  547. $sql = "select class_id,grade,create_time,semester_id from holiday_report_setting where report_id = '{$reportId}'";
  548. $msg = $this->sConn->createCommand($sql)->queryRow();
  549. $sendParams[]=array(
  550. 'reportId'=>$reportId,
  551. 'classId'=>$msg['class_id'],
  552. 'studentIds'=>$params["studentIds"]
  553. );
  554. $this->updateHrpDownloadStatus($params['studentIds'],$reportId);
  555. }
  556. if($notFound == count($params_arr)){
  557. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  558. }
  559. $printData['typeId']=7;
  560. $printData['params']=$sendParams;
  561. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  562. }
  563. //打印方法宝
  564. public function actionGetFfb()
  565. {
  566. $examId = Req::get("examId");
  567. $classId = Req::get("classId");
  568. $type = Req::get("type");
  569. $studentsIds = Req::get("studentsIds");
  570. if (!$examId || !$classId || !$type) {
  571. self::responseMsg(0, '缺少参数');
  572. }
  573. $params = array(
  574. "schoolId" => $this->schoolId,
  575. "examId" => $examId,
  576. "classId" => $classId,
  577. "type" => $type,
  578. "studentIds" => array(),
  579. );
  580. $classinfo = ClassModel::model()->find("class_id=:id", array(":id" => $classId));
  581. $Sem = new SSemester();
  582. $code = $Sem->conn->createQuery()->from('semester')->where("semester_id = '" . $classinfo['semester_id'] . "'")
  583. ->limit(1)
  584. ->query()
  585. ->read();
  586. $sql = "select p.add_time from exam e join class_exam_printer p on p.exam_id=e.exam_id
  587. join class c on e.class_id = c.class_id where e.class_id = '{$classId}' and e.exam_id = '{$examId}'";
  588. $time = $this->sConn->createCommand($sql)->queryRow();
  589. $intarr = array(
  590. "schoolId" => $this->schoolId,
  591. "clazzId" => $classId,
  592. "semester" => $code['refer_code'],
  593. "grade" => $classinfo['grade'],
  594. "students" => array(),
  595. "examTime" => isset($time['add_time'])? $time['add_time'] : time(),
  596. "classify" => $type,
  597. );
  598. //判断学科
  599. $examInfo = Exam::model()->findByPk($examId);
  600. $intarr['subject'] = $examInfo['subject_id'];
  601. if (in_array($intarr['subject'], $this->mathSubjectId) && $intarr['subject']!=41) {
  602. $intarr['subject'] = 3;
  603. }
  604. $pdfPathColumn = 'pdf_path';
  605. $isGenerateColumn = 'is_create_pdf';
  606. $productDownload = new ProductDownload($type);
  607. //*****获取生成的学生***//
  608. $generateStu = $productDownload->getGenerateStu('exam_product_status', 'exam_id', $pdfPathColumn, $isGenerateColumn, $examId, $studentsIds);
  609. if(!$generateStu){
  610. self::responseMsg(0, '无生成的pdf');
  611. }
  612. $params['studentIds'] = $generateStu['studentIds'];
  613. $separate=0;
  614. if($generateStu['pathArr']){
  615. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  616. if(count($checkTopicAnswer)>1){
  617. $separate=1;
  618. }
  619. }
  620. if (Yii::app()->params["limit_open"]) {
  621. $params["studentIds"] = $productDownload->getCanDownloadStu($generateStu['studentIds'], $intarr, $this->schoolId);
  622. }
  623. ProductProcessTime::model()->updateDownloadTime($params["studentIds"],$type,$examId);
  624. $this->updateDownloadStatus($params["studentIds"],$examId,$type);
  625. $printData=array();
  626. $printData['typeId']=8;
  627. $printData['params']['examIds'][]=$examId;
  628. $printData['params']['classIds'][]=$classId;
  629. if($studentsIds){
  630. $printData['params']['studentIds']=$params["studentIds"];
  631. }
  632. $printData['separate']=$separate;
  633. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  634. }
  635. //FIXME 批量
  636. public function actionBatch(){
  637. $json_params = file_get_contents('php://input');
  638. $params_arr = json_decode($json_params, true);
  639. $notFound = 0;
  640. $printData=array();
  641. $printData['typeId']=8;
  642. $examIds=array();
  643. $classIds=array();
  644. foreach ($params_arr as $param) {
  645. $examId = isset($param['examId']) ? $param['examId'] : null;
  646. $classId = isset($param['classId']) ? $param['classId'] : null;
  647. $type = isset($param['type']) ? $param['type'] : null;
  648. $absentFilter = isset($param['absent_filter']) ? $param['absent_filter'] : false;
  649. if (!$examId || !$classId || !$type) {
  650. echo json_encode(array("success" => 0, "message" => "缺少参数"));exit();
  651. }
  652. $pdfPathColumn = 'pdf_path';
  653. $isGenerateColumn = 'is_create_pdf';
  654. $productDownload = new ProductDownload($type);
  655. $condition = array('product_type'=>$type);
  656. //*****获取生成的学生***//
  657. $generateStu = $productDownload->getGenerateStu('exam_product_status', 'exam_id', $pdfPathColumn, $isGenerateColumn, $examId, array(), $absentFilter, $condition);
  658. if(!$generateStu){
  659. $notFound++;
  660. continue;
  661. }
  662. $params['studentIds'] = $generateStu['studentIds'];
  663. $separate=0;
  664. if($generateStu['pathArr']){
  665. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  666. if(count($checkTopicAnswer)>1){
  667. $separate=1;
  668. }
  669. }
  670. ProductProcessTime::model()->updateDownloadTime($params["studentIds"],$type,$examId);
  671. $this->updateDownloadStatus($params["studentIds"],$examId,$type);
  672. $examIds[]=$examId;
  673. $classIds[]=$classId;
  674. }
  675. if($notFound && $notFound==count($params_arr)){
  676. echo json_encode(array("success" => 0, "message" => "无生成的pdf"));exit();
  677. }
  678. $printData['params']['examIds']=$examIds;
  679. $printData['params']['classIds']=$classIds;
  680. $printData['separate']=$separate;
  681. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  682. }
  683. //打印专题宝
  684. public function actionGetUrlZtb()
  685. {
  686. $gpId = Req::get("gpId");
  687. $classId = Req::get("classId");
  688. $type = Req::get("type");
  689. $studentsIds = Req::get("studentsIds");
  690. if (!$gpId || !$classId || !$type) {
  691. self::responseMsg(0, '缺少参数');
  692. }
  693. $params = array(
  694. "schoolId" => $this->schoolId,
  695. "gpId" => $gpId,
  696. "classId" => $classId,
  697. "type" => $type,
  698. "studentIds" => array(),
  699. );
  700. $classinfo = ClassModel::model()->find("class_id=:id", array(":id" => $classId));
  701. $Sem = new SSemester();
  702. $code = $Sem->conn->createQuery()->from('semester')->where("semester_id = '" . $classinfo['semester_id'] . "'")
  703. ->limit(1)
  704. ->query()
  705. ->read();
  706. $product = SGeneralProduct::model()->find('gp_id=:gp_id and class_id=:classid', array(':gp_id' => $gpId, ':classid' => $classId));
  707. $intarr = array(
  708. "schoolId" => $this->schoolId,
  709. "clazzId" => $classId,
  710. "semester" => $code['refer_code'],
  711. "grade" => $classinfo['grade'],
  712. "students" => array(),
  713. "examTime" => $product['create_time'] ? $product['create_time'] : time(),
  714. "classify" => $type,
  715. );
  716. //判断学科
  717. $intarr['subject'] = $product['subject_id'];
  718. $pdfPathColumn = 'pdf_path';
  719. $isGenerateColumn = 'is_create_pdf';
  720. $productDownload = new ProductDownload($type);
  721. //*****获取生成的学生***//
  722. $generateStu = $productDownload->getGenerateStu('general_product_student', 'gp_id', $pdfPathColumn, $isGenerateColumn, $gpId, $studentsIds);
  723. if(!$generateStu){
  724. self::responseMsg(0, '无生成的pdf');
  725. }
  726. $params['studentIds'] = $generateStu['studentIds'];
  727. $separate=0;
  728. if($generateStu['pathArr']){
  729. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  730. if(count($checkTopicAnswer)>1){
  731. $separate=1;
  732. }
  733. }
  734. if (Yii::app()->params["limit_open"]) {
  735. $params["studentIds"] = $productDownload->getCanDownloadStu($generateStu['studentIds'], $intarr, $this->schoolId);
  736. array_push($params['studentIds'],0);
  737. }
  738. $this->updateDownloadStatusZtb($params["studentIds"],$gpId);
  739. $printData=array();
  740. $printData['typeId']=9;
  741. $sendParams[]=array(
  742. 'gpId'=>$gpId,
  743. 'classId'=>$classId,
  744. 'studentIds'=>$params["studentIds"]
  745. );
  746. $printData['params']=$sendParams;
  747. $printData['separate']=$separate;
  748. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  749. }
  750. //批量打印专题宝
  751. public function actionBatchZtb(){
  752. $json_params = file_get_contents('php://input');
  753. $params_arr = json_decode($json_params, true);
  754. $notFound = 0;
  755. $printData=array();
  756. $printData['typeId']=9;
  757. $sendParams=array();
  758. foreach ($params_arr as $param) {
  759. $gpId = isset($param['gpId']) ? $param['gpId'] : null;
  760. $classId = isset($param['classId']) ? $param['classId'] : null;
  761. $type = isset($param['type']) ? $param['type'] : null;
  762. $absentFilter = isset($param['absent_filter']) ? $param['absent_filter'] : false;
  763. if (!$gpId || !$classId || !$type) {
  764. echo json_encode(array("success" => 0, "message" => "缺少参数"));exit();
  765. }
  766. $params = array(
  767. "schoolId" => $this->schoolId,
  768. "gpId" => $gpId,
  769. "classId" => $classId,
  770. "type" => $type,
  771. "studentIds" => array(),
  772. );
  773. $pdfPathColumn = 'pdf_path';
  774. $isGenerateColumn = 'is_create_pdf';
  775. $productDownload = new ProductDownload($type);
  776. //*****获取生成的学生***//
  777. $generateStu = $productDownload->getGenerateStu('general_product_student', 'gp_id', $pdfPathColumn, $isGenerateColumn, $gpId, array(), $absentFilter);
  778. if(!$generateStu){
  779. $notFound++;
  780. continue;
  781. }
  782. $params['studentIds'] = $generateStu['studentIds'];
  783. $separate=0;
  784. if($generateStu['pathArr']){
  785. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  786. if(count($checkTopicAnswer)>1){
  787. $separate=1;
  788. }
  789. }
  790. $sendParams[]=array(
  791. 'gpId'=>$gpId,
  792. 'classId'=>$classId,
  793. 'studentIds'=>$params["studentIds"]
  794. );
  795. $this->updateDownloadStatusZtb($params["studentIds"],$gpId);
  796. }
  797. if($notFound && $notFound==count($params_arr)){
  798. echo json_encode(array("success" => 0, "message" => "无生成的pdf"));exit();
  799. }
  800. $printData['separate']=$separate;
  801. $printData['params']=$sendParams;
  802. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  803. }
  804. //打印假期作业
  805. public function actionGetUrlJqzy()
  806. {
  807. $gpId = Req::get("gpId");
  808. $classId = Req::get("classId");
  809. $type = Req::get("type");
  810. $studentsIds = Req::get("studentsIds");
  811. if (!$gpId || !$classId || !$type) {
  812. self::responseMsg(0, '缺少参数');
  813. }
  814. $params = array(
  815. "schoolId" => $this->schoolId,
  816. "gpId" => $gpId,
  817. "classId" => $classId,
  818. "type" => $type,
  819. "studentIds" => array(),
  820. );
  821. $classinfo = ClassModel::model()->find("class_id=:id", array(":id" => $classId));
  822. $Sem = new SSemester();
  823. $code = $Sem->conn->createQuery()->from('semester')->where("semester_id = '" . $classinfo['semester_id'] . "'")
  824. ->limit(1)
  825. ->query()
  826. ->read();
  827. $product = SGeneralProduct::model()->find('gp_id=:gp_id and class_id=:classid', array(':gp_id' => $gpId, ':classid' => $classId));
  828. $intarr = array(
  829. "schoolId" => $this->schoolId,
  830. "clazzId" => $classId,
  831. "semester" => $code['refer_code'],
  832. "grade" => $classinfo['grade'],
  833. "students" => array(),
  834. "examTime" => $product['create_time'] ? $product['create_time'] : time(),
  835. "classify" => $type,
  836. );
  837. //判断学科
  838. $intarr['subject'] = $product['subject_id'];
  839. $pdfPathColumn = 'pdf_path';
  840. $isGenerateColumn = 'is_create_pdf';
  841. $productDownload = new ProductDownload($type);
  842. //*****获取生成的学生***//
  843. $generateStu = $productDownload->getGenerateStu('general_product_student', 'gp_id', $pdfPathColumn, $isGenerateColumn, $gpId, $studentsIds);
  844. if(!$generateStu){
  845. self::responseMsg(0, '无生成的pdf');
  846. }
  847. $params['studentIds'] = $generateStu['studentIds'];
  848. if (Yii::app()->params["limit_open"]) {
  849. $params["studentIds"] = $productDownload->getCanDownloadStu($generateStu['studentIds'], $intarr, $this->schoolId);
  850. array_push($params['studentIds'],0);
  851. }
  852. $separate=0;
  853. if($generateStu['pathArr']){
  854. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  855. if(count($checkTopicAnswer)>1){
  856. $separate=1;
  857. }
  858. }
  859. $this->updateDownloadStatusZtb($params["studentIds"],$gpId);
  860. $printData=array();
  861. $printData['typeId']=10;
  862. $sendParams[]=array(
  863. 'gpId'=>$gpId,
  864. 'classId'=>$classId,
  865. 'studentIds'=>$params["studentIds"]
  866. );
  867. $printData['params']=$sendParams;
  868. $printData['separate']=$separate;
  869. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  870. }
  871. //批量打印假期作业
  872. public function actionBatchJqzy(){
  873. $json_params = file_get_contents('php://input');
  874. $params_arr = json_decode($json_params, true);
  875. $notFound = 0;
  876. $printData=array();
  877. $printData['typeId']=10;
  878. $sendParams=array();
  879. foreach ($params_arr as $param) {
  880. $gpId = isset($param['gpId']) ? $param['gpId'] : null;
  881. $classId = isset($param['classId']) ? $param['classId'] : null;
  882. $type = isset($param['type']) ? $param['type'] : null;
  883. $absentFilter = isset($param['absent_filter']) ? $param['absent_filter'] : false;
  884. if (!$gpId || !$classId || !$type) {
  885. echo json_encode(array("success" => 0, "message" => "缺少参数"));exit();
  886. }
  887. $params = array(
  888. "schoolId" => $this->schoolId,
  889. "gpId" => $gpId,
  890. "classId" => $classId,
  891. "type" => $type,
  892. "studentIds" => array(),
  893. );
  894. $pdfPathColumn = 'pdf_path';
  895. $isGenerateColumn = 'is_create_pdf';
  896. $productDownload = new ProductDownload($type);
  897. //*****获取生成的学生***//
  898. $generateStu = $productDownload->getGenerateStu('general_product_student', 'gp_id', $pdfPathColumn, $isGenerateColumn, $gpId, array(), $absentFilter);
  899. if(!$generateStu){
  900. $notFound++;
  901. continue;
  902. }
  903. $params['studentIds'] = $generateStu['studentIds'];
  904. $separate=0;
  905. if($generateStu['pathArr']){
  906. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  907. if(count($checkTopicAnswer)>1){
  908. $separate=1;
  909. }
  910. }
  911. $sendParams[]=array(
  912. 'gpId'=>$gpId,
  913. 'classId'=>$classId,
  914. 'studentIds'=>$params["studentIds"]
  915. );
  916. $this->updateDownloadStatusZtb($params["studentIds"],$gpId);
  917. }
  918. if($notFound && $notFound==count($params_arr)){
  919. echo json_encode(array("success" => 0, "message" => "无生成的pdf"));exit();
  920. }
  921. $printData['params']=$sendParams;
  922. $printData['separate']=$separate;
  923. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  924. }
  925. /**
  926. * 打印晨读词汇
  927. */
  928. public function actionGetEnglishFile()
  929. {
  930. $weekId = (string)Req::get("weekId");
  931. $studentsIds = Req::get("studentsIds");
  932. $params = array();
  933. if (!$weekId) {
  934. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  935. exit();
  936. }
  937. //*****获取生成的学生***//
  938. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_EN_MRV);
  939. $generateStu = $productDownload->getGenerateStu('english_week_student', 'week_id', 'week_pdf_path', 'is_week_pdf', $weekId, $studentsIds);
  940. if(!$generateStu){
  941. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  942. }
  943. $params['studentIds'] = $generateStu['studentIds'];
  944. $separate=0;
  945. if($generateStu['pathArr']){
  946. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  947. if(count($checkTopicAnswer)>1){
  948. $separate=1;
  949. }
  950. }
  951. $sql = "select class_id,grade,create_time,semester_id,`name` from english_week where week_id = '{$weekId}'";
  952. $msg = $this->sConn->createCommand($sql)->queryRow();
  953. $Sem = new SSemester();
  954. $code = $Sem->conn->createQuery()
  955. ->from('semester')
  956. ->where("semester_id = '" . $msg['semester_id'] . "'")
  957. ->limit(1)
  958. ->query()
  959. ->read();
  960. $intarr = array(
  961. "schoolId" => $this->schoolId,
  962. "clazzId" => $msg['class_id'],
  963. "semester" => $code['refer_code'],
  964. "grade" => $msg['grade'],
  965. "examTime" => $msg['create_time'],
  966. "classify" => 3,
  967. "subject" => 8
  968. );
  969. //************ Step-1 判断是否有订单 *************//
  970. if (Yii::app()->params["limit_open"]) {
  971. if (Yii::app()->params["limit_open"]) {
  972. $params["studentIds"] = $productDownload->getCanDownloadStu($params['studentIds'], $intarr, $this->schoolId);
  973. }
  974. }
  975. $this->updateEnMrvDownloadStatus($params['studentIds'],$weekId);
  976. $printData=array();
  977. $printData['typeId']=15;
  978. $sendParams[]=array(
  979. 'weekId'=>$weekId,
  980. 'classId'=>$msg['class_id'],
  981. 'studentIds'=>$params["studentIds"]
  982. );
  983. $printData['params']=$sendParams;
  984. $printData['separate']=$separate;
  985. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  986. }
  987. //批量晨读词汇
  988. public function actionBatchEnMrv()
  989. {
  990. $json_params = file_get_contents('php://input');
  991. $params_arr = json_decode($json_params, true);
  992. $notFound = 0;
  993. $printData=array();
  994. $printData['typeId']=15;
  995. $sendParams=array();
  996. $separate=0;
  997. foreach ($params_arr as $param) {
  998. $weekId = isset($param['weekId']) ? $param['weekId'] : null;
  999. $params = array();
  1000. if (!$weekId) {
  1001. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1002. exit();
  1003. }
  1004. //*****获取生成的学生***//
  1005. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_EN_MRV);
  1006. $generateStu = $productDownload->getGenerateStu('english_week_student', 'week_id', 'week_pdf_path', 'is_week_pdf', $weekId, array());
  1007. if(!$generateStu){
  1008. $notFound++;
  1009. continue;
  1010. }
  1011. $params['studentIds'] = $generateStu['studentIds'];
  1012. if($generateStu['pathArr'] && !$separate){
  1013. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  1014. if(count($checkTopicAnswer)>1){
  1015. $separate=1;
  1016. }
  1017. }
  1018. $sql = "select class_id,grade,create_time,semester_id,`name` from english_week where week_id = '{$weekId}'";
  1019. $msg = $this->sConn->createCommand($sql)->queryRow();
  1020. $sendParams[]=array(
  1021. 'weekId'=>$weekId,
  1022. 'classId'=>$msg['class_id'],
  1023. 'studentIds'=>$params["studentIds"]
  1024. );
  1025. $this->updateEnMrvDownloadStatus($params['studentIds'], $weekId);
  1026. }
  1027. if($notFound == count($params_arr)){
  1028. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  1029. }
  1030. $printData['params']=$sendParams;
  1031. $printData['separate']=$separate;
  1032. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1033. }
  1034. /**
  1035. * 下载外刊美文个性化学习宝
  1036. */
  1037. public function actionGetEnglishReadingFile()
  1038. {
  1039. $weekId = (string)Req::get("weekId");
  1040. $studentsIds = Req::get("studentsIds");
  1041. $classDownload = $studentsIds ? false : true;
  1042. $params = array();
  1043. if (!$weekId) {
  1044. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1045. exit();
  1046. }
  1047. $sql = "select class_id,ers.grade,er.create_time,er.semester_id,name,ers.category,ers.product_type from english_reading er join english_reading_setting ers on ers.reading_id=er.reading_id where week_id = '{$weekId}'";
  1048. $msg = $this->sConn->createCommand($sql)->queryRow();
  1049. $Sem = new SSemester();
  1050. $code = $Sem->conn->createQuery()
  1051. ->from('semester')
  1052. ->where("semester_id = '" . $msg['semester_id'] . "'")
  1053. ->limit(1)
  1054. ->query()
  1055. ->read();
  1056. $classify=6;
  1057. if($msg['category']==2){
  1058. if($msg['product_type']==1){
  1059. $classify=57;
  1060. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_EN_READING_JICHU);
  1061. }elseif($msg['product_type']==2){
  1062. $classify=61;
  1063. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_EN_READING_WAIKAN);
  1064. }elseif($msg['product_type']==3){
  1065. $classify=58;
  1066. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_EN_READING_REDIAN);
  1067. }
  1068. }else{
  1069. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_EN_READING);
  1070. }
  1071. //*****获取生成的学生***//
  1072. $generateStu = $productDownload->getGenerateStu('english_reading_student', 'week_id', 'week_pdf_path', 'is_week_pdf', $weekId, $studentsIds);
  1073. if(!$generateStu){
  1074. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  1075. }
  1076. $params['studentIds'] = $generateStu['studentIds'];
  1077. $separate=0;
  1078. if($generateStu['pathArr']){
  1079. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  1080. if(count($checkTopicAnswer)>1){
  1081. $separate=1;
  1082. }
  1083. }
  1084. $intarr = array(
  1085. "schoolId" => $this->schoolId,
  1086. "clazzId" => $msg['class_id'],
  1087. "semester" => $code['refer_code'],
  1088. "grade" => $msg['grade'],
  1089. "students" => $studentsIds,
  1090. "examTime" => $msg['create_time'],
  1091. "classify" => $classify,
  1092. "subject" => 8
  1093. );
  1094. //************ Step-1 判断是否有订单 *************//
  1095. if (Yii::app()->params["limit_open"]) {
  1096. if (Yii::app()->params["limit_open"]) {
  1097. $params["studentIds"] = $productDownload->getCanDownloadStu($params['studentIds'], $intarr, $this->schoolId);
  1098. }
  1099. }
  1100. $this->updateEnreadingDownloadStatus($params['studentIds'],$weekId);
  1101. $printData=array();
  1102. $printData['typeId']=11;
  1103. $sendParams[]=array(
  1104. 'weekId'=>$weekId,
  1105. 'classId'=>$msg['class_id'],
  1106. 'studentIds'=>$params["studentIds"]
  1107. );
  1108. $printData['params']=$sendParams;
  1109. $printData['separate']=$separate;
  1110. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1111. }
  1112. /**
  1113. * 批量外刊美文个性化学习宝
  1114. */
  1115. public function actionBatchEnReading()
  1116. {
  1117. $json_params = file_get_contents('php://input');
  1118. $params_arr = json_decode($json_params, true);
  1119. $notFound = 0;
  1120. $printData=array();
  1121. $printData['typeId']=11;
  1122. $sendParams=array();
  1123. $separate=0;
  1124. foreach ($params_arr as $param) {
  1125. $weekId = isset($param['weekId']) ? (string)$param['weekId'] : null;
  1126. $params = array();
  1127. if (!$weekId) {
  1128. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1129. exit();
  1130. }
  1131. //*****获取生成的学生***//
  1132. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_EN_READING);
  1133. $generateStu = $productDownload->getGenerateStu('english_reading_student', 'week_id', 'week_pdf_path', 'is_week_pdf', $weekId, array());
  1134. if(!$generateStu){
  1135. $notFound++;
  1136. continue;
  1137. }
  1138. $params['studentIds'] = $generateStu['studentIds'];
  1139. if($generateStu['pathArr'] && !$separate){
  1140. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  1141. if(count($checkTopicAnswer)>1){
  1142. $separate=1;
  1143. }
  1144. }
  1145. $sql = "select class_id,grade,create_time,semester_id,name from english_reading where week_id = '{$weekId}'";
  1146. $msg = $this->sConn->createCommand($sql)->queryRow();
  1147. $sendParams[]=array(
  1148. 'weekId'=>$weekId,
  1149. 'classId'=>$msg['class_id'],
  1150. 'studentIds'=>$params["studentIds"]
  1151. );
  1152. $this->updateEnreadingDownloadStatus($params['studentIds'], $weekId);
  1153. }
  1154. if($notFound == count($params_arr)){
  1155. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  1156. }
  1157. $printData['params']=$sendParams;
  1158. $printData['separate']=$separate;
  1159. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1160. }
  1161. /**
  1162. * 下载词汇宝
  1163. */
  1164. public function actionGetMagicWordFile()
  1165. {
  1166. $mwId = (string)Req::get("mw_id");
  1167. $studentsIds = Req::get("studentsIds");
  1168. $params = array();
  1169. if (!$mwId) {
  1170. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1171. exit();
  1172. }
  1173. $sql = "select class_id,grade,create_time,semester_id,name from english_magic_word where mw_id = '{$mwId}'";
  1174. $msg = $this->sConn->createCommand($sql)->queryRow();
  1175. //*****获取生成的学生***//
  1176. $productDownload = new ProductDownload($msg['grade']==3?ProductDownload::PRODUCT_TYPE_EN_MAGIC_WORD:ProductDownload::PRODUCT_TYPE_EN_INTEREST_WORD);
  1177. $generateStu = $productDownload->getGenerateStu('english_magic_word_student', 'mw_id', 'week_pdf_path', 'is_week_pdf', $mwId, $studentsIds);
  1178. if(!$generateStu){
  1179. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  1180. }
  1181. $params['studentIds'] = $generateStu['studentIds'];
  1182. $separate=0;
  1183. if($generateStu['pathArr']){
  1184. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  1185. if(count($checkTopicAnswer)>1){
  1186. $separate=count($checkTopicAnswer);
  1187. }
  1188. }
  1189. $Sem = new SSemester();
  1190. $code = $Sem->conn->createQuery()
  1191. ->from('semester')
  1192. ->where("semester_id = '" . $msg['semester_id'] . "'")
  1193. ->limit(1)
  1194. ->query()
  1195. ->read();
  1196. $intarr = array(
  1197. "schoolId" => $this->schoolId,
  1198. "clazzId" => $msg['class_id'],
  1199. "semester" => $code['refer_code'],
  1200. "grade" => $msg['grade'],
  1201. "students" => $studentsIds,
  1202. "examTime" => $msg['create_time'],
  1203. "classify" => 11,
  1204. "subject" => 8
  1205. );
  1206. //************ Step-1 判断是否有订单 *************//
  1207. if (Yii::app()->params["limit_open"]) {
  1208. if (Yii::app()->params["limit_open"]) {
  1209. $params["studentIds"] = $productDownload->getCanDownloadStu($params['studentIds'], $intarr, $this->schoolId);
  1210. }
  1211. }
  1212. $this->updateMagicWordDownloadStatus($params['studentIds'],$mwId);
  1213. $printData=array();
  1214. $printData['typeId']=12;
  1215. $sendParams[]=array(
  1216. 'mwId'=>$mwId,
  1217. 'classId'=>$msg['class_id'],
  1218. 'studentIds'=>$params["studentIds"]
  1219. );
  1220. $printData['params']=$sendParams;
  1221. $printData['separate']=$separate;
  1222. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1223. }
  1224. /**
  1225. * 批量词汇宝下载
  1226. */
  1227. public function actionBatchMagicWord()
  1228. {
  1229. $json_params = file_get_contents('php://input');
  1230. $params_arr = json_decode($json_params, true);
  1231. $notFound = 0;
  1232. $printData=array();
  1233. $printData['typeId']=12;
  1234. $sendParams=array();
  1235. $separate=0;
  1236. foreach ($params_arr as $param) {
  1237. $weekId = isset($param['mw_id']) ? (string)$param['mw_id'] : null;
  1238. $params = array();
  1239. if (!$weekId) {
  1240. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1241. exit();
  1242. }
  1243. //*****获取生成的学生***//
  1244. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_EN_MAGIC_WORD);
  1245. $generateStu = $productDownload->getGenerateStu('english_magic_word_student', 'mw_id', 'week_pdf_path', 'is_week_pdf', $weekId, array());
  1246. if(!$generateStu){
  1247. $notFound++;
  1248. continue;
  1249. }
  1250. $params['studentIds'] = $generateStu['studentIds'];
  1251. if($generateStu['pathArr'] && $separate==0){
  1252. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  1253. if(count($checkTopicAnswer)>1){
  1254. $separate=1;
  1255. }
  1256. }
  1257. $sql = "select class_id,grade,create_time,semester_id,name from english_magic_word where mw_id = '{$weekId}'";
  1258. $msg = $this->sConn->createCommand($sql)->queryRow();
  1259. $params['schoolId'] = $this->schoolId;
  1260. $params['type'] = 6;
  1261. $params['mwId'] = $weekId;
  1262. $sendParams[]=array(
  1263. 'mwId'=>$weekId,
  1264. 'classId'=>$msg['class_id'],
  1265. 'studentIds'=>$params["studentIds"]
  1266. );
  1267. $this->updateMagicWordDownloadStatus($params['studentIds'], $weekId);
  1268. }
  1269. if($notFound == count($params_arr)){
  1270. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  1271. }
  1272. $printData['params']=$sendParams;
  1273. $printData['separate']=$separate;
  1274. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1275. }
  1276. /**
  1277. * 下载写作宝
  1278. */
  1279. public function actionGetWritingFile()
  1280. {
  1281. $ewId = (string)Req::get("ew_id");
  1282. $studentsIds = Req::get("studentsIds");
  1283. $classDownload = $studentsIds ? false : true;
  1284. $params = array();
  1285. if (!$ewId) {
  1286. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1287. exit();
  1288. }
  1289. $sql = "select class_id,grade,create_time,semester_id,name from english_writing where ew_id = '{$ewId}'";
  1290. $msg = $this->sConn->createCommand($sql)->queryRow();
  1291. //*****获取生成的学生***//
  1292. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_WRITING);
  1293. $generateStu = $productDownload->getGenerateStu('english_writing_student', 'ew_id', 'week_pdf_path', 'is_week_pdf', $ewId, $studentsIds);
  1294. if(!$generateStu){
  1295. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  1296. }
  1297. $params['studentIds'] = $generateStu['studentIds'];
  1298. $separate=0;
  1299. if($generateStu['pathArr']){
  1300. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  1301. if(count($checkTopicAnswer)>1){
  1302. $separate=1;
  1303. }
  1304. }
  1305. $Sem = new SSemester();
  1306. $code = $Sem->conn->createQuery()
  1307. ->from('semester')
  1308. ->where("semester_id = '" . $msg['semester_id'] . "'")
  1309. ->limit(1)
  1310. ->query()
  1311. ->read();
  1312. $intarr = array(
  1313. "schoolId" => $this->schoolId,
  1314. "clazzId" => $msg['class_id'],
  1315. "semester" => $code['refer_code'],
  1316. "grade" => $msg['grade'],
  1317. "students" => $studentsIds,
  1318. "examTime" => $msg['create_time'],
  1319. "classify" => 32,
  1320. "subject" => 8
  1321. );
  1322. //************ Step-1 判断是否有订单 *************//
  1323. if (Yii::app()->params["limit_open"]) {
  1324. if (Yii::app()->params["limit_open"]) {
  1325. $params["studentIds"] = $productDownload->getCanDownloadStu($params['studentIds'], $intarr, $this->schoolId);
  1326. }
  1327. }
  1328. $this->updateWritingDownloadStatus($params['studentIds'],$ewId);
  1329. $printData=array();
  1330. $printData['typeId']=13;
  1331. $sendParams[]=array(
  1332. 'ewId'=>$ewId,
  1333. 'classId'=>$msg['class_id'],
  1334. 'studentIds'=>$params["studentIds"]
  1335. );
  1336. $printData['params']=$sendParams;
  1337. $printData['separate']=$separate;
  1338. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1339. }
  1340. /**
  1341. * 批量写作宝下载
  1342. */
  1343. public function actionBatchWriting()
  1344. {
  1345. $json_params = file_get_contents('php://input');
  1346. $params_arr = json_decode($json_params, true);
  1347. $notFound = 0;
  1348. $printData=array();
  1349. $printData['typeId']=13;
  1350. $sendParams=array();
  1351. $separate=0;
  1352. foreach ($params_arr as $param) {
  1353. $weekId = isset($param['ew_id']) ? (string)$param['ew_id'] : null;
  1354. $params = array();
  1355. if (!$weekId) {
  1356. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1357. exit();
  1358. }
  1359. //*****获取生成的学生***//
  1360. $productDownload = new ProductDownload(ProductDownload::PRODUCT_TYPE_WRITING);
  1361. $generateStu = $productDownload->getGenerateStu('english_writing_student', 'ew_id', 'week_pdf_path', 'is_week_pdf', $weekId, array());
  1362. if(!$generateStu){
  1363. $notFound++;
  1364. continue;
  1365. }
  1366. $params['studentIds'] = $generateStu['studentIds'];
  1367. if($generateStu['pathArr'] && $separate==0){
  1368. $checkTopicAnswer=explode(',',$generateStu['pathArr'][0]);
  1369. if(count($checkTopicAnswer)>1){
  1370. $separate=1;
  1371. }
  1372. }
  1373. $sql = "select class_id,grade,create_time,semester_id,name from english_writing where ew_id = '{$weekId}'";
  1374. $msg = $this->sConn->createCommand($sql)->queryRow();
  1375. $params['schoolId'] = $this->schoolId;
  1376. $params['type'] = 7;
  1377. $params['ewId'] = $weekId;
  1378. $sendParams[]=array(
  1379. 'ewId'=>$weekId,
  1380. 'classId'=>$msg['class_id'],
  1381. 'studentIds'=>$params["studentIds"]
  1382. );
  1383. $this->updateWritingDownloadStatus($params['studentIds'], $weekId);
  1384. }
  1385. if($notFound == count($params_arr)){
  1386. echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit();
  1387. }
  1388. $printData['params']=$sendParams;
  1389. $printData['separate']=$separate;
  1390. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1391. }
  1392. //打印在线答题卡
  1393. public function actionGetOnlinePdf(){
  1394. $examGroupId = (string)Req::post("examGroupId");
  1395. if(!$examGroupId ){
  1396. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1397. exit;
  1398. }
  1399. $printData=array();
  1400. $sql = "select class_id,exam_id from exam where exam_group_id = '{$examGroupId}'";
  1401. $msg = $this->sConn->createCommand($sql)->queryAll();
  1402. $printData['typeId']=14;
  1403. $examIds=array();
  1404. $classIds=array();
  1405. if($msg){
  1406. foreach ($msg as $item){
  1407. $examIds[]=$item['exam_id'];
  1408. $classIds[]=$item['class_id'];
  1409. }
  1410. }
  1411. $printData['params']['examIds']=$examIds;
  1412. $printData['params']['classIds']=$classIds;
  1413. $printData['separate']=0;
  1414. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1415. }
  1416. /**
  1417. * 下载词汇宝检测卡
  1418. */
  1419. public function actionGetMagicWordCard()
  1420. {
  1421. $mwId = (string)Req::get("mw_id");
  1422. $params = array();
  1423. if (!$mwId) {
  1424. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1425. exit();
  1426. }
  1427. $sql = "select student_id from english_magic_word_student where mw_id = '{$mwId}' and is_card_pdf = 1";
  1428. $stuArr = $this->getDbConnection()->createCommand($sql)->queryAll();
  1429. if ($stuArr) {
  1430. foreach ($stuArr as $k => $v) {
  1431. $params['studentIds'][] = $v['student_id'];
  1432. }
  1433. }else{
  1434. echo json_encode(array("success" => 0, "message" => "未找到生成的检测卡"));
  1435. exit();
  1436. }
  1437. $sql = "select class_id from english_magic_word where mw_id = '{$mwId}'";
  1438. $magicWord = $this->getDbConnection()->createCommand($sql)->queryRow();
  1439. $printData=array();
  1440. $printData['typeId']=16;
  1441. $sendParams[]=array(
  1442. 'mwId'=>$mwId,
  1443. 'classId'=>$magicWord['class_id'],
  1444. 'studentIds'=>$params["studentIds"]
  1445. );
  1446. $printData['params']=$sendParams;
  1447. $printData['separate']=0;
  1448. $this->updateMagicWordAfterDownloadStatus($params['studentIds'],$mwId);
  1449. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1450. }
  1451. /**
  1452. * 下载写作宝检测卡
  1453. */
  1454. public function actionGetWritingCard()
  1455. {
  1456. $ewId = (string)Req::get("ew_id");
  1457. $params = array();
  1458. if (!$ewId) {
  1459. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1460. exit();
  1461. }
  1462. $sql = "select student_id,card_pdf_path from english_writing_student where ew_id = '{$ewId}' and is_card_pdf = 1";
  1463. $stuArr = $this->getDbConnection()->createCommand($sql)->queryAll();
  1464. if ($stuArr) {
  1465. foreach ($stuArr as $k => $v) {
  1466. $params['studentIds'][] = $v['student_id'];
  1467. }
  1468. }else{
  1469. echo json_encode(array("success" => 0, "message" => "未找到生成的检测卡"));
  1470. exit();
  1471. }
  1472. $sql = "select class_id from english_writing where ew_id = '{$ewId}' ";
  1473. $set = $this->getDbConnection()->createCommand($sql)->queryRow();
  1474. $time=time();
  1475. $sql = "update english_writing_student set is_card_download = 1,card_download_time={$time} where ew_id = '{$ewId}' and student_id in (" . implode(',', $params['studentIds']) . ")";
  1476. $this->sConn->createCommand($sql)->execute();
  1477. $printData=array();
  1478. $printData['typeId']=17;
  1479. $sendParams[]=array(
  1480. 'ewId'=>$ewId,
  1481. 'classId'=>$set['class_id'],
  1482. 'studentIds'=>$params["studentIds"]
  1483. );
  1484. $printData['params']=$sendParams;
  1485. $printData['separate']=0;
  1486. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1487. }
  1488. /**
  1489. * 判断写作宝批改后答题卡是否分离
  1490. */
  1491. public function actionGetWritingCardAnswer()
  1492. {
  1493. $ewId = (string)Req::get("ew_id");
  1494. if (!$ewId) {
  1495. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1496. exit();
  1497. }
  1498. $sql = "select student_id,card_pdf_path from english_writing_student where ew_id = '{$ewId}' and is_card_pdf = 1";
  1499. $stuArr = $this->getDbConnection()->createCommand($sql)->queryRow();
  1500. $separate=0;
  1501. if ($stuArr) {
  1502. if($stuArr['card_pdf_path']){
  1503. $checkTopicAnswer=explode(',',$stuArr['card_pdf_path']);
  1504. if(count($checkTopicAnswer)>1){
  1505. $separate=1;
  1506. }
  1507. }
  1508. }
  1509. echo json_encode(array("success" => 1, "message" => "success","data"=>$separate));exit();
  1510. }
  1511. /**
  1512. * 更新词汇宝批改后检测卡下载状态
  1513. * @param $studentsIds
  1514. * @param $weekId
  1515. */
  1516. private function updateMagicWordAfterDownloadStatus($studentsIds, $weekId)
  1517. {
  1518. $time = time();
  1519. $sql = "update english_magic_word_student set is_card_download = 1,card_download_time={$time} where mw_id = '{$weekId}' and student_id in (" . implode(',', $studentsIds) . ") and card_download_time = 0";
  1520. $this->sConn->createCommand($sql)->execute();
  1521. }
  1522. /**
  1523. * 更新写作宝下载状态
  1524. * @param $studentsIds
  1525. * @param $weekId
  1526. */
  1527. private function updateWritingDownloadStatus($studentsIds, $weekId)
  1528. {
  1529. $time = time();
  1530. $sql = "update english_writing_student set is_week_download = 1,week_download_time={$time} where ew_id = '{$weekId}' and student_id in (" . implode(',', $studentsIds) . ") and week_download_time = 0";
  1531. $this->sConn->createCommand($sql)->execute();
  1532. }
  1533. /**
  1534. * 更新词汇宝下载状态
  1535. * @param $studentsIds
  1536. * @param $weekId
  1537. */
  1538. private function updateMagicWordDownloadStatus($studentsIds, $weekId)
  1539. {
  1540. $time = time();
  1541. $sql = "update english_magic_word_student set is_week_download = 1,week_download_time={$time} where mw_id = '{$weekId}' and student_id in (" . implode(',', $studentsIds) . ") and week_download_time = 0";
  1542. $this->sConn->createCommand($sql)->execute();
  1543. }
  1544. /**
  1545. * 更新外刊下载状态
  1546. * @param $studentsIds
  1547. * @param $weekId
  1548. */
  1549. private function updateEnreadingDownloadStatus($studentsIds, $weekId)
  1550. {
  1551. $time = time();
  1552. $sql = "update english_reading_student set is_week_download = 1,week_download_time={$time} where week_id = '{$weekId}' and student_id in (" . implode(',', $studentsIds) . ") and week_download_time = 0";
  1553. $this->sConn->createCommand($sql)->execute();
  1554. }
  1555. /**
  1556. * 更新晨读词汇下载状态
  1557. * @param $studentsIds
  1558. * @param $weekId
  1559. */
  1560. private function updateEnMrvDownloadStatus($studentsIds, $weekId)
  1561. {
  1562. $time = time();
  1563. $sql = "update english_week_student set is_week_download = 1,week_download_time={$time} where week_id = '{$weekId}' and student_id in (" . implode(',', $studentsIds) . ")";
  1564. $this->sConn->createCommand($sql)->execute();
  1565. }
  1566. /**
  1567. * 更新阶段复习个性化学习宝下载状态
  1568. * @param $studentIds
  1569. * @param $type
  1570. */
  1571. private function updateSpDownloadStatus($studentIds, $type,$planId)
  1572. {
  1573. $criteria = new CDbCriteria();
  1574. $criteria->addInCondition('student_id', $studentIds);
  1575. $criteria->addCondition('type=:type');
  1576. $criteria->addCondition('plan_id=:pid');
  1577. $criteria->params[':type'] = $type;
  1578. $criteria->params[':pid'] = $planId;
  1579. SStudentProductModel::model()->updateAll(array('is_download' => 1, 'download_time' => time()), $criteria);
  1580. }
  1581. /**
  1582. * 更新二轮下载状态
  1583. * @param $studentsIds
  1584. * @param $mrId
  1585. */
  1586. private function updateSecondRunDownloadStatus($studentsIds, $mrId)
  1587. {
  1588. $time = time();
  1589. $sql = "update math_review_student set is_review_download = 1,review_download_time={$time} where mr_id = '{$mrId}' and student_id in (" . implode(',', $studentsIds) . ")";
  1590. $this->sConn->createCommand($sql)->execute();
  1591. }
  1592. /**
  1593. * 更新好题本下载状态
  1594. * @param $studentsIds
  1595. * @param $htbId
  1596. */
  1597. private function updateHtbDownloadStatus($studentsIds, $htbId)
  1598. {
  1599. $time = time();
  1600. $sql = "update math_htb_student set is_htb_download = 1,htb_download_time={$time} where htb_id = '{$htbId}' and student_id in (" . implode(',', $studentsIds) . ")";
  1601. $this->sConn->createCommand($sql)->execute();
  1602. }
  1603. /**
  1604. * 更新假期报告下载状态
  1605. * @param $studentsIds
  1606. * @param $reportId
  1607. */
  1608. private function updateHrpDownloadStatus($studentsIds, $reportId){
  1609. $time = time();
  1610. $sql = "update holiday_report_student set is_report_download = 1,report_download_time={$time} where report_id = '{$reportId}' and student_id in (" . implode(',', $studentsIds) . ") and report_download_time = 0";
  1611. $this->sConn->createCommand($sql)->execute();
  1612. }
  1613. /**
  1614. * 更新下载状态
  1615. * @param $studentsIds
  1616. * @param $examId
  1617. * @param $type
  1618. * @return mixed
  1619. */
  1620. private function updateDownloadStatus($studentsIds, $examId, $type)
  1621. {
  1622. $time = time();
  1623. $sql = "update exam_product_status set is_download = 1,download_time={$time} where `product_type`={$type} and exam_id = '{$examId}' and student_id in (" . implode(',', $studentsIds) . ")";
  1624. return $this->sConn->createCommand($sql)->execute();
  1625. }
  1626. /**
  1627. * 更新专题宝下载状态
  1628. * @param $studentsIds
  1629. * @param $gpId
  1630. * @param $type
  1631. */
  1632. private function updateDownloadStatusZtb($studentsIds, $gpId)
  1633. {
  1634. $time = time();
  1635. $sql = "update general_product_student set is_download = 1,download_time={$time} where gp_id = '{$gpId}' and student_id in (" . implode(',', $studentsIds) . ")";
  1636. $this->sConn->createCommand($sql)->execute();
  1637. }
  1638. /**
  1639. * 更新个性化学习宝下载状态
  1640. * @param array $studentIds
  1641. * @param $classId
  1642. * @param $examId
  1643. * @param $isDownloadColumn
  1644. * @param $downloadTimeCoulmn
  1645. * @return mixed
  1646. */
  1647. private function updateIspDownloadStatus($studentIds=array(), $classId, $examId, $isDownloadColumn, $downloadTimeCoulmn)
  1648. {
  1649. $criteria = new CDbCriteria();
  1650. if ($studentIds) {
  1651. $criteria->addInCondition('student_id', $studentIds);
  1652. } else {
  1653. $criteria->addCondition('(is_complete = :is_complete and is_feedback = :is_complete) or is_del = :is_complete ');
  1654. $criteria->params[':is_complete'] = 1;
  1655. $criteria->params[':is_feedback'] = 1;
  1656. $criteria->params[':is_del'] = 1;
  1657. }
  1658. $criteria->addCondition('class_id=:class_id');
  1659. $criteria->params[':class_id'] = $classId;
  1660. $criteria->addCondition('exam_id=:exam_id');
  1661. $criteria->addCondition("{$isDownloadColumn}=:is_download");
  1662. $criteria->params[':exam_id'] = $examId;
  1663. $criteria->params[':is_download'] = 0;
  1664. return SStudentPaperRelation::model()->updateAll(array($isDownloadColumn => 1, $downloadTimeCoulmn => time()), $criteria);
  1665. }
  1666. //个性化学习宝教学宝
  1667. public function actionGetTeacherPdf(){
  1668. $examId = safe_replace(Yii::app()->request->getQuery('examId'));
  1669. if(!$examId){
  1670. echo json_encode(array("success" => 0, "message" => "缺少参数"));
  1671. exit();
  1672. }
  1673. $printData=array();
  1674. $sql = "select e.name as exam_name,e.academicr_pdf_path,e.academicr_pdf_time,e.exam_group_id,e.class_id,e.subject_id from exam as e left join exam_group as eg on e.exam_group_id=eg.exam_group_id left join paper as p on p.exam_id=e.exam_id left join `class` as c on c.class_id=e.class_id where e.exam_id={$examId}";
  1675. $exam_info = $this->sConn->createCommand($sql)->queryRow();
  1676. if($exam_info['academicr_pdf_path']){
  1677. $printData['typeId']=18;
  1678. $printData['productType']=20003;
  1679. $printData['params']=array(
  1680. 'classIds'=>array($exam_info['class_id']),
  1681. 'url'=>$exam_info['academicr_pdf_path'],
  1682. 'name'=>$exam_info['exam_name'],
  1683. 'subjectId'=>$exam_info['subject_id'],
  1684. 'examGroupId'=>$exam_info['exam_group_id'],
  1685. );
  1686. }else{
  1687. echo json_encode(array("success" => 0, "message" => "文件未生成"));
  1688. exit();
  1689. }
  1690. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1691. }
  1692. //方法宝教师版
  1693. public function actionGetMethodPdfPrint(){
  1694. $examId = (string)Req::get("examId");
  1695. $productType = 31;
  1696. require_once('TeachingMethod.php');
  1697. $teachingPhysicsObj = new TeachingMethod($this);
  1698. $result = $teachingPhysicsObj->getTeachingPdf($this->schoolId, $examId, $productType, $this->subjectId, 0, 1);
  1699. if($result['pdf_url']){
  1700. $sql = "select class_id,exam_group_id from exam where exam_id = '{$examId}'";
  1701. $examInfo = $this->sConn->createCommand($sql)->queryRow();
  1702. $printData['typeId']=18;
  1703. $printData['productType']=20031;
  1704. $printData['params']=array(
  1705. 'classIds'=>array($examInfo['class_id']),
  1706. 'url'=>$result['pdf_url'],
  1707. 'name'=>$result['file_name'],
  1708. 'subjectId'=>$this->subjectId,
  1709. 'examGroupId'=>$examInfo['exam_group_id'],
  1710. );
  1711. }else{
  1712. echo json_encode(array("success" => 0, "message" => "文件未生成"));
  1713. exit();
  1714. }
  1715. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1716. }
  1717. //错题前十
  1718. public function actionGetCTQSPrint()
  1719. {
  1720. $exam_id = safe_replace(Yii::app()->request->getQuery('exam_id'));
  1721. $host = '';
  1722. $databases_data = BusinessDatabase::model()->find('school_id=:school_id', array(':school_id' => $this->schoolId));
  1723. if ($databases_data) {
  1724. $host = isset(Yii::app()->params['static_url'][$databases_data->group_id]) ? Yii::app()->params['static_url'][$databases_data->group_id] : Yii::app()->params['api_host'] . '/uploads/';
  1725. }
  1726. $exam_data = Exam::model()->find('exam_id=:exam_id', array(':exam_id' => $exam_id));
  1727. if ($exam_data) {
  1728. $filename = $exam_data->topwb_pdf_path;
  1729. $filenames = explode('/', $filename);
  1730. $filenames = array_reverse($filenames);
  1731. if (!filter_var(trim($filename), FILTER_VALIDATE_URL)) { //没有http
  1732. $filename = $host . '/' . $filename;
  1733. }
  1734. $printData['typeId'] = 18;
  1735. $printData['productType']=10005;
  1736. $printData['params'] = array(
  1737. 'classIds' => array($exam_data->class_id),
  1738. 'url' => $filename,
  1739. 'name' => $exam_data['name'],
  1740. 'subjectId' => $this->subjectId,
  1741. 'examGroupId' => $exam_data['exam_group_id'],
  1742. );
  1743. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1744. }
  1745. echo json_encode(array("success" => 0, "message" => "没有找到文件"));exit();
  1746. }
  1747. //英语周推教师版下载
  1748. public function actionCDCHTeacherPrint(){
  1749. set_time_limit(0);
  1750. $weekId = safe_replace(Yii::app()->request->getQuery('weekId'));
  1751. $sql = "select * from teacher_week_extend where week_id = '{$weekId}'";
  1752. $week_info = $this->sConn->createCommand($sql)->queryAll();
  1753. $teacher_extend_arr = array();
  1754. foreach($week_info as $info)
  1755. {
  1756. $content = $info['content'];
  1757. $content = json_decode($content,true);
  1758. $teacher_extend_arr[$info['type']] = $content;
  1759. }
  1760. $sql = "select grade,teacher_general_pdf_path,class_id,set_id from english_week where week_id = '{$weekId}'";
  1761. $week_info = $this->sConn->createCommand($sql)->queryRow();
  1762. $sql = "select class_id,semester_id,words_type,is_new_version from english_week_setting where id = '{$week_info['set_id']}'";
  1763. $week_setting_info = $this->sConn->createCommand($sql)->queryRow();
  1764. if($week_setting_info['is_new_version']){
  1765. $this->newEnTeacherWeek($weekId,$week_info);
  1766. exit;
  1767. }
  1768. $words_type = $week_setting_info['words_type'];
  1769. $sql = "select ps_id from product_class_relation where class_id={$week_setting_info['class_id']} and semester_id={$week_setting_info['semester_id']} and set_type=7 order by ps_id desc limit 1";
  1770. $arr = $this->sConn->createCommand($sql)->queryRow();
  1771. $product_setting = '';
  1772. if($arr){
  1773. $sql = "select custom_config from product_setting where ps_id={$arr['ps_id']}";
  1774. $product_setting = $this->sConn->createCommand($sql)->queryRow();
  1775. $product_setting = $product_setting ? $product_setting['custom_config'] : '';
  1776. }
  1777. $setting = array(
  1778. 'moduleName'=>'晨读词汇',
  1779. 'moduleType'=>'english_4',
  1780. 'setting'=>array(
  1781. 'vocabularySelfTest' =>array( //词汇自测
  1782. "coreVocabulary"=>array( //核心词汇开关
  1783. "onOff" =>1,
  1784. "vocabularyUse" =>1 //词汇运用
  1785. ),
  1786. "keyPhrases" =>1 //重点短语
  1787. ),
  1788. "focusOnGrammar" =>array(//语法聚焦
  1789. "singleSentenceGrammar" =>1, //单句语法填空
  1790. "grammaticalFillIn" =>1 //语法填空
  1791. ),
  1792. "writingTraining" =>array(//写作训练
  1793. "commentsOnGoodSentences" =>1, // 佳句点拨
  1794. "actualCombatDrill" =>1 //实战演练
  1795. ),
  1796. "extensiveReadingOfForeignJournals" =>array( //外刊泛读
  1797. "accumulationOfNewWords" =>1, //新词积累
  1798. "appreciationOfGoldenSentences" =>1, //金句赏析
  1799. "fullTextTranslation" =>1, //全文翻译
  1800. ),
  1801. )
  1802. );
  1803. $product_setting = $product_setting ? json_decode($product_setting, true) : $setting;
  1804. //$product_setting = $setting;
  1805. //核心词区分派生非派生
  1806. $single_words_derivative = array();
  1807. if(isset($teacher_extend_arr[1])){
  1808. foreach($teacher_extend_arr[1] as $k=>$v){
  1809. if(isset($v['is_derivative'])){
  1810. $single_words_derivative[$v['is_derivative']][] = $v;
  1811. }
  1812. }
  1813. }
  1814. $html_data = array(
  1815. 'cur_grade' => $week_info['grade'],
  1816. 'single_words' => isset($teacher_extend_arr[1]) ? $teacher_extend_arr[1] : array(),
  1817. 'phrase' => isset($teacher_extend_arr[2]) ? $teacher_extend_arr[2] : array(),
  1818. 'topic_type_six' => isset($teacher_extend_arr[4]) ? $teacher_extend_arr[4] : array(),
  1819. 'topic_type_nineteen'=> isset($teacher_extend_arr[3]) ? $teacher_extend_arr[3] : array(),
  1820. 'writing_training' => isset($teacher_extend_arr[5]) ? $teacher_extend_arr[5] : array(),
  1821. 'single_translation' => isset($teacher_extend_arr[6]) ? $teacher_extend_arr[6] : array(),
  1822. 'essayDetail' => isset($teacher_extend_arr[7]) ? $teacher_extend_arr[7] : array(),
  1823. 'word_single_translation' => isset($teacher_extend_arr[8]) ? $teacher_extend_arr[8] : array(), //词汇运用(单句翻译)
  1824. 'word_grammar_blank' => isset($teacher_extend_arr[9]) ? $teacher_extend_arr[9] : array(), //词汇运用(单句语法填空)
  1825. 'word_spelling' => isset($teacher_extend_arr[20]) ? $teacher_extend_arr[20] : array(), //词汇运用(单词拼写)
  1826. 'complete_sentence' => isset($teacher_extend_arr[21]) ? $teacher_extend_arr[21] : array(), //词汇运用(完成句子)
  1827. 'product_setting' => $product_setting['setting'],
  1828. 'words_type'=>$words_type,
  1829. 'single_words_derivative'=>$single_words_derivative
  1830. );
  1831. $classId = $week_info['class_id'];
  1832. $sql = "select class_name from class where class_id = '{$classId}'";
  1833. $classInfo = $this->sConn->createCommand($sql)->queryRow();
  1834. $className = $classInfo ? $classInfo['class_name'] : '';
  1835. if (empty($week_info['teacher_general_pdf_path'])) {
  1836. $sql = "select topic_id from teacher_week where week_id = '{$weekId}' order by topic_id desc";
  1837. $topic_info = $this->sConn->createCommand($sql)->queryAll();
  1838. if (empty($topic_info)) {
  1839. echo json_encode(array("success" => 0, "message" => "周推教师版尚未生成"));exit();
  1840. } else {
  1841. $html_name = 'english_week_teacher';
  1842. //$this->render("{$html_name}", $html_data);exit;
  1843. $html = $this->renderPartial("{$html_name}", $html_data,true);
  1844. unset($html_data);
  1845. $htmlpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/reading/'; //存放生成的HTML路径
  1846. $pdfpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/reading/' . $this->schoolId . "/"; //存放生成的PDF路径
  1847. $pdfurl = '/upload/tmpDir/reading/' . $this->schoolId . "/";
  1848. if (!is_dir($htmlpath)) {
  1849. if (!mkdir($htmlpath, 0777, true)) {
  1850. exit('Create directory fail: ' . $htmlpath);
  1851. }
  1852. }
  1853. if (!is_dir($pdfpath)) {
  1854. if (!mkdir($pdfpath, 0777, true)) {
  1855. exit('Create directory fail1: ' . $pdfpath);
  1856. }
  1857. }
  1858. $gradeRel = array(1=>"高一",2=>"高二",3=>"高三");
  1859. $grade = isset($gradeRel[$week_info['grade']]) ? $gradeRel[$week_info['grade']] : '';
  1860. $htmlpath .= $weekId . ".html";
  1861. $f = fopen($htmlpath, "w");
  1862. fwrite($f, $html);
  1863. fclose($f);
  1864. $htmlurl = '/upload/tmpDir/reading/' . $weekId . ".html"; //访问HTML的路径
  1865. $locale='en_US.UTF-8';
  1866. setlocale(LC_ALL,$locale);
  1867. putenv('LC_ALL='.$locale);
  1868. if (Yii::app()->basePath == 'D:\xampp\htdocs\zsy-as2-php\protected') {//本地的basePath
  1869. $htmlurl = " http://192.168.1.48:8077/upload/tmpDir/reading" . '/' . $weekId . '.html';
  1870. $pdffname = $weekId . ".pdf";
  1871. $pdfpath = $pdfpath . $pdffname;
  1872. $pdfurl = $pdfurl . $pdffname;
  1873. $commond = Yii::app()->params['phantomjs'] . " "
  1874. . Yii::app()->params['html2pdf'] . " "
  1875. . " {$htmlurl}"
  1876. . " {$pdfpath}"
  1877. . ' 176mm*250mm "'.$grade.'|||'.date('Y-m-d',time()).'"';
  1878. } else {
  1879. $htmlurl = "http://" . $_SERVER['SERVER_NAME'] . $htmlurl;
  1880. $pdffname = $weekId . ".pdf";
  1881. $pdfpath = $pdfpath . $pdffname;
  1882. $pdfurl = $pdfurl . $pdffname;
  1883. $commond = Yii::app()->params['phantomjs_server_en'] . " "
  1884. . Yii::app()->basePath . '/../js/html2pdf_en.js' . " "
  1885. . " {$htmlurl}"
  1886. . " {$pdfpath}"
  1887. . ' 176mm*250mm "'.$grade.' '.$className.'|||'.date('Y-m-d',time()).'"';
  1888. }
  1889. exec($commond, $res, $code);
  1890. if(isset($res[0])){
  1891. $isBool = false;
  1892. foreach ($res as $msg) {
  1893. if (strpos($msg, 'succeed') !== false) {
  1894. $isBool = true;
  1895. }
  1896. }
  1897. if ($isBool) {//命令返回成功
  1898. if (file_exists($pdfpath)) {
  1899. // $pdfurl=iconv("GBK", "UTF-8",$pdfurl);
  1900. $repdf = $weekId . ".pdf";
  1901. $rename = 'zsyas2/reading/' . $this->schoolId . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/' . uniqid() . '.' . $repdf;
  1902. $ucloud = new Qcloud();
  1903. $uploadInfo = $ucloud->putFile($rename, $pdfpath);
  1904. if ($uploadInfo['status'] == 0) {
  1905. $pdfurl = "http://" . $_SERVER['SERVER_NAME'] . $pdfurl;
  1906. $this->sConn->createCommand()->update("english_week", array("teacher_general_pdf_path" => $pdfurl), "week_id = '{$weekId}'");
  1907. $week_info['teacher_general_pdf_path'] = $pdfurl;
  1908. }else{
  1909. $pdfurl = $uploadInfo['url'];
  1910. $this->sConn->createCommand()->update("english_week", array("teacher_general_pdf_path" => $pdfurl), "week_id = '{$weekId}'");
  1911. $week_info['teacher_general_pdf_path'] = $pdfurl;
  1912. @unlink($pdfpath);
  1913. }
  1914. @unlink($htmlpath);
  1915. } else {
  1916. @unlink($htmlpath);
  1917. echo json_encode(array("success" => 0, "message" => "PDF文件未找到"));exit();
  1918. exit;
  1919. }
  1920. } else {
  1921. @unlink($htmlpath);
  1922. echo json_encode(array("success" => 0, "message" => "PDF创建失败"));exit();
  1923. exit;
  1924. }
  1925. } else {
  1926. echo json_encode(array("success" => 0, "message" => "PDF创建失败"));exit();
  1927. }
  1928. }
  1929. }
  1930. if($week_info['teacher_general_pdf_path']){
  1931. $fileName = $className.'_周推教师版';
  1932. $url = $week_info['teacher_general_pdf_path'];
  1933. $printData['typeId'] = 18;
  1934. $printData['productType']=30001;
  1935. $printData['params'] = array(
  1936. 'classIds' => array($week_info['class_id']),
  1937. 'url' => $url,
  1938. 'name' => $fileName,
  1939. 'subjectId' => $this->subjectId,
  1940. 'examGroupId' => $weekId,
  1941. );
  1942. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  1943. }else{
  1944. echo json_encode(array("success" => 0, "message" => "尚未生成PDF"));exit();
  1945. }
  1946. }
  1947. //外刊宝教师版
  1948. public function actionDownPdfWKBTeacherPrint(){
  1949. set_time_limit(0);
  1950. $gradeRel = array(1=>"高一",2=>"高二",3=>"高三");
  1951. $weekId = safe_replace(Yii::app()->request->getQuery('weekId'));
  1952. $sql = "select teacher_general_pdf_path,grade,is_new_version,reading_id,class_id from english_reading where week_id = '{$weekId}'";
  1953. $week_info = $this->sConn->createCommand($sql)->queryRow();
  1954. if (empty($week_info['teacher_general_pdf_path'])) {
  1955. if($week_info['is_new_version']){//新版本
  1956. $this->new_en_reading($weekId,$week_info);
  1957. exit;
  1958. }
  1959. $grade = isset($gradeRel[$week_info['grade']]) ? $gradeRel[$week_info['grade']] : '';
  1960. $sql = "select distinct topic_id from student_reading_topic where week_id = '{$weekId}' order by create_time asc";
  1961. $topic_info = $this->sConn->createCommand($sql)->queryAll();
  1962. if (empty($topic_info)) {
  1963. echo json_encode(array("success" => 0, "message" => "学生外刊宝尚未生成!"));
  1964. } else {
  1965. $push_topics = _array_column($topic_info, 'topic_id');
  1966. $_params = array('isFormat' => 1, 'isTird' => 1, 'isNewEnglish' => 1, 'isNoReplaceLable' => 1);
  1967. $topicDetails = $this->apiBrainPost('/topic/batchAll', array('topicIds' => $push_topics, 'subjectId' => $this->subjectId, 'params' => $_params), 25, true);
  1968. if (!$topicDetails) {
  1969. echo json_encode(array("success" => 1, "message" => "获取接口batchALL无数据!"));
  1970. exit();
  1971. } elseif (isset($topicDetails['status']) && $topicDetails['status'] == 0) {
  1972. echo json_encode(array("success" => 1, "message" => $topicDetails['error'][0]));
  1973. exit();
  1974. } else {
  1975. foreach($topicDetails as $node=>$td){
  1976. if (isset($td['slave'])) {
  1977. $topicDetails[$node]['diff_str'] = $this->getLargeDifficulty($td['slave']);
  1978. }else {
  1979. $topicDetails[$node]['diff_str'] = '';
  1980. }
  1981. }
  1982. $data = array();
  1983. $data['all_topics'] = $push_topics;
  1984. $data['reading_detail'] = $topicDetails;
  1985. $html_name = 'en_reading';
  1986. $html = $this->renderPartial("{$html_name}", $data,true);
  1987. unset($data);
  1988. $htmlpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/reading/'; //存放生成的HTML路径
  1989. $pdfpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/reading/' . $this->schoolId . "/"; //存放生成的PDF路径
  1990. $pdfurl = '/upload/tmpDir/reading/' . $this->schoolId . "/";
  1991. if (!is_dir($htmlpath)) {
  1992. if (!mkdir($htmlpath, 0777, true)) {
  1993. exit('Create directory fail: ' . $htmlpath);
  1994. }
  1995. }
  1996. if (!is_dir($pdfpath)) {
  1997. if (!mkdir($pdfpath, 0777, true)) {
  1998. exit('Create directory fail1: ' . $pdfpath);
  1999. }
  2000. }
  2001. $htmlpath .= $weekId . ".html";
  2002. $f = fopen($htmlpath, "w");
  2003. fwrite($f, $html);
  2004. fclose($f);
  2005. $htmlurl = '/upload/tmpDir/reading/' . $weekId . ".html"; //访问HTML的路径
  2006. //防止exec 执行命令行导致中文乱码
  2007. $locale='en_US.UTF-8';
  2008. setlocale(LC_ALL,$locale);
  2009. putenv('LC_ALL='.$locale);
  2010. if (Yii::app()->basePath == "E:\wamp64\www\zsyas2\protected") {//本地的basePath
  2011. $htmlurl = " http://local.zsyas2teaching.com" . '/' . $weekId . '.html';
  2012. $pdffname = $weekId . ".pdf";
  2013. $pdfpath = $pdfpath . $pdffname;
  2014. $pdfurl = $pdfurl . $pdffname;
  2015. $commond = Yii::app()->params['phantomjs'] . " "
  2016. . Yii::app()->params['html2pdf'] . " "
  2017. . " {$htmlurl}"
  2018. . " {$pdfpath}"
  2019. . " 176mm*250mm '".$grade." || ".date('Y-m-d',time())."'";
  2020. } else {
  2021. $htmlurl = "http://" . $_SERVER['SERVER_NAME'] . $htmlurl;
  2022. $pdffname = $weekId . ".pdf";
  2023. $pdfpath = $pdfpath . $pdffname;
  2024. $pdfurl = $pdfurl . $pdffname;
  2025. $commond = Yii::app()->params['phantomjs_server_en'] . " "
  2026. . Yii::app()->basePath . '/../js/html2pdf_en.js' . " "
  2027. . " {$htmlurl}"
  2028. . " {$pdfpath}"
  2029. . ' 176mm*250mm "'.$grade.'|||'.date('Y-m-d',time()).'"';
  2030. }
  2031. exec($commond, $res, $code);
  2032. if(isset($res[0])){
  2033. $isBool = false;
  2034. foreach ($res as $msg) {
  2035. if (strpos($msg, 'succeed') !== false) {
  2036. $isBool = true;
  2037. }
  2038. }
  2039. if ($isBool) {//命令返回成功
  2040. if (file_exists($pdfpath)) {
  2041. // $pdfurl=iconv("GBK", "UTF-8",$pdfurl);
  2042. $repdf = $weekId . ".pdf";
  2043. $rename = 'zsyas2/reading/' . $this->schoolId . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/' . uniqid() . '.' . $repdf;
  2044. $ucloud = new Qcloud();
  2045. $uploadInfo = $ucloud->putFile($rename, $pdfpath);
  2046. if ($uploadInfo['status'] == 0) {
  2047. $pdfurl = "http://" . $_SERVER['SERVER_NAME'] . $pdfurl;
  2048. $this->sConn->createCommand()->update("english_reading", array("teacher_general_pdf_path" => $pdfurl), "week_id = '{$weekId}'");
  2049. $week_info['teacher_general_pdf_path'] = $pdfurl;
  2050. }else{
  2051. $pdfurl = $uploadInfo['url'];
  2052. $this->sConn->createCommand()->update("english_reading", array("teacher_general_pdf_path" => $pdfurl), "week_id = '{$weekId}'");
  2053. $week_info['teacher_general_pdf_path'] = $pdfurl;
  2054. @unlink($pdfpath);
  2055. }
  2056. @unlink($htmlpath);
  2057. } else {
  2058. @unlink($htmlpath);
  2059. echo json_encode(array("success" => 0, "message" => "PDF文件未找到"));exit();
  2060. exit;
  2061. }
  2062. } else {
  2063. @unlink($htmlpath);
  2064. echo json_encode(array("success" => 0, "message" => "PDF创建失败"));exit();
  2065. exit;
  2066. }
  2067. } else {
  2068. echo json_encode(array("success" => 0, "message" => "PDF创建失败"));exit();
  2069. exit;
  2070. }
  2071. }
  2072. }
  2073. }
  2074. if($week_info['teacher_general_pdf_path']){
  2075. $url = $week_info['teacher_general_pdf_path'];
  2076. $printData['typeId'] = 18;
  2077. $printData['productType']=20006;
  2078. $printData['params'] = array(
  2079. 'classIds' => array($week_info['class_id']),
  2080. 'url' => $url,
  2081. 'name' => '外刊宝教师版',
  2082. 'subjectId' => $this->subjectId,
  2083. 'examGroupId' => $weekId,
  2084. );
  2085. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  2086. }else{
  2087. echo json_encode(array("success" => 0, "message" => "尚未生成PDF"));exit();
  2088. }
  2089. }
  2090. //词汇宝教师版
  2091. public function actionDownPdfCHBTeacherPrint(){
  2092. set_time_limit(0);
  2093. $mwId = safe_replace(Yii::app()->request->getQuery('mwId'));
  2094. $sql = "select * from teacher_magic_word where mw_id = '{$mwId}'";
  2095. $week_info = $this->sConn->createCommand($sql)->queryAll();
  2096. $teacher_extend_arr = array();
  2097. foreach($week_info as $info)
  2098. {
  2099. $content = $info['content'];
  2100. $content = json_decode($content,true);
  2101. $teacher_extend_arr[$info['type']] = $content;
  2102. }
  2103. $sql = "select grade,mw_group_id,teacher_general_pdf_path,class_id,semester_id from english_magic_word where mw_id = '{$mwId}'";
  2104. $week_info = $this->sConn->createCommand($sql)->queryRow();
  2105. $sql = "select words_count,practice_type,translate_type,is_class_common,card_word_count,is_new_version from english_magic_word_setting where mw_group_id='{$week_info['mw_group_id']}'";
  2106. $week_setting_info = $this->sConn->createCommand($sql)->queryRow();
  2107. if($week_setting_info && $week_setting_info['practice_type'] == 2){ //1共性 2个性
  2108. echo json_encode(array("success" => 0, "message" => "学生个性化词汇宝无教师版"));exit();
  2109. }
  2110. $sql = "select ps_id from product_class_relation where class_id={$week_info['class_id']} and semester_id={$week_info['semester_id']} and set_type=8 order by ps_id desc limit 1";
  2111. $arr = $this->sConn->createCommand($sql)->queryRow();
  2112. $sql = $arr ? "select custom_config from product_setting where ps_id={$arr['ps_id']}" : "select custom_config from product_setting where product_type=8";
  2113. $product_setting = $this->sConn->createCommand($sql)->queryRow();
  2114. $product_setting = $product_setting ? $product_setting['custom_config'] : '';
  2115. $setting = array(
  2116. 'moduleName'=>'词汇宝',
  2117. 'moduleType'=>'english_5',
  2118. 'setting'=>array(
  2119. 'training' => array( //a-词汇集训
  2120. 'wordReview' => 1, //词汇回顾
  2121. 'wordExplain' => 1, // 词汇精讲
  2122. 'practiceExact' => array( // 精准训练
  2123. 'translate' => 1, //英汉互译
  2124. 'wordApply' => 1, //词汇运用
  2125. 'discourse' => 1, //语篇训练
  2126. ) //
  2127. ),
  2128. 'checkCard' => 1, //词汇集训检测卡
  2129. 'wrongPractice' => 1, //错词再练
  2130. 'wrongPracticeTimes' => 3, //第几次推送错词再练
  2131. )
  2132. );
  2133. $product_setting = $product_setting ? json_decode($product_setting, true) : $setting;
  2134. $sql = "select * from english_magic_word_student where mw_id = '{$mwId}'";
  2135. $h5_generate_time = $this->sConn->createCommand($sql)->queryRow();
  2136. $h5_generate_time = $h5_generate_time ? explode('-',date('Y-m-d',$h5_generate_time['week_html_time'])) : '';
  2137. $h5_year = $h5_generate_time ? $h5_generate_time[0] : 0;
  2138. $h5_month = $h5_generate_time ? $h5_generate_time[1] : 0;
  2139. $h5_day = $h5_generate_time ? $h5_generate_time[2] : 0;
  2140. // if(YII_ENV != 'production'){
  2141. // $h5_url = 'http://zsyapi.testing.xueping.com/uploads/magic_word/html/'.$this->schoolId.'/'.$h5_year.'/'.$h5_month.'/'.$h5_day.'/'.$mwId.'/h5/0.html';
  2142. // }else{
  2143. // $h5_url = Yii::app()->params['static_url'][$this->schoolGroupId].'/magic_word/html/'.$this->schoolId.'/'.$h5_year.'/'.$h5_month.'/'.$h5_day.'/'.$mwId.'/h5/0.html';
  2144. // }
  2145. if(!$week_setting_info['is_new_version']){
  2146. $h5_url = Yii::app()->params['static_url'][$this->schoolGroupId].'/magic_word/html/'.$this->schoolId.'/'.$h5_year.'/'.$h5_month.'/'.$h5_day.'/'.$mwId.'/0_h5.html';
  2147. }else{
  2148. $h5_url = Yii::app()->params['static_url'][$this->schoolGroupId].'/zxhx_exam_html/english/english_magic_word/'. date('Y-m-d') .'/'.$mwId.'/0_h5.html';
  2149. }
  2150. $h5_img = $this->qrcode64($h5_url);
  2151. $topic_type_ids = $topic_type_k_v = array();
  2152. if($week_setting_info['is_new_version']){
  2153. if(YII_ENV != 'production'){
  2154. //语篇训练
  2155. $topic_type_k_v = array('choice_cloze'=>554,'reading_comprehension'=>555,'sentence_cloze'=>556,'grammar_gap_filling'=>563);
  2156. $topic_type_ids = array(554=>'Choice Cloze (完形填空)', 555=>'Reading Comprehension (阅读理解)', 556=>'Sentence Cloze (七选五)', 563=>'Grammar Gap Filling (语法填空)');
  2157. }else{
  2158. //语篇训练
  2159. $topic_type_k_v = array('choice_cloze'=>41,'reading_comprehension'=>42,'sentence_cloze'=>44,'grammar_gap_filling'=>278);
  2160. $topic_type_ids = array(41=>'Choice Cloze (完形填空)', 42=>'Reading Comprehension (阅读理解)', 44=>'Sentence Cloze (七选五)', 278=>'Grammar Gap Filling (语法填空)');
  2161. }
  2162. //新版检测卡根据word_type归类
  2163. $check_card = array();
  2164. $check_card_detail = isset($teacher_extend_arr[8]) ? $teacher_extend_arr[8] : array();
  2165. if($check_card_detail){
  2166. foreach ($check_card_detail as $val){
  2167. $check_card[$val['word_type']][] = $val;
  2168. }
  2169. if(isset($check_card[1])){
  2170. for($i=0;$i<count($check_card[1]);$i+=2){
  2171. $_check_card[] = array_slice($check_card[1],$i,2);
  2172. }
  2173. $check_card[1] = $_check_card;
  2174. unset($_check_card);
  2175. }
  2176. }
  2177. }else{
  2178. $check_card = isset($teacher_extend_arr[8]) ? $teacher_extend_arr[8] : array();
  2179. }
  2180. $html_data = array(
  2181. 'cur_grade' => $week_info['grade'],
  2182. 'title' => isset($teacher_extend_arr[0]) ? $teacher_extend_arr[0] : array(),
  2183. 'word_review' => isset($teacher_extend_arr[1]) ? $teacher_extend_arr[1] : array(),
  2184. 'word_phase' => isset($teacher_extend_arr[2]) ? $teacher_extend_arr[2] : array(),
  2185. 'translates' => isset($teacher_extend_arr[3]) ? $teacher_extend_arr[3] : array(),
  2186. 'word_apply_ids' => isset($teacher_extend_arr[4]) ? $teacher_extend_arr[4] : array(),
  2187. 'word_apply_content'=> isset($teacher_extend_arr[5]) ? $teacher_extend_arr[5] : array(),
  2188. 'card_topic_ids' => isset($teacher_extend_arr[6]) ? current($teacher_extend_arr[6]) : array(),
  2189. 'card_topic_content' => isset($teacher_extend_arr[7]) ? $teacher_extend_arr[7] : array(),
  2190. 'check_card' => $check_card,
  2191. 'card_title' => isset($teacher_extend_arr[9]) ? $teacher_extend_arr[9] : (isset($teacher_extend_arr[0]) ? $teacher_extend_arr[0] : array()),
  2192. 'product_setting' => $product_setting['setting'],
  2193. 'setting' => $week_setting_info,
  2194. 'h5_image' =>$h5_img,
  2195. 'topic_type_ids' => $topic_type_ids,
  2196. 'topic_type_k_v' => $topic_type_k_v
  2197. );
  2198. if($week_setting_info['is_new_version']){
  2199. $cardPage = 0;
  2200. }else{
  2201. $cardPage = isset($teacher_extend_arr[8]) ? 2 : 0;
  2202. }
  2203. if (empty($week_info['teacher_general_pdf_path'])) {
  2204. $sql = "select mw_id from teacher_magic_word where mw_id = '{$mwId}' order by mw_id desc";
  2205. $topic_info = $this->sConn->createCommand($sql)->queryAll();
  2206. if (empty($topic_info)) {
  2207. echo json_encode(array("success" => 0, "message" => "词汇宝教师版尚未生成"));exit();
  2208. } else {
  2209. if(!$week_setting_info['is_new_version']){
  2210. $html_name = '../magic/english_magic_word_teacher';
  2211. }else{
  2212. $html_name = '../magic/english_magic_word_teacher_new';
  2213. }
  2214. // $this->render("{$html_name}", $html_data);exit;
  2215. $html = $this->renderPartial("{$html_name}", $html_data,true);
  2216. unset($html_data);
  2217. $htmlpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/reading/'; //存放生成的HTML路径
  2218. $pdfpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/reading/' . $this->schoolId . "/"; //存放生成的PDF路径
  2219. $pdfurl = '/upload/tmpDir/reading/' . $this->schoolId . "/";
  2220. if (!is_dir($htmlpath)) {
  2221. if (!mkdir($htmlpath, 0777, true)) {
  2222. exit('Create directory fail: ' . $htmlpath);
  2223. }
  2224. }
  2225. if (!is_dir($pdfpath)) {
  2226. if (!mkdir($pdfpath, 0777, true)) {
  2227. exit('Create directory fail1: ' . $pdfpath);
  2228. }
  2229. }
  2230. $gradeRel = array(1=>"高一",2=>"高二",3=>"高三");
  2231. $grade = isset($gradeRel[$week_info['grade']]) ? $gradeRel[$week_info['grade']] : '';
  2232. $classId = $week_info['class_id'];
  2233. $sql = "select class_name from class where class_id = '{$classId}'";
  2234. $classInfo = $this->sConn->createCommand($sql)->queryRow();
  2235. $className = $classInfo ? $classInfo['class_name'] : '';
  2236. $htmlpath .= $mwId . ".html";
  2237. $f = fopen($htmlpath, "w");
  2238. fwrite($f, $html);
  2239. fclose($f);
  2240. $htmlurl = '/upload/tmpDir/reading/' . $mwId . ".html"; //访问HTML的路径
  2241. $locale='en_US.UTF-8';
  2242. setlocale(LC_ALL,$locale);
  2243. putenv('LC_ALL='.$locale);
  2244. if (Yii::app()->basePath == 'D:\xampp\htdocs\zsy-as2-php\protected') {//本地的basePath
  2245. $htmlurl = " http://192.168.1.48:8077/upload/tmpDir/reading" . '/' . $mwId . '.html';
  2246. $pdffname = $mwId . ".pdf";
  2247. $pdfpath = $pdfpath . $pdffname;
  2248. $pdfurl = $pdfurl . $pdffname;
  2249. $commond = Yii::app()->params['phantomjs'] . " "
  2250. . Yii::app()->params['html2_card_pdf'] . " "
  2251. . " {$htmlurl}"
  2252. . " {$pdfpath}"
  2253. . ' 176mm*250mm "'.$grade.'|||'.date('Y-m-d',time()).'"';
  2254. } else {
  2255. $htmlurl = "http://" . $_SERVER['SERVER_NAME'] . $htmlurl;
  2256. $pdffname = $mwId . ".pdf";
  2257. $pdfpath = $pdfpath . $pdffname;
  2258. $pdfurl = $pdfurl . $pdffname;
  2259. $commond = Yii::app()->params['phantomjs_server'] . " "
  2260. . Yii::app()->basePath . '/../js/html2pdf_enCard.js' . " "
  2261. . " {$htmlurl}"
  2262. . " {$pdfpath}"
  2263. // . ' 176mm*250mm "'.date('Y-m-d',time()).'|||123456|||'.$grade.' '.$className.'|||'.$cardPage.'"';
  2264. . ' 176mm*250mm "'.$grade.'|||词汇宝|||'.date('Y-m-d',time()).'|||'.$grade.' '.$className.'|||'.$cardPage.'"';
  2265. }
  2266. // $stu_name . "|||" . (subtext($week_name, 30)) . "|||" .$product_name."|||". Params::$params['cur_subject_id']."|||".$card_page,
  2267. exec($commond, $res, $code);
  2268. if(isset($res[0])){
  2269. $isBool = false;
  2270. foreach ($res as $msg) {
  2271. if (strpos($msg, 'succeed') !== false) {
  2272. $isBool = true;
  2273. }
  2274. }
  2275. if ($isBool) {//命令返回成功
  2276. if (file_exists($pdfpath) && file_exists($htmlpath)) {
  2277. // $pdfurl=iconv("GBK", "UTF-8",$pdfurl);
  2278. $repdf = $mwId . ".pdf";
  2279. $rename = 'zsyas2/reading/' . $this->schoolId . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/' . uniqid() . '.' . $repdf;
  2280. $rehtml = $mwId . ".html";
  2281. $reHtmlName = 'zsyas2/reading/' . $this->schoolId . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/' . uniqid() . '.' . $rehtml;
  2282. $ucloud = new Qcloud();
  2283. $uploadInfo = $ucloud->putFile($rename, $pdfpath);
  2284. $uploadHtmlInfo = $ucloud->putFile($reHtmlName, $htmlpath);
  2285. if ($uploadInfo['status'] == 0 && $uploadHtmlInfo['status'] == 0) {
  2286. $pdfurl = "http://" . $_SERVER['SERVER_NAME'] . $pdfurl;
  2287. $htmlurl = "http://" . $_SERVER['SERVER_NAME'] . $htmlurl;
  2288. //echo $pdfurl;
  2289. $this->sConn->createCommand()->update("english_magic_word", array("teacher_general_pdf_path" => $pdfurl,"teacher_general_html_path" => $htmlurl), "mw_id = '{$mwId}'");
  2290. $week_info['teacher_general_pdf_path'] = $pdfurl;
  2291. }else{
  2292. $pdfurl = $uploadInfo['url'];
  2293. $htmlurl = $uploadHtmlInfo['url'];
  2294. //echo $pdfurl;
  2295. $this->sConn->createCommand()->update("english_magic_word", array("teacher_general_pdf_path" => $pdfurl,"teacher_general_html_path" => $htmlurl), "mw_id = '{$mwId}'");
  2296. $week_info['teacher_general_pdf_path'] = $pdfurl;
  2297. @unlink($pdfpath);
  2298. }
  2299. @unlink($htmlpath);
  2300. } else {
  2301. @unlink($htmlpath);
  2302. echo json_encode(array("success" => 0, "message" => "PDF文件未找到"));exit();
  2303. exit;
  2304. }
  2305. } else {
  2306. @unlink($htmlpath);
  2307. echo json_encode(array("success" => 0, "message" => "PDF创建失败"));exit();
  2308. exit;
  2309. }
  2310. } else {
  2311. echo json_encode(array("success" => 0, "message" => "PDF创建失败"));exit();
  2312. exit;
  2313. }
  2314. }
  2315. }
  2316. if($week_info['teacher_general_pdf_path']){
  2317. $url = $week_info['teacher_general_pdf_path'];
  2318. $printData['typeId'] = 18;
  2319. $printData['productType']=20011;
  2320. $printData['params'] = array(
  2321. 'classIds' => array($week_info['class_id']),
  2322. 'url' => $url,
  2323. 'name' => '词汇宝教师版',
  2324. 'subjectId' => $this->subjectId,
  2325. 'examGroupId' => $mwId,
  2326. );
  2327. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  2328. }else{
  2329. Yii::app()->jump->error('尚未生成PDF');
  2330. }
  2331. }
  2332. /**
  2333. * 新版英语外刊教师版
  2334. */
  2335. public function new_en_reading($weekId='',$week_info=array()){
  2336. $sql = "select product_type,basic_topic,hot_topic from english_reading_setting where reading_id='{$week_info['reading_id']}'";
  2337. $week_setting = $this->sConn->createCommand($sql)->queryRow();
  2338. $data = array();
  2339. $gradeRel = array(1=>"高一",2=>"高二",3=>"高三");
  2340. $class_name = '';
  2341. $grade = isset($gradeRel[$week_info['grade']]) ? $gradeRel[$week_info['grade']] : '';
  2342. $class_id = $week_info['class_id'];
  2343. $sql = "select class_id,class_name from class where class_id = '$class_id'";
  2344. $class_data = $this->sConn->createCommand($sql)->queryRow();
  2345. if($class_data){
  2346. $class_name = $class_data['class_name'];
  2347. }
  2348. if($week_setting){
  2349. if($week_setting['product_type'] == 1){//基础宝
  2350. $p_name="外刊-基础宝";
  2351. $html_name = 'en_jichu';
  2352. $basic_data = array();
  2353. $basic_topic = $week_setting['basic_topic'];//基础宝ID
  2354. if($basic_topic){
  2355. $basic_topic_arr = explode(",",$basic_topic);
  2356. $brain_data = $this->apiBrainPost('/all_library/englishBaseBaby', array('ids' => $basic_topic_arr), 25, true);
  2357. if($brain_data && isset($brain_data['data']) && $brain_data['data']){
  2358. foreach($brain_data['data'] as $k=>$v){
  2359. if(isset($v['jsb']) && $v['jsb']){
  2360. $basic_data = json_decode($v['jsb'],true);
  2361. }
  2362. }
  2363. }else{
  2364. echo json_encode(array("success" => 0, "message" => "基础宝教师版接口有误"));exit();
  2365. }
  2366. }else{
  2367. echo json_encode(array("success" => 0, "message" => "基础宝ID设置有误"));exit();
  2368. }
  2369. if(!$basic_data){
  2370. echo json_encode(array("success" => 0, "message" => "基础宝教师版没有数据"));exit();
  2371. }else{
  2372. $data['basic_data'] = $basic_data;
  2373. }
  2374. }else if($week_setting['product_type'] == 2){//外刊宝
  2375. $p_name="外刊-外刊宝";
  2376. $html_name = 'en_waikan';
  2377. $sql = "select topic_id from student_reading_topic where week_id='{$weekId}'";
  2378. $topic_data = $this->sConn->createCommand($sql)->queryAll();
  2379. if($topic_data){
  2380. $topic_ids = _array_column($topic_data, 'topic_id');
  2381. $topic_ids = array_unique($topic_ids);
  2382. $data['topic_ids'] = $topic_ids;
  2383. $topicDetails = $this->apiBrainPost('/topic/batchAll', array('topicIds' => $topic_ids), 25, true);
  2384. if (!$topicDetails) {
  2385. echo json_encode(array("success" => 0, "message" => "获取接口batchALL无数据"));exit();
  2386. } elseif (isset($topicDetails['status']) && $topicDetails['status'] == 0) {
  2387. echo json_encode(array("success" => 0, "message" => $topicDetails['error'][0]));exit();
  2388. } else {
  2389. $paper_topic_detail= array();
  2390. foreach($topicDetails as $k=>$v){
  2391. $paper_topic_detail[(string)$v['id']] = $v;
  2392. }
  2393. $new_topic_detail = $this->newTopicDetail($paper_topic_detail);
  2394. $data['topic_detail'] = $new_topic_detail;
  2395. }
  2396. }else{
  2397. echo json_encode(array("success" => 0, "message" => "学生外刊没生成"));exit();
  2398. }
  2399. }else{//热点宝
  2400. $p_name="外刊-热点宝";
  2401. $html_name = 'en_hot';
  2402. $hot_topic = $week_setting['hot_topic'];//热点宝ID
  2403. $redian_topic_ids = array();
  2404. if($hot_topic){
  2405. $hot_topic_arr = explode(",",$hot_topic);
  2406. $brain_data = $this->apiBrainPost('/all_library/englishHotBaby', array('ids' => $hot_topic_arr), 25, true);
  2407. if($brain_data && isset($brain_data['data']) && $brain_data['data']){
  2408. foreach($brain_data['data'] as $k=>$v){
  2409. if(isset($v['xxtlsy']) && $v['xxtlsy']){
  2410. $redian_topic_ids = array_merge($redian_topic_ids,$v['xxtlsy']);
  2411. }
  2412. if(isset($v['ljfxsy']) && $v['ljfxsy']){
  2413. $redian_topic_ids = array_merge($redian_topic_ids,$v['ljfxsy']);
  2414. }
  2415. if(isset($v['sbsy']) && $v['sbsy']){
  2416. $redian_topic_ids = array_merge($redian_topic_ids,$v['sbsy']);
  2417. }
  2418. if(isset($v['yychhy']) && $v['yychhy']){
  2419. $redian_topic_ids = array_merge($redian_topic_ids,$v['yychhy']);
  2420. }
  2421. if(isset($v['yyjjfx']) && $v['yyjjfx']){
  2422. $redian_topic_ids = array_merge($redian_topic_ids,$v['yyjjfx']);
  2423. }
  2424. if(isset($v['zhyysy']) && $v['zhyysy']){
  2425. $redian_topic_ids = array_merge($redian_topic_ids,$v['zhyysy']);
  2426. }
  2427. }
  2428. $data['hot_data'] = $brain_data['data'][0];
  2429. }else{
  2430. echo json_encode(array("success" => 0, "message" => "热点宝教师版接口有误"));exit();
  2431. }
  2432. }else{
  2433. echo json_encode(array("success" => 0, "message" => "热点宝ID设置有误"));exit();
  2434. }
  2435. $sql = "select topic_id from student_reading_topic where week_id='{$weekId}'";
  2436. $topic_data = $this->sConn->createCommand($sql)->queryAll();
  2437. if($topic_data){
  2438. $topic_ids_0 = _array_column($topic_data, 'topic_id');
  2439. $topic_ids_0 = array_unique($topic_ids_0);
  2440. $topic_ids = array_merge($topic_ids_0,$redian_topic_ids);
  2441. $data['topic_ids'] = $topic_ids_0;
  2442. $topicDetails = $this->apiBrainPost('/topic/batchAll', array('topicIds' => $topic_ids), 25, true);
  2443. if (!$topicDetails) {
  2444. echo json_encode(array("success" => 0, "message" => "获取接口batchALL无数据"));exit();
  2445. } elseif (isset($topicDetails['status']) && $topicDetails['status'] == 0) {
  2446. echo json_encode(array("success" => 0, "message" => "topicDetails['error'][0]"));exit();
  2447. } else {
  2448. $paper_topic_detail= array();
  2449. foreach($topicDetails as $k=>$v){
  2450. $paper_topic_detail[(string)$v['id']] = $v;
  2451. }
  2452. $new_topic_detail = $this->newTopicDetail($paper_topic_detail);
  2453. $data['topic_detail'] = $new_topic_detail;
  2454. }
  2455. }else{
  2456. echo json_encode(array("success" => 0, "message" => "学生外刊没生成"));exit();
  2457. }
  2458. }
  2459. //开始生成html
  2460. $data['type_config'] =array('gestalt'=>713,'reading'=>714,'seven_selected_five'=>array(715,432));
  2461. $html = $this->renderPartial("{$html_name}", $data,true);
  2462. unset($data);
  2463. $htmlpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/reading/'; //存放生成的HTML路径
  2464. $pdfpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/reading/' . $this->schoolId . "/"; //存放生成的PDF路径
  2465. $pdfurl = '/upload/tmpDir/reading/' . $this->schoolId . "/";
  2466. if (!is_dir($htmlpath)) {
  2467. if (!mkdir($htmlpath, 0777, true)) {
  2468. Yii::app()->jump->error('Create directory fail: ' . $htmlpath);
  2469. }
  2470. }
  2471. if (!is_dir($pdfpath)) {
  2472. if (!mkdir($pdfpath, 0777, true)) {
  2473. Yii::app()->jump->error('Create directory fail: ' . $pdfpath);
  2474. }
  2475. }
  2476. $htmlpath .= $weekId . ".html";
  2477. $f = fopen($htmlpath, "w");
  2478. fwrite($f, $html);
  2479. fclose($f);
  2480. $htmlurl = '/upload/tmpDir/reading/' . $weekId . ".html"; //访问HTML的路径
  2481. //防止exec 执行命令行导致中文乱码
  2482. $locale='en_US.UTF-8';
  2483. setlocale(LC_ALL,$locale);
  2484. putenv('LC_ALL='.$locale);
  2485. if (Yii::app()->basePath == "E:\wamp64\www\zsyas2\protected") {//本地的basePath
  2486. $htmlurl = " http://local.zsyas2teaching.com" . '/' . $weekId . '.html';
  2487. $pdffname = $weekId . ".pdf";
  2488. $pdfpath = $pdfpath . $pdffname;
  2489. $pdfurl = $pdfurl . $pdffname;
  2490. $commond = Yii::app()->params['phantomjs'] . " "
  2491. . Yii::app()->params['html2pdf'] . " "
  2492. . " {$htmlurl}"
  2493. . " {$pdfpath}"
  2494. . " 176mm*250mm '".$grade." || ".date('Y-m-d',time())."'";
  2495. } else {
  2496. $htmlurl = "http://" . $_SERVER['SERVER_NAME'] . $htmlurl;
  2497. $pdffname = $weekId . ".pdf";
  2498. $pdfpath = $pdfpath . $pdffname;
  2499. $pdfurl = $pdfurl . $pdffname;
  2500. $commond = Yii::app()->params['phantomjs_server_en'] . " "
  2501. . Yii::app()->basePath . '/../js/html2pdf_en.js' . " "
  2502. . " {$htmlurl}"
  2503. . " {$pdfpath}"
  2504. . ' 176mm*250mm "'.$class_name.'|||'.'时间:'.date('Y-m-d',time()).' '.$p_name.'"';
  2505. }
  2506. exec($commond, $res, $code);
  2507. if(isset($res[0])){
  2508. $isBool = false;
  2509. foreach ($res as $msg) {
  2510. if (strpos($msg, 'succeed') !== false) {
  2511. $isBool = true;
  2512. }
  2513. }
  2514. if ($isBool) {//命令返回成功
  2515. if (file_exists($pdfpath)) {
  2516. // $pdfurl=iconv("GBK", "UTF-8",$pdfurl);
  2517. $repdf = $weekId . ".pdf";
  2518. $rename = 'zsyas2/reading/' . $this->schoolId . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/' . uniqid() . '.' . $repdf;
  2519. $ucloud = new Qcloud();
  2520. $uploadInfo = $ucloud->putFile($rename, $pdfpath);
  2521. //上传html
  2522. $rehtml = $weekId.".html";
  2523. $rename = 'zsyas2/reading/' . $this->schoolId . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/' . uniqid() . '.' . $rehtml;
  2524. $uploadHtmlInfo = $ucloud->putFile($rename, $htmlpath);
  2525. if($uploadHtmlInfo['status'] == 0){
  2526. $html_url = "http://" . $_SERVER['SERVER_NAME'].$htmlurl;
  2527. }else{
  2528. $html_url = $uploadHtmlInfo['url'];
  2529. }
  2530. if ($uploadInfo['status'] == 0) {
  2531. $pdfurl = "http://" . $_SERVER['SERVER_NAME'] . $pdfurl;
  2532. $this->sConn->createCommand()->update("english_reading", array("teacher_general_pdf_path" => $pdfurl,"teacher_general_html_path"=>$html_url), "week_id = '{$weekId}'");
  2533. $week_info['teacher_general_pdf_path'] = $pdfurl;
  2534. }else{
  2535. $pdfurl = $uploadInfo['url'];
  2536. $this->sConn->createCommand()->update("english_reading", array("teacher_general_pdf_path" => $pdfurl,"teacher_general_html_path"=>$html_url), "week_id = '{$weekId}'");
  2537. $week_info['teacher_general_pdf_path'] = $pdfurl;
  2538. @unlink($pdfpath);
  2539. }
  2540. @unlink($htmlpath);
  2541. } else {
  2542. @unlink($htmlpath);
  2543. echo json_encode(array("success" => 0, "message" => "PDF文件未找到"));exit();
  2544. }
  2545. } else {
  2546. @unlink($htmlpath);
  2547. echo json_encode(array("success" => 0, "message" => "PDF创建失败"));exit();
  2548. }
  2549. } else {
  2550. echo json_encode(array("success" => 0, "message" => "PDF创建失败11"));exit();
  2551. }
  2552. }else{
  2553. echo json_encode(array("success" => 0, "message" => "外刊宝设置信息有误"));exit();
  2554. }
  2555. if($week_info['teacher_general_pdf_path']){
  2556. $url = $week_info['teacher_general_pdf_path'];
  2557. $printData['typeId'] = 18;
  2558. $printData['productType']=20006;
  2559. $printData['params'] = array(
  2560. 'classIds' => array($week_info['class_id']),
  2561. 'url' => $url,
  2562. 'name' => '外刊宝教师版',
  2563. 'subjectId' => $this->subjectId,
  2564. 'examGroupId' => $weekId,
  2565. );
  2566. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  2567. }else{
  2568. echo json_encode(array("success" => 0, "message" => "尚未生成PDF"));exit();
  2569. }
  2570. }
  2571. //写作宝教师版
  2572. public function actionDownPdfXZBTeacherPrint(){
  2573. set_time_limit(0);
  2574. $ewId = safe_replace(Yii::app()->request->getQuery('mwId'));
  2575. $sql = "select * from teacher_writing where ew_id = '{$ewId}'";
  2576. $week_info = $this->sConn->createCommand($sql)->queryAll();
  2577. $teacher_extend_arr = array();
  2578. foreach($week_info as $info)
  2579. {
  2580. $content = stripslashes($info['content']);
  2581. $content = substr($content,1,-1);
  2582. $content = json_decode($content,true);
  2583. $teacher_extend_arr[$info['type']] = $content;
  2584. }
  2585. $sql = "select grade,ew_group_id,teacher_general_pdf_path,class_id,semester_id from english_writing where ew_id = '{$ewId}'";
  2586. $week_info = $this->sConn->createCommand($sql)->queryRow();
  2587. $sql = "select * from english_writing_student where ew_id = '{$ewId}'";
  2588. $h5_generate_time = $this->sConn->createCommand($sql)->queryRow();
  2589. $h5_generate_time = $h5_generate_time ? explode('-',date('Y-m-d',$h5_generate_time['week_html_time'])) : '';
  2590. $h5_year = $h5_generate_time ? $h5_generate_time[0] : 0;
  2591. $h5_month = $h5_generate_time ? $h5_generate_time[1] : 0;
  2592. $h5_day = $h5_generate_time ? $h5_generate_time[2] : 0;
  2593. $html_data = array(
  2594. 'cur_grade' => $week_info['grade'],
  2595. 'writing' => isset($teacher_extend_arr[0]) ? $teacher_extend_arr[0] : array(),
  2596. 'third' => isset($teacher_extend_arr[1]) ? $teacher_extend_arr[1] : array(),
  2597. );
  2598. $taskName = (isset($teacher_extend_arr[0]['task_name'])) ? ($teacher_extend_arr[0]['task_name']) : (isset($teacher_extend_arr[1]['task_name']) ? $teacher_extend_arr[1]['task_name'] : '');
  2599. //debug($html_data);
  2600. $cardPage = isset($teacher_extend_arr[8]) ? 2 : 0;
  2601. if (empty($week_info['teacher_general_pdf_path'])) {
  2602. $sql = "select ew_id from teacher_writing where ew_id = '{$ewId}' order by ew_id desc";
  2603. $topic_info = $this->sConn->createCommand($sql)->queryAll();
  2604. if (empty($topic_info)) {
  2605. echo json_encode(array("success" => 0, "message" => "写作宝教师版尚未生成"));exit();
  2606. } else {
  2607. $html_name = '../writing/english_writing_teacher';
  2608. //$this->render("{$html_name}", $html_data);exit;
  2609. $html = $this->renderPartial("{$html_name}", $html_data,true);
  2610. unset($html_data);
  2611. $htmlpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/reading/'; //存放生成的HTML路径
  2612. $pdfpath = str_replace("protected", "", Yii::app()->basePath) . '/upload/tmpDir/reading/' . $this->schoolId . "/"; //存放生成的PDF路径
  2613. $pdfurl = '/upload/tmpDir/reading/' . $this->schoolId . "/";
  2614. if (!is_dir($htmlpath)) {
  2615. if (!mkdir($htmlpath, 0777, true)) {
  2616. exit('Create directory fail: ' . $htmlpath);
  2617. }
  2618. }
  2619. if (!is_dir($pdfpath)) {
  2620. if (!mkdir($pdfpath, 0777, true)) {
  2621. exit('Create directory fail1: ' . $pdfpath);
  2622. }
  2623. }
  2624. $gradeRel = array(1=>"高一",2=>"高二",3=>"高三");
  2625. $grade = isset($gradeRel[$week_info['grade']]) ? $gradeRel[$week_info['grade']] : '';
  2626. $classId = $week_info['class_id'];
  2627. $sql = "select class_name from class where class_id = '{$classId}'";
  2628. $classInfo = $this->sConn->createCommand($sql)->queryRow();
  2629. $className = $classInfo ? $classInfo['class_name'] : '';
  2630. $htmlpath .= $ewId . ".html";
  2631. $f = fopen($htmlpath, "w");
  2632. fwrite($f, $html);
  2633. fclose($f);
  2634. $htmlurl = '/upload/tmpDir/reading/' . $ewId . ".html"; //访问HTML的路径
  2635. $locale='en_US.UTF-8';
  2636. setlocale(LC_ALL,$locale);
  2637. putenv('LC_ALL='.$locale);
  2638. if (Yii::app()->basePath == 'D:\xampp\htdocs\zsy-as2-php\protected') {//本地的basePath
  2639. $htmlurl = " http://192.168.1.48:8077/upload/tmpDir/reading" . '/' . $ewId . '.html';
  2640. $pdffname = $ewId . ".pdf";
  2641. $pdfpath = $pdfpath . $pdffname;
  2642. $pdfurl = $pdfurl . $pdffname;
  2643. $commond = Yii::app()->params['phantomjs'] . " "
  2644. . Yii::app()->params['html2_card_pdf'] . " "
  2645. . " {$htmlurl}"
  2646. . " {$pdfpath}"
  2647. . ' 176mm*250mm "'.$grade.'|||'.date('Y-m-d',time()).'"';
  2648. } else {
  2649. $htmlurl = "http://" . $_SERVER['SERVER_NAME'] . $htmlurl;
  2650. $pdffname = $ewId . ".pdf";
  2651. $pdfpath = $pdfpath . $pdffname;
  2652. $pdfurl = $pdfurl . $pdffname;
  2653. $commond = Yii::app()->params['phantomjs_server'] . " "
  2654. . Yii::app()->basePath . '/../js/html2pdf_enCard.js' . " "
  2655. . " {$htmlurl}"
  2656. . " {$pdfpath}"
  2657. // . ' 176mm*250mm "'.date('Y-m-d',time()).'|||123456|||'.$grade.' '.$className.'|||'.$cardPage.'"';
  2658. . ' 176mm*250mm "'.$className.'|||'.$taskName.'|||'.date('Y-m-d',time()).' 写作宝-教师版|||'.$className.' '.$className.'|||'.$cardPage.'"';
  2659. }
  2660. // $stu_name . "|||" . (subtext($week_name, 30)) . "|||" .$product_name."|||". Params::$params['cur_subject_id']."|||".$card_page,
  2661. exec($commond, $res, $code);
  2662. if(isset($res[0])){
  2663. $isBool = false;
  2664. foreach ($res as $msg) {
  2665. if (strpos($msg, 'succeed') !== false) {
  2666. $isBool = true;
  2667. }
  2668. }
  2669. if ($isBool) {//命令返回成功
  2670. if (file_exists($pdfpath)) {
  2671. // $pdfurl=iconv("GBK", "UTF-8",$pdfurl);
  2672. $repdf = $ewId . ".pdf";
  2673. $rename = 'zsyas2/reading/' . $this->schoolId . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/' . uniqid() . '.' . $repdf;
  2674. $ucloud = new Qcloud();
  2675. $uploadInfo = $ucloud->putFile($rename, $pdfpath);
  2676. if ($uploadInfo['status'] == 0) {
  2677. $pdfurl = "http://" . $_SERVER['SERVER_NAME'] . $pdfurl;
  2678. //echo $pdfurl;
  2679. $this->sConn->createCommand()->update("english_writing", array("teacher_general_pdf_path" => $pdfurl), "ew_id = '{$ewId}'");
  2680. $week_info['teacher_general_pdf_path'] = $pdfurl;
  2681. }else{
  2682. $pdfurl = $uploadInfo['url'];
  2683. //echo $pdfurl;
  2684. $this->sConn->createCommand()->update("english_writing", array("teacher_general_pdf_path" => $pdfurl), "ew_id = '{$ewId}'");
  2685. $week_info['teacher_general_pdf_path'] = $pdfurl;
  2686. @unlink($pdfpath);
  2687. }
  2688. @unlink($htmlpath);
  2689. } else {
  2690. @unlink($htmlpath);
  2691. echo json_encode(array("success" => 0, "message" => "PDF文件未找到"));exit();
  2692. exit;
  2693. }
  2694. } else {
  2695. @unlink($htmlpath);
  2696. echo json_encode(array("success" => 0, "message" => "PDF创建失败"));exit();
  2697. exit;
  2698. }
  2699. } else {
  2700. echo json_encode(array("success" => 0, "message" => "PDF创建失败"));exit();
  2701. exit;
  2702. }
  2703. }
  2704. }
  2705. if($week_info['teacher_general_pdf_path']){
  2706. $url = $week_info['teacher_general_pdf_path'];
  2707. $printData['typeId'] = 18;
  2708. $printData['productType']=20032;
  2709. $printData['params'] = array(
  2710. 'classIds' => array($week_info['class_id']),
  2711. 'url' => $url,
  2712. 'name' => '写作宝教师版',
  2713. 'subjectId' => $this->subjectId,
  2714. 'examGroupId' => $ewId,
  2715. );
  2716. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  2717. }else{
  2718. echo json_encode(array("success" => 0, "message" => "尚未生成PDF"));exit();
  2719. }
  2720. }
  2721. /**
  2722. * 整理试题详情数据
  2723. */
  2724. public function newTopicDetail($paper_topic_detail){
  2725. $result = array();
  2726. $answer = array('A','B','C','D','E','F','G','H','I','J','K');
  2727. foreach($paper_topic_detail as $k=>$v){
  2728. $result[$k]['title'] = $v['title'];
  2729. $result[$k]['type_id'] = $v['type_id'];
  2730. $result[$k]['parse_content'] = $v['parse_content'];
  2731. $result[$k]['answer'] = array();
  2732. $slave_answer = array();
  2733. if(isset($v['slave']) && $v['slave']){
  2734. $slave_arr = array();
  2735. foreach($v['slave'] as $sla_k=>$sla_v){
  2736. $slave_arr[$sla_k]['title'] = $sla_v['title'];//小题题干
  2737. if(isset($sla_v['items']) && $sla_v['items']){
  2738. if(isset($sla_v['items']['options']) && $sla_v['items']['options']){
  2739. foreach($sla_v['items']['options'] as $op_k=>$op_v){
  2740. $slave_arr[$sla_k]['options'][$op_k] = $op_v['option_content'];
  2741. if($op_v['option_correct']){
  2742. $slave_answer[] = $answer[$op_k];
  2743. }
  2744. }
  2745. }
  2746. }
  2747. }
  2748. $result[$k]['slave'] = $slave_arr;
  2749. $result[$k]['answer'] = $slave_answer;
  2750. }else{
  2751. if(isset($v['items']) && $v['items'] && isset($v['items'][0]) && $v['items'][0]){
  2752. if(isset($v['items'][0]['options']) && $v['items'][0]['options']){
  2753. foreach($v['items'][0]['options'] as $op_k=>$op_v){
  2754. if($op_v['option_correct'] == 1){
  2755. $slave_answer[] = $op_v['option_content'];
  2756. }
  2757. }
  2758. }
  2759. }
  2760. $result[$k]['answer'] = $slave_answer;
  2761. }
  2762. if(isset($v['affiliate']) && $v['affiliate']){
  2763. foreach($v['affiliate'] as $aff_k=>$aff_v){
  2764. if($aff_v['field_name'] == '体裁类型'){
  2765. $result[$k]['tc'] = $this->getTags($aff_v['field_key'],$aff_v['field_value']);
  2766. }
  2767. if($aff_v['field_name'] == '主题语境'){
  2768. //主题语境只显示一个
  2769. $ztyj_str = $this->getTags($aff_v['field_key'],$aff_v['field_value']);
  2770. $ztyj_arr = explode(",",$ztyj_str);
  2771. if($ztyj_arr){
  2772. $result[$k]['ztyj'] = $ztyj_arr[0];
  2773. }else{
  2774. $result[$k]['ztyj'] ='';
  2775. }
  2776. }
  2777. if($aff_v['field_name'] == '语篇等级'){
  2778. $result[$k]['ypdj'] = $aff_v['field_value'];
  2779. }
  2780. if($aff_v['field_name'] == '句子剖析'){
  2781. $result[$k]['jzpx'] = $aff_v['field_value'];
  2782. }
  2783. if($aff_v['field_name'] == '词汇积累'){
  2784. $result[$k]['chjl'] = $aff_v['field_value'];
  2785. }
  2786. if($aff_v['field_name'] == '关键词拓展'){
  2787. $result[$k]['gjctz'] = $aff_v['field_value'];
  2788. }
  2789. if($aff_v['field_name'] == '长难句解析'){
  2790. $result[$k]['cnjjx'] = $aff_v['field_value'];
  2791. }
  2792. }
  2793. }
  2794. }
  2795. return $result;
  2796. }
  2797. /*
  2798. * 获取试题标签
  2799. *
  2800. */
  2801. public function getTags($field_key='',$field_value=''){
  2802. $result = '';
  2803. $data = array(
  2804. 'subjectId'=>8,
  2805. 'isSearch'=>1,
  2806. 'tagFieldName'=>array($field_key)
  2807. );
  2808. $brain_data = $this->apiBrainPost('/all_subject/topic_tag', $data, 25, true);
  2809. if($brain_data && isset($brain_data['data']) && $brain_data['data']){
  2810. $brain_arr = $brain_data['data'];
  2811. if(isset($brain_arr[0]) && isset($brain_arr[0]['extend']) && $brain_arr[0]['extend']){
  2812. $field_value_arr = explode("|",$field_value);
  2813. $field_arr = array();
  2814. foreach($brain_arr[0]['extend'] as $extend_v){
  2815. if(in_array($extend_v['tag_extend_id'],$field_value_arr)){
  2816. $field_arr[]=$extend_v['tag_extend_name'];
  2817. }
  2818. }
  2819. if($field_arr){
  2820. $result = implode(",",$field_arr);
  2821. }
  2822. }
  2823. }
  2824. return $result;
  2825. }
  2826. public function qrcode64($code_str, $level = 'L', $size = 10, $margin = 1){
  2827. $QRcode = new \QRcode();
  2828. ob_start();//开启缓冲区
  2829. $QRcode::pngNoHeader($code_str, false, 'L', 10, 1);//生成二维码
  2830. $img = ob_get_contents();//获取缓冲区内容
  2831. ob_end_clean();//清除缓冲区内容
  2832. $imgInfo = 'data:png;base64,' . chunk_split(base64_encode($img));//转base64
  2833. //ob_flush();
  2834. return $imgInfo;
  2835. }
  2836. /**
  2837. * 英语周推新版教师版下载
  2838. */
  2839. public function newEnTeacherWeek($weekId='',$weekMsg=array()){
  2840. $sql = "select week_pdf_path from english_week_student where week_id='{$weekId}' and student_id=0";
  2841. $week_info = $this->sConn->createCommand($sql)->queryRow();
  2842. if($week_info && $week_info['week_pdf_path']){
  2843. $classId = $weekMsg['class_id'];
  2844. $sql = "select class_name from class where class_id = '{$classId}'";
  2845. $classInfo = $this->sConn->createCommand($sql)->queryRow();
  2846. $className = $classInfo ? $classInfo['class_name'] : '';
  2847. $url = $week_info['week_pdf_path'];
  2848. if(isset(Yii::app()->params["static_url"][$this->schoolGroupId]) && Yii::app()->params["static_url"][$this->schoolGroupId]){
  2849. $url = Yii::app()->params["static_url"][$this->schoolGroupId].'/'.$url;
  2850. }else{
  2851. echo json_encode(array("success" => 0, "message" => "接口配置信息错误"));exit();
  2852. }
  2853. $fileName = $className.'_周推教师版';
  2854. $printData['typeId'] = 18;
  2855. $printData['productType']=30001;
  2856. $printData['params'] = array(
  2857. 'classIds' => array($weekMsg['class_id']),
  2858. 'url' => $url,
  2859. 'name' => $fileName,
  2860. 'subjectId' => $this->subjectId,
  2861. 'examGroupId' => $weekId,
  2862. );
  2863. echo json_encode(array("success" => 1, "message" => "success","data"=>$printData));exit();
  2864. }else{
  2865. echo json_encode(array("success" => 0, "message" => "周推教师版尚未生成"));exit();
  2866. }
  2867. }
  2868. }