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 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); }
/** 导出 */ 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 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 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 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 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); } }
/** 支持使用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 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 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 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 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; }
/** * 分页查询数据 * * @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 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; } }
/** 重置密码 */ 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 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; }
/** 插入用户权限 */ 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 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 update() throws ServletException, IOException { HttpServletRequest request = Struts2Utils.getRequest(); LoginListener loginListener = (LoginListener) request.getSession().getAttribute(VarConstants.LOGIN_LISTENER_KEY); TbBaseUserInfo userInfo = loginListener.getSessionContainer().getUserInfo(); String businessIds = request.getParameter("businessIds"); String business = request.getParameter("business"); String msg = null; String[] bussIds = null; String businessId = null; try { request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00102); entity.setIntTaskStatus(0); // 新建时的状态 entity.setDtOrderTime( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.s").format(new Date())); // 新建时的定制时间 entity.setVcTaskOrder(userInfo.getVcUserName()); keywordsTacticsImpl.update(entity); List dlist = keywordsTacticsImpl.findDataGetterFilterId(entity.getNmDataGetterTaskId() + ""); 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.deleteKeyValueGetterFilter(entity.getNmDataGetterTaskId()); if (businessIds != null && !"".equals(businessIds)) { String[] datas = businessIds.split(","); for (String ids : datas) { bussIds = ids.split(":"); businessId = bussIds[1].trim(); if (!vcFilterKeyValue1.equals("")) { vcFilterKeyValue1 = vcFilterKeyValue1.replace(",", ","); String[] vcFilterKeyValue = vcFilterKeyValue1.split(","); List keyList = new ArrayList<String>(); for (int i = 0; i < vcFilterKeyValue.length; i++) { if (!keyList.contains(vcFilterKeyValue[i]) && keyList.size() < 50) { long id = keywordsTacticsImpl.insertIsExactMark( entity.getNmDataGetterTaskId(), vcFilterKeyValue[i], 1); keywordsTacticsImpl.insertKeyValueSoTypeId(new Long(businessId), id); keyList.add(vcFilterKeyValue[i]); } } } if (!vcFilterKeyValue2.equals("")) { vcFilterKeyValue2 = vcFilterKeyValue2.replace(",", ","); String[] vcFilterKeyValue = vcFilterKeyValue2.split(","); List keyList2 = new ArrayList<String>(); for (int i = 0; i < vcFilterKeyValue.length; i++) { if (!keyList2.contains(vcFilterKeyValue[i]) && keyList2.size() < 50) { long id = keywordsTacticsImpl.insertIsExactMark( entity.getNmDataGetterTaskId(), vcFilterKeyValue[i], 0); keywordsTacticsImpl.insertKeyValueSoTypeId(new Long(businessId), id); keyList2.add(vcFilterKeyValue[i]); } } } } } msg = "编辑策略任务[名称:" + entity.getVcTaskName() + "]成功!"; // commonManagerImpl.log(request, msg); return "success"; } catch (Exception e) { logger.error(e.getMessage()); logger.error(e.toString()); logger.error(e.getMessage()); request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00004); msg = "编辑策略任务[名称:" + entity.getVcTaskName() + "]失败!"; // commonManagerImpl.log(request, msg); return "success"; } }