/** * 根据ID查询下一条,上一条短信详细 * * @return */ @Action( value = "followPage", results = { @Result(name = SUCCESS, location = "/sms/smssend/jsp/hadsend_content.jsp"), @Result(name = ERROR, location = "/error.jsp") }) public String followPage() { if (!StringUtil.isEmpty(selectedId) && pageDirect != null) { entityMap = new HashMap<String, Object>(); try { HashMap<String, Object> followPage = new HashMap<String, Object>(); if (pageDirect == 0) { followPage.put("frontPage", Long.valueOf(selectedId)); } else { followPage.put("nextPage", Long.valueOf(selectedId)); } MbnSmsOperationClass smsOperationClass = mbnSmsOperationClassService.findByCoding(operationId); followPage.put("operationId", smsOperationClass.getId()); if (!StringUtil.isEmpty(batchId)) { followPage.put("batchId", Long.valueOf(batchId)); } Users u = (Users) super.getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO); followPage.put("merchantPin", u.getMerchantPin()); List<MbnSmsHadSendVO> smsList = mbnSmsHadSendService.followPage(followPage); if (!smsList.isEmpty()) { mbnSmsHadSendVO = smsList.get(0); } else { mbnSmsHadSendVO = mbnSmsHadSendService.queryByPk(Long.valueOf(selectedId)); hasFollow = false; } // Long batchId, Long mPin, Long createBy // 设定只查询自己发送的信息 boolean isQuerySelf = false; Long createBy = null; if (!StringUtils.isBlank( WebUtils.getPropertyByName( com.leadtone.mas.admin.common.ApSmsConstants.QUERYSELFINFO))) { isQuerySelf = Boolean.valueOf( WebUtils.getPropertyByName( com.leadtone.mas.admin.common.ApSmsConstants.QUERYSELFINFO)); if (isQuerySelf && u.getUserType() == com.leadtone.mas.admin.common.ApSmsConstants.USER_TYPE_ENTERPRISE_NORMAL) { createBy = u.getId(); } } smsHadSendList = mbnSmsHadSendService.getByBatchId( mbnSmsHadSendVO.getBatchId(), u.getMerchantPin(), createBy); return SUCCESS; } catch (Exception e) { e.printStackTrace(); } } return ERROR; }
/** * 根据ID查询短信详细 * * @return */ @Action( value = "edit", results = { @Result(name = SUCCESS, location = "/sms/smssend/jsp/sms_write.jsp"), @Result(name = ERROR, location = "/error.jsp") }) public String edit() { String result = SUCCESS; if (!StringUtil.isEmpty(selectedId)) { try { mbnSmsHadSendVO = mbnSmsHadSendService.queryByPk(Long.parseLong(selectedId)); this.getRequest() .setAttribute( "smsText", StringEscapeUtils.escapeJavaScript(mbnSmsHadSendVO.getContent())); this.getRequest().setAttribute("title", mbnSmsHadSendVO.getTitle()); Users loginUser = (Users) super.getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO); List<SmsMbnTunnelVO> tunnelList = getTunnelList(loginUser.getMerchantPin()); this.getRequest().setAttribute("tunnelList", tunnelList); } catch (Exception e) { e.printStackTrace(); result = ERROR; } } return result; }
/** * Ajax 验证用户是否存在,页面右侧通讯录的查询用户 * * @throws Exception */ @Action( value = "queryUserExist", results = { @Result( type = "json", params = {"root", "entityMap", "contentType", "text/html"}) }) public String queryUserExist() { try { logger.info("queryUserExist: flag->" + flag); if ("add".equals(flag)) { /*PAN-Z-G 添加当前登录的商户pin码,用于唯一性用户验证*/ long merchantPin = users.getMerchantPin(); // 新增页面验证用户 // 设定是否为托管mas处理方式 if (WebUtils.isHostMas()) { portalUser.setMerchantPin(merchantPin); } Users users = userService.validateUser(portalUser); // cnt >0表示此用户已经存在,否则不存在 if (users != null) { entityMap.put("flag", 1); } else { entityMap.put("flag", 0); } // 新增页面验证用户是否存在 logger.info("queryUser: "******"query".equals(flag)) { // 新增页面右侧搜索框 portalUser.setMerchantPin(users.getMerchantPin()); List<UserVO> uList = userService.queryUserLikeAccount(portalUser); List<UserVO> tList = new ArrayList<UserVO>(); for (int i = 0, len = uList.size(); i < len; i++) { UserVO userVO = uList.get(i); userVO.setPassword( new MasPasswordTool().getDesString(userVO.getPassword(), userVO.getAccount())); tList.add(userVO); } entityMap.put("users", tList); logger.info("query from add right address: " + entityMap); } } catch (Exception e) { logger.error("validate user erorr: " + e); } return SUCCESS; }
/** * @param page,rows,... * @description 提供查询分页/模糊查询分页 * @return entityMap * @type Json */ @Action( value = "listBatchSendResult", results = { @Result( type = "json", params = {"root", "entityMap", "contentType", "text/html"}) }) public String listBatchSendResult() { if (!StringUtil.isEmpty(batchId)) { PageUtil pageUtil = new PageUtil(); pageUtil.setStart(page); pageUtil.setPageSize(rows); pageUtil.setBatchId(Long.valueOf(batchId)); try { Users u = (Users) super.getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO); pageUtil.setMerchantPin(u.getMerchantPin()); if (!StringUtil.isEmpty(searchBycontacts)) { pageUtil.setContactName(URLDecoder.decode(searchBycontacts, "UTF-8")); } if (!StringUtil.isEmpty(sendResult) && !sendResult.equals("4")) { pageUtil.setSendResult(Integer.valueOf(sendResult)); } Page page = mbnSmsHadSendService.batchPage(pageUtil); if (page != null) { @SuppressWarnings("unchecked") List<MbnSmsHadSend> datas = (List<MbnSmsHadSend>) page.getData(); entityMap = new HashMap<String, Object>(); entityMap.put("total", page.getRecords()); if (datas == null) { datas = new ArrayList<MbnSmsHadSend>(); } entityMap.put("rows", datas); entityMap.put("totalrecords", page.getTotal()); entityMap.put("currpage", page.getStart()); } } catch (Exception e) { e.printStackTrace(); return ERROR; } } return SUCCESS; }
/** * 收藏收件箱短信,置标志 为 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; }
/** * 根据ID查询短信详细 * * @return */ @Action( value = "getSmsDetails", results = { @Result(name = SUCCESS, location = "/sms/smssend/jsp/hadsend_content.jsp"), @Result(name = ERROR, location = "/error.jsp") }) public String getSmsDetails() { String result = SUCCESS; if (!StringUtil.isEmpty(selectedId)) { try { mbnSmsHadSendVO = mbnSmsHadSendService.queryByPk(Long.parseLong(selectedId)); Users u = (Users) super.getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO); // Long batchId, Long mPin, Long createBy // 设定只查询自己发送的信息 boolean isQuerySelf = false; Long createBy = null; if (!StringUtils.isBlank( WebUtils.getPropertyByName( com.leadtone.mas.admin.common.ApSmsConstants.QUERYSELFINFO))) { isQuerySelf = Boolean.valueOf( WebUtils.getPropertyByName( com.leadtone.mas.admin.common.ApSmsConstants.QUERYSELFINFO)); if (isQuerySelf && u.getUserType() == com.leadtone.mas.admin.common.ApSmsConstants.USER_TYPE_ENTERPRISE_NORMAL) { createBy = u.getId(); } } smsHadSendList = mbnSmsHadSendService.getByBatchId( mbnSmsHadSendVO.getBatchId(), u.getMerchantPin(), createBy); } catch (Exception e) { e.printStackTrace(); result = ERROR; } } return result; }
/** * 导出已发箱结果 * * @return */ @Action( value = "exportResult", results = { @Result( type = "json", params = {"root", "entityMap", "contentType", "text/html"}) }) public String exportResult() { try { PageUtil pageUtil = new PageUtil(); pageUtil.setColumn3("export"); // 用于判断,sql是否分页 pageUtil.setBatchId(Long.valueOf(batchId)); Users u = (Users) super.getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO); pageUtil.setMerchantPin(u.getMerchantPin()); if (!StringUtil.isEmpty(searchBycontacts)) { pageUtil.setContactName(URLDecoder.decode(searchBycontacts, "UTF-8")); } if (!StringUtil.isEmpty(sendResult) && !sendResult.equals("4")) { pageUtil.setSendResult(Integer.valueOf(sendResult)); } Page page = mbnSmsHadSendService.batchPage(pageUtil); if (page != null) { @SuppressWarnings("unchecked") List<MbnSmsHadSend> datas = (List<MbnSmsHadSend>) page.getData(); entityMap = new HashMap<String, Object>(); if (datas == null) { datas = new ArrayList<MbnSmsHadSend>(); } int size = datas.size(); String[][] billsInArr = new String[size][4]; for (int j = 0; j < size; j++) { MbnSmsHadSend mbnSmsHadSend = datas.get(j); int status = mbnSmsHadSend.getSendResult(); String smsStatus = ""; switch (status) { case -1: smsStatus = "取消发送"; break; case 0: smsStatus = "未发送"; break; case 1: smsStatus = "已提交网关"; break; case 2: smsStatus = "成功"; break; case 3: smsStatus = "失败"; break; default: smsStatus = "无"; break; } billsInArr[j][0] = mbnSmsHadSend.getTos(); // 手机号码 billsInArr[j][1] = (mbnSmsHadSend.getTosName() == null || mbnSmsHadSend.getTosName() == "" ? "(未知)" : mbnSmsHadSend.getTosName()); // 接收人姓名 billsInArr[j][2] = smsStatus; // 状态 -1取消发送,0未发送,1已提交网关,2成功,3失败 billsInArr[j][3] = (mbnSmsHadSend.getFailReason() == null || mbnSmsHadSend.getFailReason() == "" ? "(无)" : mbnSmsHadSend.getFailReason()); // 失败原因 } String[] cols = {"手机号码", "接收人姓名", "发送结果", "失败原因"}; String downLoadPath = ExportUtil.exportToExcel(getRequest(), "SMS_HADSEND_RESULT", cols, billsInArr); entityMap.put("fileName", downLoadPath); entityMap.put("message", "导出" + size + "条已发箱发送结果记录成功!"); entityMap.put("resultcode", SUCCESS); } } catch (Exception e) { entityMap = new HashMap<String, Object>(); entityMap.put("resultcode", ERROR); entityMap.put("message", "导出已发箱发送结果出错,请稍后再试"); e.printStackTrace(); return ERROR; } return SUCCESS; }
/** * 导出列表 * * @return */ @Action( value = "export", results = { @Result( type = "json", params = {"root", "entityMap", "contentType", "text/html"}) }) public String export() { PageUtil pageUtil = new PageUtil(); pageUtil.setColumn3("export"); // 用于判断,sql是否分页 try { MbnSmsOperationClass smsOperationClass = mbnSmsOperationClassService.findByCoding(operationId); pageUtil.setOperationId(smsOperationClass.getId()); Users u = (Users) super.getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO); pageUtil.setMerchantPin(u.getMerchantPin()); // 设定只查询自己发送的信息 boolean isQuerySelf = false; if (!StringUtils.isBlank( WebUtils.getPropertyByName(com.leadtone.mas.admin.common.ApSmsConstants.QUERYSELFINFO))) { isQuerySelf = Boolean.valueOf( WebUtils.getPropertyByName( com.leadtone.mas.admin.common.ApSmsConstants.QUERYSELFINFO)); if (isQuerySelf && u.getUserType() == com.leadtone.mas.admin.common.ApSmsConstants.USER_TYPE_ENTERPRISE_NORMAL) { pageUtil.setCreateBy(u.getId()); } } if (!StringUtil.isEmpty(searchBycontacts)) { pageUtil.setContactName(URLDecoder.decode(searchBycontacts, "UTF-8")); } if (!StringUtil.isEmpty(searchBySmsTitle)) { pageUtil.setSmsTitle(URLDecoder.decode(searchBySmsTitle, "UTF-8")); } if (!StringUtil.isEmpty(searchAct)) { Timestamp endDate = new Timestamp(System.currentTimeMillis()); switch (Integer.valueOf(searchAct)) { case 1: // all break; case 2: // 一天内 pageUtil.setEndDate(endDate); Date startDateDay = DateUtil.oneDayAgo(endDate); pageUtil.setStartDate(startDateDay); break; case 3: // 一周内 7天 pageUtil.setEndDate(endDate); Date startDateWeek = DateUtil.oneWeekAgo(endDate); pageUtil.setStartDate(startDateWeek); break; case 4: // 一月内 30天 pageUtil.setEndDate(endDate); Date startDateMonth = DateUtil.oneMonthAgo(endDate); pageUtil.setStartDate(startDateMonth); break; case 5: // 时间区间dateFrom SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); if (!StringUtil.isEmpty(dateTo)) { pageUtil.setEndDate(format.parse(dateTo)); } if (!StringUtil.isEmpty(dateFrom)) { pageUtil.setStartDate(format.parse(dateFrom)); } break; } } Page page = mbnSmsHadSendService.extPortAll(pageUtil); if (page != null) { @SuppressWarnings("unchecked") List<MbnSmsHadSendVO> datas = (List<MbnSmsHadSendVO>) page.getData(); entityMap = new HashMap<String, Object>(); if (datas == null) { datas = new ArrayList<MbnSmsHadSendVO>(); } String tunnelName = ""; int size = datas.size(); String[][] billsInArr = new String[size][7]; for (int j = 0; j < size; j++) { MbnSmsHadSendVO mbnSmsHadSendVO = datas.get(j); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); switch (mbnSmsHadSendVO.getTunnelType()) { case 1: tunnelName = "话机"; break; case 3: tunnelName = "猫池"; break; case 2: tunnelName = "移动"; break; case 4: tunnelName = "联通"; break; case 6: tunnelName = "电信"; break; default: tunnelName = "无"; } String smsStatus = ""; switch (mbnSmsHadSendVO.getSendResult()) { case -1: smsStatus = "取消发送"; break; case 0: smsStatus = "未发送"; break; case 1: smsStatus = "已提交网关"; break; case 2: smsStatus = "成功"; break; case 3: smsStatus = "失败"; break; default: smsStatus = "无"; break; } billsInArr[j][0] = mbnSmsHadSendVO.getTosName(); // 用户名称 billsInArr[j][1] = mbnSmsHadSendVO.getTos(); // 手机号码 billsInArr[j][2] = mbnSmsHadSendVO.getTitle(); // 短信标题 billsInArr[j][3] = mbnSmsHadSendVO.getContent(); // 短信内容 billsInArr[j][4] = smsStatus; billsInArr[j][5] = (null == mbnSmsHadSendVO.getReadySendTime() ? "" : sdf.format(mbnSmsHadSendVO.getReadySendTime())); // 发送时间 billsInArr[j][6] = tunnelName; // billsInArr[j][3] = ""+mbnSmsHadSendVO.getContent().length(); //短信长度 // billsInArr[j][5] = ""+mbnSmsHadSendVO.getReplyCount(); // 回复 } String[] cols = {"用户名称", "用户手机号码", "短信标题", "短信内容", "发送状态", "发送时间", "发送通道名称"}; String downLoadPath = ExportUtil.exportToExcel(getRequest(), "SMS_HADSEND", cols, billsInArr); entityMap.put("fileName", downLoadPath); entityMap.put("message", "导出" + size + "条已发箱记录成功!"); entityMap.put("resultcode", SUCCESS); } } catch (Exception e) { entityMap = new HashMap<String, Object>(); entityMap.put("resultcode", ERROR); entityMap.put("message", "导出已发箱出错,请稍后再试"); e.printStackTrace(); return ERROR; } return SUCCESS; }
/** * @param page,rows,... * @description 提供查询分页/模糊查询分页 * @return entityMap * @type Json */ @Action( value = "listHadSendSms", results = { @Result( type = "json", params = {"root", "entityMap", "contentType", "text/html"}) }) public String listHadSendSms() { PageUtil pageUtil = new PageUtil(); pageUtil.setStart(page); pageUtil.setPageSize(rows); try { MbnSmsOperationClass smsOperationClass = mbnSmsOperationClassService.findByCoding(ApSmsConstants.SMS_OPERATION_CODE_HD); pageUtil.setOperationId(smsOperationClass.getId()); Users u = (Users) super.getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO); // 设定只查询自己发送的信息 boolean isQuerySelf = false; if (!StringUtils.isBlank( WebUtils.getPropertyByName(com.leadtone.mas.admin.common.ApSmsConstants.QUERYSELFINFO))) { isQuerySelf = Boolean.valueOf( WebUtils.getPropertyByName( com.leadtone.mas.admin.common.ApSmsConstants.QUERYSELFINFO)); if (isQuerySelf && u.getUserType() == com.leadtone.mas.admin.common.ApSmsConstants.USER_TYPE_ENTERPRISE_NORMAL) { pageUtil.setCreateBy(u.getId()); } } pageUtil.setMerchantPin(u.getMerchantPin()); if (!StringUtil.isEmpty(searchBycontacts)) { pageUtil.setContactName(URLDecoder.decode(searchBycontacts, "UTF-8")); } if (!StringUtil.isEmpty(searchBySmsTitle)) { pageUtil.setSmsTitle(URLDecoder.decode(searchBySmsTitle, "UTF-8")); } if (!StringUtil.isEmpty(searchAct)) { Timestamp endDate = new Timestamp(System.currentTimeMillis()); switch (Integer.valueOf(searchAct)) { case 1: // all break; case 2: // 一天内 pageUtil.setEndDate(endDate); Date startDateDay = DateUtil.oneDayAgo(endDate); pageUtil.setStartDate(startDateDay); break; case 3: // 一周内 7天 pageUtil.setEndDate(endDate); Date startDateWeek = DateUtil.oneWeekAgo(endDate); pageUtil.setStartDate(startDateWeek); break; case 4: // 一月内 30天 pageUtil.setEndDate(endDate); Date startDateMonth = DateUtil.oneMonthAgo(endDate); pageUtil.setStartDate(startDateMonth); break; case 5: // 时间区间dateFrom SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); if (!StringUtil.isEmpty(dateTo)) { pageUtil.setEndDate(format.parse(dateTo)); } if (!StringUtil.isEmpty(dateFrom)) { pageUtil.setStartDate(format.parse(dateFrom)); } break; } } Page page = mbnSmsHadSendService.pageVO(pageUtil); // List<GroupUtil> groupBy = smsStatusService.groupPage(pageUtil); if (page != null) { @SuppressWarnings("unchecked") List<MbnSmsHadSendVO> datas = (List<MbnSmsHadSendVO>) page.getData(); entityMap = new HashMap<String, Object>(); entityMap.put("total", page.getRecords()); if (datas == null) { datas = new ArrayList<MbnSmsHadSendVO>(); } entityMap.put("rows", datas); entityMap.put("totalrecords", page.getTotal()); entityMap.put("currpage", page.getStart()); } } catch (Exception e) { e.printStackTrace(); return ERROR; } return SUCCESS; }
@Action( value = "getBatchSms", results = { @Result(name = SUCCESS, location = "/sms/smssend/jsp/hadsend_result_details.jsp"), @Result(name = ERROR, location = "/error.jsp") }) public String getBatchSms() { if (!StringUtil.isEmpty(batchId)) { try { Users u = (Users) super.getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO); // Long batchId, Long mPin, Long createBy // 设定只查询自己发送的信息 boolean isQuerySelf = false; Long createBy = null; if (!StringUtils.isBlank( WebUtils.getPropertyByName( com.leadtone.mas.admin.common.ApSmsConstants.QUERYSELFINFO))) { isQuerySelf = Boolean.valueOf( WebUtils.getPropertyByName( com.leadtone.mas.admin.common.ApSmsConstants.QUERYSELFINFO)); if (isQuerySelf && u.getUserType() == com.leadtone.mas.admin.common.ApSmsConstants.USER_TYPE_ENTERPRISE_NORMAL) { createBy = u.getId(); } } smsHadSendList = mbnSmsHadSendService.getByBatchId(Long.valueOf(batchId), u.getMerchantPin(), createBy); if (!smsHadSendList.isEmpty()) { smsSendResult = new HashMap<String, Integer>(); smsSendResult.put("success", 0); smsSendResult.put("failure", 0); smsSendResult.put("sending", 0); smsSendResult.put("cancel", 0); smsSendResult.put("waiting", 0); smsSendResult.put("totails", smsHadSendList.size()); for (int i = 0; i < smsHadSendList.size(); i++) { MbnSmsHadSend temp = smsHadSendList.get(i); switch (temp.getSendResult()) { case -1: smsSendResult.put("cancel", smsSendResult.get("cancel") + 1); break; case 0: smsSendResult.put("waiting", smsSendResult.get("waiting") + 1); break; case 1: smsSendResult.put("sending", smsSendResult.get("sending") + 1); break; case 2: smsSendResult.put("success", smsSendResult.get("success") + 1); break; case 3: smsSendResult.put("failure", smsSendResult.get("failure") + 1); break; } } } } catch (Exception e) { e.printStackTrace(); } } return SUCCESS; }
/** * 查询用户信息<未完成的,分页列表> * * @return * @throws Exception */ @Action( value = "query", results = { @Result( type = "json", params = {"root", "entityMap", "contentType", "text/html"}) }) public String query() { try { PageUtil pageUtil = new PageUtil(); pageUtil.setStart(page); pageUtil.setPageSize(rows); pageUtil.setMerchantPin(users.getMerchantPin()); if (portalUser != null) { pageUtil.setAccount(portalUser.getAccount()); pageUtil.setMobile(portalUser.getMobile()); pageUtil.setEmail(portalUser.getEmail()); // Integer activeFlag = // portalUser.getActiveFlag()== -99 ? null : portalUser.getActiveFlag(); pageUtil.setActiveFlag(portalUser.getActiveFlag()); String roleId = request.getParameter("roleId"); if (roleId != null && !"-99".equals(roleId)) pageUtil.setRoleId(Long.parseLong(roleId)); } logger.info("role query portalUser:"******"role query pageUtil:" + pageUtil); // REX@20130112 判断登陆用户类型 if (users.getUserType() == ApSmsConstants.USER_TYPE_SUPER_ADMIN) { // 在省、地市 管理员的时候,不需要pin码 pageUtil.setMerchantPin(null); String[] provArray = null; List<Region> regionList = regionService.findProvinces(); if (regionList != null) { provArray = new String[regionList.size()]; for (int i = 0; i < regionList.size(); i++) { provArray[i] = String.valueOf(regionList.get(i).getId()); } } // 增加全省列表 pageUtil.setAreaRange(provArray); // 设置用户类型为省管理员 pageUtil.setUserType(users.getUserType()); } else if (users.getUserType() == ApSmsConstants.USER_TYPE_PROVINCE_ADMIN) { // 在省、地市 管理员的时候,不需要pin码 pageUtil.setMerchantPin(null); Long provinceId = 0L; provinceId = Long.parseLong(users.getProvince()); String[] cityArray = null; List<Region> regionList = regionService.findCityByProvinceId(provinceId); if (regionList != null) { cityArray = new String[regionList.size()]; for (int i = 0; i < regionList.size(); i++) { cityArray[i] = String.valueOf(regionList.get(i).getId()); } } // 增加地区列表 pageUtil.setAreaRange(cityArray); // 设置用户类型为地市管理员 pageUtil.setUserType(users.getUserType()); } else if (users.getUserType() == ApSmsConstants.USER_TYPE_CITY_ADMIN) { pageUtil.setMerchantPin(null); // 增加地区列表 pageUtil.setAreaRange(new String[] {users.getCity()}); // 设置用户类型为企业管理员 pageUtil.setUserType(users.getUserType()); } else if (users.getUserType() == ApSmsConstants.USER_TYPE_ENTERPRISE_ADMIN) { // 设置用户类型为企业管理员 pageUtil.setUserType(users.getUserType()); } else { pageUtil.setUserType(users.getUserType()); } Page page = userService.page(pageUtil); if (page != null) { @SuppressWarnings("unchecked") List<UserVO> datas = (List<UserVO>) page.getData(); entityMap = new HashMap<String, Object>(); entityMap.put("total", page.getRecords()); if (datas == null) { datas = new ArrayList<UserVO>(); } entityMap.put("rows", datas); entityMap.put("totalrecords", page.getTotal()); entityMap.put("currpage", page.getStart()); } logger.info("query user page: " + entityMap); } catch (Exception e) { e.printStackTrace(); return ERROR; } return SUCCESS; }
/** * 新增用户 * * @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; }
/** * 初始化新增页面 * * @return */ @Action( value = "forward", results = { @Result(name = "forward", location = "/ap/user/useradd.jsp"), @Result(name = ERROR, location = "/error.jsp"), @Result(name = INPUT, location = "/ap/user/useradd.jsp") }) public String forward() { try { List<Role> roleList = userService.getRolesByMerchantPin(users.getMerchantPin()); // 初次进入新增页面,得初始化角色 request.setAttribute("rolesList", roleList); // REX@20130111 判断管理员类型 0:超级管理员 1:省系统管理员;2:地市管理员3、企业超级管理员4、企业用户 // 0返回省列表 // 1返回省代码,地市列表 // 2,3,4 返回省代码、地市代码 int userType = users.getUserType(); if (userType == ApSmsConstants.USER_TYPE_SUPER_ADMIN) { List<Region> list = regionService.findProvinces(); request.setAttribute("regionList", list); } else if (userType == ApSmsConstants.USER_TYPE_PROVINCE_ADMIN) { Long prov = Long.parseLong(users.getProvince()); List<Region> list = regionService.findCityByProvinceId(prov); request.setAttribute("regionList", list); request.setAttribute("province", users.getProvince()); } else if (userType == ApSmsConstants.USER_TYPE_CITY_ADMIN) { // 地市管理员。列出企业。 Long prov = Long.parseLong(users.getProvince()); List<MbnMerchantVip> list = MbnMerchantVipIService.loadByProvinceAndCity(users.getProvince(), users.getCity()); request.setAttribute("merchantList", list); request.setAttribute("province", users.getProvince()); request.setAttribute("city", users.getCity()); // }else if(userType == ApSmsConstants.USER_TYPE_ENTERPRISE_ADMIN){ // request.setAttribute("entAdmin", true); // request.setAttribute("province", users.getProvince()); // request.setAttribute("city", users.getCity()); } else { MbnConfigMerchant mbnConfigMerchant = mbnConfigMerchantIService.loadByMerchantPin(users.getMerchantPin(), "corp_login_port"); if (mbnConfigMerchant != null) { request.setAttribute("corpLoginPort", mbnConfigMerchant.getItemValue()); } request.setAttribute("province", users.getProvince()); request.setAttribute("city", users.getCity()); } logger.debug(" inser into useradd.jsp before -->flag: " + flag); if ("addForward".equals(flag)) { return "forward"; } else if ("updateForward".equals(flag)) { request.setAttribute("allList", userService.getAllRoles()); // 修改用户之前的初始化新增页面角色,查询要修改的用户信息 List<UserVO> uList = userService.queryUserLikeAccount(portalUser); logger.info("query updateForward user: "******"corp_login_port"); if (mbnConfigMerchant != null) { request.setAttribute("corpLoginPort", mbnConfigMerchant.getItemValue()); } } userVO.setPassword( new MasPasswordTool().getDesString(userVO.getPassword(), userVO.getAccount())); // 从全部角色里去掉此用户已经有的角色 List<Role> delList = new ArrayList<Role>(); // List<Long> longs = userVO.getRoles(); Set<Role> userRoles = userVO.getRole(); // logger.info("------userRoles-"+ userRoles); // 从所有的用户里删除此角色拥有的用户,待选 用户里显示 for (Iterator<Role> uIterator = userRoles.iterator(); uIterator.hasNext(); ) { Role _roleUser = uIterator.next(); // logger.debug("; roleUsers: "+ _roleUser.getId()+";"); for (Role _role : roleList) { if (_roleUser.getId().equals(_role.getId())) { // logger.debug("into le."); delList.add(_role); } } } roleList.removeAll(delList); // 增加扩展信息 PortalUserExtBean bean = portalUserExtService.getByPk(userVO.getId()); Users temp = userService.queryByUserId(userVO.getId()); userVO.setWebService(temp.getWebService()); request.setAttribute("portalUserExt", bean); // 初次进入新增页面,得初始化角色 request.setAttribute("rolesList", roleList); request.setAttribute("userVO", userVO); return "forward"; } } catch (Exception e) { logger.error("", e); return ERROR; } return SUCCESS; }