Example #1
0
  /**
   * 更新SIM卡信息
   *
   * @return
   */
  public String update() {
    UserInfo currentUser =
        (UserInfo) ActionContext.getContext().getSession().get(Constants.USER_SESSION_KEY);
    if (simInfo != null) {
      // 设置修改用户
      simInfo.setModifier(currentUser.getUserID());
      // 设置SIM卡主键值
      simInfo.setSimId(simId);
      // 设置旧SIM卡号值
      simInfo.setOldSimCardNumber(simOldNumber);
    }

    try {
      // 修改SIM卡信息
      simManageService.updateSimInfo(simInfo);
      setMessage("sim.update.success");
    } catch (BusinessException e) {
      setMessage("info.db.error");
      log.error("Update sim info error:" + e.getMessage());
      return ERROR;
    } catch (Exception e) {
      setMessage("info.db.error");
      log.error("Update sim info error:" + e.getMessage());
      return ERROR;
    } finally {
      setOperationType(Constants.UPDATE, ModuleId.CLW_M_CS_SIM_MODIFY_MID);
      addOperationLog("修改SIM卡信息");
    }

    return SUCCESS;
  }
Example #2
0
  /**
   * 导入SIM卡信息
   *
   * @return
   */
  public String importSim() {
    if (null == file
        || null == fileContentType
        || null == fileFileName
        || fileFileName.length() < 3) {
      getBusinessInfos();
      log.info(getText("file.not.exist"));
      addActionError(getText("file.not.exist"));
      return ERROR;
    } else if (!"xls"
        .equals(fileFileName.substring(fileFileName.length() - 3, fileFileName.length()))) {
      // 判断是否是excel类型文件
      getBusinessInfos();
      addActionError(getText("file.type.err"));
      log.info(getText("file.type.err"));
      return ERROR;
    }

    List<SimInfo> list = new ArrayList<SimInfo>();

    FileInputStream fis = null;
    try {
      fis = new FileInputStream(file);
      IEExcelImporter excelImplortor = null;
      try {
        excelImplortor = new IEExcelImporter(fis);
      } catch (Exception e) {
        setMessage("file.import.error");
        log.error("Import file error:" + e.getMessage());
      }

      list = excelImplortor.getSheetData("importSim", 0);

      String errMessage = getFileContentError(excelImplortor.getErrorMessage());

      if (errMessage.length() > 0) {
        getBusinessInfos();
        addActionError(errMessage);
        return ERROR;
      }
    } catch (Exception e) {
      getBusinessInfos();
      setMessage(getText("file.import.error"));
      log.error("Import file error:" + e.getMessage());
      return ERROR;
    } finally {
      // 关闭流
      if (null != fis) {
        try {
          fis.close();
        } catch (IOException e) {;
        }
      }
    }

    // 格式化数据
    list = formatSimInfos(list);

    if (list.size() == 0) {
      getBusinessInfos();
      // 文件中无内容
      addActionMessage(getText("file.content.empty"));
      return ERROR;
    } else {
      try {
        // 导入SIM卡信息
        simManageService.importSimInfos(list);
        setMessage("file.import.success");
      } catch (BusinessException e) {
        getBusinessInfos();
        addActionError(getText("info.db.error"));
        log.error("Import sim error:" + e.getMessage());
        return ERROR;
      } catch (Exception e) {
        getBusinessInfos();
        addActionError(getText("info.db.error"));
        log.error("Import sim error:" + e.getMessage());
        return ERROR;
      } finally {
        setOperationType(Constants.IMPORT, ModuleId.CLW_M_CS_SIM_IMPORT_MID);
        addOperationLog("导入SIM卡信息");
      }
    }

    return SUCCESS;
  }