Commit 41bc74d2cdd7b2d2ecb7c222272ae09a66819a4e
1 parent
76263c7c
添加空判断
Showing
1 changed file
with
54 additions
and
47 deletions
src/com/fh/controller/sunvote/homework/HomeworkController.java
... | ... | @@ -302,58 +302,65 @@ public class HomeworkController extends BaseController { |
302 | 302 | } |
303 | 303 | pd.put("CLASSES", list); |
304 | 304 | |
305 | - // 对应班级数据 | |
306 | - PageData data = new PageData(); | |
307 | - List<PageData> studentList = studentService.findByClassId(pd); | |
308 | - | |
309 | - List<PageData> homeworkList = homeworkService.listAll(pd); | |
310 | - List<PageData> dataList = homeworkService.report(pd); | |
311 | - for(PageData stuPd:studentList){ | |
312 | - double all = 0 ; | |
313 | - double get = 0; | |
314 | - for(PageData dpd : dataList){ | |
315 | - if(dpd.get("STUDENT_ID").equals(stuPd.get("ID"))){ | |
316 | - stuPd.put(dpd.get("HOMEWORK_ID"), dpd.get("STUDENT_SCORE")); | |
317 | - try{ | |
318 | - get += Double.parseDouble(dpd.get("STUDENT_SCORE").toString()); | |
319 | - }catch(Exception ex){ | |
320 | - | |
321 | - } | |
322 | - try{ | |
323 | - all += Double.parseDouble(dpd.get("PAPER_SCORE").toString()); | |
324 | - }catch(Exception ex){ | |
325 | - | |
305 | + if (pd.get("CLASS_ID") != null) { | |
306 | + // 对应班级数据 | |
307 | + PageData data = new PageData(); | |
308 | + List<PageData> studentList = studentService.findByClassId(pd); | |
309 | + | |
310 | + List<PageData> homeworkList = homeworkService.listAll(pd); | |
311 | + List<PageData> dataList = homeworkService.report(pd); | |
312 | + for (PageData stuPd : studentList) { | |
313 | + double all = 0; | |
314 | + double get = 0; | |
315 | + for (PageData dpd : dataList) { | |
316 | + if (dpd.get("STUDENT_ID").equals(stuPd.get("ID"))) { | |
317 | + stuPd.put(dpd.get("HOMEWORK_ID"), | |
318 | + dpd.get("STUDENT_SCORE")); | |
319 | + try { | |
320 | + get += Double.parseDouble(dpd.get("STUDENT_SCORE") | |
321 | + .toString()); | |
322 | + } catch (Exception ex) { | |
323 | + | |
324 | + } | |
325 | + try { | |
326 | + all += Double.parseDouble(dpd.get("PAPER_SCORE") | |
327 | + .toString()); | |
328 | + } catch (Exception ex) { | |
329 | + | |
330 | + } | |
326 | 331 | } |
327 | 332 | } |
333 | + stuPd.put("STUDENT_ALL_SCORE", get); | |
334 | + stuPd.put("PAPER_ALL_SCORE", all); | |
335 | + stuPd.remove("SCHOOL_ID"); | |
336 | + stuPd.remove("SEX"); | |
337 | + stuPd.remove("CLASS_ID"); | |
338 | + stuPd.remove("NUMBER"); | |
339 | + stuPd.remove("ID"); | |
328 | 340 | } |
329 | - stuPd.put("STUDENT_ALL_SCORE", get); | |
330 | - stuPd.put("PAPER_ALL_SCORE", all); | |
331 | - stuPd.remove("SCHOOL_ID"); | |
332 | - stuPd.remove("SEX"); | |
333 | - stuPd.remove("CLASS_ID"); | |
334 | - stuPd.remove("NUMBER"); | |
335 | - stuPd.remove("ID"); | |
336 | - } | |
337 | - for(PageData hpd: homeworkList){ | |
338 | - hpd.remove("QUESTION_COUNT"); | |
339 | - hpd.remove("COMPLETE_COUNT"); | |
340 | - hpd.remove("SUBJECT_ID"); | |
341 | - hpd.remove("SCHOOL_ID"); | |
342 | - hpd.remove("GRADE_ID"); | |
343 | - hpd.remove("SUMBIT_DATE"); | |
344 | - hpd.remove("MODIFY_DATE"); | |
345 | - hpd.remove("TEACHER_ID"); | |
346 | - hpd.remove("CREATE_DATE"); | |
347 | - hpd.remove("CLASS_ID"); | |
348 | - hpd.remove("CODE"); | |
349 | - hpd.remove("GET_MAX_SCORE"); | |
350 | - hpd.remove("HOMEWORK_DESC"); | |
351 | - hpd.remove("COMPLETE_DESC"); | |
341 | + for (PageData hpd : homeworkList) { | |
342 | + hpd.remove("QUESTION_COUNT"); | |
343 | + hpd.remove("COMPLETE_COUNT"); | |
344 | + hpd.remove("SUBJECT_ID"); | |
345 | + hpd.remove("SCHOOL_ID"); | |
346 | + hpd.remove("GRADE_ID"); | |
347 | + hpd.remove("SUMBIT_DATE"); | |
348 | + hpd.remove("MODIFY_DATE"); | |
349 | + hpd.remove("TEACHER_ID"); | |
350 | + hpd.remove("CREATE_DATE"); | |
351 | + hpd.remove("CLASS_ID"); | |
352 | + hpd.remove("CODE"); | |
353 | + hpd.remove("GET_MAX_SCORE"); | |
354 | + hpd.remove("HOMEWORK_DESC"); | |
355 | + hpd.remove("COMPLETE_DESC"); | |
356 | + } | |
357 | + data.put("HOMEWORKS", homeworkList);// | |
358 | + data.put("STUDENTS", studentList); | |
359 | + pd.put("DATA", data); | |
360 | + }else{ | |
361 | + pd.put("CLASS_ID", ""); | |
352 | 362 | } |
353 | - data.put("HOMEWORKS", homeworkList);// | |
354 | - data.put("STUDENTS", studentList); | |
355 | 363 | pd.remove("JSON"); |
356 | - pd.put("DATA", data); | |
357 | 364 | mv.setViewName("sunvote/homework/homework_report"); |
358 | 365 | mv.addObject("pd", pd); |
359 | 366 | return mv; | ... | ... |