Ejemplo n.º 1
0
  /**
   * 方法用途和描述: 定时发送彩信任务
   *
   * @author chenliang 新增日期:2013-10-26
   * @throws ServiceException
   * @throws RemoteException
   * @since mms-task
   */
  public void inTimeSendMmsWork() throws ServiceException, RemoteException {
    // 查询彩信待发送表中的数据,等级为1,渠道为web
    String hql =
        "from TbSendMmsQueue where sendLevel=1 and channel=1 and toBeSendTime is not null and states = 1";
    List<TbSendMmsQueue> queueList = sendMmsQueueDAO.find(hql);
    try {
      if (null != queueList && queueList.size() > 0) {
        Mcp mcp = new McpServiceLocator().getMcpPort();
        Gson gson = new Gson();
        String param = "";
        LOGGER.info("开始定时发送彩信任务.");
        Date now = new Date();
        for (int i = 0; i < queueList.size(); i++) {
          TbSendMmsQueue sendMmsQueue = queueList.get(i);
          if (now.after(sendMmsQueue.getToBeSendTime())) {
            PostcardMMS cardmms = new PostcardMMS();
            cardmms.setSender(sendMmsQueue.getSponsor()); // 发起人
            cardmms.setReceiver(sendMmsQueue.getReciver()); // 接收人
            cardmms.setContent(sendMmsQueue.getMsgBody()); // 内容
            cardmms.setChannel("" + sendMmsQueue.getChannel()); // 渠道
            cardmms.setMsgType(sendMmsQueue.getMsgType()); // 消息类型
            cardmms.setMsgSn(sendMmsQueue.getTransationId()); // 消息id
            cardmms.setSubject(sendMmsQueue.getTitle());
            cardmms.setImagePath(sendMmsQueue.getPicUrl()); // 图片地址
            cardmms.setMusicPath(sendMmsQueue.getMusicUrl()); // 音乐地址

            // 根据发起人号码,查询产品号码
            TSignOrder signOrder = userService.findProductByMdn(sendMmsQueue.getSponsor());
            cardmms.setProductCode(signOrder.getProductId()); // 产品id

            // 调用接口
            param = gson.toJson(cardmms);
            String response = mcp.sendPostcardMms(param);
            Response resp = gson.fromJson(response, new TypeToken<Response>() {}.getType());
            LOGGER.info("接口调用接口[" + resp.getMsg() + "].");
          }
        }
      } else {
        LOGGER.info("没有定时发送彩信任务.");
      }
    } catch (RemoteException e) {
      LOGGER.error("定时发送彩信任务异常.", e);
      throw e;
    }
  }
Ejemplo n.º 2
0
 /**
  * 方法用途和描述: 批量保存待发送短信
  *
  * @param smsList
  * @author chenliang 新增日期:2013-9-27
  * @since mms-task
  */
 public void saveBatchSendSms(List<TbSendMmsQueue> smsList) {
   sendMmsQueueDAO.saveBatchSendSms(null, smsList);
 }