diff --git a/src/com/fh/controller/api/V1.java b/src/com/fh/controller/api/V1.java index 6fad723..54b28cb 100644 --- a/src/com/fh/controller/api/V1.java +++ b/src/com/fh/controller/api/V1.java @@ -1770,14 +1770,45 @@ public class V1 extends BaseController { ResponseGson res = new ResponseGson(); if (!StringUtils.isEmpty(pd.getJsonString())) { logger.info(pd.getJsonString()); - StudentPaper studentPaper = StudentPaper.parse(pd.getJsonString()); - List list = studentPaper.getStudents(); try { + StudentPaper studentPaper = StudentPaper.parse(pd + .getJsonString()); + + PageData testPd = new PageData(); + testPd.put("PAPER_ID", studentPaper.getPaperId()); + List oldList = testpaperService.listAll(testPd); + if (oldList == null || oldList.size() == 0) { + testPd.put("TEACHER_ID", ""); + testPd.put("SCLASS_ID", ""); + testPd.put( + "CREATE_DATE", + studentPaper.getCreateDate() == null ? Tools + .date2Str(new Date()) : studentPaper + .getCreateDate()); + testPd.put("TEST_TYPE", "1"); + testPd.put("START_DATE", ""); + testPd.put("END_DATE", studentPaper.getEndDate()); + testPd.put("NAME", ""); + testPd.put("TESTPAPER_ID", get32UUID()); + testPd.put("OTHER_SCORE", ""); + testPd.put("HIGHT_SCORE", ""); + testPd.put("LOW_SCORE", ""); + testPd.put("AVG_SCORE", ""); + testPd.put("TOTAL_SCORE", ""); + testPd.put("SUBJECT_ID", ""); + testPd.put("REMARK", ""); + testpaperService.save(testPd); + } + + List list = studentPaper + .getStudents(); + for (StudentPaper.StudentAnswer studentAnswer : list) { - PageData testPd = new PageData(); - + PageData stestPd = new PageData(); + String studentId = studentAnswer.getStudentId(); String classId = ""; + // 通过学号id 查找学生信息 if (StringUtils.isEmpty(studentId)) { PageData ptd = new PageData(); @@ -1796,22 +1827,25 @@ public class V1 extends BaseController { classId = stPd.getString("CLASS_ID"); } } - testPd.put("STUDENT_ID", studentId); - testPd.put("CLASS_ID", classId); - testPd.put("PAPER_ID", studentPaper.getPaperId()); - testPd.put("TEST_ID", studentPaper.getPaperId()); - testPd.put("SCORE", studentAnswer.getScore()); + if (StringUtils.isEmpty(studentId)) { + continue; + } + stestPd.put("STUDENT_ID", studentId); + stestPd.put("CLASS_ID", classId); + stestPd.put("PAPER_ID", studentPaper.getPaperId()); + stestPd.put("TEST_ID", studentPaper.getPaperId()); + stestPd.put("SCORE", studentAnswer.getScore()); testPd.put("LOST_TEST", studentAnswer.getLosttest()); - List liste = studenttestService.listAll(testPd); - if(liste == null || liste.size() == 0){ + List liste = studenttestService.listAll(stestPd); + if (liste == null || liste.size() == 0) { testPd.put("STUDENTTEST_ID", get32UUID()); - studenttestService.save(testPd); - }else{ + studenttestService.save(stestPd); + } else { PageData ptd = liste.get(0); testPd.put("STUDENTTEST_ID", ptd.get("STUDENTTEST_ID")); - studenttestService.edit(testPd); + studenttestService.edit(stestPd); } - + List testInfoPdList = new ArrayList(); List questions = studentAnswer .getQuestions(); @@ -1826,12 +1860,14 @@ public class V1 extends BaseController { testInfoPd.put("RIGHT", question.getRight()); testInfoPd.put("SCORE", question.getScore()); testInfoPd.put("ANSWER_TYPE", question.getAnswerType()); - List listse = testpaperinfoService.listAll(testInfoPd); - if(listse == null || listse.size() == 0){ + List listse = testpaperinfoService + .listAll(testInfoPd); + if (listse == null || listse.size() == 0) { testInfoPdList.add(testInfoPd); - }else{ + } else { PageData ptd = listse.get(0); - testInfoPd.put("TESTPAPERINFO_ID", testInfoPd.get("TESTPAPERINFO_ID")); + testInfoPd.put("TESTPAPERINFO_ID", + testInfoPd.get("TESTPAPERINFO_ID")); testpaperinfoService.edit(testInfoPd); } }