瀏覽代碼

Merge branch 'dev_xuwenjin' of http://git.qmth.com.cn/luoshi/stmms-ft.git into dev_xuwenjin

ting.yin 6 年之前
父節點
當前提交
4abbfa7131

+ 22 - 16
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/dao/ExamQuestionDao.java

@@ -1,52 +1,58 @@
 package cn.com.qmth.stmms.biz.exam.dao;
 package cn.com.qmth.stmms.biz.exam.dao;
 
 
-import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
+import java.util.List;
+
+import org.springframework.data.domain.Sort;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.jpa.repository.Query;
 
 
-import java.util.List;
+import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
 
 
 public interface ExamQuestionDao extends JpaRepository<ExamQuestion, Integer>, JpaSpecificationExecutor<ExamQuestion> {
 public interface ExamQuestionDao extends JpaRepository<ExamQuestion, Integer>, JpaSpecificationExecutor<ExamQuestion> {
 
 
-
     @Query("select sum(q.totalScore) as totalScore from ExamQuestion q where q.examId=?1 and q.subjectCode=?2 and q.mainNumber=?3")
     @Query("select sum(q.totalScore) as totalScore from ExamQuestion q where q.examId=?1 and q.subjectCode=?2 and q.mainNumber=?3")
-    public Double queryFullScoreByExamIdAndSubjectCodeAndMainNumber(Integer examId, String subjectCode, Integer mainNumber);
+    public Double queryFullScoreByExamIdAndSubjectCodeAndMainNumber(Integer examId, String subjectCode,
+            Integer mainNumber);
 
 
-    @Query("select q from ExamQuestion q where q.examId=?1 and q.subjectCode=?2 and q.objective=?3 and q.paperType is not null "
-            + "order by q.mainNumber, q.subNumber")
+    @Query("select q from ExamQuestion q where q.examId=?1 and  q.subjectCode=?2 and q.objective=?3 "
+            + "order by q.paperType, q.mainNumber, q.subNumber")
     public List<ExamQuestion> findByExamIdAndSubjectCodeAndObjective(Integer examId, String subjectCode,
     public List<ExamQuestion> findByExamIdAndSubjectCodeAndObjective(Integer examId, String subjectCode,
-                                                                     boolean objective);
+            boolean objective);
 
 
-    @Query("select q from ExamQuestion q where q.examId=?1 and q.subjectCode=?2 and q.objective=?3 "
-            + "and q.paperType=?4 order by q.mainNumber, q.subNumber")
+    // @Query("select q from ExamQuestion q where q.examId=?1 and
+    // q.subjectCode=?2 and q.objective=?3 "
+    // + "and q.paperType=?4 order by q.mainNumber, q.subNumber")
     public List<ExamQuestion> findByExamIdAndSubjectCodeAndObjectiveAndPaperType(Integer examId, String subjectCode,
     public List<ExamQuestion> findByExamIdAndSubjectCodeAndObjectiveAndPaperType(Integer examId, String subjectCode,
-                                                                                 boolean objective, String paperType);
+            boolean objective, String paperType, Sort sort);
 
 
     @Query("select q from ExamQuestion q where q.examId=?1 and q.subjectCode=?2 and q.objective=?3 "
     @Query("select q from ExamQuestion q where q.examId=?1 and q.subjectCode=?2 and q.objective=?3 "
             + "and q.mainNumber=?4 order by q.subNumber")
             + "and q.mainNumber=?4 order by q.subNumber")
+
     public List<ExamQuestion> findByExamIdAndSubjectCodeAndObjectiveAndMainNumber(Integer examId, String subjectCode,
     public List<ExamQuestion> findByExamIdAndSubjectCodeAndObjectiveAndMainNumber(Integer examId, String subjectCode,
-                                                                                  boolean objective, Integer mainNumber);
+            boolean objective, Integer mainNumber);
 
 
-    @Query("select q from ExamQuestion q where q.examId=?1 and q.subjectCode=?2 and q.objective=?3 "
-            + "and q.paperType=?4 and q.mainNumber=?5 order by q.subNumber")
+    // @Query("select q from ExamQuestion q where q.examId=?1 and
+    // q.subjectCode=?2 and q.objective=?3 "
+    // + "and q.paperType=?4 and q.mainNumber=?5 order by q.subNumber")
     public List<ExamQuestion> findByExamIdAndSubjectCodeAndObjectiveAndPaperTypeAndMainNumber(Integer examId,
     public List<ExamQuestion> findByExamIdAndSubjectCodeAndObjectiveAndPaperTypeAndMainNumber(Integer examId,
-                                                                                              String subjectCode, boolean objective, String paperType, Integer mainNumber);
+            String subjectCode, boolean objective, String paperType, Integer mainNumber, Sort sort);
 
 
     @Modifying
     @Modifying
     @Query("delete from ExamQuestion q where q.examId=?1 and q.subjectCode=?2 and q.objective=?3")
     @Query("delete from ExamQuestion q where q.examId=?1 and q.subjectCode=?2 and q.objective=?3")
+
     public void deleteByExamIdAndSubjectCodeAndObjective(Integer examId, String subjectCode, boolean objective);
     public void deleteByExamIdAndSubjectCodeAndObjective(Integer examId, String subjectCode, boolean objective);
 
 
     @Modifying
     @Modifying
     @Query("delete from ExamQuestion q where q.examId=?1 and q.subjectCode=?2 and q.objective=?3 and q.mainNumber=?4")
     @Query("delete from ExamQuestion q where q.examId=?1 and q.subjectCode=?2 and q.objective=?3 and q.mainNumber=?4")
     public void deleteByExamIdAndSubjectCodeAndObjectiveAndMainNumber(Integer examId, String subjectCode,
     public void deleteByExamIdAndSubjectCodeAndObjectiveAndMainNumber(Integer examId, String subjectCode,
-                                                                      boolean objective, Integer mainNumber);
+            boolean objective, Integer mainNumber);
 
 
     @Modifying
     @Modifying
     @Query("update ExamQuestion q set q.mainTitle=?5 where q.examId=?1 and q.subjectCode=?2 "
     @Query("update ExamQuestion q set q.mainTitle=?5 where q.examId=?1 and q.subjectCode=?2 "
             + "and q.objective=?3 and q.mainNumber=?4")
             + "and q.objective=?3 and q.mainNumber=?4")
     public void updateMainTitleByExamIdAndSubjectCodeAndObjectiveAndMainNumber(Integer examId, String subjectCode,
     public void updateMainTitleByExamIdAndSubjectCodeAndObjectiveAndMainNumber(Integer examId, String subjectCode,
-                                                                               boolean objective, Integer mainNumber, String mainTitle);
+            boolean objective, Integer mainNumber, String mainTitle);
 
 
 }
 }

