Commit e9f47f909e29b1ed90a04a0d34523f36011bdf53

Authored by 孙向锦
1 parent 96009ee8

优化个人成绩报表

WebRoot/WEB-INF/jsp/sunvote/teacher/stduent_report.jsp
... ... @@ -117,7 +117,7 @@ li {
117 117 <script type="">
118 118 var URL = '<%=basePath%>${URL}';
119 119 </script>
120   - <script src="../static/js/control1.js?a=4"></script>
  120 + <script src="../static/js/control1.js?a=1"></script>
121 121 <!-- 日期框 -->
122 122 <script>
123 123 //lay('#version').html('-v'+ laydate.v);
... ...
WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_report_1.jsp
... ... @@ -118,7 +118,7 @@
118 118 href="report/student_report?studentid=${var.ID}&class_id=${info.CLASS_ID}">${var.NAME}</a>
119 119 </td> --%>
120 120 <td class="center"><div style="width:150px;cursor:hand"><a
121   - onclick="student('${info.CLASS_ID}','${var.ID}')">${var.NAME}</a></div>
  121 + onclick="student('${info.CLASS_ID}','${var.STUDENT_ID}')">${var.NAME}</a></div>
122 122 </td>
123 123 <td class="center"><div style="width:150px;"><fmt:formatNumber type="number"
124 124 value="${var.TOTALSCORE == 0 ? 0: (var.GETSCORE / var.TOTALSCORE * 100)}"
... ...
WebRoot/static/js/control1.js
... ... @@ -96,11 +96,11 @@
96 96 function dataMethod(index,data){
97 97 console.log(data);
98 98 //data0=[];data1=[];data2=[];data3=[];
99   - var GETSCORE = parseInt(data.data.studentList[index].GETSCORE);
100   - var TOTALSCORE = parseInt(data.data.TOTAL_SCORE);
  99 + var GETSCORE = parseFloat(data.data.studentList[index].GETSCORE);
  100 + var TOTALSCORE = parseFloat(data.data.TOTAL_SCORE);
101 101 var ratio=(GETSCORE/TOTALSCORE*100).toFixed(2);
102   - var class_avg= (parseInt(data.data.AVG_SCORE)/ parseInt(data.data.TOTAL_SCORE)*100).toFixed(2);
103   - var class_max=(parseInt(data.data.MAX_SCORE)/ parseInt(data.data.TOTAL_SCORE)*100).toFixed(2);
  102 + var class_avg= (parseFloat(data.data.AVG_SCORE)/ parseFloat(data.data.TOTAL_SCORE)*100).toFixed(2);
  103 + var class_max=(parseFloat(data.data.MAX_SCORE)/ parseFloat(data.data.TOTAL_SCORE)*100).toFixed(2);
104 104  
105 105 var test_num=data.data.studentList[index].testList.length;
106 106 var part_num=test_num;
... ...
resources/mybatis1/sunvote/StudentTestMapper.xml
... ... @@ -164,6 +164,47 @@
164 164  
165 165 </select>
166 166  
  167 +
  168 + <select id="reportClassListData" parameterType="pd" resultType="pd">
  169 + SELECT
  170 + sv_student.ID,
  171 + sv_student.`NAME` AS NAME,
  172 + sv_testpaper.`NAME` AS TNAME,
  173 + sv_studenttest.SCORE AS SCORE,
  174 + sv_testpaper.TOTAL_SCORE AS TOTAL_SCORE,
  175 + sv_testpaper.CREATE_DATE,
  176 + sv_testpaper.AVG_SCORE AS AVG_SCORE,
  177 + sv_testpaper.HIGHT_SCORE AS MAX_SCORE
  178 + FROM
  179 + sv_student
  180 + LEFT JOIN sv_studenttest ON sv_student.ID = sv_studenttest.STUDENT_ID
  181 + LEFT JOIN sv_testpaper ON sv_testpaper.TESTPAPER_ID = sv_studenttest.TEST_ID
  182 + WHERE 1 = 1
  183 + <if test="CLASS_ID != null and CLASS_ID != ''">
  184 + AND sv_student.CLASS_ID = #{CLASS_ID}
  185 + AND sv_testpaper.SCLASS_ID = #{CLASS_ID}
  186 + </if>
  187 + AND sv_testpaper.`NAME` IS NOT NULL
  188 + <if test="TEACHER_ID != null and TEACHER_ID != ''">
  189 + and sv_testpaper.TEACHER_ID = #{TEACHER_ID}
  190 + </if>
  191 + <if test="TEST_TYPE != null and TEST_TYPE != ''">
  192 + and sv_testpaper.TEST_TYPE = #{TEST_TYPE}
  193 + </if>
  194 + <if test="START_DATE != null and START_DATE != ''"><!-- 关键词检索 -->
  195 + and (CREATE_DATE &gt; #{START_DATE})
  196 + </if>
  197 + <if test="END_DATE != null and END_DATE != ''"><!-- 关键词检索 -->
  198 + and (CREATE_DATE &lt; #{END_DATE})
  199 + </if>
  200 + <if test="SUBJECT_ID != null and SUBJECT_ID != ''"><!-- 关键词检索 -->
  201 + and (sv_testpaper.SUBJECT_ID = #{SUBJECT_ID})
  202 + </if>
  203 + ORDER BY
  204 + sv_student.NUMBER,
  205 + sv_testpaper.CREATE_DATE
  206 + </select>
  207 +
167 208 <select id="reportListDataCalc" parameterType="pd" resultType="pd">
168 209  
169 210 SELECT
... ...
src/com/fh/controller/sunvote/report/ReportController.java
... ... @@ -94,13 +94,8 @@ public class ReportController extends BaseController {
94 94 info.put("CLASS_CODE", classPageData.getString("CLASS_CODE"));
95 95 info.put("CLASS_ID", classPageData.getString("ID"));
96 96 pd.put("CLASS_ID", pd.get("CLASSID"));
97   -
98 97 // 2查询班级考试
99 98 pd.put("TEST_TYPE", "1");
100   -// List<PageData> testpaperList = testpaperService.listAll(pd);
101   -// mv.addObject("testpaperList", testpaperList);
102   -// info.put("testsize", testpaperList != null ? testpaperList.size() : 0);
103   -
104 99 // modify 根據班級查詢班級報表
105 100 List<PageData> reportData = v1Service.classReport(pd);
106 101 List<PageData> testpaperList = new ArrayList();
... ... @@ -199,48 +194,6 @@ public class ReportController extends BaseController {
199 194 mv.addObject("testpaperList", testpaperList);
200 195 info.put("testsize", testpaperList != null ? testpaperList.size() : 0);
201 196  
202   - /*
203   - List<PageData> studentList = studentService.listAllClass(pd);
204   - // 查询学生名单及人数
205   - if(studentList != null && studentList.size() > 0){
206   - for(PageData studentPageData : studentList){
207   - studentPageData.put("STUDENT_ID", studentPageData.getString("ID"));
208   - List<PageData> studentTestList = studenttestService.listAll(studentPageData);
209   - for(PageData studentTestPageData :studentTestList){
210   - String score = studentTestPageData.getString("SCORE");
211   - if(!"0".equals(score)){
212   - studentPageData.put(studentTestPageData.getString("TEST_ID"), studentTestPageData.getString("SCORE"));
213   - }else{
214   - studentPageData.put(studentTestPageData.getString("TEST_ID"), "--");
215   - }
216   - }
217   - int totalScore = 0 ;
218   - int getScore = 0 ;
219   - for(PageData testPaperPageData:testpaperList){
220   - String totalScoreStr = testPaperPageData.getString("TOTAL_SCORE");
221   - if(totalScoreStr != null){
222   - try{
223   - totalScore += Integer.parseInt(totalScoreStr);
224   - }catch(Exception ex){
225   - logger.info(ex);
226   - }
227   - }
228   - String getScoreStr = studentPageData.getString(testPaperPageData.getString("TESTPAPER_ID"));
229   - if(getScoreStr != null){
230   - try{
231   - getScore += Integer.parseInt(getScoreStr);
232   - }catch(Exception ex){
233   - logger.info(ex);
234   - }
235   - }
236   - }
237   - studentPageData.put("TOTALSCORE", totalScore);
238   - studentPageData.put("GETSCORE", getScore);
239   -
240   - }
241   - }*/
242   - // 课程平均得分率
243   - // 课程总分
244 197 mv.addObject("studentList", studentList);
245 198 info.put("STUDENT_NUM", studentList != null ? studentList.size() : 0);
246 199 mv.addObject("info", info);
... ... @@ -294,17 +247,72 @@ public class ReportController extends BaseController {
294 247 logBefore(logger, Jurisdiction.getUsername()+"学生报表数据");
295 248 PageData pd = getPageData();
296 249 ResponseGson<PageData> ret = new ResponseGson();
297   -// pd.put("CLASS_ID", pd.get("CLASSID"));
298   - List<PageData> studentList = studentService.listAllClass(pd);
299 250 if ("teacher".equals(getRole())) {
300 251 pd.put("TEACHER_ID", getUserID());
301 252 }
302   - List<PageData> testpaperList = testpaperService.listAll(pd);
  253 + pd.put("TEST_TYPE", "1");
  254 + List<PageData> dataList = studenttestService.reportClassListData(pd);
  255 + List<PageData> studentList = new ArrayList();
  256 + List<PageData> studentTestList = new ArrayList();
  257 + PageData studentPd = null;
  258 + float getScore = 0f ;
  259 + float allGetScore = 0;
  260 + float maxScore = 0 ;
  261 + for(PageData tmp : dataList){
  262 + if(studentPd != null && tmp.get("ID").equals(studentPd.get("ID"))){
  263 + String getScoreStr = tmp.getString("SCORE");
  264 + float score = 0 ;
  265 + if(getScoreStr != null){
  266 + try{
  267 + score = Float.parseFloat(getScoreStr);
  268 + }catch(Exception ex){
  269 + logger.info(ex);
  270 + }
  271 + }
  272 + getScore += score;
  273 + allGetScore += score;
  274 + tmp.put("NAME", tmp.get("TNAME"));
  275 + studentTestList.add(tmp);
  276 + }else{
  277 + if(studentPd != null){
  278 + if(getScore > maxScore){
  279 + maxScore = getScore ;
  280 + }
  281 + studentPd.put("GETSCORE", getScore);
  282 + studentPd.put("testList", studentTestList);
  283 + studentList.add(studentPd);
  284 + }
  285 + studentPd = new PageData();
  286 + studentTestList = new ArrayList();
  287 + getScore = 0 ;
  288 + String getScoreStr = tmp.getString("SCORE");
  289 + float score = 0 ;
  290 + if(getScoreStr != null){
  291 + try{
  292 + score = Float.parseFloat(getScoreStr);
  293 + }catch(Exception ex){
  294 + logger.info(ex);
  295 + }
  296 + }
  297 + getScore += score;
  298 + allGetScore += score;
  299 + studentPd.put("NAME", tmp.get("NAME"));
  300 + studentPd.put("ID", tmp.get("ID"));
  301 + tmp.put("NAME", tmp.get("TNAME"));
  302 + studentTestList.add(tmp);
  303 +
  304 + }
  305 + }
  306 + if(studentPd != null){
  307 + studentPd.put("GETSCORE", getScore);
  308 + studentPd.put("testList", studentTestList);
  309 + studentList.add(studentPd);
  310 + }
303 311 pd.put("ID", pd.get("CLASS_ID"));
304 312 PageData classPageData = sclassService.findById(pd);
305 313 float totalScore = 0 ;
306 314 float avgScore = 0;
307   - for(PageData testPaperPageData:testpaperList){
  315 + for(PageData testPaperPageData:studentTestList){
308 316 String totalScoreStr = testPaperPageData.getString("TOTAL_SCORE");
309 317 if(totalScoreStr != null){
310 318 try{
... ... @@ -323,61 +331,7 @@ public class ReportController extends BaseController {
323 331 }
324 332  
325 333 }
326   - float allGetScore = 0;
327   - float maxScore = 0 ;
328   - // 查询学生名单及人数
329   - if(studentList != null && studentList.size() > 0){
330   - for(PageData studentPageData : studentList){
331   - PageData search = new PageData();
332   - search.put("STUDENT_ID", studentPageData.getString("ID"));
333   - if(pd.containsKey("START_DATE")){
334   - search.put("START_DATE", pd.getString("START_DATE"));
335   - }
336   - if(pd.containsKey("END_DATE")){
337   - search.put("END_DATE", pd.getString("END_DATE"));
338   - }
339   - if("teacher".equals(getRole())){
340   - search.put("TEACHER_ID", getUserID());
341   - }
342   - if(pd.containsKey("SUBJECT_ID")){
343   - search.put("SUBJECT_ID", pd.getString("SUBJECT_ID"));
344   - }
345   - List<PageData> studentTestList = studenttestService.reportListData(search);
346   - studentPageData.put("testList", studentTestList);
347   -
348   - float getScore = 0 ;
349   - for(PageData studentTestPageData:studentTestList){
350   - String getScoreStr = studentTestPageData.getString("SCORE");
351   - if(getScoreStr != null){
352   - try{
353   - getScore += Float.parseFloat(getScoreStr);
354   - }catch(Exception ex){
355   - logger.info(ex);
356   - }
357   - }
358   -
359   - studentTestPageData.getString("TEST_ID");
360   -
361   - }
362   -// studentPageData.put("TOTALSCORE", totalScore);
363   - studentPageData.put("GETSCORE", getScore);
364   - studentPageData.remove("GROUPID");
365   - studentPageData.remove("REMARK");
366   - studentPageData.remove("PARENT_PHONE");
367   - studentPageData.remove("PARENT_NAME");
368   - studentPageData.remove("NUMBER");
369   - studentPageData.remove("SIGN_NO");
370   - studentPageData.remove("KEYPAD_ID");
371   - studentPageData.remove("SNO");
372   - studentPageData.remove("SEX");
373   -
374   - allGetScore += getScore;
375   - if(getScore > maxScore){
376   - maxScore = getScore ;
377   - }
378   -
379   - }
380   - }
  334 +
381 335 classPageData.remove("SCHOOL_ID");
382 336 classPageData.remove("GRADE_ID");
383 337 classPageData.remove("BASESTATION_ID");
... ...
src/com/fh/service/sunvote/studenttest/StudentTestManager.java
1 1 package com.fh.service.sunvote.studenttest;
2 2  
3 3 import java.util.List;
  4 +
4 5 import com.fh.entity.Page;
5 6 import com.fh.util.PageData;
6 7  
... ... @@ -59,5 +60,8 @@ public interface StudentTestManager{
59 60 */
60 61 public void deleteAll(String[] ArrayDATA_IDS)throws Exception;
61 62  
  63 +
  64 + public List<PageData> reportClassListData(PageData pd) throws Exception;
  65 +
62 66 }
63 67  
... ...
src/com/fh/service/sunvote/studenttest/impl/StudentTestService.java
... ... @@ -86,5 +86,10 @@ public class StudentTestService implements StudentTestManager{
86 86 return (List<PageData>)dao.findForList("StudentTestMapper.reportListData", pd);
87 87 }
88 88  
  89 + @Override
  90 + public List<PageData> reportClassListData(PageData pd) throws Exception {
  91 + return (List<PageData>)dao.findForList("StudentTestMapper.reportClassListData", pd);
  92 + }
  93 +
89 94 }
90 95  
... ...