|
@@ -5,6 +5,7 @@ import cn.com.qmth.stmms.ms.core.domain.Student;
|
|
|
import cn.com.qmth.stmms.ms.core.domain.enums.TrialEnum;
|
|
|
import cn.com.qmth.stmms.ms.core.vo.Subject;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import java.util.ArrayList;
|
|
@@ -135,6 +136,7 @@ public class StudentSpecification extends PagingAndSortingSpecification {
|
|
|
public Specification<Student> getSpecification() {
|
|
|
return (root, query, cb) -> {
|
|
|
List<Predicate> predicates = new ArrayList<Predicate>();
|
|
|
+ List<Predicate> listPermission = new ArrayList<>();
|
|
|
predicates.add(cb.equal(root.get("test"), String.valueOf(TrialEnum.DEFAULT.getId())));
|
|
|
if (getStudentName() != null) {
|
|
|
predicates.add(cb.like(root.get("name"), "%" + getStudentName() + "%"));
|
|
@@ -149,7 +151,18 @@ public class StudentSpecification extends PagingAndSortingSpecification {
|
|
|
predicates.add(cb.equal(root.get("areaCode"), getAreaCode()));
|
|
|
}
|
|
|
if (getIsAbsent() != null) {
|
|
|
- predicates.add(cb.equal(root.get("isAbsent"), getIsAbsent()));
|
|
|
+// predicates.add(cb.equal(root.get("isAbsent"), getIsAbsent()));
|
|
|
+ if (getSubject().equals(Subject.SC.name())) {
|
|
|
+ predicates.add(cb.equal(root.get("scMissing"), true));
|
|
|
+ } else if (getSubject().equals(Subject.SX.name())) {
|
|
|
+ predicates.add(cb.equal(root.get("sxMissing"), true));
|
|
|
+ } else if (getSubject().equals(Subject.SM.name())) {
|
|
|
+ predicates.add(cb.equal(root.get("smMissing"), true));
|
|
|
+ } else {
|
|
|
+ listPermission.add(cb.equal(root.get("scMissing"), true));
|
|
|
+ listPermission.add(cb.equal(root.get("sxMissing"), true));
|
|
|
+ listPermission.add(cb.equal(root.get("smMissing"), true));
|
|
|
+ }
|
|
|
}
|
|
|
// if (getUploadStatus() != null) {
|
|
|
// predicates.add(cb.like(root.get("uploadStatus"), "%" + getUploadStatus() + "%"));
|
|
@@ -164,13 +177,6 @@ public class StudentSpecification extends PagingAndSortingSpecification {
|
|
|
if (getUpload() != null && !getUpload()) {
|
|
|
if (Objects.nonNull(getSubject()) && !getSubject().isEmpty()) {
|
|
|
predicates.add(cb.like(root.get("uploadStatus"), "%" + getSubject() + ":0" + "%"));
|
|
|
- if(getSubject().equals(Subject.SC.name())){
|
|
|
- predicates.add(cb.equal(root.get("scMissing"), true));
|
|
|
- } else if(getSubject().equals(Subject.SX.name())){
|
|
|
- predicates.add(cb.equal(root.get("sxMissing"), true));
|
|
|
- } else if(getSubject().equals(Subject.SM.name())){
|
|
|
- predicates.add(cb.equal(root.get("smMissing"), true));
|
|
|
- }
|
|
|
} else {
|
|
|
predicates.add(cb.equal(root.get("uploadStatus"), "SX:0,SC:0,SM:0"));
|
|
|
}
|
|
@@ -187,7 +193,14 @@ public class StudentSpecification extends PagingAndSortingSpecification {
|
|
|
if (getExamRoom() != null && getExamRoom() != "") {
|
|
|
predicates.add(cb.equal(root.get("examRoom"), getExamRoom()));
|
|
|
}
|
|
|
- return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ Predicate Pre_And = cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ if (!CollectionUtils.isEmpty(listPermission)) {
|
|
|
+ Predicate[] predicatesPermissionArr = new Predicate[listPermission.size()];
|
|
|
+ Predicate Pre_Or = cb.or(listPermission.toArray(predicatesPermissionArr));
|
|
|
+ return query.where(Pre_And, Pre_Or).getRestriction();
|
|
|
+ } else {
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ }
|
|
|
};
|
|
|
}
|
|
|
}
|