+ 5 - 3
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/service/impl/ExamQuestionServiceImpl.java

@@ -10,6 +10,8 @@ import javax.persistence.criteria.Root;
 
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
@@ -61,8 +63,8 @@ public class ExamQuestionServiceImpl extends BaseQueryService<ExamQuestion> impl
     @Override
     @Override
     public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndPaperType(Integer examId, String subjectCode,
     public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndPaperType(Integer examId, String subjectCode,
             boolean objective, String paperType) {
             boolean objective, String paperType) {
-        return questionDao.findByExamIdAndSubjectCodeAndObjectiveAndPaperType(examId, subjectCode, objective,
-                paperType);
+        return questionDao.findByExamIdAndSubjectCodeAndObjectiveAndPaperType(examId, subjectCode, objective, paperType,
+                new Sort(Direction.ASC, "mainNumber", "subNumber"));
     }
     }
 
 
     @Override
     @Override
@@ -76,7 +78,7 @@ public class ExamQuestionServiceImpl extends BaseQueryService<ExamQuestion> impl
     public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndPaperTypeAndMainNumber(Integer examId,
     public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndPaperTypeAndMainNumber(Integer examId,
             String subjectCode, boolean objective, String paperType, Integer mainNumber) {
             String subjectCode, boolean objective, String paperType, Integer mainNumber) {
         return questionDao.findByExamIdAndSubjectCodeAndObjectiveAndPaperTypeAndMainNumber(examId, subjectCode,
         return questionDao.findByExamIdAndSubjectCodeAndObjectiveAndPaperTypeAndMainNumber(examId, subjectCode,
-                objective, paperType, mainNumber);
+                objective, paperType, mainNumber, new Sort(Direction.ASC, "subNumber"));
     }
     }
 
 
     @Override
     @Override