|
@@ -16,6 +16,8 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
+import org.springframework.data.domain.Sort.Direction;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.RowMapper;
|
|
@@ -40,6 +42,7 @@ import cn.com.qmth.examcloud.service.examwork.entity.Exam;
|
|
|
import cn.com.qmth.examcloud.service.examwork.entity.ExamStudent;
|
|
|
import cn.com.qmth.examcloud.service.examwork.service.rpc.CourseService;
|
|
|
import cn.com.qmth.examcloud.service.examwork.service.rpc.OrgService;
|
|
|
+import cn.com.qmth.examcloud.service.examwork.service.rpc.SpecialtyService;
|
|
|
import cn.com.qmth.examcloud.service.examwork.service.rpc.StudentService;
|
|
|
|
|
|
/**
|
|
@@ -72,6 +75,10 @@ public class ExamStudentService {
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ SpecialtyService specialtyService;
|
|
|
+
|
|
|
+
|
|
|
// @Value("${app.em.photo.path}")
|
|
|
// private String PHOTO_PATH ;
|
|
|
// @Value("${app.em.facepp.key}")
|
|
@@ -95,7 +102,7 @@ public class ExamStudentService {
|
|
|
// Example<ExamStudent> examExamStudentple = Example.of(examStudentSearch, exampleMatcher);
|
|
|
// Page<ExamStudent> examStudents = examStudentRepo.findAll(examExamStudentple,pageable);
|
|
|
// return examStudents;
|
|
|
- Specification<ExamStudent> specification = getSpecification(examCriteria);
|
|
|
+ Specification<ExamStudent> specification = getPageSpecification(examCriteria);
|
|
|
Page<ExamStudent> examStudents = examStudentRepo.findAll(specification,pageable);
|
|
|
return examStudents;
|
|
|
}
|
|
@@ -108,7 +115,7 @@ public class ExamStudentService {
|
|
|
*/
|
|
|
public List<ExamStudent> getAllExamStudent(ExamStudentDTO examCriteria){
|
|
|
Specification<ExamStudent> specification = getSpecification(examCriteria);
|
|
|
- return examStudentRepo.findAll(specification);
|
|
|
+ return examStudentRepo.findAll(specification,new Sort(Direction.DESC,"id"));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -256,6 +263,16 @@ public class ExamStudentService {
|
|
|
if(StringUtils.isEmpty(dto.getOrgCode())){
|
|
|
return new ExcelError("学习中心代码不能为空");
|
|
|
}
|
|
|
+// if(StringUtils.isEmpty(dto.getSpecialtyCode())){
|
|
|
+// return new ExcelError("专业代码不能为空");
|
|
|
+// }
|
|
|
+//
|
|
|
+// Specialty specialty = specialtyService.findByOrgIdAndCode(dto.getOrgId(),dto.getSpecialtyCode());
|
|
|
+// if(specialty == null || !specialty.getEnable()){
|
|
|
+// return new ExcelError("专业代码不存在/被禁用");
|
|
|
+// }
|
|
|
+// dto.setSpecialtyName(specialty.getName());
|
|
|
+
|
|
|
Course course = courseService.findByOrgIdAndCode(dto.getRootOrgId(), dto.getCourseCode());
|
|
|
if(course == null || !course.getEnable()){
|
|
|
return new ExcelError("课程不存在/被禁用");
|
|
@@ -319,7 +336,6 @@ public class ExamStudentService {
|
|
|
private Specification<ExamStudent> getSpecification(ExamStudentDTO examCriteria) {
|
|
|
Specification<ExamStudent> specification = (root, query, cb) -> {
|
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
-// predicates.add(cb.equal(root.get("exam").get("enable"),true));
|
|
|
if(!StringUtils.isEmpty(examCriteria.getStudentId())){
|
|
|
predicates.add(cb.equal(root.get("studentId"),examCriteria.getStudentId()));
|
|
|
}
|
|
@@ -353,7 +369,6 @@ public class ExamStudentService {
|
|
|
if(!StringUtils.isEmpty(examCriteria.getFinished())){
|
|
|
predicates.add(cb.equal(root.get("finished"),examCriteria.getFinished()));
|
|
|
}
|
|
|
-
|
|
|
if(!StringUtils.isEmpty(examCriteria.getExamSite())){
|
|
|
predicates.add(cb.like(root.get("examSite"),"%"+examCriteria.getExamSite()+"%"));
|
|
|
}
|
|
@@ -389,6 +404,83 @@ public class ExamStudentService {
|
|
|
return specification;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成查询条件
|
|
|
+ * @param examCriteria
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Specification<ExamStudent> getPageSpecification(ExamStudentDTO examCriteria) {
|
|
|
+ Specification<ExamStudent> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getStudentId())){
|
|
|
+ predicates.add(cb.equal(root.get("studentId"),examCriteria.getStudentId()));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getRootOrgId())){
|
|
|
+ predicates.add(cb.equal(root.get("rootOrgId"),examCriteria.getRootOrgId()));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getOrgId())){
|
|
|
+ predicates.add(cb.equal(root.get("orgId"),examCriteria.getOrgId()));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getOrgName())){
|
|
|
+ predicates.add(cb.like(root.get("orgName"),"%"+examCriteria.getOrgName()+"%"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getExamId())){
|
|
|
+ predicates.add(cb.equal(root.get("exam").get("id"),examCriteria.getExamId()));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getName())){
|
|
|
+ predicates.add(cb.like(root.get("name"),"%"+examCriteria.getName()+"%"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getStudentCode())){
|
|
|
+ predicates.add(cb.like(root.get("studentCode"),"%"+examCriteria.getStudentCode()+"%"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getCourseCode())){
|
|
|
+ predicates.add(cb.equal(root.get("courseCode"),examCriteria.getCourseCode()));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getCourseLevel())){
|
|
|
+ predicates.add(cb.equal(root.get("courseLevel"),examCriteria.getCourseLevel()));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getCourseName())){
|
|
|
+ predicates.add(cb.like(root.get("courseName"),"%"+examCriteria.getCourseName()+"%"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getFinished())){
|
|
|
+ predicates.add(cb.equal(root.get("finished"),examCriteria.getFinished()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getExamSite())){
|
|
|
+ predicates.add(cb.like(root.get("examSite"),"%"+examCriteria.getExamSite()+"%"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getIdentityNumber())){
|
|
|
+ predicates.add(cb.like(root.get("identityNumber"),"%"+examCriteria.getIdentityNumber()+"%"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getSpecialtyName())){
|
|
|
+ predicates.add(cb.like(root.get("specialtyName"),"%"+examCriteria.getSpecialtyName()+"%"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getPaperType())){
|
|
|
+ predicates.add(cb.equal(root.get("paperType"),examCriteria.getPaperType()));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getDegree())){
|
|
|
+ predicates.add(cb.equal(root.get("degree"),examCriteria.getDegree()));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getRepair())){
|
|
|
+ predicates.add(cb.equal(root.get("repair"),examCriteria.getRepair()));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getGraduated())){
|
|
|
+ predicates.add(cb.equal(root.get("graduated"),examCriteria.getGraduated()));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getGrade())){
|
|
|
+ predicates.add(cb.like(root.get("grade"),"%"+examCriteria.getGrade()+"%"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getExamNumber())){
|
|
|
+ predicates.add(cb.like(root.get("examNumber"),"%"+examCriteria.getExamNumber()+"%"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(examCriteria.getInfoCollector())){
|
|
|
+ predicates.add(cb.like(root.get("infoCollector"),"%"+examCriteria.getInfoCollector()+"%"));
|
|
|
+ }
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+ return specification;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 复制考生
|
|
|
* @param sourceExamId
|
|
@@ -469,9 +561,13 @@ public class ExamStudentService {
|
|
|
orgExamInfo.setOrgName(rs.getString("orgname"));
|
|
|
orgExamInfo.setAllNum(rs.getInt("allNum"));
|
|
|
orgExamInfo.setCompletedNum(rs.getInt("completedNum"));
|
|
|
- DecimalFormat df = new DecimalFormat("#.00");
|
|
|
- double proportion = orgExamInfo.getCompletedNum()/orgExamInfo.getAllNum();
|
|
|
- orgExamInfo.setProportion(df.format(proportion));
|
|
|
+ if(orgExamInfo.getCompletedNum()==0){
|
|
|
+ orgExamInfo.setProportion("0");
|
|
|
+ }else{
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
+ double proportion = (double)orgExamInfo.getCompletedNum()/orgExamInfo.getAllNum();
|
|
|
+ orgExamInfo.setProportion(df.format(proportion*100));
|
|
|
+ }
|
|
|
return orgExamInfo;
|
|
|
}
|
|
|
});
|