Commit 2ad7ca4572de9e90bb7cf611b2ee89bad575d84b
1 parent
ce70231e
试卷bug修改
Showing
4 changed files
with
515 additions
and
120 deletions
resources/mybatis1/sunvote/PaperMapper.xml
@@ -21,6 +21,7 @@ | @@ -21,6 +21,7 @@ | ||
21 | PAPER_STATE, | 21 | PAPER_STATE, |
22 | REMARK, | 22 | REMARK, |
23 | SCORE, | 23 | SCORE, |
24 | + CLASS_ID, | ||
24 | QUESTION_NUM, | 25 | QUESTION_NUM, |
25 | PAPER_ID | 26 | PAPER_ID |
26 | </sql> | 27 | </sql> |
@@ -39,6 +40,7 @@ | @@ -39,6 +40,7 @@ | ||
39 | #{PAPER_STATE}, | 40 | #{PAPER_STATE}, |
40 | #{REMARK}, | 41 | #{REMARK}, |
41 | #{SCORE}, | 42 | #{SCORE}, |
43 | + #{CLASS_ID}, | ||
42 | #{QUESTION_NUM}, | 44 | #{QUESTION_NUM}, |
43 | #{PAPER_ID} | 45 | #{PAPER_ID} |
44 | </sql> | 46 | </sql> |
@@ -79,6 +81,7 @@ | @@ -79,6 +81,7 @@ | ||
79 | PAPER_STATE = #{PAPER_STATE}, | 81 | PAPER_STATE = #{PAPER_STATE}, |
80 | REMARK = #{REMARK}, | 82 | REMARK = #{REMARK}, |
81 | SCORE = #{SCORE}, | 83 | SCORE = #{SCORE}, |
84 | + CLASS_ID = #{CLASS_ID}, | ||
82 | QUESTION_NUM = #{QUESTION_NUM}, | 85 | QUESTION_NUM = #{QUESTION_NUM}, |
83 | PAPER_ID = PAPER_ID | 86 | PAPER_ID = PAPER_ID |
84 | where | 87 | where |
@@ -128,6 +131,9 @@ | @@ -128,6 +131,9 @@ | ||
128 | <if test="pd.USER_ID != null and pd.USER_ID != ''"><!-- 关键词检索 --> | 131 | <if test="pd.USER_ID != null and pd.USER_ID != ''"><!-- 关键词检索 --> |
129 | and USER_ID = #{pd.USER_ID} | 132 | and USER_ID = #{pd.USER_ID} |
130 | </if> | 133 | </if> |
134 | + <if test="pd.CLASS_ID != null and pd.CLASS_ID != ''"><!-- 关键词检索 --> | ||
135 | + and CLASS_ID = #{pd.CLASS_ID} | ||
136 | + </if> | ||
131 | 137 | ||
132 | order by CREATE_DATE DESC | 138 | order by CREATE_DATE DESC |
133 | </select> | 139 | </select> |
@@ -159,6 +165,9 @@ | @@ -159,6 +165,9 @@ | ||
159 | <if test="pd.SUBJECT_ID != null and pd.SUBJECT_ID != ''"> | 165 | <if test="pd.SUBJECT_ID != null and pd.SUBJECT_ID != ''"> |
160 | and SUBJECT_ID = #{pd.SUBJECT_ID} | 166 | and SUBJECT_ID = #{pd.SUBJECT_ID} |
161 | </if> | 167 | </if> |
168 | + <if test="pd.CLASS_ID != null and pd.CLASS_ID != ''"> | ||
169 | + and CLASS_ID = #{pd.CLASS_ID} | ||
170 | + </if> | ||
162 | 171 | ||
163 | order by CREATE_DATE DESC | 172 | order by CREATE_DATE DESC |
164 | </select> | 173 | </select> |
src/com/fh/bean/Question.java
@@ -42,7 +42,7 @@ public class Question { | @@ -42,7 +42,7 @@ public class Question { | ||
42 | 42 | ||
43 | private String sug_part_score; | 43 | private String sug_part_score; |
44 | 44 | ||
45 | - private String questionType = "" ; | 45 | + private String questionType ; |
46 | 46 | ||
47 | private List<Question> questions; | 47 | private List<Question> questions; |
48 | 48 |
src/com/fh/controller/api/ResponseGson.java
@@ -45,6 +45,11 @@ public class ResponseGson<T> { | @@ -45,6 +45,11 @@ public class ResponseGson<T> { | ||
45 | Gson gson = new GsonBuilder().serializeNulls().create(); | 45 | Gson gson = new GsonBuilder().serializeNulls().create(); |
46 | return gson.toJson(this); | 46 | return gson.toJson(this); |
47 | } | 47 | } |
48 | + | ||
49 | + public String toBrifJson(){ | ||
50 | + Gson gson = new Gson(); | ||
51 | + return gson.toJson(this); | ||
52 | + } | ||
48 | 53 | ||
49 | @Override | 54 | @Override |
50 | public String toString() { | 55 | public String toString() { |
src/com/fh/controller/api/V1.java
@@ -171,10 +171,17 @@ public class V1 extends BaseController { | @@ -171,10 +171,17 @@ public class V1 extends BaseController { | ||
171 | 171 | ||
172 | @Resource(name = "teachingmaterialService") | 172 | @Resource(name = "teachingmaterialService") |
173 | private TeachingMaterialManager teachingmaterialService; | 173 | private TeachingMaterialManager teachingmaterialService; |
174 | - | ||
175 | - @Resource(name="cacheService") | 174 | + |
175 | + @Resource(name = "cacheService") | ||
176 | private CacheManager cacheService; | 176 | private CacheManager cacheService; |
177 | 177 | ||
178 | + /** | ||
179 | + * 登录 | ||
180 | + * 可以通过账号密码登录、 | ||
181 | + * 可以通过教师卡登录 | ||
182 | + * @return | ||
183 | + * @throws Exception | ||
184 | + */ | ||
178 | @RequestMapping(value = "/login", produces = "application/json;charset=UTF-8") | 185 | @RequestMapping(value = "/login", produces = "application/json;charset=UTF-8") |
179 | @ResponseBody | 186 | @ResponseBody |
180 | public Object login() throws Exception { | 187 | public Object login() throws Exception { |
@@ -231,6 +238,12 @@ public class V1 extends BaseController { | @@ -231,6 +238,12 @@ public class V1 extends BaseController { | ||
231 | return res.toJson(); | 238 | return res.toJson(); |
232 | } | 239 | } |
233 | 240 | ||
241 | + /** | ||
242 | + * 查询班级 | ||
243 | + * 班级及班级学生详细信息 | ||
244 | + * @return | ||
245 | + * @throws Exception | ||
246 | + */ | ||
234 | @RequestMapping(value = "/class", produces = "application/json;charset=UTF-8") | 247 | @RequestMapping(value = "/class", produces = "application/json;charset=UTF-8") |
235 | @ResponseBody | 248 | @ResponseBody |
236 | public Object sclass() throws Exception { | 249 | public Object sclass() throws Exception { |
@@ -266,6 +279,11 @@ public class V1 extends BaseController { | @@ -266,6 +279,11 @@ public class V1 extends BaseController { | ||
266 | } | 279 | } |
267 | } | 280 | } |
268 | 281 | ||
282 | + /** | ||
283 | + * 问题类型 | ||
284 | + * @return | ||
285 | + * @throws Exception | ||
286 | + */ | ||
269 | @RequestMapping(value = "/questiontype", produces = "application/json;charset=UTF-8") | 287 | @RequestMapping(value = "/questiontype", produces = "application/json;charset=UTF-8") |
270 | @ResponseBody | 288 | @ResponseBody |
271 | public Object questiontype() throws Exception { | 289 | public Object questiontype() throws Exception { |
@@ -280,6 +298,11 @@ public class V1 extends BaseController { | @@ -280,6 +298,11 @@ public class V1 extends BaseController { | ||
280 | return res.toJson(); | 298 | return res.toJson(); |
281 | } | 299 | } |
282 | 300 | ||
301 | + /** | ||
302 | + * 班级类型 | ||
303 | + * @return | ||
304 | + * @throws Exception | ||
305 | + */ | ||
283 | @RequestMapping(value = "/classtype", produces = "application/json;charset=UTF-8") | 306 | @RequestMapping(value = "/classtype", produces = "application/json;charset=UTF-8") |
284 | @ResponseBody | 307 | @ResponseBody |
285 | public Object classtype() throws Exception { | 308 | public Object classtype() throws Exception { |
@@ -294,6 +317,12 @@ public class V1 extends BaseController { | @@ -294,6 +317,12 @@ public class V1 extends BaseController { | ||
294 | return res.toJson(); | 317 | return res.toJson(); |
295 | } | 318 | } |
296 | 319 | ||
320 | + /** | ||
321 | + * 年级 | ||
322 | + * 年级类型 | ||
323 | + * @return | ||
324 | + * @throws Exception | ||
325 | + */ | ||
297 | @RequestMapping(value = "/grade", produces = "application/json;charset=UTF-8") | 326 | @RequestMapping(value = "/grade", produces = "application/json;charset=UTF-8") |
298 | @ResponseBody | 327 | @ResponseBody |
299 | public Object grade() throws Exception { | 328 | public Object grade() throws Exception { |
@@ -312,6 +341,11 @@ public class V1 extends BaseController { | @@ -312,6 +341,11 @@ public class V1 extends BaseController { | ||
312 | return res.toJson(); | 341 | return res.toJson(); |
313 | } | 342 | } |
314 | 343 | ||
344 | + /** | ||
345 | + * 科目 | ||
346 | + * @return | ||
347 | + * @throws Exception | ||
348 | + */ | ||
315 | @RequestMapping(value = "/subject", produces = "application/json;charset=UTF-8") | 349 | @RequestMapping(value = "/subject", produces = "application/json;charset=UTF-8") |
316 | @ResponseBody | 350 | @ResponseBody |
317 | public Object subject() throws Exception { | 351 | public Object subject() throws Exception { |
@@ -330,6 +364,11 @@ public class V1 extends BaseController { | @@ -330,6 +364,11 @@ public class V1 extends BaseController { | ||
330 | return res.toJson(); | 364 | return res.toJson(); |
331 | } | 365 | } |
332 | 366 | ||
367 | + /** | ||
368 | + * 键盘扫描 | ||
369 | + * @return | ||
370 | + * @throws Exception | ||
371 | + */ | ||
333 | @RequestMapping(value = "/keypadscan", produces = "application/json;charset=UTF-8") | 372 | @RequestMapping(value = "/keypadscan", produces = "application/json;charset=UTF-8") |
334 | @ResponseBody | 373 | @ResponseBody |
335 | public Object keypadScan() throws Exception { | 374 | public Object keypadScan() throws Exception { |
@@ -352,6 +391,12 @@ public class V1 extends BaseController { | @@ -352,6 +391,12 @@ public class V1 extends BaseController { | ||
352 | return res.toJson(); | 391 | return res.toJson(); |
353 | } | 392 | } |
354 | 393 | ||
394 | + /** | ||
395 | + * showcount 数量 currentpage 当前页码 | ||
396 | + * | ||
397 | + * @return | ||
398 | + * @throws Exception | ||
399 | + */ | ||
355 | @RequestMapping(value = "/paper", produces = "application/json;charset=UTF-8") | 400 | @RequestMapping(value = "/paper", produces = "application/json;charset=UTF-8") |
356 | @ResponseBody | 401 | @ResponseBody |
357 | public Object paper() throws Exception { | 402 | public Object paper() throws Exception { |
@@ -389,6 +434,11 @@ public class V1 extends BaseController { | @@ -389,6 +434,11 @@ public class V1 extends BaseController { | ||
389 | return res.toJson(); | 434 | return res.toJson(); |
390 | } | 435 | } |
391 | 436 | ||
437 | + /** | ||
438 | + * 试卷详细信息 | ||
439 | + * @return | ||
440 | + * @throws Exception | ||
441 | + */ | ||
392 | @RequestMapping(value = "/paperinfo", produces = "application/json;charset=UTF-8") | 442 | @RequestMapping(value = "/paperinfo", produces = "application/json;charset=UTF-8") |
393 | @ResponseBody | 443 | @ResponseBody |
394 | public Object paperInfo() throws Exception { | 444 | public Object paperInfo() throws Exception { |
@@ -497,6 +547,83 @@ public class V1 extends BaseController { | @@ -497,6 +547,83 @@ public class V1 extends BaseController { | ||
497 | return res.toJson(); | 547 | return res.toJson(); |
498 | } | 548 | } |
499 | 549 | ||
550 | + /** | ||
551 | + * 试卷简要信息 | ||
552 | + * @return | ||
553 | + * @throws Exception | ||
554 | + */ | ||
555 | + @RequestMapping(value = "/paperbriefinfo", produces = "application/json;charset=UTF-8") | ||
556 | + @ResponseBody | ||
557 | + public Object paperBriefInfo() throws Exception { | ||
558 | + event("paperBriefInfo"); | ||
559 | + long cur = System.currentTimeMillis(); | ||
560 | + PageData pd = this.getPageData(); | ||
561 | + ResponseGson<Paper> res = new ResponseGson<Paper>(); | ||
562 | + if (pd.containsKey("PAPER_ID")) { | ||
563 | + try { | ||
564 | + try { | ||
565 | + Paper paper = new Paper(); | ||
566 | + PageData ppd = paperService.findById(pd); | ||
567 | + if (ppd != null) { | ||
568 | + paper.setTitle(ppd.getString("TITLE")); | ||
569 | + paper.setExam_time(ppd.getString("EXAM_TIME")); | ||
570 | + paper.setUser_id(ppd.getString("USER_ID")); | ||
571 | + paper.setPaper_type(ppd.getString("PAPER_TYPE")); | ||
572 | + paper.setSubject_id(ppd.getString("SUBJECT_ID")); | ||
573 | + paper.setGrade_id(ppd.getString("GRADE_ID")); | ||
574 | + paper.setScore(ppd.getString("SCORE")); | ||
575 | + paper.setQuestions(new ArrayList<Question>()); | ||
576 | + | ||
577 | + List<PageData> questList = v1Service | ||
578 | + .getTestPaperInfo(pd); | ||
579 | + for (PageData qpd : questList) { | ||
580 | + Question question = new Question(); | ||
581 | + question.setQuestion_id(qpd | ||
582 | + .getString("QUESTION_ID")); | ||
583 | + if ("-1".equals("" + qpd.getString("P_ID"))) { | ||
584 | + PageData pidPd = new PageData(); | ||
585 | + pidPd.put("PID", question.getQuestion_id()); | ||
586 | + question.setQuestions(new ArrayList<Question>()); | ||
587 | + List<PageData> qs = v1Service | ||
588 | + .getQuestionsByPID(pidPd); | ||
589 | + for (PageData q : qs) { | ||
590 | + Question qq = new Question(); | ||
591 | + qq.setQuestion_id(q | ||
592 | + .getString("QUESTION_ID")); | ||
593 | + question.getQuestions().add(qq); | ||
594 | + } | ||
595 | + } | ||
596 | + if ("-1".equals(qpd.getString("P_ID")) | ||
597 | + || "0".equals(qpd.getString("P_ID"))) { | ||
598 | + paper.getQuestions().add(question); | ||
599 | + } | ||
600 | + } | ||
601 | + // pd.put("JSON", paper.toJson()); | ||
602 | + res.setData(paper); | ||
603 | + logger.info(paper.toJson()); | ||
604 | + | ||
605 | + } | ||
606 | + } catch (Exception ex) { | ||
607 | + ex.printStackTrace(); | ||
608 | + } | ||
609 | + } catch (Exception ex) { | ||
610 | + ex.printStackTrace(); | ||
611 | + res.setError(); | ||
612 | + } | ||
613 | + } else { | ||
614 | + res.setOtherError(); | ||
615 | + } | ||
616 | + logger.info("paperInfo cost time : " | ||
617 | + + (System.currentTimeMillis() - cur)); | ||
618 | + return res.toBrifJson(); | ||
619 | + } | ||
620 | + | ||
621 | + | ||
622 | + /** | ||
623 | + * 试卷问题 | ||
624 | + * @return | ||
625 | + * @throws Exception | ||
626 | + */ | ||
500 | @RequestMapping(value = "/paperquestion", produces = "application/json;charset=UTF-8") | 627 | @RequestMapping(value = "/paperquestion", produces = "application/json;charset=UTF-8") |
501 | @ResponseBody | 628 | @ResponseBody |
502 | public Object paperQuestion() throws Exception { | 629 | public Object paperQuestion() throws Exception { |
@@ -509,17 +636,30 @@ public class V1 extends BaseController { | @@ -509,17 +636,30 @@ public class V1 extends BaseController { | ||
509 | return res.toJson(); | 636 | return res.toJson(); |
510 | } | 637 | } |
511 | 638 | ||
639 | + /** | ||
640 | + * 问题 | ||
641 | + * @return | ||
642 | + * @throws Exception | ||
643 | + */ | ||
512 | @RequestMapping(value = "/question", produces = "application/json;charset=UTF-8") | 644 | @RequestMapping(value = "/question", produces = "application/json;charset=UTF-8") |
513 | @ResponseBody | 645 | @ResponseBody |
514 | public Object question() throws Exception { | 646 | public Object question() throws Exception { |
515 | event("question"); | 647 | event("question"); |
516 | long cur = System.currentTimeMillis(); | 648 | long cur = System.currentTimeMillis(); |
517 | PageData pd = this.getPageData(); | 649 | PageData pd = this.getPageData(); |
518 | - ResponseGson<PageData> res = new ResponseGson(); | 650 | + ResponseGson<List<PageData>> res = new ResponseGson(); |
651 | + List<PageData> list = new ArrayList<PageData>(); | ||
519 | if (pd.containsKey("ID")) { | 652 | if (pd.containsKey("ID")) { |
520 | - pd.put("QUESTION_ID", pd.get("ID")); | ||
521 | - PageData data = questionService.findById(pd); | ||
522 | - res.setData(data); | 653 | + String ids = pd.getString("ID"); |
654 | + String[] id = ids.split(","); | ||
655 | + for (String i : id) { | ||
656 | + pd.put("QUESTION_ID", i); | ||
657 | + PageData data = questionService.findById(pd); | ||
658 | + if (data != null) { | ||
659 | + list.add(data); | ||
660 | + } | ||
661 | + } | ||
662 | + res.setData(list); | ||
523 | } else { | 663 | } else { |
524 | res.setDataError(); | 664 | res.setDataError(); |
525 | } | 665 | } |
@@ -528,6 +668,71 @@ public class V1 extends BaseController { | @@ -528,6 +668,71 @@ public class V1 extends BaseController { | ||
528 | return res.toJson(); | 668 | return res.toJson(); |
529 | } | 669 | } |
530 | 670 | ||
671 | + /** | ||
672 | + * 查询知识点名称 | ||
673 | + * @return | ||
674 | + * @throws Exception | ||
675 | + */ | ||
676 | + @RequestMapping(value = "/knowledgename", produces = "application/json;charset=UTF-8") | ||
677 | + @ResponseBody | ||
678 | + public Object knowledgename() throws Exception { | ||
679 | + ResponseGson<List<PageData>> res = new ResponseGson(); | ||
680 | + List<PageData> list = new ArrayList<PageData>(); | ||
681 | + PageData pd = getPageData(); | ||
682 | + if (pd.get("ID") != null) { | ||
683 | + String ids = pd.getString("ID"); | ||
684 | + String[] id = ids.split(","); | ||
685 | + for (String i : id) { | ||
686 | + pd.put("KNOWLEDGE_ID", i); | ||
687 | + PageData data = knowledgeService.findById(pd); | ||
688 | + if (data != null) { | ||
689 | + PageData t = new PageData(); | ||
690 | + t.put("KNOWLEDGE_ID", data.get("KNOWLEDGE_ID")); | ||
691 | + t.put("NAME", data.get("NAME")); | ||
692 | + list.add(t); | ||
693 | + } | ||
694 | + } | ||
695 | + res.setData(list); | ||
696 | + } | ||
697 | + ; | ||
698 | + return res; | ||
699 | + } | ||
700 | + | ||
701 | + /** | ||
702 | + * 章节名称 | ||
703 | + * @return | ||
704 | + * @throws Exception | ||
705 | + */ | ||
706 | + @RequestMapping(value = "/chaptername", produces = "application/json;charset=UTF-8") | ||
707 | + @ResponseBody | ||
708 | + public Object chaptername() throws Exception { | ||
709 | + ResponseGson<List<PageData>> res = new ResponseGson(); | ||
710 | + List<PageData> list = new ArrayList<PageData>(); | ||
711 | + PageData pd = getPageData(); | ||
712 | + if (pd.get("ID") != null) { | ||
713 | + String ids = pd.getString("ID"); | ||
714 | + String[] id = ids.split(","); | ||
715 | + for (String i : id) { | ||
716 | + pd.put("ID", i); | ||
717 | + PageData data = chapterService.findById(pd); | ||
718 | + if (data != null) { | ||
719 | + PageData t = new PageData(); | ||
720 | + t.put("ID", data.get("ID")); | ||
721 | + t.put("NAME", data.get("NAME")); | ||
722 | + list.add(t); | ||
723 | + } | ||
724 | + } | ||
725 | + res.setData(list); | ||
726 | + } | ||
727 | + ; | ||
728 | + return res; | ||
729 | + } | ||
730 | + | ||
731 | + /** | ||
732 | + * 试题添加 | ||
733 | + * @return | ||
734 | + * @throws Exception | ||
735 | + */ | ||
531 | @RequestMapping(value = "/question/add", produces = "application/json;charset=UTF-8") | 736 | @RequestMapping(value = "/question/add", produces = "application/json;charset=UTF-8") |
532 | @ResponseBody | 737 | @ResponseBody |
533 | public Object questionAdd() throws Exception { | 738 | public Object questionAdd() throws Exception { |
@@ -542,6 +747,11 @@ public class V1 extends BaseController { | @@ -542,6 +747,11 @@ public class V1 extends BaseController { | ||
542 | return res.toJson(); | 747 | return res.toJson(); |
543 | } | 748 | } |
544 | 749 | ||
750 | + /*** | ||
751 | + * 上传试卷 | ||
752 | + * @return | ||
753 | + * @throws Exception | ||
754 | + */ | ||
545 | @RequestMapping(value = "/uploadpaper", produces = "application/json;charset=UTF-8") | 755 | @RequestMapping(value = "/uploadpaper", produces = "application/json;charset=UTF-8") |
546 | @ResponseBody | 756 | @ResponseBody |
547 | public Object uploadpaper() throws Exception { | 757 | public Object uploadpaper() throws Exception { |
@@ -674,6 +884,71 @@ public class V1 extends BaseController { | @@ -674,6 +884,71 @@ public class V1 extends BaseController { | ||
674 | return res.toJson(); | 884 | return res.toJson(); |
675 | } | 885 | } |
676 | 886 | ||
887 | + /** | ||
888 | + * 上传试卷,不上传试题详细信息。试题从已有数据库中组卷 | ||
889 | + * @return | ||
890 | + * @throws Exception | ||
891 | + */ | ||
892 | + @RequestMapping(value = "/publishpaper", produces = "application/json;charset=UTF-8") | ||
893 | + @ResponseBody | ||
894 | + public Object publishPaper() throws Exception { | ||
895 | + event("publishpaper"); | ||
896 | + long cur = System.currentTimeMillis(); | ||
897 | + PageData pd = this.getPageData(); | ||
898 | + ResponseGson<String> res = new ResponseGson(); | ||
899 | + | ||
900 | + if (!StringUtils.isEmpty(pd.getJsonString())) { | ||
901 | + logger.info(pd.getJsonString()); | ||
902 | + Paper paper = Paper.parse(pd.getJsonString()); | ||
903 | + PageData paperPd = new PageData(); | ||
904 | + String paperID = this.get32UUID(); | ||
905 | + res.setData(paperID); | ||
906 | + paperPd.put("PAPER_ID", paperID); | ||
907 | + paperPd.put("TITLE", paper.getTitle()); | ||
908 | + paperPd.put("USER_ID", paper.getUser_id()); | ||
909 | + paperPd.put("PAPER_TYPE", paper.getPaper_type()); | ||
910 | + paperPd.put("SUBJECT_ID", paper.getSubject_id()); | ||
911 | + paperPd.put("GRADE_ID", paper.getGrade_id()); | ||
912 | + paperPd.put("EXAM_TIME", paper.getExam_time()); | ||
913 | + paperPd.put("SCORE", paper.getScore()); | ||
914 | + paperPd.put("PAPER_STATE", "0"); | ||
915 | + paperPd.put("REMARK", ""); | ||
916 | + String schoolID = Myelfun.getUserID(paper.getUser_id()); | ||
917 | + paperPd.put("SCHOOL_ID", schoolID); | ||
918 | + paperPd.put("CREATE_DATE", Tools.date2Str(new Date())); | ||
919 | + paperPd.put("MODIFY_DATE", Tools.date2Str(new Date())); | ||
920 | + int questionNum = 0; | ||
921 | + List<Question> questions = paper.getQuestions(); | ||
922 | + if (questions != null) { | ||
923 | + for (Question question : questions) { | ||
924 | + PageData pqPd = new PageData(); | ||
925 | + pqPd.put("PAPER_ID", paperID); | ||
926 | + pqPd.put("QUESTION_ID", question.getQuestion_id()); | ||
927 | + pqPd.put("SCORE", question.getScore()); | ||
928 | + pqPd.put("PART_SCORE", "0"); | ||
929 | + pqPd.put("RANK", question.getRank()); | ||
930 | + pqPd.put("NO_NAME", question.getNo_name()); | ||
931 | + pqPd.put("PAPERQUESTION_ID", this.get32UUID()); | ||
932 | + paperquestionService.save(pqPd); | ||
933 | + | ||
934 | + } | ||
935 | + } | ||
936 | + paperPd.put("QUESTION_NUM", "" + questionNum); | ||
937 | + paperService.save(paperPd); | ||
938 | + | ||
939 | + } else { | ||
940 | + res.setDataError(); | ||
941 | + } | ||
942 | + logger.info("uploadpaper cost time : " | ||
943 | + + (System.currentTimeMillis() - cur)); | ||
944 | + return res.toJson(); | ||
945 | + } | ||
946 | + | ||
947 | + /** | ||
948 | + * 上传知识点 | ||
949 | + * @return | ||
950 | + * @throws Exception | ||
951 | + */ | ||
677 | @RequestMapping(value = "/uploadpoint", produces = "application/json;charset=UTF-8") | 952 | @RequestMapping(value = "/uploadpoint", produces = "application/json;charset=UTF-8") |
678 | @ResponseBody | 953 | @ResponseBody |
679 | public Object uploadpoint() throws Exception { | 954 | public Object uploadpoint() throws Exception { |
@@ -703,7 +978,10 @@ public class V1 extends BaseController { | @@ -703,7 +978,10 @@ public class V1 extends BaseController { | ||
703 | return res.toJson(); | 978 | return res.toJson(); |
704 | } | 979 | } |
705 | 980 | ||
706 | - // 上传测验成绩 | 981 | + /** |
982 | + * 上传测验成绩 | ||
983 | + * @return | ||
984 | + */ | ||
707 | @RequestMapping(value = "/uploadtestpaper", produces = "application/json;charset=UTF-8") | 985 | @RequestMapping(value = "/uploadtestpaper", produces = "application/json;charset=UTF-8") |
708 | @ResponseBody | 986 | @ResponseBody |
709 | public Object uploadTestpaper() { | 987 | public Object uploadTestpaper() { |
@@ -818,7 +1096,10 @@ public class V1 extends BaseController { | @@ -818,7 +1096,10 @@ public class V1 extends BaseController { | ||
818 | 1096 | ||
819 | } | 1097 | } |
820 | 1098 | ||
821 | - // 上传测验成绩 | 1099 | + /** |
1100 | + * 上传测验成绩 | ||
1101 | + * @return | ||
1102 | + */ | ||
822 | @RequestMapping(value = "/uploadupdatetestpaper", produces = "application/json;charset=UTF-8") | 1103 | @RequestMapping(value = "/uploadupdatetestpaper", produces = "application/json;charset=UTF-8") |
823 | @ResponseBody | 1104 | @ResponseBody |
824 | public Object uploadupdateTestpaper() { | 1105 | public Object uploadupdateTestpaper() { |
@@ -931,41 +1212,54 @@ public class V1 extends BaseController { | @@ -931,41 +1212,54 @@ public class V1 extends BaseController { | ||
931 | 1212 | ||
932 | } | 1213 | } |
933 | 1214 | ||
1215 | + /** | ||
1216 | + * 查询知识点 | ||
1217 | + * @return | ||
1218 | + * @throws Exception | ||
1219 | + */ | ||
934 | @RequestMapping(value = "/point", produces = "application/json;charset=UTF-8") | 1220 | @RequestMapping(value = "/point", produces = "application/json;charset=UTF-8") |
935 | @ResponseBody | 1221 | @ResponseBody |
936 | public Object point() throws Exception { | 1222 | public Object point() throws Exception { |
937 | ResponseGson<List<PageData>> res = new ResponseGson(); | 1223 | ResponseGson<List<PageData>> res = new ResponseGson(); |
938 | - | 1224 | + |
939 | PageData pd = getPageData(); | 1225 | PageData pd = getPageData(); |
940 | - String key = this.getRequestKey(pd,"point"); | 1226 | + String key = this.getRequestKey(pd, "point"); |
941 | PageData pagedata = new PageData(); | 1227 | PageData pagedata = new PageData(); |
942 | pagedata.put("KEY", key); | 1228 | pagedata.put("KEY", key); |
943 | - if(!"".equals(key.trim())){ | 1229 | + if (!"".equals(key.trim())) { |
944 | PageData ret = cacheService.findById(pagedata); | 1230 | PageData ret = cacheService.findById(pagedata); |
945 | - if(ret != null && ret.get("CACHE") != null){ | 1231 | + if (ret != null && ret.get("CACHE") != null) { |
946 | return ret.get("CACHE"); | 1232 | return ret.get("CACHE"); |
947 | } | 1233 | } |
948 | } | 1234 | } |
949 | List<PageData> list = knowledgeService.listAllknowledge(pd); | 1235 | List<PageData> list = knowledgeService.listAllknowledge(pd); |
950 | String depth = pd.getString("DEPTH"); | 1236 | String depth = pd.getString("DEPTH"); |
951 | - int end = 3 ; | ||
952 | - if(depth != null){ | ||
953 | - try{ | 1237 | + int end = 3; |
1238 | + if (depth != null) { | ||
1239 | + try { | ||
954 | end = Integer.parseInt(depth); | 1240 | end = Integer.parseInt(depth); |
955 | - }catch(Exception e){ | ||
956 | - | 1241 | + } catch (Exception e) { |
1242 | + | ||
957 | } | 1243 | } |
958 | } | 1244 | } |
959 | - roundPointData(list,1,end); | 1245 | + roundPointData(list, 1, end); |
960 | res.setData(list); | 1246 | res.setData(list); |
961 | String str = res.toJson(); | 1247 | String str = res.toJson(); |
962 | - str = str.replaceAll("[^\u0000-\uFFFF]", ""); | 1248 | + str = str.replaceAll("[^\u0000-\uFFFF]", ""); |
963 | pagedata.put("CACHE", str); | 1249 | pagedata.put("CACHE", str); |
964 | cacheService.save(pagedata); | 1250 | cacheService.save(pagedata); |
965 | return str; | 1251 | return str; |
966 | } | 1252 | } |
967 | 1253 | ||
968 | - private void roundPointData(List<PageData> list,int dept , int end) throws Exception { | 1254 | + /** |
1255 | + * 知识点递归查询 | ||
1256 | + * @param list 查询知识点及子知识点 | ||
1257 | + * @param dept 深度 | ||
1258 | + * @param end 层深 | ||
1259 | + * @throws Exception | ||
1260 | + */ | ||
1261 | + private void roundPointData(List<PageData> list, int dept, int end) | ||
1262 | + throws Exception { | ||
969 | if (list != null) { | 1263 | if (list != null) { |
970 | for (PageData pd : list) { | 1264 | for (PageData pd : list) { |
971 | pd.put("P_ID", pd.getString("KNOWLEDGE_ID")); | 1265 | pd.put("P_ID", pd.getString("KNOWLEDGE_ID")); |
@@ -973,7 +1267,7 @@ public class V1 extends BaseController { | @@ -973,7 +1267,7 @@ public class V1 extends BaseController { | ||
973 | && !"".equals(pd.getString("P_ID")) && dept < end) { | 1267 | && !"".equals(pd.getString("P_ID")) && dept < end) { |
974 | List<PageData> ret = knowledgeService.listAllknowledge(pd); | 1268 | List<PageData> ret = knowledgeService.listAllknowledge(pd); |
975 | if (ret != null && ret.size() > 0) { | 1269 | if (ret != null && ret.size() > 0) { |
976 | - roundPointData(ret,dept + 1,end); | 1270 | + roundPointData(ret, dept + 1, end); |
977 | pd.put("CHILDREN", ret); | 1271 | pd.put("CHILDREN", ret); |
978 | } | 1272 | } |
979 | } | 1273 | } |
@@ -981,25 +1275,39 @@ public class V1 extends BaseController { | @@ -981,25 +1275,39 @@ public class V1 extends BaseController { | ||
981 | } | 1275 | } |
982 | } | 1276 | } |
983 | } | 1277 | } |
984 | - | ||
985 | - private void roundChapterData(List<PageData> list,int dept,int end) throws Exception { | ||
986 | - if (list != null && dept < end) { | 1278 | + |
1279 | + /** | ||
1280 | + * 章节递归查询 | ||
1281 | + * @param list 章节 | ||
1282 | + * @param dept 深度 | ||
1283 | + * @param end 递归深度 | ||
1284 | + * @throws Exception | ||
1285 | + */ | ||
1286 | + private void roundChapterData(List<PageData> list, int dept, int end) | ||
1287 | + throws Exception { | ||
1288 | + if (list != null) { | ||
987 | for (PageData pd : list) { | 1289 | for (PageData pd : list) { |
988 | pd.put("P_ID", pd.getString("ID")); | 1290 | pd.put("P_ID", pd.getString("ID")); |
989 | - if (pd.getString("P_ID") != null | ||
990 | - && !"".equals(pd.getString("P_ID"))) { | ||
991 | - List<PageData> ret = chapterService.listAllChapter(pd); | ||
992 | - if (ret != null && ret.size() > 0) { | ||
993 | - roundChapterData(ret,dept+1,end); | ||
994 | - pd.put("CHILDREN", ret); | 1291 | + if (dept < end) { |
1292 | + if (pd.getString("P_ID") != null | ||
1293 | + && !"".equals(pd.getString("P_ID"))) { | ||
1294 | + List<PageData> ret = chapterService.listAllChapter(pd); | ||
1295 | + if (ret != null && ret.size() > 0) { | ||
1296 | + roundChapterData(ret, dept + 1, end); | ||
1297 | + pd.put("CHILDREN", ret); | ||
1298 | + } | ||
995 | } | 1299 | } |
996 | } | 1300 | } |
997 | pd.remove("P_ID"); | 1301 | pd.remove("P_ID"); |
1302 | + pd.remove("TEACHINGMATERIAL_ID"); | ||
998 | } | 1303 | } |
999 | } | 1304 | } |
1000 | } | 1305 | } |
1001 | 1306 | ||
1002 | - // 下载测验成绩 | 1307 | + /** |
1308 | + * 下载测验成绩 | ||
1309 | + * @return | ||
1310 | + */ | ||
1003 | @RequestMapping(value = "/downloadtestpaper", produces = "application/json;charset=UTF-8") | 1311 | @RequestMapping(value = "/downloadtestpaper", produces = "application/json;charset=UTF-8") |
1004 | @ResponseBody | 1312 | @ResponseBody |
1005 | public Object downloadTestpaper() { | 1313 | public Object downloadTestpaper() { |
@@ -1086,7 +1394,11 @@ public class V1 extends BaseController { | @@ -1086,7 +1394,11 @@ public class V1 extends BaseController { | ||
1086 | 1394 | ||
1087 | } | 1395 | } |
1088 | 1396 | ||
1089 | - // 下载测验成绩 | 1397 | + /** |
1398 | + * | ||
1399 | + * 下载测验成绩 | ||
1400 | + * @return | ||
1401 | + */ | ||
1090 | @RequestMapping(value = "/testpaper", produces = "application/json;charset=UTF-8") | 1402 | @RequestMapping(value = "/testpaper", produces = "application/json;charset=UTF-8") |
1091 | @ResponseBody | 1403 | @ResponseBody |
1092 | public Object testpaper() { | 1404 | public Object testpaper() { |
@@ -1128,6 +1440,9 @@ public class V1 extends BaseController { | @@ -1128,6 +1440,9 @@ public class V1 extends BaseController { | ||
1128 | 1440 | ||
1129 | } | 1441 | } |
1130 | 1442 | ||
1443 | + /*** | ||
1444 | + * | ||
1445 | + */ | ||
1131 | @RequestMapping(value = "/schooladmin", produces = "application/json;charset=UTF-8") | 1446 | @RequestMapping(value = "/schooladmin", produces = "application/json;charset=UTF-8") |
1132 | @ResponseBody | 1447 | @ResponseBody |
1133 | public void schoolAdmin() { | 1448 | public void schoolAdmin() { |
@@ -1136,6 +1451,12 @@ public class V1 extends BaseController { | @@ -1136,6 +1451,12 @@ public class V1 extends BaseController { | ||
1136 | this.getUserID(); | 1451 | this.getUserID(); |
1137 | } | 1452 | } |
1138 | 1453 | ||
1454 | + | ||
1455 | + /*** | ||
1456 | + * 网络 | ||
1457 | + * @return | ||
1458 | + * @throws Exception | ||
1459 | + */ | ||
1139 | @RequestMapping(value = "/network", produces = "application/json;charset=UTF-8") | 1460 | @RequestMapping(value = "/network", produces = "application/json;charset=UTF-8") |
1140 | @ResponseBody | 1461 | @ResponseBody |
1141 | public Object network() throws Exception { | 1462 | public Object network() throws Exception { |
@@ -1184,6 +1505,10 @@ public class V1 extends BaseController { | @@ -1184,6 +1505,10 @@ public class V1 extends BaseController { | ||
1184 | return res.toJson(); | 1505 | return res.toJson(); |
1185 | } | 1506 | } |
1186 | 1507 | ||
1508 | + /** | ||
1509 | + * 获取远端ip地址 | ||
1510 | + * @return | ||
1511 | + */ | ||
1187 | public String getRemoteIp() { | 1512 | public String getRemoteIp() { |
1188 | HttpServletRequest request = getRequest(); | 1513 | HttpServletRequest request = getRequest(); |
1189 | String ip = ""; | 1514 | String ip = ""; |
@@ -1195,6 +1520,12 @@ public class V1 extends BaseController { | @@ -1195,6 +1520,12 @@ public class V1 extends BaseController { | ||
1195 | return ip; | 1520 | return ip; |
1196 | } | 1521 | } |
1197 | 1522 | ||
1523 | + /** | ||
1524 | + * 查询新版本信息 | ||
1525 | + * @param request | ||
1526 | + * @return | ||
1527 | + * @throws Exception | ||
1528 | + */ | ||
1198 | @RequestMapping(value = "/newversion", produces = "application/json;charset=UTF-8") | 1529 | @RequestMapping(value = "/newversion", produces = "application/json;charset=UTF-8") |
1199 | @ResponseBody | 1530 | @ResponseBody |
1200 | public Object getNewVersion(HttpServletRequest request) throws Exception { | 1531 | public Object getNewVersion(HttpServletRequest request) throws Exception { |
@@ -1246,7 +1577,8 @@ public class V1 extends BaseController { | @@ -1246,7 +1577,8 @@ public class V1 extends BaseController { | ||
1246 | for (String sub : subs) { | 1577 | for (String sub : subs) { |
1247 | if (subjectID.trim().equals(sub.trim())) { | 1578 | if (subjectID.trim().equals(sub.trim())) { |
1248 | pad.remove("SUBJECT_ID"); | 1579 | pad.remove("SUBJECT_ID"); |
1249 | - pad.put("VERSION_CODE", pad.getString("VERSION_CODE")); | 1580 | + pad.put("VERSION_CODE", |
1581 | + pad.getString("VERSION_CODE")); | ||
1250 | lpd.add(pad); | 1582 | lpd.add(pad); |
1251 | break; | 1583 | break; |
1252 | } | 1584 | } |
@@ -1264,7 +1596,7 @@ public class V1 extends BaseController { | @@ -1264,7 +1596,7 @@ public class V1 extends BaseController { | ||
1264 | ret.setData(lpd); | 1596 | ret.setData(lpd); |
1265 | return ret.toJson(); | 1597 | return ret.toJson(); |
1266 | } | 1598 | } |
1267 | - | 1599 | + |
1268 | /** | 1600 | /** |
1269 | * 获取教材版本 | 1601 | * 获取教材版本 |
1270 | * | 1602 | * |
@@ -1275,35 +1607,34 @@ public class V1 extends BaseController { | @@ -1275,35 +1607,34 @@ public class V1 extends BaseController { | ||
1275 | @ResponseBody | 1607 | @ResponseBody |
1276 | public Object chapter() throws Exception { | 1608 | public Object chapter() throws Exception { |
1277 | PageData pd = getPageData(); | 1609 | PageData pd = getPageData(); |
1278 | - String key = this.getRequestKey(pd,"chapter"); | 1610 | + String key = this.getRequestKey(pd, "chapter"); |
1279 | PageData pagedata = new PageData(); | 1611 | PageData pagedata = new PageData(); |
1280 | pagedata.put("KEY", key); | 1612 | pagedata.put("KEY", key); |
1281 | - if(!"".equals(key.trim())){ | 1613 | + if (!"".equals(key.trim())) { |
1282 | PageData ret = cacheService.findById(pagedata); | 1614 | PageData ret = cacheService.findById(pagedata); |
1283 | - if(ret != null && ret.get("CACHE") != null){ | 1615 | + if (ret != null && ret.get("CACHE") != null) { |
1284 | return ret.get("CACHE"); | 1616 | return ret.get("CACHE"); |
1285 | } | 1617 | } |
1286 | } | 1618 | } |
1287 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); | 1619 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); |
1288 | List<PageData> list = chapterService.listAllChapter(pd); | 1620 | List<PageData> list = chapterService.listAllChapter(pd); |
1289 | String depth = pd.getString("DEPTH"); | 1621 | String depth = pd.getString("DEPTH"); |
1290 | - int end = 3 ; | ||
1291 | - if(depth != null){ | ||
1292 | - try{ | 1622 | + int end = 3; |
1623 | + if (depth != null) { | ||
1624 | + try { | ||
1293 | end = Integer.parseInt(depth); | 1625 | end = Integer.parseInt(depth); |
1294 | - }catch(Exception e){ | ||
1295 | - | 1626 | + } catch (Exception e) { |
1627 | + | ||
1296 | } | 1628 | } |
1297 | } | 1629 | } |
1298 | - roundChapterData(list,1,end); | 1630 | + roundChapterData(list, 1, end); |
1299 | res.setData(list); | 1631 | res.setData(list); |
1300 | String str = res.toJson(); | 1632 | String str = res.toJson(); |
1301 | - str = str.replaceAll("[^\\u0000-\\uFFFF]", ""); | ||
1302 | pagedata.put("CACHE", str); | 1633 | pagedata.put("CACHE", str); |
1303 | cacheService.save(pagedata); | 1634 | cacheService.save(pagedata); |
1304 | return str; | 1635 | return str; |
1305 | } | 1636 | } |
1306 | - | 1637 | + |
1307 | /** | 1638 | /** |
1308 | * 获取试题 | 1639 | * 获取试题 |
1309 | * | 1640 | * |
@@ -1317,37 +1648,39 @@ public class V1 extends BaseController { | @@ -1317,37 +1648,39 @@ public class V1 extends BaseController { | ||
1317 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); | 1648 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); |
1318 | String teachingmaterialId = pd.getString("TEACHINGMATERIAL_ID"); | 1649 | String teachingmaterialId = pd.getString("TEACHINGMATERIAL_ID"); |
1319 | String chapterId = pd.getString("CHAPTER_ID"); | 1650 | String chapterId = pd.getString("CHAPTER_ID"); |
1320 | - if(teachingmaterialId != null && !teachingmaterialId.equals("") && chapterId == null){ | 1651 | + if (teachingmaterialId != null && !teachingmaterialId.equals("") |
1652 | + && chapterId == null) { | ||
1321 | PageData chapterPd = new PageData(); | 1653 | PageData chapterPd = new PageData(); |
1322 | chapterPd.put("TEACHINGMATERIAL_ID", teachingmaterialId); | 1654 | chapterPd.put("TEACHINGMATERIAL_ID", teachingmaterialId); |
1323 | - List<PageData> chapterList = chapterService.listAllChapter(chapterPd); | 1655 | + List<PageData> chapterList = chapterService |
1656 | + .listAllChapter(chapterPd); | ||
1324 | roundChapterData(chapterList, 1, 3); | 1657 | roundChapterData(chapterList, 1, 3); |
1325 | - List<String> ids = getIds(chapterList,"ID"); | 1658 | + List<String> ids = getIds(chapterList, "ID"); |
1326 | pd.put("CHAPTER_IDS", ids); | 1659 | pd.put("CHAPTER_IDS", ids); |
1327 | - }else{ | 1660 | + } else { |
1328 | List<String> ids = new ArrayList<String>(); | 1661 | List<String> ids = new ArrayList<String>(); |
1329 | - if(chapterId != null && !"".equals(chapterId.trim())){ | 1662 | + if (chapterId != null && !"".equals(chapterId.trim())) { |
1330 | ids.add(chapterId); | 1663 | ids.add(chapterId); |
1331 | } | 1664 | } |
1332 | pd.put("CHAPTER_IDS", ids); | 1665 | pd.put("CHAPTER_IDS", ids); |
1333 | } | 1666 | } |
1334 | pd.remove("CHAPTER_ID"); | 1667 | pd.remove("CHAPTER_ID"); |
1335 | String knowledge = pd.getString("KNOWLEDGE_ID"); | 1668 | String knowledge = pd.getString("KNOWLEDGE_ID"); |
1336 | - if(knowledge != null && !"".equals(knowledge.trim())){ | 1669 | + if (knowledge != null && !"".equals(knowledge.trim())) { |
1337 | PageData knowPd = new PageData(); | 1670 | PageData knowPd = new PageData(); |
1338 | knowPd.put("P_ID", knowledge); | 1671 | knowPd.put("P_ID", knowledge); |
1339 | List<PageData> knowlist = knowledgeService.listAllknowledge(knowPd); | 1672 | List<PageData> knowlist = knowledgeService.listAllknowledge(knowPd); |
1340 | roundPointData(knowlist, 1, 3); | 1673 | roundPointData(knowlist, 1, 3); |
1341 | - List<String> ids = getIds(knowlist,"KNOWLEDGE_ID"); | 1674 | + List<String> ids = getIds(knowlist, "KNOWLEDGE_ID"); |
1342 | ids.add(knowledge); | 1675 | ids.add(knowledge); |
1343 | - pd.put("KNOWLEDGE_IDS",ids); | 1676 | + pd.put("KNOWLEDGE_IDS", ids); |
1344 | pd.remove("KNOWLEDGE_ID"); | 1677 | pd.remove("KNOWLEDGE_ID"); |
1345 | } | 1678 | } |
1346 | List<PageData> list = questionService.listAllquestion(pd); | 1679 | List<PageData> list = questionService.listAllquestion(pd); |
1347 | res.setData(list); | 1680 | res.setData(list); |
1348 | return res.toJson(); | 1681 | return res.toJson(); |
1349 | } | 1682 | } |
1350 | - | 1683 | + |
1351 | /** | 1684 | /** |
1352 | * 随机获取试题 | 1685 | * 随机获取试题 |
1353 | * | 1686 | * |
@@ -1361,61 +1694,75 @@ public class V1 extends BaseController { | @@ -1361,61 +1694,75 @@ public class V1 extends BaseController { | ||
1361 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); | 1694 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); |
1362 | String teachingmaterialId = pd.getString("TEACHINGMATERIAL_ID"); | 1695 | String teachingmaterialId = pd.getString("TEACHINGMATERIAL_ID"); |
1363 | String chapterId = pd.getString("CHAPTER_ID"); | 1696 | String chapterId = pd.getString("CHAPTER_ID"); |
1364 | - if(teachingmaterialId != null && !teachingmaterialId.equals("") && chapterId == null){ | 1697 | + if (teachingmaterialId != null && !teachingmaterialId.equals("") |
1698 | + && chapterId == null) { | ||
1365 | PageData chapterPd = new PageData(); | 1699 | PageData chapterPd = new PageData(); |
1366 | chapterPd.put("TEACHINGMATERIAL_ID", teachingmaterialId); | 1700 | chapterPd.put("TEACHINGMATERIAL_ID", teachingmaterialId); |
1367 | - List<PageData> chapterList = chapterService.listAllChapter(chapterPd); | 1701 | + List<PageData> chapterList = chapterService |
1702 | + .listAllChapter(chapterPd); | ||
1368 | roundChapterData(chapterList, 1, 3); | 1703 | roundChapterData(chapterList, 1, 3); |
1369 | - List<String> ids = getIds(chapterList,"ID"); | 1704 | + List<String> ids = getIds(chapterList, "ID"); |
1370 | pd.put("CHAPTER_IDS", ids); | 1705 | pd.put("CHAPTER_IDS", ids); |
1371 | - }else{ | 1706 | + } else { |
1372 | List<String> ids = new ArrayList<String>(); | 1707 | List<String> ids = new ArrayList<String>(); |
1373 | - if(chapterId != null && !"".equals(chapterId.trim())){ | 1708 | + if (chapterId != null && !"".equals(chapterId.trim())) { |
1374 | ids.add(chapterId); | 1709 | ids.add(chapterId); |
1375 | } | 1710 | } |
1376 | pd.put("CHAPTER_IDS", ids); | 1711 | pd.put("CHAPTER_IDS", ids); |
1377 | } | 1712 | } |
1378 | pd.remove("CHAPTER_ID"); | 1713 | pd.remove("CHAPTER_ID"); |
1379 | String knowledge = pd.getString("KNOWLEDGE_ID"); | 1714 | String knowledge = pd.getString("KNOWLEDGE_ID"); |
1380 | - if(knowledge != null && !"".equals(knowledge.trim())){ | 1715 | + if (knowledge != null && !"".equals(knowledge.trim())) { |
1381 | PageData knowPd = new PageData(); | 1716 | PageData knowPd = new PageData(); |
1382 | knowPd.put("P_ID", knowledge); | 1717 | knowPd.put("P_ID", knowledge); |
1383 | List<PageData> knowlist = knowledgeService.listAllknowledge(knowPd); | 1718 | List<PageData> knowlist = knowledgeService.listAllknowledge(knowPd); |
1384 | roundPointData(knowlist, 1, 3); | 1719 | roundPointData(knowlist, 1, 3); |
1385 | - List<String> ids = getIds(knowlist,"KNOWLEDGE_ID"); | 1720 | + List<String> ids = getIds(knowlist, "KNOWLEDGE_ID"); |
1386 | ids.add(knowledge); | 1721 | ids.add(knowledge); |
1387 | - pd.put("KNOWLEDGE_IDS",ids); | 1722 | + pd.put("KNOWLEDGE_IDS", ids); |
1388 | pd.remove("KNOWLEDGE_ID"); | 1723 | pd.remove("KNOWLEDGE_ID"); |
1389 | } | 1724 | } |
1390 | List<PageData> list = questionService.listAllRandquestion(pd); | 1725 | List<PageData> list = questionService.listAllRandquestion(pd); |
1391 | res.setData(list); | 1726 | res.setData(list); |
1392 | return res.toJson(); | 1727 | return res.toJson(); |
1393 | } | 1728 | } |
1394 | - | ||
1395 | - public List<String> getIds(List<PageData> chapterList,String key){ | 1729 | + |
1730 | + /** | ||
1731 | + * | ||
1732 | + * @param chapterList | ||
1733 | + * @param key | ||
1734 | + * @return | ||
1735 | + */ | ||
1736 | + public List<String> getIds(List<PageData> chapterList, String key) { | ||
1396 | List<String> ids = new ArrayList<String>(); | 1737 | List<String> ids = new ArrayList<String>(); |
1397 | - if(chapterList != null && chapterList.size() > 0){ | ||
1398 | - for(PageData pd : chapterList){ | 1738 | + if (chapterList != null && chapterList.size() > 0) { |
1739 | + for (PageData pd : chapterList) { | ||
1399 | String chapterid = pd.getString(key); | 1740 | String chapterid = pd.getString(key); |
1400 | - if(chapterid != null && !"".equals(chapterid)){ | 1741 | + if (chapterid != null && !"".equals(chapterid)) { |
1401 | ids.add(chapterid); | 1742 | ids.add(chapterid); |
1402 | } | 1743 | } |
1403 | Object obj = pd.get("CHILDREN"); | 1744 | Object obj = pd.get("CHILDREN"); |
1404 | - if(obj != null && (obj instanceof List)){ | 1745 | + if (obj != null && (obj instanceof List)) { |
1405 | @SuppressWarnings("unchecked") | 1746 | @SuppressWarnings("unchecked") |
1406 | - List<PageData> list = (List<PageData>)obj ; | ||
1407 | - List<String> ret = getIds(list,key); | ||
1408 | - if(ret != null && ret.size() > 0){ | 1747 | + List<PageData> list = (List<PageData>) obj; |
1748 | + List<String> ret = getIds(list, key); | ||
1749 | + if (ret != null && ret.size() > 0) { | ||
1409 | ids.addAll(ret); | 1750 | ids.addAll(ret); |
1410 | } | 1751 | } |
1411 | } | 1752 | } |
1412 | } | 1753 | } |
1413 | } | 1754 | } |
1414 | - | 1755 | + |
1415 | return ids; | 1756 | return ids; |
1416 | - | 1757 | + |
1417 | } | 1758 | } |
1418 | 1759 | ||
1760 | + | ||
1761 | + /** | ||
1762 | + * | ||
1763 | + * @return | ||
1764 | + * @throws Exception | ||
1765 | + */ | ||
1419 | @RequestMapping(value = "/tempcreateUser", produces = "application/json;charset=UTF-8") | 1766 | @RequestMapping(value = "/tempcreateUser", produces = "application/json;charset=UTF-8") |
1420 | @ResponseBody | 1767 | @ResponseBody |
1421 | public Object tempCreateUser() throws Exception { | 1768 | public Object tempCreateUser() throws Exception { |
@@ -1451,6 +1798,10 @@ public class V1 extends BaseController { | @@ -1451,6 +1798,10 @@ public class V1 extends BaseController { | ||
1451 | return "{'res':'success'}"; | 1798 | return "{'res':'success'}"; |
1452 | } | 1799 | } |
1453 | 1800 | ||
1801 | + /** | ||
1802 | + * | ||
1803 | + * @param apiName | ||
1804 | + */ | ||
1454 | private void event(String apiName) { | 1805 | private void event(String apiName) { |
1455 | PageData eventPd = new PageData(); | 1806 | PageData eventPd = new PageData(); |
1456 | eventPd.put("EVENT_ID", get32UUID()); | 1807 | eventPd.put("EVENT_ID", get32UUID()); |
@@ -1469,6 +1820,11 @@ public class V1 extends BaseController { | @@ -1469,6 +1820,11 @@ public class V1 extends BaseController { | ||
1469 | 1820 | ||
1470 | static int index = 0; | 1821 | static int index = 0; |
1471 | 1822 | ||
1823 | + /** | ||
1824 | + * | ||
1825 | + * @param point | ||
1826 | + * @param pid | ||
1827 | + */ | ||
1472 | private void savePoint(Point point, String pid) { | 1828 | private void savePoint(Point point, String pid) { |
1473 | List<Point> children = point.getChildren(); | 1829 | List<Point> children = point.getChildren(); |
1474 | if (children != null && children.size() > 0) { | 1830 | if (children != null && children.size() > 0) { |
@@ -1488,6 +1844,11 @@ public class V1 extends BaseController { | @@ -1488,6 +1844,11 @@ public class V1 extends BaseController { | ||
1488 | } | 1844 | } |
1489 | } | 1845 | } |
1490 | 1846 | ||
1847 | + /** | ||
1848 | + * | ||
1849 | + * @return | ||
1850 | + * @throws Exception | ||
1851 | + */ | ||
1491 | @RequestMapping(value = "/uploadbook", produces = "application/json;charset=UTF-8") | 1852 | @RequestMapping(value = "/uploadbook", produces = "application/json;charset=UTF-8") |
1492 | @ResponseBody | 1853 | @ResponseBody |
1493 | public Object uploadbook() throws Exception { | 1854 | public Object uploadbook() throws Exception { |
@@ -1517,6 +1878,10 @@ public class V1 extends BaseController { | @@ -1517,6 +1878,10 @@ public class V1 extends BaseController { | ||
1517 | return res.toJson(); | 1878 | return res.toJson(); |
1518 | } | 1879 | } |
1519 | 1880 | ||
1881 | + /** | ||
1882 | + * | ||
1883 | + * @param point | ||
1884 | + */ | ||
1520 | private void saveBook(Point point) { | 1885 | private void saveBook(Point point) { |
1521 | 1886 | ||
1522 | PageData pd = new PageData(); | 1887 | PageData pd = new PageData(); |
@@ -1530,8 +1895,12 @@ public class V1 extends BaseController { | @@ -1530,8 +1895,12 @@ public class V1 extends BaseController { | ||
1530 | e.printStackTrace(); | 1895 | e.printStackTrace(); |
1531 | } | 1896 | } |
1532 | } | 1897 | } |
1533 | - | ||
1534 | - | 1898 | + |
1899 | + /** | ||
1900 | + * | ||
1901 | + * @return | ||
1902 | + * @throws Exception | ||
1903 | + */ | ||
1535 | @RequestMapping(value = "/uploadyuncelianquestion", produces = "application/json;charset=UTF-8") | 1904 | @RequestMapping(value = "/uploadyuncelianquestion", produces = "application/json;charset=UTF-8") |
1536 | @ResponseBody | 1905 | @ResponseBody |
1537 | public Object uploadyuncelianquestion() throws Exception { | 1906 | public Object uploadyuncelianquestion() throws Exception { |
@@ -1542,99 +1911,100 @@ public class V1 extends BaseController { | @@ -1542,99 +1911,100 @@ public class V1 extends BaseController { | ||
1542 | 1911 | ||
1543 | if (!StringUtils.isEmpty(pd.getJsonString())) { | 1912 | if (!StringUtils.isEmpty(pd.getJsonString())) { |
1544 | try { | 1913 | try { |
1545 | - ResponseGson<Object> req = ResponseGson.parse( | ||
1546 | - pd.getJsonString()); | 1914 | + ResponseGson<Object> req = ResponseGson.parse(pd |
1915 | + .getJsonString()); | ||
1547 | Object data = req.getData(); | 1916 | Object data = req.getData(); |
1548 | - if(data instanceof List){ | ||
1549 | - List<Object> list = (List)data; | ||
1550 | - for(Object obj : list){ | ||
1551 | - if(obj instanceof Map){ | ||
1552 | - Map map = (Map)obj; | ||
1553 | - | 1917 | + if (data instanceof List) { |
1918 | + List<Object> list = (List) data; | ||
1919 | + for (Object obj : list) { | ||
1920 | + if (obj instanceof Map) { | ||
1921 | + Map map = (Map) obj; | ||
1922 | + | ||
1554 | PageData pageData = new PageData(); | 1923 | PageData pageData = new PageData(); |
1555 | pageData.put("QUESTION_ID", map.get("id")); | 1924 | pageData.put("QUESTION_ID", map.get("id")); |
1556 | Object cateObj = map.get("cate"); | 1925 | Object cateObj = map.get("cate"); |
1557 | - if(cateObj != null){ | 1926 | + if (cateObj != null) { |
1558 | String cate = cateObj.toString(); | 1927 | String cate = cateObj.toString(); |
1559 | float catef = Float.parseFloat(cate); | 1928 | float catef = Float.parseFloat(cate); |
1560 | - pageData.put("QUESTION_TYPE_ID", (int)catef); | 1929 | + pageData.put("QUESTION_TYPE_ID", (int) catef); |
1561 | } | 1930 | } |
1562 | Object contentObj = map.get("content"); | 1931 | Object contentObj = map.get("content"); |
1563 | - if(contentObj != null){ | 1932 | + if (contentObj != null) { |
1564 | String content = contentObj.toString(); | 1933 | String content = contentObj.toString(); |
1565 | content = replaceWebUrl(content); | 1934 | content = replaceWebUrl(content); |
1566 | pageData.put("CONTENT", content); | 1935 | pageData.put("CONTENT", content); |
1567 | } | 1936 | } |
1568 | Object subjectCodeObj = map.get("subjectCode"); | 1937 | Object subjectCodeObj = map.get("subjectCode"); |
1569 | - if(subjectCodeObj != null){ | 1938 | + if (subjectCodeObj != null) { |
1570 | String subjectCode = subjectCodeObj.toString(); | 1939 | String subjectCode = subjectCodeObj.toString(); |
1571 | - pageData.put("SUBJECT_ID",subjectCode); | 1940 | + pageData.put("SUBJECT_ID", subjectCode); |
1572 | } | 1941 | } |
1573 | Object optionsObj = map.get("options"); | 1942 | Object optionsObj = map.get("options"); |
1574 | - if(optionsObj instanceof List){ | ||
1575 | - List ss = (List)optionsObj; | ||
1576 | - pageData.put("OPTION_CONTENT", optionsObj.toString()); | 1943 | + if (optionsObj instanceof List) { |
1944 | + List ss = (List) optionsObj; | ||
1945 | + pageData.put("OPTION_CONTENT", | ||
1946 | + optionsObj.toString()); | ||
1577 | pageData.put("OPTION_NUM", "" + ss.size()); | 1947 | pageData.put("OPTION_NUM", "" + ss.size()); |
1578 | } | 1948 | } |
1579 | Object answersObj = map.get("answers"); | 1949 | Object answersObj = map.get("answers"); |
1580 | - if(answersObj instanceof List){ | ||
1581 | - List answers = (List)answersObj; | 1950 | + if (answersObj instanceof List) { |
1951 | + List answers = (List) answersObj; | ||
1582 | StringBuilder sb = new StringBuilder(); | 1952 | StringBuilder sb = new StringBuilder(); |
1583 | - for(Object as:answers){ | 1953 | + for (Object as : answers) { |
1584 | sb.append(as.toString()); | 1954 | sb.append(as.toString()); |
1585 | } | 1955 | } |
1586 | pageData.put("ANSWER", sb.toString()); | 1956 | pageData.put("ANSWER", sb.toString()); |
1587 | } | 1957 | } |
1588 | - Object difficulty = map.get("difficulty"); | ||
1589 | - try{ | 1958 | + Object difficulty = map.get("difficulty"); |
1959 | + try { | ||
1590 | if (difficulty != null) { | 1960 | if (difficulty != null) { |
1591 | float fdifficulty = Float | 1961 | float fdifficulty = Float |
1592 | .parseFloat(difficulty.toString()); | 1962 | .parseFloat(difficulty.toString()); |
1593 | pageData.put("DIFFICULTY", | 1963 | pageData.put("DIFFICULTY", |
1594 | (int) fdifficulty); | 1964 | (int) fdifficulty); |
1595 | } | 1965 | } |
1596 | - }catch(Exception ex){ | 1966 | + } catch (Exception ex) { |
1597 | ex.printStackTrace(); | 1967 | ex.printStackTrace(); |
1598 | } | 1968 | } |
1599 | Object discussObj = map.get("discuss"); | 1969 | Object discussObj = map.get("discuss"); |
1600 | - if(discussObj != null){ | 1970 | + if (discussObj != null) { |
1601 | String discuss = discussObj.toString(); | 1971 | String discuss = discussObj.toString(); |
1602 | discuss = replaceWebUrl(discuss); | 1972 | discuss = replaceWebUrl(discuss); |
1603 | pageData.put("REMARK", discuss); | 1973 | pageData.put("REMARK", discuss); |
1604 | } | 1974 | } |
1605 | Object analyseObj = map.get("analyse"); | 1975 | Object analyseObj = map.get("analyse"); |
1606 | - if(analyseObj != null){ | 1976 | + if (analyseObj != null) { |
1607 | String analyse = analyseObj.toString(); | 1977 | String analyse = analyseObj.toString(); |
1608 | analyse = replaceWebUrl(analyse); | 1978 | analyse = replaceWebUrl(analyse); |
1609 | pageData.put("ANALYSIS", analyse); | 1979 | pageData.put("ANALYSIS", analyse); |
1610 | } | 1980 | } |
1611 | Object methodObj = map.get("method"); | 1981 | Object methodObj = map.get("method"); |
1612 | - if(methodObj != null){ | 1982 | + if (methodObj != null) { |
1613 | String method = methodObj.toString(); | 1983 | String method = methodObj.toString(); |
1614 | method = replaceWebUrl(method); | 1984 | method = replaceWebUrl(method); |
1615 | pageData.put("METHOD", method); | 1985 | pageData.put("METHOD", method); |
1616 | } | 1986 | } |
1617 | Object points = map.get("points"); | 1987 | Object points = map.get("points"); |
1618 | StringBuilder sb = new StringBuilder(); | 1988 | StringBuilder sb = new StringBuilder(); |
1619 | - if(points instanceof List){ | ||
1620 | - List pointsList = (List)points; | ||
1621 | - for(Object pObject : pointsList){ | ||
1622 | - if(pObject instanceof Map){ | ||
1623 | - Map pMap = (Map)pObject; | 1989 | + if (points instanceof List) { |
1990 | + List pointsList = (List) points; | ||
1991 | + for (Object pObject : pointsList) { | ||
1992 | + if (pObject instanceof Map) { | ||
1993 | + Map pMap = (Map) pObject; | ||
1624 | sb.append(pMap.get("code")).append(","); | 1994 | sb.append(pMap.get("code")).append(","); |
1625 | } | 1995 | } |
1626 | } | 1996 | } |
1627 | - | ||
1628 | - if(sb.toString().length() > 1){ | 1997 | + |
1998 | + if (sb.toString().length() > 1) { | ||
1629 | sb.deleteCharAt(sb.length() - 1); | 1999 | sb.deleteCharAt(sb.length() - 1); |
1630 | } | 2000 | } |
1631 | pageData.put("KNOWLEDGE_ID", sb.toString()); | 2001 | pageData.put("KNOWLEDGE_ID", sb.toString()); |
1632 | } | 2002 | } |
1633 | pageData.put("QUESTION_FROM", "101"); | 2003 | pageData.put("QUESTION_FROM", "101"); |
1634 | - try{ | 2004 | + try { |
1635 | questionService.save(pageData); | 2005 | questionService.save(pageData); |
1636 | - }catch(Exception e){ | ||
1637 | - logger.error("save fail:" + map.get("id"),e); | 2006 | + } catch (Exception e) { |
2007 | + logger.error("save fail:" + map.get("id"), e); | ||
1638 | } | 2008 | } |
1639 | } | 2009 | } |
1640 | } | 2010 | } |
@@ -1650,17 +2020,28 @@ public class V1 extends BaseController { | @@ -1650,17 +2020,28 @@ public class V1 extends BaseController { | ||
1650 | return res.toJson(); | 2020 | return res.toJson(); |
1651 | } | 2021 | } |
1652 | 2022 | ||
1653 | - | ||
1654 | - private String replaceWebUrl(String content){ | ||
1655 | - if(content != null){ | ||
1656 | - content = content.replaceAll("http://image.yuncelian.com/1/analysis/", "http://image.yuncelian.com/1/analysis/"); | 2023 | + /** |
2024 | + * | ||
2025 | + * @param content | ||
2026 | + * @return | ||
2027 | + */ | ||
2028 | + private String replaceWebUrl(String content) { | ||
2029 | + if (content != null) { | ||
2030 | + content = content.replaceAll( | ||
2031 | + "http://image.yuncelian.com/1/analysis/", | ||
2032 | + "http://image.yuncelian.com/1/analysis/"); | ||
1657 | } | 2033 | } |
1658 | return content; | 2034 | return content; |
1659 | } | 2035 | } |
1660 | - | ||
1661 | - | ||
1662 | - public String getRequestKey(PageData pd,String methodName){ | ||
1663 | - StringBuilder key = new StringBuilder() ; | 2036 | + |
2037 | + /** | ||
2038 | + * | ||
2039 | + * @param pd | ||
2040 | + * @param methodName | ||
2041 | + * @return | ||
2042 | + */ | ||
2043 | + public String getRequestKey(PageData pd, String methodName) { | ||
2044 | + StringBuilder key = new StringBuilder(); | ||
1664 | key.append(methodName).append("{"); | 2045 | key.append(methodName).append("{"); |
1665 | if (pd != null) { | 2046 | if (pd != null) { |
1666 | Iterator iterator = pd.keySet().iterator(); | 2047 | Iterator iterator = pd.keySet().iterator(); |
@@ -1671,7 +2052,7 @@ public class V1 extends BaseController { | @@ -1671,7 +2052,7 @@ public class V1 extends BaseController { | ||
1671 | } | 2052 | } |
1672 | } | 2053 | } |
1673 | key.append("}"); | 2054 | key.append("}"); |
1674 | - | 2055 | + |
1675 | return key.toString(); | 2056 | return key.toString(); |
1676 | } | 2057 | } |
1677 | } | 2058 | } |