派生自 projectDept/qhighschool

EricsHu
2022-12-05 068fc7f2e81178e55fa191a13709af64b1a163f6
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/******************************************************************************
 * Copyright (C) 2015 Shenzhen Penguin Network Technology Co., Ltd
 * All Rights Reserved.
 * 本软件为深圳企鹅网络科技有限公司开发研制。未经本公司正式书面同意,其他任何个人、团体
 * 不得使用、复制、修改或发布本软件.
 *****************************************************************************/
 
package com.qxueyou.scc.school.dao;
 
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
 
import com.qxueyou.scc.base.dao.BaseDAO;
import com.qxueyou.scc.org.model.OrgTeacher;
 
 
@Repository(value="evaluateDAO")
/**
 * 自动注入sessionFactory 评估
 *
 * @author 邓志永
 * @since JDK1.6
 * @history 2015-01-07 邓志永 新建
 */
public class EvaluateDAO extends BaseDAO {
    
    /**
     * 注入sessionFactory
     *
     * @param sessionFactory
     */
    @Autowired(required = false)
    public void setSessionfactory(SessionFactory sessionFactory) {
        this.setSessionFactory(sessionFactory);
    }
    
    /**
     * 查询签到排名结果
     * @param sql
     * @param args
     * @return
     */
    @SuppressWarnings("unchecked")
    public List<Map<String, Object>> querySignRankList(String sql,
        List<Object> args) {
        // 查询结果
        List<Object[]> lst = (List<Object[]>) this.getHibernateTemplate().find(sql, args.toArray());
        if(lst.isEmpty()){
            return null;
        }
        List<Map<String, Object>> resultLst = new ArrayList<Map<String, Object>>(lst.size());
        
        Map<String, Object> resultMap = new HashMap<String, Object>(8);
        for (Object[] obj : lst) {
             resultMap = new HashMap<String, Object>();
             resultMap.put("userId", obj[0]);
             resultMap.put("userName", obj[1]);
             resultMap.put("signOrder", obj[2]);
             resultMap.put("signTime", obj[3]);
             resultMap.put("lessonId", obj[4]);
             resultMap.put("lessonName", obj[5]);
             resultMap.put("signId", obj[6]);
             resultMap.put("classId", obj[7]);
             resultLst.add(resultMap);
        }
        return resultLst;
    }
    
    /**
     * 查询出勤率结果
     * @param sql
     * @param args
     * @return
     */
    @SuppressWarnings("unchecked")
    public List<Map<String, Object>> querySignAttendanceList(String sql,
        List<Object> args) {
        // 查询结果
        List<Object[]> lst =  this.findBySql(sql, args);
        if(lst.isEmpty()){
            return null;
        }
        List<Map<String, Object>> resultLst = new ArrayList<Map<String, Object>>(lst.size());
        
        Map<String, Object> resultMap = new HashMap<String, Object>(8);
        for (Object[] obj : lst) {
             resultMap = new HashMap<String, Object>();
             resultMap.put("classId", obj[0]);
             resultMap.put("className", obj[1]);
             resultMap.put("userId", obj[2]);
             resultMap.put("userName", obj[3]);
             resultMap.put("stuSignCount", obj[4]);
             resultMap.put("signNormal", obj[5]);
             resultMap.put("classSignCount", obj[6]);
             resultLst.add(resultMap);
        }
        return resultLst;
    }
    
    
    /**
        * 查询家庭作业完成度结果
        * @param sql
        * @param args
        * @return
        */
       @SuppressWarnings("unchecked")
       public List<Map<String, Object>> queryEvaHomeTimelinessList(String sql,
           List<Object> args) {
           
        List<Object[]> lst =  this.findBySql(sql, args);
           if(lst.isEmpty()){
               return null;
           }
           List<Map<String, Object>> resultLst = new ArrayList<Map<String, Object>>(lst.size());
           
           Map<String, Object> resultMap = new HashMap<String, Object>(5);
           for (Object[] obj : lst) {
                resultMap = new HashMap<String, Object>();
                resultMap.put("classId", obj[0]);
                resultMap.put("className", obj[1]);
                resultMap.put("userId", obj[2]);
                resultMap.put("userName", obj[3]);
                resultMap.put("complateRate", obj[4]);
                resultLst.add(resultMap);
           }
           return resultLst;
       }
       
       /**
        * 查询家庭作业答题分数结果
        * @param sql
        * @param args
        * @return
        */
       @SuppressWarnings("unchecked")
       public List<Map<String, Object>> queryEvaHomeExamResultList(String sql,
               List<Object> args) {
           
           List<Object[]> lst =  this.findBySql(sql, args);
           if(lst.isEmpty()){
               return null;
           }
           List<Map<String, Object>> resultLst = new ArrayList<Map<String, Object>>(lst.size());
           
           Map<String, Object> resultMap = new HashMap<String, Object>(5);
           for (Object[] obj : lst) {
               resultMap = new HashMap<String, Object>();
               resultMap.put("classId", obj[0]);
               resultMap.put("className", obj[1]);
               resultMap.put("userId", obj[2]);
               resultMap.put("userName", obj[3]);
               resultMap.put("correctRate", obj[4]);
               resultLst.add(resultMap);
           }
           return resultLst;
       }
       
    @SuppressWarnings("rawtypes")
    public <T> List<T> queryListByIn(String hql, List<Object> args, Class<T> cls) {
        List<T> result = new ArrayList<T>();
        // 查询结果
        Session session = this.getSessionFactory().getCurrentSession();
        Query query = session.createQuery(hql);
        query.setParameterList("ins", args);
          List lst = query.list();
         for (Object obj : lst) {
             result.add(cls.cast(obj));
         }
         return result;
    }
    
    /**
     * 查询老师列表
     * @param sql
     * @param args
     * @return
     * @throws ParseException 
     */
    @SuppressWarnings("unchecked")
    public List<OrgTeacher> queryTeacherList(String sql,List<Object> args) {
        // 查询结果
        Session session = this.getSessionFactory().getCurrentSession();
        SQLQuery query = session.createSQLQuery(sql);
        query.setResultTransformer(Transformers.aliasToBean(OrgTeacher.class));
        for(int i = 0;args !=null && i < args.size() ;  i++ ){
            query.setParameter(i, args.get(i));
        }
        List<OrgTeacher> lstItems = query.list();
        
        return lstItems;
    }
    
}