Commit f9e1fd73c7d513c110e3ea108886264c50dfdfa6

Authored by Elvis
1 parent c34a91ee

1. 如果重复上传就更新,首次为插入。 2 test Id 就是试卷ID

src/com/fh/controller/api/V1.java
... ... @@ -1775,8 +1775,7 @@ public class V1 extends BaseController {
1775 1775 try {
1776 1776 for (StudentPaper.StudentAnswer studentAnswer : list) {
1777 1777 PageData testPd = new PageData();
1778   - String testPaperId = this.get32UUID();
1779   - testPd.put("STUDENTTEST_ID", testPaperId);
  1778 +
1780 1779 String studentId = studentAnswer.getStudentId();
1781 1780 String classId = "";
1782 1781 // 通过学号id 查找学生信息
... ... @@ -1800,15 +1799,26 @@ public class V1 extends BaseController {
1800 1799 testPd.put("STUDENT_ID", studentId);
1801 1800 testPd.put("CLASS_ID", classId);
1802 1801 testPd.put("PAPER_ID", studentPaper.getPaperId());
  1802 + testPd.put("TEST_ID", studentPaper.getPaperId());
1803 1803 testPd.put("SCORE", studentAnswer.getScore());
1804 1804 testPd.put("LOST_TEST", studentAnswer.getLosttest());
1805   - studenttestService.save(testPd);
  1805 + List<PageData> liste = studenttestService.listAll(testPd);
  1806 + if(liste == null || liste.size() == 0){
  1807 + testPd.put("STUDENTTEST_ID", get32UUID());
  1808 + studenttestService.save(testPd);
  1809 + }else{
  1810 + PageData ptd = liste.get(0);
  1811 + testPd.put("STUDENTTEST_ID", ptd.get("STUDENTTEST_ID"));
  1812 + studenttestService.edit(testPd);
  1813 + }
  1814 +
1806 1815 List<PageData> testInfoPdList = new ArrayList();
1807 1816 List<StudentPaper.Question> questions = studentAnswer
1808 1817 .getQuestions();
1809 1818 for (StudentPaper.Question question : questions) {
1810 1819 PageData testInfoPd = new PageData();
1811 1820 testInfoPd.put("TESTPAPERINFO_ID", this.get32UUID());
  1821 + testInfoPd.put("TEST_ID", studentPaper.getPaperId());
1812 1822 testInfoPd.put("PAPER_ID", studentPaper.getPaperId());
1813 1823 testInfoPd.put("STUDENT_ID", studentId);
1814 1824 testInfoPd.put("QUESTION_ID", question.getQuestionId());
... ... @@ -1816,7 +1826,14 @@ public class V1 extends BaseController {
1816 1826 testInfoPd.put("RIGHT", question.getRight());
1817 1827 testInfoPd.put("SCORE", question.getScore());
1818 1828 testInfoPd.put("ANSWER_TYPE", question.getAnswerType());
1819   - testInfoPdList.add(testInfoPd);
  1829 + List<PageData> listse = testpaperinfoService.listAll(testInfoPd);
  1830 + if(listse == null || listse.size() == 0){
  1831 + testInfoPdList.add(testInfoPd);
  1832 + }else{
  1833 + PageData ptd = listse.get(0);
  1834 + testInfoPd.put("TESTPAPERINFO_ID", testInfoPd.get("TESTPAPERINFO_ID"));
  1835 + testpaperinfoService.edit(testInfoPd);
  1836 + }
1820 1837 }
1821 1838  
1822 1839 if (testInfoPdList.size() > 0) {
... ...