log4j打印错误日志输出 利用sql取出的值放在list集合中,集合中的字段类型为映射类类型

public ServiceResult<List<KefuDetail>> MaxRespondtime(Date startDate,Date endDate, String saler, String taobaoShopConfId)
{
ServiceResult<List<KefuDetail>> result = new ServiceResult<List<KefuDetail>>();

String start = ParameterUtil.formatDatetime(startDate);
String end = ParameterUtil.formatDatetime(endDate);
List<Object[]> list = dao.getKefuDetailListMaxRespondtime(start, end, saler,taobaoShopConfId);
Object[] max_time_item = dao.getMax(start, end, saler,taobaoShopConfId);
Integer max = (Integer)max_time_item[0];
List<KefuDetail> detailList = new ArrayList<KefuDetail>();//建立一个映射类型为javabean类型的集合框架detaillist
for (Object[] objs : list)
{
KefuDetail detail = new KefuDetail();//建立一个javabean,然后对其进行操作,最后把整个javabean加入到这个list中。
String referee = ParameterUtil.getStringValue(objs[0]); //objs[0]对应着SQL语句查询字段的第一个字段。
detail.setReferee(referee);
String replier = ParameterUtil.getStringValue(objs[1]);
detail.setReplier(replier);
String dateTime = ParameterUtil.getStringValue(objs[2]);
detail.setDateTime(dateTime);
String content = ParameterUtil.getStringValue(objs[3]);
detail.setContent(content);
String interval = ParameterUtil.getStringValue(objs[4]);
detail.setInterval(interval);
String section_id = ParameterUtil.getStringValue(objs[5]);
detail.setSection_id(section_id);
System.out.println(section_id);
if(interval != null && !interval.equalsIgnoreCase("") && max == Integer.parseInt(interval)){
detail.setMark(1);
}else{
detail.setMark(0);
}
detailList.add(detail);
}
result.setResult(detailList);
return result;
}

Log4J的用法

 import org.apache.log4j.Logger;
 private Logger log = Logger.getLogger(HibernateKefujixiaoDao.class); 
 

public List<Object[]> getKefuDetailListGreaterStandardRate(String startDate, String endDate, String saler, String taobaoShopConfId ){
try{
Session session = slaveSessionFactory.getCurrentSession();
String sql ="SELECT cc.referee,cc.replier, cc.time,CAST(cc.content AS char(255)),cc.`interval`,if(cc.interval>60,1,0) as mark,cc.section_id from ecshop.taobao_consulting_content cc "+
"inner join ecshop.taobao_consulting_section s on cc.section_id = convert(s.section_id using utf8) "+
"where s.`owner` = '"+saler+"' and s.taobao_shop_id = '"+ taobaoShopConfId+"' and "+
" s.start >= '"+startDate+"' AND s.start < date_add('"+endDate+"',interval 1 day)" +
"and cc.section_id in (select section_id from ecshop.taobao_consulting_section )" +
" order by cc.time ";
System.out.println( "超标率sql:" +sql);
Query query = session.createSQLQuery(sql);
List<Object[]> result = query.list();
return result;
} catch (Exception e) {
log.error("HibernateKefujixiaoDao[getKefuDetailList1] ", e.fillInStackTrace());
}
return null;
}

posted @ 2015-03-23 19:38  周先森  阅读(1212)  评论(0编辑  收藏  举报