Commit 3a163205f9c9d41e6ab8dd9b0cca5562b89081fc

Authored by 孙向锦
1 parent 705eb8ca

报表优化

WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_1.jsp
... ... @@ -238,7 +238,7 @@
238 238 var subject_id = $("#SUBJECT_ID").val();
239 239 url = url + "&start_date=" + startDate ;
240 240 if(endDate != null){
241   - url = url + + "&end_date=" + endDate;
  241 + url = url + "&end_date=" + endDate;
242 242 }
243 243 if(subject_id != null){
244 244 url = url + "&SUBJECT_ID=" + subject_id;
... ...
WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_test.jsp
... ... @@ -28,7 +28,7 @@
28 28 </style>
29 29 </head>
30 30  
31   -<body style="background:#fff;overflow-y:hidden;">
  31 +<body style="background:#fff;/* overflow-y:hidden; */">
32 32 <div style="padding:20px 20px;">
33 33  
34 34 <form action="report/report_test.do" method="post" name="Form" id="Form">
... ... @@ -36,10 +36,12 @@
36 36 <table style="margin-top:5px;">
37 37 <tr style="height: 30px">
38 38 <td>测验名称: ${testpaperInfo.NAME}</td>
  39 + <c:if test="${display}">
39 40 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
40 41 <td>教师: ${teacherPd.NAME}</td>
41 42 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
42 43 <td>科目名称: ${subjectPd.CNAME}</td>
  44 + </c:if>
43 45 </tr>
44 46 <tr style="height: 30px">
45 47 <td>收卷时间: ${testpaperInfo.END_DATE}</td>
... ... @@ -78,8 +80,8 @@
78 80 <!-- <td class="center"></td> -->
79 81 <td class="center"><div style="width:80px;">--</div></td>
80 82 <c:forEach items="${questionInfo}" var="var" varStatus="vs">
81   - <td class="center"><div style="width:80px;margin:0 auto;"><fmt:formatNumber type="number"
82   - value="${var == 0 ? 0: (var / classInfo.studentNum * 100)}"
  83 + <td class="center"><div style="width:80px;margin:0 auto;"><c:set var="key"><c:out value="${vs.index+1}" /></c:set><fmt:formatNumber type="number"
  84 + value="${(questionInfo[key] / classInfo.studentNum * 100)}"
83 85 maxFractionDigits="1" />%</div></td>
84 86 </c:forEach>
85 87 <!-- <td class="center"></td> -->
... ... @@ -142,7 +144,7 @@
142 144 removeOriginal: true
143 145 };
144 146  
145   - $("#simple-table").tablescroller(options);
  147 +// $("#simple-table").tablescroller(options);
