|
@@ -62,11 +62,10 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
public List<ExamStudent> findByQuery(ExamStudentSearchQuery query, SubjectiveStatus status, Integer mainNumber,
|
|
|
- Double mainStartScore, Double mainEndScore, Double questionScore, SelectiveStatus selectiveStatus) {
|
|
|
+ Double mainStartScore, Double mainEndScore, SelectiveStatus selectiveStatus) {
|
|
|
int offset=(query.getPageNumber() - 1) * query.getPageSize();
|
|
|
StringBuilder dataSql = new StringBuilder("select s.id from eb_exam_student s ");
|
|
|
- String whereSql = getWhereSql(query, status, mainNumber, mainStartScore, mainEndScore, questionScore,
|
|
|
- selectiveStatus);
|
|
|
+ String whereSql = getWhereSql(query, status, mainNumber, mainStartScore, mainEndScore,selectiveStatus);
|
|
|
dataSql.append(whereSql).append(" order by s.inspect_time desc ").append(" limit "+offset+","+query.getPageSize());
|
|
|
Query dataQuery = entityManager.createNativeQuery(dataSql.toString());
|
|
|
List<Integer> list = dataQuery.getResultList();
|
|
@@ -85,7 +84,7 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
}
|
|
|
|
|
|
private String getWhereSql(ExamStudentSearchQuery query, SubjectiveStatus status, Integer mainNumber,
|
|
|
- Double mainStartScore, Double mainEndScore, Double questionScore, SelectiveStatus selectiveStatus) {
|
|
|
+ Double mainStartScore, Double mainEndScore, SelectiveStatus selectiveStatus) {
|
|
|
StringBuilder whereSql = new StringBuilder(" WHERE s.is_upload = 1 and s.is_absent = 0 and s.is_breach = 0 ");
|
|
|
if (query.getExamId() != null) {
|
|
|
whereSql.append(" and s.exam_id ="+query.getExamId());
|
|
@@ -93,6 +92,10 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
if (StringUtils.isNotBlank(query.getSubjectCode())) {
|
|
|
whereSql.append(" and s.subject_code ='"+query.getSubjectCode()+"'");
|
|
|
}
|
|
|
+ if (StringUtils.isNotBlank(query.getInspectorName())) {
|
|
|
+ whereSql.append(" and exists (select 1 from eb_inspect_history ei left join b_user bu on ei.inspector_id=bu.id "
|
|
|
+ +" where ei.student_id = s.id and bu.login_name like '"+query.getInspectorName()+"%')");
|
|
|
+ }
|
|
|
if (StringUtils.isNotBlank(query.getSubjectCodeIn())) {
|
|
|
String[] subjectCodeIn = query.getSubjectCodeIn().split(",");
|
|
|
List<String> in = new ArrayList<String>();
|
|
@@ -101,18 +104,9 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
}
|
|
|
whereSql.append(" and s.subject_code in ('"+StringUtils.join(in, "','")+"') ");
|
|
|
}
|
|
|
- whereSql.append(" and s.subjective_status IN ('MARKED','INSPECTED')");
|
|
|
- if (status != null) {
|
|
|
- if(SubjectiveStatus.MARKED.equals(status)) {
|
|
|
- whereSql.append(" and not exists(select 1 from eb_inspect_history h "
|
|
|
- +"left join eb_exam_subject sub on h.exam_id=sub.exam_id and h.subject_code=sub.code "
|
|
|
- +"where s.id=h.student_id and h.inspect_round=sub.inspect_round) ");
|
|
|
- }
|
|
|
- if(SubjectiveStatus.INSPECTED.equals(status)) {
|
|
|
- whereSql.append(" and exists(select 1 from eb_inspect_history h "
|
|
|
- +"left join eb_exam_subject sub on h.exam_id=sub.exam_id and h.subject_code=sub.code "
|
|
|
- +"where s.id=h.student_id and h.inspect_round=sub.inspect_round) ");
|
|
|
- }
|
|
|
+ whereSql.append(" and s.subjective_status ='MARKED'");
|
|
|
+ if (query.getInspected() != null) {
|
|
|
+ whereSql.append(" and s.inspected ="+(query.getInspected()?1:0));
|
|
|
}
|
|
|
if (query.getStartScore() != null) {
|
|
|
whereSql.append(
|
|
@@ -125,6 +119,7 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
if (StringUtils.isNotBlank(query.getSecretNumber())) {
|
|
|
whereSql.append(" and s.secret_number ='"+query.getSecretNumber()+"'");
|
|
|
}
|
|
|
+ Double questionScore=query.getQuestionScore();
|
|
|
if (mainNumber != null || mainStartScore != null || mainEndScore != null || questionScore != null) {
|
|
|
whereSql.append(" and exists (select e.student_id from eb_subjective_score e where e.student_id = s.id ");
|
|
|
if (mainNumber != null) {
|
|
@@ -137,7 +132,19 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
whereSql.append(" and e.main_score <="+mainEndScore);
|
|
|
}
|
|
|
if (questionScore != null) {
|
|
|
- whereSql.append(" and e.score ="+questionScore);
|
|
|
+ if(questionScore!=0) {
|
|
|
+ whereSql.append(" and e.score ="+questionScore);
|
|
|
+ }else {
|
|
|
+ if(query.getQuestionScoreEmpty()!=null) {
|
|
|
+ if(query.getQuestionScoreEmpty()) {
|
|
|
+ whereSql.append(" and e.score =0 and e.unanswered_count >0");
|
|
|
+ }else {
|
|
|
+ whereSql.append(" and e.score =0 and (e.unanswered_count is null or e.unanswered_count =0)");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ whereSql.append(" and e.score =0");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
whereSql.append(" ) ");
|
|
|
}
|
|
@@ -173,10 +180,9 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
|
|
|
@Override
|
|
|
public Integer countByQuery(ExamStudentSearchQuery query, SubjectiveStatus status, Integer mainNumber,
|
|
|
- Double mainStartScore, Double mainEndScore, Double questionScore, SelectiveStatus selectiveStatus) {
|
|
|
+ Double mainStartScore, Double mainEndScore,SelectiveStatus selectiveStatus) {
|
|
|
StringBuilder countSql = new StringBuilder("select count(s.id) from eb_exam_student s ");
|
|
|
- String whereSql = getWhereSql(query, status, mainNumber, mainStartScore, mainEndScore, questionScore,
|
|
|
- selectiveStatus);
|
|
|
+ String whereSql = getWhereSql(query, status, mainNumber, mainStartScore, mainEndScore, selectiveStatus);
|
|
|
countSql.append(whereSql);
|
|
|
Query countQuery = entityManager.createNativeQuery(countSql.toString());
|
|
|
Object singleResult = countQuery.getResultList().get(0);
|
|
@@ -186,11 +192,9 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
|
|
|
@Override
|
|
|
public Integer needInspectCount(ExamStudentSearchQuery query, Integer mainNumber,
|
|
|
- Double mainStartScore, Double mainEndScore, Double questionScore,
|
|
|
- SelectiveStatus selectiveStatus) {
|
|
|
+ Double mainStartScore, Double mainEndScore,SelectiveStatus selectiveStatus) {
|
|
|
StringBuilder countSql = new StringBuilder("select count(s.id) from eb_exam_student s ");
|
|
|
- String whereSql = getWhereSql(query, SubjectiveStatus.MARKED, mainNumber, mainStartScore, mainEndScore, questionScore,
|
|
|
- selectiveStatus);
|
|
|
+ String whereSql = getWhereSql(query, SubjectiveStatus.MARKED, mainNumber, mainStartScore, mainEndScore,selectiveStatus);
|
|
|
countSql.append(whereSql);
|
|
|
Query countQuery = entityManager.createNativeQuery(countSql.toString());
|
|
|
Object singleResult = countQuery.getResultList().get(0);
|
|
@@ -243,7 +247,7 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
public boolean inspect(ExamStudent student, Integer userId) {
|
|
|
if (this.hasApplied(student, userId) && SubjectiveStatus.MARKED.equals(student.getSubjectiveStatus())) {
|
|
|
if (!SubjectiveStatus.MARKED.equals(student.getSubjectiveStatus())
|
|
|
- &&!SubjectiveStatus.INSPECTED.equals(student.getSubjectiveStatus())) {
|
|
|
+ ||student.getInspected()) {
|
|
|
return false;
|
|
|
}
|
|
|
ExamSubject subject=examSubjectService.find(student.getExamId(), student.getSubjectCode());
|
|
@@ -252,8 +256,7 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
return false;
|
|
|
}
|
|
|
Date now = new Date();
|
|
|
- studentService.updateSubjectiveStatusAndTimeAndInspectorId(student.getId(), SubjectiveStatus.INSPECTED, now,
|
|
|
- userId);
|
|
|
+ studentService.inspect(student.getId(), now,userId);
|
|
|
InspectHistory i = new InspectHistory();
|
|
|
i.setExamId(student.getExamId());
|
|
|
i.setStudentId(student.getId());
|
|
@@ -269,12 +272,14 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
@Override
|
|
|
public boolean cancel(Integer studentId) {
|
|
|
ExamStudent student = studentService.findById(studentId);
|
|
|
- if (student.getSubjectiveStatus().equals(SubjectiveStatus.INSPECTED)) {
|
|
|
- studentService
|
|
|
- .updateSubjectiveStatusAndTimeAndInspectorId(student.getId(), SubjectiveStatus.MARKED, null, null);
|
|
|
+ ExamSubject sub=examSubjectService.find(student.getExamId(), student.getSubjectCode());
|
|
|
+ if (student.getInspected()) {
|
|
|
+ studentService.cancelInspect(studentId);
|
|
|
+ inspectHistoryService.deleteByStudentIdAndInspectRound(studentId,sub.getInspectRound());
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
@@ -312,10 +317,10 @@ public class InspectedServiceImpl extends BaseQueryService<ExamStudent> implemen
|
|
|
long totalPaperCount = studentService.countByQuery(sQuery);
|
|
|
StringBuilder countSql = new StringBuilder("select count(s.id) from eb_exam_student s where s.exam_id ="
|
|
|
+examId+" and s.subject_code ='"+subjectCode+"'");
|
|
|
- countSql.append(" and s.subjective_status IN ('MARKED','INSPECTED')");
|
|
|
- countSql.append(" and exists(select 1 from eb_inspect_history h "
|
|
|
- +" left join eb_exam_subject sub on h.exam_id=sub.exam_id and h.subject_code=sub.code "
|
|
|
- +" where s.id=h.student_id and h.inspect_round="+inspectRound+") ");
|
|
|
+ countSql.append(" and s.inspected=1");
|
|
|
+// countSql.append(" and exists(select 1 from eb_inspect_history h "
|
|
|
+// +" left join eb_exam_subject sub on h.exam_id=sub.exam_id and h.subject_code=sub.code "
|
|
|
+// +" where s.id=h.student_id and h.inspect_round="+inspectRound+") ");
|
|
|
Query countQuery = entityManager.createNativeQuery(countSql.toString());
|
|
|
Object singleResult = countQuery.getResultList().get(0);
|
|
|
Integer count = singleResult == null ? 0 : Integer.valueOf(singleResult.toString());
|