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的用法
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;
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。