/******************************************************************************
|
* 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;
|
}
|
|
}
|