Esempio n. 1
0
 /**
  * 生成群发文件
  *
  * @param terminalid 群发号码
  * @param blackid 黑名单号码
  * @param whiteid 白名单号码
  * @param task 群发任务对象
  * @throws Exception
  */
 public long saveTaskSendFile(String terminalid, String filePath) throws Exception {
   int submitCnt = 0;
   try {
     if (null != terminalid && !terminalid.equals("")) {
       terminalid = terminalid.replaceAll(",", ",");
       submitCnt = terminalid.split(",").length;
       // 把号码写入文件
       terminalid = terminalid.replaceAll(",", "\r\n"); // 把输入的号码分隔符","换成行号
       FileTools.writeTxt(terminalid, filePath);
     }
   } catch (Exception e) {
     log.error("生成群发文件出错:" + e.getMessage());
   }
   return submitCnt;
 }
Esempio n. 2
0
  /**
   * 保存SMS群发任务
   *
   * @param task
   * @param uploadfile
   * @param uploadblackfile
   * @param uploadwhitefile
   * @throws Exception
   */
  @Transactional
  public void saveMsmTask(
      BatchTask task,
      MultipartFile uploadfile,
      MultipartFile uploadblackfile,
      MultipartFile uploadwhitefile,
      Long mmsvalue)
      throws Exception {
    String IsNewTerminalId = task.getIsNewTerminalId();
    String srcFrom = task.getSrcFrom();
    String smsorwapservice[] = task.getService().split("\\|");
    task.setFeeType(Long.valueOf(smsorwapservice[1]));
    task.setServiceId(smsorwapservice[0]);
    task.setFee(Long.valueOf(smsorwapservice[2]));
    task.setStatus(0L);

    task.setSpeed(50L);
    task.setTaskType(2l);
    task.setCreateTime(TimeStamp.getTime(14));
    task.setPriority(10L);
    task.setTraceRespond(1L);
    task.setStartTime(
        task.getStartTime().replaceAll("-", "").replaceAll(" ", "").replaceAll(":", ""));
    task.setStopTime(
        task.getStopTime().replaceAll("-", "").replaceAll(" ", "").replaceAll(":", ""));
    task.setCustomTag(0l);
    if (null != mmsvalue && !"".equals(mmsvalue)) {
      ContMms mmsInfo = mmsDao.findOne(mmsvalue);
      String mmstitle = mmsInfo.getTitle();
      String mmscontent = mmsInfo.getContentPath();
      String mmssmil = mmsInfo.getSmilName();
      task.setTitle(mmstitle);
      task.setContent(mmscontent);
      task.setSmil(mmssmil);
    }
    task = batchTaskDao.save(task);
    if (IsNewTerminalId.equals("1")) {
      PathInfo filepath =
          bsFileService.dealModuleFile(
              uploadfile, BsFileService.MODULE_TASK_BATCH, task.getId()); // 群发号码文件路径
      PathInfo whiteFilepath =
          bsFileService.dealModuleFile(
              uploadwhitefile, BsFileService.MODULE_TASK_BATCH_WHITE, task.getId()); // 白名单号码文件路径
      PathInfo blackFilepath =
          bsFileService.dealModuleFile(
              uploadblackfile, BsFileService.MODULE_TASK_BATCH_BLACK, task.getId()); // 黑名单号码文件路径

      // 号码文件来源文本文件
      if (srcFrom.equals("1")) {
        if (uploadfile != null && !uploadfile.isEmpty()) {
          List list = FileTools.readLines(filepath.getRealPath());
          task.setSubmitCnt(Long.valueOf(list.size()));
          // task.setMobileListFile(filepath.getRealWebPath(""));
          task.setMobileListFile(filepath.getRealPath()); // 存放号码文件绝对路径
        }
        if (uploadwhitefile != null && !uploadwhitefile.isEmpty()) {
          // task.setWhiteListFile(whiteFilepath.getRealPath());
          task.setWhiteListFile(whiteFilepath.getRealPath()); // 存放号码文件绝对路径
        }
        if (uploadblackfile != null && !uploadblackfile.isEmpty()) {
          // task.setBlackListFile(blackFilepath.getRealWebPath(""));
          task.setBlackListFile(blackFilepath.getRealPath()); // 存放号码文件绝对路径
        }
      } else {
        task.setSubmitCnt(saveTaskSendFile(task.getTerminalid(), filepath.getRealPath()));
        // saveTaskSendFile(task.getTerminalid(),
        // filepath.getRealPath());
        task.setMobileListFile(filepath.getRealPath()); // 存放号码文件绝对路径
        if (null != task.getBlackid() && !"".equals(task.getBlackid())) {
          // 黑名单文件
          saveTaskSendFile(task.getBlackid(), blackFilepath.getRealPath());
          // task.setBlackListFile(blackFilepath.getRealWebPath(""));
          task.setBlackListFile(blackFilepath.getRealPath()); // 存放号码文件绝对路径
        }
        if (null != task.getWhiteid() && !"".equals(task.getWhiteid())) {
          // 白名单文件
          saveTaskSendFile(task.getWhiteid(), whiteFilepath.getRealPath());
          // task.setWhiteListFile(whiteFilepath.getRealWebPath(""));
          task.setWhiteListFile(whiteFilepath.getRealPath()); // 存放号码文件绝对路径
        }
      }

      batchTaskDao.save(task);
    }
  }