@Test
 public void testSendLogAll() throws ParseException, FileNotFoundException {
   UrpayOrderRequest urpay = new UrpayOrderRequest();
   urpay.setDpId("65927470");
   //		urpay.setStartCreated(DateUtils.parseDate("2013-06-23", "yyyy-MM-dd").getTime());
   //		urpay.setEndCreated(DateUtils.parseDate("2013-06-24", "yyyy-MM-dd").getTime());
   //		System.out.println(JackSonMapper.toJsonString(urpay));
   PrintWriter pw = new PrintWriter("f:/a.txt");
   countOrderRepository.getSendLogByTypeAlls(urpay, pw);
   //
   //		for (SendLogDomain sendLogDomain : listPage) {
   //			System.out.println(JackSonMapper.toJsonString(sendLogDomain));
   //		}
 }
  @Test
  public void test() throws ParseException, FileNotFoundException {
    UrpayOrderRequest urpay = new UrpayOrderRequest();
    urpay.setDpId("65927470");
    //		urpay.setStartCreated(DateUtils.parseDate("2013-06-23", "yyyy-MM-dd").getTime());
    //		urpay.setEndCreated(DateUtils.parseDate("2013-06-24", "yyyy-MM-dd").getTime());

    StringBuffer sql = new StringBuffer();
    Map<String, Object> paramMap = new HashMap<String, Object>();
    final Map<String, String> columnNameMap = new LinkedHashMap<String, String>(6);
    final Object[] columnName = construct(columnNameMap, paramMap, sql, urpay);
    System.out.println(columnName);
    System.out.println(sql);
  }
 private Object[] construct(
     Map<String, String> columnNameMap,
     Map<String, Object> paramMap,
     StringBuffer sql,
     UrpayOrderRequest request) {
   // 列名对应的中文名称
   columnNameMap.put("created", "发送时间");
   columnNameMap.put("mobile", "手机号码");
   columnNameMap.put("type", "发送类型");
   columnNameMap.put("buyerNick", "淘宝昵称");
   columnNameMap.put("tid", "订单编号");
   columnNameMap.put("smsContent", "短信内容");
   // 查询 sql
   sql.append("select from tb_tc_send_log ").append("where dp_id = :dpId ");
   // 查询参数
   paramMap.put("dpId", request.getDpId());
   if (ObjectUtils.notEqual(request.getType(), null)) {
     sql.append("and type = :type ");
     paramMap.put("type", request.getType());
   }
   if (ObjectUtils.notEqual(request.getStartCreated(), null)
       && ObjectUtils.notEqual(request.getEndCreated(), null)) {
     sql.append("and (created between :startCreated and :endCreated) ");
     paramMap.put("startCreated", new Date(request.getStartCreated()));
     paramMap.put("endCreated", new Date(request.getEndCreated()));
   }
   if (StringUtils.isNotEmpty(request.getMobileOrNickOrTid())) {
     sql.append("and (mobile = :fields or buyer_nick = :fields or tid = :fields) ");
     paramMap.put("fields", request.getMobileOrNickOrTid());
   }
   String columns =
       " date_format(created, ''%Y-%m-%d %H:%i:%s'') as {0}, mobile as {1}, type as {2}, buyer_nick as {3}, tid as {4}, sms_content as {5}";
   Object[] columnName = columnNameMap.keySet().toArray(new Object[0]);
   columns = MessageFormat.format(columns, columnName);
   sql.insert(6, columns);
   return columnName;
 }