コード例 #1
0
 /**
  * 收藏收件箱短信,置标志 为 2 收藏
  *
  * @return
  */
 @Action(
     value = "collectByIds",
     results = {
       @Result(
           type = "json",
           params = {"root", "entityMap", "contentType", "text/html"})
     })
 public String collectByIds() {
   Users loginUser = (Users) super.getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO);
   entityMap = new HashMap<String, Object>();
   if (!StringUtil.isEmpty(smsIds) && loginUser != null) {
     Timestamp currentTime = new Timestamp(System.currentTimeMillis());
     try {
       String[] stringArr = smsIds.split(",");
       Long[] ids = ConvertUtil.arrStringToLong(stringArr);
       List<MbnSmsHadSend> smsInList = mbnSmsHadSendService.getByPks(ids);
       List<MbnSmsSelected> smsSelectedList = new ArrayList<MbnSmsSelected>();
       ListIterator<MbnSmsHadSend> smsInIterator = smsInList.listIterator();
       while (smsInIterator.hasNext()) {
         MbnSmsHadSend tempInSms = smsInIterator.next();
         MbnSmsSelected smsSelected = new MbnSmsSelected();
         smsSelected.setId(PinGen.getSerialPin());
         smsSelected.setContent(tempInSms.getContent());
         smsSelected.setCreateBy(loginUser.getId());
         smsSelected.setCreateTime(currentTime);
         smsSelected.setMerchantPin(loginUser.getMerchantPin());
         smsSelectedList.add(smsSelected);
       }
       mbnSmsSelectedService.batchSaveByList(smsSelectedList);
     } catch (Exception e) {
       e.printStackTrace();
       entityMap.put("resultcode", "error");
       entityMap.put("message", "收藏失败!");
     }
     entityMap.put("resultcode", "success");
     entityMap.put("message", "收藏成功!");
   } else {
     entityMap.put("resultcode", "error");
     entityMap.put("message", "收藏失败!");
   }
   return SUCCESS;
 }
コード例 #2
0
  @Action(
      value = "retry",
      results = {
        @Result(
            type = "json",
            params = {"root", "entityMap", "contentType", "text/html"})
      })
  public String retry() {
    String result = SUCCESS;
    entityMap = new HashMap<String, Object>();
    if (!StringUtil.isEmpty(smsIds)) {
      try {
        //				String[] stringArr = smsIds.split(",");
        //				Long[] ids = ConvertUtil.arrStringToLong(stringArr);
        //				List<MbnSmsHadSend> smsList = mbnSmsHadSendService.getByPks(ids);
        PageUtil pageUtil = new PageUtil();
        pageUtil.setBatchId(Long.parseLong(smsIds));
        pageUtil.setSendResult(3);
        List<MbnSmsHadSend> smsList = null;
        Page batchTry = mbnSmsHadSendService.batchPage(pageUtil);
        if (batchTry != null) {
          smsList = (List<MbnSmsHadSend>) batchTry.getData();
        }
        if (smsList != null) {
          ListIterator<MbnSmsHadSend> smsIterator = smsList.listIterator();
          List<MbnSmsReadySend> smsRetry = new ArrayList<MbnSmsReadySend>();
          long batchId = PinGen.getSerialPin();
          while (smsIterator.hasNext()) {
            MbnSmsHadSend tempSms = smsIterator.next();
            MbnSmsReadySend tempTry = new MbnSmsReadySend();
            tempTry.setBatchId(batchId);
            tempTry.setContent(tempSms.getContent());
            tempTry.setCreateBy(tempSms.getCreateBy());
            tempTry.setCutApartNumber(tempSms.getCutApartNumber());
            tempTry.setDescription(tempSms.getDescription());
            tempTry.setId(PinGen.getSerialPin());
            tempTry.setMerchantPin(tempSms.getMerchantPin());
            tempTry.setOperationId(tempSms.getOperationId());
            tempTry.setPriorityLevel(tempSms.getPriorityLevel());
            tempTry.setProvince(tempSms.getProvince());
            tempTry.setSelfMobile(tempSms.getSelfMobile());
            tempTry.setSmsAccessNumber(tempSms.getSmsAccessNumber());
            tempTry.setTaskNumber(tempSms.getTaskNumber());
            tempTry.setTitle(tempSms.getTitle());
            tempTry.setTos(tempSms.getTos());
            tempTry.setTosName(tempSms.getTosName());
            tempTry.setTunnelType(tempSms.getTunnelType());
            tempTry.setWebService(tempSms.getWebService());
            tempTry.setCompleteTime(null);
            // retry
            tempTry.setReadySendTime(new Date());
            tempTry.setCommitTime(new Date());
            tempTry.setSendResult(ApSmsConstants.SMS_READY_STATE);
            tempTry.setFailReason("");
            tempTry.setExpireTime(null);

            smsRetry.add(tempTry);
          }
          mbnSmsReadySendService.batchSaveByList(smsRetry);
          entityMap.put("resultcode", "success");
          entityMap.put("message", "短信失败重发命令提交成功!请勿短时间内重复点击“重发失败项”按钮。");
        } else {
          entityMap.put("resultcode", "error");
          entityMap.put("message", "未找到失败短信信息!");
        }
      } catch (Exception e) {
        entityMap.put("resultcode", "error");
        entityMap.put("message", "短信失败重发命令提交失败!请重试");
        result = ERROR;
        e.printStackTrace();
      }
    }
    return result;
  }
