派生自 projectDept/qhighschool

11
yn147
2022-11-21 e2f63040ba839fb0045360b4971ebbb06a79d55d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package com.qxueyou.scc.exam.service.impl;
 
import java.text.SimpleDateFormat;
import java.util.*;
 
import com.qxueyou.scc.exam.model.ExamResultV;
import org.springframework.stereotype.Service;
 
import com.qxueyou.scc.base.model.Pager;
import com.qxueyou.scc.base.model.Result;
import com.qxueyou.scc.base.service.impl.CommonAppService;
import com.qxueyou.scc.base.util.CollectionUtils;
import com.qxueyou.scc.base.util.TraceUtils;
import com.qxueyou.scc.exam.model.ExamBatchClassRe;
import com.qxueyou.scc.exam.model.ExamBatchInfo;
import com.qxueyou.scc.exam.service.IExamBatchService;
 
/**
 * ÊÔ¾íÅú´Î¹ÜÀí·þÎñ²ã
 *
 * @author kevin
 * @createTime 2017-11-1
 */
@Service
public class ExamBatchService extends CommonAppService implements IExamBatchService {
 
    @Override
    public int queryExamBatchCount(Map<String, Object> param) {
        // TODO Auto-generated method stub
        return 0;
    }
 
    @Override
    public List<ExamBatchInfo> queryExamBatchList(Map<String, Object> param,Pager page) {
        // TODO Auto-generated method stub
        return null;
    }
 
    @Override
    public List<Map<String,Object>> queryListForIdName() {
//        String hql="select v from ExamResultV v where v.startTime >? ";
        //¸ù¾Ý¿¼ÊÔ»ñÈ¡ËùÓÐÅú´ÎÐÅÏ¢
        String hql="select r from ExamBatchInfo i , ExamBatchClassRe r where i.examId in (SELECT e.examId from ExamInfo e where e.deleteFlag is false )" +
                " and i.deleteFlag is false and i.startTime>? and r.examBatchId=i.examBatchId ";
        //»ñÈ¡ÁÐ±í£¬¿ªÊ¼Ê±¼ä´óÓÚµ±Ç°Ê±¼ä£¬Ò²¾ÍÊÇ»¹Î´¿ªÊ¼
        List<ExamBatchClassRe> examResults = this.find(hql, CollectionUtils.newList(new Date()), ExamBatchClassRe.class);
        List<Map<String,Object>> list=new ArrayList<>();
        for (ExamBatchClassRe examResult : examResults) {
            //·â×°³Éǰ¶ËÒªÓõÄÊý¾Ý
            Map<String,Object> map=new HashMap<>();
            //»ñÈ¡¿¼ÊÔÃû³Æ¼ÓÅú´ÎÐÅÏ¢
            String ql="SELECT e.examName from ExamInfo e where e.deleteFlag is false and e.examId=?";
            //»ñÈ¡¿¼ÊÔÃû³Æ
            String s = this.findUnique(ql, CollectionUtils.newList(examResult.getExamId()), String.class);
            String q="SELECT e from ExamBatchInfo e where e.deleteFlag is false and e.examBatchId=?";
            //Åú´ÎÐÅÏ¢
            ExamBatchInfo examBatchInfo = this.findUnique(q, CollectionUtils.newList(examResult.getExamBatchId()), ExamBatchInfo.class);
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            //²âÊÔ¿¼ÊÔ(¿¼³¡Ò»_2020-06-16 9:00 ~ 06-16 12:00)
            s+="("+examBatchInfo.getExamRoomName()+"_"+format.format(examBatchInfo.getStartTime())+" ~ "+new SimpleDateFormat("MM-dd HH:mm:ss").format(examBatchInfo.getEndTime())+")";
            map.put("batchName",s);
            map.put("batchId",examResult.getExamBatchId());
            map.put("classId",examResult.getClassId());
            list.add(map);
        }
        return list;
    }
    @Override
    public List<String> queryComNameByBatchId(String classId) {
        //¸ù¾ÝËùÔÚ×éid
        String hql="select f.subjectId from StuStudent f where f.subjectId is not null and f.classId =? and f.deleteFlag is false group by f.subjectId";
        //»ñÈ¡¹«Ë¾Ãû³ÆÁбí
        return this.find(hql, CollectionUtils.newList(classId), String.class);
    }
    @Override
    public List<String> queryStudentNoByComNameAndBatch(String subjectId,String classId) {
        //¸ù¾ÝËùÔÚ×éid
//        String hql="select f.studentNo from StuStudent f where f.subjectId=? and f.classId =? and f.deleteFlag is false ";
        String hql="select f.studentNo from StuStudent f where  f.classId =? and f.deleteFlag is false ";
        //»ñÈ¡Áбí
//        return this.find(hql, CollectionUtils.newList(subjectId,classId), String.class);
        return this.find(hql, CollectionUtils.newList(classId), String.class);
    }
 
