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