コード例 #3
0
ファイル: UserAction.java プロジェクト: zhaopengshan/ltbird
  /**
   * 新增用户
   *
   * @return
   * @throws Exception
   */
  @Action(
      value = "adduser",
      results = {
        @Result(
            type = "json",
            params = {"root", "entityMap", "contentType", "text/html"})
      })
  public String adduser() {
    try {
      logger.info("add user: 	"******"V_P_" + portalUser.getProvince());
          merchant.setGroupCode(String.valueOf(merchantPin));
          merchant.setPlatform(ApSmsConstants.MERCHANT_PROVINCE_VIRTUAL_TYPE);
          merchant.setCreateTime(new Date());
          boolean result = MbnMerchantVipIService.insertMerchant(merchant);
          logger.info(
              "Province ["
                  + portalUser.getProvince()
                  + "] add virtual merchant ["
                  + merchantPin
                  + "] result:"
                  + result);
        } else {
          merchantPin = vProvinceMerchant.getMerchantPin();
        }
      } else if (userType == ApSmsConstants.USER_TYPE_PROVINCE_ADMIN) {
        // 省管理员创建市管理员
        portalUser.setUserType(ApSmsConstants.USER_TYPE_CITY_ADMIN);
        MbnMerchantVip vCityMerchant =
            MbnMerchantVipIService.loadVirtualProvinceMerchant(
                portalUser.getCity(), ApSmsConstants.MERCHANT_CITY_VIRTUAL_TYPE);
        // 判断地市虚拟企业是否存在,不存在增加
        if (vCityMerchant == null) {
          MbnMerchantVip merchant = new MbnMerchantVip();
          merchantPin = PinGen.getMerchantPin();
          merchant.setProvince(portalUser.getProvince());
          merchant.setCity(portalUser.getCity());
          merchant.setMerchantPin(merchantPin);
          merchant.setName("V_C_" + portalUser.getCity());
          merchant.setGroupCode(String.valueOf(merchantPin));
          merchant.setPlatform(ApSmsConstants.MERCHANT_CITY_VIRTUAL_TYPE);
          merchant.setCreateTime(new Date());
          boolean result = MbnMerchantVipIService.insertMerchant(merchant);
          logger.info(
              "Province ["
                  + portalUser.getProvince()
                  + "] City ["
                  + portalUser.getCity()
                  + "] "
                  + "add virtual merchant ["
                  + merchantPin
                  + "] result:"
                  + result);
        } else {
          merchantPin = vCityMerchant.getMerchantPin();
        }
      } else if (userType == ApSmsConstants.USER_TYPE_CITY_ADMIN) {
        // 市管理员创建企业管理员
        portalUser.setUserType(ApSmsConstants.USER_TYPE_ENTERPRISE_ADMIN);
        merchantPin = portalUser.getMerchantPin();
      } else if (userType == ApSmsConstants.USER_TYPE_ENTERPRISE_ADMIN) {
        // 企业管理员创建企业用户
        portalUser.setUserType(ApSmsConstants.USER_TYPE_ENTERPRISE_NORMAL);
      } else {
        // 默认企业用户
        portalUser.setUserType(ApSmsConstants.USER_TYPE_ENTERPRISE_NORMAL);
      }
      portalUser.setCreateBy(users.getId());
      // 设定是否为托管mas处理方式
      if (WebUtils.isHostMas()) {
        // 20130427 为用户随机生成zxtUserId
        String zxtUserId = getZxtUserId();
        portalUser.setZxtUserId(zxtUserId);
        portalUser.setMerchantPin(merchantPin);
      }
      Users existUser = userService.validateUser(portalUser);
      if (existUser != null) {
        entityMap.put("flag", "用户账号已存在,请重新填写");
        return SUCCESS;
      }
      // add wangyu
      portalUser.setMerchantPin(merchantPin);
      // 地市管理员创建用户分配角色硬编码
      Set<RoleVO> rSet = new HashSet<RoleVO>();
      if (userType == ApSmsConstants.USER_TYPE_CITY_ADMIN) {
        RoleVO roleVO = new RoleVO();
        roleVO.setId(ApSmsConstants.UNION_CORP_ADMIN_ROLEID);
        roleVO.setCreateBy(users.getId());
        rSet.add(roleVO);
      } else {
        String[] roles = multiUserRoles.split(", ");
        RoleVO roleVO = null;
        for (String _role : roles) {
          roleVO = new RoleVO();
          roleVO.setId(Long.parseLong(_role));
          roleVO.setCreateBy(users.getId());
          rSet.add(roleVO);
        }
      }
      portalUser.setRoles(rSet);
      // 添加解锁~加锁
      isLockFlag(portalUser);
      portalUser.setFirstLoginFlag(0);
      if (!org.apache.commons.lang3.StringUtils.isBlank(
          WebUtils.getPropertyByName(com.leadtone.mas.admin.common.ApSmsConstants.TUNNELALL))) {
        String tunnelAll =
            WebUtils.getPropertyByName(com.leadtone.mas.admin.common.ApSmsConstants.TUNNELALL);
        if ("true".equalsIgnoreCase(tunnelAll)) {
          Integer corpId = MbnMerchantVipIService.getCorpZXTId(merchantPin);
          int userId =
              ZXTUserTool.addUser(
                  portalUser.getAccount(),
                  portalUser.getPassword(),
                  corpId.toString(),
                  portalUser.getZxtUserId());
          portalUser.setZxtId(userId);
          portalUser.setZxtLoginAcount(portalUser.getAccount());
          portalUser.setZxtPwd(portalUser.getPassword());
        }
      }
      portalUser.setId(PinGen.getSerialPin());
      if (StringUtil.isEmpty(portalUser.getZxtUserId())) {
        // TODO
        portalUser.setZxtUserId(portalUser.getId().toString());
      }
      userService.addUser(portalUser);
      // 增加扩展信息
      portalUserExt.setId(portalUser.getId());
      portalUserExtService.save(portalUserExt);

      // 地市管理员创建企业管理员,需要同步至业务节点 20130926
      if (userType == ApSmsConstants.USER_TYPE_CITY_ADMIN) {
        try {
          addUserToNode(portalUser, portalUserExt);
        } catch (Exception e) {
          logger.error("Add user to node faile", e);
        }
      }

      entityMap.put("flag", SUCCESS);
      logger.info("add user success");
    } catch (Exception exception) {
      entityMap = new HashMap<String, Object>();
      entityMap.put("flag", ERROR);
      logger.error("add user error: ", exception);
      return ERROR;
    }
    return SUCCESS;
  }