    @Override
    public String addExamBatch(ExamBatchInfo examBatchInfo) {
        //²éѯ×î´óÅú´ÎºÅ
        Short  maxBatchNo = this.findUnique("select max(f.examBatchNo) from ExamBatchInfo f where f.examId =? and f.deleteFlag is false", CollectionUtils.newList(examBatchInfo.getExamId()), Short.class);
        maxBatchNo = maxBatchNo==null?0:maxBatchNo;
        examBatchInfo.setExamBatchNo(++maxBatchNo);
        TraceUtils.setCreateTrace(examBatchInfo);
        this.insert(examBatchInfo);
        List<ExamBatchClassRe> lstExamBatchClassRe = examBatchInfo.getReClasses();
        if(lstExamBatchClassRe!=null &&lstExamBatchClassRe.size()>0){
            for(ExamBatchClassRe examBatchClassRe :lstExamBatchClassRe){
                TraceUtils.setCreateTrace(examBatchClassRe);
                examBatchClassRe.setExamBatchId(examBatchInfo.getExamBatchId());
                examBatchClassRe.setExamId(examBatchInfo.getExamId());
                this.insert(examBatchClassRe);
            }
        }
        return examBatchInfo.getExamBatchId();
    }
 
    @Override
    public Result deleteExamBatch(String[] elxamBatchIds) {
        Result result = new Result(true) ;
        if(elxamBatchIds!=null && elxamBatchIds.length>0 ){
            String hql = "update ExamBatchInfo set deleteFlag = true where examBatchId=?";
            result = bulkUpdateInLoop(hql, elxamBatchIds);
        }
        return result;
    }
 
    @Override
    public Result updateExamBatch(ExamBatchInfo param) {
        ExamBatchInfo examBatchInfo = read(ExamBatchInfo.class, param.getExamBatchId());
        if(examBatchInfo!=null){
            TraceUtils.setUpdateTrace(examBatchInfo);
            examBatchInfo.setStartTime(param.getStartTime());
            examBatchInfo.setEndTime(param.getEndTime());
            List<ExamBatchClassRe> lstExamBatchClassRe = param.getReClasses();
            //ɾ³ýÔ­À´µÄ¹ØÁª¹ØÏµ
            String hql="update ExamBatchClassRe set deleteFlag = true where examBatchId=? ";
            this.bulkUpdate(hql, new Object[]{ param.getExamBatchId()});
 
            if(lstExamBatchClassRe!=null &&lstExamBatchClassRe.size()>0){
                for(ExamBatchClassRe examBatchClassRe :lstExamBatchClassRe){
                    TraceUtils.setCreateTrace(examBatchClassRe);
                    examBatchClassRe.setExamBatchId(examBatchInfo.getExamBatchId());
                    examBatchClassRe.setExamId(examBatchInfo.getExamId());
                    this.insert(examBatchClassRe);
                }
            }
        }
        return save(examBatchInfo);
    }
 
    @Override
    public ExamBatchInfo queryExamBatchDetail(String examBatchId) {
        return this.read(ExamBatchInfo.class, examBatchId);
    }
 
    @Override
    public ExamBatchClassRe queryExamBatchByClassId(String examBatchId) {
        String hql="select f from ExamBatchClassRe f where f.examBatchId =? and f.deleteFlag is false";
        return this.findUnique(hql, CollectionUtils.newList(examBatchId), ExamBatchClassRe.class);
    }
 
}