146 148 });
147 149 $(function() {
148 150  
... ...
resources/mybatis1/api/V1Mapper.xml
... ... @@ -260,6 +260,47 @@
260 260 </select>
261 261  
262 262  
  263 + <select id="classReport" parameterType="pd" resultType="pd">
  264 + SELECT
  265 + sv_student.`NAME`,
  266 + sv_studenttest.STUDENT_ID,
  267 + sv_studenttest.TEST_ID,
  268 + sv_studenttest.SCORE,
  269 + sv_testpaper.`NAME` AS PAPER_NAME,
  270 + sv_testpaper.CREATE_DATE,
  271 + sv_testpaper.AVG_SCORE,
  272 + sv_testpaper.TOTAL_SCORE
  273 + FROM
  274 + sv_testpaper
  275 + LEFT JOIN sv_studenttest ON sv_testpaper.TESTPAPER_ID = sv_studenttest.TEST_ID
  276 + LEFT JOIN sv_student ON sv_student.ID = sv_studenttest.STUDENT_ID
  277 + WHERE
  278 + sv_student.`NAME` IS NOT NULL
  279 + <if test="CLASS_ID != null and CLASS_ID != ''">
  280 + AND sv_testpaper.SCLASS_ID = #{CLASS_ID}
  281 + AND sv_student.CLASS_ID = #{CLASS_ID}
  282 + </if>
  283 + <if test="TEACHER_ID != null and TEACHER_ID != ''">
  284 + AND sv_testpaper.TEACHER_ID = #{TEACHER_ID}
  285 + </if>
  286 + <if test="SUBJECT_ID != null and SUBJECT_ID != ''">
  287 + AND sv_testpaper.SUBJECT_ID = #{SUBJECT_ID}
  288 + </if>
  289 + <if test="TEST_TYPE != null and TEST_TYPE != ''">
  290 + AND sv_testpaper.TEST_TYPE = #{TEST_TYPE}
  291 + </if>
  292 + <if test="START_DATE != null and START_DATE != ''">
  293 + AND sv_testpaper.CREATE_DATE &gt; #{START_DATE}
  294 + </if>
  295 + <if test="END_DATE != null and END_DATE != ''">
  296 + AND sv_testpaper.CREATE_DATE &lt; CONCAT(#{END_DATE},'A')
  297 + </if>
  298 + ORDER BY
  299 + (sv_student.NUMBER * 1),
  300 + sv_studenttest.STUDENT_ID,
  301 + sv_testpaper.CREATE_DATE
  302 + </select>
  303 +
263 304  
264 305  
265 306 </mapper>
266 307 \ No newline at end of file
... ...
resources/mybatis1/sunvote/TestPaperInfoMapper.xml
... ... @@ -263,6 +263,29 @@
263 263 (sv_paperquestion.RANK * 1)
264 264 </select>
265 265  
  266 + <select id="reportTestPaperDetail" parameterType="pd" resultType="pd">
  267 + SELECT
  268 + sv_student.`NAME`,
  269 + sv_student.ID,
  270 + sv_student.KEYPAD_ID,
  271 + sv_student.NUMBER,
  272 + sv_testpaperinfo.STUDENT_ID,
  273 + sv_testpaperinfo.QUESTION_ID,
  274 + sv_testpaperinfo.SCORE,
  275 + sv_testpaperinfo.ANSWER,
  276 + sv_testpaperinfo.`RIGHT`,
  277 + sv_paperquestion.RANK
  278 + FROM
  279 + sv_testpaperinfo
  280 + LEFT JOIN sv_student ON sv_testpaperinfo.STUDENT_ID = sv_student.ID
  281 + LEFT JOIN sv_paperquestion ON sv_testpaperinfo.QUESTION_ID = sv_paperquestion.QUESTION_ID
  282 + WHERE
  283 + sv_testpaperinfo.TEST_ID = #{TEST_ID}
  284 + ORDER BY
  285 + sv_testpaperinfo.STUDENT_ID,
  286 + (sv_paperquestion.RANK * 1)
  287 + </select>
  288 +
266 289  
267 290 <!-- 批量删除 -->
268 291 <delete id="deleteAll" parameterType="String">
... ...
src/com/fh/bean/TestPaper.java
... ... @@ -49,6 +49,8 @@ public class TestPaper {
49 49  
50 50 private String test_type ;
51 51  
  52 + private String subject_id ;
  53 +
52 54 private List<StudentAnswer> students = new ArrayList<StudentAnswer>();
53 55  
54 56 public String getTestpaperId() {
... ... @@ -187,6 +189,16 @@ public class TestPaper {
187 189 return gson.fromJson(json, TestPaper.class);
188 190 }
189 191  
  192 +
  193 +
  194 + public String getSubject_id() {
  195 + return subject_id;
  196 + }
  197 +
  198 + public void setSubject_id(String subject_id) {
  199 + this.subject_id = subject_id;
  200 + }
  201 +
190 202 public String toJson(){
191 203 Gson gson = new Gson();
192 204 return gson.toJson(this);
... ...
src/com/fh/controller/api/V1.java
... ... @@ -1607,6 +1607,7 @@ public class V1 extends BaseController {
1607 1607 testPd.put("LOW_SCORE", testPaper.getLowScore());
1608 1608 testPd.put("AVG_SCORE", testPaper.getAvgScore());
1609 1609 testPd.put("TOTAL_SCORE", testPaper.getTotalScore());
  1610 + testPd.put("SUBJECT_ID", testPaper.getSubject_id());
1610 1611 testPd.put("REMARK", testPaper.getRemark());
1611 1612 testpaperService.save(testPd);
1612 1613 if (testPaper.getStudents() != null) {
... ... @@ -1728,6 +1729,7 @@ public class V1 extends BaseController {
1728 1729 testPd.put("LOW_SCORE", testPaper.getLowScore());
1729 1730 testPd.put("AVG_SCORE", testPaper.getAvgScore());
1730 1731 testPd.put("TOTAL_SCORE", testPaper.getTotalScore());
  1732 + testPd.put("SUBJECT_ID", testPaper.getSubject_id());
1731 1733 testPd.put("REMARK", testPaper.getRemark());
1732 1734 testpaperService.save(testPd);
1733 1735 if (testPaper.getStudents() != null) {
... ...
src/com/fh/controller/sunvote/report/ReportController.java
... ... @@ -20,7 +20,6 @@ import com.fh.service.sunvote.student.StudentManager;
20 20 import com.fh.service.sunvote.studenttest.StudentTestManager;
21 21 import com.fh.service.sunvote.subject.SubjectManager;
22 22 import com.fh.service.sunvote.teacher.TeacherManager;
23   -import com.fh.service.sunvote.teacher.impl.TeacherService;
24 23 import com.fh.service.sunvote.testpaper.TestPaperManager;
25 24 import com.fh.service.sunvote.testpaperinfo.TestPaperInfoManager;
26 25 import com.fh.util.Jurisdiction;
... ... @@ -95,15 +94,113 @@ public class ReportController extends BaseController {
95 94 info.put("CLASS_CODE", classPageData.getString("CLASS_CODE"));
96 95 info.put("CLASS_ID", classPageData.getString("ID"));
97 96 pd.put("CLASS_ID", pd.get("CLASSID"));
98   - List<PageData> studentList = studentService.listAllClass(pd);
99   -
100   -
101 97  
102 98 // 2查询班级考试
103 99 pd.put("TEST_TYPE", "1");
104   - List<PageData> testpaperList = testpaperService.listAll(pd);
  100 +// List<PageData> testpaperList = testpaperService.listAll(pd);
  101 +// mv.addObject("testpaperList", testpaperList);
  102 +// info.put("testsize", testpaperList != null ? testpaperList.size() : 0);
  103 +
  104 + // modify 根據班級查詢班級報表
  105 + List<PageData> reportData = v1Service.classReport(pd);
  106 + List<PageData> testpaperList = new ArrayList();
  107 + List<PageData> studentList = new ArrayList();
  108 + PageData studentPd = null;
  109 + float totalScore = 0 ;
  110 + float getScore = 0 ;
  111 + for(PageData item : reportData){
  112 +
  113 + // 学生列表
  114 + if(studentPd != null && item.get("STUDENT_ID").equals(studentPd.get("STUDENT_ID"))){
  115 + //
  116 + String score = item.getString("SCORE");
  117 + if(!"0".equals(score)){
  118 + studentPd.put(item.get("TEST_ID"), item.get("SCORE"));
  119 + }else{
  120 + studentPd.put(item.get("TEST_ID"), "--");
  121 + }
  122 + String totalScoreStr = item.getString("TOTAL_SCORE");
  123 + if(totalScoreStr != null){
  124 + try{
  125 + totalScore +=Float.parseFloat(totalScoreStr);
  126 + }catch(Exception ex){
  127 + logger.info(ex);
  128 + }
  129 + }
  130 + if(score != null){
  131 + try{
  132 + getScore += Float.parseFloat(score);
  133 + }catch(Exception ex){
  134 + logger.info(ex);
  135 + }
  136 + }
  137 + }else{
  138 + if(studentPd != null){
  139 + studentPd.put("TOTALSCORE", totalScore);
  140 + studentPd.put("GETSCORE", getScore);
  141 + studentList.add(studentPd);
  142 + totalScore = 0 ;
  143 + getScore = 0 ;
  144 + }
  145 + studentPd = new PageData();
  146 + studentPd.put("STUDENT_ID", item.get("STUDENT_ID"));
  147 + studentPd.put("NAME", item.get("NAME"));
  148 + String score = item.getString("SCORE");
  149 + if(!"0".equals(score)){
  150 + studentPd.put(item.get("TEST_ID"), item.get("SCORE"));
  151 + }else{
  152 + studentPd.put(item.get("TEST_ID"), "--");
  153 + }
  154 + String totalScoreStr = item.getString("TOTAL_SCORE");
  155 + if(totalScoreStr != null){
  156 + try{
  157 + totalScore += Float.parseFloat(totalScoreStr);
  158 + }catch(Exception ex){
  159 + logger.info(ex);
  160 + }
  161 + }
  162 + if(score != null){
  163 + try{
  164 + getScore += Float.parseFloat(score);
  165 + }catch(Exception ex){
  166 + logger.info(ex);
  167 + }
  168 + }
  169 +
  170 + }
  171 + PageData clone = new PageData(item);
  172 + // 试卷列表
  173 + if(!contain(testpaperList, clone, "TEST_ID")){
  174 + clone.put("TESTPAPER_ID", clone.get("TEST_ID"));
  175 + clone.put("NAME", clone.get("PAPER_NAME"));
  176 + testpaperList.add(clone);
  177 + }
  178 +
  179 + }
  180 + if(studentPd != null){
  181 + studentPd.put("TOTALSCORE", totalScore);
  182 + studentPd.put("GETSCORE", getScore);
  183 + studentList.add(studentPd);
  184 + totalScore = 0 ;
  185 + getScore = 0 ;
  186 + }
  187 +
  188 + Collections.sort(testpaperList,new Comparator<PageData>(){
  189 +
  190 + @Override
  191 + public int compare(PageData o1, PageData o2) {
  192 + String o1GetScore = o1.getString("CREATE_DATE");
  193 + String o2GetScore = o2.getString("CREATE_DATE");
  194 + return - o1GetScore.compareToIgnoreCase(o2GetScore);
  195 + }
  196 +
  197 + });
  198 +
105 199 mv.addObject("testpaperList", testpaperList);
106 200 info.put("testsize", testpaperList != null ? testpaperList.size() : 0);
  201 +
  202 + /*
  203 + List<PageData> studentList = studentService.listAllClass(pd);
107 204 // 查询学生名单及人数
108 205 if(studentList != null && studentList.size() > 0){
109 206 for(PageData studentPageData : studentList){
... ... @@ -141,7 +238,7 @@ public class ReportController extends BaseController {
141 238 studentPageData.put("GETSCORE", getScore);
142 239  
143 240 }
144   - }
  241 + }*/
145 242 // 课程平均得分率
146 243 // 课程总分
147 244 mv.addObject("studentList", studentList);
... ... @@ -154,6 +251,15 @@ public class ReportController extends BaseController {
154 251 return mv;
155 252 }
156 253  
  254 + private boolean contain(List<PageData> source, PageData aim,String key){
  255 + for(PageData tp : source){
  256 + if(tp.get(key) != null && tp.get(key).equals(aim.get(key))){
  257 + return true;
  258 + }
  259 + }
  260 + return false;
  261 + }
  262 +
157 263 @RequestMapping(value="/teacher_report")
158 264 public ModelAndView teacher_report() throws Exception{
159 265 logBefore(logger, Jurisdiction.getUsername()+"教师报表");
... ... @@ -305,9 +411,70 @@ public class ReportController extends BaseController {
305 411 subjectPd.put("ID", testpaperPd.get("SUBJECT_ID"));
306 412 subjectPd = subjectService.findById(subjectPd);
307 413  
  414 + pd.put("TEST_ID", pd.get("TESTID"));
  415 + List<PageData> detail = testpaperinfoService.reportTestPaperDetail(pd);
308 416  
  417 + List<PageData> studentList = new ArrayList();
  418 +// List<Integer> questionList = new ArrayList<Integer>();
  419 + PageData questionList = new PageData();
  420 + List<PageData> tqList = new ArrayList<PageData>();
  421 + PageData tmp = null;
  422 + float getScore = 0 ;
  423 + for(PageData tpd : detail){
  424 + if(tmp != null && tpd.get("ID").equals(tmp.get("ID"))){
  425 + try{
  426 + getScore += Float.parseFloat(tpd.getString("SCORE"));
  427 + }catch(Exception ex){};
  428 + tqList.add(tpd);
  429 + if(questionList.get(tpd.get("RANK")) != null){
  430 + if("1".equals(tpd.get("RIGHT"))){
  431 + Integer num = (Integer)questionList.get(tpd.get("RANK"));
  432 + questionList.put(tpd.get("RANK"), num+1);
  433 + }
  434 + }else{
  435 + if("1".equals(tpd.get("RIGHT"))){
  436 + questionList.put(tpd.get("RANK"), 1);
  437 + }else{
  438 + questionList.put(tpd.get("RANK"), 0);
  439 + }
  440 + }
  441 + }else{
  442 + if(tmp != null){
  443 + tmp.put("GETSCORE", getScore);
  444 + studentList.add(tmp);
  445 + }
  446 + getScore = 0 ;
  447 + tmp = new PageData();
  448 + tqList = new ArrayList<PageData>();
  449 + tmp.put("NAME", tpd.get("NAME"));
  450 + tmp.put("KEYPAD_ID", tpd.get("KEYPAD_ID"));
  451 + tmp.put("NUMBER", tpd.get("NUMBER"));
  452 + tmp.put("ID", tpd.get("ID"));
  453 + tqList.add(tpd);
  454 + tmp.put("detail", tqList);
  455 + try{
  456 + getScore += Float.parseFloat(tpd.getString("SCORE"));
  457 + }catch(Exception ex){};
  458 + if(questionList.get(tpd.get("RANK")) != null){
  459 + if("1".equals(tpd.get("RIGHT"))){
  460 + Integer num = (Integer)questionList.get(tpd.get("RANK"));
  461 + questionList.put(tpd.get("RANK"), num+1);
  462 + }
  463 + }else{
  464 + if("1".equals(tpd.get("RIGHT"))){
  465 + questionList.put(tpd.get("RANK"), 1);
  466 + }else{
  467 + questionList.put(tpd.get("RANK"), 0);
  468 + }
  469 + }
  470 + }
  471 + }
  472 + if(tmp != null){
  473 + tmp.put("GETSCORE", getScore);
  474 + studentList.add(tmp);
  475 + }
309 476  
310   - // 查询班级学生
  477 + /*// 查询班级学生
311 478 List<PageData> studentList = studentService.listAllClass(pd);
312 479 List<Integer> questionList = new ArrayList<Integer>();
313 480 for(PageData studentPd : studentList){
... ... @@ -338,7 +505,7 @@ public class ReportController extends BaseController {
338 505  
339 506 }
340 507 studentPd.put("GETSCORE", score);
341   - }
  508 + }*/
342 509  
343 510  
344 511 Collections.sort(studentList,new Comparator<PageData>(){
... ... @@ -363,7 +530,7 @@ public class ReportController extends BaseController {
363 530 String n1 = o1.getString("NUMBER");
364 531 String n2 = o2.getString("NUMBER");
365 532 if(n1 != null && n2 != null){
366   - return n1.compareToIgnoreCase(n2);
  533 + return Integer.parseInt(n1) - Integer.parseInt(n2);
367 534 }
368 535 }
369 536 return o2score - o1score > 0 ? 1 : -1;
... ... @@ -399,6 +566,13 @@ public class ReportController extends BaseController {
399 566 }
400 567  
401 568 classPageData.put("studentNum", studentList.size());
  569 +
  570 + if("teacher".equals(getRole())){
  571 + mv.addObject("display", false);
  572 + }else{
  573 + mv.addObject("display", true);
  574 + }
  575 +
402 576 mv.addObject("classInfo", classPageData);
403 577 mv.addObject("testpaperInfo", testpaperPd);
404 578 mv.addObject("questionInfo", questionList);
... ...
src/com/fh/service/api/V1Manager.java
... ... @@ -25,4 +25,6 @@ public interface V1Manager {
25 25 public List<PageData> getAdminInfo(PageData pd) throws Exception;
26 26  
27 27 public List<PageData> getClassBySchoolAndGradle(PageData pd) throws Exception;
  28 +
  29 + public List<PageData> classReport(PageData pd) throws Exception;
28 30 }
... ...
src/com/fh/service/api/impl/V1Service.java
... ... @@ -66,5 +66,11 @@ public class V1Service implements V1Manager {
66 66 throws Exception {
67 67 return (List<PageData>)dao.findForList("V1Mapper.getClassBySchoolAndGradle", pd);
68 68 }
  69 +
  70 + @Override
  71 + public List<PageData> classReport(PageData pd)
  72 + throws Exception {
  73 + return (List<PageData>)dao.findForList("V1Mapper.classReport", pd);
  74 + }
69 75  
70 76 }
... ...
src/com/fh/service/sunvote/testpaperinfo/TestPaperInfoManager.java
... ... @@ -54,6 +54,9 @@ public interface TestPaperInfoManager{
54 54 */
55 55 public List<PageData> reportPaperDetail(PageData pd)throws Exception;
56 56  
  57 +
  58 + public List<PageData> reportTestPaperDetail(PageData pd)throws Exception;
  59 +
57 60 /**通过id获取数据
58 61 * @param pd
59 62 * @throws Exception
... ...
src/com/fh/service/sunvote/testpaperinfo/impl/TestPaperInfoService.java
... ... @@ -93,6 +93,11 @@ public class TestPaperInfoService implements TestPaperInfoManager{
93 93 return (List<PageData>)dao.findForList("TestPaperInfoMapper.reportPaperDetail", pd);
94 94 }
95 95  
  96 + @SuppressWarnings("unchecked")
  97 + public List<PageData> reportTestPaperDetail(PageData pd)throws Exception{
  98 + return (List<PageData>)dao.findForList("TestPaperInfoMapper.reportTestPaperDetail", pd);
  99 + }
  100 +
96 101 /**通过id获取数据
97 102 * @param pd
98 103 * @throws Exception
... ...
src/com/fh/util/PageData.java
... ... @@ -167,4 +167,8 @@ public class PageData extends HashMap implements Map{
167 167 return map.values();
168 168 }
169 169  
  170 +
  171 + public PageData(PageData tp){
  172 + this.map = new HashMap(tp.map);
  173 + }
170 174 }
... ...