Commit 982c03840a22d10d74c2779594008de836d47846
1 parent
78353cf9
更新接口
Showing
1 changed file
with
55 additions
and
19 deletions
src/com/fh/controller/api/V1.java
@@ -1770,14 +1770,45 @@ public class V1 extends BaseController { | @@ -1770,14 +1770,45 @@ public class V1 extends BaseController { | ||
1770 | ResponseGson<String> res = new ResponseGson(); | 1770 | ResponseGson<String> res = new ResponseGson(); |
1771 | if (!StringUtils.isEmpty(pd.getJsonString())) { | 1771 | if (!StringUtils.isEmpty(pd.getJsonString())) { |
1772 | logger.info(pd.getJsonString()); | 1772 | logger.info(pd.getJsonString()); |
1773 | - StudentPaper studentPaper = StudentPaper.parse(pd.getJsonString()); | ||
1774 | - List<StudentPaper.StudentAnswer> list = studentPaper.getStudents(); | ||
1775 | try { | 1773 | try { |
1774 | + StudentPaper studentPaper = StudentPaper.parse(pd | ||
1775 | + .getJsonString()); | ||
1776 | + | ||
1777 | + PageData testPd = new PageData(); | ||
1778 | + testPd.put("PAPER_ID", studentPaper.getPaperId()); | ||
1779 | + List<PageData> oldList = testpaperService.listAll(testPd); | ||
1780 | + if (oldList == null || oldList.size() == 0) { | ||
1781 | + testPd.put("TEACHER_ID", ""); | ||
1782 | + testPd.put("SCLASS_ID", ""); | ||
1783 | + testPd.put( | ||
1784 | + "CREATE_DATE", | ||
1785 | + studentPaper.getCreateDate() == null ? Tools | ||
1786 | + .date2Str(new Date()) : studentPaper | ||
1787 | + .getCreateDate()); | ||
1788 | + testPd.put("TEST_TYPE", "1"); | ||
1789 | + testPd.put("START_DATE", ""); | ||
1790 | + testPd.put("END_DATE", studentPaper.getEndDate()); | ||
1791 | + testPd.put("NAME", ""); | ||
1792 | + testPd.put("TESTPAPER_ID", get32UUID()); | ||
1793 | + testPd.put("OTHER_SCORE", ""); | ||
1794 | + testPd.put("HIGHT_SCORE", ""); | ||
1795 | + testPd.put("LOW_SCORE", ""); | ||
1796 | + testPd.put("AVG_SCORE", ""); | ||
1797 | + testPd.put("TOTAL_SCORE", ""); | ||
1798 | + testPd.put("SUBJECT_ID", ""); | ||
1799 | + testPd.put("REMARK", ""); | ||
1800 | + testpaperService.save(testPd); | ||
1801 | + } | ||
1802 | + | ||
1803 | + List<StudentPaper.StudentAnswer> list = studentPaper | ||
1804 | + .getStudents(); | ||
1805 | + | ||
1776 | for (StudentPaper.StudentAnswer studentAnswer : list) { | 1806 | for (StudentPaper.StudentAnswer studentAnswer : list) { |
1777 | - PageData testPd = new PageData(); | ||
1778 | - | 1807 | + PageData stestPd = new PageData(); |
1808 | + | ||
1779 | String studentId = studentAnswer.getStudentId(); | 1809 | String studentId = studentAnswer.getStudentId(); |
1780 | String classId = ""; | 1810 | String classId = ""; |
1811 | + | ||
1781 | // 通过学号id 查找学生信息 | 1812 | // 通过学号id 查找学生信息 |
1782 | if (StringUtils.isEmpty(studentId)) { | 1813 | if (StringUtils.isEmpty(studentId)) { |
1783 | PageData ptd = new PageData(); | 1814 | PageData ptd = new PageData(); |
@@ -1796,22 +1827,25 @@ public class V1 extends BaseController { | @@ -1796,22 +1827,25 @@ public class V1 extends BaseController { | ||
1796 | classId = stPd.getString("CLASS_ID"); | 1827 | classId = stPd.getString("CLASS_ID"); |
1797 | } | 1828 | } |
1798 | } | 1829 | } |
1799 | - testPd.put("STUDENT_ID", studentId); | ||
1800 | - testPd.put("CLASS_ID", classId); | ||
1801 | - testPd.put("PAPER_ID", studentPaper.getPaperId()); | ||
1802 | - testPd.put("TEST_ID", studentPaper.getPaperId()); | ||
1803 | - testPd.put("SCORE", studentAnswer.getScore()); | 1830 | + if (StringUtils.isEmpty(studentId)) { |
1831 | + continue; | ||
1832 | + } | ||
1833 | + stestPd.put("STUDENT_ID", studentId); | ||
1834 | + stestPd.put("CLASS_ID", classId); | ||
1835 | + stestPd.put("PAPER_ID", studentPaper.getPaperId()); | ||
1836 | + stestPd.put("TEST_ID", studentPaper.getPaperId()); | ||
1837 | + stestPd.put("SCORE", studentAnswer.getScore()); | ||
1804 | testPd.put("LOST_TEST", studentAnswer.getLosttest()); | 1838 | testPd.put("LOST_TEST", studentAnswer.getLosttest()); |
1805 | - List<PageData> liste = studenttestService.listAll(testPd); | ||
1806 | - if(liste == null || liste.size() == 0){ | 1839 | + List<PageData> liste = studenttestService.listAll(stestPd); |
1840 | + if (liste == null || liste.size() == 0) { | ||
1807 | testPd.put("STUDENTTEST_ID", get32UUID()); | 1841 | testPd.put("STUDENTTEST_ID", get32UUID()); |
1808 | - studenttestService.save(testPd); | ||
1809 | - }else{ | 1842 | + studenttestService.save(stestPd); |
1843 | + } else { | ||
1810 | PageData ptd = liste.get(0); | 1844 | PageData ptd = liste.get(0); |
1811 | testPd.put("STUDENTTEST_ID", ptd.get("STUDENTTEST_ID")); | 1845 | testPd.put("STUDENTTEST_ID", ptd.get("STUDENTTEST_ID")); |
1812 | - studenttestService.edit(testPd); | 1846 | + studenttestService.edit(stestPd); |
1813 | } | 1847 | } |
1814 | - | 1848 | + |
1815 | List<PageData> testInfoPdList = new ArrayList(); | 1849 | List<PageData> testInfoPdList = new ArrayList(); |
1816 | List<StudentPaper.Question> questions = studentAnswer | 1850 | List<StudentPaper.Question> questions = studentAnswer |
1817 | .getQuestions(); | 1851 | .getQuestions(); |
@@ -1826,12 +1860,14 @@ public class V1 extends BaseController { | @@ -1826,12 +1860,14 @@ public class V1 extends BaseController { | ||
1826 | testInfoPd.put("RIGHT", question.getRight()); | 1860 | testInfoPd.put("RIGHT", question.getRight()); |
1827 | testInfoPd.put("SCORE", question.getScore()); | 1861 | testInfoPd.put("SCORE", question.getScore()); |
1828 | testInfoPd.put("ANSWER_TYPE", question.getAnswerType()); | 1862 | testInfoPd.put("ANSWER_TYPE", question.getAnswerType()); |
1829 | - List<PageData> listse = testpaperinfoService.listAll(testInfoPd); | ||
1830 | - if(listse == null || listse.size() == 0){ | 1863 | + List<PageData> listse = testpaperinfoService |
1864 | + .listAll(testInfoPd); | ||
1865 | + if (listse == null || listse.size() == 0) { | ||
1831 | testInfoPdList.add(testInfoPd); | 1866 | testInfoPdList.add(testInfoPd); |
1832 | - }else{ | 1867 | + } else { |
1833 | PageData ptd = listse.get(0); | 1868 | PageData ptd = listse.get(0); |
1834 | - testInfoPd.put("TESTPAPERINFO_ID", testInfoPd.get("TESTPAPERINFO_ID")); | 1869 | + testInfoPd.put("TESTPAPERINFO_ID", |
1870 | + testInfoPd.get("TESTPAPERINFO_ID")); | ||
1835 | testpaperinfoService.edit(testInfoPd); | 1871 | testpaperinfoService.edit(testInfoPd); |
1836 | } | 1872 | } |
1837 | } | 1873 | } |