public void query() throws ServletException, IOException { HttpServletRequest request = Struts2Utils.getRequest(); List<TbBaseUserInfo> list = null; List<PropertyFilter> filters = HibernateWebUtils.buildPropertyFilters(Struts2Utils.getRequest()); GridServerHandler gridServerHandler = new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse()); // 角色查询 String vcRoleNo = request.getParameter("role_search"); if (vcRoleNo != null && !vcRoleNo.equals("")) { String vcUserNos = baseUserInfoManager.getUserIdByRoleId(vcRoleNo); String[] vun = vcUserNos.split(","); filters.add(new PropertyFilter("id", vun, MatchType.IN)); } page.setOrderBy("id"); page.setOrder("desc"); page.setPageSize(gridServerHandler.getPageSize()); page.setPageNo(gridServerHandler.getPageInfo().getPageNum()); page = baseUserInfoManager.search(page, filters); int totalRowNum = gridServerHandler.getTotalRowNum(); if (totalRowNum < 1) { totalRowNum = page.getTotalCount(); gridServerHandler.setTotalRowNum(totalRowNum); } list = page.getResult(); gridServerHandler.setData(this.formatViewData(list)); Struts2Utils.renderJson(gridServerHandler.getLoadResponseText()); }
public void queryKey() throws ServletException, IOException { GridServerHandler gridServerHandler = new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse()); SortInfo si = gridServerHandler.getSingleSortInfo(); if (si != null) { String order = si.getSortOrder(); if ("defaultsort".equals(order)) { page.setOrder("desc"); page.setOrderBy("fullDate"); } else { page.setOrder(order); page.setOrderBy(MantoEyeUtils.getSortField(si.getFieldName())); } // 默认排序方式 } else { page.setOrderBy("fullDate"); page.setOrder("desc"); } page.setPageSize(gridServerHandler.getPageSize()); page.setPageNo(gridServerHandler.getPageInfo().getPageNum()); page = keywordsTacticsImpl.queryKey(page, id, startTime, endTime); int totalRowNum = gridServerHandler.getTotalRowNum(); if (totalRowNum < 1) { totalRowNum = page.getTotalCount(); gridServerHandler.setTotalRowNum(totalRowNum); } gridServerHandler.setData(page.getResult(), KeywordsDetail.class); Struts2Utils.renderJson(gridServerHandler.getLoadResponseText()); }
/** 数据导出 */ public void export() throws ServletException, IOException { logger.info("businessName:" + businessName); logger.info("businessName:" + Common.convertToUTF8(businessName)); List<CommonFlush> list = spaceDistributeBusinessManager.listData( Common.StringToInt(dataType_search), Integer.parseInt(spaceLevel_search), Common.convertToUTF8(businessName), Integer.parseInt(timeLevel_search), time_search); GridServerHandler gridServerHandler = new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse()); String exportmsg = ExportMsg.EXPORT_FLUSH_BUSINESS_SPACE + Common.getTimeLevelCH(timeLevel_search) + "(" + Common.convertToUTF8(businessName) + "|" + time_search + ")"; commonManagerImpl.log(Struts2Utils.getRequest(), exportmsg); gridServerHandler.exportXLS(list, CommonFlush.class); }
/** * 判断该任务是否存在 * * @throws IOException */ public String checkUnique() throws IOException { HttpServletRequest request = ServletActionContext.getRequest(); String vcTaskName = request.getParameter("vcTaskName").trim(); int i = keywordsTacticsImpl.isVcTaskName(vcTaskName); if (i == -1) { // -1表示不存在该任务名称 Struts2Utils.renderText("true"); } else { Struts2Utils.renderText("false"); } return null; }
/** 支持使用Jquery.validate Ajax检验用户名是否重复. */ public String checkUnique() { HttpServletRequest request = Struts2Utils.getRequest(); String loginName = request.getParameter("entity.vcLoginName"); String oldLoginName = request.getParameter("oldLoginName"); if (baseUserInfoManager.isPropertyUnique("vcLoginName", loginName, oldLoginName)) { Struts2Utils.renderText("true"); } else { Struts2Utils.renderText("false"); } return null; }
/** 数据导出 */ public void exportKey() throws ServletException, IOException { List<KeywordsDetail> list = keywordsTacticsImpl.listData(id, startTime, endTime); GridServerHandler gridServerHandler = new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse()); String exportmsg = "策略结果列表(" + startTime + "~" + endTime + ")"; // commonManagerImpl.log(this.getServletRequest(), exportmsg); if (list != null && list.size() > 0) { gridServerHandler.exportCSV(list, KeywordsDetail.class); } }
/** 导出 */ public void export() throws ServletException, IOException { if (this.searchdate == null) { this.searchdate = CommonUtils.getSYestoday(); } List<TopStat> list = null; GridServerHandler gridServerHandler = new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse()); list = topFlushAndImsiManager.findTopStatImsi(raittype, stattype, searchdate); String exportmsg = ExportMsg.EXPORT_FLUSH_TOPUSER + "(" + searchdate + ")"; commonManagerImpl.log(Struts2Utils.getRequest(), exportmsg); gridServerHandler.exportXLS(list, TopStat.class); }
/** 查询策略任务表 */ public void query() { GridServerHandler gridServerHandler = new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse()); List<KeywordsTacticsDTO> list = keywordsTacticsImpl.queryTacticsList(); List<JSONObject> jsonList = new ArrayList<JSONObject>(); for (KeywordsTacticsDTO dto : list) { jsonList.add(JSONObject.fromObject(dto)); } // JSONArray jArray = JSONArray.fromObject(list); gridServerHandler.setData(jsonList); Struts2Utils.renderJson(gridServerHandler.getLoadResponseJSON().toString()); }
/** 查询详细信息 */ public void showDialect() { HttpServletRequest request = ServletActionContext.getRequest(); GridServerHandler gridServerHandler = new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse()); String nmDataGetterTaskId = ReqUtils.getReqString(request, "id"); List<DialectKeywordsDTO> list = keywordsTacticsImpl.showDialect(nmDataGetterTaskId); List<JSONObject> jsonList = new ArrayList<JSONObject>(); for (DialectKeywordsDTO dto : list) { jsonList.add(JSONObject.fromObject(dto)); } gridServerHandler.setData(jsonList); Struts2Utils.renderJson(gridServerHandler.getLoadResponseJSON().toString()); }
/** 保存用户信息 */ public String save() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String msg = ""; String usemd5 = PropertiesUtil.getInstance().getProperty("system.password.save.encry"); // 数据库保存密码是否需要md5加密 String newpw = entity.getVcPassword(); if (usemd5 != null && usemd5.equalsIgnoreCase("MD5")) { newpw = Utils.getMD5String(entity.getVcPassword()); } try { entity.setVcPassword(newpw); baseUserInfoManager.save(entity); request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00101); msg = "添加用户信息[登录名:" + entity.getVcLoginName() + "]成功!"; return SUCCESS; } catch (Exception e) { logger.error(e.getMessage()); request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00004); msg = "添加用户信息[登录名:" + entity.getVcLoginName() + "]失败!"; return ERROR; } finally { commonManagerImpl.log(request, msg); } }
/** 获取图形数据 */ public void getAjaxChartXmlData() throws Exception { // int pageSize = 20; /* * 图表不包含‘其他’的数据,因此为了去除其他,必须多查一条数据 */ int pageSize = 21; String totalXml = this.packTotalData( dataType_search, spaceLevel_search, businessName, timeLevel_search, time_search, pageSize); String imsisXml = this.packImsisData( dataType_search, spaceLevel_search, businessName, timeLevel_search, time_search, pageSize); String countXml = this.packCountData( dataType_search, spaceLevel_search, businessName, timeLevel_search, time_search, pageSize); Struts2Utils.renderText(totalXml + "&&&" + imsisXml + "&&&" + countXml); }
/** 获取角色对应菜单ID */ public void getAjaxRoleMenuIds() throws Exception { String menuIds = ""; HttpServletRequest request = ServletActionContext.getRequest(); String roleId = request.getParameter("role_id"); List list = basePermissionsManager.getAllPermis(false); List permisList = baseRoleManager.getRolePermis(roleId); if (list != null && !list.isEmpty()) { for (Iterator it = list.iterator(); it.hasNext(); ) { VBasePermissions basePermisView = (VBasePermissions) it.next(); String permis_id = basePermisView.getId(); // 循环得到角色标识对应菜单 if (permisList != null && !permisList.isEmpty()) { for (Iterator it2 = permisList.iterator(); it2.hasNext(); ) { TbBaseRolePermis tbBaseRolePermis = (TbBaseRolePermis) it2.next(); if (permis_id.equals(tbBaseRolePermis.getVcPermId())) { menuIds = menuIds + permis_id + ":"; } } } } } if (!"".equals(menuIds)) { menuIds = menuIds.substring(0, menuIds.lastIndexOf(":")); } Struts2Utils.renderText(menuIds); }
/** 核查旧密码合法性 */ public String checkPwd() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String oldPwd = request.getParameter("oldPwd"); LoginListener loginListener = (LoginListener) ServletActionContext.getRequest() .getSession() .getAttribute(VarConstants.LOGIN_LISTENER_KEY); String userid = loginListener.getSessionContainer().getUserInfo().getId(); TbBaseUserInfo userInfo = baseUserInfoManager.get(userid); if (Utils.getMD5String(oldPwd).equals(userInfo.getVcPassword())) { Struts2Utils.renderText("true"); } else { Struts2Utils.renderText("false"); } return null; }
/** 查询数据 */ public void query() throws ServletException, IOException { HttpServletRequest request = Struts2Utils.getRequest(); List<TopStat> list = null; if (this.searchdate == null) { this.searchdate = CommonUtils.getSYestoday(); } logger.info("stattype:" + stattype + "--searchdate:" + searchdate + "--raittype:" + raittype); GridServerHandler gridServerHandler = new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse()); try { list = topFlushAndImsiManager.findTopStatImsi(raittype, stattype, searchdate); } catch (Exception e) { logger.error(e.getMessage()); } gridServerHandler.setData(list, TopStat.class); Struts2Utils.renderJson(gridServerHandler.getLoadResponseText()); }
/** 停止策略 */ public void stopTactics() throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); String msg = ""; ServletActionContext.getResponse().setCharacterEncoding("UTF-8"); ServletActionContext.getRequest().setCharacterEncoding("UTF-8"); int nmDataGetterTaskId = ReqUtils.getReqInt(request, "ids"); keywordsTacticsImpl.stopTatctics(nmDataGetterTaskId); msg = "停止策略成功!"; Struts2Utils.renderText(msg); }
/** 查询数据 */ public void query() throws ServletException, IOException { List<CommonFlush> list = null; GridServerHandler gridServerHandler = new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse()); SortInfo si = gridServerHandler.getSingleSortInfo(); if (si != null) { String order = si.getSortOrder(); if ("defaultsort".equals(order)) { page.setOrder("desc"); page.setOrderBy("nmFlush"); } else { page.setOrder(order); page.setOrderBy(MantoEyeUtils.getSortField(si.getFieldName())); } // 默认排序方式 } else { page.setOrderBy("nmFlush"); page.setOrder("desc"); } page.setPageSize(gridServerHandler.getPageSize()); page.setPageNo(gridServerHandler.getPageInfo().getPageNum()); page = spaceDistributeBusinessManager.query( page, Integer.parseInt(dataType_search), Common.StringToInt(spaceLevel_search), businessName, Integer.parseInt(timeLevel_search), time_search); int totalRowNum = gridServerHandler.getTotalRowNum(); if (totalRowNum < 1) { totalRowNum = page.getTotalCount(); gridServerHandler.setTotalRowNum(totalRowNum); } list = page.getResult(); gridServerHandler.setData(list, CommonFlush.class); Struts2Utils.renderJson(gridServerHandler.getLoadResponseText()); }
/** 方法需修改测试 */ public String doassociate() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String userIds = keys; String roleNo = request.getParameter("roleNo"); Long rolesId = roleId; boolean bo = baseUserInfoManager.inserMutilUserRoles(userIds, roleNo, request); if (bo) { addActionMessage(MsgConstants.SUCC_CODE_00028); return SUCCESS; } else { addActionMessage(MsgConstants.ERROR_CODE_00009); return ERROR; } }
/** 同步统一网管平台用户信息 */ public void getAllUnmpUserInfo() { String msg = ""; try { boolean b = unmpUserManager.getAllUnmpUserInfo(); if (b) { msg = "同步用户成功!"; } else { msg = "同步用户失败!"; } } catch (Exception e) { logger.error(e.getMessage()); msg = "同步用户失败!"; } Struts2Utils.renderText(msg); }
/** 删除用户 */ public void deleteUsers() throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); String ids = request.getParameter("ids"); String[] sids = ids.split(","); String msg = ""; try { // 删除成功 baseUserInfoManager.deleteByKeys(sids); msg = "删除用户成功!"; commonManagerImpl.log(request, "删除用户[主键:" + ids + "]成功!"); } catch (Exception e) { // 删除失败 msg = "删除用户成功\\!"; commonManagerImpl.log(request, "删除用户[主键:" + ids + "]失败!"); } Struts2Utils.renderText(msg); }
/** 列表显示页面 分页显示总行时有问题,分页还需要测试 */ public String list() throws Exception { HttpServletRequest request = Struts2Utils.getRequest(); rolesList = baseRoleManager.getAll(); // 获取所有角色 deptsList = baseDepartmentManager.getAll(); // 获取所有部门 request.setAttribute("rolesList", rolesList); request.setAttribute("deptsList", deptsList); // 设置角色标识,供页面保留查询条件使用 request.setAttribute("search_vcRoleNo", request.getParameter("vcRoleNo2")); // 设置部门标识,供页面保留查询条件使用 request.setAttribute("search_vcDeptNo", request.getParameter("filter_LIKE_vcDeptNo")); // 调用分页方法 this.setPaginationdataList(); logger.error("日志测试"); return INDEX; }
/** 保存用户信息 */ public String update() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String msg = ""; try { baseUserInfoManager.save(entity); msg = " 编辑用户信息[登录名:" + entity.getVcLoginName() + "]成功!"; request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00102); return SUCCESS; } catch (Exception e) { request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00004); msg = "编辑用户信息[登录名:" + entity.getVcLoginName() + "]失败!"; return ERROR; } finally { commonManagerImpl.log(request, msg); } }
/** 删除用户 */ public String delete() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String[] sids = keys.split(","); String msg = null; try { // 删除成功 baseUserInfoManager.deleteByKeys(sids); request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00008); request.setAttribute(VarConstants.URL, "/user_list.do?1=1"); msg = "删除用户信息[用户主键:" + keys + "]成功!"; commonManagerImpl.log(request, msg); return SUCCESS; } catch (Exception e) { // 删除失败 request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00005); msg = "删除用户信息[用户主键:" + keys + "]失败!"; commonManagerImpl.log(request, msg); return ERROR; } }
/** * 分页查询数据 * * @throws ServiceStartupException */ public void setPaginationdataList() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); List<PropertyFilter> filters = HibernateWebUtils.buildPropertyFilters(request); // 如果选择按角色查询条件,则设置角色的过滤 String vcRoleNo = request.getParameter("vcRoleNo2"); if (vcRoleNo != null && !vcRoleNo.equals("")) { String vcUserNos = baseUserInfoManager.getUserIdByRoleId(vcRoleNo); String[] vun = vcUserNos.split(","); filters.add(new PropertyFilter("id", vun, MatchType.IN)); } if (page.getOrderBy() == null) { page.setOrderBy("id"); } page = baseUserInfoManager.search(page, filters); List dataList = page.getVresult(); request.setAttribute("dataList", dataList); }
/** 更新密码 */ public String updatePwd() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String oldPwd = request.getParameter("oldPwd"); String newPwd = request.getParameter("newPwd"); String msg = ""; if (baseUserInfoManager.updatePwd(oldPwd, newPwd, request)) { request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00106); msg = "更新用户密码[新密码:" + newPwd + "]成功!"; commonManagerImpl.log(request, msg); return SUCCESS; } else { request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00008); request.setAttribute(VarConstants.URL, "/welcome.jsp.do?1=1"); msg = "更新用户密码[新密码:" + newPwd + "]失败!"; commonManagerImpl.log(request, msg); return ERROR; } }
/** 删除策略 */ public void deleteTactics() throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); String msg = ""; ServletActionContext.getResponse().setCharacterEncoding("UTF-8"); ServletActionContext.getRequest().setCharacterEncoding("UTF-8"); String nmDataGetterTaskId = ReqUtils.getReqString(request, "ids"); List dlist = keywordsTacticsImpl.findDataGetterFilterId(nmDataGetterTaskId); if (dlist != null && dlist.size() > 0) { String nmDataGetterFilterId = ""; for (int i = 0; i < dlist.size(); i++) { nmDataGetterFilterId = nmDataGetterFilterId + dlist.get(i).toString() + ","; } nmDataGetterFilterId = nmDataGetterFilterId.substring(0, nmDataGetterFilterId.length() - 1); keywordsTacticsImpl.deleteKeyValueSoTypeIdFilter(nmDataGetterFilterId); } keywordsTacticsImpl.deleteTactics(nmDataGetterTaskId); msg = "删除策略成功!"; Struts2Utils.renderText(msg); }
/** 重置密码 */ public String resetPwd() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String sids = Common.FormatString(keys, "0"); boolean updateBoolean = baseUserInfoManager.updatePwdReset(sids, request); String msg = ""; if (updateBoolean) { request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00003); request.setAttribute(VarConstants.URL, "/user_list.do?1=1"); msg = "重置用户密码[用户主键:" + keys + "]成功!"; commonManagerImpl.log(request, msg); return SUCCESS; } else { request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00007); request.setAttribute(VarConstants.URL, "/user_list.do?1=1"); msg = "重置用户密码[用户主键:" + keys + "]失败!"; commonManagerImpl.log(request, msg); return ERROR; } }
/** 插入用户权限 */ public String insertPermis() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String vcUserNo = request.getParameter("vcUserNo"); String vcRoleNo = request.getParameter("vcRoleNo"); String msg = ""; boolean bo = baseUserInfoManager.inserUserRoles(vcUserNo, vcRoleNo, request); if (bo) { request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00104); msg = "插入角色权限[权限关联字段:" + "vcUserNo:" + vcUserNo + " vcRoleNo:" + vcRoleNo + "]成功!"; commonManagerImpl.log(request, msg); return SUCCESS; } else { request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00009); request.setAttribute(VarConstants.URL, "/user_list.do?1=1"); msg = "插入角色权限[权限关联字段:" + "vcUserNo:" + vcUserNo + " vcRoleNo:" + vcRoleNo + "]失败!"; commonManagerImpl.log(request, msg); return ERROR; } }
/** 打开权限树 */ public String openPermis() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String newrole_id = request.getParameter("role_id"); List listdata = baseRoleManager.getAll(); TbBaseUserInfo userInfo = baseUserInfoManager.get(id); List rolesIdList = null; if (Common.judgeString(newrole_id)) { rolesIdList = new ArrayList(); rolesIdList.add(newrole_id); } else { // 根据用户标识获取角色标识集合 rolesIdList = baseUserInfoManager.getRoles(userInfo.getId()); } request.setAttribute("rolesIdList", rolesIdList); request.setAttribute("listdata", listdata); request.setAttribute("userId", id); request.setAttribute("vcUserNo", userInfo.getId()); request.setAttribute("userName", entity == null ? "" : entity.getVcUserName()); return ACTION_FORWORD_USERPERMIS_LIST; }
/** * 获取部门和角色信息 * * @throws Exception */ public void getAjaxXmlData() throws Exception { deptsList = baseDepartmentManager.getAll(); // 获取所有部门 rolesList = baseRoleManager.getAll(); // 获取所有角色 String deptXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; if (deptsList != null && !deptsList.isEmpty()) { deptXml = deptXml + "<root>"; for (TbBaseDepartment dept : deptsList) { deptXml = deptXml + "<data>" + "<id>" + dept.getId() + "</id>" + "<name>" + dept.getVcDeptName() + "</name>" + "</data>"; } deptXml = deptXml + "</root>"; } String roleXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; if (rolesList != null && !rolesList.isEmpty()) { roleXml = roleXml + "<root>"; for (TbBaseRoles role : rolesList) { roleXml = roleXml + "<data>" + "<id>" + role.getId() + "</id>" + "<name>" + role.getVcRolesName() + "</name>" + "</data>"; } roleXml = roleXml + "</root>"; } Struts2Utils.renderText(deptXml + "&&&" + roleXml); }
public void initBussnessDialogData() throws Exception { Struts2Utils.renderXml(packBussnessInfo()); }