Commit c34a91ee22c4c136dd936c165af57702b42c2c84
1 parent
58e024ae
添加学生成绩接口
Showing
5 changed files
with
426 additions
and
100 deletions
resources/mybatis1/sunvote/StudentMapper.xml
| ... | ... | @@ -119,6 +119,16 @@ |
| 119 | 119 | </select> |
| 120 | 120 | |
| 121 | 121 | <!-- 通过ID获取数据 --> |
| 122 | + <select id="findByNumber" parameterType="pd" resultType="pd"> | |
| 123 | + select | |
| 124 | + <include refid="Field"></include> | |
| 125 | + from | |
| 126 | + <include refid="tableName"></include> | |
| 127 | + where | |
| 128 | + NUMBER = #{NUMBER} | |
| 129 | + </select> | |
| 130 | + | |
| 131 | + <!-- 通过ID获取数据 --> | |
| 122 | 132 | <select id="countByClassId" parameterType="String" resultType="Integer"> |
| 123 | 133 | select |
| 124 | 134 | count(0) | ... | ... |
src/com/fh/bean/StudentPaper.java
0 → 100644
| 1 | +package com.fh.bean; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +import com.google.gson.Gson; | |
| 6 | + | |
| 7 | +public class StudentPaper { | |
| 8 | + | |
| 9 | + public static class StudentAnswer{ | |
| 10 | + | |
| 11 | + private Integer score; | |
| 12 | + | |
| 13 | + private String number; | |
| 14 | + | |
| 15 | + private String studentId; | |
| 16 | + | |
| 17 | + private String losttest; | |
| 18 | + | |
| 19 | + public String getLosttest() { | |
| 20 | + return losttest; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public void setLosttest(String losttest) { | |
| 24 | + this.losttest = losttest; | |
| 25 | + } | |
| 26 | + | |
| 27 | + private List<Question> questions; | |
| 28 | + | |
| 29 | + public Integer getScore() { | |
| 30 | + return score; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public void setScore(Integer score) { | |
| 34 | + this.score = score; | |
| 35 | + } | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + public String getNumber() { | |
| 40 | + return number; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void setNumber(String number) { | |
| 44 | + this.number = number; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public String getStudentId() { | |
| 48 | + return studentId; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public void setStudentId(String studentId) { | |
| 52 | + this.studentId = studentId; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public List<Question> getQuestions() { | |
| 56 | + return questions; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public void setQuestions(List<Question> questions) { | |
| 60 | + this.questions = questions; | |
| 61 | + } | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + } | |
| 66 | + | |
| 67 | + public static class Question{ | |
| 68 | + private String answer; | |
| 69 | + | |
| 70 | + private String pressTime; | |
| 71 | + | |
| 72 | + private String questionId; | |
| 73 | + | |
| 74 | + private String right; | |
| 75 | + | |
| 76 | + private String score; | |
| 77 | + | |
| 78 | + private String answerType; | |
| 79 | + | |
| 80 | + public String getAnswer() { | |
| 81 | + return answer; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public void setAnswer(String answer) { | |
| 85 | + this.answer = answer; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public String getPressTime() { | |
| 89 | + return pressTime; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public void setPressTime(String pressTime) { | |
| 93 | + this.pressTime = pressTime; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public String getQuestionId() { | |
| 97 | + return questionId; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public void setQuestionId(String questionId) { | |
| 101 | + this.questionId = questionId; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public String getRight() { | |
| 105 | + return right; | |
| 106 | + } | |
| 107 | + | |
| 108 | + public void setRight(String right) { | |
| 109 | + this.right = right; | |
| 110 | + } | |
| 111 | + | |
| 112 | + public String getScore() { | |
| 113 | + return score; | |
| 114 | + } | |
| 115 | + | |
| 116 | + public void setScore(String score) { | |
| 117 | + this.score = score; | |
| 118 | + } | |
| 119 | + | |
| 120 | + public String getAnswerType() { | |
| 121 | + return answerType; | |
| 122 | + } | |
| 123 | + | |
| 124 | + public void setAnswerType(String answerType) { | |
| 125 | + this.answerType = answerType; | |
| 126 | + } | |
| 127 | + | |
| 128 | + | |
| 129 | + } | |
| 130 | + | |
| 131 | + private String createDate; | |
| 132 | + | |
| 133 | + private String endDate; | |
| 134 | + | |
| 135 | + private String schoolId; | |
| 136 | + | |
| 137 | + private String paperId; | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + private List<StudentAnswer> students; | |
| 142 | + | |
| 143 | + public String getCreateDate() { | |
| 144 | + return createDate; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public void setCreateDate(String createDate) { | |
| 148 | + this.createDate = createDate; | |
| 149 | + } | |
| 150 | + | |
| 151 | + public String getEndDate() { | |
| 152 | + return endDate; | |
| 153 | + } | |
| 154 | + | |
| 155 | + public void setEndDate(String endDate) { | |
| 156 | + this.endDate = endDate; | |
| 157 | + } | |
| 158 | + | |
| 159 | + public String getSchoolId() { | |
| 160 | + return schoolId; | |
| 161 | + } | |
| 162 | + | |
| 163 | + public void setSchoolId(String schoolId) { | |
| 164 | + this.schoolId = schoolId; | |
| 165 | + } | |
| 166 | + | |
| 167 | + public List<StudentAnswer> getStudents() { | |
| 168 | + return students; | |
| 169 | + } | |
| 170 | + | |
| 171 | + public void setStudents(List<StudentAnswer> students) { | |
| 172 | + this.students = students; | |
| 173 | + } | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + public String getPaperId() { | |
| 178 | + return paperId; | |
| 179 | + } | |
| 180 | + | |
| 181 | + public void setPaperId(String paperId) { | |
| 182 | + this.paperId = paperId; | |
| 183 | + } | |
| 184 | + | |
| 185 | + | |
| 186 | + public static StudentPaper parse(String json){ | |
| 187 | + Gson gson = new Gson(); | |
| 188 | + return gson.fromJson(json, StudentPaper.class); | |
| 189 | + } | |
| 190 | + | |
| 191 | + | |
| 192 | + public String toJson(){ | |
| 193 | + Gson gson = new Gson(); | |
| 194 | + return gson.toJson(this); | |
| 195 | + } | |
| 196 | + | |
| 197 | +} | ... | ... |
src/com/fh/controller/api/V1.java
| ... | ... | @@ -29,6 +29,7 @@ import com.fh.bean.Question; |
| 29 | 29 | import com.fh.bean.ResultHomework; |
| 30 | 30 | import com.fh.bean.ResultHomework.ResultStudent; |
| 31 | 31 | import com.fh.bean.StudentAnswer; |
| 32 | +import com.fh.bean.StudentPaper; | |
| 32 | 33 | import com.fh.bean.TestPaper; |
| 33 | 34 | import com.fh.bean.TestPaperInfo; |
| 34 | 35 | import com.fh.controller.base.BaseController; |
| ... | ... | @@ -98,7 +99,7 @@ public class V1 extends BaseController { |
| 98 | 99 | private ClassRosterManager classrosterService; |
| 99 | 100 | |
| 100 | 101 | @Resource(name = "classtypeService") |
| 101 | - private ClassTypeManager classtypeService; | |
| 102 | + private ClassTypeManager classtypeService; | |
| 102 | 103 | |
| 103 | 104 | @Resource(name = "gradeService") |
| 104 | 105 | private GradeManager gradeService; |
| ... | ... | @@ -141,10 +142,10 @@ public class V1 extends BaseController { |
| 141 | 142 | |
| 142 | 143 | @Resource(name = "sclassService") |
| 143 | 144 | private SClassManager sclassService; |
| 144 | - | |
| 145 | - @Resource(name="homeworkService") | |
| 145 | + | |
| 146 | + @Resource(name = "homeworkService") | |
| 146 | 147 | private HomeworkManager homeworkService; |
| 147 | - | |
| 148 | + | |
| 148 | 149 | @Resource(name = "studentService") |
| 149 | 150 | private StudentManager studentService; |
| 150 | 151 | |
| ... | ... | @@ -153,8 +154,8 @@ public class V1 extends BaseController { |
| 153 | 154 | |
| 154 | 155 | @Resource(name = "teacherService") |
| 155 | 156 | private TeacherManager teacherService; |
| 156 | - | |
| 157 | - @Resource(name="headmasterService") | |
| 157 | + | |
| 158 | + @Resource(name = "headmasterService") | |
| 158 | 159 | private HeadmasterManager headmasterService; |
| 159 | 160 | |
| 160 | 161 | @Resource(name = "testpaperinfoService") |
| ... | ... | @@ -198,13 +199,13 @@ public class V1 extends BaseController { |
| 198 | 199 | |
| 199 | 200 | @Resource(name = "cacheService") |
| 200 | 201 | private CacheManager cacheService; |
| 201 | - | |
| 202 | - @Resource(name="homeworkproblemService") | |
| 202 | + | |
| 203 | + @Resource(name = "homeworkproblemService") | |
| 203 | 204 | private HomeworkProblemManager homeworkproblemService; |
| 204 | - | |
| 205 | - @Resource(name="homeworkReporService") | |
| 205 | + | |
| 206 | + @Resource(name = "homeworkReporService") | |
| 206 | 207 | private HomeworkReportManager homeworkReporkService; |
| 207 | - | |
| 208 | + | |
| 208 | 209 | /** |
| 209 | 210 | * 登录 可以通过账号密码登录、 可以通过教师卡登录 |
| 210 | 211 | * |
| ... | ... | @@ -236,15 +237,16 @@ public class V1 extends BaseController { |
| 236 | 237 | } |
| 237 | 238 | eventPd.put("EVENT_IP", getRemoteIp()); |
| 238 | 239 | eventService.save(eventPd); |
| 239 | - | |
| 240 | + | |
| 240 | 241 | PageData pageData = teacherService.getUserInfo(pd); |
| 241 | - if(pageData == null){ | |
| 242 | + if (pageData == null) { | |
| 242 | 243 | pd.put("PASSWORD", |
| 243 | 244 | new SimpleHash("SHA-1", pd.getString("ACCOUT"), pd |
| 244 | 245 | .getString("PASSWORD")).toString()); |
| 245 | 246 | pageData = teacherService.getUserInfo(pd); |
| 246 | 247 | } |
| 247 | - PageData headerMaster = headmasterService.findByUsenameAndPassword(pd); | |
| 248 | + PageData headerMaster = headmasterService | |
| 249 | + .findByUsenameAndPassword(pd); | |
| 248 | 250 | if (pageData != null && pageData.getString("ID") != null) { |
| 249 | 251 | pageData.put("PASSWORD", "");// 返回参数中不返回密码 |
| 250 | 252 | PageData pt = new PageData(); |
| ... | ... | @@ -262,14 +264,15 @@ public class V1 extends BaseController { |
| 262 | 264 | |
| 263 | 265 | pageData.remove("SUBJECT_IDS"); |
| 264 | 266 | |
| 265 | - | |
| 266 | 267 | pageData.put("role", "teacher"); |
| 267 | 268 | res.setData(pageData); |
| 268 | 269 | // 填充数据到返回数据中 |
| 269 | - } else if(headerMaster != null && headerMaster.get("HEADMASTER_ID") != null){ | |
| 270 | + } else if (headerMaster != null | |
| 271 | + && headerMaster.get("HEADMASTER_ID") != null) { | |
| 270 | 272 | headerMaster.put("role", "headermaster"); |
| 271 | - List<PageData> classInfoList = sclassService.listAll(headerMaster); | |
| 272 | - for(PageData pttd : classInfoList){ | |
| 273 | + List<PageData> classInfoList = sclassService | |
| 274 | + .listAll(headerMaster); | |
| 275 | + for (PageData pttd : classInfoList) { | |
| 273 | 276 | pttd.put("CLASS_ID", pttd.get("ID")); |
| 274 | 277 | pttd.remove("ID"); |
| 275 | 278 | pttd.remove("HEADMASTER_ID"); |
| ... | ... | @@ -280,8 +283,8 @@ public class V1 extends BaseController { |
| 280 | 283 | headerMaster.remove("USERNAME"); |
| 281 | 284 | headerMaster.remove("PASSWORD"); |
| 282 | 285 | res.setData(headerMaster); |
| 283 | - | |
| 284 | - }else{ | |
| 286 | + | |
| 287 | + } else { | |
| 285 | 288 | res.set1Error(); |
| 286 | 289 | } |
| 287 | 290 | } else { |
| ... | ... | @@ -549,13 +552,13 @@ public class V1 extends BaseController { |
| 549 | 552 | pd.put("CURRENTPAGE", "" + currentPage); |
| 550 | 553 | } |
| 551 | 554 | PageData p = teacherService.findById2(pd.get("USER_ID").toString()); |
| 552 | - if(p != null){ | |
| 555 | + if (p != null) { | |
| 553 | 556 | pd.put("SCHOOL_ID", p.get("SCHOOL_ID")); |
| 554 | - //pd.remove("USER_ID"); | |
| 555 | - }else{ | |
| 557 | + // pd.remove("USER_ID"); | |
| 558 | + } else { | |
| 556 | 559 | pd.put("SCHOOL_ID", ""); |
| 557 | 560 | } |
| 558 | - if(pd.getString("PAPER_TYPE").equals("2")){ | |
| 561 | + if (pd.getString("PAPER_TYPE").equals("2")) { | |
| 559 | 562 | pd.remove("USER_ID"); |
| 560 | 563 | } |
| 561 | 564 | List<PageData> pageList = paperService.listAllByType(pd); |
| ... | ... | @@ -610,7 +613,8 @@ public class V1 extends BaseController { |
| 610 | 613 | question.setKnowledge_id(qpd |
| 611 | 614 | .getString("KNOWLEDGE_ID")); |
| 612 | 615 | String ttcontent = qpd.getString("CONTENT"); |
| 613 | - ttcontent = ttcontent.replaceAll("<fill></fill>", "______"); | |
| 616 | + ttcontent = ttcontent.replaceAll("<fill></fill>", | |
| 617 | + "______"); | |
| 614 | 618 | question.setContent(ttcontent); |
| 615 | 619 | question.setOption_num(qpd.getString("OPTION_NUM")); |
| 616 | 620 | question.setOption_content(qpd |
| ... | ... | @@ -642,7 +646,9 @@ public class V1 extends BaseController { |
| 642 | 646 | .getString("PROBLEM_TYPE_ID")); |
| 643 | 647 | qq.setKnowledge_id(q |
| 644 | 648 | .getString("KNOWLEDGE_ID")); |
| 645 | - qq.setContent(q.getString("CONTENT").replaceAll("<fill></fill>", "______")); | |
| 649 | + qq.setContent(q.getString("CONTENT") | |
| 650 | + .replaceAll("<fill></fill>", | |
| 651 | + "______")); | |
| 646 | 652 | qq.setOption_num(q.getString("OPTION_NUM")); |
| 647 | 653 | qq.setOption_content(q |
| 648 | 654 | .getString("OPTION_CONTENT")); |
| ... | ... | @@ -815,7 +821,6 @@ public class V1 extends BaseController { |
| 815 | 821 | + (System.currentTimeMillis() - cur)); |
| 816 | 822 | return res.toJson(); |
| 817 | 823 | } |
| 818 | - | |
| 819 | 824 | |
| 820 | 825 | /** |
| 821 | 826 | * 试卷详细信息 |
| ... | ... | @@ -1285,7 +1290,8 @@ public class V1 extends BaseController { |
| 1285 | 1290 | paperPd.put("PAPER_STATE", "0"); |
| 1286 | 1291 | paperPd.put("REMARK", ""); |
| 1287 | 1292 | String schoolID = Myelfun.getUserID(paper.getUser_id()); |
| 1288 | - paperPd.put("SCHOOL_ID", paper.getSchool_id() == null ? schoolID:paper.getSchool_id()); | |
| 1293 | + paperPd.put("SCHOOL_ID", paper.getSchool_id() == null ? schoolID | |
| 1294 | + : paper.getSchool_id()); | |
| 1289 | 1295 | paperPd.put("CREATE_DATE", Tools.date2Str(new Date())); |
| 1290 | 1296 | paperPd.put("MODIFY_DATE", Tools.date2Str(new Date())); |
| 1291 | 1297 | |
| ... | ... | @@ -1595,7 +1601,7 @@ public class V1 extends BaseController { |
| 1595 | 1601 | |
| 1596 | 1602 | } |
| 1597 | 1603 | } |
| 1598 | - if(testInfoPdList != null && testInfoPdList.size() > 0){ | |
| 1604 | + if (testInfoPdList != null && testInfoPdList.size() > 0) { | |
| 1599 | 1605 | testpaperinfoService.batchSave(testInfoPdList); |
| 1600 | 1606 | } |
| 1601 | 1607 | } |
| ... | ... | @@ -1684,7 +1690,7 @@ public class V1 extends BaseController { |
| 1684 | 1690 | studentPageData.put("CLASS_ID", |
| 1685 | 1691 | testPaper.getClassId()); |
| 1686 | 1692 | studentPageData.put("STUDENTTEST_ID", get32UUID()); |
| 1687 | - | |
| 1693 | + | |
| 1688 | 1694 | String flag = ""; |
| 1689 | 1695 | for (TestPaperInfo testPaperInfo : studentAnswer |
| 1690 | 1696 | .getQuestions()) { |
| ... | ... | @@ -1700,7 +1706,9 @@ public class V1 extends BaseController { |
| 1700 | 1706 | testPaperInfo.getQuestionId()); |
| 1701 | 1707 | testInfoPd.put("ANSWER", |
| 1702 | 1708 | testPaperInfo.getAnswer()); |
| 1703 | - flag = testPaperInfo.getAnswer().toString().equals("")?""+flag:testPaperInfo.getAnswer().toString(); | |
| 1709 | + flag = testPaperInfo.getAnswer().toString() | |
| 1710 | + .equals("") ? "" + flag : testPaperInfo | |
| 1711 | + .getAnswer().toString(); | |
| 1704 | 1712 | testInfoPd.put("RIGHT", |
| 1705 | 1713 | testPaperInfo.getRight()); |
| 1706 | 1714 | testInfoPd.put("SCORE", |
| ... | ... | @@ -1721,14 +1729,14 @@ public class V1 extends BaseController { |
| 1721 | 1729 | testPaperInfo.getMarkNo()); |
| 1722 | 1730 | testInfoPdList.add(testInfoPd); |
| 1723 | 1731 | } |
| 1724 | - | |
| 1725 | - if(flag.equals("")){ | |
| 1726 | - studentPageData.put("LOST_TEST","1"); | |
| 1732 | + | |
| 1733 | + if (flag.equals("")) { | |
| 1734 | + studentPageData.put("LOST_TEST", "1"); | |
| 1727 | 1735 | } |
| 1728 | 1736 | studenttestService.save(studentPageData); |
| 1729 | 1737 | } |
| 1730 | 1738 | } |
| 1731 | - if(testInfoPdList != null && testInfoPdList.size() > 0){ | |
| 1739 | + if (testInfoPdList != null && testInfoPdList.size() > 0) { | |
| 1732 | 1740 | testpaperinfoService.batchSave(testInfoPdList); |
| 1733 | 1741 | } |
| 1734 | 1742 | } |
| ... | ... | @@ -1749,6 +1757,90 @@ public class V1 extends BaseController { |
| 1749 | 1757 | } |
| 1750 | 1758 | |
| 1751 | 1759 | /** |
| 1760 | + * 上传学生测验成绩 | |
| 1761 | + * | |
| 1762 | + * @return | |
| 1763 | + */ | |
| 1764 | + @RequestMapping(value = "/uploadstudenttest", produces = "application/json;charset=UTF-8") | |
| 1765 | + @ResponseBody | |
| 1766 | + public Object uploadstudenttest() { | |
| 1767 | + event("uploadupdateTestpaper"); | |
| 1768 | + long cur = System.currentTimeMillis(); | |
| 1769 | + PageData pd = this.getPageData(); | |
| 1770 | + ResponseGson<String> res = new ResponseGson(); | |
| 1771 | + if (!StringUtils.isEmpty(pd.getJsonString())) { | |
| 1772 | + logger.info(pd.getJsonString()); | |
| 1773 | + StudentPaper studentPaper = StudentPaper.parse(pd.getJsonString()); | |
| 1774 | + List<StudentPaper.StudentAnswer> list = studentPaper.getStudents(); | |
| 1775 | + try { | |
| 1776 | + for (StudentPaper.StudentAnswer studentAnswer : list) { | |
| 1777 | + PageData testPd = new PageData(); | |
| 1778 | + String testPaperId = this.get32UUID(); | |
| 1779 | + testPd.put("STUDENTTEST_ID", testPaperId); | |
| 1780 | + String studentId = studentAnswer.getStudentId(); | |
| 1781 | + String classId = ""; | |
| 1782 | + // 通过学号id 查找学生信息 | |
| 1783 | + if (StringUtils.isEmpty(studentId)) { | |
| 1784 | + PageData ptd = new PageData(); | |
| 1785 | + ptd.put("NUMBER", studentAnswer.getNumber()); | |
| 1786 | + PageData stPd = studentService.findByNumber(ptd); | |
| 1787 | + if (stPd != null) { | |
| 1788 | + studentId = stPd.getString("ID"); | |
| 1789 | + classId = stPd.getString("CLASS_ID"); | |
| 1790 | + } | |
| 1791 | + } else { | |
| 1792 | + PageData ptd = new PageData(); | |
| 1793 | + ptd.put("ID", studentAnswer.getStudentId()); | |
| 1794 | + PageData stPd = studentService.findByNumber(ptd); | |
| 1795 | + if (stPd != null) { | |
| 1796 | + studentId = stPd.getString("ID"); | |
| 1797 | + classId = stPd.getString("CLASS_ID"); | |
| 1798 | + } | |
| 1799 | + } | |
| 1800 | + testPd.put("STUDENT_ID", studentId); | |
| 1801 | + testPd.put("CLASS_ID", classId); | |
| 1802 | + testPd.put("PAPER_ID", studentPaper.getPaperId()); | |
| 1803 | + testPd.put("SCORE", studentAnswer.getScore()); | |
| 1804 | + testPd.put("LOST_TEST", studentAnswer.getLosttest()); | |
| 1805 | + studenttestService.save(testPd); | |
| 1806 | + List<PageData> testInfoPdList = new ArrayList(); | |
| 1807 | + List<StudentPaper.Question> questions = studentAnswer | |
| 1808 | + .getQuestions(); | |
| 1809 | + for (StudentPaper.Question question : questions) { | |
| 1810 | + PageData testInfoPd = new PageData(); | |
| 1811 | + testInfoPd.put("TESTPAPERINFO_ID", this.get32UUID()); | |
| 1812 | + testInfoPd.put("PAPER_ID", studentPaper.getPaperId()); | |
| 1813 | + testInfoPd.put("STUDENT_ID", studentId); | |
| 1814 | + testInfoPd.put("QUESTION_ID", question.getQuestionId()); | |
| 1815 | + testInfoPd.put("ANSWER", question.getAnswer()); | |
| 1816 | + testInfoPd.put("RIGHT", question.getRight()); | |
| 1817 | + testInfoPd.put("SCORE", question.getScore()); | |
| 1818 | + testInfoPd.put("ANSWER_TYPE", question.getAnswerType()); | |
| 1819 | + testInfoPdList.add(testInfoPd); | |
| 1820 | + } | |
| 1821 | + | |
| 1822 | + if (testInfoPdList.size() > 0) { | |
| 1823 | + testpaperinfoService.batchSave(testInfoPdList); | |
| 1824 | + } | |
| 1825 | + | |
| 1826 | + } | |
| 1827 | + | |
| 1828 | + } catch (Exception e) { | |
| 1829 | + e.printStackTrace(); | |
| 1830 | + res.setError(); | |
| 1831 | + res.setMessage(e.getMessage()); | |
| 1832 | + } | |
| 1833 | + } else { | |
| 1834 | + res.setDataError(); | |
| 1835 | + } | |
| 1836 | + logger.info("uploadupdatetestpaper cost time:" | |
| 1837 | + + (System.currentTimeMillis() - cur)); | |
| 1838 | + | |
| 1839 | + return res.toJson(); | |
| 1840 | + | |
| 1841 | + } | |
| 1842 | + | |
| 1843 | + /** | |
| 1752 | 1844 | * 上传测验成绩 |
| 1753 | 1845 | * |
| 1754 | 1846 | * @return |
| ... | ... | @@ -1855,7 +1947,7 @@ public class V1 extends BaseController { |
| 1855 | 1947 | } |
| 1856 | 1948 | } |
| 1857 | 1949 | } |
| 1858 | - if(testInfoPdList.size() > 0){ | |
| 1950 | + if (testInfoPdList.size() > 0) { | |
| 1859 | 1951 | testpaperinfoService.batchSave(testInfoPdList); |
| 1860 | 1952 | } |
| 1861 | 1953 | } |
| ... | ... | @@ -2390,9 +2482,11 @@ public class V1 extends BaseController { |
| 2390 | 2482 | } else { |
| 2391 | 2483 | pad.put("OPTION_CONTENT", new String[] { optionContent }); |
| 2392 | 2484 | } |
| 2393 | - | |
| 2394 | - if(pad.getString("CONTENT") != null){ | |
| 2395 | - pad.put("CONTENT", pad.getString("CONTENT").replaceAll("<fill></fill>", "______")); | |
| 2485 | + | |
| 2486 | + if (pad.getString("CONTENT") != null) { | |
| 2487 | + pad.put("CONTENT", | |
| 2488 | + pad.getString("CONTENT").replaceAll("<fill></fill>", | |
| 2489 | + "______")); | |
| 2396 | 2490 | } |
| 2397 | 2491 | } |
| 2398 | 2492 | res.setData(list); |
| ... | ... | @@ -2531,19 +2625,19 @@ public class V1 extends BaseController { |
| 2531 | 2625 | * @param apiName |
| 2532 | 2626 | */ |
| 2533 | 2627 | private void event(String apiName) { |
| 2534 | -// PageData eventPd = new PageData(); | |
| 2535 | -// eventPd.put("EVENT_ID", get32UUID()); | |
| 2536 | -// eventPd.put("EVENT_NAME", apiName); | |
| 2537 | -// eventPd.put("EVENT_USER", getUsername()); | |
| 2538 | -// eventPd.put("EVENT_TYPE", "-1"); | |
| 2539 | -// eventPd.put("EVENT_START_TIME", Tools.date2Str(new Date())); | |
| 2540 | -// eventPd.put("CLIENT_ID", "SERVER"); | |
| 2541 | -// eventPd.put("EVENT_IP", getRemoteIp()); | |
| 2542 | -// try { | |
| 2543 | -// eventService.save(eventPd); | |
| 2544 | -// } catch (Exception e) { | |
| 2545 | -// | |
| 2546 | -// } | |
| 2628 | + // PageData eventPd = new PageData(); | |
| 2629 | + // eventPd.put("EVENT_ID", get32UUID()); | |
| 2630 | + // eventPd.put("EVENT_NAME", apiName); | |
| 2631 | + // eventPd.put("EVENT_USER", getUsername()); | |
| 2632 | + // eventPd.put("EVENT_TYPE", "-1"); | |
| 2633 | + // eventPd.put("EVENT_START_TIME", Tools.date2Str(new Date())); | |
| 2634 | + // eventPd.put("CLIENT_ID", "SERVER"); | |
| 2635 | + // eventPd.put("EVENT_IP", getRemoteIp()); | |
| 2636 | + // try { | |
| 2637 | + // eventService.save(eventPd); | |
| 2638 | + // } catch (Exception e) { | |
| 2639 | + // | |
| 2640 | + // } | |
| 2547 | 2641 | } |
| 2548 | 2642 | |
| 2549 | 2643 | static int index = 0; |
| ... | ... | @@ -2862,7 +2956,7 @@ public class V1 extends BaseController { |
| 2862 | 2956 | return res.toJson(); |
| 2863 | 2957 | |
| 2864 | 2958 | } |
| 2865 | - | |
| 2959 | + | |
| 2866 | 2960 | /** |
| 2867 | 2961 | * 获取作业列表 |
| 2868 | 2962 | * |
| ... | ... | @@ -2875,15 +2969,15 @@ public class V1 extends BaseController { |
| 2875 | 2969 | public String listhomework() throws Exception { |
| 2876 | 2970 | ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>(); |
| 2877 | 2971 | PageData pageData = this.getPageData(); |
| 2878 | - if(pageData.get("COMPLETE_DATE") == null){ | |
| 2972 | + if (pageData.get("COMPLETE_DATE") == null) { | |
| 2879 | 2973 | pageData.put("COMPLETE_DATE", pageData.get("COMPLETE")); |
| 2880 | 2974 | } |
| 2881 | 2975 | List<PageData> list = homeworkService.qlistAll(pageData); |
| 2882 | 2976 | res.setData(list); |
| 2883 | 2977 | return res.toJson(); |
| 2884 | - | |
| 2978 | + | |
| 2885 | 2979 | } |
| 2886 | - | |
| 2980 | + | |
| 2887 | 2981 | /** |
| 2888 | 2982 | * 获取作业详情 |
| 2889 | 2983 | * |
| ... | ... | @@ -2898,18 +2992,19 @@ public class V1 extends BaseController { |
| 2898 | 2992 | PageData pageData = this.getPageData(); |
| 2899 | 2993 | pageData.put("CODE", pageData.get("HOMEWORK_ID")); |
| 2900 | 2994 | List<PageData> list = homeworkproblemService.listProblem(pageData); |
| 2901 | - for(PageData pd : list){ | |
| 2902 | - if(pd.get("P_HOMEWORK_PROBLEM_ID") != null){ | |
| 2903 | - List<PageData> childList = homeworkproblemService.listProblem(pd); | |
| 2995 | + for (PageData pd : list) { | |
| 2996 | + if (pd.get("P_HOMEWORK_PROBLEM_ID") != null) { | |
| 2997 | + List<PageData> childList = homeworkproblemService | |
| 2998 | + .listProblem(pd); | |
| 2904 | 2999 | pd.put("PROBLEMS", childList); |
| 2905 | 3000 | } |
| 2906 | - | |
| 3001 | + | |
| 2907 | 3002 | } |
| 2908 | 3003 | res.setData(list); |
| 2909 | 3004 | return res.toJson(); |
| 2910 | - | |
| 3005 | + | |
| 2911 | 3006 | } |
| 2912 | - | |
| 3007 | + | |
| 2913 | 3008 | /** |
| 2914 | 3009 | * 获取作业详情 |
| 2915 | 3010 | * |
| ... | ... | @@ -2921,15 +3016,17 @@ public class V1 extends BaseController { |
| 2921 | 3016 | @ResponseBody |
| 2922 | 3017 | public String uploadhomework() throws Exception { |
| 2923 | 3018 | ResponseGson<String> res = new ResponseGson<String>(); |
| 2924 | - | |
| 3019 | + | |
| 2925 | 3020 | PageData pd = this.getPageData(); |
| 2926 | 3021 | if (!StringUtils.isEmpty(pd.getJsonString())) { |
| 2927 | - ResultHomework resultHomework = ResultHomework.parse(pd.getJsonString()); | |
| 3022 | + ResultHomework resultHomework = ResultHomework.parse(pd | |
| 3023 | + .getJsonString()); | |
| 2928 | 3024 | PageData homePd = new PageData(); |
| 2929 | 3025 | homePd.put("HOMEWORK_ID", resultHomework.getHOMEWORK_ID()); |
| 2930 | 3026 | homePd.put("CLASS_ID", resultHomework.getCLASS_ID()); |
| 2931 | 3027 | homePd.put("GET_SCORE", resultHomework.getGET_SCORE()); |
| 2932 | - homePd.put("GET_SCORE_PERSENT", resultHomework.getGET_SCORE_PERSENT()); | |
| 3028 | + homePd.put("GET_SCORE_PERSENT", | |
| 3029 | + resultHomework.getGET_SCORE_PERSENT()); | |
| 2933 | 3030 | homePd.put("COMPLETE_DESC", resultHomework.getCOMPLETE_DESC()); |
| 2934 | 3031 | homePd.put("GET_MAX_SCORE", resultHomework.getGET_MAX_SCORE()); |
| 2935 | 3032 | homePd.put("GET_MIN_SCORE", resultHomework.getGET_MIN_SCORE()); |
| ... | ... | @@ -2937,12 +3034,13 @@ public class V1 extends BaseController { |
| 2937 | 3034 | homePd.put("COMPLETE_PERSENT", resultHomework.getCOMPLETE_PERSENT()); |
| 2938 | 3035 | homePd.put("COMPLETE_COUNT", "1"); |
| 2939 | 3036 | homeworkService.edit(homePd); |
| 2940 | - List<PageData> list = homeworkReporkService.findByHomeworkID(homePd); | |
| 2941 | - if(list == null || list.size() == 0){ | |
| 3037 | + List<PageData> list = homeworkReporkService | |
| 3038 | + .findByHomeworkID(homePd); | |
| 3039 | + if (list == null || list.size() == 0) { | |
| 2942 | 3040 | // 初始化班級作业数据 |
| 2943 | 3041 | // 1. 根据班级id 查询班级学生列表 |
| 2944 | 3042 | List<PageData> student = studentService.findByClassId(homePd); |
| 2945 | - for(PageData ptd : student){ | |
| 3043 | + for (PageData ptd : student) { | |
| 2946 | 3044 | ptd.put("STUDENT_ID", ptd.get("ID")); |
| 2947 | 3045 | ptd.put("STUDENT_NAME", ptd.get("NAME")); |
| 2948 | 3046 | ptd.put("HOMEWORK_REPORT_ID", this.get32UUID()); |
| ... | ... | @@ -2957,12 +3055,12 @@ public class V1 extends BaseController { |
| 2957 | 3055 | ptd.put("HOMEWORK_ID", resultHomework.getHOMEWORK_ID()); |
| 2958 | 3056 | } |
| 2959 | 3057 | // 2. 根据学生列表生成初始化成绩 |
| 2960 | - if(student.size() > 0){ | |
| 3058 | + if (student.size() > 0) { | |
| 2961 | 3059 | homeworkReporkService.batchSave(student); |
| 2962 | 3060 | } |
| 2963 | 3061 | } |
| 2964 | 3062 | List<ResultStudent> students = resultHomework.getSTUDENTS(); |
| 2965 | - for(ResultStudent student:students){ | |
| 3063 | + for (ResultStudent student : students) { | |
| 2966 | 3064 | // update 学生作业情况 |
| 2967 | 3065 | PageData tpd = new PageData(); |
| 2968 | 3066 | tpd.put("STUDENT_NAME", student.getSTUDENT_NAME()); |
| ... | ... | @@ -2978,15 +3076,14 @@ public class V1 extends BaseController { |
| 2978 | 3076 | homeworkReporkService.update(tpd); |
| 2979 | 3077 | } |
| 2980 | 3078 | res.setData(resultHomework.getHOMEWORK_ID()); |
| 2981 | - }else{ | |
| 3079 | + } else { | |
| 2982 | 3080 | res.setDataError(); |
| 2983 | 3081 | } |
| 2984 | - | |
| 3082 | + | |
| 2985 | 3083 | return res.toJson(); |
| 2986 | - | |
| 3084 | + | |
| 2987 | 3085 | } |
| 2988 | - | |
| 2989 | - | |
| 3086 | + | |
| 2990 | 3087 | /** |
| 2991 | 3088 | * 更新学生详情 |
| 2992 | 3089 | * |
| ... | ... | @@ -2998,24 +3095,27 @@ public class V1 extends BaseController { |
| 2998 | 3095 | @ResponseBody |
| 2999 | 3096 | public String uploadshomework() throws Exception { |
| 3000 | 3097 | ResponseGson<String> res = new ResponseGson<String>(); |
| 3001 | - | |
| 3098 | + | |
| 3002 | 3099 | PageData pd = this.getPageData(); |
| 3003 | 3100 | if (!StringUtils.isEmpty(pd.getJsonString())) { |
| 3004 | - ResultHomework resultHomework = ResultHomework.parse(pd.getJsonString()); | |
| 3101 | + ResultHomework resultHomework = ResultHomework.parse(pd | |
| 3102 | + .getJsonString()); | |
| 3005 | 3103 | PageData homePd = new PageData(); |
| 3006 | 3104 | homePd.put("HOMEWORK_ID", resultHomework.getHOMEWORK_ID()); |
| 3007 | 3105 | homePd.put("CLASS_ID", resultHomework.getCLASS_ID()); |
| 3008 | 3106 | homePd.put("GET_SCORE", resultHomework.getGET_SCORE()); |
| 3009 | - homePd.put("GET_SCORE_PERSENT", resultHomework.getGET_SCORE_PERSENT()); | |
| 3107 | + homePd.put("GET_SCORE_PERSENT", | |
| 3108 | + resultHomework.getGET_SCORE_PERSENT()); | |
| 3010 | 3109 | homePd.put("COMPLETE_DESC", resultHomework.getCOMPLETE_DESC()); |
| 3011 | 3110 | homePd.put("GET_MAX_SCORE", resultHomework.getGET_MAX_SCORE()); |
| 3012 | 3111 | homeworkService.edit(homePd); |
| 3013 | - List<PageData> list = homeworkReporkService.findByHomeworkID(homePd); | |
| 3014 | - if(list == null || list.size() == 0){ | |
| 3112 | + List<PageData> list = homeworkReporkService | |
| 3113 | + .findByHomeworkID(homePd); | |
| 3114 | + if (list == null || list.size() == 0) { | |
| 3015 | 3115 | // 初始化班級作业数据 |
| 3016 | 3116 | // 1. 根据班级id 查询班级学生列表 |
| 3017 | 3117 | List<PageData> student = studentService.findByClassId(homePd); |
| 3018 | - for(PageData ptd : student){ | |
| 3118 | + for (PageData ptd : student) { | |
| 3019 | 3119 | ptd.put("STUDENT_NAME", ptd.get("NAME")); |
| 3020 | 3120 | ptd.put("STUDENT_NO", ptd.get("SNO")); |
| 3021 | 3121 | ptd.put("RANK", student.size() + ""); |
| ... | ... | @@ -3026,12 +3126,12 @@ public class V1 extends BaseController { |
| 3026 | 3126 | ptd.put("HOMEWORK_ID", resultHomework.getHOMEWORK_ID()); |
| 3027 | 3127 | } |
| 3028 | 3128 | // 2. 根据学生列表生成初始化成绩 |
| 3029 | - if(student != null && student.size() > 0){ | |
| 3129 | + if (student != null && student.size() > 0) { | |
| 3030 | 3130 | homeworkReporkService.batchSave(student); |
| 3031 | 3131 | } |
| 3032 | 3132 | } |
| 3033 | 3133 | List<ResultStudent> students = resultHomework.getSTUDENTS(); |
| 3034 | - for(ResultStudent student:students){ | |
| 3134 | + for (ResultStudent student : students) { | |
| 3035 | 3135 | // update 学生作业情况 |
| 3036 | 3136 | PageData tpd = new PageData(); |
| 3037 | 3137 | tpd.put("STUDENT_NAME", student.getSTUDENT_NAME()); |
| ... | ... | @@ -3045,12 +3145,12 @@ public class V1 extends BaseController { |
| 3045 | 3145 | homeworkReporkService.update(tpd); |
| 3046 | 3146 | } |
| 3047 | 3147 | res.setData(resultHomework.getHOMEWORK_ID()); |
| 3048 | - }else{ | |
| 3148 | + } else { | |
| 3049 | 3149 | res.setDataError(); |
| 3050 | 3150 | } |
| 3051 | - | |
| 3151 | + | |
| 3052 | 3152 | return res.toJson(); |
| 3053 | - | |
| 3153 | + | |
| 3054 | 3154 | } |
| 3055 | 3155 | |
| 3056 | 3156 | /** |
| ... | ... | @@ -3158,7 +3258,7 @@ public class V1 extends BaseController { |
| 3158 | 3258 | |
| 3159 | 3259 | @RequestMapping(value = "/liuqin", produces = "application/json;charset=UTF-8") |
| 3160 | 3260 | @ResponseBody |
| 3161 | - public String dosunvotedata() /*throws Exception*/ { | |
| 3261 | + public String dosunvotedata() /* throws Exception */{ | |
| 3162 | 3262 | |
| 3163 | 3263 | PageData pd = new PageData(); |
| 3164 | 3264 | pd.put("dbtype", "mysql"); |
| ... | ... | @@ -3169,7 +3269,7 @@ public class V1 extends BaseController { |
| 3169 | 3269 | pd.put("databaseName", "sunvote"); |
| 3170 | 3270 | pd.put("dbport", "3306"); |
| 3171 | 3271 | List<PageData> resultList = new ArrayList<PageData>(); |
| 3172 | - | |
| 3272 | + | |
| 3173 | 3273 | try { |
| 3174 | 3274 | Connection conn = DbFH.getFHCon(pd); |
| 3175 | 3275 | |
| ... | ... | @@ -3232,7 +3332,7 @@ public class V1 extends BaseController { |
| 3232 | 3332 | detailPd.put("NAME", rs1.getString("studentName")); |
| 3233 | 3333 | detailPd.put("answerStr", rs1.getString("answerStr")); |
| 3234 | 3334 | detailPd.put("SCORE", rs1.getString("totalScore")); |
| 3235 | - detailPd.put("totalScore", rs.getString("paperScore")); | |
| 3335 | + detailPd.put("totalScore", rs.getString("paperScore")); | |
| 3236 | 3336 | detailList.add(detailPd); |
| 3237 | 3337 | } |
| 3238 | 3338 | rs1.close(); |
| ... | ... | @@ -3245,7 +3345,7 @@ public class V1 extends BaseController { |
| 3245 | 3345 | rs.close(); |
| 3246 | 3346 | stmt.close(); |
| 3247 | 3347 | conn.close(); |
| 3248 | - }catch(Exception e){ | |
| 3348 | + } catch (Exception e) { | |
| 3249 | 3349 | e.printStackTrace(); |
| 3250 | 3350 | } |
| 3251 | 3351 | for (PageData paper : resultList) { |
| ... | ... | @@ -3285,8 +3385,9 @@ public class V1 extends BaseController { |
| 3285 | 3385 | } catch (Exception e) { |
| 3286 | 3386 | e.printStackTrace(); |
| 3287 | 3387 | } |
| 3288 | - logger.info("添加测试名称成功:" + paper.get("TESTPAPER_ID")); | |
| 3289 | - List<PageData> detailList = (List<PageData>) paper.get("STUDENT"); | |
| 3388 | + logger.info("添加测试名称成功:" + paper.get("TESTPAPER_ID")); | |
| 3389 | + List<PageData> detailList = (List<PageData>) paper | |
| 3390 | + .get("STUDENT"); | |
| 3290 | 3391 | int i = 0; |
| 3291 | 3392 | List<PageData> testInfoPdList = new ArrayList(); |
| 3292 | 3393 | for (PageData student : detailList) { |
| ... | ... | @@ -3311,7 +3412,7 @@ public class V1 extends BaseController { |
| 3311 | 3412 | } catch (Exception e) { |
| 3312 | 3413 | e.printStackTrace(); |
| 3313 | 3414 | } |
| 3314 | - logger.info("添加学生测试成功:" + studentDetail.get("NAME")); | |
| 3415 | + logger.info("添加学生测试成功:" + studentDetail.get("NAME")); | |
| 3315 | 3416 | |
| 3316 | 3417 | String answerStr = student.getString("answerStr"); |
| 3317 | 3418 | String[] answerStrs = answerStr.split(";"); |
| ... | ... | @@ -3323,7 +3424,8 @@ public class V1 extends BaseController { |
| 3323 | 3424 | testInfoPd.put("PAPER_ID", paper.get("TESTPAPER_ID")); |
| 3324 | 3425 | testInfoPd.put("STUDENT_ID", studentDetail.get("ID")); |
| 3325 | 3426 | testInfoPd.put("TEST_ID", paper.get("TESTPAPER_ID")); |
| 3326 | - testInfoPd.put("QUESTION_ID", paper.get("TESTPAPER_ID") + "" + i); | |
| 3427 | + testInfoPd.put("QUESTION_ID", paper.get("TESTPAPER_ID") | |
| 3428 | + + "" + i); | |
| 3327 | 3429 | String[] ans = answers.split(","); |
| 3328 | 3430 | testInfoPd.put("ANSWER", ans[0]); |
| 3329 | 3431 | testInfoPd.put("RIGHT", ans[1]); |
| ... | ... | @@ -3345,20 +3447,20 @@ public class V1 extends BaseController { |
| 3345 | 3447 | // TODO Auto-generated catch block |
| 3346 | 3448 | e.printStackTrace(); |
| 3347 | 3449 | } |
| 3348 | -// testInfoPdList.add(testInfoPd); | |
| 3450 | + // testInfoPdList.add(testInfoPd); | |
| 3349 | 3451 | } |
| 3350 | -// logger.info("学生详细测试数据"); | |
| 3351 | -// logger.info(testInfoPdList); | |
| 3452 | + // logger.info("学生详细测试数据"); | |
| 3453 | + // logger.info(testInfoPdList); | |
| 3352 | 3454 | try { |
| 3353 | -// testpaperinfoService.batchSave(testInfoPdList); | |
| 3455 | + // testpaperinfoService.batchSave(testInfoPdList); | |
| 3354 | 3456 | } catch (Exception e) { |
| 3355 | 3457 | e.printStackTrace(); |
| 3356 | 3458 | } |
| 3357 | -// logger.info("添加学生详细情况成功:"); | |
| 3459 | + // logger.info("添加学生详细情况成功:"); | |
| 3358 | 3460 | } |
| 3359 | 3461 | } |
| 3360 | 3462 | } |
| 3361 | - | |
| 3463 | + | |
| 3362 | 3464 | ResponseGson<String> res = new ResponseGson<String>(); |
| 3363 | 3465 | return res.toJson(); |
| 3364 | 3466 | } | ... | ... |
src/com/fh/service/sunvote/student/StudentManager.java
| ... | ... | @@ -95,5 +95,14 @@ public interface StudentManager{ |
| 95 | 95 | */ |
| 96 | 96 | public List<PageData> listAllClassByTerm(PageData pd)throws Exception; |
| 97 | 97 | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * | |
| 101 | + * @param pd | |
| 102 | + * @return | |
| 103 | + * @throws Exception | |
| 104 | + */ | |
| 105 | + public PageData findByNumber(PageData pd)throws Exception; | |
| 106 | + | |
| 98 | 107 | } |
| 99 | 108 | ... | ... |
src/com/fh/service/sunvote/student/impl/StudentService.java
| ... | ... | @@ -116,6 +116,14 @@ public class StudentService implements StudentManager{ |
| 116 | 116 | return (PageData)dao.findForObject("StudentMapper.findByName", pd); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | + /**通过学号获取数据 | |
| 120 | + * @param pd | |
| 121 | + * @throws Exception | |
| 122 | + */ | |
| 123 | + public PageData findByNumber(PageData pd)throws Exception{ | |
| 124 | + return (PageData)dao.findForObject("StudentMapper.findByNumber", pd); | |
| 125 | + } | |
| 126 | + | |
| 119 | 127 | /**批量删除 |
| 120 | 128 | * @param ArrayDATA_IDS |
| 121 | 129 | * @throws Exception | ... | ... |