diff --git a/src/com/fh/controller/api/V1.java b/src/com/fh/controller/api/V1.java index 398eee3..6fad723 100644 --- a/src/com/fh/controller/api/V1.java +++ b/src/com/fh/controller/api/V1.java @@ -1775,8 +1775,7 @@ public class V1 extends BaseController { try { for (StudentPaper.StudentAnswer studentAnswer : list) { PageData testPd = new PageData(); - String testPaperId = this.get32UUID(); - testPd.put("STUDENTTEST_ID", testPaperId); + String studentId = studentAnswer.getStudentId(); String classId = ""; // 通过学号id 查找学生信息 @@ -1800,15 +1799,26 @@ public class V1 extends BaseController { 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()); testPd.put("LOST_TEST", studentAnswer.getLosttest()); - studenttestService.save(testPd); + List liste = studenttestService.listAll(testPd); + if(liste == null || liste.size() == 0){ + testPd.put("STUDENTTEST_ID", get32UUID()); + studenttestService.save(testPd); + }else{ + PageData ptd = liste.get(0); + testPd.put("STUDENTTEST_ID", ptd.get("STUDENTTEST_ID")); + studenttestService.edit(testPd); + } + List testInfoPdList = new ArrayList(); List questions = studentAnswer .getQuestions(); for (StudentPaper.Question question : questions) { PageData testInfoPd = new PageData(); testInfoPd.put("TESTPAPERINFO_ID", this.get32UUID()); + testInfoPd.put("TEST_ID", studentPaper.getPaperId()); testInfoPd.put("PAPER_ID", studentPaper.getPaperId()); testInfoPd.put("STUDENT_ID", studentId); testInfoPd.put("QUESTION_ID", question.getQuestionId()); @@ -1816,7 +1826,14 @@ public class V1 extends BaseController { testInfoPd.put("RIGHT", question.getRight()); testInfoPd.put("SCORE", question.getScore()); testInfoPd.put("ANSWER_TYPE", question.getAnswerType()); - testInfoPdList.add(testInfoPd); + List listse = testpaperinfoService.listAll(testInfoPd); + if(listse == null || listse.size() == 0){ + testInfoPdList.add(testInfoPd); + }else{ + PageData ptd = listse.get(0); + testInfoPd.put("TESTPAPERINFO_ID", testInfoPd.get("TESTPAPERINFO_ID")); + testpaperinfoService.edit(testInfoPd); + } } if (testInfoPdList.size() > 0) {