Example #1
0
  /**
   * 天健发送短信函数 其实只记录到数据库表,不发送 要立即发送,请调用 sendRealSm
   *
   * @param recvNum //测试接收号码,号码间用逗号隔开
   * @param content //测试内容
   * @return
   */
  public static synchronized String sendSm(
      String recvNum, String content, String unkey, Connection conn, String sendtime) {
    // recvNum="13632254864";
    String clientNo = "057188216999"; // "057187719000,057188216999";
    String remark = MessageFormat.format("平台{2}发短信{0}:{1}", recvNum, content, clientNo);
    //// System.out.println(remark);

    DbUtil dbUtil = null;
    String re = "";
    int eff = 0;
    SmsConfigVO smsConfigVO = null;
    try {
      dbUtil = new DbUtil(conn);
      smsConfigVO = dbUtil.load(SmsConfigVO.class, "sys");
      SmsVO smsVO = new SmsVO();
      smsVO.setClient_num(smsConfigVO.getClient_no());
      smsVO.setContext(content);
      smsVO.setCreate_time(StringUtil.getCurDateTime());
      smsVO.setSend_date(StringUtil.getCurDate());
      // System.out.println("=====================sendtime="+sendtime);
      smsVO.setSend_time(sendtime);
      smsVO.setRemark(remark);
      smsVO.setUn_key(unkey);
      smsVO.setUuid(UUID.randomUUID().toString());
      smsVO.setState("r"); //
      smsVO.setMobile(recvNum);

      eff += dbUtil.insert(smsVO);

    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return re;
  }
Example #2
0
  public static synchronized String sendRealSm(
      String recvNum, String content, SmsConfigVO smsConfigVO) {

    if (smsConfigVO == null) {
      return sendRealSm(
          DEFAULT_URL,
          DEFAULT_ACCOUNT,
          DEFAULT_VALIDATE_CODE,
          "SEND",
          "88216999",
          recvNum,
          content);
    } else {

      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
      Date sdate = null, ndate = new Date(), edate = null;
      try {
        sdate = sdf.parse(StringUtil.getCurDate() + " " + smsConfigVO.getStart_time());
        edate = sdf.parse(StringUtil.getCurDate() + " " + smsConfigVO.getEnd_time());
        if (ndate.before(sdate) || ndate.after(edate)) {
          return MessageFormat.format(
              "{2}超过短信发送时间{0}至{1}",
              smsConfigVO.getStart_time(), smsConfigVO.getEnd_time(), StringUtil.getCurTime());
        }
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      return sendRealSm(
          smsConfigVO.getService_url(),
          smsConfigVO.getUnit_code(),
          smsConfigVO.getSubject_code(),
          smsConfigVO.getSend_type(),
          // "88216999",
          smsConfigVO.getClient_no(),
          StringUtil.isBlank(smsConfigVO.getTest_phone()) ? recvNum : smsConfigVO.getTest_phone(),
          content + smsConfigVO.getContext_subfix());
    }
  }