diff --git a/resources/mybatis1/api/V1Mapper.xml b/resources/mybatis1/api/V1Mapper.xml index be914a4..3a126f1 100644 --- a/resources/mybatis1/api/V1Mapper.xml +++ b/resources/mybatis1/api/V1Mapper.xml @@ -213,6 +213,21 @@ + + + + SELECT + sv_student.* + FROM + sv_student + LEFT JOIN sv_sclass ON sv_student.CLASS_ID = sv_sclass.ID + WHERE + sv_sclass.SCHOOL_ID = #{SCHOOL_ID} + AND sv_student.NUMBER = #{NUMBER} + + + + SELECT diff --git a/resources/mybatis1/sunvote/StudentTestMapper.xml b/resources/mybatis1/sunvote/StudentTestMapper.xml index 9ad116d..e671777 100644 --- a/resources/mybatis1/sunvote/StudentTestMapper.xml +++ b/resources/mybatis1/sunvote/StudentTestMapper.xml @@ -72,6 +72,7 @@ PAPER_ID = #{PAPER_ID}, SCORE = #{SCORE}, CLASS_ID = #{CLASS_ID}, + LOST_TEST = #{LOST_TEST}, STUDENTTEST_ID = STUDENTTEST_ID where STUDENTTEST_ID = #{STUDENTTEST_ID} diff --git a/src/com/fh/controller/api/V1.java b/src/com/fh/controller/api/V1.java index b963d4a..3c27fad 100644 --- a/src/com/fh/controller/api/V1.java +++ b/src/com/fh/controller/api/V1.java @@ -1634,118 +1634,132 @@ public class V1 extends BaseController { public Object uploadupdateTestpaper() { event("uploadupdateTestpaper"); long cur = System.currentTimeMillis(); - PageData pd = this.getPageData(); + final PageData pd = this.getPageData(); ResponseGson res = new ResponseGson(); if (!StringUtils.isEmpty(pd.getJsonString())) { - logger.info(pd.getJsonString()); - TestPaper testPaper = TestPaper.parse(pd.getJsonString()); - try { - PageData testPd = new PageData(); - String testPaperId = this.get32UUID(); - testPd.put("TEACHER_ID", testPaper.getTeacherId()); - testPd.put("PAPER_ID", testPaper.getPaperId()); - testPd.put("SCLASS_ID", testPaper.getClassId()); - testPd.put( - "CREATE_DATE", - testPaper.getCreateDate() == null ? Tools - .date2Str(new Date()) : testPaper - .getCreateDate()); - testPd.put( - "TEST_TYPE", - testPaper.getTest_type() != null ? testPaper - .getTest_type() : "1"); - List listData = testpaperService.listAll(testPd); - if ((listData != null && listData.size() > 0)) { - testPaperId = listData.get(0).getString("TESTPAPER_ID"); - testpaperService.deleteList(testPd); - testPd.put("TEST_ID", testPaperId); - testpaperinfoService.delete(testPd); - studenttestService.delete(testPd); - } - testPd.put("START_DATE", testPaper.getStartDate()); - testPd.put("END_DATE", testPaper.getEndDate()); - testPd.put("NAME", testPaper.getName()); - testPd.put("TESTPAPER_ID", testPaperId); - testPd.put("OTHER_SCORE", testPaper.getOtherScore()); - testPd.put("HIGHT_SCORE", testPaper.getHighScore()); - testPd.put("LOW_SCORE", testPaper.getLowScore()); - testPd.put("AVG_SCORE", testPaper.getAvgScore()); - testPd.put("TOTAL_SCORE", testPaper.getTotalScore()); - testPd.put("SUBJECT_ID", testPaper.getSubject_id()); - testPd.put("REMARK", testPaper.getRemark()); - testpaperService.save(testPd); - if (testPaper.getStudents() != null) { - List testInfoPdList = new ArrayList(); - PageData testInfoPd = null; - for (StudentAnswer studentAnswer : testPaper.getStudents()) { - if (studentAnswer.getQuestions() != null) { - PageData studentPageData = new PageData(); - studentPageData.put("STUDENT_ID", - studentAnswer.getStudentId()); - studentPageData.put("TEST_ID", testPaperId); - studentPageData.put("PAPER_ID", - testPaper.getPaperId()); - studentPageData.put("SCORE", - studentAnswer.getScore()); - studentPageData.put("CLASS_ID", - testPaper.getClassId()); - studentPageData.put("STUDENTTEST_ID", get32UUID()); + new Thread() { + public void run() { + logger.info(pd.getJsonString()); + TestPaper testPaper = TestPaper.parse(pd.getJsonString()); + try { + PageData testPd = new PageData(); + String testPaperId = get32UUID(); + testPd.put("TEACHER_ID", testPaper.getTeacherId()); + testPd.put("PAPER_ID", testPaper.getPaperId()); + testPd.put("SCLASS_ID", testPaper.getClassId()); + testPd.put( + "CREATE_DATE", + testPaper.getCreateDate() == null ? Tools + .date2Str(new Date()) : testPaper + .getCreateDate()); + testPd.put( + "TEST_TYPE", + testPaper.getTest_type() != null ? testPaper + .getTest_type() : "1"); + List listData = testpaperService + .listAll(testPd); + if ((listData != null && listData.size() > 0)) { + testPaperId = listData.get(0).getString( + "TESTPAPER_ID"); + testpaperService.deleteList(testPd); + testPd.put("TEST_ID", testPaperId); + testpaperinfoService.delete(testPd); + studenttestService.delete(testPd); + } + testPd.put("START_DATE", testPaper.getStartDate()); + testPd.put("END_DATE", testPaper.getEndDate()); + testPd.put("NAME", testPaper.getName()); + testPd.put("TESTPAPER_ID", testPaperId); + testPd.put("OTHER_SCORE", testPaper.getOtherScore()); + testPd.put("HIGHT_SCORE", testPaper.getHighScore()); + testPd.put("LOW_SCORE", testPaper.getLowScore()); + testPd.put("AVG_SCORE", testPaper.getAvgScore()); + testPd.put("TOTAL_SCORE", testPaper.getTotalScore()); + testPd.put("SUBJECT_ID", testPaper.getSubject_id()); + testPd.put("REMARK", testPaper.getRemark()); + testpaperService.save(testPd); + if (testPaper.getStudents() != null) { + List testInfoPdList = new ArrayList(); + PageData testInfoPd = null; + for (StudentAnswer studentAnswer : testPaper + .getStudents()) { + if (studentAnswer.getQuestions() != null) { + PageData studentPageData = new PageData(); + studentPageData.put("STUDENT_ID", + studentAnswer.getStudentId()); + studentPageData.put("TEST_ID", testPaperId); + studentPageData.put("PAPER_ID", + testPaper.getPaperId()); + studentPageData.put("SCORE", + studentAnswer.getScore()); + studentPageData.put("CLASS_ID", + testPaper.getClassId()); + studentPageData.put("STUDENTTEST_ID", + get32UUID()); + + String flag = ""; + for (TestPaperInfo testPaperInfo : studentAnswer + .getQuestions()) { + testInfoPd = new PageData(); + testInfoPd.put("TESTPAPERINFO_ID", + get32UUID()); + testInfoPd.put("PAPER_ID", + testPaper.getPaperId()); + testInfoPd.put("STUDENT_ID", + studentAnswer.getStudentId()); + testInfoPd.put("TEST_ID", testPaperId); + testInfoPd.put("QUESTION_ID", + testPaperInfo.getQuestionId()); + testInfoPd.put("ANSWER", + testPaperInfo.getAnswer()); + flag = StringUtils.isEmpty(testPaperInfo + .getAnswer()) + ? "" + + flag : testPaperInfo + .getAnswer(); + testInfoPd.put("RIGHT", + testPaperInfo.getRight()); + testInfoPd.put("SCORE", + testPaperInfo.getScore()); + testInfoPd.put("LIKES", + testPaperInfo.getLikes()); + testInfoPd + .put("ANSWER_TYPE", + testPaperInfo + .getAnswerType() == null ? "1" + : testPaperInfo + .getAnswerType()); + testInfoPd.put("PRESS_TIME", + testPaperInfo.getPressTime()); + testInfoPd + .put("RECEIVER_DATE", + testPaperInfo + .getReceiverDate()); + testInfoPd.put("SUBJECTIVE", + testPaperInfo.getSubjective()); + testInfoPd.put("NOTE", + testPaperInfo.getNote()); + testInfoPd.put("MARK_NO", + testPaperInfo.getMarkNo()); + testInfoPdList.add(testInfoPd); + } - String flag = ""; - for (TestPaperInfo testPaperInfo : studentAnswer - .getQuestions()) { - testInfoPd = new PageData(); - testInfoPd.put("TESTPAPERINFO_ID", - this.get32UUID()); - testInfoPd.put("PAPER_ID", - testPaper.getPaperId()); - testInfoPd.put("STUDENT_ID", - studentAnswer.getStudentId()); - testInfoPd.put("TEST_ID", testPaperId); - testInfoPd.put("QUESTION_ID", - testPaperInfo.getQuestionId()); - testInfoPd.put("ANSWER", - testPaperInfo.getAnswer()); - flag = testPaperInfo.getAnswer().toString() - .equals("") ? "" + flag : testPaperInfo - .getAnswer().toString(); - testInfoPd.put("RIGHT", - testPaperInfo.getRight()); - testInfoPd.put("SCORE", - testPaperInfo.getScore()); - testInfoPd.put("LIKES", - testPaperInfo.getLikes()); - testInfoPd.put("ANSWER_TYPE", testPaperInfo - .getAnswerType() == null ? "1" - : testPaperInfo.getAnswerType()); - testInfoPd.put("PRESS_TIME", - testPaperInfo.getPressTime()); - testInfoPd.put("RECEIVER_DATE", - testPaperInfo.getReceiverDate()); - testInfoPd.put("SUBJECTIVE", - testPaperInfo.getSubjective()); - testInfoPd.put("NOTE", testPaperInfo.getNote()); - testInfoPd.put("MARK_NO", - testPaperInfo.getMarkNo()); - testInfoPdList.add(testInfoPd); + if (flag.equals("")) { + studentPageData.put("LOST_TEST", "1"); + } + studenttestService.save(studentPageData); + } } - - if (flag.equals("")) { - studentPageData.put("LOST_TEST", "1"); + if (testInfoPdList != null + && testInfoPdList.size() > 0) { + testpaperinfoService.batchSave(testInfoPdList); } - studenttestService.save(studentPageData); } - } - if (testInfoPdList != null && testInfoPdList.size() > 0) { - testpaperinfoService.batchSave(testInfoPdList); + } catch (Exception e) { + e.printStackTrace(); } } - res.setData(testPaperId); - } catch (Exception e) { - e.printStackTrace(); - res.setError(); - res.setMessage(e.getMessage()); - } + }.start(); } else { res.setDataError(); } @@ -1766,156 +1780,163 @@ public class V1 extends BaseController { public Object uploadstudenttest() { event("uploadstudenttest"); long cur = System.currentTimeMillis(); - PageData pd = this.getPageData(); + final PageData pd = this.getPageData(); ResponseGson res = new ResponseGson(); if (!StringUtils.isEmpty(pd.getJsonString())) { - logger.info(pd.getJsonString()); - 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",studentPaper.getStartDate()); - testPd.put("END_DATE", studentPaper.getEndDate()); - testPd.put("TESTPAPER_ID", studentPaper.getPaperId()); - testPd.put("OTHER_SCORE", ""); - testPd.put("HIGHT_SCORE", ""); - testPd.put("LOW_SCORE", ""); - testPd.put("AVG_SCORE", ""); - testPd.put("TOTAL_SCORE", ""); - testPd.put("SUBJECT_ID", studentPaper.getSubject_id()); - testPd.put("REMARK", ""); - testPd.put("NAME", studentPaper.getName()); - testpaperService.save(testPd); - }else{ - boolean find = false; - for(PageData pda: oldList){ - if(pda != null && studentPaper.getPaperId().equals(pda.get("TESTPAPER_ID"))){ - find = true; - break; + new Thread(){ + public void run() { + logger.info(pd.getJsonString()); + + 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",studentPaper.getStartDate()); + testPd.put("END_DATE", studentPaper.getEndDate()); + testPd.put("TESTPAPER_ID", studentPaper.getPaperId()); + testPd.put("OTHER_SCORE", ""); + testPd.put("HIGHT_SCORE", ""); + testPd.put("LOW_SCORE", ""); + testPd.put("AVG_SCORE", ""); + testPd.put("TOTAL_SCORE", ""); + testPd.put("SUBJECT_ID", studentPaper.getSubject_id()); + testPd.put("REMARK", ""); + testPd.put("NAME", studentPaper.getName()); + testpaperService.save(testPd); + }else{ + boolean find = false; + for(PageData pda: oldList){ + if(pda != null && studentPaper.getPaperId().equals(pda.get("TESTPAPER_ID"))){ + find = true; + break; + } + } + if(!find){ + 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",studentPaper.getStartDate()); + testPd.put("END_DATE", studentPaper.getEndDate()); + testPd.put("TESTPAPER_ID", studentPaper.getPaperId()); + testPd.put("OTHER_SCORE", ""); + testPd.put("HIGHT_SCORE", ""); + testPd.put("LOW_SCORE", ""); + testPd.put("AVG_SCORE", ""); + testPd.put("TOTAL_SCORE", ""); + testPd.put("SUBJECT_ID", studentPaper.getSubject_id()); + testPd.put("REMARK", ""); + testPd.put("NAME", studentPaper.getName()); + testpaperService.save(testPd); + } } - } - if(!find){ - 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",studentPaper.getStartDate()); - testPd.put("END_DATE", studentPaper.getEndDate()); - testPd.put("TESTPAPER_ID", studentPaper.getPaperId()); - testPd.put("OTHER_SCORE", ""); - testPd.put("HIGHT_SCORE", ""); - testPd.put("LOW_SCORE", ""); - testPd.put("AVG_SCORE", ""); - testPd.put("TOTAL_SCORE", ""); - testPd.put("SUBJECT_ID", studentPaper.getSubject_id()); - testPd.put("REMARK", ""); - testPd.put("NAME", studentPaper.getName()); - testpaperService.save(testPd); - } - } - List list = studentPaper - .getStudents(); + List list = studentPaper + .getStudents(); - for (StudentPaper.StudentAnswer studentAnswer : list) { - PageData stestPd = new PageData(); + for (StudentPaper.StudentAnswer studentAnswer : list) { + PageData stestPd = new PageData(); - String studentId = studentAnswer.getStudentId(); - String classId = ""; + String studentId = studentAnswer.getStudentId(); + String classId = ""; - // 通过学号id 查找学生信息 - if (StringUtils.isEmpty(studentId)) { - PageData ptd = new PageData(); - ptd.put("NUMBER", studentAnswer.getNumber()); - PageData stPd = studentService.findByNumber(ptd); - if (stPd != null) { - studentId = stPd.getString("ID"); - classId = stPd.getString("CLASS_ID"); - } - } else { - PageData ptd = new PageData(); - ptd.put("ID", studentAnswer.getStudentId()); - PageData stPd = studentService.findByNumber(ptd); - if (stPd != null) { - studentId = stPd.getString("ID"); - classId = stPd.getString("CLASS_ID"); - } - } - 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()); - stestPd.put("LOST_TEST", studentAnswer.getLosttest()); - List liste = studenttestService.listAll(stestPd); - if (liste == null || liste.size() == 0) { - stestPd.put("STUDENTTEST_ID", get32UUID()); - studenttestService.save(stestPd); - } else { - PageData ptd = liste.get(0); - stestPd.put("STUDENTTEST_ID", ptd.get("STUDENTTEST_ID")); - studenttestService.edit(stestPd); - } - - 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()); - testInfoPd.put("ANSWER", question.getAnswer()); - 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) { - testInfoPdList.add(testInfoPd); - } else { - PageData ptd = listse.get(0); - testInfoPd.put("TESTPAPERINFO_ID", - testInfoPd.get("TESTPAPERINFO_ID")); - testpaperinfoService.edit(testInfoPd); - } - } + // 通过学号id 查找学生信息 + if (StringUtils.isEmpty(studentId)) { + PageData ptd = new PageData(); + ptd.put("NUMBER", studentAnswer.getNumber()); + ptd.put("SCHOOL_ID", studentPaper.getSchoolId()); + PageData stPd = v1Service.findStudentBySchoolIdAndNumber(ptd); // + if(stPd == null){ + stPd = studentService.findByNumber(ptd); + } + if (stPd != null) { + studentId = stPd.getString("ID"); + classId = stPd.getString("CLASS_ID"); + } + } else { + PageData ptd = new PageData(); + ptd.put("ID", studentAnswer.getStudentId()); + PageData stPd = studentService.findById(ptd); + if (stPd != null) { + studentId = stPd.getString("ID"); + classId = stPd.getString("CLASS_ID"); + } + } + 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()); + stestPd.put("LOST_TEST", studentAnswer.getLosttest()); + List liste = studenttestService.listAll(stestPd); + if (liste == null || liste.size() == 0) { + stestPd.put("STUDENTTEST_ID", get32UUID()); + studenttestService.save(stestPd); + } else { + PageData ptd = liste.get(0); + stestPd.put("STUDENTTEST_ID", ptd.get("STUDENTTEST_ID")); + studenttestService.edit(stestPd); + } - if (testInfoPdList.size() > 0) { - testpaperinfoService.batchSave(testInfoPdList); - } + List testInfoPdList = new ArrayList(); + List questions = studentAnswer + .getQuestions(); + for (StudentPaper.Question question : questions) { + PageData testInfoPd = new PageData(); + testInfoPd.put("TESTPAPERINFO_ID", get32UUID()); + testInfoPd.put("TEST_ID", studentPaper.getPaperId()); + testInfoPd.put("PAPER_ID", studentPaper.getPaperId()); + testInfoPd.put("STUDENT_ID", studentId); + testInfoPd.put("QUESTION_ID", question.getQuestionId()); + testInfoPd.put("ANSWER", question.getAnswer()); + 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) { + testInfoPdList.add(testInfoPd); + } else { + PageData ptd = listse.get(0); + testInfoPd.put("TESTPAPERINFO_ID", + testInfoPd.get("TESTPAPERINFO_ID")); + testpaperinfoService.edit(testInfoPd); + } + } - } + if (testInfoPdList.size() > 0) { + testpaperinfoService.batchSave(testInfoPdList); + } - } catch (Exception e) { - e.printStackTrace(); - res.setError(); - res.setMessage(e.getMessage()); - } - } else { + } + }catch(Exception e){ + e.printStackTrace(); + } + }; + }.start(); + }else{ res.setDataError(); } + logger.info("uploadstudenttest cost time:" + (System.currentTimeMillis() - cur)); diff --git a/src/com/fh/controller/sunvote/paper/PaperController.java b/src/com/fh/controller/sunvote/paper/PaperController.java index f8c0d47..115fa3a 100644 --- a/src/com/fh/controller/sunvote/paper/PaperController.java +++ b/src/com/fh/controller/sunvote/paper/PaperController.java @@ -961,7 +961,17 @@ public class PaperController extends BaseController { Float o2GetScore = Float.valueOf(o2.getString("TEST_NUM")) == 0 ? 0 : Float.valueOf(o2.getString("STUDENT_TOTAL")) / Float.valueOf(o2.getString("TEST_NUM")); - return o2GetScore.compareTo(o1GetScore); + + int result = o2GetScore.compareTo(o1GetScore); + if(result == 0){ + if(Float.valueOf(o1.getString("TEST_NUM")) -Float.valueOf(o2.getString("TEST_NUM")) == 0 ){ + return o1.get("STUDENT_NUMBER").toString().compareTo(o2.get("STUDENT_NUMBER").toString()); + } + return Float.valueOf(o1.getString("TEST_NUM")) -Float.valueOf(o2.getString("TEST_NUM")) > 0 ? -1 : 1; + + } + + return result; } }); diff --git a/src/com/fh/service/api/V1Manager.java b/src/com/fh/service/api/V1Manager.java index 1e7716c..1c56587 100644 --- a/src/com/fh/service/api/V1Manager.java +++ b/src/com/fh/service/api/V1Manager.java @@ -26,6 +26,9 @@ public interface V1Manager { public PageData getAdminInfo(PageData pd) throws Exception; + + public PageData findStudentBySchoolIdAndNumber(PageData pd) throws Exception; + public List getClassBySchoolAndGradle(PageData pd) throws Exception; public List classReport(PageData pd) throws Exception; diff --git a/src/com/fh/service/api/impl/V1Service.java b/src/com/fh/service/api/impl/V1Service.java index ed404a1..25192c4 100644 --- a/src/com/fh/service/api/impl/V1Service.java +++ b/src/com/fh/service/api/impl/V1Service.java @@ -57,6 +57,11 @@ public class V1Service implements V1Manager { } @Override + public PageData findStudentBySchoolIdAndNumber(PageData pd) throws Exception { + return (PageData)dao.findForObject("V1Mapper.findStudentBySchoolIdAndNumber", pd); + } + + @Override public List getQuestionWrongInfo(PageData pd) throws Exception { return (List)dao.findForList("V1Mapper.getQuestionWrongInfo", pd); }