From 3a163205f9c9d41e6ab8dd9b0cca5562b89081fc Mon Sep 17 00:00:00 2001 From: Elvis Date: Tue, 27 Nov 2018 16:21:06 +0800 Subject: [PATCH] 报表优化 --- WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_1.jsp | 2 +- WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_test.jsp | 10 ++++++---- resources/mybatis1/api/V1Mapper.xml | 41 +++++++++++++++++++++++++++++++++++++++++ resources/mybatis1/sunvote/TestPaperInfoMapper.xml | 23 +++++++++++++++++++++++ src/com/fh/bean/TestPaper.java | 12 ++++++++++++ src/com/fh/controller/api/V1.java | 2 ++ src/com/fh/controller/sunvote/report/ReportController.java | 192 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- src/com/fh/service/api/V1Manager.java | 2 ++ src/com/fh/service/api/impl/V1Service.java | 6 ++++++ src/com/fh/service/sunvote/testpaperinfo/TestPaperInfoManager.java | 3 +++ src/com/fh/service/sunvote/testpaperinfo/impl/TestPaperInfoService.java | 5 +++++ src/com/fh/util/PageData.java | 4 ++++ 12 files changed, 288 insertions(+), 14 deletions(-) diff --git a/WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_1.jsp b/WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_1.jsp index 4d7fc08..f36d38d 100644 --- a/WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_1.jsp +++ b/WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_1.jsp @@ -238,7 +238,7 @@ var subject_id = $("#SUBJECT_ID").val(); url = url + "&start_date=" + startDate ; if(endDate != null){ - url = url + + "&end_date=" + endDate; + url = url + "&end_date=" + endDate; } if(subject_id != null){ url = url + "&SUBJECT_ID=" + subject_id; diff --git a/WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_test.jsp b/WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_test.jsp index 1c2dfb8..0e57e9b 100644 --- a/WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_test.jsp +++ b/WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_test.jsp @@ -28,7 +28,7 @@ - +
@@ -36,10 +36,12 @@ + + @@ -78,8 +80,8 @@ - @@ -142,7 +144,7 @@ removeOriginal: true }; - $("#simple-table").tablescroller(options); +// $("#simple-table").tablescroller(options); }); $(function() { diff --git a/resources/mybatis1/api/V1Mapper.xml b/resources/mybatis1/api/V1Mapper.xml index 018dd01..1879d19 100644 --- a/resources/mybatis1/api/V1Mapper.xml +++ b/resources/mybatis1/api/V1Mapper.xml @@ -260,6 +260,47 @@ + + \ No newline at end of file diff --git a/resources/mybatis1/sunvote/TestPaperInfoMapper.xml b/resources/mybatis1/sunvote/TestPaperInfoMapper.xml index 12b2da8..1c71d75 100644 --- a/resources/mybatis1/sunvote/TestPaperInfoMapper.xml +++ b/resources/mybatis1/sunvote/TestPaperInfoMapper.xml @@ -263,6 +263,29 @@ (sv_paperquestion.RANK * 1) + + diff --git a/src/com/fh/bean/TestPaper.java b/src/com/fh/bean/TestPaper.java index cc5ea6e..370c012 100644 --- a/src/com/fh/bean/TestPaper.java +++ b/src/com/fh/bean/TestPaper.java @@ -49,6 +49,8 @@ public class TestPaper { private String test_type ; + private String subject_id ; + private List students = new ArrayList(); public String getTestpaperId() { @@ -187,6 +189,16 @@ public class TestPaper { return gson.fromJson(json, TestPaper.class); } + + + public String getSubject_id() { + return subject_id; + } + + public void setSubject_id(String subject_id) { + this.subject_id = subject_id; + } + public String toJson(){ Gson gson = new Gson(); return gson.toJson(this); diff --git a/src/com/fh/controller/api/V1.java b/src/com/fh/controller/api/V1.java index 6752243..0c43ff1 100644 --- a/src/com/fh/controller/api/V1.java +++ b/src/com/fh/controller/api/V1.java @@ -1607,6 +1607,7 @@ public class V1 extends BaseController { testPd.put("LOW_SCORE", testPaper.getLowScore()); testPd.put("AVG_SCORE", testPaper.getAvgScore()); testPd.put("TOTAL_SCORE", testPaper.getTotalScore()); + testPd.put("SUBJECT_ID", testPaper.getSubject_id()); testPd.put("REMARK", testPaper.getRemark()); testpaperService.save(testPd); if (testPaper.getStudents() != null) { @@ -1728,6 +1729,7 @@ public class V1 extends BaseController { testPd.put("LOW_SCORE", testPaper.getLowScore()); testPd.put("AVG_SCORE", testPaper.getAvgScore()); testPd.put("TOTAL_SCORE", testPaper.getTotalScore()); + testPd.put("SUBJECT_ID", testPaper.getSubject_id()); testPd.put("REMARK", testPaper.getRemark()); testpaperService.save(testPd); if (testPaper.getStudents() != null) { diff --git a/src/com/fh/controller/sunvote/report/ReportController.java b/src/com/fh/controller/sunvote/report/ReportController.java index 1d21063..b7a23e6 100644 --- a/src/com/fh/controller/sunvote/report/ReportController.java +++ b/src/com/fh/controller/sunvote/report/ReportController.java @@ -20,7 +20,6 @@ import com.fh.service.sunvote.student.StudentManager; import com.fh.service.sunvote.studenttest.StudentTestManager; import com.fh.service.sunvote.subject.SubjectManager; import com.fh.service.sunvote.teacher.TeacherManager; -import com.fh.service.sunvote.teacher.impl.TeacherService; import com.fh.service.sunvote.testpaper.TestPaperManager; import com.fh.service.sunvote.testpaperinfo.TestPaperInfoManager; import com.fh.util.Jurisdiction; @@ -95,15 +94,113 @@ public class ReportController extends BaseController { info.put("CLASS_CODE", classPageData.getString("CLASS_CODE")); info.put("CLASS_ID", classPageData.getString("ID")); pd.put("CLASS_ID", pd.get("CLASSID")); - List studentList = studentService.listAllClass(pd); - - // 2查询班级考试 pd.put("TEST_TYPE", "1"); - List testpaperList = testpaperService.listAll(pd); +// List testpaperList = testpaperService.listAll(pd); +// mv.addObject("testpaperList", testpaperList); +// info.put("testsize", testpaperList != null ? testpaperList.size() : 0); + + // modify 根據班級查詢班級報表 + List reportData = v1Service.classReport(pd); + List testpaperList = new ArrayList(); + List studentList = new ArrayList(); + PageData studentPd = null; + float totalScore = 0 ; + float getScore = 0 ; + for(PageData item : reportData){ + + // 学生列表 + if(studentPd != null && item.get("STUDENT_ID").equals(studentPd.get("STUDENT_ID"))){ + // + String score = item.getString("SCORE"); + if(!"0".equals(score)){ + studentPd.put(item.get("TEST_ID"), item.get("SCORE")); + }else{ + studentPd.put(item.get("TEST_ID"), "--"); + } + String totalScoreStr = item.getString("TOTAL_SCORE"); + if(totalScoreStr != null){ + try{ + totalScore +=Float.parseFloat(totalScoreStr); + }catch(Exception ex){ + logger.info(ex); + } + } + if(score != null){ + try{ + getScore += Float.parseFloat(score); + }catch(Exception ex){ + logger.info(ex); + } + } + }else{ + if(studentPd != null){ + studentPd.put("TOTALSCORE", totalScore); + studentPd.put("GETSCORE", getScore); + studentList.add(studentPd); + totalScore = 0 ; + getScore = 0 ; + } + studentPd = new PageData(); + studentPd.put("STUDENT_ID", item.get("STUDENT_ID")); + studentPd.put("NAME", item.get("NAME")); + String score = item.getString("SCORE"); + if(!"0".equals(score)){ + studentPd.put(item.get("TEST_ID"), item.get("SCORE")); + }else{ + studentPd.put(item.get("TEST_ID"), "--"); + } + String totalScoreStr = item.getString("TOTAL_SCORE"); + if(totalScoreStr != null){ + try{ + totalScore += Float.parseFloat(totalScoreStr); + }catch(Exception ex){ + logger.info(ex); + } + } + if(score != null){ + try{ + getScore += Float.parseFloat(score); + }catch(Exception ex){ + logger.info(ex); + } + } + + } + PageData clone = new PageData(item); + // 试卷列表 + if(!contain(testpaperList, clone, "TEST_ID")){ + clone.put("TESTPAPER_ID", clone.get("TEST_ID")); + clone.put("NAME", clone.get("PAPER_NAME")); + testpaperList.add(clone); + } + + } + if(studentPd != null){ + studentPd.put("TOTALSCORE", totalScore); + studentPd.put("GETSCORE", getScore); + studentList.add(studentPd); + totalScore = 0 ; + getScore = 0 ; + } + + Collections.sort(testpaperList,new Comparator(){ + + @Override + public int compare(PageData o1, PageData o2) { + String o1GetScore = o1.getString("CREATE_DATE"); + String o2GetScore = o2.getString("CREATE_DATE"); + return - o1GetScore.compareToIgnoreCase(o2GetScore); + } + + }); + mv.addObject("testpaperList", testpaperList); info.put("testsize", testpaperList != null ? testpaperList.size() : 0); + + /* + List studentList = studentService.listAllClass(pd); // 查询学生名单及人数 if(studentList != null && studentList.size() > 0){ for(PageData studentPageData : studentList){ @@ -141,7 +238,7 @@ public class ReportController extends BaseController { studentPageData.put("GETSCORE", getScore); } - } + }*/ // 课程平均得分率 // 课程总分 mv.addObject("studentList", studentList); @@ -154,6 +251,15 @@ public class ReportController extends BaseController { return mv; } + private boolean contain(List source, PageData aim,String key){ + for(PageData tp : source){ + if(tp.get(key) != null && tp.get(key).equals(aim.get(key))){ + return true; + } + } + return false; + } + @RequestMapping(value="/teacher_report") public ModelAndView teacher_report() throws Exception{ logBefore(logger, Jurisdiction.getUsername()+"教师报表"); @@ -305,9 +411,70 @@ public class ReportController extends BaseController { subjectPd.put("ID", testpaperPd.get("SUBJECT_ID")); subjectPd = subjectService.findById(subjectPd); + pd.put("TEST_ID", pd.get("TESTID")); + List detail = testpaperinfoService.reportTestPaperDetail(pd); + List studentList = new ArrayList(); +// List questionList = new ArrayList(); + PageData questionList = new PageData(); + List tqList = new ArrayList(); + PageData tmp = null; + float getScore = 0 ; + for(PageData tpd : detail){ + if(tmp != null && tpd.get("ID").equals(tmp.get("ID"))){ + try{ + getScore += Float.parseFloat(tpd.getString("SCORE")); + }catch(Exception ex){}; + tqList.add(tpd); + if(questionList.get(tpd.get("RANK")) != null){ + if("1".equals(tpd.get("RIGHT"))){ + Integer num = (Integer)questionList.get(tpd.get("RANK")); + questionList.put(tpd.get("RANK"), num+1); + } + }else{ + if("1".equals(tpd.get("RIGHT"))){ + questionList.put(tpd.get("RANK"), 1); + }else{ + questionList.put(tpd.get("RANK"), 0); + } + } + }else{ + if(tmp != null){ + tmp.put("GETSCORE", getScore); + studentList.add(tmp); + } + getScore = 0 ; + tmp = new PageData(); + tqList = new ArrayList(); + tmp.put("NAME", tpd.get("NAME")); + tmp.put("KEYPAD_ID", tpd.get("KEYPAD_ID")); + tmp.put("NUMBER", tpd.get("NUMBER")); + tmp.put("ID", tpd.get("ID")); + tqList.add(tpd); + tmp.put("detail", tqList); + try{ + getScore += Float.parseFloat(tpd.getString("SCORE")); + }catch(Exception ex){}; + if(questionList.get(tpd.get("RANK")) != null){ + if("1".equals(tpd.get("RIGHT"))){ + Integer num = (Integer)questionList.get(tpd.get("RANK")); + questionList.put(tpd.get("RANK"), num+1); + } + }else{ + if("1".equals(tpd.get("RIGHT"))){ + questionList.put(tpd.get("RANK"), 1); + }else{ + questionList.put(tpd.get("RANK"), 0); + } + } + } + } + if(tmp != null){ + tmp.put("GETSCORE", getScore); + studentList.add(tmp); + } - // 查询班级学生 + /*// 查询班级学生 List studentList = studentService.listAllClass(pd); List questionList = new ArrayList(); for(PageData studentPd : studentList){ @@ -338,7 +505,7 @@ public class ReportController extends BaseController { } studentPd.put("GETSCORE", score); - } + }*/ Collections.sort(studentList,new Comparator(){ @@ -363,7 +530,7 @@ public class ReportController extends BaseController { String n1 = o1.getString("NUMBER"); String n2 = o2.getString("NUMBER"); if(n1 != null && n2 != null){ - return n1.compareToIgnoreCase(n2); + return Integer.parseInt(n1) - Integer.parseInt(n2); } } return o2score - o1score > 0 ? 1 : -1; @@ -399,6 +566,13 @@ public class ReportController extends BaseController { } classPageData.put("studentNum", studentList.size()); + + if("teacher".equals(getRole())){ + mv.addObject("display", false); + }else{ + mv.addObject("display", true); + } + mv.addObject("classInfo", classPageData); mv.addObject("testpaperInfo", testpaperPd); mv.addObject("questionInfo", questionList); diff --git a/src/com/fh/service/api/V1Manager.java b/src/com/fh/service/api/V1Manager.java index 1042185..43108fa 100644 --- a/src/com/fh/service/api/V1Manager.java +++ b/src/com/fh/service/api/V1Manager.java @@ -25,4 +25,6 @@ public interface V1Manager { public List getAdminInfo(PageData pd) throws Exception; public List getClassBySchoolAndGradle(PageData pd) throws Exception; + + public List classReport(PageData pd) throws Exception; } diff --git a/src/com/fh/service/api/impl/V1Service.java b/src/com/fh/service/api/impl/V1Service.java index 182e9dc..58058e0 100644 --- a/src/com/fh/service/api/impl/V1Service.java +++ b/src/com/fh/service/api/impl/V1Service.java @@ -66,5 +66,11 @@ public class V1Service implements V1Manager { throws Exception { return (List)dao.findForList("V1Mapper.getClassBySchoolAndGradle", pd); } + + @Override + public List classReport(PageData pd) + throws Exception { + return (List)dao.findForList("V1Mapper.classReport", pd); + } } diff --git a/src/com/fh/service/sunvote/testpaperinfo/TestPaperInfoManager.java b/src/com/fh/service/sunvote/testpaperinfo/TestPaperInfoManager.java index b7ddb8a..efae8fe 100644 --- a/src/com/fh/service/sunvote/testpaperinfo/TestPaperInfoManager.java +++ b/src/com/fh/service/sunvote/testpaperinfo/TestPaperInfoManager.java @@ -54,6 +54,9 @@ public interface TestPaperInfoManager{ */ public List reportPaperDetail(PageData pd)throws Exception; + + public List reportTestPaperDetail(PageData pd)throws Exception; + /**通过id获取数据 * @param pd * @throws Exception diff --git a/src/com/fh/service/sunvote/testpaperinfo/impl/TestPaperInfoService.java b/src/com/fh/service/sunvote/testpaperinfo/impl/TestPaperInfoService.java index 6911f71..b3fba96 100644 --- a/src/com/fh/service/sunvote/testpaperinfo/impl/TestPaperInfoService.java +++ b/src/com/fh/service/sunvote/testpaperinfo/impl/TestPaperInfoService.java @@ -93,6 +93,11 @@ public class TestPaperInfoService implements TestPaperInfoManager{ return (List)dao.findForList("TestPaperInfoMapper.reportPaperDetail", pd); } + @SuppressWarnings("unchecked") + public List reportTestPaperDetail(PageData pd)throws Exception{ + return (List)dao.findForList("TestPaperInfoMapper.reportTestPaperDetail", pd); + } + /**通过id获取数据 * @param pd * @throws Exception diff --git a/src/com/fh/util/PageData.java b/src/com/fh/util/PageData.java index 68d2281..c4e625c 100644 --- a/src/com/fh/util/PageData.java +++ b/src/com/fh/util/PageData.java @@ -167,4 +167,8 @@ public class PageData extends HashMap implements Map{ return map.values(); } + + public PageData(PageData tp){ + this.map = new HashMap(tp.map); + } } -- libgit2 0.21.4
测验名称: ${testpaperInfo.NAME}                 教师: ${teacherPd.NAME}                  科目名称: ${subjectPd.CNAME}
收卷时间: ${testpaperInfo.END_DATE}
--
%