zoukankan      html  css  js  c++  java
  • 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;
    }

  • 相关阅读:
    程序返回插入数据库成功,但是数据库内却没有数据
    C++ 使用动态二维数组参数
    深入理解.Net中的内存释放,以及有关的注意事项
    用数据集时,错误:未能启用约束。一行或多行中包含违反非空、唯一或外键约束的值
    关于堆和栈
    C#加密方法总汇
    const与readonly
    struts 将上传文件保存到数据库中
    java Annotation注解的运用
    转:获取汉字的拼音(包括一级和二级)
  • 原文地址:https://www.cnblogs.com/zhouxiansheng/p/4360804.html
Copyright © 2011-2022 走看看