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 | 21 | PAPER_STATE, |
22 | 22 | REMARK, |
23 | 23 | SCORE, |
24 | + CLASS_ID, | |
24 | 25 | QUESTION_NUM, |
25 | 26 | PAPER_ID |
26 | 27 | </sql> |
... | ... | @@ -39,6 +40,7 @@ |
39 | 40 | #{PAPER_STATE}, |
40 | 41 | #{REMARK}, |
41 | 42 | #{SCORE}, |
43 | + #{CLASS_ID}, | |
42 | 44 | #{QUESTION_NUM}, |
43 | 45 | #{PAPER_ID} |
44 | 46 | </sql> |
... | ... | @@ -79,6 +81,7 @@ |
79 | 81 | PAPER_STATE = #{PAPER_STATE}, |
80 | 82 | REMARK = #{REMARK}, |
81 | 83 | SCORE = #{SCORE}, |
84 | + CLASS_ID = #{CLASS_ID}, | |
82 | 85 | QUESTION_NUM = #{QUESTION_NUM}, |
83 | 86 | PAPER_ID = PAPER_ID |
84 | 87 | where |
... | ... | @@ -128,6 +131,9 @@ |
128 | 131 | <if test="pd.USER_ID != null and pd.USER_ID != ''"><!-- 关键词检索 --> |
129 | 132 | and USER_ID = #{pd.USER_ID} |
130 | 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 | 138 | order by CREATE_DATE DESC |
133 | 139 | </select> |
... | ... | @@ -159,6 +165,9 @@ |
159 | 165 | <if test="pd.SUBJECT_ID != null and pd.SUBJECT_ID != ''"> |
160 | 166 | and SUBJECT_ID = #{pd.SUBJECT_ID} |
161 | 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 | 172 | order by CREATE_DATE DESC |
164 | 173 | </select> | ... | ... |
src/com/fh/bean/Question.java
src/com/fh/controller/api/ResponseGson.java
... | ... | @@ -45,6 +45,11 @@ public class ResponseGson<T> { |
45 | 45 | Gson gson = new GsonBuilder().serializeNulls().create(); |
46 | 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 | 54 | @Override |
50 | 55 | public String toString() { | ... | ... |
src/com/fh/controller/api/V1.java
... | ... | @@ -171,10 +171,17 @@ public class V1 extends BaseController { |
171 | 171 | |
172 | 172 | @Resource(name = "teachingmaterialService") |
173 | 173 | private TeachingMaterialManager teachingmaterialService; |
174 | - | |
175 | - @Resource(name="cacheService") | |
174 | + | |
175 | + @Resource(name = "cacheService") | |
176 | 176 | private CacheManager cacheService; |
177 | 177 | |
178 | + /** | |
179 | + * 登录 | |
180 | + * 可以通过账号密码登录、 | |
181 | + * 可以通过教师卡登录 | |
182 | + * @return | |
183 | + * @throws Exception | |
184 | + */ | |
178 | 185 | @RequestMapping(value = "/login", produces = "application/json;charset=UTF-8") |
179 | 186 | @ResponseBody |
180 | 187 | public Object login() throws Exception { |
... | ... | @@ -231,6 +238,12 @@ public class V1 extends BaseController { |
231 | 238 | return res.toJson(); |
232 | 239 | } |
233 | 240 | |
241 | + /** | |
242 | + * 查询班级 | |
243 | + * 班级及班级学生详细信息 | |
244 | + * @return | |
245 | + * @throws Exception | |
246 | + */ | |
234 | 247 | @RequestMapping(value = "/class", produces = "application/json;charset=UTF-8") |
235 | 248 | @ResponseBody |
236 | 249 | public Object sclass() throws Exception { |
... | ... | @@ -266,6 +279,11 @@ public class V1 extends BaseController { |
266 | 279 | } |
267 | 280 | } |
268 | 281 | |
282 | + /** | |
283 | + * 问题类型 | |
284 | + * @return | |
285 | + * @throws Exception | |
286 | + */ | |
269 | 287 | @RequestMapping(value = "/questiontype", produces = "application/json;charset=UTF-8") |
270 | 288 | @ResponseBody |
271 | 289 | public Object questiontype() throws Exception { |
... | ... | @@ -280,6 +298,11 @@ public class V1 extends BaseController { |
280 | 298 | return res.toJson(); |
281 | 299 | } |
282 | 300 | |
301 | + /** | |
302 | + * 班级类型 | |
303 | + * @return | |
304 | + * @throws Exception | |
305 | + */ | |
283 | 306 | @RequestMapping(value = "/classtype", produces = "application/json;charset=UTF-8") |
284 | 307 | @ResponseBody |
285 | 308 | public Object classtype() throws Exception { |
... | ... | @@ -294,6 +317,12 @@ public class V1 extends BaseController { |
294 | 317 | return res.toJson(); |
295 | 318 | } |
296 | 319 | |
320 | + /** | |
321 | + * 年级 | |
322 | + * 年级类型 | |
323 | + * @return | |
324 | + * @throws Exception | |
325 | + */ | |
297 | 326 | @RequestMapping(value = "/grade", produces = "application/json;charset=UTF-8") |
298 | 327 | @ResponseBody |
299 | 328 | public Object grade() throws Exception { |
... | ... | @@ -312,6 +341,11 @@ public class V1 extends BaseController { |
312 | 341 | return res.toJson(); |
313 | 342 | } |
314 | 343 | |
344 | + /** | |
345 | + * 科目 | |
346 | + * @return | |
347 | + * @throws Exception | |
348 | + */ | |
315 | 349 | @RequestMapping(value = "/subject", produces = "application/json;charset=UTF-8") |
316 | 350 | @ResponseBody |
317 | 351 | public Object subject() throws Exception { |
... | ... | @@ -330,6 +364,11 @@ public class V1 extends BaseController { |
330 | 364 | return res.toJson(); |
331 | 365 | } |
332 | 366 | |
367 | + /** | |
368 | + * 键盘扫描 | |
369 | + * @return | |
370 | + * @throws Exception | |
371 | + */ | |
333 | 372 | @RequestMapping(value = "/keypadscan", produces = "application/json;charset=UTF-8") |
334 | 373 | @ResponseBody |
335 | 374 | public Object keypadScan() throws Exception { |
... | ... | @@ -352,6 +391,12 @@ public class V1 extends BaseController { |
352 | 391 | return res.toJson(); |
353 | 392 | } |
354 | 393 | |
394 | + /** | |
395 | + * showcount 数量 currentpage 当前页码 | |
396 | + * | |
397 | + * @return | |
398 | + * @throws Exception | |
399 | + */ | |
355 | 400 | @RequestMapping(value = "/paper", produces = "application/json;charset=UTF-8") |
356 | 401 | @ResponseBody |
357 | 402 | public Object paper() throws Exception { |
... | ... | @@ -389,6 +434,11 @@ public class V1 extends BaseController { |
389 | 434 | return res.toJson(); |
390 | 435 | } |
391 | 436 | |
437 | + /** | |
438 | + * 试卷详细信息 | |
439 | + * @return | |
440 | + * @throws Exception | |
441 | + */ | |
392 | 442 | @RequestMapping(value = "/paperinfo", produces = "application/json;charset=UTF-8") |
393 | 443 | @ResponseBody |
394 | 444 | public Object paperInfo() throws Exception { |
... | ... | @@ -497,6 +547,83 @@ public class V1 extends BaseController { |
497 | 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 | 627 | @RequestMapping(value = "/paperquestion", produces = "application/json;charset=UTF-8") |
501 | 628 | @ResponseBody |
502 | 629 | public Object paperQuestion() throws Exception { |
... | ... | @@ -509,17 +636,30 @@ public class V1 extends BaseController { |
509 | 636 | return res.toJson(); |
510 | 637 | } |
511 | 638 | |
639 | + /** | |
640 | + * 问题 | |
641 | + * @return | |
642 | + * @throws Exception | |
643 | + */ | |
512 | 644 | @RequestMapping(value = "/question", produces = "application/json;charset=UTF-8") |
513 | 645 | @ResponseBody |
514 | 646 | public Object question() throws Exception { |
515 | 647 | event("question"); |
516 | 648 | long cur = System.currentTimeMillis(); |
517 | 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 | 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 | 663 | } else { |
524 | 664 | res.setDataError(); |
525 | 665 | } |
... | ... | @@ -528,6 +668,71 @@ public class V1 extends BaseController { |
528 | 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 | 736 | @RequestMapping(value = "/question/add", produces = "application/json;charset=UTF-8") |
532 | 737 | @ResponseBody |
533 | 738 | public Object questionAdd() throws Exception { |
... | ... | @@ -542,6 +747,11 @@ public class V1 extends BaseController { |
542 | 747 | return res.toJson(); |
543 | 748 | } |
544 | 749 | |
750 | + /*** | |
751 | + * 上传试卷 | |
752 | + * @return | |
753 | + * @throws Exception | |
754 | + */ | |
545 | 755 | @RequestMapping(value = "/uploadpaper", produces = "application/json;charset=UTF-8") |
546 | 756 | @ResponseBody |
547 | 757 | public Object uploadpaper() throws Exception { |
... | ... | @@ -674,6 +884,71 @@ public class V1 extends BaseController { |
674 | 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 | 952 | @RequestMapping(value = "/uploadpoint", produces = "application/json;charset=UTF-8") |
678 | 953 | @ResponseBody |
679 | 954 | public Object uploadpoint() throws Exception { |
... | ... | @@ -703,7 +978,10 @@ public class V1 extends BaseController { |
703 | 978 | return res.toJson(); |
704 | 979 | } |
705 | 980 | |
706 | - // 上传测验成绩 | |
981 | + /** | |
982 | + * 上传测验成绩 | |
983 | + * @return | |
984 | + */ | |
707 | 985 | @RequestMapping(value = "/uploadtestpaper", produces = "application/json;charset=UTF-8") |
708 | 986 | @ResponseBody |
709 | 987 | public Object uploadTestpaper() { |
... | ... | @@ -818,7 +1096,10 @@ public class V1 extends BaseController { |
818 | 1096 | |
819 | 1097 | } |
820 | 1098 | |
821 | - // 上传测验成绩 | |
1099 | + /** | |
1100 | + * 上传测验成绩 | |
1101 | + * @return | |
1102 | + */ | |
822 | 1103 | @RequestMapping(value = "/uploadupdatetestpaper", produces = "application/json;charset=UTF-8") |
823 | 1104 | @ResponseBody |
824 | 1105 | public Object uploadupdateTestpaper() { |
... | ... | @@ -931,41 +1212,54 @@ public class V1 extends BaseController { |
931 | 1212 | |
932 | 1213 | } |
933 | 1214 | |
1215 | + /** | |
1216 | + * 查询知识点 | |
1217 | + * @return | |
1218 | + * @throws Exception | |
1219 | + */ | |
934 | 1220 | @RequestMapping(value = "/point", produces = "application/json;charset=UTF-8") |
935 | 1221 | @ResponseBody |
936 | 1222 | public Object point() throws Exception { |
937 | 1223 | ResponseGson<List<PageData>> res = new ResponseGson(); |
938 | - | |
1224 | + | |
939 | 1225 | PageData pd = getPageData(); |
940 | - String key = this.getRequestKey(pd,"point"); | |
1226 | + String key = this.getRequestKey(pd, "point"); | |
941 | 1227 | PageData pagedata = new PageData(); |
942 | 1228 | pagedata.put("KEY", key); |
943 | - if(!"".equals(key.trim())){ | |
1229 | + if (!"".equals(key.trim())) { | |
944 | 1230 | PageData ret = cacheService.findById(pagedata); |
945 | - if(ret != null && ret.get("CACHE") != null){ | |
1231 | + if (ret != null && ret.get("CACHE") != null) { | |
946 | 1232 | return ret.get("CACHE"); |
947 | 1233 | } |
948 | 1234 | } |
949 | 1235 | List<PageData> list = knowledgeService.listAllknowledge(pd); |
950 | 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 | 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 | 1246 | res.setData(list); |
961 | 1247 | String str = res.toJson(); |
962 | - str = str.replaceAll("[^\u0000-\uFFFF]", ""); | |
1248 | + str = str.replaceAll("[^\u0000-\uFFFF]", ""); | |
963 | 1249 | pagedata.put("CACHE", str); |
964 | 1250 | cacheService.save(pagedata); |
965 | 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 | 1263 | if (list != null) { |
970 | 1264 | for (PageData pd : list) { |
971 | 1265 | pd.put("P_ID", pd.getString("KNOWLEDGE_ID")); |
... | ... | @@ -973,7 +1267,7 @@ public class V1 extends BaseController { |
973 | 1267 | && !"".equals(pd.getString("P_ID")) && dept < end) { |
974 | 1268 | List<PageData> ret = knowledgeService.listAllknowledge(pd); |
975 | 1269 | if (ret != null && ret.size() > 0) { |
976 | - roundPointData(ret,dept + 1,end); | |
1270 | + roundPointData(ret, dept + 1, end); | |
977 | 1271 | pd.put("CHILDREN", ret); |
978 | 1272 | } |
979 | 1273 | } |
... | ... | @@ -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 | 1289 | for (PageData pd : list) { |
988 | 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 | 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 | 1311 | @RequestMapping(value = "/downloadtestpaper", produces = "application/json;charset=UTF-8") |
1004 | 1312 | @ResponseBody |
1005 | 1313 | public Object downloadTestpaper() { |
... | ... | @@ -1086,7 +1394,11 @@ public class V1 extends BaseController { |
1086 | 1394 | |
1087 | 1395 | } |
1088 | 1396 | |
1089 | - // 下载测验成绩 | |
1397 | + /** | |
1398 | + * | |
1399 | + * 下载测验成绩 | |
1400 | + * @return | |
1401 | + */ | |
1090 | 1402 | @RequestMapping(value = "/testpaper", produces = "application/json;charset=UTF-8") |
1091 | 1403 | @ResponseBody |
1092 | 1404 | public Object testpaper() { |
... | ... | @@ -1128,6 +1440,9 @@ public class V1 extends BaseController { |
1128 | 1440 | |
1129 | 1441 | } |
1130 | 1442 | |
1443 | + /*** | |
1444 | + * | |
1445 | + */ | |
1131 | 1446 | @RequestMapping(value = "/schooladmin", produces = "application/json;charset=UTF-8") |
1132 | 1447 | @ResponseBody |
1133 | 1448 | public void schoolAdmin() { |
... | ... | @@ -1136,6 +1451,12 @@ public class V1 extends BaseController { |
1136 | 1451 | this.getUserID(); |
1137 | 1452 | } |
1138 | 1453 | |
1454 | + | |
1455 | + /*** | |
1456 | + * 网络 | |
1457 | + * @return | |
1458 | + * @throws Exception | |
1459 | + */ | |
1139 | 1460 | @RequestMapping(value = "/network", produces = "application/json;charset=UTF-8") |
1140 | 1461 | @ResponseBody |
1141 | 1462 | public Object network() throws Exception { |
... | ... | @@ -1184,6 +1505,10 @@ public class V1 extends BaseController { |
1184 | 1505 | return res.toJson(); |
1185 | 1506 | } |
1186 | 1507 | |
1508 | + /** | |
1509 | + * 获取远端ip地址 | |
1510 | + * @return | |
1511 | + */ | |
1187 | 1512 | public String getRemoteIp() { |
1188 | 1513 | HttpServletRequest request = getRequest(); |
1189 | 1514 | String ip = ""; |
... | ... | @@ -1195,6 +1520,12 @@ public class V1 extends BaseController { |
1195 | 1520 | return ip; |
1196 | 1521 | } |
1197 | 1522 | |
1523 | + /** | |
1524 | + * 查询新版本信息 | |
1525 | + * @param request | |
1526 | + * @return | |
1527 | + * @throws Exception | |
1528 | + */ | |
1198 | 1529 | @RequestMapping(value = "/newversion", produces = "application/json;charset=UTF-8") |
1199 | 1530 | @ResponseBody |
1200 | 1531 | public Object getNewVersion(HttpServletRequest request) throws Exception { |
... | ... | @@ -1246,7 +1577,8 @@ public class V1 extends BaseController { |
1246 | 1577 | for (String sub : subs) { |
1247 | 1578 | if (subjectID.trim().equals(sub.trim())) { |
1248 | 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 | 1582 | lpd.add(pad); |
1251 | 1583 | break; |
1252 | 1584 | } |
... | ... | @@ -1264,7 +1596,7 @@ public class V1 extends BaseController { |
1264 | 1596 | ret.setData(lpd); |
1265 | 1597 | return ret.toJson(); |
1266 | 1598 | } |
1267 | - | |
1599 | + | |
1268 | 1600 | /** |
1269 | 1601 | * 获取教材版本 |
1270 | 1602 | * |
... | ... | @@ -1275,35 +1607,34 @@ public class V1 extends BaseController { |
1275 | 1607 | @ResponseBody |
1276 | 1608 | public Object chapter() throws Exception { |
1277 | 1609 | PageData pd = getPageData(); |
1278 | - String key = this.getRequestKey(pd,"chapter"); | |
1610 | + String key = this.getRequestKey(pd, "chapter"); | |
1279 | 1611 | PageData pagedata = new PageData(); |
1280 | 1612 | pagedata.put("KEY", key); |
1281 | - if(!"".equals(key.trim())){ | |
1613 | + if (!"".equals(key.trim())) { | |
1282 | 1614 | PageData ret = cacheService.findById(pagedata); |
1283 | - if(ret != null && ret.get("CACHE") != null){ | |
1615 | + if (ret != null && ret.get("CACHE") != null) { | |
1284 | 1616 | return ret.get("CACHE"); |
1285 | 1617 | } |
1286 | 1618 | } |
1287 | 1619 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); |
1288 | 1620 | List<PageData> list = chapterService.listAllChapter(pd); |
1289 | 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 | 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 | 1631 | res.setData(list); |
1300 | 1632 | String str = res.toJson(); |
1301 | - str = str.replaceAll("[^\\u0000-\\uFFFF]", ""); | |
1302 | 1633 | pagedata.put("CACHE", str); |
1303 | 1634 | cacheService.save(pagedata); |
1304 | 1635 | return str; |
1305 | 1636 | } |
1306 | - | |
1637 | + | |
1307 | 1638 | /** |
1308 | 1639 | * 获取试题 |
1309 | 1640 | * |
... | ... | @@ -1317,37 +1648,39 @@ public class V1 extends BaseController { |
1317 | 1648 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); |
1318 | 1649 | String teachingmaterialId = pd.getString("TEACHINGMATERIAL_ID"); |
1319 | 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 | 1653 | PageData chapterPd = new PageData(); |
1322 | 1654 | chapterPd.put("TEACHINGMATERIAL_ID", teachingmaterialId); |
1323 | - List<PageData> chapterList = chapterService.listAllChapter(chapterPd); | |
1655 | + List<PageData> chapterList = chapterService | |
1656 | + .listAllChapter(chapterPd); | |
1324 | 1657 | roundChapterData(chapterList, 1, 3); |
1325 | - List<String> ids = getIds(chapterList,"ID"); | |
1658 | + List<String> ids = getIds(chapterList, "ID"); | |
1326 | 1659 | pd.put("CHAPTER_IDS", ids); |
1327 | - }else{ | |
1660 | + } else { | |
1328 | 1661 | List<String> ids = new ArrayList<String>(); |
1329 | - if(chapterId != null && !"".equals(chapterId.trim())){ | |
1662 | + if (chapterId != null && !"".equals(chapterId.trim())) { | |
1330 | 1663 | ids.add(chapterId); |
1331 | 1664 | } |
1332 | 1665 | pd.put("CHAPTER_IDS", ids); |
1333 | 1666 | } |
1334 | 1667 | pd.remove("CHAPTER_ID"); |
1335 | 1668 | String knowledge = pd.getString("KNOWLEDGE_ID"); |
1336 | - if(knowledge != null && !"".equals(knowledge.trim())){ | |
1669 | + if (knowledge != null && !"".equals(knowledge.trim())) { | |
1337 | 1670 | PageData knowPd = new PageData(); |
1338 | 1671 | knowPd.put("P_ID", knowledge); |
1339 | 1672 | List<PageData> knowlist = knowledgeService.listAllknowledge(knowPd); |
1340 | 1673 | roundPointData(knowlist, 1, 3); |
1341 | - List<String> ids = getIds(knowlist,"KNOWLEDGE_ID"); | |
1674 | + List<String> ids = getIds(knowlist, "KNOWLEDGE_ID"); | |
1342 | 1675 | ids.add(knowledge); |
1343 | - pd.put("KNOWLEDGE_IDS",ids); | |
1676 | + pd.put("KNOWLEDGE_IDS", ids); | |
1344 | 1677 | pd.remove("KNOWLEDGE_ID"); |
1345 | 1678 | } |
1346 | 1679 | List<PageData> list = questionService.listAllquestion(pd); |
1347 | 1680 | res.setData(list); |
1348 | 1681 | return res.toJson(); |
1349 | 1682 | } |
1350 | - | |
1683 | + | |
1351 | 1684 | /** |
1352 | 1685 | * 随机获取试题 |
1353 | 1686 | * |
... | ... | @@ -1361,61 +1694,75 @@ public class V1 extends BaseController { |
1361 | 1694 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); |
1362 | 1695 | String teachingmaterialId = pd.getString("TEACHINGMATERIAL_ID"); |
1363 | 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 | 1699 | PageData chapterPd = new PageData(); |
1366 | 1700 | chapterPd.put("TEACHINGMATERIAL_ID", teachingmaterialId); |
1367 | - List<PageData> chapterList = chapterService.listAllChapter(chapterPd); | |
1701 | + List<PageData> chapterList = chapterService | |
1702 | + .listAllChapter(chapterPd); | |
1368 | 1703 | roundChapterData(chapterList, 1, 3); |
1369 | - List<String> ids = getIds(chapterList,"ID"); | |
1704 | + List<String> ids = getIds(chapterList, "ID"); | |
1370 | 1705 | pd.put("CHAPTER_IDS", ids); |
1371 | - }else{ | |
1706 | + } else { | |
1372 | 1707 | List<String> ids = new ArrayList<String>(); |
1373 | - if(chapterId != null && !"".equals(chapterId.trim())){ | |
1708 | + if (chapterId != null && !"".equals(chapterId.trim())) { | |
1374 | 1709 | ids.add(chapterId); |
1375 | 1710 | } |
1376 | 1711 | pd.put("CHAPTER_IDS", ids); |
1377 | 1712 | } |
1378 | 1713 | pd.remove("CHAPTER_ID"); |
1379 | 1714 | String knowledge = pd.getString("KNOWLEDGE_ID"); |
1380 | - if(knowledge != null && !"".equals(knowledge.trim())){ | |
1715 | + if (knowledge != null && !"".equals(knowledge.trim())) { | |
1381 | 1716 | PageData knowPd = new PageData(); |
1382 | 1717 | knowPd.put("P_ID", knowledge); |
1383 | 1718 | List<PageData> knowlist = knowledgeService.listAllknowledge(knowPd); |
1384 | 1719 | roundPointData(knowlist, 1, 3); |
1385 | - List<String> ids = getIds(knowlist,"KNOWLEDGE_ID"); | |
1720 | + List<String> ids = getIds(knowlist, "KNOWLEDGE_ID"); | |
1386 | 1721 | ids.add(knowledge); |
1387 | - pd.put("KNOWLEDGE_IDS",ids); | |
1722 | + pd.put("KNOWLEDGE_IDS", ids); | |
1388 | 1723 | pd.remove("KNOWLEDGE_ID"); |
1389 | 1724 | } |
1390 | 1725 | List<PageData> list = questionService.listAllRandquestion(pd); |
1391 | 1726 | res.setData(list); |
1392 | 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 | 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 | 1740 | String chapterid = pd.getString(key); |
1400 | - if(chapterid != null && !"".equals(chapterid)){ | |
1741 | + if (chapterid != null && !"".equals(chapterid)) { | |
1401 | 1742 | ids.add(chapterid); |
1402 | 1743 | } |
1403 | 1744 | Object obj = pd.get("CHILDREN"); |
1404 | - if(obj != null && (obj instanceof List)){ | |
1745 | + if (obj != null && (obj instanceof List)) { | |
1405 | 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 | 1750 | ids.addAll(ret); |
1410 | 1751 | } |
1411 | 1752 | } |
1412 | 1753 | } |
1413 | 1754 | } |
1414 | - | |
1755 | + | |
1415 | 1756 | return ids; |
1416 | - | |
1757 | + | |
1417 | 1758 | } |
1418 | 1759 | |
1760 | + | |
1761 | + /** | |
1762 | + * | |
1763 | + * @return | |
1764 | + * @throws Exception | |
1765 | + */ | |
1419 | 1766 | @RequestMapping(value = "/tempcreateUser", produces = "application/json;charset=UTF-8") |
1420 | 1767 | @ResponseBody |
1421 | 1768 | public Object tempCreateUser() throws Exception { |
... | ... | @@ -1451,6 +1798,10 @@ public class V1 extends BaseController { |
1451 | 1798 | return "{'res':'success'}"; |
1452 | 1799 | } |
1453 | 1800 | |
1801 | + /** | |
1802 | + * | |
1803 | + * @param apiName | |
1804 | + */ | |
1454 | 1805 | private void event(String apiName) { |
1455 | 1806 | PageData eventPd = new PageData(); |
1456 | 1807 | eventPd.put("EVENT_ID", get32UUID()); |
... | ... | @@ -1469,6 +1820,11 @@ public class V1 extends BaseController { |
1469 | 1820 | |
1470 | 1821 | static int index = 0; |
1471 | 1822 | |
1823 | + /** | |
1824 | + * | |
1825 | + * @param point | |
1826 | + * @param pid | |
1827 | + */ | |
1472 | 1828 | private void savePoint(Point point, String pid) { |
1473 | 1829 | List<Point> children = point.getChildren(); |
1474 | 1830 | if (children != null && children.size() > 0) { |
... | ... | @@ -1488,6 +1844,11 @@ public class V1 extends BaseController { |
1488 | 1844 | } |
1489 | 1845 | } |
1490 | 1846 | |
1847 | + /** | |
1848 | + * | |
1849 | + * @return | |
1850 | + * @throws Exception | |
1851 | + */ | |
1491 | 1852 | @RequestMapping(value = "/uploadbook", produces = "application/json;charset=UTF-8") |
1492 | 1853 | @ResponseBody |
1493 | 1854 | public Object uploadbook() throws Exception { |
... | ... | @@ -1517,6 +1878,10 @@ public class V1 extends BaseController { |
1517 | 1878 | return res.toJson(); |
1518 | 1879 | } |
1519 | 1880 | |
1881 | + /** | |
1882 | + * | |
1883 | + * @param point | |
1884 | + */ | |
1520 | 1885 | private void saveBook(Point point) { |
1521 | 1886 | |
1522 | 1887 | PageData pd = new PageData(); |
... | ... | @@ -1530,8 +1895,12 @@ public class V1 extends BaseController { |
1530 | 1895 | e.printStackTrace(); |
1531 | 1896 | } |
1532 | 1897 | } |
1533 | - | |
1534 | - | |
1898 | + | |
1899 | + /** | |
1900 | + * | |
1901 | + * @return | |
1902 | + * @throws Exception | |
1903 | + */ | |
1535 | 1904 | @RequestMapping(value = "/uploadyuncelianquestion", produces = "application/json;charset=UTF-8") |
1536 | 1905 | @ResponseBody |
1537 | 1906 | public Object uploadyuncelianquestion() throws Exception { |
... | ... | @@ -1542,99 +1911,100 @@ public class V1 extends BaseController { |
1542 | 1911 | |
1543 | 1912 | if (!StringUtils.isEmpty(pd.getJsonString())) { |
1544 | 1913 | try { |
1545 | - ResponseGson<Object> req = ResponseGson.parse( | |
1546 | - pd.getJsonString()); | |
1914 | + ResponseGson<Object> req = ResponseGson.parse(pd | |
1915 | + .getJsonString()); | |
1547 | 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 | 1923 | PageData pageData = new PageData(); |
1555 | 1924 | pageData.put("QUESTION_ID", map.get("id")); |
1556 | 1925 | Object cateObj = map.get("cate"); |
1557 | - if(cateObj != null){ | |
1926 | + if (cateObj != null) { | |
1558 | 1927 | String cate = cateObj.toString(); |
1559 | 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 | 1931 | Object contentObj = map.get("content"); |
1563 | - if(contentObj != null){ | |
1932 | + if (contentObj != null) { | |
1564 | 1933 | String content = contentObj.toString(); |
1565 | 1934 | content = replaceWebUrl(content); |
1566 | 1935 | pageData.put("CONTENT", content); |
1567 | 1936 | } |
1568 | 1937 | Object subjectCodeObj = map.get("subjectCode"); |
1569 | - if(subjectCodeObj != null){ | |
1938 | + if (subjectCodeObj != null) { | |
1570 | 1939 | String subjectCode = subjectCodeObj.toString(); |
1571 | - pageData.put("SUBJECT_ID",subjectCode); | |
1940 | + pageData.put("SUBJECT_ID", subjectCode); | |
1572 | 1941 | } |
1573 | 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 | 1947 | pageData.put("OPTION_NUM", "" + ss.size()); |
1578 | 1948 | } |
1579 | 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 | 1952 | StringBuilder sb = new StringBuilder(); |
1583 | - for(Object as:answers){ | |
1953 | + for (Object as : answers) { | |
1584 | 1954 | sb.append(as.toString()); |
1585 | 1955 | } |
1586 | 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 | 1960 | if (difficulty != null) { |
1591 | 1961 | float fdifficulty = Float |
1592 | 1962 | .parseFloat(difficulty.toString()); |
1593 | 1963 | pageData.put("DIFFICULTY", |
1594 | 1964 | (int) fdifficulty); |
1595 | 1965 | } |
1596 | - }catch(Exception ex){ | |
1966 | + } catch (Exception ex) { | |
1597 | 1967 | ex.printStackTrace(); |
1598 | 1968 | } |
1599 | 1969 | Object discussObj = map.get("discuss"); |
1600 | - if(discussObj != null){ | |
1970 | + if (discussObj != null) { | |
1601 | 1971 | String discuss = discussObj.toString(); |
1602 | 1972 | discuss = replaceWebUrl(discuss); |
1603 | 1973 | pageData.put("REMARK", discuss); |
1604 | 1974 | } |
1605 | 1975 | Object analyseObj = map.get("analyse"); |
1606 | - if(analyseObj != null){ | |
1976 | + if (analyseObj != null) { | |
1607 | 1977 | String analyse = analyseObj.toString(); |
1608 | 1978 | analyse = replaceWebUrl(analyse); |
1609 | 1979 | pageData.put("ANALYSIS", analyse); |
1610 | 1980 | } |
1611 | 1981 | Object methodObj = map.get("method"); |
1612 | - if(methodObj != null){ | |
1982 | + if (methodObj != null) { | |
1613 | 1983 | String method = methodObj.toString(); |
1614 | 1984 | method = replaceWebUrl(method); |
1615 | 1985 | pageData.put("METHOD", method); |
1616 | 1986 | } |
1617 | 1987 | Object points = map.get("points"); |
1618 | 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 | 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 | 1999 | sb.deleteCharAt(sb.length() - 1); |
1630 | 2000 | } |
1631 | 2001 | pageData.put("KNOWLEDGE_ID", sb.toString()); |
1632 | 2002 | } |
1633 | 2003 | pageData.put("QUESTION_FROM", "101"); |
1634 | - try{ | |
2004 | + try { | |
1635 | 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 | 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 | 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 | 2045 | key.append(methodName).append("{"); |
1665 | 2046 | if (pd != null) { |
1666 | 2047 | Iterator iterator = pd.keySet().iterator(); |
... | ... | @@ -1671,7 +2052,7 @@ public class V1 extends BaseController { |
1671 | 2052 | } |
1672 | 2053 | } |
1673 | 2054 | key.append("}"); |
1674 | - | |
2055 | + | |
1675 | 2056 | return key.toString(); |
1676 | 2057 | } |
1677 | 2058 | } | ... | ... |