initial commit

This commit is contained in:
chenjinsong
2018-09-27 16:21:05 +08:00
commit dc91c4c987
2011 changed files with 408920 additions and 0 deletions

72
src/nis/nms/web/Test.java Normal file
View File

@@ -0,0 +1,72 @@
package nis.nms.web;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStream;
import org.apache.log4j.Logger;
public class Test {
static Logger logger=Logger.getLogger(Test.class);
public static void main(String[] args) {
File zh=new File("D:\\Workspaces\\wwrWork\\nmsweb\\WebRoot\\i18n\\globalMessages_zh_CN.properties");
File ru=new File("D:\\Workspaces\\wwrWork\\nmsweb\\WebRoot\\i18n\\globalMessages_ru_RU.properties");
if(!zh.exists()||!ru.exists()){
logger.error("文件未找到");
return ;
}
try {
BufferedReader zhReader=new BufferedReader(new FileReader(zh));
BufferedReader ruReader=new BufferedReader(new FileReader(ru));
String zhLine=null;
String ruLine=null;
int rowNum=0;
while((zhLine=zhReader.readLine())!=null&&(ruLine=ruReader.readLine())!=null){
if(zhLine.startsWith("#")||ruLine.startsWith("#")){
rowNum++;
continue;
}
rowNum++;
if(rowNum==4348){
System.out.println("bug点");
}
String[] zhSplit=zhLine.split("=");
String[] ruSplit=ruLine.split("=");
if((zhSplit==null||zhSplit.length<2)||(ruSplit==null||ruSplit.length<2)){
if(zhLine.equals(ruLine)){
continue;
}else{
logger.error("此行不匹配:"+rowNum);
return ;
}
}
String zhKey=zhSplit[0];
String ruKey=ruSplit[0];
if(zhKey.equals(ruKey)){
continue;
}else{
logger.error("行不匹配:"+rowNum);
return ;
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,578 @@
package nis.nms.web.actions;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import org.apache.commons.lang.StringUtils;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import com.nis.util.StringUtil;
import nis.nms.core.Constants;
import nis.nms.core.Resource;
import nis.nms.domains.TableDepartment;
import nis.nms.domains.TableLoginRpt;
import nis.nms.domains.TableUserDepartment;
import nis.nms.domains.XtJsJbxx;
import nis.nms.domains.XtYhJbxx;
import nis.nms.domains.XtYhJsIndex;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Constant;
import nis.nms.util.MD5;
import nis.nms.util.OnlineListener;
@SuppressWarnings("unchecked")
@Results( {
@Result(name="ok", value = "/main.jsp"),
//updateUserPassword.jsp
///modifyPwd.jsp
@Result(name="modifyPwd", value="/page/system/fourceModifyUserPwd.jsp"),
@Result(name="systemSelect", value = "systemSelect.jsp"),
@Result(name="back", value = "/login.jsp"),
@Result(name="logout", value = "/login.jsp?i18n_lang=${i18n_lang}"),
@Result(name="test", value = "2.jsp"),
@Result(name = "error", value = "/error.jsp")
})
public class LoginAction extends BaseAction {
private static final long serialVersionUID = 1L;
private CommonService commonService;
private XtYhJbxx logInInfo;
private List<XtYhJbxx> userInfoList = new ArrayList();
public String executeAction() throws Exception {
return login();
}
public String login() {
try {
if(logInInfo!=null){
MD5 md5 = new MD5();
//用户使用用户代码和用户密码登陆
String sql = " from XtYhJbxx where yhbh = '" + logInInfo.getYhmc().trim() + "' and yhmm = '" + md5.getMD5Code(logInInfo.getYhmm().trim()) +"' ";
userInfoList = this.commonService.find(sql);
if(userInfoList != null && userInfoList.size() > 0){
XtYhJbxx userInfo = (XtYhJbxx)userInfoList.get(0);
if(userInfo.getZxbz().equals("1")){
outHtmlString("<script type=\"text/javascript\">alert('i18n_LoginAction.login.userLocked_n81i');this.location='login.jsp'</script>");
return null;
}
//判断部门
/*2018-09-19新增根据deptflag判断是否启用用户部门管理 0:启用 1不启用*/
Long deptflag =(Long) this.getRequest().getSession().getAttribute(Constant.DEPT_FLAG);
try {
if(deptflag==null){
sql="select t.type_state from type_table t where t.type_identity = ?";
List list = this.commonService.executeSQL(sql, "deptflag");
if(list!=null&&list.size()>0){
deptflag = ((BigDecimal) list.get(0)).longValue();
}else{
deptflag=1L;
}
System.out.println("是否启用部门管理功能:"+(deptflag==0?"启用":"关闭"));
this.getRequest().getSession().setAttribute(Constant.DEPT_FLAG, deptflag);
}
} catch (Exception e) {
System.out.println("get dept flag faild"+e);
}
if(!"admin".equalsIgnoreCase(userInfo.getYhbh())&&deptflag==0){
XtYhJbxx checkDeptUser = this.getYhJbxx(userInfo);
List ll = checkDeptUser.getUserDeptList();
boolean isDeptstate = false;
if(ll!=null && ll.size()>0){
for(int g=0;g<ll.size();g++){
TableDepartment td = (TableDepartment)ll.get(g);
if(td.getDeptstate().equals("0")){
isDeptstate = true;
break;
}
}
}
if(!isDeptstate){//false说明此用户所在部门全部无效故禁止登录
outHtmlString("<script type=\"text/javascript\">alert('i18n_LoginAction.login.deptLocked_n81i');this.location='login.jsp'</script>");
return null;
}
}
HttpSession session = getRequest().getSession(true); // true
this.getRequest().getSession().removeAttribute(Constant.SESSION_SYSTEM_LOGIN);
this.getRequest().getSession().removeAttribute(Constant.SESSION_SYSTEM_LOGIN_NAME);
try {
/*2018-08-30将 是否启用邮件标识 加入session*/
Long emailFlag = (Long)this.getRequest().getSession().getAttribute(Constant.EMAIL_FLAG);
if(emailFlag==null){
sql="select t.type_state from type_table t where t.type_identity = ?";
List list = this.commonService.executeSQL(sql, "emailflag");
if(list!=null&&list.size()>0){
emailFlag = ((BigDecimal) list.get(0)).longValue();
}else{
emailFlag=1L;
}
System.out.println("是否启用邮件功能:"+(emailFlag==0?"启用":"关闭"));
this.getRequest().getSession().setAttribute(Constant.EMAIL_FLAG, emailFlag);
}
} catch (Exception e) {
System.out.println("get email flag faild"+e);
}
/*2018-09-12新增配置属性NATION_ROLE标识管理角色*/
this.getRequest().getSession().setAttribute("nationRole", Constants.NATION_ROLE);
// 判断重复登陆
if (XtYhJbxx.LONGIN_USER != null)
{// 存在在线用户
boolean isLogin = false;
if (XtYhJbxx.LONGIN_USER.contains(userInfo.getYhid()))
isLogin = true;
if (isLogin)//在线用户中包括正在登陆的用户
{
// if(this.getIsSingleLogin()==0){//启用单点登录
// outHtmlString("<script type=\"text/javascript\">alert('此用户已登录,请选择其他用户登录');this.location='login.html'</script>");
// this.saveLoginRpt("重复登录,失败","登入",userInfo.getYhmc());//记录登陆日志
// return null;
// }
HttpSession sessionold = (HttpSession) XtYhJbxx.LOGIN_SESSION
.get(userInfo.getYhid());// 如果用户已经登录则取出之前登录的session信息
try
{
if (sessionold != null)
{
if(!session.getId().equals(sessionold.getId())){//如果新的sessionid不等于旧的sessionid(新打开浏览器)
if(this.getIsSingleLogin()==0){//启用单点登录
sessionold.invalidate();// 将旧的session信息销毁
}
}else {//处理登录登出异常操作
XtYhJbxx user = (XtYhJbxx) session.getAttribute(Constant.SESSION_CZY_NAME);//获取之前登录用户的session
if(!userInfo.getYhid().equals(user.getYhid())){//对比之前登录的用户与当前登录用户是否相同
XtYhJbxx.LOGIN_SESSION.remove(user.getYhid());// 从session列表信息中移除
XtYhJbxx.LONGIN_USER.remove(user.getYhid());// 将之前的用户信息从登录用户信息列表中移除
}else{
//新增是否首次使用密码判断如果是首次使用密码则必须先修改密码才可进入操作系统
int ischeck = checkPwdState(userInfo.getYhbh());
if(ischeck == 0){
logInInfo.setYhid(userInfo.getYhid());
logInInfo.setYhbh(userInfo.getYhbh());
logInInfo.setYhmc(userInfo.getYhmc());
return "modifyPwd";
}else if(ischeck == 1){
if(session.getAttribute(Constant.SESSION_SYSTEM_LOGIN)!=null){
//进入系统界面
return "ok";
}else{
//获取可访问的业务系统
toSystemSelect(userInfo.getYhbh());
}
}
}
}
}
//if(this.getIsSingleLogin()==0){//启用单点登录
XtYhJbxx.LOGIN_SESSION.remove(userInfo.getYhid());// 从session列表信息中移除
XtYhJbxx.LONGIN_USER.remove(userInfo.getYhid());// 将之前的用户信息从登录用户信息列表中移除
//}
} catch (Exception e)
{
e.printStackTrace();
System.out.println("sessionold已经过期");
XtYhJbxx.LOGIN_SESSION.remove(userInfo.getYhid());// 从session列表信息中移除
XtYhJbxx.LONGIN_USER.remove(userInfo.getYhid());// 将之前的用户信息从登录用户信息列表中移除
}
}
XtYhJbxx.LONGIN_USER.add(userInfo.getYhid());// 将新用户写入在线用户信息中
} else
{// 没有在线用户
XtYhJbxx.LONGIN_USER = new ArrayList();
XtYhJbxx.LONGIN_USER.add(userInfo.getYhid());//将新用户写入在线用户信息中
}
session.setAttribute("loginYhid", userInfo.getYhid());
session.setAttribute("userBgColor", userInfo.getBgColor());
session.setAttribute("YHBH", userInfo.getYhbh());
if(!StringUtil.isBlank(userInfo.getLanguage())){//将用户的语言存入session中
String lang=userInfo.getLanguage();
String[] split = lang.split("_");
Locale locale = new Locale(split[0], split[1]);
session.setAttribute("i18n_lang", locale);
}
session.setAttribute(Constant.SESSION_CZY_NAME, this.getYhJbxx(userInfo));
XtYhJbxx.LOGIN_SESSION.put(userInfo.getYhid(),session);//将session保存起来
//把session加入监听器
OnlineListener.createsession(new HttpSessionEvent(session));
session.setAttribute("treeList", this.getYhJsMk(userInfo.getYhbh()));
//System.out.println("sessionid = " + this.getRequest().getSession().getId());
//记录登陆日志
this.saveLoginRpt("i18n_LoginAction.login.success_n81i","i18n_LoginAction.login.in_n81i",userInfo.getYhmc());
// 查询菜单树
QueryMenuTreeAction query = new QueryMenuTreeAction(commonService);
List<Map<String, Object>> userfunctionList = null;
if (logInInfo.getYhmc() != null && "admin".equals(logInInfo.getYhmc().trim())){
userfunctionList = query.queryMenuTree(logInInfo.getYhmc().trim(), null);
} else {
if (userInfo != null) {
userfunctionList = query.queryMenuTree(null,this.getUser().getYhbh());
}else{
return "error";
}
}
if(userfunctionList==null || userfunctionList.size()==0){
this.saveLoginRpt("i18n_LoginAction.login.noPermission_n81i","i18n_LoginAction.login.in_n81i",logInInfo.getYhmc());//记录登陆日志
outHtmlString("<script type=\"text/javascript\">alert('i18n_LoginAction.login.noPermission_n81i');this.location='login.jsp'</script>");
//outHtmlString("<script type='text/javascript' src='js/ymPrompt.js'></script><link rel='stylesheet' href='js/ski/qq/ymPrompt.css' type='text/css'></link><script type=\"text/javascript\">ymPrompt.alert('操作失败');</script>");
return null;
}
// 用户所要功能权限 add by ghh
session.setAttribute("userfunctionList", userfunctionList);
LinkedList<Map<String,Object>> userfunctionList2 = new LinkedList<Map<String,Object>>();
userfunctionList2.addAll(userfunctionList);
// List<Map<String, Object>> userfunctionList2 = (List<Map<String, Object>>) ((LinkedList<Map<String,Object>>)userfunctionList).clone();
String treeStr = query.makeMenuTree(userfunctionList2);
//System.out.println(userInfoTemp.getNickname()+":treeXML\t" + treeStr);
if(session.getAttribute("treeStr")!=null){
session.removeAttribute("treeStr");
}
session.setAttribute("treeStr", treeStr);
session.setAttribute("treeHtml", query.getMenuHtml(treeStr));
//新增是否首次使用密码判断如果是首次使用密码则必须先修改密码才可进入操作系统
int ischeck = checkPwdState(userInfo.getYhbh());
if(ischeck == 0){
logInInfo.setYhid(userInfo.getYhid());
logInInfo.setYhbh(userInfo.getYhbh());
logInInfo.setYhmc(userInfo.getYhmc());
return "modifyPwd";
}else if(ischeck == 1){
//新增业务系统登陆判断systemLogin
if(session.getAttribute(Constant.SESSION_SYSTEM_LOGIN)==null){//跳转到业务系统选择页面
return toSystemSelect(userInfo.getYhbh());
}else {//进入系统界面
return "ok";
}
}else{
session.invalidate();
}
}
}else{
return "back";
}
} catch (Exception e) {
// e.printStackTrace();
// outHtmlString("<script type=\"text/javascript\">alert('操作失败');this.location='index.jsp'</script>");
this.saveLoginRpt("i18n_LoginAction.login.unpredictableErr_n81i","i18n_LoginAction.login.in_n81i",logInInfo.getYhmc());//记录登陆日志
outHtmlString("<script type=\"text/javascript\">alert('i18n_LoginAction.checkPwdState.faild_n81i');this.location='login.jsp'</script>");
//outHtmlString("<script type='text/javascript' src='js/ymPrompt.js'></script><link rel='stylesheet' href='js/ski/qq/ymPrompt.css' type='text/css'></link><script type=\"text/javascript\">ymPrompt.alert('操作失败');</script>");
return null;
}
this.saveLoginRpt("用户名或密码错误","i18n_LoginAction.login.in_n81i",logInInfo.getYhmc());//记录登陆日志
outHtmlString("<script type=\"text/javascript\">alert('i18n_LoginAction.login.usernameOrPwdErr_n81i');this.location='login.jsp'</script>");
//outHtmlString("<script type='text/javascript' src='js/ymPrompt.js'></script><link rel='stylesheet' href='js/ski/qq/ymPrompt.css' type='text/css'></link><script type=\"text/javascript\">ymPrompt.alert('操作失败');</script>");
return null;
}
private String toSystemSelect(String yhbh){
try {
List<Object []> stList = new ArrayList<Object[]>();
if(yhbh != null && !"".equals(yhbh)){
if("admin".equals(yhbh.trim())){
this.getRequest().getSession().setAttribute(Constant.SESSION_SYSTEM_LOGIN, -1l);
this.getRequest().getSession().setAttribute(Constant.SESSION_SYSTEM_LOGIN_NAME, "ALL");
return "ok";
}else{
stList = this.commonService
.executeSQL("select DISTINCT(st.system_Id),st.system_Name,st.is_master " +
"from system_table st " +
"left join Gorup_System_Table gst on gst.system_Id = st.system_Id " +
"left join Xt_Yh_Js_Index xyji on xyji.jsbh = gst.user_Group_Id " +
"left join XT_JS_JBXX xjj on xjj.jsbh = xyji.jsbh " +
"where xyji.yhbh='" + yhbh.trim() +
"' and st.system_state = 0 and xyji.type=1 and xjj.zxbz=0 " +//业务系统启用+角色类型为用户组+用户组有效
"order by st.system_Id");
//国家中心人员具有 查看所有业务系统 数据的权限
List<String> list = this.commonService.executeSQL("SELECT jsbh FROM xt_yh_js_index where yhbh = ?", yhbh.trim());
if(list != null && list.size() > 0){
for(String obj : list){
if(StringUtils.isNotBlank(obj)){
if((Constants.NATION_ROLE.trim()).equals(obj.trim())){
Object[] all = new Object[3];
all[0] = -1;
all[1] = "ALL";
all[2] = 1;
stList.add(0, all);
break;
}
}
}
}
if(stList!=null && stList.size()==1){
this.getRequest().getSession().setAttribute(Constant.SESSION_SYSTEM_LOGIN, Long.parseLong(stList.get(0)[0].toString()));
this.getRequest().getSession().setAttribute(Constant.SESSION_SYSTEM_LOGIN_NAME, stList.get(0)[1].toString());
// System.out.println(stList.get(0)[1]+"-=-=-=-=-=-=--=-=-=-=-=-==============--- Only One "+this.getRequest().getSession().getAttribute(Constant.SESSION_SYSTEM_LOGIN));
return "ok";
}
}
}
this.getRequest().setAttribute("stList", stList);
} catch (Exception e) {
e.printStackTrace();
}
return "systemSelect";
}
/**
* 判断用户是否首次使用密码如果是首次返回到密码修改页面
* @param yhbh
* @return 0要修改密码1无需修改密码继续2用户不存在
*/
private int checkPwdState(String yhbh){
//默认要修改密码
int ischeck = 0;
try {
List<Object []> stList = new ArrayList<Object[]>();
if(yhbh != null && !"".equals(yhbh)){
stList = this.commonService
.executeSQL("select xyj.PWDSTATE from xt_yh_jbxx xyj where xyj.yhbh = '"+yhbh+"' AND xyj.ZXBZ = 0 ");
if(stList == null){
outHtmlString("<script type=\"text/javascript\">alert('i18n_LoginAction.checkPwdState.userIsNotExists_n81i');this.location='login.jsp'</script>");
ischeck = 2;
}else if(stList.size()==1){// && stList.size()==1
//如果密码正常状态则直接放行
ischeck =Integer.parseInt(String.valueOf(stList.get(0)));
}else{
outHtmlString("<script type=\"text/javascript\">alert('i18n_LoginAction.checkPwdState.userInfoErr_n81i');this.location='login.jsp'</script>");
ischeck = 2;
}
}
this.getRequest().setAttribute("stList", stList);
} catch (Exception e) {
e.printStackTrace();
}
return ischeck;
}
// 更新用户密码信息
public String forceModifyPassword() {
String yhid = this.getRequest().getParameter("yhid");
String yhbh = this.getRequest().getParameter("yhbh");
try {
MD5 md5 = new MD5();
XtYhJbxx userNew = (XtYhJbxx) this.commonService.get(
XtYhJbxx.class, Long.parseLong(yhid.trim()));
userNew.setYhmm(md5.getMD5Code(logInInfo.getYhmm().trim()));
//让管理员重置密码之后修改密码状态未必须修改状态0
userNew.setPwdState("1");
this.commonService.update(userNew);
// //将删除操作写到操作日志中
this.addDBOperationRpt(commonService, "XT_YH_JBXX", "UPDATE",
userNew.getYhid());
this.getRequest().setAttribute("MSG", 1);
} catch (Exception e) {
this.getRequest().setAttribute("MSG", 2);
e.printStackTrace();
}
return toSystemSelect(yhbh);
}
public String systemSelect(){
if("yes".equals(this.getRequest().getParameter("SytemChange"))){
if(this.getRequest().getSession().getAttribute("YHBH")!=null){
return toSystemSelect(this.getRequest().getSession().getAttribute("YHBH").toString());
}else {
outHtmlString("<script type=\"text/javascript\">alert('i18n_LoginAction.checkPwdState.selectSys_n81i');window.history.go(-1);</script>");
return null;
}
}else{
if(this.getRequest().getParameter("systemId")!=null && !"".equals(this.getRequest().getParameter("systemId"))){
Long systemId = Long.parseLong(this.getRequest().getParameter("systemId"));
this.getRequest().getSession().setAttribute(Constant.SESSION_SYSTEM_LOGIN, systemId);
if(systemId == -1){//管理员权限,查看所有数据
this.getRequest().getSession().setAttribute(Constant.SESSION_SYSTEM_LOGIN_NAME, "ALL");
this.getRequest().getSession().setAttribute(Constant.ADMIN_FLAG, true);
}else{
this.getRequest().getSession().setAttribute(Constant.ADMIN_FLAG, false);
List<Object> stList = new ArrayList<Object>();
try{
stList = this.commonService.executeSQL("select st.system_Name from system_table st where st.system_Id = "+Long.parseLong(this.getRequest().getParameter("systemId")));
if(stList!=null && stList.size()==1){
this.getRequest().getSession().setAttribute(Constant.SESSION_SYSTEM_LOGIN_NAME, stList.get(0).toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}
//刷新菜单树---------------------------2013-1-8 新增
QueryMenuTreeAction query = new QueryMenuTreeAction(commonService);
List<Map<String, Object>> userfunctionList = null;
userfunctionList = query.queryMenuTree(null,this.getUser().getYhbh());
if(userfunctionList==null || userfunctionList.size()==0){
this.saveLoginRpt("i18n_LoginAction.login.noPermission_n81i","i18n_LoginAction.login.in_n81i",logInInfo.getYhmc());//记录登陆日志
outHtmlString("<script type=\"text/javascript\">alert('i18n_LoginAction.login.noPermission_n81i');this.location='login.jsp'</script>");
//outHtmlString("<script type='text/javascript' src='js/ymPrompt.js'></script><link rel='stylesheet' href='js/ski/qq/ymPrompt.css' type='text/css'></link><script type=\"text/javascript\">ymPrompt.alert('操作失败');</script>");
return null;
}
// 用户所要功能权限 add by ghh
this.getRequest().getSession().setAttribute("userfunctionList", userfunctionList);
LinkedList<Map<String,Object>> userfunctionList2 = new LinkedList<Map<String,Object>>();
userfunctionList2.addAll(userfunctionList);
// List<Map<String, Object>> userfunctionList2 = (List<Map<String, Object>>) ((LinkedList<Map<String,Object>>)userfunctionList).clone();
String treeStr = query.makeMenuTree(userfunctionList2);
//System.out.println(userInfoTemp.getNickname()+":treeXML\t" + treeStr);
if(this.getRequest().getSession().getAttribute("treeStr")!=null){
this.getRequest().getSession().removeAttribute("treeStr");
}
this.getRequest().getSession().setAttribute("treeStr", treeStr);
//---------------------------2013-1-8 新增--------end-------------
return "ok";
}else{
outHtmlString("<script type=\"text/javascript\">alert('i18n_LoginAction.checkPwdState.selectSys_n81i');window.history.go(-1);</script>");
return null;
}
}
}
public String logout(){
System.out.println("用户退出@@@@@@@@@@@@@@@@@@@@@@");
HttpSession session = this.getRequest().getSession(false);
if (session.isNew())
System.out.println("session被重新创建了");
if (session != null) {
XtYhJbxx user = (XtYhJbxx) session.getAttribute(Constant.SESSION_CZY_NAME);
if (user != null) {
XtYhJbxx.LONGIN_USER.remove(user.getYhbh());
XtYhJbxx.LOGIN_SESSION.remove(user.getYhbh());
Locale lang = (Locale) session.getAttribute("i18n_lang");
// OnlineListener online = new OnlineListener();
// online.sessionDestroyed(new HttpSessionEvent(session));
// 使用户session失效
session.invalidate();
this.saveLoginRpt("i18n_LoginAction.login.success_n81i","i18n_LoginAction.checkPwdState.out_n81i",user.getYhmc());//记录登陆日志
}else{
System.out.println("从session中没有取得人员信息");
this.saveLoginRpt("i18n_LoginAction.checkPwdState.sessionOutTime_n81i","i18n_LoginAction.checkPwdState.out_n81i",user.getYhmc());//记录登陆日志
}
}
return "logout";
}
public List getYhJsMk(String yhbh){
List treeList = new ArrayList();
try {
// String sql="select substr(mkbh,0,length(mkbh)-5) as pid,mkbh,mkmc,mkms,mkurl,mktb from XtMkJbxx where mkbh in " +
// "(select mkbh from XtJsMkIndex where jsbh in" +
// "(select a.jsbh from XtJsJbxx a where a.jsbh in(" +
// "select jsbh from XtYhJsIndex where yhbh = '"+yhbh+"') and a.zxbz='0')) and zxbz='0'";
String sql="select pid,id,mkmc,mkms,mkurl,mktb,iconimage,mktype from XtMkJbxx where id in " +
"(select mkbh from XtJsMkIndex where jsbh in" +
"(select a.jsbh from XtJsJbxx a where a.jsbh in(" +
"select jsbh from XtYhJsIndex where yhbh = '"+yhbh+"') and a.zxbz='0')) and zxbz='0' order by showlevel,showorder";
List menuList = this.commonService.find(sql);
for(int i=0;i<menuList.size();i++){
Object[] obj = (Object[])menuList.get(i);//0为pid,1为mkbh,2为mkmc,3为mkms,4为mkurl,5为mktb
Resource resource = new Resource();
resource.setParRsCode(obj[0].toString());
resource.setRsCode(obj[1].toString());
resource.setRsid(obj[1].toString());
resource.setRsname(obj[2].toString());
resource.setRsaddress(obj[4]==null?"":obj[4].toString());
resource.setIconshow(obj[6]==null?"":obj[6].toString());
resource.setMktype(obj[7]==null?"":obj[7].toString());
treeList.add(resource);
}
} catch (Exception e) {
e.printStackTrace();
}
return treeList;
}
public XtYhJbxx getYhJbxx(XtYhJbxx user){
try {
List userRoleList = this.commonService.find("from XtYhJsIndex where yhbh=?",user.getYhbh());
List roleList = this.commonService.find("from XtJsJbxx order by jsbh");
for(int j = 0;j<roleList.size();j++){
XtJsJbxx role = (XtJsJbxx)roleList.get(j);
for(int k =0;k<userRoleList.size();k++){
XtYhJsIndex jbxx = (XtYhJsIndex)userRoleList.get(k);
if(role.getJsbh().equals(jbxx.getJsbh())){
user.getUserRoleList().add(role);
}
}
}
//获取用户部门信息
Long deptFlag =(Long) this.getRequest().getSession().getAttribute(Constant.DEPT_FLAG);
if(deptFlag!=null&&deptFlag==0){
List userDeptList = this.commonService.find("from TableUserDepartment where userid=?", user.getYhid());
List deptList = this.commonService.find("from TableDepartment order by deptid");
for(int j = 0;j<deptList.size();j++){
TableDepartment dept = (TableDepartment)deptList.get(j);
for(int k = 0;k<userDeptList.size();k++){
TableUserDepartment userDepartment = (TableUserDepartment)userDeptList.get(k);
if(dept.getDeptid().equals(userDepartment.getDeptid())){
user.getUserDeptList().add(dept);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return user;
}
/**
* @param status,login状态
* @param event,login行为
*/
public void saveLoginRpt(String status,String event,String yhmc){
try {
TableLoginRpt login = new TableLoginRpt();
login.setAction(event);
login.setStatus(status);
login.setTime(new Date());
login.setUsername(yhmc);
login.setIp(this.getRequest().getRemoteAddr());
this.commonService.save(login);
} catch (Exception e) {
e.printStackTrace();
}
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public XtYhJbxx getLogInInfo() {
return logInInfo;
}
public void setLogInInfo(XtYhJbxx logInInfo) {
this.logInInfo = logInInfo;
}
public List<XtYhJbxx> getUserInfoList() {
return userInfoList;
}
public void setUserInfoList(List<XtYhJbxx> userInfoList) {
this.userInfoList = userInfoList;
}
}

View File

@@ -0,0 +1,298 @@
package nis.nms.web.actions;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import nis.nms.domains.XtYhJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.Common;
import nis.nms.util.Constant;
/**
*
*
*/
public class QueryMenuTreeAction {
private static final long serialVersionUID = 1L;
private List<XtYhJbxx> userInfoList = null;
@SuppressWarnings("unchecked")
private CommonService commonService;
/** 拼接的xml字符串 */
private StringBuffer xmlStr;
/**
* 从数据库中查询出菜单拼接成xml字符串并存放到Session中
* @param menuIds某权限下的菜单Id的集合
* @return xmlStr 拼接成的字符串
*/
@SuppressWarnings("unchecked")
public List<Map<String, Object>> queryMenuTree(String yhmc,String yhbh) {
// 查询用户下的所以功能节点
List<Map<String, Object>> userfunctionList = null;
try {
StringBuffer hql = new StringBuffer();
if (yhmc != null
&& "admin".equals(yhmc.trim())) {
hql
.append("select n.Id,n.ZXBZ,n.PID,n.HANDLER,n.MKURL,"
+ "n.MKMC,n.MKTYPE from xt_mk_jbxx n where ZXBZ=0");
} else {
if (yhbh != null) {
if(Constant.F_BUTTON_AUTHER){
hql
.append("select n.id,n.ZXBZ,n.PID,n.HANDLER,n.MKURL,"
+ "n.MKMC,n.MKTYPE from xt_mk_jbxx n where ZXBZ=0 and n.id in (select r.MKBH from xt_js_mk_index r"
+ " where r.JSBH in (select ro.JSBH from xt_yh_js_index ro where ro.TYPE is null and ro.YHBH = '"
+ yhbh
+ "') and r.JSBH in(select js.JSBH from XT_JS_JBXX js where js.ZXBZ = 0)) or n.MKTYPE=4");
}else{
hql
.append("select n.id,n.ZXBZ,n.PID,n.HANDLER,n.MKURL,"
+ "n.MKMC,n.MKTYPE from xt_mk_jbxx n where ZXBZ=0 and n.id in (select r.MKBH from xt_js_mk_index r"
+ " where r.JSBH in (select ro.JSBH from xt_yh_js_index ro where ro.TYPE is null and ro.YHBH = '"
+ yhbh
+ "') and r.JSBH in(select js.JSBH from XT_JS_JBXX js where js.ZXBZ = 0)) ");
}
}
}
hql.append( " order by n.showlevel,n.showorder");
userfunctionList = this.commonService.findByJdbcStrUp(hql.toString());
} catch (Exception e) {
e.printStackTrace();
}
return userfunctionList;
}
/**
* 从数据库中查询出菜单拼接成xml字符串并存放到Session中
* @param menuIds某权限下的菜单Id的集合
* @return xmlStr 拼接成的字符串
*/
@SuppressWarnings("unchecked")
public String makeMenuTree(List<Map<String, Object>> userfunctionList) {
// 如果没有可用的菜单返回
if (userfunctionList == null || userfunctionList.size() <= 0) {
return null;
}
try {
xmlStr = new StringBuffer();
// 添加文件头
xmlStr.append("<?xml version='1.0' encoding='UTF-8'?>");
// 如果没有可用的菜单返回
if (userfunctionList == null || userfunctionList.size() <= 0) {
return null;
}
// 添加root节点
xmlStr.append("<" + Constant.XML_FILE_ROOT + ">");
// 找到顶层菜单的集合,递归的入口
List<Map<String, Object>> topMenuInfoList = new ArrayList<Map<String, Object>>();
Map<String, Object> obj;
for (int i = 0; i < userfunctionList.size(); i++) {
//obj = new HashMap();
obj = userfunctionList.get(i);
String href = "";
if (obj.get("MKURL") != null && !"".equals(obj.get("MKURL"))) {
// 将数据库中查找到的所有菜单的链接格式化为XML格式字符串main.jsp页面以XML格式读取菜单
href = Common.converseToXMLStr(obj.get("MKURL").toString());
obj.put("MKURL",href);
}
if (obj.get("PID")!=null && !"".equals(obj.get("PID")) && 0 == Integer.parseInt(obj.get("PID").toString())) {
topMenuInfoList.add(obj);
userfunctionList.remove(i);
i = -1;
}
}
// 递归得到树形菜单
for (int j = 0; j < topMenuInfoList.size(); j++) {
obj = topMenuInfoList.get(j);
getXmlByParentAndChild(obj, userfunctionList);
}
xmlStr.append("</" + Constant.XML_FILE_ROOT + ">");
} catch (Exception e) {
e.printStackTrace();
}
return xmlStr.toString();
}
/**
* @description 递归父菜单及其相应子菜单返回一个Xml字符串
* @param parentMenu
* Map<String, Object>类型的父菜单
* @param otherMenus
* 其余菜单集合
*
* @return xmlStr 父菜单和相应子菜单拼接的xml字符串
*/
public void getXmlByParentAndChild(Map<String, Object> parentMenu,
List<Map<String, Object>> otherMenus) {
if(!"1".equals(parentMenu.get("MKTYPE"))){
String parentMenuXml = getMenuXml(parentMenu);
// 添加xml的子节点Constants.XML_FILE_NODE=resource
xmlStr.append("<" + Constant.XML_FILE_NODE + parentMenuXml);
List<Map<String, Object>> currentMenuChild = getChildMenusByParentMenu(
parentMenu, otherMenus);
if (currentMenuChild.size() > 0) {
xmlStr.append(">");
for (int i = 0; i < currentMenuChild.size(); i++) {
Map<String, Object> menu = currentMenuChild.get(i);
getXmlByParentAndChild(menu, otherMenus);
}
xmlStr.append("</" + Constant.XML_FILE_NODE + ">");
} else {
xmlStr.append("/>");
}
}
}
/**
* @description 根据父菜单找到其下的子菜单
* @param parentMenu
* FunctionMenus类型的父菜单
* @param otherMenus
* 剩余的其他菜单集合
*
* @return childMenuList 返回该父菜单的子菜单集合
*/
public List<Map<String, Object>> getChildMenusByParentMenu(
Map<String, Object> parentMenu, List<Map<String, Object>> otherMenus) {
List<Map<String, Object>> childMenuList = new ArrayList<Map<String, Object>>();
int childNums = otherMenus.size();
if (childNums > 0) {
for (int i = 0; i < otherMenus.size(); i++) {
Map<String, Object> childMenu = otherMenus.get(i);
if(childMenu!=null){
if(parentMenu.get("ID")!=null &&!"".equals(parentMenu.get("ID")) && childMenu.get("PID")!=null && !"".equals(childMenu.get("PID")) ){
String parentMenuId = parentMenu.get("ID").toString();
String childPId = childMenu.get("PID").toString();
if (parentMenuId.equals(childPId)) {
childMenuList.add(childMenu);
otherMenus.remove(i);
i = -1;
}
}
}
}
}
return childMenuList;
}
/**
* 将菜单信息拼接成一个字符串
*/
public String getMenuXml(Map<String, Object> menu) {
StringBuffer menuXmlStr = new StringBuffer();
// 添加资源标识rsid
if (menu.get("ID") != null && !"".equals(menu.get("ID"))) {
menuXmlStr.append(" " + Constant.XML_FILE_NODE_RSID + "='"
+menu.get("ID").toString() + "'");
}
// 添加菜单名称rsname
if (menu.get("MKMC") != null && !"".equals(menu.get("MKMC"))) {
menuXmlStr.append(" " + Constant.XML_FILE_NODE_RSNAME + "='"
+ menu.get("MKMC").toString() + "'");
}
// 添加链接rsaddress
if (menu.get("MKURL") != null && !"".equals(menu.get("MKURL"))) {
/*menuXmlStr.append(" " + Constant.XML_FILE_NODE_RSADDRESS + "='"
+ menu.get("MKURL") + "'");*/
/*menuXmlStr.append(" " + Constant.XML_FILE_NODE_RSADDRESS + "='"
+ Common.converseToNomal(menu.get("MKURL").toString()) + "'");*/
menuXmlStr.append(" " + Constant.XML_FILE_NODE_RSADDRESS + "='"
+ Common.converseToXMLStr(menu.get("MKURL").toString()) + "'");
}
return menuXmlStr.toString();
}
public String getMenuHtml(String xmlStr){
StringBuilder sb = new StringBuilder();
SAXBuilder builder = new SAXBuilder();
Element resources = null;
try {
// 将xml字符串序列化,生成一个树型枚举对象
Reader read = new StringReader(xmlStr);
Document read_doc = builder.build(read);
resources = read_doc.getRootElement();
List<Element> children = resources.getChildren(Constant.XML_FILE_NODE);
/*<ul>
<li class="nav-item">
<a href="javascript:;"><span>System Configuration</span><i class="my-icon nav-more"></i></a>
<ul>
<li><a href="javascript:;" data-url='/nmsweb/detection/monitorData.do?action=query'><span>网站设置</span></a></li>
<li><a href='/nmsweb/sysManage/sysErrorManage!execute.do?action=queryError' target='I3'><span>友情链接</span></a></li>
<li><a href='/nmsweb/detection/monitorData.do?action=query' target='I3'><span>分类管理</span></a></li>
<li><a href="javascript:;"><span>系统日志</span></a></li>
</ul>
</li>
</ul>*/
sb.append("<ul>");
for(Element ele : children){
sb.append("<li class='nav-item'>");
List<Element> list = ele.getChildren();
if(list != null && list.size()>0){
sb.append("<a href='javascript:;'><span class='memuNameSpan' title='"+ele.getAttributeValue(Constant.XML_FILE_NODE_RSNAME)+"'>");
sb.append(ele.getAttributeValue(Constant.XML_FILE_NODE_RSNAME));
sb.append("</span><i class='my-icon nav-more'></i></a>");
sb.append("<ul>");
for(Element e : list){
sb.append("<li><a href='");
sb.append("/nmsweb");
sb.append(e.getAttributeValue(Constant.XML_FILE_NODE_RSADDRESS));
sb.append("' target='I3'><span class='memuNameSpan' title='"+e.getAttributeValue(Constant.XML_FILE_NODE_RSNAME)+"'>");
sb.append(e.getAttributeValue(Constant.XML_FILE_NODE_RSNAME));
sb.append("</span></a></li>");
}
sb.append("</ul>");
}else{
if(StringUtils.isNotBlank(ele.getAttributeValue(Constant.XML_FILE_NODE_RSADDRESS))){
sb.append("<a target='I3' href='");
sb.append("/nmsweb");
sb.append(ele.getAttributeValue(Constant.XML_FILE_NODE_RSADDRESS));
sb.append("'><span class='memuNameSpan' title='"+ele.getAttributeValue(Constant.XML_FILE_NODE_RSNAME)+"'>");
sb.append(ele.getAttributeValue(Constant.XML_FILE_NODE_RSNAME));
sb.append("</span><i class='my-icon nav-more'></i></a>");
}
}
sb.append("</li>");
}
sb.append("<ul>");
} catch (Exception e) {
e.printStackTrace();
}
return sb.toString();
}
@SuppressWarnings("unchecked")
public CommonService getCommonService() {
return commonService;
}
@SuppressWarnings("unchecked")
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
@SuppressWarnings("unchecked")
public QueryMenuTreeAction(CommonService commonService) {
super();
this.commonService = commonService;
}
public QueryMenuTreeAction() {
}
}

View File

@@ -0,0 +1,82 @@
package nis.nms.web.actions.authentication;
import java.io.IOException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;
import java.util.ResourceBundle;
import com.nis.util.StringUtil;
import net.sf.json.JSONObject;
import nis.nms.util.BaseAction;
import nis.nms.util.MD5;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class IdentificatAction extends BaseAction {
private static final long serialVersionUID = -5399695444475961856L;
public static ResourceBundle rb = ResourceBundle.getBundle("myconfig");
private final String TARGET_SYSTEM_URL=rb.getString("system.url");
private final String splitStr="@#@";
private String action;
private String token;
@Override
public String executeAction() throws Exception {
if("toTargetSys".equals(action)){
String ip = this.getRequest().getParameter("addr");
Long userId = (Long) this.getRequest().getSession().getAttribute("loginYhid");//获取用户id md5 加密 作为token
MD5 md5=new MD5();
String token = md5.getMD5Code(userId.toString()+System.currentTimeMillis());
String user=rb.getString("target.system.user");
String pwd=rb.getString("target.system.pwd");
BASE64Encoder encoder=new BASE64Encoder();
String encode = encoder.encode((user+splitStr+pwd).getBytes());
this.getRequest().getSession().setAttribute(token, encode);
StringBuilder sb=new StringBuilder();
sb.append(TARGET_SYSTEM_URL+"?token="+token);
sb.append("&ip="+ip);
System.out.println("grafana addr : "+sb.toString());
this.getResponse().sendRedirect(sb.toString());
}
System.err.println("Identificat="+action);
if("identification".equals(action)){
String tokenVal = (String) this.getRequest().getSession().getAttribute(token);
this.getRequest().getSession().removeAttribute(token);
if(!StringUtil.isBlank(tokenVal)){
try {
JSONObject jsonObj=new JSONObject();
jsonObj.put("jsondata", tokenVal);
System.out.println("jsonObj:"+jsonObj.toString());
String jsonpCallback="jsonpCallback("+jsonObj.toString()+")";
this.getResponse().getWriter().write(jsonpCallback);
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
}

View File

@@ -0,0 +1,353 @@
package nis.nms.web.actions.deptManage;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import nis.nms.domains.TableDepartment;
import nis.nms.persistence.HibernateGeneralDaoImpl;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Page;
@SuppressWarnings("unchecked")
@Results( {
@Result(name = "queryDeptInfo", value = "/page/system/deptManage/deptInfoList.jsp"),
@Result(name = "add", value = "/deptManage/deptManage!execute.do?action=queryDeptInfo"),
@Result(name = "openUpdateDeptPage", value = "/page/system/updateDeptInfo.jsp")})
public class DeptManageAction extends BaseAction {
/**
*
*/
private static final long serialVersionUID = 1L;
private CommonService commonService;
private int pageNo = 1;
private int pageSize = this.getDefaultPageSize(); // 每页显示的记录条数
private Page page;
private String action;// 系统操作
private TableDepartment dept;//保存部门信息
private List listDeptInfo = new ArrayList();
private List deptList = new ArrayList();
private String deptname;// 部门名称
public String executeAction() {
String resultpage = "";
// 部门管理部分
if (action.equals("queryDeptInfo")) {// 查询部门信息
resultpage = queryDeptInfo();
}
if (action.equals("add")) {//添加部门
add();
return null;
}
if (action.equals("update")) {//修改部门
update();
return null;
}
return resultpage;
}
/**
*
* 查询部门信息
* @author hyx Mar 29, 2012
* @version 1.0
* @return
*/
public String queryDeptInfo() {
try {
String sql = "from TableDepartment where 1=1 ";
String sqlCondition = "where 1=1";// 将查询条件记录到操作日志中
if (deptname != null && !"".equals(deptname)) {
sql += " and Upper(deptname) like '%" + deptname.toUpperCase() + "%'";
sqlCondition += " and deptname like '%" + deptname + "%'";
}
sql += "order by deptid";
listDeptInfo = (List<TableDepartment>)this.commonService.find(sql);
// 将查询请求记入到操作日志表中
this.addDBOperationRpt(commonService, sqlCondition,
"TableDepartment");
} catch (Exception e) {
e.printStackTrace();
}
return "queryDeptInfo";
}
// 进行修改模块信息操作
public void update() {
try {
if(dept.getDeptid()!=null && !dept.getDeptid().toString().equals("1")){
if(dept.getDeptstate()!=null){
if(dept.getDeptstate().equals("1")){//置为无效,则其下部门全部职位无效
//@2018-3-9 fang 修改 首先查询符合条件的id在拼接sql适配mysql
String swcbSql = "select deptid from tabledepartment where 1=1 ";
List<Map<String,Object>> list = this.commonService.startWithConnectBy(swcbSql, "deptid="+dept.getDeptid(), "deptid", "upperlayer");
StringBuilder sb = new StringBuilder();
for(Map<String,Object> map : list){
if(map != null){
Object o = HibernateGeneralDaoImpl.getIgnoreCase(map, "deptid");
if(o != null){
sb.append(",");
sb.append(o.toString());
}
}
}
if(sb.length() > 0){
sb.deleteCharAt(0);
}
String getAllDept = "select * from tabledepartment t where t.deptid in ("+sb.toString()+")";
/* String getAllDept = "select * from tabledepartment t start with t.deptid="+dept.getDeptid()+" connect by prior t.deptid = t.upperlayer";
*/ List deptUpdateLsit = this.commonService.executeSQL(getAllDept,TableDepartment.class);
for(int i=0;i<deptUpdateLsit.size();i++){
TableDepartment td = (TableDepartment)deptUpdateLsit.get(i);
td.setDeptstate("1");
this.commonService.update(td);
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "TABLEDEPARTMENT", "UPDATE",td.getDeptid());
}
}else{
TableDepartment deptForUpdate = (TableDepartment) commonService.get(TableDepartment.class, dept.getDeptid());
deptForUpdate.setDeptname(dept.getDeptname());
deptForUpdate.setUpperlayer(dept.getUpperlayer());
deptForUpdate.setDeptstate(dept.getDeptstate());
this.commonService.update(deptForUpdate);
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "TABLEDEPARTMENT", "UPDATE",deptForUpdate.getDeptid());
}
}
}
outHtmlString("<script type=\"text/javascript\">alert('i18n_DeptManageAction.update.success_n81i');this.location='deptManage!execute.do?action=queryDeptInfo'</script>");
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_DeptManageAction.update.faild_n81i');this.location='deptManage!execute.do?action=queryDeptInfo'</script>");
}
}
// 添加模块信息操作
public void add() {
try {
TableDepartment dptDepartment = new TableDepartment();
dptDepartment.setDeptname(dept.getDeptname());
dptDepartment.setDeptstate(dept.getDeptstate());
if(dept.getUpperlayer()==null){
//dept.setUpperlayer(1l);
dptDepartment.setUpperlayer(1l);
}else{
dptDepartment.setUpperlayer(dept.getDeptid());
}
this.commonService.save(dptDepartment);
// 将添加操作写到操作日志中
this.addDBOperationRpt(commonService, "TABLEDEPARTMENT", "INSERT",dptDepartment.getDeptid());
outHtmlString("<script type=\"text/javascript\">alert('i18n_DeptManageAction.update.success_n81i');this.location='deptManage!execute.do?action=queryDeptInfo'</script>");
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_DeptManageAction.update.faild_n81i');this.location='deptManage!execute.do?action=queryDeptInfo'</script>");
}
}
// // 查询所有部门信息
// public void queryAllDeptInfo() {
// try {
// listDeptInfo = this.commonService
// .find("from TableDepartment order by deptid desc");
// String sqlCondition = "where 1=1";// 将查询条件记录到操作日志中
// // 将查询请求记入到操作日志表中
// this.addDBOperationRpt(commonService, sqlCondition,
// "TableDepartment");
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// 根据用户编号查询用户部门信息,并且所在部门处于选中状态
// public void queryDeptInfoByYhBh() {
// try {
// listDeptInfo = new ArrayList();
// List userDeptList = this.commonService.find(
// "from TableUserDepartment where userid=?", Long
//// .parseLong(yhid.trim()));
//// String sqlCondition = "where userid=" + yhid;// 将查询条件记录到操作日志中
// // 将查询请求记入到操作日志表中
// this.addDBOperationRpt(commonService, sqlCondition,
// "TableUserDepartment");
//
// deptList = this.commonService
// .find("from TableDepartment order by deptid desc");
// for (int j = 0; j < deptList.size(); j++) {
// TableDepartment dept = (TableDepartment) deptList.get(j);
// for (int i = 0; i < userDeptList.size(); i++) {
// TableUserDepartment userDepartment = (TableUserDepartment) userDeptList
// .get(i);
// if (dept.getDeptid().equals(userDepartment.getDeptid())) {
// dept.setIsChecked("isChecked");
// }
// }
// listDeptInfo.add(dept);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
/**
* 部门管理部分
*
* @return
*/
// // 添加部门信息
// public void addDeptInfo() {
// try {
// if (dept.getUpperlayer() == null) {
// dept.setUpperlayer(-1l);
// }
// this.commonService.save(dept);
//
// // 将添加操作写到操作日志中
// this.addDBOperationRpt(commonService, "TABLEDEPARTMENT", "INSERT",
// dept.getDeptid());
//
// this.getRequest().setAttribute("MSG", "1");// 操作成功
// } catch (Exception e) {
// this.getRequest().setAttribute("MSG", "2");// 操作失败
// e.printStackTrace();
// }
// }
// 根据部门编号查询部门信息
// public void queryDeptInfoByid() {
// try {
// deptList = this.commonService.find(
// "from TableDepartment where deptid=?", Long
// .parseLong(deptid.trim()));
//
// String sqlCondition = "where deptid=" + deptid.trim();// 将查询条件记录到操作日志中
// // 将查询请求记入到操作日志表中
// this.addDBOperationRpt(commonService, sqlCondition,
// "TableDepartment");
//
// listDeptInfo = this.commonService
// .find("from TableDepartment order by deptid desc");
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// 进行部门修改信息
// public void doUpdateDeptInfo() {
// try {
// TableDepartment deptNew = (TableDepartment) commonService.get(
// TableDepartment.class, Long.parseLong(deptid.trim()));
// if (dept.getUpperlayer() == null) {
// dept.setUpperlayer(-1l);
// }
// deptNew.setDeptlayer(dept.getDeptlayer());
// deptNew.setDeptname(dept.getDeptname());
// deptNew.setUpperlayer(dept.getUpperlayer());
// this.commonService.update(deptNew);
//
// // 将更新操作写到操作日志中
// this.addDBOperationRpt(commonService, "TABLEDEPARTMENT", "UPDATE",
// dept.getDeptid());
//
// this.getRequest().setAttribute("MSG", "1");
// } catch (Exception e) {
// this.getRequest().setAttribute("MSG", "2");
// e.printStackTrace();
// }
// }
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public List getListDeptInfo() {
return listDeptInfo;
}
public void setListDeptInfo(List listDeptInfo) {
this.listDeptInfo = listDeptInfo;
}
public TableDepartment getDept() {
return dept;
}
public void setDept(TableDepartment dept) {
this.dept = dept;
}
public List getDeptList() {
return deptList;
}
public void setDeptList(List deptList) {
this.deptList = deptList;
}
public String getDeptname() {
return deptname;
}
public void setDeptname(String deptname) {
this.deptname = deptname;
}
}

View File

@@ -0,0 +1,278 @@
/**
* DesktopAction.java
* 版权所有(C) 2010 北京中科智源育成信息技术有限公司
* @author ZhengXi
* @date 2010-11-19
* @version V1.0
*/
package nis.nms.web.actions.desktop;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSession;
import nis.nms.core.MakeTree;
import nis.nms.core.Resource;
import nis.nms.domains.Module;
import nis.nms.domains.XtYhJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.CNToPinyUtils;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@Results( {
@Result(name = "gotoDesktop", value = "/page/desktop/desktop.jsp"),
@Result(name = "thirdItem", value = "/page/desktop/thirdItem.jsp"),
@Result(name = "error", value = "/error.jsp") })
/**
* 桌面系统控制
*/
public class DesktopAction extends BaseAction {
private static final long serialVersionUID = 1L;
private CommonService commonService;
private String pid;
private String secondUrl;
private String bgColors;
private List<Resource> thirdResource=new ArrayList();
private String nodeTitle;
public String getNodeTitle() {
return nodeTitle;
}
public void setNodeTitle(String nodeTitle) {
this.nodeTitle = nodeTitle;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
//初始化桌面菜单的节点
public String getIconModules() {
try {
List<Resource> list = (List<Resource>) getRequest().getSession()
.getAttribute("treeList");
List<Resource> menus = MakeTree.getRootResourceList(list);
int id=Integer.parseInt(this.getRequest().getSession().getAttribute("loginYhid").toString());
String sql="from XtYhJbxx where yhid="+id+"";
List<XtYhJbxx> userInfoList=this.commonService.find(sql);
XtYhJbxx userInfo = (XtYhJbxx)userInfoList.get(0);
List draggRight=new ArrayList();
if(userInfo.getRightMenuItems()!=null&&!"".equals(userInfo.getRightMenuItems())){
String[] all=userInfo.getRightMenuItems().split(",");
if(all!=null&&all.length!=0){
for(int k=0;k<all.length;k++){
draggRight.add(all[k]);
}
}
}
List<Module> mods = new ArrayList<Module>();
for (Resource res : menus) {
Module module = new Module();
module.setId(Integer.valueOf(res.getRsid()));
module.setTitle(res.getRsname());
module.setUrl(res.getRsaddress());
module.setIcon(res.getIconshow());
module.setKey(CNToPinyUtils.cn2FirstSpell(res.getRsname()));
module.setPinyin(CNToPinyUtils.cn2Spell(res.getRsname()));
if(draggRight.contains(module.getTitle())){
}
else{
mods.add(module);
}
}
outJsonArray(mods);
} catch (Exception e) {
e.printStackTrace();
}
// getRequest().getSession().setAttribute("modules",
// JSONArray.fromObject(mods).toString());
//System.out.println(JSONArray.fromObject(mods).toString());
return null;
}
//初始化右边菜单的节点
public String getRightMenuModules() {
try {
List<Resource> list = (List<Resource>) getRequest().getSession()
.getAttribute("treeList");
List<Resource> menus = MakeTree.getRootResourceList(list);
int id=Integer.parseInt(this.getRequest().getSession().getAttribute("loginYhid").toString());
String sql="from XtYhJbxx where yhid="+id+"";
List<XtYhJbxx> userInfoList=this.commonService.find(sql);
XtYhJbxx userInfo = (XtYhJbxx)userInfoList.get(0);
List draggRight=new ArrayList();
if(userInfo.getRightMenuItems()!=null&&!"".equals(userInfo.getRightMenuItems())){
String[] all=userInfo.getRightMenuItems().split(",");
if(all!=null&&all.length!=0){
for(int k=0;k<all.length;k++){
draggRight.add(all[k]);
}
}
}
List<Module> mods = new ArrayList<Module>();
for (Resource res : menus) {
Module module = new Module();
module.setId(Integer.valueOf(res.getRsid()));
module.setTitle(res.getRsname());
module.setUrl(res.getRsaddress());
module.setIcon(res.getIconshow());
module.setKey(CNToPinyUtils.cn2FirstSpell(res.getRsname()));
module.setPinyin(CNToPinyUtils.cn2Spell(res.getRsname()));
if(draggRight.contains(module.getTitle())){
mods.add(module);
}
}
outJsonArray(mods);
} catch (Exception e) {
e.printStackTrace();
}
// getRequest().getSession().setAttribute("modules",
// JSONArray.fromObject(mods).toString());
//System.out.println(JSONArray.fromObject(mods).toString());
return null;
}
public String showthirdItem(){
List<Resource> list = (List<Resource>) getRequest().getSession().getAttribute("treeList");
thirdResource=MakeTree.getotherResourceList(list, pid);
return "thirdItem";
}
//把节点从桌面移向右边菜单
public String addRightMenu(){
HttpSession session = getRequest().getSession(true);
int id=Integer.parseInt(session.getAttribute("loginYhid").toString());
String sql="from XtYhJbxx where yhid="+id+"";
try {
List<XtYhJbxx> userInfoList=this.commonService.find(sql);
XtYhJbxx userInfo = (XtYhJbxx)userInfoList.get(0);
String rigthMenu;
if(userInfo.getRightMenuItems()!=null&&!"".equals(userInfo.getRightMenuItems())){
rigthMenu=userInfo.getRightMenuItems()+nodeTitle+",";
}
else{
rigthMenu=nodeTitle+",";
}
userInfo.setRightMenuItems(rigthMenu);
this.commonService.save(userInfo);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//把节点从右边菜单移向桌面
public String removeRightMenu(){
HttpSession session = getRequest().getSession(true);
int id=Integer.parseInt(session.getAttribute("loginYhid").toString());
String sql="from XtYhJbxx where yhid="+id+"";
try {
List<XtYhJbxx> userInfoList=this.commonService.find(sql);
XtYhJbxx userInfo = (XtYhJbxx)userInfoList.get(0);
String rigthMenu;
if(userInfo.getRightMenuItems()!=null&&!"".equals(userInfo.getRightMenuItems())){
rigthMenu=userInfo.getRightMenuItems().replace(nodeTitle+",", "");
}
else{
rigthMenu=userInfo.getRightMenuItems();
}
userInfo.setRightMenuItems(rigthMenu);
this.commonService.save(userInfo);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//更换皮肤
public String changebgColor(){
HttpSession session = getRequest().getSession(true);
int id=Integer.parseInt(session.getAttribute("loginYhid").toString());
String sql="from XtYhJbxx where yhid="+id+"";
try {
List<XtYhJbxx> userInfoList=this.commonService.find(sql);
XtYhJbxx userInfo = (XtYhJbxx)userInfoList.get(0);
if(bgColors!=null&&!"".equals(bgColors)){
userInfo.setBgColor(bgColors);
}
else{
userInfo.setBgColor("");
}
this.commonService.save(userInfo);
session.setAttribute("userBgColor", userInfo.getBgColor());
} catch (Exception e) {
e.printStackTrace();
}
return "gotoDesktop";
}
public String executeAction() throws Exception {
// TODO Auto-generated method stub
return null;
}
public List<Resource> getThirdResource() {
return thirdResource;
}
public void setThirdResource(List<Resource> thirdResource) {
this.thirdResource = thirdResource;
}
public String getSecondUrl() {
return secondUrl;
}
public void setSecondUrl(String secondUrl) {
this.secondUrl = secondUrl;
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public String getBgColors() {
return bgColors;
}
public void setBgColors(String bgColors) {
this.bgColors = bgColors;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,226 @@
package nis.nms.web.actions.detection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import nis.nms.domains.NodeBoxTable;
import nis.nms.domains.NodeLatticeTable;
import nis.nms.domains.OidDictionary;
import nis.nms.domains.SystemTable;
import nis.nms.domains.TroubleState;
import nis.nms.domains.TypeTable;
import nis.nms.domains.XtYhJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Page;
import org.apache.log4j.Logger;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name="queryOidDictionaryInfo", value = "/page/detection/oidDictionary/oidDictionaryList.jsp"),
@Result(name="addOidDictionary", value = "/page/detection/oidDictionary/addOidDictionary.jsp"),
@Result(name="updateOidDictionary", value = "/page/detection/oidDictionary/updateOidDictionary.jsp"),
@Result(name="detailOidDictionary", value = "/page/detection/oidDictionary/detailOidDictionary.jsp")
})
/**
* 监测设置相关操作
*/
public class OidDictionaryAction extends BaseAction {
private Logger logger = Logger.getLogger(OidDictionaryAction.class);
private static final long serialVersionUID = 1L;
private CommonService commonService;
private int pageNo = 1;
private int pageSize =this.getDefaultPageSize(); //每页显示的记录条数
private Page page;
private String action;
private List<OidDictionary> oidDictionaryList;
private OidDictionary od;
private String odid;
@Override
public String executeAction() throws Exception {
String resultpage = "";
if("query".equals(this.action)){
resultpage = this.queryDictionary();
}else if("openAdd".equals(this.action)){
resultpage = "addOidDictionary";
}else if("doAdd".equals(this.action)){
addOidDictionary();
return null;
}else if("openUpdate".equals(this.action)){
resultpage = this.openUpdOidDictionary();
}else if("doUpdate".equals(this.action)){
doUpdOidDictionary();
return null;
}else{
resultpage = this.queryDictionary();
}
return resultpage;
}
public String queryDictionary(){
try {
//查询oid字典
String oidhql = "from OidDictionary order by id";
page = this.commonService.findByPage(oidhql, pageNo, pageSize);
oidDictionaryList = (List<OidDictionary>)page.getResult();
} catch (Exception e) {
logger.error(e.getStackTrace());
this.outHtmlString("<script>alert('i18n_OidDictionaryAction.queryDictionary.queryDictFaild_n81i');history.back();</script>");
return null;
}
return "queryOidDictionaryInfo";
}
public void addOidDictionary(){
try {
if(checkOid(od.getOid())){
this.commonService.save(od);
// 将添加操作写到操作日志中
this.addDBOperationRpt(commonService, "oid_dictionary", "INSERT",
od.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_OidDictionaryAction.queryDictionary.faild_n81i');this.location='oidDictionary.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
}else{
this.outHtmlString("<script>alert('i18n_OidDictionaryAction.queryDictionary.oidExists_n81i');history.back();</script>");
return;
}
} catch (Exception e) {
logger.error(e.getStackTrace());
this.outHtmlString("<script>alert('i18n_OidDictionaryAction.queryDictionary.addBoxFaild_n81i');history.back();</script>");
return;
}
}
public String openUpdOidDictionary(){
try {
if(odid!=null && !"".equals(odid)){
List list = this.commonService.find(
"from OidDictionary where id=?", Long.parseLong(odid));
if(list!=null && list.size()>0){
od = (OidDictionary)list.get(0);
}
}
} catch (Exception e) {
logger.error(e.getStackTrace());
this.outHtmlString("<script>alert('i18n_OidDictionaryAction.queryDictionary.openUpdateViewFaild_n81i');history.back();</script>");
return null;
}
return "updateOidDictionary";
}
public void doUpdOidDictionary(){
try {
List list = this.commonService.find("from OidDictionary where oid=? and id<>?",
od.getOid().trim(),od.getId());
if (list != null && list.size() > 0){
this.outHtmlString("<script>alert('i18n_OidDictionaryAction.queryDictionary.recordExists_n81i');history.back();</script>");
return;
}
OidDictionary md = (OidDictionary) commonService.get(OidDictionary.class, od
.getId());
md.setOid(od.getOid());
md.setOidDesc(od.getOidDesc());
this.commonService.update(md);
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "oid_dictionary", "UPDATE",
md.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_OidDictionaryAction.queryDictionary.success_n81i');this.location='oidDictionary.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
} catch (Exception e) {
logger.error(e.getStackTrace());
this.outHtmlString("<script>alert('i18n_OidDictionaryAction.queryDictionary.updateFaild_n81i');history.back();</script>");
return;
}
}
public boolean checkOid(String oid){
boolean checkResu = true;
try {
String sql = "select count(*) from oid_dictionary t where oid ='"+oid+"'";
List list = this.commonService.executeSQL(sql);
if(list!=null && list.get(0)!=null){
int num = Integer.parseInt(list.get(0).toString());
if(num>0){
checkResu = false;
}
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return checkResu;
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getOdid() {
return odid;
}
public void setOdid(String odid) {
this.odid = odid;
}
public List<OidDictionary> getOidDictionaryList() {
return oidDictionaryList;
}
public void setOidDictionaryList(List<OidDictionary> oidDictionaryList) {
this.oidDictionaryList = oidDictionaryList;
}
public OidDictionary getOd() {
return od;
}
public void setOd(OidDictionary od) {
this.od = od;
}
}

View File

@@ -0,0 +1,470 @@
package nis.nms.web.actions.detection;
import java.util.List;
import nis.nms.domains.CheckTypeInfo;
import nis.nms.domains.DataPoliceRelation;
import nis.nms.domains.DetectionSetInfo;
import nis.nms.domains.Metadata;
import nis.nms.domains.OptionTable;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Page;
import org.apache.log4j.Logger;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name = "queryPoliceRelationInfo", value = "/page/detection/policeRelation/policeRelationList.jsp"),
@Result(name = "addPoliceRelation", value = "/page/detection/policeRelation/addPoliceRelation.jsp"),
@Result(name = "updatePoliceRelation", value = "/page/detection/policeRelation/updatePoliceRelation.jsp"),
@Result(name = "error", value = "/error.jsp") })
/**
* 报警设置相关操作
*/
public class PoliceSetAction extends BaseAction {
private Logger logger = Logger.getLogger(PoliceSetAction.class);
private static final long serialVersionUID = 1L;
private CommonService commonService;
private int pageNo = 1;
private int pageSize = this.getDefaultPageSize(); // 每页显示的记录条数
private Page page;
private String action;
private List<DataPoliceRelation> dataPoliceRelationList;
private DataPoliceRelation dataPoliceRelation;
private Metadata metadata;
private List<Metadata> allMetadata;
private List<OptionTable> allpoliceEmergent;
private List<CheckTypeInfo> allCheckTypeInfo;
private Long[] ids;
private Long setId;
private String ctn;
private String pIden;
private String ip;
private CheckTypeInfo checkTypeInfo;
private DetectionSetInfo detectionSetInfo;
private String detectionSetInfoId;
private String policeRelationId;
public String getPIden() {
return pIden;
}
public void setPIden(String iden) {
pIden = iden;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getDetectionSetInfoId() {
return detectionSetInfoId;
}
public void setDetectionSetInfoId(String detectionSetInfoId) {
this.detectionSetInfoId = detectionSetInfoId;
}
public String getCtn() {
return ctn;
}
public void setCtn(String ctn) {
this.ctn = ctn;
}
public String getpIden() {
return pIden;
}
public void setpIden(String pIden) {
this.pIden = pIden;
}
@Override
public String executeAction() throws Exception {
String resultpage = "";
if ("query".equals(this.action)) {
queryCheckTypeInfo();
resultpage = this.queryPoliceSetInfo();
} else if ("openAdd".equals(this.action)) {
this.getDetectionSetInfoAndMetadata();
resultpage = "addPoliceRelation";
} else if ("doAdd".equals(this.action)) {
addPoliceSetInfo();
return null;
} else if ("openUpdate".equals(this.action)) {
this.getDetectionSetInfoAndMetadata();
resultpage = this.openUpdatePoliceSet();
} else if ("doUpdate".equals(this.action)) {
doUpdatePoliceSet();
return null;
} else {
resultpage = this.queryPoliceSetInfo();
}
return resultpage;
}
public String queryPoliceSetInfo() {
try {
String operator="all";// 用于判断查询设置告警是从监测设置告警页面进入还是监测配置下进入 从监测设置告警页面进入值为all查询所有告警 监测配置下进入只查询当前监测的告警
String hql = "from DataPoliceRelation where 1=1";
if (setId != null && !"".equals(setId)) {
operator = "";
hql +=" and detectionSetInfo.id="+ setId;
}
if (ctn != null && !"".equals(ctn)) {
hql +=" and detectionSetInfo.checkTypeInfo.id = " + ctn;
}
if (pIden != null && !"".equals(pIden)) {
hql +=" and Upper(detectionSetInfo.processIdenName) like '%" + pIden.trim().toUpperCase() + "%'";
}
if (this.getAdminMark()) {// 如果是admin登陆则无限制
hql +=" and detectionSetInfo.checkTypeInfo.isSchedule<>2";
} else {
//使用监测设置权限
hql +=" and detectionSetInfo.checkTypeInfo.isSchedule<>2 and (( detectionSetInfo.viewLevel=1 and detectionSetInfo.createUserId=";
hql +=this.getUserID();
hql +=" and detectionSetInfo.systemId ="+this.getSystemID()+")";
hql +=" or ( detectionSetInfo.viewLevel=2 and detectionSetInfo.createUserGroupId in (select x.jsbh from XtYhJsIndex x where x.yhbh='";
hql +=this.getUser().getYhbh();
hql +="' and x.type = 1) and detectionSetInfo.systemId = "+this.getSystemID()+") or (detectionSetInfo.viewLevel=3 and detectionSetInfo.systemId = "+this.getSystemID()+")";
//hql +=" or (detectionSetInfo.viewLevel=4 )";
hql +=") ";
}
hql +="order by policeState asc";
page = this.commonService.findByPage(hql, pageNo, pageSize);
dataPoliceRelationList = (List<DataPoliceRelation>) page
.getResult();
getRequest().setAttribute("operator", operator);
} catch (Exception e) {
logger.error(e.getStackTrace());
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_PoliceSetAction.queryPoliceSetInfo.faild_n81i');this.location='detectionSet.do?action=query'</script>");
}
return "queryPoliceRelationInfo";
}
private void queryCheckTypeInfo() throws Exception {
try {
StringBuffer hql = new StringBuffer();
if (this.getAdminMark()) {// 如果是admin登陆则无限制
hql.append("from CheckTypeInfo where isSchedule<>2 ");
} else {
//权限控制--------begin
hql.append("from CheckTypeInfo t where isSchedule<>2 and (( t.viewLevel=1 and t.userId=");
hql.append(this.getUserID());
hql.append(" and t.systemId ="+this.getSystemID()+")");
hql.append(" or ( t.viewLevel=2 and t.groupId in (select x.jsbh from XtYhJsIndex x where x.yhbh='");
hql.append(this.getUser().getYhbh());
hql.append("' and x.type = 1) and t.systemId = "+this.getSystemID()+") or (t.viewLevel=3 and t.systemId = "+this.getSystemID()+")");
hql.append(" or (t.viewLevel=4 )");
hql.append(") ");
//----------------end
}
hql.append(" and creteState = 0 order by decode(isSchedule,0,0,2,0,1,1,2) asc ,decode(isSnmp,2,0,null,0,1) asc, ID asc");
allCheckTypeInfo = this.commonService.find(hql.toString());
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getStackTrace());
}
}
public void getDetectionSetInfoAndMetadata()throws Exception {
try {
if (setId != null && !"".equals(setId)) {
List list = this.commonService.find(
"from DetectionSetInfo where id=?", setId);
if (list != null && list.size() > 0) {
detectionSetInfo = (DetectionSetInfo) list.get(0);
allMetadata = this.commonService.find(
"from Metadata where checkTypeInfo.id=?",
detectionSetInfo.getCheckTypeInfo().getId());
allpoliceEmergent = this.commonService.find(
"from OptionTable where typeIdentity='emergent'");;
}
} else if (ids != null && !"".equals(ids)) {
List<DataPoliceRelation> datapolicerelationList = this.commonService
.find("from DataPoliceRelation where id = ?", ids[0]);
if (datapolicerelationList != null
&& datapolicerelationList.size() > 0) {
long setId = datapolicerelationList.get(0)
.getDetectionSetInfo().getId();
List list = this.commonService.find(
"from DetectionSetInfo where id=?", setId);
if (list != null && list.size() > 0) {
detectionSetInfo = (DetectionSetInfo) list.get(0);
allMetadata = this.commonService.find(
"from Metadata where checkTypeInfo.id=?",
detectionSetInfo.getCheckTypeInfo().getId());
allpoliceEmergent = this.commonService
.find("from OptionTable where typeIdentity='emergent'");
}
}
}
} catch (Exception e) {
logger.error(e.getStackTrace());
e.printStackTrace();
}
}
// 新增
public void addPoliceSetInfo() throws Exception{
DetectionSetInfo dsi = null;
try {
String sql = "select count(*) from data_police_relation t where DETECTION_SET_INFO_ID ="
+ setId
+ " and METADATA_ID ="
+ dataPoliceRelation.getMetadata().getId();
List list = this.commonService.executeSQL(sql);
int num = Integer.parseInt(list.get(0).toString());
if (num > 0) {
this.outHtmlString("<script>alert('i18n_PoliceSetAction.queryPoliceSetInfo.recordExists_n81i');this.location='policeSet.do?action=query&pIden="+pIden+"&ctn="+ctn+"&ip="+ip+"&pageNo="+pageNo+"&pageSize="+pageSize+"&setId="+setId+"'</script>");
return;
}
Metadata metadata = (Metadata) this.commonService.get(
Metadata.class, dataPoliceRelation.getMetadata().getId());
dsi = (DetectionSetInfo) this.commonService.get(DetectionSetInfo.class, setId);
dataPoliceRelation.setMetadata(metadata);
dataPoliceRelation.setDetectionSetInfo(dsi);
this.commonService.save(dataPoliceRelation);
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService,"data_police_relation", "INSERT", dataPoliceRelation.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_PoliceSetAction.queryPoliceSetInfo.success_n81i');this.location='policeSet.do?action=query&pIden="+pIden+"&ctn="+ctn+"&ip="+ip+"&pageNo="+pageNo+"&pageSize="+pageSize+"&setId="+setId+"'</script>");
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getStackTrace());
outHtmlString("<script type=\"text/javascript\">alert('i18n_PoliceSetAction.queryPoliceSetInfo.faild_n81i');this.location='policeSet.do?action=query&pIden="+pIden+"&ctn="+ctn+"&ip="+ip+"&pageNo="+pageNo+"&pageSize="+pageSize+"&setId="+setId+"'</script>");
}
sendSetInfo(null,dsi,commonService);
}
public String openUpdatePoliceSet() {
try {
if (ids != null && ids.length > 0) {
policeRelationId=String.valueOf(ids[0]);
List list = this.commonService.find(
"from DataPoliceRelation where id=?", ids[0]);
if (list != null && list.size() > 0) {
dataPoliceRelation = (DataPoliceRelation) list.get(0);
}
}
} catch (Exception e) {
logger.error(e.getStackTrace());
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_PoliceSetAction.queryPoliceSetInfo.faild_n81i');this.location='detectionSet.do?action=query'</script>");
}
return "updatePoliceRelation";
}
public void doUpdatePoliceSet() throws Exception{
try {
List list = this.commonService
.find(
"from DataPoliceRelation where detectionSetInfo.id=? and metadata.id=? and id<>?",
Long.valueOf(detectionSetInfoId), dataPoliceRelation.getMetadata().getId(), dataPoliceRelation
.getId());
if (list != null && list.size() > 0) {
this.outHtmlString("<script>alert('i18n_PoliceSetAction.queryPoliceSetInfo.recordExists_n81i');this.location='policeSet.do?action=openUpdate&ids="+policeRelationId+"&detectionSetInfoId="+detectionSetInfoId+"'</script>");
return;
}
DataPoliceRelation dpRelation = (DataPoliceRelation) this.commonService
.get(DataPoliceRelation.class, dataPoliceRelation.getId());
DetectionSetInfo ds = null;
if(null!=detectionSetInfoId&&!detectionSetInfoId.equals("")){
ds = (DetectionSetInfo) this.commonService.get(
DetectionSetInfo.class, Long.parseLong(detectionSetInfoId.trim()));
}else{
ds = (DetectionSetInfo) this.commonService.get(
DetectionSetInfo.class, setId);
}
Metadata me = (Metadata) this.commonService.get(Metadata.class,
dataPoliceRelation.getMetadata().getId());
dpRelation.setPoliceState(dataPoliceRelation.getPoliceState());
dpRelation.setPoliceLevel(dataPoliceRelation.getPoliceLevel());
dpRelation.setPoliceValue(dataPoliceRelation.getPoliceValue());
dpRelation.setPoliceUnit(dataPoliceRelation.getPoliceUnit());
dpRelation.setPoliceSymbols(dataPoliceRelation.getPoliceSymbols());
dpRelation.setDetectionSetInfo(ds);
dpRelation.setPoliceShowInfo(dataPoliceRelation.getPoliceShowInfo());
dpRelation.setMetadata(me);
dpRelation.setPoliceEmergent(dataPoliceRelation.getPoliceEmergent());
dpRelation.setMarker(dataPoliceRelation.getMarker());
dpRelation.setMarkerFiledId(dataPoliceRelation.getMarkerFiledId());
this.commonService.update(dpRelation);
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService,"data_police_relation", "UPDATE", dpRelation.getId());
sendSetInfo(null,ds,commonService);
String setIdStr = "";
if(setId != null){
setIdStr = "&setId="+setId;
}
String str = "<script type=\"text/javascript\">alert('i18n_PoliceSetAction.queryPoliceSetInfo.success_n81i');this.location='policeSet.do?action=query&pIden="+pIden+"&ctn="+ctn+"&ip="+ip+"&pageNo="+pageNo+"&pageSize="+pageSize+setIdStr+"'</script>";
outHtmlString(str);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getStackTrace());
String setIdStr = "";
if(setId != null){
setIdStr = "&setId="+setId;
}
String str = "<script type=\"text/javascript\">alert('i18n_PoliceSetAction.queryPoliceSetInfo.faild_n81i');this.location='policeSet.do?action=query&pIden="+pIden+"&ctn="+ctn+"&ip="+ip+"&pageNo="+pageNo+"&pageSize="+pageSize+setIdStr+"'</script>";
outHtmlString(str);
}
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public List<CheckTypeInfo> getAllCheckTypeInfo() {
return allCheckTypeInfo;
}
public void setAllCheckTypeInfo(List<CheckTypeInfo> allCheckTypeInfo) {
this.allCheckTypeInfo = allCheckTypeInfo;
}
public Long[] getIds() {
return ids;
}
public List<Metadata> getAllMetadata() {
return allMetadata;
}
public List<OptionTable> getAllpoliceEmergent() {
return allpoliceEmergent;
}
public void setAllpoliceEmergent(List<OptionTable> allpoliceEmergent) {
this.allpoliceEmergent = allpoliceEmergent;
}
public void setAllMetadata(List<Metadata> allMetadata) {
this.allMetadata = allMetadata;
}
public DetectionSetInfo getDetectionSetInfo() {
return detectionSetInfo;
}
public void setIds(Long[] ids) {
this.ids = ids;
}
public CheckTypeInfo getCheckTypeInfo() {
return checkTypeInfo;
}
public void setCheckTypeInfo(CheckTypeInfo checkTypeInfo) {
this.checkTypeInfo = checkTypeInfo;
}
public Metadata getMetadata() {
return metadata;
}
public void setMetadata(Metadata metadata) {
this.metadata = metadata;
}
public List<DataPoliceRelation> getDataPoliceRelationList() {
return dataPoliceRelationList;
}
public void setDataPoliceRelationList(
List<DataPoliceRelation> dataPoliceRelationList) {
this.dataPoliceRelationList = dataPoliceRelationList;
}
public DataPoliceRelation getDataPoliceRelation() {
return dataPoliceRelation;
}
public void setDataPoliceRelation(DataPoliceRelation dataPoliceRelation) {
this.dataPoliceRelation = dataPoliceRelation;
}
public void setDetectionSetInfo(DetectionSetInfo detectionSetInfo) {
this.detectionSetInfo = detectionSetInfo;
}
public Long getSetId() {
return setId;
}
public void setSetId(Long setId) {
this.setId = setId;
}
public Logger getLogger() {
return logger;
}
public void setLogger(Logger logger) {
this.logger = logger;
}
public String getPoliceRelationId() {
return policeRelationId;
}
public void setPoliceRelationId(String policeRelationId) {
this.policeRelationId = policeRelationId;
}
}

View File

@@ -0,0 +1 @@
Element_batchNodeFigureInfo = nis.nms.domains.NodeFigureInfo

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,229 @@
package nis.nms.web.actions.download;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import nis.nms.util.BaseAction;
import org.apache.commons.lang.StringUtils;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name="error", value ="/error.jsp")
})
public class DownLoadFileAction extends BaseAction {
/**
*
*/
private static final long serialVersionUID = 1L;
private String file;
private String backPathStr;
/**
* 下载结果文件
* @return
*/
public void download() {
String path = getServletContext().getRealPath("/")+"/" +file;
InputStream fis = null;
OutputStream os =null;
try{
File file = new File(path);// path是根据日志路径和文件名拼接出来的
String filename = file.getName();// 获取日志文件名称
fis = new BufferedInputStream(new FileInputStream(path));
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
getResponse().reset();
// 先去掉文件名称中的空格,然后转换编码格式为utf-8,保证不出现乱码,这个文件名称用于浏览器的下载框中自动显示的文件名
getResponse().addHeader("Content-Disposition", "attachment;filename=" + new String(filename.replaceAll(" ", "").getBytes("utf-8"),"iso8859-1"));
getResponse().addHeader("Content-Length", "" + file.length());
os = new BufferedOutputStream(getResponse().getOutputStream());
getResponse().setContentType("application/octet-stream");
os.write(buffer);// 输出文件
}catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_DownLoadFileAction.downloadDevPic.noFile_n81i');history.go(-1);</script>");
}finally{
try {
fis.close();
os.flush();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/*public String download() {
FileInputStream fis = null;
BufferedInputStream bis = null;
OutputStream fos = null;
BufferedOutputStream bos = null;
try {
String path = getServletContext().getRealPath("/")+"/" +file;
File uploadFile = new File(path);
if (!uploadFile.exists()) {
this.outHtmlString("<script>alert('下载文件已转移或已删除!');history.back();</script>");
return null;
}
fis = new FileInputStream(uploadFile);
bis = new BufferedInputStream(fis);
fos = getResponse().getOutputStream();
bos = new BufferedOutputStream(fos);
String titlePath=new String((path.substring(path.lastIndexOf("\\")+1, path.length())).getBytes());
getResponse().setContentType("application/octec-stream");
getResponse().setHeader("Content-disposition",
"attachment;filename=" +
URLEncoder.encode(titlePath, "utf-8"));
int bytesRead = 0;
//同上传类似使用输入输出流这里用的是缓冲输入输出流
byte[] buffer = new byte[1024];
while ((bytesRead = bis.read(buffer, 0, 1024)) != -1) {
bos.write(buffer, 0, bytesRead);
}
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('文件不存在');history.go(-1);</script>");
return null;
}
finally{
try {
bos.flush();
fis.close();
bis.close();
fos.close();
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}*/
public String downloadDevPic() {
try {
String path = getServletContext().getRealPath("/")+"/" +file;
File uploadFile = new File(path);
if (!uploadFile.exists()) {
if(StringUtils.isNotBlank(backPathStr)) {
this.outHtmlString("<script>alert('i18n_DownLoadFileAction.downloadDevPic.downloadFileIsnull_n81i');this.location='"+backPathStr+"';</script>");
}else {
this.outHtmlString("<script>alert('i18n_DownLoadFileAction.downloadDevPic.downloadFileIsnull_n81i');history.back();</script>");
}
return null;
}
FileInputStream fis = new FileInputStream(uploadFile);
BufferedInputStream bis = new BufferedInputStream(fis);
OutputStream fos = getResponse().getOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(fos);
String titlePath = file;
if(file.contains("\\")) {
titlePath=new String((file.substring(file.lastIndexOf("\\")+1, file.length())).getBytes());
}else if(file.contains("/")){
titlePath=new String((file.substring(file.lastIndexOf("/")+1, file.length())).getBytes());
}
getResponse().setContentType("application/octec-stream");
getResponse().setHeader("Content-disposition",
"attachment;filename=" +
URLEncoder.encode(titlePath, "utf-8"));
int bytesRead = 0;
//同上传类似使用输入输出流这里用的是缓冲输入输出流
byte[] buffer = new byte[8192];
while ((bytesRead = bis.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.flush();
fis.close();
bis.close();
fos.close();
bos.close();
} catch (Exception e) {
e.printStackTrace();
if(StringUtils.isNotBlank(backPathStr)) {
outHtmlString("<script type=\"text/javascript\">alert('i18n_DownLoadFileAction.downloadDevPic.noFile_n81i');this.location='"+backPathStr+"';</script>");
}else {
outHtmlString("<script type=\"text/javascript\">alert('i18n_DownLoadFileAction.downloadDevPic.noFile_n81i');history.go(-1);</script>");
}
return null;
}
return null;
}
/**
* 远程连接
* 1、流程先查看是否有指定操作系统类型
* A、有直接连接Linux下用putty.exe(检查文件是否存在,不存在提供下载),Windows下用mstsc远程桌面
* B、没有提示选择操作系统类型
* 2、操作步骤
* A、在调用远程连接之前要在原有的SQL基础上添加对note_table的node_system_type的查询
* B、在调用远程连接的页面include引入/common/remoteConn.jsp页面
* C、在相应IP连接处调用JS--romoteConn(nodeSysType,ip)
* @return
*/
public String remoteConn() {
try {
String sysType = this.getRequest().getParameter("sysType");//操作系统类型
String ip = this.getRequest().getParameter("ip");//远程连接的节点IP
if (sysType != null && !"".equals(sysType)) {
String cmd = null;
if ("1".equals(sysType)) {// 1 Linux
File file = new File("D:\\putty.EXE");
if(!file.exists()){
this.outHtmlString("i18n_DownLoadFileAction.downloadDevPic.toDownload_n81i<a href='javascript:download(\"putty.exe\");'>putty.exe</a>i18n_DownLoadFileAction.downloadDevPic.saveToD_n81i");
return null;
}
cmd = "D:\\putty.EXE " + ip;
} else if ("2".equals(sysType)) {// 2 Windows
cmd = "mstsc /v " + ip;
} else {//其他
cmd = "telnet " + ip;
}
String[] cmdArr = new String[] { "cmd.exe", "/C", cmd };
Runtime.getRuntime().exec(cmdArr);
}
} catch (Exception e) {
e.printStackTrace();
}
this.outHtmlString("");
return null;
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
@Override
public String executeAction() throws Exception {
// TODO Auto-generated method stub
return null;
}
public String getBackPathStr()
{
return backPathStr;
}
public void setBackPathStr(String backPathStr)
{
this.backPathStr = backPathStr;
}
}

View File

@@ -0,0 +1,434 @@
package nis.nms.web.actions.functionManager;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import nis.nms.domains.XtMkJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Page;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import com.nis.util.StringUtil;
@SuppressWarnings("unchecked")
@Results( {
@Result(name = "ok", value = "/page/function/mkInfoList.jsp")
})
public class FunctionManagerAction extends BaseAction {
private static final long serialVersionUID = -2875856570815151046L;
private String action = "";
private XtMkJbxx module;// 保存模块信息
private String pmkmc;
private List allMkInfo = new ArrayList();// 保存所有模块信息
private Page page;
private int pageNo = 1;
private int pageSize = this.getDefaultPageSize(); // 每页显示的记录条数
private String mkmc;// 模块名称
private String mkid;// 模块ID
private String mkms;// 模块描述
private CommonService commonService;
private String sort;
private String pid;
public String executeAction(){
String result = "ok";
try {
if ("update".equals(action)) {
result = updateMk();
}
if("add".equals(this.action)){
result = addMk();
}
if("del".equals(this.action)){
result = delMk();
}
allMkInfo = this.commonService.find("from XtMkJbxx where 1=1 order by showlevel, showorder");
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
// 进行修改模块信息操作
public String updateMk() {
XtMkJbxx xt = null;
List<XtMkJbxx> newFunctionlists = null;
try {
// 判断是否是修改排序
if (sort != null) {
// 上升
if ("up".equals(sort)) {
//更新上一个将上一个的showOrder set 自己的showOrder
newFunctionlists = getXtMkJbxxListByParam(null, module.getPid(), module.getShoworder()-1);
if (!StringUtil.isEmpty(newFunctionlists)) {//判断是否存在上一个,如果不存在不更新自己的序号
xt = newFunctionlists.get(0);
// 修改排序
if (xt.getShoworder()!= null) {
xt.setShoworder(module.getShoworder());
}
commonService.update(xt);
//更新自己将自己的showOrder-1
newFunctionlists = getXtMkJbxxListByParam(module.getId(), module.getPid(),null);
if (!StringUtil.isEmpty(newFunctionlists)) {
xt = newFunctionlists.get(0);
// 修改排序
if (xt.getShoworder()!=null) {
xt.setShoworder(module.getShoworder()-1);
}
commonService.update(xt);
}
}else{
//outHtmlString("<script type=\"text/javascript\">alert('此模块已排在首位,无法上移');this.location='functionManager.do?action=queryMkInfo'</script>");
outHtmlString("3");
return null;
}
} else {
// 下降
//更新下一个将下一个的showOrder set 自己的showOrder
newFunctionlists = getXtMkJbxxListByParam(null, module.getPid(), module.getShoworder()+1);
if (!StringUtil.isEmpty(newFunctionlists)) {
xt = newFunctionlists.get(0);
// 修改排序
if (xt.getShoworder()!= null) {
xt.setShoworder(module.getShoworder());
}
commonService.update(xt);
//更新自己将自己的showOrder+1
newFunctionlists = getXtMkJbxxListByParam(module.getId(), module.getPid(),null);
if (!StringUtil.isEmpty(newFunctionlists)) {
xt = newFunctionlists.get(0);
// 修改排序
if (xt.getShoworder()!=null) {
xt.setShoworder(module.getShoworder()+1);
}
commonService.update(xt);
}
}else{
//outHtmlString("<script type=\"text/javascript\">alert('此模块已排在最后,无法下移');this.location='functionManager.do?action=queryMkInfo'</script>");
outHtmlString("4");
return null;
}
}
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "XT_MK_JBXX", "UPDATE_SHOWORDER",module.getId());
//outHtmlString("<script type=\"text/javascript\">alert('操作成功,请重新登录'); window.location='<%=path%>/login.do?type=refresh';window.location.reload;</script>");
outHtmlString("1");
return null;
}else{
updateMKInfo();
}
} catch (Exception e) {
e.printStackTrace();
outHtmlString("2");
//outHtmlString("<script type=\"text/javascript\">alert('操作失败');this.location='functionManager.do?action=queryMkInfo'</script>");
return null;
}
return null;
}
//根据参数获取功能节点信息,pid父节点,id功能ID,showOrder排序
public List getXtMkJbxxListByParam(Long id,Long pid,Long showOrder) throws Exception{
List funList = new ArrayList();
String sql = "from XtMkJbxx n where 1=1 ";
if(id!=null){
sql += " and n.id="+id;
}
if(pid!=null){
sql += " and n.pid="+ pid;
}
// if(!StringUtil.isBlank(fclevels)){
// sql += " and n.fclevels='" + fclevels + "'";
// }
if(showOrder!=null){
sql += " and n.showorder='" + showOrder + "'";
}
funList = this.commonService.find(sql);
return funList;
}
public String updateMKInfo(){
try {
XtMkJbxx md = (XtMkJbxx) commonService.get(XtMkJbxx.class, module
.getId());
md.setMkmc(module.getMkmc());
if(module.getMktype()!=1){ //菜单
md.setMkurl(module.getMkurl());
md.setHandler(null);
}else{ //按钮
md.setHandler(module.getHandler());
md.setMkurl(null);
}
md.setMkms(module.getMkms());
md.setZxbz(module.getZxbz());
md.setMktype(module.getMktype());//0代表菜单 1代表按钮
md.setShowlevel(module.getShowlevel());
md.setShoworder(module.getShoworder());
//更新子模块为无效
if(module.getZxbz().equals("1")){//无效状态
List allChildMk = this.commonService.find("from XtMkJbxx where pid="+module.getId());
if(allChildMk!=null && allChildMk.size()>0){
for(int i=0;i<allChildMk.size();i++){
XtMkJbxx mk = (XtMkJbxx)allChildMk.get(i);
mk.setZxbz("1");
this.commonService.update(mk);
}
}
}
//更新父模块
this.commonService.update(md);
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "XT_MK_JBXX", "UPDATE",module.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_FunctionManagerAction.updateMKInfo.success_n81i');this.location='functionManager.do?action=queryMkInfo'</script>");
return null;
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_FunctionManagerAction.updateMKInfo.faild_n81i');this.location='functionManager.do?action=queryMkInfo'</script>");
return null;
}
}
// 添加模块信息操作
public String addMk() {
try {
if(module.getPid()==null){
module.setPid(0l);
}
if(!module.getMktype().equals(1l)){ //菜单
module.setHandler(null);
}else{ //按钮
module.setMkurl(null);
}
module.setCtime(new Date());
module.setShowarea(0l);
this.commonService.save(module);
// 将添加操作写到操作日志中
this.addDBOperationRpt(commonService, "XT_MK_JBXX", "INSERT",module.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_FunctionManagerAction.updateMKInfo.success_n81i');this.location='functionManager.do?action=queryMkInfo'</script>");
return null;
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_FunctionManagerAction.updateMKInfo.faild_n81i');this.location='functionManager.do?action=queryMkInfo'</script>");
return null;
}
}
// 注销模块信息操作
public String delMk() {
try {
XtMkJbxx md = (XtMkJbxx) commonService.get(XtMkJbxx.class, module.getId());
md.setZxbz("1");
this.commonService.update(md);
// 将添加操作写到操作日志中
this.addDBOperationRpt(commonService, "XT_MK_JBXX", "UPDATE",
module.getId());
this.addDBOperationRpt(commonService, "XT_MK_JBXX", "INSERT",module.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_FunctionManagerAction.updateMKInfo.success_n81i');this.location='functionManager.do?action=queryMkInfo'</script>");
return null;
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_FunctionManagerAction.updateMKInfo.faild_n81i');this.location='functionManager.do?action=queryMkInfo'</script>");
return null;
}
}
public String getMaxShowOrder(){
String jsonStr = null;
List maxList = null;
Long maxShow=0l;
try {
if("".equals(pid)){//主节点
pid="0";
}
String sql="select max(showorder) from xt_mk_jbxx t where pid="+pid;
maxList = commonService.executeSQL(sql);
if(maxList!=null&&maxList.size()>0){
if(maxList.get(0)!=null){
maxShow = Long.parseLong(maxList.get(0).toString())+1;
}else{
maxShow = 1l;
}
}
jsonStr = "{\"maxShowOrder\":\"" + maxShow + "\"}";
this.outJson(jsonStr);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
// 查询模块信息
public String queryMkInfo() {
try {
String sql = "from XtMkJbxx where 1=1 ";
String sqlCondition = "where 1=1";// 将查询条件记录到操作日志中
if (mkmc != null && !"".equals(mkmc)) {
sql += " and mkmc like '%" + mkmc + "%'";
sqlCondition += " and mkmc like '%" + mkmc + "%'";
}
if (mkms != null && !"".equals(mkms)) {
sql += " and mkms like '%" + mkms + "%'";
sqlCondition += " and mkms like '%" + mkms + "%'";
}
if(pmkmc!=null&&!"".equals(pmkmc)){
sql += " and pid in (select id from XtMkJbxx x where x.mkmc like '%"+pmkmc+"%')";
sqlCondition += " and pid in (select id from XtMkJbxx x where x.mkmc like '%"+pmkmc+"%')";
}
sql += "order by showlevel, showorder";
allMkInfo = this.commonService.find(sql);
// 将查询请求记入到操作日志表中
this.addDBOperationRpt(commonService, sqlCondition, "xt_mk_jbxx");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return "ok";
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public String getMkmc() {
return mkmc;
}
public void setMkmc(String mkmc) {
this.mkmc = mkmc;
}
public List getAllMkInfo() {
return allMkInfo;
}
public void setAllMkInfo(List allMkInfo) {
this.allMkInfo = allMkInfo;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public String getMkms() {
return mkms;
}
public void setMkms(String mkms) {
this.mkms = mkms;
}
public String getPmkmc() {
return pmkmc;
}
public void setPmkmc(String pmkmc) {
this.pmkmc = pmkmc;
}
public String getMkid() {
return mkid;
}
public void setMkid(String mkid) {
this.mkid = mkid;
}
public XtMkJbxx getModule() {
return module;
}
public void setModule(XtMkJbxx module) {
this.module = module;
}
public String getSort() {
return sort;
}
public void setSort(String sort) {
this.sort = sort;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
}

View File

@@ -0,0 +1,233 @@
package nis.nms.web.actions.logs;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import nis.nms.domains.TableDBOperationRpt;
import nis.nms.domains.TableLoginRpt;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Page;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name="login", value = "/page/logs/loginlogs.jsp"),
@Result(name="operate", value = "/page/logs/operatelogs.jsp"),
@Result(name="error", value ="/error.jsp")
})
public class LogsAction extends BaseAction {
/**
*
*/
private static final long serialVersionUID = 1L;
private CommonService commonService=null;
private int pageNo = 1;//当前页
private int pageSize = getDefaultPageSize(); //每页显示的记录条数
private Page page;
private List<TableLoginRpt> loginList = null;
private List<TableDBOperationRpt> actionList = null;
private String username;
private Date startTime;
private Date endTime;
private String logsaction;
private String position;
private String module;
@Override
public String executeAction() throws Exception {
// TODO Auto-generated method stub
return this.login();
}
public String login () {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = "";
String sql = "from TableLoginRpt ";
boolean haswhere = false;
if (username != null && !"".equals(username))
if(haswhere)
sql+= " and username='" + username+"'";
else{
sql += "where username='"+ username+"'";
haswhere = true;
}
if(logsaction!=null&&!"".equals(logsaction)){
if(haswhere)
sql +=" and action='"+ logsaction+"'";
else{
sql += "where action='"+ logsaction+"'";
haswhere = true;
}
}
if (startTime != null && !"".equals(startTime)) {
date = format.format(startTime);
if(haswhere)
sql += " and time>=to_date('" + date
+ "','yyyy-MM-dd hh24-mi-ss')";
else{
sql+= "where time>=to_date('" + date
+ "','yyyy-MM-dd hh24-mi-ss')";
haswhere = true;
}
}
if (endTime != null && !"".equals(endTime)) {
date = format.format(endTime);
if(haswhere)
sql += " and time<=to_date('" + date
+ "','yyyy-MM-dd hh24-mi-ss')";
else{
sql+= "where time>=to_date('" + date
+ "','yyyy-MM-dd hh24-mi-ss')";
haswhere = true;
}
}
sql +=" order by id desc";
page = this.commonService.findByPage(sql, pageNo, pageSize);
loginList = (List<TableLoginRpt>) page.getResult();
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return "login";
}
public String operate() {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = "";
String sql = "from TableDBOperationRpt ";
boolean haswhere = false;
if (username != null && !"".equals(username))
if(haswhere)
sql+= " and username='" + username+"'";
else{
sql += "where username='"+ username+"'";
haswhere = true;
}
if(logsaction!=null&&!"".equals(logsaction)){
if(haswhere)
sql +=" and action='"+ logsaction+"'";
else{
sql += "where action='"+ logsaction+"'";
haswhere = true;
}
}
if (startTime != null && !"".equals(startTime)) {
date = format.format(startTime);
if(haswhere)
sql += " and time>=to_date('" + date
+ "','yyyy-MM-dd hh24-mi-ss')";
else{
sql+= "where time>=to_date('" + date
+ "','yyyy-MM-dd hh24-mi-ss')";
haswhere = true;
}
}
if (endTime != null && !"".equals(endTime)) {
date = format.format(endTime);
if(haswhere)
sql += " and time<=to_date('" + date
+ "','yyyy-MM-dd hh24-mi-ss')";
else{
sql+= "where time>=to_date('" + date
+ "','yyyy-MM-dd hh24-mi-ss')";
haswhere = true;
}
}
sql +=" order by id desc";
page = this.commonService.findByPage(sql, pageNo, pageSize);
actionList = (List<TableDBOperationRpt>) page.getResult();
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return "operate";
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public void setUsername(String _username){
username = _username;
}
public String getUsername(){
return username;
}
public void setStartTime(Date _starttime){
startTime = _starttime;
}
public Date getStartTime(){
return startTime;
}
public void setEndTime(Date _endtime){
endTime = _endtime;
}
public Date getEndTime(){
return endTime;
}
public void setLogsaction(String _action){
logsaction = _action;
}
public String getLogsaction(){
return logsaction;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getModule() {
return module;
}
public void setModule(String module) {
this.module = module;
}
public void setLoginList(List<TableLoginRpt> loginList){
this.loginList = loginList;
}
public List<TableLoginRpt> getLoginList(){
return loginList;
}
public void setActionList(List<TableDBOperationRpt> actionList){
this.actionList = actionList;
}
public List<TableDBOperationRpt> getActionList(){
return actionList;
}
}

View File

@@ -0,0 +1,377 @@
package nis.nms.web.actions.mission;
import java.util.ArrayList;
import java.util.List;
import nis.nms.domains.MissionParameterDefaults;
import nis.nms.domains.MissionParameterTable1;
import nis.nms.domains.MissionParameterTable2;
import nis.nms.domains.MissionStateTable;
import nis.nms.domains.NodegroupTable;
import nis.nms.domains.SystemTable;
import nis.nms.domains.XtJsJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Constant;
import nis.nms.util.Page;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name="select", value = "/page/mission/parameterDefaults/defaultsInfoList.jsp"),
@Result(name="add", value = "/page/mission/parameterDefaults/addDefaultsInfo.jsp"),
@Result(name="edit", value = "/page/mission/parameterDefaults/updateDefaultsInfo.jsp"),
@Result(name="view1", value = "/page/mission/parameterDefaults/examineDefaultsInfo1.jsp"),
@Result(name="view2", value = "/page/mission/parameterDefaults/examineDefaultsInfo2.jsp"),
@Result(name="error", value ="/error.jsp")
})
public class MissionParameterDefaultsAction extends BaseAction{
/**
*
*/
private static final long serialVersionUID = 1L;
private CommonService commonService;
private int pageNo = 1;
private int pageSize =this.getDefaultPageSize(); //每页显示的记录条数
// private MD5 md5 = new MD5();
private Page page;
private String action;
private String MSG;
private int MSGFlag; //判断业务系统和任务类型校验唯一的标记[0,1] 1有效0无效
private MissionStateTable missionState;
private MissionParameterDefaults parameterDefaults;
private List<MissionParameterDefaults> list;
private MissionParameterTable1 missionParameter1;
private MissionParameterTable2 missionParameter2;
//--其他
private Long ckqxDid = new Long(1); //查看权限字典表ID
private Long mtDid = new Long(3); //任务类型字典表Id
private Long mtbmDid = new Long(7); //任务类型别名字典表ID
private Long msDid = new Long(4); //任务状态字典表ID
private Long msdsDid = new Long(5); //定时任务状态字典表ID
private Long rwcsDid = new Long(6); //任务参数字典表ID
public String executeAction(){
missionState = missionState == null? new MissionStateTable() : missionState;
missionState.setSystemId((Long)this.getRequest().getAttribute(Constant.SESSION_SYSTEM_LOGIN));
System.out.println("*** executeAction ***");
String resultpage = "";
if("select".equals(this.action)){
resultpage = select();
}else if("add".equals(this.action)){
resultpage = add();
}else if("insert".equals(this.action)){
resultpage = insert();
}else if("view".equals(this.action)){
resultpage = view();
}else if("delete".equals(this.action)){
resultpage = delete();
}else if("check".equals(this.action)){
resultpage = check();
}
// else if("edit".equals(this.action)){
// resultpage = edit();
// }
// else if("update".equals(this.action)){
// resultpage = update();
// }
return resultpage;
}
private String select(){
// XtYhJbxx user = this.getUser();
String sysHql = "select st.system_Id,st.system_Name from system_table st where st.system_state = 0";
String ngHql = "select nt.group_Id,nt.group_Name,nt.system_Id from Nodegroup_Table nt";
String sql = spSql();
try {
//查询系统
List<Object []> sysList = (List<Object []>)this.commonService.executeSQL(sysHql);
this.getRequest().setAttribute("sysList", sysList);
//查询节点组
List<Object []> ngList = (List<Object []>)this.commonService.executeSQL(ngHql);
this.getRequest().setAttribute("ngList", ngList);
// //任务状态
// List<Object []> msList = this.searchParameters(msDid,false);
// this.getRequest().setAttribute("msList", msList);
//任务类型
List<Object []> mtList = this.searchParameters(mtDid,false);
this.getRequest().setAttribute("mtList", mtList);
// //查看权限
// List<Object []> vlList = this.searchParameters(ckqxDid,false);
// this.getRequest().setAttribute("vlList", vlList);
page = this.commonService.findByPageForSql(sql, pageNo, pageSize);
list = (List<MissionParameterDefaults>) page.getResult();
} catch (Exception e) {
e.printStackTrace();
}
return "select";
}
//sql拼接
private String spSql(){
StringBuffer hql = new StringBuffer();
hql.append("select mpd.id,mpd.mission_type_name, mpd.mission_type, mpd.system_id, st.system_name, mpd.node_list_id, nt.Group_name from Mission_Parameter_Defaults mpd ");
hql.append("left join system_table st on st.system_id = mpd.system_id ");
hql.append("left join nodegroup_table nt on nt.Group_id = mpd.node_list_id ");
hql.append("where 1=1 ");
if(parameterDefaults!=null){
if(parameterDefaults.getMissionType()!=null && !parameterDefaults.getMissionType().equals(0l)){//应用升级
hql.append("and mpd.mission_type="+parameterDefaults.getMissionType());
}
if(parameterDefaults.getNodeListId()!=null && !parameterDefaults.getNodeListId().equals(0)){
hql.append(" and mpd.node_List_Id ="+parameterDefaults.getNodeListId());
}
// if(parameterDefaults.getNodeListId()!=null && !parameterDefaults.getNodeListId().equals(0)){
// hql.append(" and mpt.node_List_Id ="+parameterDefaults.getNodeListId());
// }
// if(missionState.getMissionName()!=null && !"".equals(missionState.getMissionName().trim())){
// hql.append(" and st.mission_name like '%"+missionState.getMissionName().trim()+"%' ");
// }
// if(missionState.getSystemId()!=null && !missionState.getSystemId().equals(0l)){
// hql.append(" and st.system_id ="+missionState.getSystemId());
// }
// if(missionState.getMissionState()!=null && !missionState.getMissionState().equals(0l)){
// hql.append(" and st.mission_state ="+missionState.getMissionState());
// }
// if(missionState.getViewLevel()!=null && !missionState.getViewLevel().equals(0l)){
// hql.append(" and st.view_level ="+missionState.getViewLevel());
// }
// if(userName!=null && !"".equals(userName.trim())){
// hql.append(" and xyj.yhbh like '%"+userName.trim()+"%'");
// }
// if(startTime!=null && !"".equals(startTime)){
// hql.append(" and st.create_time >="+startTime);
// }
// if(endTime!=null && !"".equals(endTime)){
// hql.append(" and st.create_time ="+endTime);
// }
}
// hql.append(" and st.mission_Type = "+missionState.getMissionType()+" ");
hql.append("order by mpd.id desc");
return hql.toString();
}
private String add(){
System.out.println("跳转到添加页面 操作");
// XtYhJbxx user = this.getUser();
String sysSql = "select DISTINCT(st.system_Id),st.system_Name from system_table st where st.system_state = 0";
String ngSql = "select nt.group_Id,nt.group_Name,nt.system_Id from Nodegroup_Table nt";
String groupSql = "select xjj.jsbh,xjj.jsmc,st.system_Id from xt_js_jbxx xjj" +
" left join gorup_system_table gst on gst.user_group_id = xjj.jsbh " +
" left join system_table st on st.system_id= gst.system_id " +
" where st.system_state = 0 and xjj.zxbz=0 and xjj.type=1";
try {
//查询系统
List<Object []> sysList = (List<Object []>)this.commonService.executeSQL(sysSql);
this.getRequest().setAttribute("sysList", sysList);
//查询节点组
List<Object []> ngList = (List<Object []>)this.commonService.executeSQL(ngSql);
this.getRequest().setAttribute("ngList", ngList);
//查询节点组
List<Object []> groupList = (List<Object []>)this.commonService.executeSQL(groupSql);
this.getRequest().setAttribute("groupList", groupList);
//任务类型
List<Object []> mtbmList = this.searchParameters(mtbmDid,false);
this.getRequest().setAttribute("mtList", mtbmList);
//查看权限
List<Object []> vlList = this.searchParameters(ckqxDid,false);
this.getRequest().setAttribute("vlList", vlList);
} catch (Exception e) {
e.printStackTrace();
}
return "add";
}
public List<Object []> searchParameters(Long dId,boolean stateFlag) {
String sql="select ot.type_code,ot.type_value from option_table ot " +
"left join dictionary_table dt on dt.id = ot.TYPE_IDENTITY " +
"where dt.id= "+dId.longValue()+" ";
if(stateFlag){
sql +=" and ot.type_state=0 and dt.type_state =0 ";
}
try {
return this.commonService.executeSQL(sql, dId);
} catch (Exception e) {
e.printStackTrace();
return new ArrayList<Object[]>();
}
}
private String check() {
try {
List list = this.commonService.find("from MissionParameterDefaults mpd where mpd.systemId=? and mpd.missionType=?", parameterDefaults.getSystemId(), parameterDefaults.getMissionType());
if(list!=null && list.size()>0){
MSG = getI18nText("i18n_MissionParameterDefaultsAction.check.configExists_n81i");
MSGFlag=0;//无效配置
}else{
MSGFlag=1;//有效配置
}
} catch (Exception e) {
e.printStackTrace();
}
return add();
}
private String insert() {
System.out.println("保存 任务及参数信息操作");
try {
if(parameterDefaults!=null){
System.out.println("---"+parameterDefaults.getCheckValue());
System.out.println("---"+parameterDefaults.getFilterKeyword());
System.out.println("---"+parameterDefaults.getTargetPath());
this.commonService.save(parameterDefaults);
parameterDefaults = new MissionParameterDefaults();
}
} catch (Exception e) {
e.printStackTrace();
}
return select();
}
private String delete(){
System.out.println("停用任务操作");
if(parameterDefaults!=null && parameterDefaults.getId()!=null && !parameterDefaults.getId().equals(0l)){
try {
// this.commonService.delete(entityClass, propertyName, propertyValue);
} catch (Exception e) {
// TODO: handle exception
}
}
return select();
}
private String view() {
System.out.println("参数信息");
try {
if(parameterDefaults!=null && parameterDefaults.getId()!=null && parameterDefaults.getId().equals(0l)){
parameterDefaults = (MissionParameterDefaults)this.commonService.get(MissionParameterDefaults.class, parameterDefaults.getId());
}
//查询系统
if(parameterDefaults!=null){
if(parameterDefaults.getSystemId()!=null){
this.getRequest().setAttribute("sys", this.commonService.get(SystemTable.class, parameterDefaults.getSystemId()));
}
if(parameterDefaults.getNodeListId()!=null){
this.getRequest().setAttribute("nod", this.commonService.get(NodegroupTable.class, parameterDefaults.getNodeListId()));
}
if(parameterDefaults.getGroupId()!=null){
this.getRequest().setAttribute("xtj", this.commonService.get(XtJsJbxx.class, parameterDefaults.getGroupId()));
}
}
//任务类型
List<Object []> mtbmList = this.searchParameters(mtbmDid,false);
this.getRequest().setAttribute("mtList", mtbmList);
//查看权限
List<Object []> vlList = this.searchParameters(ckqxDid,false);
this.getRequest().setAttribute("vlList", vlList);
if(parameterDefaults.getMissionType().equals(1l)){
return "view1" ;
}else if (parameterDefaults.getMissionType().equals(2l)) {
return "view2" ;
}
} catch (Exception e) {
e.printStackTrace();
}
return "view1";
}
private String spHql(){
System.out.println("split HQL");
StringBuffer hql = new StringBuffer("from MissionStateTable");
return hql.toString();
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getMSG() {
return MSG;
}
public void setMSG(String msg) {
MSG = msg;
}
public List<MissionParameterDefaults> getList() {
return list;
}
public void setList(List<MissionParameterDefaults> list) {
this.list = list;
}
public MissionParameterTable1 getMissionParameter1() {
return missionParameter1;
}
public void setMissionParameter1(MissionParameterTable1 missionParameter1) {
this.missionParameter1 = missionParameter1;
}
public MissionParameterTable2 getMissionParameter2() {
return missionParameter2;
}
public void setMissionParameter2(MissionParameterTable2 missionParameter2) {
this.missionParameter2 = missionParameter2;
}
public MissionStateTable getMissionState() {
return missionState;
}
public void setMissionState(MissionStateTable missionState) {
this.missionState = missionState;
}
public MissionParameterDefaults getParameterDefaults() {
return parameterDefaults;
}
public void setParameterDefaults(MissionParameterDefaults parameterDefaults) {
this.parameterDefaults = parameterDefaults;
}
public int getMSGFlag() {
return MSGFlag;
}
public void setMSGFlag(int flag) {
MSGFlag = flag;
}
}

View File

@@ -0,0 +1,569 @@
package nis.nms.web.actions.mission;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import nis.nms.domains.LoopmissionStateTable;
import nis.nms.domains.MissionParameterDefaults;
import nis.nms.domains.MissionParameterTable1;
import nis.nms.domains.MissionParameterTable2;
import nis.nms.domains.MissionStateTable;
import nis.nms.domains.XtYhJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Common;
import nis.nms.util.Constant;
import nis.nms.util.MD5Util;
import nis.nms.util.Page;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name="select", value = "/page/mission/smipleMission/missionInfoList.jsp"),
@Result(name="add", value = "/page/mission/smipleMission/addMissionInfo.jsp"),
@Result(name="view1", value = "/page/mission/smipleMission/examineMissionInfo1.jsp"),
@Result(name="view2", value = "/page/mission/smipleMission/examineMissionInfo2.jsp"),
@Result(name="error", value ="/error.jsp")
})
public class SimpleMissionAction extends BaseAction{
/**
*
*/
private static final long serialVersionUID = 1L;
private CommonService commonService;
//--分页
private Page page;
private int pageNo = 1;
private int pageSize =this.getDefaultPageSize(); //每页显示的记录条数
//--请求 提示
private String action;
private String MSG;
//--查询时间
private String startTime;
private String endTime;
//--数据集合
private MissionStateTable missionState;
private MissionParameterTable1 missionParameter1;
private MissionParameterTable2 missionParameter2;
private LoopmissionStateTable loopmissionStateTable;
private List<MissionStateTable> mstlist;
private List<Object []> list;
// private Object [] objs;
//--文件上传
private File upload;
private String uploadFileName;
//--相关参数
private Integer nodeId;
private String userName;
//--其他
private Long vlDid = new Long(1); //查看权限字典表ID
private Long mtDid = new Long(3); //任务类型字典表Id
private Long mtbmDid = new Long(7); //任务类型别名字典表ID
private Long msDid = new Long(4); //任务状态字典表ID
private Long msdsDid = new Long(5); //定时任务状态字典表ID
private Long rwcsDid = new Long(6); //任务参数字典表ID
public String executeAction(){
missionState = missionState == null? new MissionStateTable() : missionState;
missionState.setSystemId((Long)this.getRequest().getSession().getAttribute(Constant.SESSION_SYSTEM_LOGIN));
String resultpage = "";
if("select1".equals(this.action)){
missionState = missionState==null?new MissionStateTable():missionState;
missionState.setMissionType(1l);
resultpage = select();
}else if("select2".equals(this.action)){
missionState = missionState==null?new MissionStateTable():missionState;
missionState.setMissionType(2l);
resultpage = select();
}else if("select".equals(this.action)){
resultpage = select();
}else if("add".equals(this.action)){
resultpage = add();
}else if("insert".equals(this.action)){
resultpage = insert();
}else if("view".equals(this.action)){
resultpage = view();
}else if("changeState".equals(this.action)){
resultpage = changeState();
}
return resultpage;
}
private String select(){
XtYhJbxx user = this.getUser();
//查询业务系统
String sysHql = "select DISTINCT(st.system_Id),st.system_Name from system_table st " +
"left join Gorup_System_Table gst on gst.system_Id = st.system_Id " +
"left join Xt_Yh_Js_Index xyji on xyji.jsbh = gst.user_Group_Id " +
"where xyji.yhbh='" + user.getYhbh() + "' order by st.system_Id";
//查询节点组
String ngHql = "select DISTINCT(nt.group_Id),nt.group_Name,nt.system_Id from Nodegroup_Table nt "+
"left join Gorup_System_Table gst on gst.system_Id = nt.system_Id " +
"left join Xt_Yh_Js_Index xyji on xyji.jsbh = gst.user_Group_Id " +
"where xyji.yhbh='" + user.getYhbh() + "'";
String sql = spSql();
try {
//查询系统
List<Object []> sysList = (List<Object []>)this.commonService.executeSQL(sysHql);
this.getRequest().setAttribute("sysList", sysList);
//查询节点组
List<Object []> ngList = (List<Object []>)this.commonService.executeSQL(ngHql);
this.getRequest().setAttribute("ngList", ngList);
//任务状态
List<Object []> msList = this.searchParameters(msDid,false);
this.getRequest().setAttribute("msList", msList);
//查看权限
List<Object []> vlList = this.searchParameters(vlDid,false);
this.getRequest().setAttribute("vlList", vlList);
page = this.commonService.findByPageForSql(sql, pageNo, pageSize);
list = (List<Object []>) page.getResult();
} catch (Exception e) {
e.printStackTrace();
}
return "select";
}
public List<Object []> searchParameters(Long dId,boolean stateFlag) {
String sql="select ot.type_code,ot.type_value from option_table ot " +
"left join dictionary_table dt on dt.id = ot.TYPE_IDENTITY " +
"where dt.id= "+dId.longValue()+" ";
if(stateFlag){
sql +=" and ot.type_state=0 and dt.type_state =0 ";
}
try {
return this.commonService.executeSQL(sql, dId);
} catch (Exception e) {
e.printStackTrace();
return new ArrayList<Object[]>();
}
}
private String add(){
System.out.println("跳转到添加页面 操作");
XtYhJbxx user = this.getUser();
//查询业务系统
String sysHql = "select DISTINCT(st.system_Id),st.system_Name from system_table st " +
"left join Gorup_System_Table gst on gst.system_Id = st.system_Id " +
"left join Xt_Yh_Js_Index xyji on xyji.jsbh = gst.user_Group_Id " +
"where xyji.yhbh='" + user.getYhbh() + "' and st.system_state=0 order by st.system_Id";
try {
List<Object[]> sysList = (List<Object []>)this.commonService.executeSQL(sysHql);
this.getRequest().setAttribute("sysList", sysList);
} catch (Exception e) {
e.printStackTrace();
}
return "add";
}
private String insert() {
System.out.println("保存 任务及参数信息操作");
String resultpage="";
try {
System.out.println("---getMissionType: "+missionState.getMissionType().intValue());
if(missionState!=null){
// Mission_type取值范围[1、5]
switch (missionState.getMissionType().intValue()) {
case 1: //1—文件推送
resultpage = addMissionParameter1();
break;
case 2: //2—非流文本数据获取
resultpage = addMissionParameter2();
break;
case 3: //3—流文本数据获取
break;
case 4: //4—命令执行
break;
case 5: //5—shell注册
break;
default:
System.out.println("任务类型错误~ Error");
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return resultpage;
}
private String changeState(){
System.out.println("停用任务操作");
String state = this.getRequest().getParameter("state");
try {
if(state!=null){
this.commonService.updateByHql("update MissionStateTable mst set mst.missionState = "+state+" where mst.missionId=?", missionState.getMissionId());
}
} catch (Exception e) {
e.printStackTrace();
}
return select();
}
private String view() {
StringBuffer sql = new StringBuffer();
try {
if(missionState!=null && missionState.getMissionType().equals(2l)){
sql.append(" select st.mission_id,st.mission_name,st.create_Time,st.mission_state,otss.type_value,st.view_Level,otvl.type_value,st.user_id,xyj.yhbh,st.group_id,xjj.jsmc,st.system_id,s.system_Name,mpt.node_List_Id,nt.group_Name,IF(mpt.Filter_keyword is null,'不过滤','过滤'),mpt.Filter_keyword,mpt.mission_desc,st.is_loop,mpt.Loop_flag,mpt.Loop_start_date,mpt.Loop_end_date,mpt.Loop_delay");
sql.append(" from Mission_State_Table st");
sql.append(" left join Mission_Parameter_Table2 mpt on st.mission_id = mpt.mission_id");
sql.append(" left join xt_js_jbxx xjj on xjj.jsbh = st.group_id");
sql.append(" left join xt_yh_jbxx xyj on xyj.Yhid = st.user_id");
sql.append(" left join Nodegroup_Table nt on nt.group_Id = mpt.node_List_Id ");
sql.append(" left join system_table s on s.system_Id = st.system_Id");
sql.append(" left join option_table otss on otss.type_code = st.mission_state");
sql.append(" left join option_table otvl on otvl.type_code = st.view_Level");
sql.append(" where otss.TYPE_IDENTITY = "+this.msdsDid+" and otvl.TYPE_IDENTITY ="+this.vlDid+" and st.mission_id="+missionState.getMissionId());
list = this.commonService.executeSQL(sql.toString());
//查看权限
List<Object []> vlList = this.searchParameters(vlDid,false);
this.getRequest().setAttribute("vlList", vlList);
return "view2" ;
}else{
sql.append(" select st.mission_id,st.mission_name,st.create_Time,st.mission_state,otss.type_value,st.view_Level,otvl.type_value,st.user_id,xyj.yhbh,st.group_id,xjj.jsmc,st.system_id,s.system_Name,mpt.node_List_Id,nt.group_Name,mpt.target_path,mpt.mission_desc");
sql.append(" from Mission_State_Table st");
sql.append(" left join Mission_Parameter_Table1 mpt on st.mission_id = mpt.mission_id");
sql.append(" left join xt_js_jbxx xjj on xjj.jsbh = st.group_id");
sql.append(" left join xt_yh_jbxx xyj on xyj.Yhid = st.user_id");
sql.append(" left join Nodegroup_Table nt on nt.group_Id = mpt.node_List_Id ");
sql.append(" left join system_table s on s.system_Id = st.system_Id");
sql.append(" left join option_table otss on otss.type_code = st.mission_state");
sql.append(" left join option_table otvl on otvl.type_code = st.view_Level");
sql.append(" where otss.TYPE_IDENTITY = "+this.msdsDid+" and otvl.TYPE_IDENTITY ="+this.vlDid+" and st.mission_id="+missionState.getMissionId());
list = this.commonService.executeSQL(sql.toString());
//查看权限
List<Object []> vlList = this.searchParameters(vlDid,false);
this.getRequest().setAttribute("vlList", vlList);
}
} catch (Exception e) {
e.printStackTrace();
}
return "view1" ;
}
//sql拼接
private String spSql(){
// System.out.println("split HQL");
XtYhJbxx user = this.getUser();
StringBuffer hql = new StringBuffer();
hql.append("select DISTINCT(st.mission_id) mission_id,st.mission_name,st.system_id,s.system_Name,st.mission_type,st.mission_state,mpt.node_List_Id,nt.group_Name,st.view_Level, xyj.yhid, xyj.yhbh,st.create_Time from Mission_State_Table st ");
if(missionState.getMissionType().equals(1l)){ //应用升级
hql.append("left join Mission_Parameter_Table1 mpt on st.mission_id = mpt.mission_id ");
}else if(missionState.getMissionType().equals(2l)){ //配置正确性验证
hql.append("left join Mission_Parameter_Table2 mpt on st.mission_id = mpt.mission_id ");
}
hql.append("left join Gorup_System_Table gst on gst.system_Id = st.system_Id ");
hql.append("left join xt_yh_jbxx xyj on xyj.yhId = st.user_id ");
// --
hql.append("left join Xt_Yh_Js_Index xyjig on xyjig.jsbh = gst.user_group_id ");
// --
hql.append("left join Xt_Yh_Js_Index xyjis on xyjis.jsbh = st.group_id ");
hql.append("left join Nodegroup_Table nt on nt.group_Id = mpt.node_List_Id ");
hql.append("left join system_table s on s.system_Id = st.system_Id ");
hql.append("where ((st.user_id ="+user.getYhid()+") or (st.view_Level = 2 and xyjis.yhid = "+user.getYhid()+" and xyjis.type=1) or (st.view_Level = 3 and xyjig.yhid = "+user.getYhid()+")) ");
if(missionState!=null){
if(nodeId!=null && !nodeId.equals(0)){
hql.append(" and mpt.node_List_Id ="+nodeId);
}
if(missionState.getMissionName()!=null && !"".equals(missionState.getMissionName().trim())){
hql.append(" and st.mission_name like '%"+missionState.getMissionName().trim()+"%' ");
}
if(missionState.getSystemId()!=null && !missionState.getSystemId().equals(0l)){
hql.append(" and st.system_id ="+missionState.getSystemId());
}
if(missionState.getMissionState()!=null && !missionState.getMissionState().equals(0l)){
hql.append(" and st.mission_state ="+missionState.getMissionState());
}
if(missionState.getViewLevel()!=null && !missionState.getViewLevel().equals(0l)){
hql.append(" and st.view_level ="+missionState.getViewLevel());
}
if(userName!=null && !"".equals(userName.trim())){
hql.append(" and xyj.yhbh like '%"+userName.trim()+"%' ");
}
if(startTime!=null && !"".equals(startTime)){
hql.append(" and st.create_time >="+startTime);
}
if(endTime!=null && !"".equals(endTime)){
hql.append(" and st.create_time ="+endTime);
}
}
hql.append(" and st.mission_name in('"+getI18nText("i18n_SimpleMissionAction.check.appUpdate_n81i")+"','"+getI18nText("i18n_SimpleMissionAction.check.validateConfig_n81i")+"')");
hql.append(" and st.mission_Type = "+missionState.getMissionType()+" ");
hql.append("order by st.mission_id desc");
return hql.toString();
}
//应用升级任务添加方法
@SuppressWarnings("static-access")
private String addMissionParameter1(){
try {
XtYhJbxx user = this.getUser();
//保存上传文件
String uploadFilePath = getConfigValue("uploadServerPath");
Date date = new Date();
if(uploadFilePath.lastIndexOf(File.separator)==uploadFilePath.length()){//获取保存路径
uploadFilePath.substring(0,uploadFilePath.length()-File.separator.length());
}
File file = new File(uploadFilePath);
if(!file.exists()){
file.mkdirs();
}
String newName = Common.addTimeTagForUploadFileName(uploadFileName);
uploadFilePath +=newName;
this.copy(upload, new File(uploadFilePath));
//获取默认参数
String paraHQL = "from MissionParameterDefaults pd where pd.missionType="+missionState.getMissionType()+" and pd.systemId="+missionState.getSystemId();
List<MissionParameterDefaults> list = (List<MissionParameterDefaults>)this.commonService.find(paraHQL);
if(list!=null && list.size()>0){
MissionParameterDefaults defaults = list.get(0);
missionState.setMissionName(defaults.getMissionTypeName());
missionState.setMissionState(1l);
missionState.setMissionType(1l);
missionState.setStartTime(defaults.getStartTime());
missionState.setEndTime(defaults.getEndTime());
missionState.setCreateTime(new Date());
missionState.setGroupId(defaults.getGroupId());
missionState.setStartTime(defaults.getStartTime());
missionState.setEndTime(defaults.getEndTime());
missionState.setUserId(user.getYhid());
missionState.setViewLevel(defaults.getViewLevel());
MissionParameterTable1 parameterTable1 = new MissionParameterTable1();
parameterTable1.setNodeListId(this.missionParameter1.getNodeListId());
//转换为MD5
MD5Util md5 = new MD5Util();
parameterTable1.setCheckValue(md5.getFileMD5String(new File(uploadFilePath)));
parameterTable1.setSourcePath(newName);
parameterTable1.setTargetPath(defaults.getTargetPath());
this.commonService.save(missionState);
parameterTable1.setMissionId(missionState.getMissionId());
this.commonService.save(parameterTable1);
MSG = "i18n_SimpleMissionAction.check.saveSuccess_n81i";
missionState = new MissionStateTable();
outHtmlString("<script type=\"text/javascript\">alert('"+MSG+"');this.location='simpleMission.do?action=select1'</script>");
}else{
MSG = "i18n_SimpleMissionAction.check.message1_n81i";
outHtmlString("<script type=\"text/javascript\">alert('"+MSG+"');this.history.go(-1);</script>");
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//配置验证任务添加方法
private String addMissionParameter2(){
try {
XtYhJbxx user = this.getUser();
// String uploadFilePath = getConfigValue("uploadServerPath");
// Date date = new Date();
// if(uploadFilePath.lastIndexOf(File.separator)==uploadFilePath.length()){//获取保存路径
// uploadFilePath.substring(0,uploadFilePath.length()-File.separator.length());
// }
// File file = new File(uploadFilePath);
// if(!file.exists()){
// file.mkdirs();
// }
// String newName = Common.addTimeTagForUploadFileName(uploadFileName);
// uploadFilePath +=newName;
// this.copy(upload, new File(uploadFilePath));
String paraHQL = "from MissionParameterDefaults pd where pd.missionType="+missionState.getMissionType()+" and pd.systemId="+missionState.getSystemId();
List<MissionParameterDefaults> list = (List<MissionParameterDefaults>)this.commonService.find(paraHQL);
if(list!=null && list.size()>0){
MissionParameterDefaults defaults = list.get(0);
missionState.setMissionName(defaults.getMissionTypeName());
missionState.setStartTime(defaults.getStartTime());
missionState.setEndTime(defaults.getEndTime());
missionState.setCreateTime(new Date());
missionState.setGroupId(defaults.getGroupId());
missionState.setUserId(user.getYhid());
missionState.setViewLevel(defaults.getViewLevel());
missionState.setLoopDelay(defaults.getLoopDelay());
MissionParameterTable2 parameterTable2 = new MissionParameterTable2();
if("0".equals(this.getRequest().getParameter("filterFlag"))){
parameterTable2.setFilterKeyword(defaults.getFilterKeyword());
}
parameterTable2.setFilePath(missionParameter2.getFilePath());
parameterTable2.setNodeListId(defaults.getNodeListId());
parameterTable2.setStartFlag(missionParameter2.getStartFlag());
parameterTable2.setEndFlag(missionParameter2.getEndFlag());
// parameterTable2.setFilterKeyword(this.missionParameter2.getFilterKeyword().trim());
if(defaults.getLoopFlag()==0){//不是定时任务
missionState.setMissionState(1l);
parameterTable2.setLoopFlag(defaults.getLoopFlag());
}else{//定时任务处理
missionState.setMissionState(0l);
parameterTable2.setLoopFlag(defaults.getLoopFlag());
parameterTable2.setLoopStartDate(defaults.getLoopStartDate());
parameterTable2.setLoopEndDate(defaults.getLoopEndDate());
parameterTable2.setLoopDelay(defaults.getLoopDelay());
}
parameterTable2.setMaxReturn(defaults.getMaxReturn());
parameterTable2.setStartFlag(defaults.getStartFlag());
parameterTable2.setEndFlag(defaults.getEndFlag());
this.commonService.save(missionState);
parameterTable2.setMissionId(missionState.getMissionId());
this.commonService.save(parameterTable2);
MSG = "i18n_SimpleMissionAction.check.saveSuccess_n81i";
missionState = new MissionStateTable();
outHtmlString("<script type=\"text/javascript\">alert('"+MSG+"');this.location='simpleMission.do?action=select2'</script>");
}else{
MSG = "i18n_SimpleMissionAction.check.message2_n81i";
outHtmlString("<script type=\"text/javascript\">alert('"+MSG+"');this.history.go(-1);</script>");
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public MissionStateTable getMissionState() {
return missionState;
}
public void setMissionState(MissionStateTable missionState) {
this.missionState = missionState;
}
public List<MissionStateTable> getMstlist() {
return mstlist;
}
public void setMstlist(List<MissionStateTable> mstlist) {
this.mstlist = mstlist;
}
public List<Object[]> getList() {
return list;
}
public void setList(List<Object[]> list) {
this.list = list;
}
public MissionParameterTable1 getMissionParameter1() {
return missionParameter1;
}
public void setMissionParameter1(MissionParameterTable1 missionParameter1) {
this.missionParameter1 = missionParameter1;
}
public MissionParameterTable2 getMissionParameter2() {
return missionParameter2;
}
public void setMissionParameter2(MissionParameterTable2 missionParameter2) {
this.missionParameter2 = missionParameter2;
}
public String getMSG() {
return MSG;
}
public void setMSG(String msg) {
MSG = msg;
}
public File getUpload() {
return upload;
}
public void setUpload(File upload) {
this.upload = upload;
}
public String getUploadFileName() {
return uploadFileName;
}
public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public Integer getNodeId() {
return nodeId;
}
public void setNodeId(Integer nodeId) {
this.nodeId = nodeId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public LoopmissionStateTable getLoopmissionStateTable() {
return loopmissionStateTable;
}
public void setLoopmissionStateTable(LoopmissionStateTable loopmissionStateTable) {
this.loopmissionStateTable = loopmissionStateTable;
}
// public static void main(String [] args) {
// SimpleMissionAction action = new SimpleMissionAction();
// CommonService service = new CommonService();
// DetectionSetInfo old;
// try {
// old = (DetectionSetInfo) service.get(DetectionSetInfo.class, 5l);
// DetectionSetInfo news = (DetectionSetInfo) service.get(DetectionSetInfo.class, 5l);
// action.sendSetInfo(old, news);
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }finally{
//
// }
// }
}

View File

@@ -0,0 +1,294 @@
package nis.nms.web.actions.nmsError;
import java.util.Calendar;
import java.util.List;
import nis.nms.domains.NmsErrorCode;
import nis.nms.domains.NmsErrorInfo;
import nis.nms.domains.XtYhJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.DateUtil;
import nis.nms.util.Page;
import org.apache.commons.lang.StringUtils;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name = "errorInfoList", value = "/page/system/nmsError/nmsErrorInfoList.jsp"),
@Result(name = "errorInfoDetail", value = "/page/system/nmsError/errorInfoDetail.jsp") })
public class NmsErrorInfoAction extends BaseAction {
/* 公用基本参数 */
private CommonService commonService;
private int pageNo = 1;
private int pageSize = this.getDefaultPageSize(); // 每页显示的记录条数
private Page page;
private String action;// 系统操作
private String position;
private Long[] ids;//业务系统id集合
/* 自定义参数 */
private NmsErrorInfo errorInfo ;
private NmsErrorCode errorCode ;
private Long eiId;
private Long eiState;
private String errorIp;
private String errorCodeStr;
private List<NmsErrorInfo> eiList ;
private List objsList;
@Override
public String executeAction() throws Exception {
String returnPage = "";
try {
// NMSServer管理
if ("query".equals(this.action)) {// 查看NMSServer列表
returnPage = query();
}else
if ("detail".equals(this.action)) {//打开添加页面
returnPage = detail();
}else
if ("checkState".equals(this.action)) {//保存添加信息
returnPage = changeState();
}
} catch (Exception e) {
e.printStackTrace();
}
return returnPage;
}
private String query(){
try {
StringBuffer sql = new StringBuffer("select nei.id, nei.error_code, nec.error_name,nei.error_des, to_char(nei.error_time,'yyyy-mm-dd hh24:mi:ss'), nei.errort_ip,nei.error_state, nei.errort_getip,nei.state_update_userid,xyj.yhmc, to_char(nei.state_update_time,'yyyy-mm-dd hh24:mi:ss') " +
"from Nms_Error_Info nei left join nms_error_code nec on nec.error_code = nei.error_code left join xt_yh_jbxx xyj on xyj.YHID = nei.state_update_userid where " +
//去除nvl(nei.error_des,'-1')过滤条件//"and (nei.error_code,nvl(nei.error_des,'-1'),nei.errort_ip,nei.errort_getip,nei.error_time) in (select t.error_code,nvl(t.error_des,'-1'),t.errort_ip,t.errort_getip,max(t.error_time) from nms_error_info t group by t.error_code,t.error_des,t.errort_ip,t.errort_getip)");
"(nei.error_code,nei.errort_ip,nei.errort_getip,nei.error_time) in (select t.error_code,t.errort_ip,t.errort_getip,max(t.error_time) from nms_error_info t group by t.error_code,t.errort_ip,t.errort_getip)");
System.out.println(sql);
if(eiId != null){
sql.append("and nei.id ='"+eiId+"' ");
}
if (eiState != null)
{
sql.append("and nei.error_State ='"+eiState+"' ");
}
if(StringUtils.isNotEmpty(errorIp) ){
sql.append("and nei.errort_Ip like '%"+errorIp+"%' ");
}
if(StringUtils.isNotEmpty(errorCodeStr)){
sql.append("and nec.error_name like '%"+errorCodeStr+"%' ");
}
sql.append("order by nei.state_update_time desc ");
page = this.commonService.findByPageForSql(sql.toString(), pageNo, pageSize);
objsList = (List) page.getResult();
return "errorInfoList";
} catch (Exception e) {
e.printStackTrace();
this.outHtmlString("<script>alert('i18n_NmsErrorInfoAction.query.queryFaild_n81i');history.back();</script>");
return null;
}
}
private String detail(){
if(eiId != null){
try {
errorInfo = (NmsErrorInfo) this.commonService.get(NmsErrorInfo.class, eiId);
if(errorInfo!= null){
if(StringUtils.isNotEmpty(errorInfo.getErrorCode())){
List<NmsErrorCode> necList = this.commonService.findByProperty(NmsErrorCode.class, "errorCode", errorInfo.getErrorCode());
if(necList!=null && necList.size()>0){
errorCode = (NmsErrorCode) necList.get(0);
}
}
if(errorInfo.getStateUpdateUserid() != null){
List<XtYhJbxx> necList = this.commonService.findByProperty(XtYhJbxx.class, "yhid", errorInfo.getStateUpdateUserid());
if(necList!=null && necList.size()>0){
XtYhJbxx jbxx = necList.get(0);
getRequest().setAttribute("yhJbxx", jbxx);
}
}
return "errorInfoDetail";
}else{
this.outHtmlString("<script>alert('i18n_NmsErrorInfoAction.query.noResultReturn_n81i');history.back();</script>");
return null;
}
} catch (Exception e) {
e.printStackTrace();
this.outHtmlString("<script>alert('i18n_NmsErrorInfoAction.query.queryFaild_n81i');history.back();</script>");
return null;
}
}else{
this.outHtmlString("<script>alert('i18n_NmsErrorInfoAction.query.invalidId_n81i');history.back();</script>");
return null;
}
}
private String changeState(){
if(ids != null){
try {
/* 当前用户ID */
this.getUserID();
/* 当前用户ID */
String dateStr = DateUtil.longToDate(Calendar.getInstance().getTimeInMillis(), "yyyy-MM-dd HH:mm:ss");
/**
* 已解决业务查询出该类异常的所有状态为1 的数据ID置为0 ,其增加操作者和操作时间
* 未解决业务更新ID为指定值的数据状态为1更新操作者和更新状态变更时间
* */
String state = getRequest().getParameter("state");
if(StringUtils.isNotEmpty(state) && "0".equals(state)){ //状态置为已解决
for(long id : ids){
this.commonService.updateBySql("update nms_error_info nei set nei.error_state=?,nei.STATE_UPDATE_USERID=?,nei.STATE_UPDATE_TIME=to_date(?,'yyyy-MM-dd HH24:mi:ss') " +
"where (nei.error_code, nei.errort_ip, nei.errort_getip) in (select t.error_code, t.errort_ip, t.errort_getip from nms_error_info t where id = ?) and nei.error_state = 1 and nei.id <= ?", 0,this.getUserID(),dateStr,id,id);
}
}else if(StringUtils.isNotEmpty(state) && "1".equals(state)){ //状态置为未解决
//拼写id串
StringBuffer idBuffer = new StringBuffer("0");
for(long id : ids){
idBuffer.append(","+id);
}
this.commonService.updateBySql("update nms_error_info nei set nei.error_state=?,nei.STATE_UPDATE_USERID=?,nei.STATE_UPDATE_TIME=to_date(?,'yyyy-MM-dd HH24:mi:ss') where nei.id in ("+idBuffer+")", 1,this.getUserID(),dateStr);
}else{
this.outHtmlString("<script>alert('i18n_NmsErrorInfoAction.query.getParamsFaild_n81i');history.back();</script>");
return null;
}
outHtmlString("<script type=\"text/javascript\">alert('i18n_NmsErrorInfoAction.query.faild_n81i');"
+ "this.location='nmsErrorInfo.do?action=query&pageNo="
+ pageNo + "&pageSize=" + pageSize + "&position=" + position + "&errorCodeStr=" + errorCodeStr + "&errorIp=" + errorIp + "&eiState=" + (eiState==null?"":eiState) + "'</script>");
return null;
} catch (Exception e) {
e.printStackTrace();
this.outHtmlString("<script>alert('i18n_NmsErrorInfoAction.query.queryFaild_n81i');history.back();</script>");
return null;
}
}else{
this.outHtmlString("<script>alert('i18n_NmsErrorInfoAction.query.invalidId_n81i');history.back();</script>");
return null;
}
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public Long[] getIds() {
return ids;
}
public void setIds(Long[] ids) {
this.ids = ids;
}
public NmsErrorInfo getErrorInfo() {
return errorInfo;
}
public void setErrorInfo(NmsErrorInfo errorInfo) {
this.errorInfo = errorInfo;
}
public Long getEiId() {
return eiId;
}
public void setEiId(Long eiId) {
this.eiId = eiId;
}
public List<NmsErrorInfo> getEiList() {
return eiList;
}
public void setEiList(List<NmsErrorInfo> eiList) {
this.eiList = eiList;
}
public List getObjsList() {
return objsList;
}
public void setObjsList(List objsList) {
this.objsList = objsList;
}
public Long getEiState() {
return eiState;
}
public void setEiState(Long eiState) {
this.eiState = eiState;
}
public String getErrorIp() {
return errorIp;
}
public void setErrorIp(String errorIp) {
this.errorIp = errorIp;
}
public String getErrorCodeStr() {
return errorCodeStr;
}
public void setErrorCodeStr(String errorCode) {
this.errorCodeStr = errorCode;
}
public NmsErrorCode getErrorCode() {
return errorCode;
}
public void setErrorCode(NmsErrorCode errorCode) {
this.errorCode = errorCode;
}
}

View File

@@ -0,0 +1,3 @@
Element_paramM1=nis.nms.bean.ParamForM1
Element_paramM4=nis.nms.bean.ParamForM4
Element_paramM6=nis.nms.bean.ParamForM6

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
package nis.nms.web.actions.nmstaskManager;
import java.util.List;
import nis.nms.service.CommonService;
public class NmstaskManagerHelper {
/*
* 根据任务查询任务执行结果信息
*/
@SuppressWarnings("unchecked")
public List<Object[]> getTaskResult(CommonService commserver,String sql){
List<Object[]> listresult = null;
try {
listresult = commserver.createSQLQuery(sql).list();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return listresult;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,908 @@
package nis.nms.web.actions.nodePosition;
import java.io.File;
import java.io.FileInputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import nis.nms.domains.NodeBoxTable;
import nis.nms.domains.NodeBoxTableVo;
import nis.nms.domains.NodeLatticeTable;
import nis.nms.domains.NodeRoomLatticeTable;
import nis.nms.domains.NodeRoomTable;
import nis.nms.domains.NodeTable;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.ExportUtils;
import nis.nms.util.Page;
import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import com.nis.util.StringUtil;
@SuppressWarnings("unchecked")
@Results( {
@Result(name="queryBoxSetInfo", value = "/page/show/nodeBox/boxInfoList.jsp"),
@Result(name="addBoxInfo", value = "/page/show/nodeBox/addBoxInfo.jsp"),
@Result(name="updateBoxInfo", value = "/page/show/nodeBox/updateBoxInfo.jsp"),
@Result(name="detailBoxInfo", value = "/page/show/nodeBox/detailBoxInfo.jsp"),
@Result(name="error", value ="/error.jsp"),
@Result(name = "showError", value = "/page/show/nodeBox/showImportError.jsp")
})
/**
* 监测设置相关操作
*/
public class BoxSetAction extends BaseAction {
private Logger logger = Logger.getLogger(BoxSetAction.class);
private static final long serialVersionUID = 1L;
private CommonService commonService;
private int pageNo = 1;
private int pageSize =this.getDefaultPageSize(); //每页显示的记录条数
private Page page;
private String action;
private List<NodeBoxTable> nodeBoxList;
private NodeBoxTable nodeBox;
private Long[] ids;
private String ispnNum;
private String descinfo;
private String fromWhere;
private String isComplete;
private String roomid;
private String roomIspn;
public String getRoomIspn() {
return roomIspn;
}
public void setRoomIspn(String roomIspn) {
this.roomIspn = roomIspn;
}
public String getRoomid() {
return roomid;
}
public void setRoomid(String roomid) {
this.roomid = roomid;
}
// 导入节点文件
private File myFile;
private String myFileFileName;
@Override
public String executeAction() throws Exception {
String resultpage = "";
this.getRequest().setAttribute("fromWhere", fromWhere);
if("query".equals(this.action)){
resultpage = this.queryBoxInfo();
}else if("openAdd".equals(this.action)){
this.getRoomIspnOption();
resultpage = "addBoxInfo";
}else if("doAdd".equals(this.action)){
this.getRequest().setAttribute("fromWhere", fromWhere);
resultpage = this.addBoxInfo();
}else if("openUpdate".equals(this.action)){
resultpage = this.openUpdBox();
}else if("doUpdate".equals(this.action)){
resultpage = this.doUpdBox();
}else if("del".equals(this.action)){
resultpage = this.delBoxInfo();
}else if ("downloadExample".equals(this.action)) {// 导出模板 程辉 2013-4-27新增
resultpage = this.downloadExample();
}else if ("importXls".equals(this.action)) {// 导入 程辉 2013-4-27新增
resultpage = this.importXls();
}else if ("emportCurrentXls".equals(this.action)) {// 导出当前页 程辉 2013-5-15新增
resultpage = this.emportCurrentXls();
}else if ("emportAllXls".equals(this.action)) {// 导出全部 程辉 2013-5-15新增
resultpage = this.emportAllXls();
}else if("addCheck".equals(this.action)){
addCheck();
return null;
}else if("updateCheck".equals(this.action)){
updateCheck();
return null;
}else {
resultpage = this.queryBoxInfo();
}
return resultpage;
}
private void getRoomIspnOption() {
if(StringUtil.isBlank(roomIspn)){
String hql = "from NodeRoomTable order by roomId desc";
try {
List<NodeRoomTable> nodeRoomList = commonService.find(hql);
this.getRequest().setAttribute("nodeRoomList",nodeRoomList);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public String queryBoxInfo(){
try {
isComplete = this.getRequest().getParameter("isComplete");
String roomspan="";
if(roomid!=null&&!roomid.equals("")){
List roomspanlist = this.commonService.find("select roomIspn from NodeRoomTable where roomId="+roomid);
if(roomspanlist!=null&&roomspanlist.size()>0){
roomspan=roomspanlist.get(0).toString();
}
}
String hql = "from NodeBoxTable where 1=1";
if(ispnNum!=null && !"".equals(ispnNum)){
hql += " and ispn like '%" + ispnNum.trim() + "%'";
}
if(roomspan!=null && !"".equals(roomspan)){
hql += " and roomIspn = '" + roomspan + "'";
}
hql += " order by ispn asc";
page = this.commonService.findByPage(hql, pageNo, pageSize);
nodeBoxList = (List<NodeBoxTable>)page.getResult();
} catch (Exception e) {
logger.error(e.getStackTrace());
this.outHtmlString("<script>alert('i18n_BoxSetAction.queryBoxInfo.queryBoxFaild_n81i');history.back();</script>");
return null;
}
return "queryBoxSetInfo";
}
public void addCheck(){
List list = null;
try {
list = this.commonService.find("from NodeBoxTable where ispn=?",nodeBox.getIspn());
if(list!=null && list.size()>0){
this.outString("exist");
return ;
}
} catch (Exception e) {
e.printStackTrace();
logger.info("机柜管理添加校验失败!",e);
this.outString("exception");
return ;
}
this.outString("success");
}
/**
* 新增机柜初始化机柜位置表机柜是多少U位就插入多少条数据初始化时SEQID为空即表示未存放节点机
* 2012-9-14 添加对所属机房信息的维护,更新机房位置表
* @return
*/
public String addBoxInfo(){
List list = null;
try {
//判断数据是否存在
/*list = this.commonService.find("from NodeBoxTable where ispn=?",nodeBox.getIspn());
if(list!=null && list.size()>0){
this.outHtmlString("<script>alert('记录已存在,请重新输入!');history.back();</script>");
return null;
}*/
this.commonService.save(nodeBox);
//-----初始化机柜位置表
List<Object> list2 = new ArrayList<Object>();
for(long i=1; i<=nodeBox.getBoxUType(); i++){
NodeLatticeTable nlt = new NodeLatticeTable();
nlt.setNodeBoxId(nodeBox.getNodeBoxId());
nlt.setNodeposition(i);
list2.add(nlt);
}
this.commonService.saveOrUpdate(list2);
//------机房位置维护
this.commonService
.updateByHql(
"update NodeRoomLatticeTable set nodeBoxId=?"
+ " where roomId in(select roomId from NodeRoomTable where roomIspn=?) and latticeRowPosition=? and latticeColPosition=?",
nodeBox.getNodeBoxId(), nodeBox.getRoomIspn(),
nodeBox.getRoomRowPosition(), nodeBox
.getRoomColPosition());
//记录用户操作用于设置向导
if(fromWhere!=null && !"".equals(fromWhere)){
if(fromWhere.equals("formGuide")){
String str ="<script type=\"text/javascript\">alert('i18n_BoxSetAction.queryBoxInfo.success_n81i');this.location='boxSet.do?action=query&isComplete=0&roomid="+roomid+"&roomIspn="+roomIspn+"'</script>";
outHtmlString(str);
}
}else{
String str= "<script type=\"text/javascript\">alert('i18n_BoxSetAction.queryBoxInfo.success_n81i');this.location='boxSet.do?action=query&roomIspn="+roomIspn+"&roomid="+roomid+"'</script>";
outHtmlString(str);
}
} catch (Exception e) {
logger.error(e.getStackTrace());
this.outHtmlString("<script>alert('i18n_BoxSetAction.queryBoxInfo.addBoxFaild_n81i');history.back();</script>");
return null;
}
return null;
}
public String openUpdBox(){
try {
if(ids!=null && ids.length>0){
List list = this.commonService.find(
"from NodeBoxTable where nodeBoxId=?", ids[0]);
if(list!=null && list.size()>0){
nodeBox = (NodeBoxTable)list.get(0);
}
}
} catch (Exception e) {
logger.error(e.getStackTrace());
this.outHtmlString("<script>alert('i18n_BoxSetAction.queryBoxInfo.toUpdateViewFaild_n81i');history.back();</script>");
return null;
}
return "updateBoxInfo";
}
public void updateCheck(){
List list;
try {
list = this.commonService.find("from NodeBoxTable where ispn='"+nodeBox.getIspn()+"' and nodeBoxId <> "+nodeBox.getNodeBoxId());
if (list != null && list.size() > 0) {
this.outString(getI18nText("i18n_BoxSetAction.queryBoxInfo.recordExists_n81i"));
return ;
}
} catch (Exception e) {
e.printStackTrace();
logger.info("机柜管理修改异常!",e);
this.outString("exception");
}
this.outString("success");
}
/**
* 修改机柜:
* 1、机柜U位变更范围若已存放了节点机则不允许修改
* 2、机柜U位若是增大则直接在位置表中插入增大的记录机柜U位若是减小减小的范围若未放置节点则删除位置表记录
* @return
*/
public String doUpdBox(){
try {
List list =null;
/*List list = this.commonService.find("from NodeBoxTable where ispn='"+nodeBox.getIspn()+"' and nodeBoxId <> "+nodeBox.getNodeBoxId());
if (list != null && list.size() > 0) {
this.outHtmlString("<script>alert('记录已存在,请重新输入!');history.back();</script>");
return null;
}*/
String historyBack = "boxSet!executeAction.do?action=openUpdate"
+ "&ids=" + nodeBox.getNodeBoxId()
+ "&pageNo=" + pageNo + "&pageSize=" + pageSize;
NodeBoxTable nbt = (NodeBoxTable) this.commonService.get(
NodeBoxTable.class, nodeBox.getNodeBoxId());
nbt.setDescinfo(nodeBox.getDescinfo());
nbt.setRoomIspn(nodeBox.getRoomIspn());
nbt.setRoomRowPosition(nodeBox.getRoomRowPosition());
nbt.setRoomColPosition(nodeBox.getRoomColPosition());
if(!nbt.getIspn().equals(nodeBox.getIspn())) { // 机柜编号修改,级联修改节点表
String sql = "select count(1) from node_box_table nbt"
+" where nbt.ispn ='" + nodeBox.getIspn().trim() + "'";
BigDecimal result = (BigDecimal) this.commonService.createSQLQuery(sql).list().get(0);
if(result.compareTo(BigDecimal.ZERO) > 0){
this.outHtmlString("<script>alert('i18n_BoxSetAction.queryBoxInfo.boxIdExists_n81i');this.location='" + historyBack + "';</script>");
return null;
} else {
String oldIspn = nbt.getIspn();
nbt.setIspn(nodeBox.getIspn());
sql = "update node_table set NODE_BOX_ISPN = '" + nodeBox.getIspn().trim() + "'"
+ " where NODE_BOX_ISPN = '" + oldIspn + "'";
this.commonService.updateBySql(sql);
}
}
if(nbt.getBoxUType()==null){//更新时为了兼容以前的旧数据
nbt.setBoxUType(0l);
}
//-----维护机柜位置表
if(nodeBox.getBoxUType()>nbt.getBoxUType()){//增大机柜U位直接添加机柜位置表
List<Object> list2 = new ArrayList<Object>();
for(long i=(nbt.getBoxUType()+1); i<=nodeBox.getBoxUType(); i++){
NodeLatticeTable nlt = new NodeLatticeTable();
nlt.setNodeBoxId(nodeBox.getNodeBoxId());
nlt.setNodeposition(i);
list2.add(nlt);
}
this.commonService.saveOrUpdate(list2);
}else if(nodeBox.getBoxUType()<nbt.getBoxUType()){//减小机柜U位检查减小的部分是否存放了节点机
String hql = "from NodeLatticeTable where nodeBoxId=? and nodeSeqId is not null and nodeposition>?";
list = this.commonService.find(hql,nodeBox.getNodeBoxId(),nodeBox.getBoxUType());
if (list != null && list.size() > 0) {
this.outHtmlString("<script>alert('i18n_BoxSetAction.queryBoxInfo.hadUpdateNode_n81i');this.location='" + historyBack + "';</script>");
return null;
}
hql = "delete from NodeLatticeTable where nodeBoxId=? and nodeposition>?";
this.commonService.delete(hql,nodeBox.getNodeBoxId(),nodeBox.getBoxUType());
}
//设置U位并更新
nbt.setBoxUType(nodeBox.getBoxUType());
//------维护机房位置
String hql = "update NodeRoomLatticeTable set nodeBoxId=null where nodeBoxId=?";
this.commonService.updateByHql(hql, nodeBox.getNodeBoxId());
hql = "update NodeRoomLatticeTable set nodeBoxId=?" +
" where roomId in(select roomId from NodeRoomTable where roomIspn=?)" +
" and latticeRowPosition=? and latticeColPosition=?";
this.commonService.updateByHql(hql, nodeBox.getNodeBoxId(), nodeBox
.getRoomIspn(), nodeBox.getRoomRowPosition(), nodeBox
.getRoomColPosition());
this.commonService.update(nbt);
this.getRequest().setAttribute("MSG", 1);
} catch (Exception e) {
logger.error(e.getStackTrace());
this.outHtmlString("<script>alert('i18n_BoxSetAction.queryBoxInfo.updateFaild_n81i');history.back();</script>");
return null;
}
return this.queryBoxInfo();
}
public String delBoxInfo(){
try {
if(ids!=null && ids.length>0){
for(Long id : ids){
List list = this.commonService.find(
"from NodeLatticeTable where nodeBoxId=? and nodeSeqId is not null", id);
if(list!=null && list.size()>0){
NodeBoxTable nrt = (NodeBoxTable)this.commonService.get(NodeBoxTable.class, id);
this.outHtmlString("<script>alert('i18n_BoxSetAction.queryBoxInfo.hadUpdateNodeToDelete1_n81i[" +nrt.getIspn()+ "]i18n_BoxSetAction.queryBoxInfo.hadUpdateNodeToDelete2_n81i');history.back();</script>");
return null;
}
}
//清空node_room_lattice_table标识ID
this.commonService.updateBatchBySql("update node_room_lattice_table set node_box_id=null where node_box_id=?", Arrays.asList(ids));
//删除记录
this.commonService.updateBatchBySql("delete from NODE_BOX_TABLE where BOX_ID=?", Arrays.asList(ids));
outHtmlString("<script type=\"text/javascript\">alert('i18n_BoxSetAction.queryBoxInfo.success_n81i');this.location='boxSet.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"&roomid="+roomid+"&roomIspn="+roomIspn+"'</script>");
}
} catch (Exception e) {
logger.error(e.getStackTrace());
this.outHtmlString("<script>alert('i18n_BoxSetAction.queryBoxInfo.deleteFaild_n81i');history.back();</script>");
return null;
}
return this.queryBoxInfo();
}
/**
* Ajax请求获取机房的空闲行
* @return
*/
public String getRoomFreeRows(){
try {
String roomIspn = this.getRequest().getParameter("roomIspn");
String boxId = this.getRequest().getParameter("boxId");
String hql = "select distinct latticeRowPosition from NodeRoomLatticeTable" +
" where roomId in (select roomId from NodeRoomTable where roomIspn=?)";
if(boxId!=null){
hql += " and (nodeBoxId is null or nodeBoxId = " +boxId+ ")";
}else{
hql += " and nodeBoxId is null";
}
hql += " order by latticeRowPosition asc";
List<Long> allList = (List<Long>)this.commonService.find(hql, roomIspn);
System.out.println("-------- room free rows: " + Arrays.toString(allList.toArray()));
this.outJsonArray(allList);
} catch (Exception e) {
logger.error(e.getStackTrace());
e.printStackTrace();
}
return null;
}
/**
* Ajax请求获取机房指定行的空闲列
* @return
*/
public String getRoomFreeCols(){
try {
String rowNumStr = this.getRequest().getParameter("rowNum");
String roomIspn = this.getRequest().getParameter("roomIspn");
String boxId = this.getRequest().getParameter("boxId");
Long rowNum = 0l;
if(rowNumStr!=null && !"".equals(rowNumStr)){
rowNum = Long.parseLong(rowNumStr);
}
String hql = "select distinct latticeColPosition from NodeRoomLatticeTable" +
" where roomId in (select roomId from NodeRoomTable where roomIspn=?)";
if(boxId!=null){
hql += " and (nodeBoxId is null or nodeBoxId = " +boxId+ ")";
}else{
hql += " and nodeBoxId is null";
}
hql += " and latticeRowPosition=? order by latticeColPosition asc";
List<Long> allList = (List<Long>)this.commonService.find(hql, roomIspn,rowNum);
System.out.println("--------room free cols: " + Arrays.toString(allList.toArray()));
this.outJsonArray(allList);
} catch (Exception e) {
logger.error(e.getStackTrace());
e.printStackTrace();
}
return null;
}
/**
* Ajax请求获取所有机柜编号
* @return
*/
public String getAllBoxsIspn(){
try {
String hql = "select distinct ispn from NodeBoxTable order by ispn ";
List<Long> allList = (List<Long>)this.commonService.find(hql);
String getIspn = "";
for (int i = 0; i < allList.size(); i++) {
if (allList.get(i) != null && !"".equals(allList.get(i))) {
getIspn += allList.get(i) + ";";
}
}
outString(getIspn);
System.out.println("--------room free cols: " + Arrays.toString(allList.toArray()));
//this.outJsonArray(allList);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getStackTrace());
}
return null;
}
// 模板下载 程辉 2013-4-27新增
public String downloadExample() {
try {
Page p = this.commonService.findByPage("from NodeBoxTable", 1, 3);
List<NodeTable> st = (List<NodeTable>) p.getResult();
String[] title = { getI18nText("i18n_BoxSetAction.queryBoxInfo.title_n81i"),
getI18nText("i18n_BoxSetAction.queryBoxInfo.title_n81i"),
getI18nText("i18n_BoxSetAction.queryBoxInfo.title_n81i"),
getI18nText("i18n_BoxSetAction.queryBoxInfo.title_n81i"),
getI18nText("i18n_BoxSetAction.queryBoxInfo.title_n81i"),
getI18nText("i18n_BoxSetAction.queryBoxInfo.title_n81i")};
String[] colu = { "ispn", "boxUType","roomIspn", "roomRowPosition",
"roomColPosition","descinfo"};
ExportUtils m = new ExportUtils();
m.setAutoSizeColumn(true);
m.exportExcel(getI18nText("i18n_BoxSetAction.queryBoxInfo.boxBaseInfo_n81i"), st, title, colu,"downloadExample");
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getStackTrace());
}
return null;
}
// 导入 程辉 2013-4-27新增
public String importXls() {
String errorInfo = "";
try {
List<NodeBoxTableVo> list = new ArrayList<NodeBoxTableVo>();
Workbook workbook = null;
if (myFileFileName.endsWith(".xlsx")) {
workbook = new XSSFWorkbook(new FileInputStream(myFile));
} else {
// 创建对Excel工作簿文件的引用
workbook = new HSSFWorkbook(new FileInputStream(myFile));
}
// 创建对工作表的引用,得到表的第一页
Sheet sheet = workbook.getSheetAt(0);
// 读取左上端单元
// 记录存储数据条数
int count = 0;
// 记录读入excel数据条数
int sum = (sheet.getLastRowNum());
for (short i = 1; i <= sheet.getLastRowNum(); i++) {
NodeBoxTableVo nodeVo = new NodeBoxTableVo();
Row row = sheet.getRow(i);
Cell cell_1 = row.getCell((short) 0);
Cell cell_2 = row.getCell((short) 1);
Cell cell_3 = row.getCell((short) 2);
Cell cell_4 = row.getCell((short) 3);
Cell cell_5 = row.getCell((short) 4);
Cell cell_6 = row.getCell((short) 5);
if ((null == cell_1 || 3 == cell_1.getCellType())
&& (null == cell_2 || 3 == cell_2.getCellType())
&& (null == cell_3 || 3 == cell_3.getCellType())
&& (null == cell_4 || 3 == cell_4.getCellType())
&& (null == cell_5 || 3 == cell_5.getCellType())
&& (null == cell_6 || 3 == cell_6.getCellType())) {
sum--;
}else {
// 编号
if (null == cell_1) {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo1_n81i",i+"");
} else if (cell_1.getCellType() == Cell.CELL_TYPE_STRING) {
if ("".equals(cell_1.getStringCellValue())) {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo1_n81i",i+"");
} else {
String ispn = cell_1.getStringCellValue().trim();
nodeVo.setIspn(ispn);
}
} else {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo2_n81i",i+"");
}
// U位
if (null == cell_2) {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo3_n81i",i+"");
} else if (cell_2.getCellType() == Cell.CELL_TYPE_NUMERIC) {
long boxUType = (long) cell_2.getNumericCellValue();
nodeVo.setBoxUType(boxUType);
} else {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo4_n81i",i+"");
}
// 机房编号
if (null == cell_3) {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo5_n81i",i+"");
} else if (cell_3.getCellType() == Cell.CELL_TYPE_STRING) {
if ("".equals(cell_3.getStringCellValue())) {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo5_n81i",i+"");
} else {
String roomIspn = cell_3.getStringCellValue()
.trim();
nodeVo.setRoomIspn(roomIspn);
}
} else {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo6_n81i",i+"");
}
// 机房行号
if (null == cell_4) {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo7_n81i",i+"");
} else if (cell_4.getCellType() == Cell.CELL_TYPE_NUMERIC) {
long roomRowPosition = (long) cell_4
.getNumericCellValue();
nodeVo.setRoomRowPosition(roomRowPosition);
} else {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo8_n81i",i+"");
}
// 机房列号
if (null == cell_5) {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo9_n81i",i+"");
} else if (cell_5.getCellType() == Cell.CELL_TYPE_NUMERIC) {
long roomColPosition = (long) cell_5
.getNumericCellValue();
nodeVo.setRoomColPosition(roomColPosition);
} else {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo10_n81i",i+"");
}
// 描述
if (null == cell_6) {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo11_n81i",i+"");
} else if (cell_6.getCellType() == Cell.CELL_TYPE_STRING) {
if ("".equals(cell_6.getStringCellValue())) {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo11_n81i",i+"");
} else {
String descinfo = cell_6.getStringCellValue()
.trim();
nodeVo.setDescinfo(descinfo);
}
} else {
errorInfo += getI18nText("i18n_BoxSetAction.queryBoxInfo.errorInfo12_n81i",i+"");
}
if ("".equals(errorInfo)) {// 保存节点
errorInfo = this.saveNode(nodeVo);
}
if ("".equals(errorInfo)) {
count++;
} else {
nodeVo.setShowError(errorInfo);
errorInfo = "";
list.add(nodeVo);
}
}
}
this.getRequest().setAttribute("errorList", list);
if (count == sum && sum > 0) {
// this.getRequest().setAttribute("MSG", 1);
// return this.queryBoxInfo();
outHtmlString("<script type=\"text/javascript\">alert('i18n_BoxSetAction.queryBoxInfo.success_n81i');this.location='boxSet.do?action=query&roomid="+roomid+"'</script>");
return null;
} else if (sum == 0) {
this
.outHtmlString("<script>alert('i18n_BoxSetAction.queryBoxInfo.fileIsNull_n81i');history.back();</script>");
return null;
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getStackTrace());
}
return "showError";
}
private String saveNode(NodeBoxTableVo vo) {
String desc = "";
try {
// 保存节点信息
NodeBoxTable nodeT = new NodeBoxTable();
nodeT.setIspn(vo.getIspn());
nodeT.setBoxUType(vo.getBoxUType());
nodeT.setRoomIspn(vo.getRoomIspn());
nodeT.setRoomRowPosition(vo.getRoomRowPosition());
nodeT.setRoomColPosition(vo.getRoomColPosition());
nodeT.setDescinfo(vo.getDescinfo());
//判断机柜编号是否已存在
List list = this.commonService.find(
"from NodeBoxTable where ispn=?", nodeT.getIspn());
if (list != null && list.size() > 0) {
return getI18nText("i18n_BoxSetAction.queryBoxInfo.boxIdRepeat_n81i");
}
long roomID; //如果机房存在 接收机房id
List boxList = this.commonService
.find("from NodeRoomTable where roomIspn='"
+ nodeT.getRoomIspn() + "'");
if (boxList == null || boxList.size() == 0) {
return getI18nText("i18n_BoxSetAction.queryBoxInfo.noRoomExists_n81i");
}else{
roomID = ((NodeRoomTable)boxList.get(0)).getRoomId();
}
//查询机房是否存在 如果存在判断该位置是否已存在机柜
List positionList = this.commonService.find("from NodeRoomLatticeTable where roomId=?" +
" and latticeRowPosition=? and latticeColPosition=?", roomID,nodeT.getRoomRowPosition(),
nodeT.getRoomColPosition());
if (positionList == null || positionList.size() == 0) {
return getI18nText("i18n_BoxSetAction.queryBoxInfo.roomPostionExists_n81i");
} else if (((NodeRoomLatticeTable) positionList.get(0))
.getNodeBoxId() != null) {
return getI18nText("i18n_BoxSetAction.queryBoxInfo.roomHadBox_n81i");
}
this.commonService.save(nodeT);
//-----初始化机柜位置表
List<Object> list2 = new ArrayList<Object>();
for(long i=1; i<=nodeT.getBoxUType(); i++){
NodeLatticeTable nlt = new NodeLatticeTable();
nlt.setNodeBoxId(nodeT.getNodeBoxId());
nlt.setNodeposition(i);
list2.add(nlt);
}
this.commonService.saveOrUpdate(list2);
//------机房位置维护
this.commonService
.updateByHql(
"update NodeRoomLatticeTable set nodeBoxId=?"
+ " where roomId in(select roomId from NodeRoomTable where roomIspn=?) and latticeRowPosition=? and latticeColPosition=?",
nodeT.getNodeBoxId(), nodeT.getRoomIspn(),
nodeT.getRoomRowPosition(), nodeT
.getRoomColPosition());
} catch (Exception e) {
e.printStackTrace();
desc = getI18nText("i18n_BoxSetAction.queryBoxInfo.nodeInfoErr_n81i");
}
return desc;
}
// 当前页导出 程辉 2013-5-8新增
public String emportCurrentXls() {
try {
// String hql = "from NodeBoxTable where 1=1";
// if(ispnNum!=null && !"".equals(ispnNum)){
// hql += " and ispn like '%" + ispnNum.trim() + "%'";
// }
// hql += " order by ispn asc";
// page = this.commonService.findByPage(hql, pageNo, pageSize);
String roomspan="";
if(roomid!=null&&!roomid.equals("")){
List roomspanlist = this.commonService.find("select roomIspn from NodeRoomTable where roomId="+roomid);
if(roomspanlist!=null&&roomspanlist.size()>0){
roomspan=roomspanlist.get(0).toString();
}
}
String hql = "from NodeBoxTable where 1=1";
if(ispnNum!=null && !"".equals(ispnNum)){
hql += " and ispn like '%" + ispnNum.trim() + "%'";
}
if(roomspan!=null && !"".equals(roomspan)){
hql += " and roomIspn = '" + roomspan + "'";
}
hql += " order by ispn asc";
page = this.commonService.findByPage(hql, pageNo, pageSize);
List<NodeBoxTable> nodeBoxList = (List<NodeBoxTable>)page.getResult();
String[] title = { getI18nText("i18n_BoxSetAction.queryBoxInfo.title1.boxId_n81i"),
getI18nText("i18n_BoxSetAction.queryBoxInfo.title1.boxDesc_n81i"),
getI18nText("i18n_BoxSetAction.queryBoxInfo.title1.roomId_n81i")};
String[] colu = { "ispn", "descinfo","roomIspn"};
ExportUtils m = new ExportUtils();
m.setAutoSizeColumn(true);
m.exportExcel(getI18nText("i18n_BoxSetAction.queryBoxInfo.boxBaseInfo_n81i"), nodeBoxList, title, colu);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getStackTrace());
}
return null;
}
// 导出全部 程辉 2013-5-8新增
public String emportAllXls() {
try {
// String hql = "from NodeBoxTable where 1=1";
// if(ispnNum!=null && !"".equals(ispnNum)){
// hql += " and ispn like '%" + ispnNum.trim() + "%'";
// }
// hql += " order by ispn asc";
String roomspan="";
if(roomid!=null&&!roomid.equals("")){
List roomspanlist = this.commonService.find("select roomIspn from NodeRoomTable where roomId="+roomid);
if(roomspanlist!=null&&roomspanlist.size()>0){
roomspan=roomspanlist.get(0).toString();
}
}
String hql = "from NodeBoxTable where 1=1";
if(ispnNum!=null && !"".equals(ispnNum)){
hql += " and ispn like '%" + ispnNum.trim() + "%'";
}
if(roomspan!=null && !"".equals(roomspan)){
hql += " and roomIspn = '" + roomspan + "'";
}
hql += " order by ispn asc";
//page = this.commonService.findByPage(hql, pageNo, pageSize);
List<NodeBoxTable> nodeBoxList = this.commonService.find(hql);
String[] title = { getI18nText("i18n_BoxSetAction.queryBoxInfo.title1.boxId_n81i"),
getI18nText("i18n_BoxSetAction.queryBoxInfo.title1.boxDesc_n81i"),
getI18nText("i18n_BoxSetAction.queryBoxInfo.title1.roomId_n81i")};
String[] colu = { "ispn", "descinfo","roomIspn"};
ExportUtils m = new ExportUtils();
m.setAutoSizeColumn(true);
m.exportExcel(getI18nText("i18n_BoxSetAction.queryBoxInfo.boxBaseInfo_n81i"), nodeBoxList, title, colu);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getStackTrace());
}
return null;
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public Long[] getIds() {
return ids;
}
public void setIds(Long[] ids) {
this.ids = ids;
}
public List<NodeBoxTable> getNodeBoxList() {
return nodeBoxList;
}
public void setNodeBoxList(List<NodeBoxTable> nodeBoxList) {
this.nodeBoxList = nodeBoxList;
}
public String getIspnNum() {
return ispnNum;
}
public void setIspnNum(String ispnNum) {
this.ispnNum = ispnNum;
}
public String getDescinfo() {
return descinfo;
}
public void setDescinfo(String descinfo) {
this.descinfo = descinfo;
}
public NodeBoxTable getNodeBox() {
return nodeBox;
}
public void setNodeBox(NodeBoxTable nodeBox) {
this.nodeBox = nodeBox;
}
public String getFromWhere() {
return fromWhere;
}
public void setFromWhere(String fromWhere) {
this.fromWhere = fromWhere;
}
public String getIsComplete() {
return isComplete;
}
public void setIsComplete(String isComplete) {
this.isComplete = isComplete;
}
public File getMyFile() {
return myFile;
}
public void setMyFile(File myFile) {
this.myFile = myFile;
}
public String getMyFileFileName() {
return myFileFileName;
}
public void setMyFileFileName(String myFileFileName) {
this.myFileFileName = myFileFileName;
}
}

View File

@@ -0,0 +1,219 @@
package nis.nms.web.actions.nodePosition;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import nis.nms.domains.NodegroupPositionAll;
import nis.nms.domains.SystemTable;
import nis.nms.domains.TopoInfo;
import nis.nms.domains.TopoLineInfo;
import nis.nms.domains.TopoNodeInfo;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Constant;
import nis.nms.util.StringUtil;
@Results({
@Result(name = "showTopo", value = "/page/show/nodeGroup/newShowTopo.jsp")
/*@Result(name = "showSingleTopo", value = "/page/show/nodeGroup/newShowSingleTopo.jsp")*/
})
public class NewTopoShowAction extends BaseAction{
private Logger logger = Logger.getLogger(NewTopoShowAction.class);
private CommonService commonService;
private String action;
private List<TopoNodeInfo> topoNodeInfos =new ArrayList<TopoNodeInfo>();
private List<TopoLineInfo> topoLineInfos =new ArrayList<TopoLineInfo>();
private List<TopoInfo> topoInfos = new ArrayList<TopoInfo>();
private Long topoInfoId;
private String requestType;
@Override
public String executeAction() throws Exception {
String resultpage = null;
if ("showTopo".equals(this.action))
{
resultpage = showTopo();
}
return resultpage;
}
/**
* 展示拓扑数据页面
* @return
*/
private String showTopo(){
/**
* 涉及的3个表说明
*
* topo_info 对应的实体类 TopoInfo topo图的基本信息存储表
* topo_node_info 对应的实体类 TopoNodeInfo topo图当中的节点或节点组等属性
* topo_line_info 对应的实体类 TopoLineInfo topo图当中的连线位置以及属性相关
*
*/
try{
//根据当前用户选择的业务系统来查询对应的topo图
//如果当前用户的业务系统为-1 代表为全权限 看主控系统的业务拓扑图
Long systemId=this.getSystemID();
if(this.getSystemID()==-1L){
//查询主控系统的systemId号
List<SystemTable> systemTables = this.commonService.find("from SystemTable where 1=1 and isMaster=1 ");
systemId=systemTables.get(0).getSystemId();
}
String topoHql="from TopoInfo where 1=1 and systemId="+systemId;
topoInfos = commonService.find(topoHql);
// logger.info("query topoInfo response : "+topoInfos);
if(StringUtil.objectIsNUll(topoInfos)){
return null;
}
//如果topoInfoId为空 则代表第一次进入查询拓扑页面展示
if(topoInfoId==null){
topoInfoId = topoInfos.get(0).getId();
}
//查询node所有节点信息
String nodeHql="from TopoNodeInfo where 1=1 and topoInfo.id="+topoInfoId;
topoNodeInfos = commonService.find(nodeHql);
List singleNodeStatus =null;
List nodesStatus =null;
List countNodes=null;
if(!StringUtil.objectIsNUll(topoNodeInfos)){
for(TopoNodeInfo topoNodeInfo:topoNodeInfos){
String statusSql="";
String countSql="";
//根据当前节点表中出来的数据判断是节点还是节点组然后查询状态
if(topoNodeInfo.getType().equals(2L)){
statusSql="select COUNT( distinct nt.node_id) from detection_info_new diw "
+ "left join node_table nt on diw.seq_id=nt.seq_id left join detection_set_info dsi "
+ "on diw.DETECTION_SET_INFO_ID=dsi.ID left join check_type_info cti on dsi.CHECK_TYPE_ID=cti.id "
+ "where diw.DETECTIONED_STATE<>1 AND diw.valid=1 AND diw.police_emergent=0 and "
+ "dsi.DETECTION_SET_STATE=1 and nt.NODE_STATE = 0 and "
+ "((nt.node_type=0 and (cti.IS_SNMP!=1 or cti.IS_SNMP is null)) or nt.node_type!=0)"
+ "and nt.node_id ="+topoNodeInfo.getTypeId();
singleNodeStatus = commonService.executeSQL(statusSql);
}else if(topoNodeInfo.getType().equals(1L)){
//查询节点组下不包含拓扑图展示单个节点的节点总数
countSql="select count(*) from node_table "
+ "where node_group_id="+topoNodeInfo.getTypeId()+" and node_state=0 and "
+ "node_id not in (select type_id from topo_node_info where type=2)";
//查询节点组下不包含拓扑图展示单个节点的异常节点个数
statusSql="select COUNT( distinct nt.node_id) from detection_info_new diw "
+ "left join node_table nt on diw.seq_id = nt.seq_id where diw.DETECTIONED_STATE<>1 AND diw.valid=1 AND diw.police_emergent=0 "
+ "and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) "
+ "and nt.NODE_STATE = 0 and nt.node_group_id ="+topoNodeInfo.getTypeId()+" and "
+ "node_id not in (select type_id from topo_node_info where type=2)";
nodesStatus = commonService.executeSQL(statusSql);
countNodes=commonService.executeSQL(countSql);
}else if(topoNodeInfo.getType().equals(3L)){
//如果当前节点类型为其它 不进行任何操作
continue;
}
// 单个节点状态 显示状态 0正常 1异常
if (topoNodeInfo.getType().equals(2L)&&singleNodeStatus != null && singleNodeStatus.size() > 0)
{
Integer count = Integer.valueOf(singleNodeStatus.get(0).toString());
if (count > 0)
{
topoNodeInfo.setAlarm("!");
topoNodeInfo.setStatus(1);
}
}else if(topoNodeInfo.getType().equals(1L)&&nodesStatus!=null && nodesStatus.size()>0 && countNodes!=null && countNodes.size()>0){
Integer allWarningNodes = Integer.valueOf(nodesStatus.get(0).toString());
Integer allNodes = Integer.valueOf(countNodes.get(0).toString());
// 节点组状态判断 超过80% 设置节点状态异常
double doubleValue =0;
if(allNodes!=0){
doubleValue=new BigDecimal((double)allWarningNodes*100/allNodes).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
}
if (doubleValue >= topoNodeInfo.getThresholdValue())
{
topoNodeInfo.setAlarm(doubleValue+"%");
topoNodeInfo.setStatus(1);
}
}else{
topoNodeInfo.setStatus(0);
}
}
}
//查询line所有线条信息
String lineHql="from TopoLineInfo where 1=1 and flag=1 and topoInfo.id="+topoInfoId;
topoLineInfos=commonService.find(lineHql);
// 5分钟刷新一次 ajax请求给返回数据
if (!StringUtil.objectIsNUll(requestType) && requestType.equals("ajax"))
{
List<NodegroupPositionAll> nodegroupPositionAllList = new ArrayList<NodegroupPositionAll>();
NodegroupPositionAll nodegroupPositionAll = new NodegroupPositionAll();
nodegroupPositionAll.setTopoLineInfoList(topoLineInfos);
nodegroupPositionAll.setTopoNodeInfoList(topoNodeInfos);
nodegroupPositionAllList.add(nodegroupPositionAll);
JsonConfig jsonConfig=new JsonConfig();
jsonConfig.setExcludes(new String[]{"handler","hibernateLazyInitializer"});
JSONArray fromObject = JSONArray.fromObject(nodegroupPositionAllList,jsonConfig);
outJsonArray(fromObject);
}
}catch(Exception e){
e.printStackTrace();
}
return "showTopo";
}
//获取当前业务系统ID
public Long getSystemID(){
HttpSession session = getRequest().getSession(true);
Long systemId = (Long)session.getAttribute(Constant.SESSION_SYSTEM_LOGIN);
return systemId;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public List<TopoNodeInfo> getTopoNodeInfos() {
return topoNodeInfos;
}
public void setTopoNodeInfos(List<TopoNodeInfo> topoNodeInfos) {
this.topoNodeInfos = topoNodeInfos;
}
public List<TopoLineInfo> getTopoLineInfos() {
return topoLineInfos;
}
public void setTopoLineInfos(List<TopoLineInfo> topoLineInfos) {
this.topoLineInfos = topoLineInfos;
}
public List<TopoInfo> getTopoInfos() {
return topoInfos;
}
public void setTopoInfos(List<TopoInfo> topoInfos) {
this.topoInfos = topoInfos;
}
public Long getTopoInfoId() {
return topoInfoId;
}
public void setTopoInfoId(Long topoInfoId) {
this.topoInfoId = topoInfoId;
}
public String getRequestType() {
return requestType;
}
public void setRequestType(String requestType) {
this.requestType = requestType;
}
}

View File

@@ -0,0 +1,911 @@
package nis.nms.web.actions.nodePosition;
import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import nis.nms.core.Constants;
import nis.nms.domains.NodeGroupPosition;
import nis.nms.domains.NodegroupArrowPosition;
import nis.nms.domains.NodegroupBgimgPosition;
import nis.nms.domains.NodegroupPositionAll;
import nis.nms.domains.NodegroupTable;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Common;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import com.nis.util.StringUtil;
@Results( { @Result(name = "showTopo", value = "/page/show/nodeGroup/showTopo.jsp"),
@Result(name = "configTopo", value = "/page/show/nodeGroup/configTopo.jsp"),
@Result(name = "error", value = "/error.jsp") })
/**
* 拓扑图展示 jinsj 2013-06-03
*/
public class NodeGroupPositionAction extends BaseAction
{
private Logger logger = Logger.getLogger(NodeGroupPositionAction.class);
private static final long serialVersionUID = 1L;
private CommonService commonService;
private String action;
private String from;
private List<NodegroupTable> nodeGroupList = new ArrayList<NodegroupTable>();// 节点组列表
private List<NodeGroupPosition> nodeGroupPositionList = new ArrayList<NodeGroupPosition>();
private List<NodegroupArrowPosition> nodegroupArrowPositionList = new ArrayList<NodegroupArrowPosition>();
private List<NodegroupBgimgPosition> nodegroupBgimgPositionList = new ArrayList<NodegroupBgimgPosition>();
private String svgImagePath;
private String svgFileName = "showTopo.svg";
private NodeGroupPosition backgroudImg;
private String fielSeparator = System.getProperty("file.separator");
private String filePath;
private String requestType;
private String nodeGroupId;
private String nodegroupBgImgPositions;// 拓扑图配置页面的背景图片信息
private String nodegroupArrowPositions;// 拓扑图配置页面的箭头连线信息
public String executeAction()
{
String resultpage = "error";
if ("showTopo".equals(this.action))
{
resultpage = showNodeGroupTopo();
} else if ("getNodeList".equals(this.action))
{
resultpage = getNodeList();
} else if ("configTopo".equals(this.action))
{
resultpage = configTopo();
} else if ("saveConfigTopo".equals(this.action))
{
resultpage = saveConfigTopo();
}
return resultpage;
}
/**
* 保存拓扑图配置信息 TODO
*
* @author jinshujuan Oct 24, 2013
* @version 1.0
* @return
*/
private String saveConfigTopo()
{
try
{
System.out.println("nodegroupBgImgPositions:"+nodegroupBgImgPositions);
System.out.println("nodegroupArrowPositions:"+nodegroupArrowPositions);
String[] nodegroupBgImgPositionInfos = nodegroupBgImgPositions.split(":");
for (String nodegroupBgImgPositionInfo: nodegroupBgImgPositionInfos)
{
String[] bgImgInfos = nodegroupBgImgPositionInfo.split(",");
// 1.设置NodegroupBgimgPosition背景图片信息
NodegroupBgimgPosition nodegroupBgimgPosition = new NodegroupBgimgPosition();
nodegroupBgimgPosition.setGroupId(Long.parseLong(bgImgInfos[0]));
nodegroupBgimgPosition.setFigureFill(bgImgInfos[1] + ".png");
nodegroupBgimgPosition.setFigureX(Long.parseLong(bgImgInfos[2]));
nodegroupBgimgPosition.setFigureY(Long.parseLong(bgImgInfos[3]));
nodegroupBgimgPosition.setFigureWidth(Long.parseLong(bgImgInfos[4]));
nodegroupBgimgPosition.setFigureHeight(Long.parseLong(bgImgInfos[5]));
nodegroupBgimgPosition.setSystemId(getSystemID());
nodegroupBgimgPosition.setCreateTime(new Date());
nodegroupBgimgPosition.setCreateUserid(getUserID());
nodegroupBgimgPositionList.add(nodegroupBgimgPosition);
// 2.设置NodeGroupPosition灯泡信息
NodeGroupPosition nodeGroupPosition = new NodeGroupPosition();
NodegroupTable nodeGroup = (NodegroupTable) commonService.get(NodegroupTable.class,
Long.parseLong(bgImgInfos[0]));
nodeGroupPosition.setNodeGroup(nodeGroup);
nodeGroupPosition.setFigureFill("green_bulb.png");
//根据不同的底图画灯泡的配置偏移量不同
if (bgImgInfos[1].equals("server"))
{
nodeGroupPosition.setFigureX(Long.parseLong(bgImgInfos[2])+22);
nodeGroupPosition.setFigureY(Long.parseLong(bgImgInfos[3])+26);
} else if (bgImgInfos[1].equals("core_switch"))
{
nodeGroupPosition.setFigureX(Long.parseLong(bgImgInfos[2])+32);
nodeGroupPosition.setFigureY(Long.parseLong(bgImgInfos[3])+18);
} else if (bgImgInfos[1].equals("switch"))
{
nodeGroupPosition.setFigureX(Long.parseLong(bgImgInfos[2])+20);
nodeGroupPosition.setFigureY(Long.parseLong(bgImgInfos[3])+15);
} else if (bgImgInfos[1].equals("device"))
{
nodeGroupPosition.setFigureX(Long.parseLong(bgImgInfos[2])+8);
nodeGroupPosition.setFigureY(Long.parseLong(bgImgInfos[3])-4);
} else if (bgImgInfos[1].equals("router"))
{
nodeGroupPosition.setFigureX(Long.parseLong(bgImgInfos[2])+3);
nodeGroupPosition.setFigureY(Long.parseLong(bgImgInfos[3]));
}
nodeGroupPosition.setFigureWidth(25l);
nodeGroupPosition.setFigureHeight(25l);
nodeGroupPosition.setSystemId(getSystemID());
nodeGroupPosition.setPgroupId(0l);
nodeGroupPosition.setShowLevel(2l);
nodeGroupPosition.setFigureType("image");
nodeGroupPosition.setShowStatus(0l);
nodeGroupPosition.setAddTime(new Date());
nodeGroupPosition.setAddUserid(getUserID());
nodeGroupPositionList.add(nodeGroupPosition);
}
// 3.设置NodegroupArrowPosition箭头信息
String[] nodegroupArrowPositionInfos = nodegroupArrowPositions.split(":");
for (String nodegroupArrowPositionInfo: nodegroupArrowPositionInfos)
{
String[] arrowLineInfos = nodegroupArrowPositionInfo.split(";");
for (String arrowLineInfo: arrowLineInfos)
{
String[] lineInfos = arrowLineInfo.split(",");
NodegroupArrowPosition nodegroupArrowPosition = new NodegroupArrowPosition();
NodegroupTable srcNodeGroup = (NodegroupTable) commonService
.get(NodegroupTable.class, Long.parseLong(lineInfos[0]));
NodegroupTable descNodeGroup = (NodegroupTable) commonService
.get(NodegroupTable.class, Long.parseLong(lineInfos[1]));
nodegroupArrowPosition.setSrcNodeGroup(srcNodeGroup);
nodegroupArrowPosition.setDescNodeGroup(descNodeGroup);
nodegroupArrowPosition.setFigureX(Long.parseLong(lineInfos[2]));
nodegroupArrowPosition.setFigureY(Long.parseLong(lineInfos[3]));
nodegroupArrowPosition.setFigureWidth(Long.parseLong(lineInfos[4]));
nodegroupArrowPosition.setFigureHeight(Long.parseLong(lineInfos[5]));
System.out.println(lineInfos[6]);
String fillImg = lineInfos[6] == "" ? "" : lineInfos[6].split("/")[2]
.substring(0, lineInfos[6].split("/")[2].length() - 1);
nodegroupArrowPosition.setFigureFill(fillImg);
nodegroupArrowPosition.setSystemId(getSystemID());
nodegroupArrowPosition.setCreateTime(new Date());
nodegroupArrowPosition.setCreateUserid(getUserID());
commonService.save(nodegroupArrowPosition);
nodegroupArrowPositionList.add(nodegroupArrowPosition);
}
}
// 批量新增拓扑图相关配置信息
commonService.saveOrUpdate(nodegroupBgimgPositionList);
commonService.saveOrUpdate(nodeGroupPositionList);
commonService.saveOrUpdate(nodegroupArrowPositionList);
} catch (Exception e)
{
logger.error("Failed to save topology map configuration information", e);
}
return configTopo();
}
/**
*
* TODO 业务逻辑拓扑展示
*
* @author jinshujuan Jun 3, 2013
* @version 1.0
* @return
*/
private String showNodeGroupTopo()
{
/**
* 涉及的3个表说明
*
* NODEGROUP_POSITION 对应的实体类 NodeGroupPosition showLevel=1是底图 showLevel=2是灯泡位置信息
* NODEGROUP_BGIMG_POSITION 对应的实体类 NodegroupBgimgPosition 节点组对应的图标位置信息
* NODEGROUP_ARROW_POSITION 对应的实体类 NodegroupArrowPosition 带箭头的线信息
*/
try
{
//------------1. 获取底图------------
String hql = " from NodeGroupPosition where showLevel =1 and systemId="
+ this.getSystemID();
nodeGroupPositionList = commonService.find(hql);
if (nodeGroupPositionList.size() > 0)
{
backgroudImg = nodeGroupPositionList.get(0);
}
//------------2. 获取节点组------------
hql = " from NodegroupTable where 1=1 ";
boolean ADMFlag = this.getAdminMark();
this.getRequest().setAttribute("ADMFlag", ADMFlag);
if (!ADMFlag)
{
// 如果当前登录选择了业务系统,则只做和本业务系统相关的操作
if (this.getSystemID() != null)
{
hql += " and systemId = " + this.getSystemID();
}
// 1 发布人查看,2 发布人所在组查看,3 系统内全部人员可看
hql += " and (";
hql += " (viewLevel=1 and createUserId=" + this.getUserID() + ")";
hql += " or (viewLevel=2 and createUsergroupId in (select jsbh from XtYhJsIndex "
+ " where type=1 and yhbh='" + this.getUser().getYhbh() + "') )";
if (this.getSystemID() != null)
{
hql += " or (viewLevel=3 and systemId=" + this.getSystemID() + ")";
} else
{
hql += " or (viewLevel=3 and systemId in"
+ " (select systemId from GorupSystemTable where userGroupId in"
+ " (select jsbh from XtYhJsIndex where type=1 and yhbh='"
+ this.getUser().getYhbh() + "')" + " ) )";
}
hql += ")";
}
//查询该用户在业务系统下拥有权限的节点组
nodeGroupList = this.commonService.find(hql);
// 每次查询前先将箭头表的数据都修改为绿色正常图
String sql = "UPDATE nodegroup_arrow_position t SET t.figure_fill = replace(t.figure_fill,'red','green') WHERE t.system_id="
+ this.getSystemID();
commonService.updateBySql(sql);
//------------3.遍历节点组 设置节点组是否处于异常状态,用红灯、红线标识节点组异常,绿灯、绿线标识节点组正常------------
for (NodegroupTable nodegroup: nodeGroupList)
{
//@2018-3-9 fang 修改 首先查询符合条件的id在拼接sql适配mysql
String groupIdSql = "select group_id from nodegroup_table t where 1=1 ";
String ids = this.commonService.getGroupIdStartWith(groupIdSql, "t.group_id = " +nodegroup.getGroupId());
// 查询节点组状态 1:如果有紧急告警则为异常状态 2如果检测设置但是没有检测数据则为异常状态
/*String countsql = "select COUNT( distinct nt.node_id) from detection_info_new diw "
+ "left join node_table nt on diw.seq_id = nt.seq_id where diw.DETECTIONED_STATE<>1 AND diw.valid=1 AND diw.police_emergent=0 "
+ "and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) "
+ "and nt.NODE_STATE = 0 and nt.node_group_id in (select t.group_id from nodegroup_table t start with t.group_id ="
+ nodegroup.getGroupId()
+ " connect by prior t.group_id = t.parent_group_id)";*/
String countsql = "select COUNT( distinct nt.node_id) from detection_info_new diw "
+ "left join node_table nt on diw.seq_id = nt.seq_id where diw.DETECTIONED_STATE<>1 AND diw.valid=1 AND diw.police_emergent=0 "
+ "and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) "
+ "and nt.NODE_STATE = 0 and nt.node_group_id in ("+ ids +")";
List countList = commonService.executeSQL(countsql);
// 显示状态 0正常 1异常
long showStatus = 0l;
if (countList != null && countList.size() > 0)
{
Integer count = Integer.valueOf(countList.get(0).toString());
//BigDecimal count = (BigDecimal) countList.get(0);
if (count > 0)
{
showStatus = 1l;
}
}
String positionHql = " from NodeGroupPosition where systemId=" + this.getSystemID()
+ " and nodeGroup.groupId = " + nodegroup.getGroupId();
List<NodeGroupPosition> list = commonService.find(positionHql);
NodeGroupPosition nodeGroupPosition = new NodeGroupPosition();
if (list != null && list.size() > 0)
{
nodeGroupPosition = list.get(0);
// 更新节点组灯
updateObj(nodeGroupPosition, showStatus);
//@2018-3-9 fang 修改 首先查询符合条件的id在拼接sql适配mysql
// String gsql = "select group_id from nodegroup_table t where 1=1 ";
// String gids = this.commonService.getGroupIdStartWith(gsql, "t.group_id = " +nodegroup.getGroupId());
// 更新箭头
/*sql = "SELECT din.detectioned_state from detection_info_new din WHERE din.detection_set_info_id IN ( "
+ "SELECT dsi.id from detection_set_info dsi WHERE dsi.detection_set_state=1 AND dsi.check_type_id IN ("
+ "SELECT cti.id from check_type_info cti WHERE cti.check_type_name='NMSClient') "
+ ") AND din.valid=1 AND din.seq_id IN (SELECT t.seq_id from node_table t WHERE t.node_group_id in "
+ "(select nt.group_id from nodegroup_table nt start with nt.group_id ="
+ nodegroup.getGroupId()
+ " connect by prior nt.group_id = nt.parent_group_id)"
+ " AND t.node_state=0) ORDER by din.data_arrive_time DESC";*/
sql = "SELECT din.detectioned_state from detection_info_new din WHERE din.detection_set_info_id IN ( "
+ "SELECT dsi.id from detection_set_info dsi WHERE dsi.detection_set_state=1 AND dsi.check_type_id IN ("
+ "SELECT cti.id from check_type_info cti WHERE cti.check_type_name='NMSClient') "
+ ") AND din.valid=1 AND din.seq_id IN (SELECT t.seq_id from node_table t WHERE t.node_group_id in "
+ "("+ids+")"
+ " AND t.node_state=0) ORDER by din.data_arrive_time DESC";
List detectionStatusList = commonService.executeSQL(sql);
if (detectionStatusList.size() > 0)
{
String status = detectionStatusList.get(0).toString();
// 状态1正常其他都为异常
if (!status.equals("1"))
{
System.out.println("流量异常的节点:" + nodegroup.getGroupId() + " "
+ nodegroup.getGroupName());
sql = "UPDATE nodegroup_arrow_position t SET t.figure_fill = replace(t.figure_fill,'green','red') WHERE t.system_id="
+ this.getSystemID()
+ " and t.src_group_id="
+ nodegroup.getGroupId()
+ " OR t.desc_group_id="
+ nodegroup.getGroupId();
commonService.updateBySql(sql);
}
}
}
}
//------------4. 查询3表信息供jsp页面展示用------------
//------------4.1 查询节点组对应的图标位置信息 并且设置鼠标悬浮在节点组图标上显示该节点组对应的节点信息------------
hql = " from NodegroupBgimgPosition t WHERE t.systemId=" + getSystemID();
nodegroupBgimgPositionList = commonService.find(hql);
for (NodegroupBgimgPosition nodegroupBgimgPosition: nodegroupBgimgPositionList)
{
String nodeInfo = "";
if (nodegroupBgimgPosition.getGroupId() != null)
{
long groupId = nodegroupBgimgPosition.getGroupId();
sql = "SELECT distinct t.node_ip,t.node_group_id ,nb.box_id,nr.room_ispn,nrl.lattice_row_position,nrl.lattice_col_position,nb.ispn from node_table t "
+ "LEFT JOIN node_box_table nb ON t.node_box_ispn = nb.ispn "
+ "LEFT JOIN node_room_lattice_table nrl ON nrl.node_box_id = nb.box_id"
+ " LEFT JOIN node_room_table nr ON nr.room_id = nrl.room_id WHERE t.system_id="
+ getSystemID()
+ " AND t.node_state=0 AND t.node_group_id in "
+ "(select t1.group_id from nodegroup_table t1 where t1.group_id ="
+ groupId + ")";
List<Object> nodeList = commonService.executeSQL(sql);
for (Object object: nodeList)
{
Object[] obj = (Object[]) object;
String nodeBoxInfo = "";
if (obj[3] != null)
{
nodeBoxInfo += getI18nText("i18n_NodeGroupPositionAction.saveConfigTopo.room_n81i")+":" + obj[3].toString() + " ";
}
if (obj[4] != null && obj[5] != null)
{
nodeBoxInfo += obj[4].toString() + getI18nText("i18n_NodeGroupPositionAction.saveConfigTopo.row_n81i") + obj[5].toString() + getI18nText("i18n_NodeGroupPositionAction.saveConfigTopo.column_n81i");
}
if (obj[6] != null)
{
nodeBoxInfo += getI18nText("i18n_NodeGroupPositionAction.saveConfigTopo.box_n81i")+":" + obj[6].toString();
}
nodeInfo += "<div style='width: 90px;height: 22px;cursor: pointer;' onclick='getNodeBox(&quot;"
+ obj[1]
+ "&quot;,&quot;"
+ obj[2]
+ "&quot;,&quot;"
+ nodeBoxInfo
+ "&quot;,&quot;" + obj[0] + "&quot;)' >" + obj[0] + "</div>";
}
}
if (nodeInfo == "")
{
nodeInfo = getI18nText("i18n_NodeGroupPositionAction.saveConfigTopo.groupNoNode_n81i");
}
nodegroupBgimgPosition.setNodeInfo(nodeInfo);
}
//------------4.2 查询灯泡图标位置信息------------
sql = "SELECT t.id,t.group_id,t.figure_x,t.figure_y,t.figure_width,t.figure_height,t.figure_fill,t.show_status "
+ "from nodegroup_position t WHERE t.show_level=2 AND t.system_id= "
+ this.getSystemID();
nodeGroupPositionList = commonService.executeSQL(sql);
//------------4.3 查询箭头图标位置信息------------
sql = "SELECT t.id,t.src_group_id,t.desc_group_id,t.figure_x,t.figure_y,t.figure_width,t.figure_height,t.figure_fill "
+ "from nodegroup_arrow_position t WHERE t.system_id=" + this.getSystemID();
nodegroupArrowPositionList = commonService.executeSQL(sql);
// 5分钟刷新一次 ajax请求给返回数据
if (!StringUtil.isBlank(requestType) && requestType.equals("ajax"))
{
List<NodegroupPositionAll> nodegroupPositionAllList = new ArrayList<NodegroupPositionAll>();
NodegroupPositionAll nodegroupPositionAll = new NodegroupPositionAll();
nodegroupPositionAll.setNodeGroupPositionList(nodeGroupPositionList);
nodegroupPositionAll.setNodegroupArrowPositionList(nodegroupArrowPositionList);
nodegroupPositionAllList.add(nodegroupPositionAll);
outJsonArray(nodegroupPositionAllList);
}
} catch (Exception e)
{
e.printStackTrace();
}
return "showTopo";
}
/**
*
* TODO 更新系统节点组位置信息表记录的状态,显示图 同步更新灯泡
*
* @author jinshujuan Jun 4, 2013
* @version 1.0
* @param nodeGroupPosition
* @param showStatus
*/
private void updateObj(NodeGroupPosition nodeGroupPosition, long showStatus)
{
try
{
String figureFill = "green_bulb.png";
if (showStatus == 1)
{
figureFill = "alarm.gif";
}
nodeGroupPosition.setFigureFill(figureFill);
nodeGroupPosition.setShowStatus(showStatus);
nodeGroupPosition.setLastUpdateTime(new Date());
nodeGroupPosition.setLastUpdateUserid(getUserID());
commonService.update(nodeGroupPosition);
} catch (Exception e)
{
e.printStackTrace();
}
}
/**
*
* TODO 获取节点组下的所有节点
*
* @author jinshujuan Jul 2, 2013
* @version 1.0
* @return
*/
private String getNodeList()
{
try
{
System.out.println(nodeGroupId);
if (!StringUtil.isBlank(nodeGroupId))
{
String sql = "SELECT distinct t.node_ip from node_table t WHERE t.system_id="
+ getSystemID() + " AND t.node_state=0 AND t.node_group_id=" + nodeGroupId;
List nodeIpList = commonService.executeSQL(sql);
outJsonArray(nodeIpList);
}
} catch (Exception e)
{
e.printStackTrace();
}
return null;
}
/**
* 该方法废弃 根据系统节点组位置信息表创建拓扑图对应的SVG文件
*
* @author jinshujuan Jun 3, 2013
* @version 1.0
* @param nodeGroupPositionList
*/
private void createSvgFile(List<NodeGroupPosition> nodeGroupPositionList)
{
try
{
StringBuffer mainInfo = new StringBuffer("");
svgImagePath = Common.buildPath(getRequest().getContextPath()) + fielSeparator
+ Constants.TOPO_SVG_IMAGES_PATH;
for (NodeGroupPosition nodeGroupPosition: nodeGroupPositionList)
{
String xmlInfo = getElementInfo(nodeGroupPosition);
if (!StringUtil.isBlank(xmlInfo))
{
mainInfo.append(xmlInfo);
}
}
StringBuffer xml = new StringBuffer("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
xml.append("\n");
xml
.append("<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" "
+ " xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"100%\" height=\"100%\" >");
// 底图
xml.append(" \n <image x=\"" + backgroudImg.getFigureX() + "\" y=\""
+ backgroudImg.getFigureY() + "\" width=\"" + backgroudImg.getFigureWidth()
+ "\" height=\"" + backgroudImg.getFigureHeight()
+ "\" stroke=\"1\" stroke-width=\"1\" xlink:href=\"" + svgImagePath
+ backgroudImg.getFigureFill() + "\" /> \n ");
// 获取position方法
// xml.append(drawImg());
xml.append(mainInfo.toString());
xml.append("\n");
xml.append("</svg>");
File file = new File(filePath);
if (file.exists())
{
file.delete();
}
FileUtils.writeStringToFile(file, xml.toString(), "UTF-8");
} catch (Exception e)
{
e.printStackTrace();
}
}
/**
* 测试阶段用 定位每个节点组 告警位置 用于开发测试阶段 TODO
*
* @author jinshujuan Jun 7, 2013
* @version 1.0
* @return
*/
private String drawImg()
{
StringBuffer xml = new StringBuffer();
// 电信分流交换机
xml
.append(" \n <image x=\"375\" y=\"50\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "red_bulb.png\" /> \n ");
// 电信一级
xml
.append(" \n <image x=\"452\" y=\"50\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "red_bulb.png\" /> \n ");
// 电信汇接交换机
xml
.append(" \n <image x=\"523\" y=\"48\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "red_bulb.png\" /> \n ");
// 电信二级
xml
.append(" \n <image x=\"602\" y=\"51\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 管控平台后端服务器
xml
.append(" \n <image x=\"858\" y=\"58\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "red_bulb.png\" /> \n ");
// ---------------------------------------------
// 移动铁通共用专业分流交换机
xml
.append(" \n <image x=\"378\" y=\"240\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 移动一级
xml
.append(" \n <image x=\"450\" y=\"181\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 移动汇接交换机
xml
.append(" \n <image x=\"528\" y=\"178\" width=\"23\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 移动二级
xml
.append(" \n <image x=\"606\" y=\"180\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 管控平台日志库
xml
.append(" \n <image x=\"858\" y=\"178\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 铁通一级
xml
.append(" \n <image x=\"450\" y=\"312\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 铁通汇接交换机
xml
.append(" \n <image x=\"528\" y=\"308\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 铁通二级
xml
.append(" \n <image x=\"605\" y=\"312\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 管控平台核心交换机
xml
.append(" \n <image x=\"732\" y=\"310\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 管控平台邮件加载
xml
.append(" \n <image x=\"858\" y=\"312\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// --------------------
// 联通教育共用专业分流交换机
xml
.append(" \n <image x=\"378\" y=\"490\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 联通教育一级
xml
.append(" \n <image x=\"450\" y=\"434\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 联通教育汇接交换机
xml
.append(" \n <image x=\"530\" y=\"430\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 联通教育二级 \
xml
.append("\n <image x=\"605\" y=\"432\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 087 系统
xml
.append(" \n <image x=\"859\" y=\"429\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 教育一级
xml
.append(" \n <image x=\"450\" y=\"558\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 分中心
xml
.append(" \n <image x=\"859\" y=\"550\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 界面服务器
xml
.append(" \n <image x=\"944\" y=\"504\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 科技一级
xml
.append(" \n <image x=\"450\" y=\"665\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 科技汇接交换机
xml
.append(" \n <image x=\"532\" y=\"658\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 黑盒服务器
xml
.append(" \n <image x=\"859\" y=\"676\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
// 省平台服务器
xml
.append(" \n <image x=\"946\" y=\"626\" width=\"25\" height=\"25\" stroke=\"1\" stroke-width=\"1\" xlink:href=\""
+ svgImagePath + "green_bulb.png\" /> \n ");
return xml.toString();
}
/**
* 该方法废弃 TODO 将每个节点组位置信息转换为svg格式的文本块
*
* @author jinshujuan Jun 3, 2013
* @version 1.0
* @param nodeGroupPosition
* @return
*/
private String getElementInfo(NodeGroupPosition nodeGroupPosition)
{
String elementInfo = "";
try
{
if (!StringUtil.isEmpty(nodeGroupPosition))
{
String figureType = nodeGroupPosition.getFigureType();
if ("image".equals(figureType))
{
elementInfo = " \n <image x=\"" + nodeGroupPosition.getFigureX() + "\" y=\""
+ nodeGroupPosition.getFigureY() + "\" width=\""
+ nodeGroupPosition.getFigureWidth() + "\" height=\""
+ nodeGroupPosition.getFigureHeight() + "\" stroke=\""
+ nodeGroupPosition.getFigureStroke() + "\" stroke-width=\""
+ nodeGroupPosition.getFigureStrokeWidth() + "\" xlink:href=\""
+ svgImagePath + nodeGroupPosition.getFigureFill() + "\" /> \n ";
}
}
} catch (Exception e)
{
e.printStackTrace();
}
return elementInfo;
}
/**
*
* 获取异常信息节点
*
* @author jinshujuan Jun 9, 2013
* @version 1.0
*/
public void getAlarmNode()
{
try
{
if (!StringUtil.isBlank(nodeGroupId))
{
//@2018-3-9 fang 修改 首先查询符合条件的id在拼接sql适配mysql
String gsql = "select group_id from nodegroup_table t where t.system_id= "+getSystemID();
String gids = this.commonService.getGroupIdStartWith(gsql, "t.group_id = " +nodeGroupId);
/*String sql = "SELECT distinct nt.node_id,nt.node_ip,nt.node_name,nt.node_type,nt.seq_id from detection_info_new diw "
+ "left join node_table nt on diw.seq_id = nt.seq_id where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 "
+ "and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) "
+ "and nt.NODE_STATE = 0 and nt.node_group_id in (select t.group_id from nodegroup_table t WHERE t.system_id="
+ getSystemID()
+ " start with t.group_id ="
+ nodeGroupId
+ " connect by prior t.group_id = t.parent_group_id)";*/
String sql = "SELECT distinct nt.node_id,nt.node_ip,nt.node_name,nt.node_type,nt.seq_id from detection_info_new diw "
+ "left join node_table nt on diw.seq_id = nt.seq_id where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 "
+ "and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) "
+ "and nt.NODE_STATE = 0 and nt.node_group_id in ("+gids+")";
List<Object> nodeList = commonService.executeSQL(sql);
if (nodeList != null && nodeList.size() > 0)
{
outJsonArray(nodeList);
}
}
} catch (Exception e)
{
e.printStackTrace();
}
}
/**
* 拓扑图配置界面 TODO
*
* @author jinshujuan Jul 15, 2013
* @version 1.0
* @return
*/
private String configTopo()
{
try
{
// 获取底图
String hql = " from NodeGroupPosition where showLevel =1 and systemId="
+ this.getSystemID();
nodeGroupPositionList = commonService.find(hql);
if (nodeGroupPositionList.size() > 0)
{
backgroudImg = nodeGroupPositionList.get(0);
}
hql = " from NodegroupBgimgPosition t WHERE t.systemId=" + getSystemID()
+ " and to_char(createTime,'yyyy-MM-dd') >= to_char(Sysdate,'yyyy-MM-dd') ";
nodegroupBgimgPositionList = commonService.find(hql);
String sql = "SELECT t.id,t.group_id,t.figure_x,t.figure_y,t.figure_width,t.figure_height,t.figure_fill,t.show_status "
+ "from nodegroup_position t WHERE t.show_level=2 AND t.system_id= "
+ this.getSystemID()
+ " and to_char(t.add_time,'yyyy-MM-dd') >= to_char(Sysdate,'yyyy-MM-dd')";
nodeGroupPositionList = commonService.executeSQL(sql);
sql = "SELECT t.id,t.src_group_id,t.desc_group_id,t.figure_x,t.figure_y,t.figure_width,t.figure_height,t.figure_fill "
+ "from nodegroup_arrow_position t WHERE t.system_id="
+ this.getSystemID()
+ " and to_char(t.create_time,'yyyy-MM-dd') >= to_char(Sysdate,'yyyy-MM-dd')";
nodegroupArrowPositionList = commonService.executeSQL(sql);
} catch (Exception e)
{
e.printStackTrace();
}
return "configTopo";
}
public CommonService getCommonService()
{
return commonService;
}
public void setCommonService(CommonService commonService)
{
this.commonService = commonService;
}
public String getAction()
{
return action;
}
public void setAction(String action)
{
this.action = action;
}
public String getFrom()
{
return from;
}
public void setFrom(String from)
{
this.from = from;
}
public List<NodegroupTable> getNodeGroupList()
{
return nodeGroupList;
}
public void setNodeGroupList(List<NodegroupTable> nodeGroupList)
{
this.nodeGroupList = nodeGroupList;
}
public String getSvgImagePath()
{
return svgImagePath;
}
public void setSvgImagePath(String svgImagePath)
{
this.svgImagePath = svgImagePath;
}
public NodeGroupPosition getBackgroudImg()
{
return backgroudImg;
}
public void setBackgroudImg(NodeGroupPosition backgroudImg)
{
this.backgroudImg = backgroudImg;
}
public List<NodeGroupPosition> getNodeGroupPositionList()
{
return nodeGroupPositionList;
}
public void setNodeGroupPositionList(List<NodeGroupPosition> nodeGroupPositionList)
{
this.nodeGroupPositionList = nodeGroupPositionList;
}
public String getRequestType()
{
return requestType;
}
public void setRequestType(String requestType)
{
this.requestType = requestType;
}
public String getNodeGroupId()
{
return nodeGroupId;
}
public void setNodeGroupId(String nodeGroupId)
{
this.nodeGroupId = nodeGroupId;
}
public List<NodegroupArrowPosition> getNodegroupArrowPositionList()
{
return nodegroupArrowPositionList;
}
public void setNodegroupArrowPositionList(
List<NodegroupArrowPosition> nodegroupArrowPositionList)
{
this.nodegroupArrowPositionList = nodegroupArrowPositionList;
}
public List<NodegroupBgimgPosition> getNodegroupBgimgPositionList()
{
return nodegroupBgimgPositionList;
}
public void setNodegroupBgimgPositionList(
List<NodegroupBgimgPosition> nodegroupBgimgPositionList)
{
this.nodegroupBgimgPositionList = nodegroupBgimgPositionList;
}
public String getNodegroupBgImgPositions()
{
return nodegroupBgImgPositions;
}
public void setNodegroupBgImgPositions(String nodegroupBgImgPositions)
{
this.nodegroupBgImgPositions = nodegroupBgImgPositions;
}
public String getNodegroupArrowPositions()
{
return nodegroupArrowPositions;
}
public void setNodegroupArrowPositions(String nodegroupArrowPositions)
{
this.nodegroupArrowPositions = nodegroupArrowPositions;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,741 @@
package nis.nms.web.actions.nodePosition;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import nis.nms.domains.NodeRoomLatticeTable;
import nis.nms.domains.NodeRoomTable;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Constant;
import nis.nms.util.ExportUtils;
import nis.nms.util.Page;
import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name="queryRoomInfo", value = "/page/show/nodeRoom/roomInfoList.jsp"),
@Result(name="addRoomInfo", value = "/page/show/nodeRoom/addRoomInfo.jsp"),
@Result(name="updateRoomInfo", value = "/page/show/nodeRoom/updateRoomInfo.jsp"),
@Result(name = "showError", value = "/showImportError.jsp"),
@Result(name="error", value ="/error.jsp")
})
/**
* 机房管理相关操作
*/
public class RoomManageAction extends BaseAction {
private Logger logger = Logger.getLogger(RoomManageAction.class);
private static final long serialVersionUID = 1L;
private CommonService commonService;
private int pageNo = 1;
private int pageSize =this.getDefaultPageSize(); //每页显示的记录条数
private Page page;
private String action;
private List<NodeRoomTable> nodeRoomList;
private NodeRoomTable nodeRoom;
private Long[] ids;
private String rIspn;
private String descinfo;
private String fromWhere;
private String isComplete;
// 导入节点文件
private File myFile;
private String myFileFileName;
private String roomid;
private String roomIspn;
public String getRoomid() {
return roomid;
}
public void setRoomid(String roomid) {
this.roomid = roomid;
}
public String getRoomIspn() {
return roomIspn;
}
public void setRoomIspn(String roomIspn) {
this.roomIspn = roomIspn;
}
public File getMyFile() {
return myFile;
}
public void setMyFile(File myFile) {
this.myFile = myFile;
}
public String getMyFileFileName() {
return myFileFileName;
}
public void setMyFileFileName(String myFileFileName) {
this.myFileFileName = myFileFileName;
}
@Override
public String executeAction() throws Exception {
try{
String resultpage = "";
this.getRequest().setAttribute("fromWhere", fromWhere);
if("query".equals(this.action)){
resultpage = this.queryRoomInfo();
}else if("openAdd".equals(this.action)){
this.getRequest().setAttribute("fromWhere", fromWhere);
this.getRequest().setAttribute("maxRoomRows", Constant.MAX_ROOM_ROWS);
this.getRequest().setAttribute("maxRoomCols", Constant.MAX_ROOM_Cols);
resultpage = "addRoomInfo";
}else if("doAdd".equals(this.action)){
resultpage = this.addRoomInfo();
}else if("openUpdate".equals(this.action)){
this.getRequest().setAttribute("maxRoomRows", Constant.MAX_ROOM_ROWS);
this.getRequest().setAttribute("maxRoomCols", Constant.MAX_ROOM_Cols);
resultpage = this.openUpdRoom();
}else if("doUpdate".equals(this.action)){
this.doUpdRoom();
}else if("del".equals(this.action)){
resultpage = this.delRoomInfo();
}else if ("downloadExample".equals(this.action)) {
resultpage = downloadExample();
}else if ("importXls".equals(this.action)) {
resultpage = importXls();
}else if ("emportCurrentXls".equals(this.action)) {
resultpage = emportCurrentXls();
}else if ("emportAllXls".equals(this.action)) {
resultpage = emportAllXls();
}else if("AjaxCheck".equals(this.action)){
ajaxCheck();
resultpage = null;
}else if("roomManagerCheck".equals(this.action)){
roomManagerCheck();
return null;
}else{
resultpage = this.queryRoomInfo();
}
return resultpage;
} catch (Exception e) {
e.printStackTrace();
return "error";
}
}
// 模板下载 程辉 2013-5-13新增
public String downloadExample() {
try {
String hql = "select roomIspn,roomRows,roomCols,roomDesc from NodeRoomTable";
page = this.commonService.findByPage(hql, 1, 3);
List st = (List) page.getResult();
String[] title = { getI18nText("i18n_RoomManageAction.downloadExample.title.roomId_n81i"),
getI18nText("i18n_RoomManageAction.downloadExample.title.roomRows_n81i"),
getI18nText("i18n_RoomManageAction.downloadExample.title.roomColumns_n81i"),
getI18nText("i18n_RoomManageAction.downloadExample.title.rootDesc_n81i") };
String[] colu = { "0", "1","2","3" };
ExportUtils m = new ExportUtils();
m.setAutoSizeColumn(true);
m.exportExcel(getI18nText("i18n_RoomManageAction.downloadExample.roomInfoTable_n81i"), st, title, colu,"downloadExample");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
// 导入 程辉 2013-5-8新增
public String importXls() {
String errorInfo = "";
try {
List<String> headerList = new ArrayList<String>();
List<List<String>> rowList = new ArrayList<List<String>>();
Workbook workbook = null;
if (myFileFileName.endsWith(".xlsx")) {
workbook = new XSSFWorkbook(new FileInputStream(myFile));
} else {
// 创建对Excel工作簿文件的引用
workbook = new HSSFWorkbook(new FileInputStream(myFile));
}
// 创建对工作表的引用,得到表的第一页
Sheet sheet = workbook.getSheetAt(0);
// 读取左上端单元
// 记录存储数据条数
int count = 0;
// 记录读入excel数据条数
int sum = (sheet.getLastRowNum());
for (short i = 1; i <= sheet.getLastRowNum(); i++) {
String roomIspn ="";
double roomRows =0;
double roomCols =0;
String roomDesc ="";
List<String> errorList = new ArrayList<String>();
Row row = sheet.getRow(i);
Cell cell_1 = row.getCell((short) 0);
Cell cell_2 = row.getCell((short) 1);
Cell cell_3 = row.getCell((short) 2);
Cell cell_4 = row.getCell((short) 3);
if ((null == cell_1 || 3 == cell_1.getCellType())
&& (null == cell_2 || 3 == cell_2.getCellType())
&& (null == cell_3 || 3 == cell_3.getCellType())
&& (null == cell_4 || 3 == cell_4.getCellType())){
sum--;
}else {
// 机房编号
if (null == cell_1) {
errorInfo += getI18nText("i18n_RoomManageAction.downloadExample.errorInfo1_n81i",i+"");
} else if (cell_1.getCellType() == Cell.CELL_TYPE_STRING) {
if ("".equals(cell_1.getStringCellValue())) {
errorInfo += getI18nText("i18n_RoomManageAction.downloadExample.errorInfo1_n81i",i+"");
} else {
roomIspn = cell_1.getStringCellValue().trim();
}
}else if (cell_1.getCellType() == Cell.CELL_TYPE_NUMERIC) {
roomIspn = String.valueOf((int)cell_1.getNumericCellValue());
} else {
errorInfo += getI18nText("i18n_RoomManageAction.downloadExample.errorInfo2_n81i",i+"");
}
// 机房行数
if (null == cell_2) {
errorInfo += getI18nText("i18n_RoomManageAction.downloadExample.errorInfo3_n81i",i+"");
} else if (cell_2.getCellType() == Cell.CELL_TYPE_NUMERIC) {
roomRows = cell_2.getNumericCellValue();
if(roomRows>Constant.MAX_ROOM_ROWS){
errorInfo += getI18nText("i18n_RoomManageAction.downloadExample.errorInfo4_n81i",i+"")+Constant.MAX_ROOM_ROWS+";";
}
}else{
errorInfo += getI18nText("i18n_RoomManageAction.downloadExample.errorInfo5_n81i",i+"");
}
// 机房列数
if(null == cell_3){
errorInfo += getI18nText("i18n_RoomManageAction.downloadExample.errorInfo6_n81i",i+"");
}else if (cell_3.getCellType() == Cell.CELL_TYPE_NUMERIC) {
roomCols = cell_3.getNumericCellValue();
if(roomCols>Constant.MAX_ROOM_Cols){
errorInfo += getI18nText("i18n_RoomManageAction.downloadExample.errorInfo7_n81i",i+"")+Constant.MAX_ROOM_Cols+";";
}
} else {
errorInfo += getI18nText("i18n_RoomManageAction.downloadExample.errorInfo8_n81i",i+"");
}
// 机房描述
if(null == cell_4){
}else if (cell_4.getCellType() == Cell.CELL_TYPE_STRING) {
if ("".equals(cell_4.getStringCellValue())) {
} else {
roomDesc = cell_4.getStringCellValue().trim();
if(roomDesc.length()>100){
errorInfo += getI18nText("i18n_RoomManageAction.downloadExample.errorInfo9_n81i",i+"");
}
}
}
if ("".equals(errorInfo)) {// 保存节点
errorInfo = this.saveNode(roomIspn,roomRows,roomCols,roomDesc);
}
if ("".equals(errorInfo)) {
count++;
} else {
errorList.add(roomIspn);
errorList.add(String.valueOf((int)roomRows));
errorList.add(String.valueOf((int)roomCols));
errorList.add(roomDesc);
errorList.add(errorInfo);
rowList.add(errorList);
errorInfo = "";
}
}
}
headerList.add(getI18nText("i18n_RoomManageAction.downloadExample.roomId_n81i"));
headerList.add(getI18nText("i18n_RoomManageAction.downloadExample.roomRows_n81i"));
headerList.add(getI18nText("i18n_RoomManageAction.downloadExample.roomColumns_n81i"));
headerList.add(getI18nText("i18n_RoomManageAction.downloadExample.roomDesc_n81i"));
headerList.add(getI18nText("i18n_RoomManageAction.downloadExample.errorInfo_n81i"));
this.getRequest().setAttribute("rowList", rowList);
this.getRequest().setAttribute("headerList", headerList);
if (count == sum && sum > 0) {
outHtmlString("<script type=\"text/javascript\">alert('i18n_RoomManageAction.downloadExample.success_n81i');this.location='roomManage.do?action=query'</script>");
return null;
//this.getRequest().setAttribute("MSG", 1);
//return this.queryRoomInfo();
} else if (sum == 0) {
this
.outHtmlString("<script>alert('i18n_RoomManageAction.downloadExample.selectFileIsNull_n81i');history.back();</script>");
return null;
}
} catch (Exception e) {
e.printStackTrace();
}
return "showError";
}
private String saveNode(String roomIspn,double roomRows,double roomCols,String roomDesc) {
String desc = "";
NodeRoomTable nodeRoomTable = new NodeRoomTable();
try {
// 保存节点信息
nodeRoomTable.setCreateDatetime(new Date());
nodeRoomTable.setCreateUserId(getUserID());
nodeRoomTable.setRoomCols((long)roomCols);
nodeRoomTable.setRoomRows((long)roomRows);
nodeRoomTable.setRoomIspn(roomIspn);
nodeRoomTable.setRoomDesc(roomDesc);
//判断机房编号是否已存在
List<NodeRoomTable> NodeRoomTableList = this.commonService.find(
"from NodeRoomTable where roomIspn=?", nodeRoomTable.getRoomIspn());
if (NodeRoomTableList != null && NodeRoomTableList.size() > 0) {
return getI18nText("i18n_RoomManageAction.downloadExample.roomIdExists_n81i");
}
this.commonService.save(nodeRoomTable);
//-----初始化机房位置表
List<Object> list2 = new ArrayList<Object>();
for(long i=1; i<=nodeRoomTable.getRoomRows(); i++){
for(long j=1; j<=nodeRoomTable.getRoomCols(); j++){
NodeRoomLatticeTable nlt = new NodeRoomLatticeTable();
nlt.setRoomId(nodeRoomTable.getRoomId());
nlt.setLatticeRowPosition(i);
nlt.setLatticeColPosition(j);
list2.add(nlt);
}
}
this.commonService.saveOrUpdate(list2);
} catch (Exception e) {
e.printStackTrace();
desc = getI18nText("i18n_RoomManageAction.downloadExample.nodeInfoImportErr_n81i");
}
return desc;
}
// 当前页导出 程辉 2013-5-8新增
public String emportCurrentXls() {
try {
String hql = "from NodeRoomTable where 1=1";
if(rIspn!=null && !"".equals(rIspn)){
hql += " and Upper(roomIspn) like '%" + rIspn.trim().toUpperCase() + "%'";
}
hql += " order by roomId desc";
page = this.commonService.findByPage(hql, pageNo, pageSize);
List<NodeRoomTable> nodeRoomList = (List<NodeRoomTable>)page.getResult();
String[] title = { getI18nText("i18n_RoomManageAction.downloadExample.roomId_n81i"),
getI18nText("i18n_RoomManageAction.downloadExample.roomRows_n81i"),
getI18nText("i18n_RoomManageAction.downloadExample.roomColumns_n81i"),
getI18nText("i18n_RoomManageAction.downloadExample.roomDesc_n81i") };
String[] colu = { "roomIspn","roomRows","roomCols","roomDesc" };
String url = "roomManage.do?action=query&rIspn="+rIspn+"&pageSize="+pageSize+"&pageNo="+pageNo;
ExportUtils m = new ExportUtils();
m.setAutoSizeColumn(true);
m.exportExcel(url,getI18nText("i18n_RoomManageAction.downloadExample.roomInfoTable_n81i"), nodeRoomList, title, colu);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
// 导出全部 程辉 2013-5-8新增
public String emportAllXls() {
try {
String hql = "from NodeRoomTable where 1=1";
if(rIspn!=null && !"".equals(rIspn)){
hql += " and Upper(roomIspn) like '%" + rIspn.trim().toUpperCase() + "%'";
}
hql += " order by roomId desc";
List<NodeRoomTable> nodeRoomList = this.commonService.find(hql);
String[] title = { getI18nText("i18n_RoomManageAction.downloadExample.roomId_n81i"),
getI18nText("i18n_RoomManageAction.downloadExample.roomRows_n81i"),
getI18nText("i18n_RoomManageAction.downloadExample.roomColumns_n81i"),
getI18nText("i18n_RoomManageAction.downloadExample.roomDesc_n81i") };
String[] colu = { "roomIspn","roomRows","roomCols","roomDesc" };
String url = "roomManage.do?action=query&rIspn="+rIspn+"&pageSize="+pageSize+"&pageNo="+pageNo;
ExportUtils m = new ExportUtils();
m.setAutoSizeColumn(true);
m.exportExcel(url,getI18nText("i18n_RoomManageAction.downloadExample.roomInfoTable_n81i"), nodeRoomList, title, colu);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public String queryRoomInfo(){
try {
isComplete = this.getRequest().getParameter("isComplete");
String hql = "from NodeRoomTable where 1=1";
if(rIspn!=null && !"".equals(rIspn)){
hql += " and Upper(roomIspn) like '%" + rIspn.trim().toUpperCase() + "%'";
}
hql += " order by roomId desc";
page = this.commonService.findByPage(hql, pageNo, pageSize);
nodeRoomList = (List<NodeRoomTable>)page.getResult();
} catch (Exception e) {
logger.error("Query room information is abnormal", e);
return "error";
}
return "queryRoomInfo";
}
public void ajaxCheck(){
List list = null;
try {
list = this.commonService.find("from NodeRoomTable where roomIspn=?",nodeRoom.getRoomIspn());
if(list!=null && list.size()>0){
this.outString("error");
return ;
}
} catch (Exception e) {
e.printStackTrace();
logger.info("添加机房配置校验异常",e);
this.outString("exception");
}
this.outString("success");
}
/**
* 新增机房初始化机房位置表机房有M行N列就插入M*N条数据初始化时NodeBoxID为空即表示未存放机柜
* @return
*/
public String addRoomInfo(){
// List list = null;
try {
//判断数据是否存在
/*list = this.commonService.find("from NodeRoomTable where roomIspn=?",nodeRoom.getRoomIspn());
if(list!=null && list.size()>0){
this.outHtmlString("<script>alert('记录已存在,请重新输入!');history.back();</script>");
return null;
}*/
nodeRoom.setCreateUserId(this.getUserID());
nodeRoom.setCreateDatetime(new Date());
this.commonService.save(nodeRoom);
//-----初始化机房位置表
List<Object> list2 = new ArrayList<Object>();
for(long i=1; i<=nodeRoom.getRoomRows(); i++){
for(long j=1; j<=nodeRoom.getRoomCols(); j++){
NodeRoomLatticeTable nlt = new NodeRoomLatticeTable();
nlt.setRoomId(nodeRoom.getRoomId());
nlt.setLatticeRowPosition(i);
nlt.setLatticeColPosition(j);
list2.add(nlt);
}
}
this.commonService.saveOrUpdate(list2);
//记录用户操作用于设置向导
if(fromWhere!=null && !"".equals(fromWhere)){
if(fromWhere.equals("formGuide")){
outHtmlString("<script type=\"text/javascript\">alert('i18n_RoomManageAction.downloadExample.success_n81i');this.location='roomManage.do?action=query&isComplete=0'</script>");
}
}else{
outHtmlString("<script type=\"text/javascript\">alert('i18n_RoomManageAction.downloadExample.success_n81i');this.location='roomManage.do?action=query'</script>");
}
} catch (Exception e) {
logger.error("Failed to add room information", e);
}
return null;
}
public String openUpdRoom(){
try {
if(ids!=null && ids.length>0){
List list = this.commonService.find(
"from NodeRoomTable where roomId=?", ids[0]);
if(list!=null && list.size()>0){
nodeRoom = (NodeRoomTable)list.get(0);
}
}
} catch (Exception e) {
logger.error("Query room modification error", e);
return "error";
}
return "updateRoomInfo";
}
public void roomManagerCheck(){
List list;
try {
list = this.commonService.find("from NodeRoomTable where roomIspn='"+nodeRoom.getRoomIspn()+"' and roomId <> "+nodeRoom.getRoomId());
if (list != null && list.size() > 0) {
this.outString("error");
return ;
}
} catch (Exception e) {
e.printStackTrace();
logger.error("Ajax query verification room number abnormal", e);
this.outString("exception");
}
this.outString("success");
}
/**
* 修改机房:
* 1、机房行列变更范围若已存放了机柜则不允许修改
* 2、机房行或列若是增大则直接在位置表中插入增大的记录机房行或列若是减小减小的范围若未放置机柜则删除位置表记录
* @return
*/
public void doUpdRoom(){
try {
NodeRoomTable nrt = (NodeRoomTable) this.commonService.get(
NodeRoomTable.class, nodeRoom.getRoomId());
String ispn = nrt.getRoomIspn();
nrt.setRoomIspn(nodeRoom.getRoomIspn());
nrt.setRoomDesc(nodeRoom.getRoomDesc());
nrt.setUpdateUserId(this.getUserID());
nrt.setUpdateDatetime(new Date());
String historyBack = "roomManage!executeAction.do?action=openUpdate"
+ "&ids=" + nodeRoom.getRoomId()
+ "&pageNo=" + pageNo + "&pageSize=" + pageSize;
List list;
// 若行列中至少有一个是减小的情况,先检查减小的部分是否存放了机柜
if(nodeRoom.getRoomRows()<nrt.getRoomRows()){//行数减小
String hql = "from NodeRoomLatticeTable where roomId=? and nodeBoxId is not null and latticeRowPosition>?";
list = this.commonService.find(hql, nodeRoom.getRoomId(), nodeRoom.getRoomRows());
if (list != null && list.size() > 0) {
this.outHtmlString("<script>alert('i18n_RoomManageAction.downloadExample.changeRowsErr_n81i');this.location='" + historyBack + "';</script>");
return;
}
}
if(nodeRoom.getRoomCols()<nrt.getRoomCols()){//列数减小
String hql = "from NodeRoomLatticeTable where roomId=? and nodeBoxId is not null and latticeColPosition>?";
list = this.commonService.find(hql, nodeRoom.getRoomId(), nodeRoom.getRoomCols());
if (list != null && list.size() > 0) {
this.outHtmlString("<script>alert('i18n_RoomManageAction.downloadExample.changecolumnssErr_n81i');this.location='" + historyBack + "';</script>");
return;
}
}
List<Object> list2 = new ArrayList<Object>();
if(nodeRoom.getRoomRows()>nrt.getRoomRows()){//行数增大
for(long i=(nrt.getRoomRows()+1); i<=nodeRoom.getRoomRows(); i++){
for(long j=1; j<=nodeRoom.getRoomCols(); j++){//列数以新修改的列数为准
NodeRoomLatticeTable nlt = new NodeRoomLatticeTable();
nlt.setRoomId(nodeRoom.getRoomId());
nlt.setLatticeRowPosition(i);
nlt.setLatticeColPosition(j);
list2.add(nlt);
}
}
}else if(nodeRoom.getRoomRows()<nrt.getRoomRows()){//行数减小,上面已作检查,此处可以直接删除
String hql = "delete from NodeRoomLatticeTable where roomId=? and latticeRowPosition>?";
this.commonService.delete(hql, nodeRoom.getRoomId(), nodeRoom.getRoomRows());
}
if(nodeRoom.getRoomCols()>nrt.getRoomCols()){//列数增大,直接添加机房位置表
long rowSize = nodeRoom.getRoomRows();//行数以新修改的为准
if(nodeRoom.getRoomRows()>nrt.getRoomRows()){//如果行列同时都增大,在增大行时已经按新修改的列数插入数据了,这里的行数就要按原来的行
rowSize = nrt.getRoomRows();
}
for(long i=1; i<=rowSize; i++){
for(long j=(nrt.getRoomCols()+1); j<=nodeRoom.getRoomCols(); j++){
NodeRoomLatticeTable nlt = new NodeRoomLatticeTable();
nlt.setRoomId(nodeRoom.getRoomId());
nlt.setLatticeRowPosition(i);
nlt.setLatticeColPosition(j);
list2.add(nlt);
}
}
}else if(nodeRoom.getRoomCols()<nrt.getRoomCols()){//列减小,上面已作检查,此处可以直接删除
String hql = "delete from NodeRoomLatticeTable where roomId=? and latticeColPosition>?";
this.commonService.delete(hql, nodeRoom.getRoomId(), nodeRoom.getRoomCols());
}
if(list2.size()>0){//若有增大的,则保存
this.commonService.saveOrUpdate(list2);
}
// 设置行列并更新
nrt.setRoomRows(nodeRoom.getRoomRows());
nrt.setRoomCols(nodeRoom.getRoomCols());
this.commonService.update(nrt);
this.getRequest().setAttribute("MSG", 1);
if(!ispn.equals(nodeRoom.getRoomIspn())){
String sql = "update node_box_table set ROOM_ISPN = ? where ROOM_ISPN = ?";
this.commonService.updateBySql(sql, nodeRoom.getRoomIspn(),ispn);
}
} catch (Exception e) {
logger.error("Failed to update room information", e);
}
outHtmlString("<script type=\"text/javascript\">alert('i18n_RoomManageAction.downloadExample.success_n81i');this.location='roomManage.do?action=query&rIspn="+rIspn+"&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
}
public String delRoomInfo(){
try {
if(ids!=null && ids.length>0){
for(Long id : ids){
List list = this.commonService.find(
"from NodeRoomLatticeTable where roomId=? and nodeBoxId is not null", id);
if(list!=null && list.size()>0){
NodeRoomTable nrt = (NodeRoomTable)this.commonService.get(NodeRoomTable.class, id);
this.outHtmlString("<script>alert('i18n_RoomManageAction.downloadExample.deleteUnable1_n81i[" +nrt.getRoomIspn()+ "]i18n_RoomManageAction.downloadExample.deleteUnable2_n81i');history.back();</script>");
return null;
}
}
//删除node_room_lattice_table记录
this.commonService.updateBatchBySql("delete from node_room_lattice_table where ROOM_ID=?", Arrays.asList(ids));
//删除记录
this.commonService.updateBatchBySql("delete from NODE_ROOM_TABLE where ROOM_ID=?", Arrays.asList(ids));
outHtmlString("<script type=\"text/javascript\">alert('i18n_RoomManageAction.downloadExample.success_n81i');this.location='roomManage.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
}
} catch (Exception e) {
logger.error("Failed to delete room information", e);
return "error";
}
return this.queryRoomInfo();
}
/**
* Ajax请求获取所有机柜编号
* @return
*/
public String getAllRoomIspn(){
try {
String hql = "select distinct roomIspn from NodeRoomTable order by roomIspn ";
List<Long> allList = (List<Long>)this.commonService.find(hql);
String getIspn = "";
for (int i = 0; i < allList.size(); i++) {
if (allList.get(i) != null && !"".equals(allList.get(i))) {
getIspn += allList.get(i) + ";";
}
}
outString(getIspn);
System.out.println("--------room free cols: " + Arrays.toString(allList.toArray()));
//this.outJsonArray(allList);
} catch (Exception e) {
logger.error(e.getStackTrace());
e.printStackTrace();
}
return null;
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public Long[] getIds() {
return ids;
}
public void setIds(Long[] ids) {
this.ids = ids;
}
public String getRIspn() {
return rIspn;
}
public void setRIspn(String ispn) {
rIspn = ispn;
}
public String getDescinfo() {
return descinfo;
}
public void setDescinfo(String descinfo) {
this.descinfo = descinfo;
}
public List<NodeRoomTable> getNodeRoomList() {
return nodeRoomList;
}
public void setNodeRoomList(List<NodeRoomTable> nodeRoomList) {
this.nodeRoomList = nodeRoomList;
}
public NodeRoomTable getNodeRoom() {
return nodeRoom;
}
public void setNodeRoom(NodeRoomTable nodeRoom) {
this.nodeRoom = nodeRoom;
}
public String getFromWhere() {
return fromWhere;
}
public void setFromWhere(String fromWhere) {
this.fromWhere = fromWhere;
}
public String getIsComplete() {
return isComplete;
}
public void setIsComplete(String isComplete) {
this.isComplete = isComplete;
}
}

View File

@@ -0,0 +1,752 @@
package nis.nms.web.actions.nodePosition;
import java.util.List;
import nis.nms.core.Topology;
import nis.nms.domains.XtYhJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.service.ServiceUtil;
import flex.messaging.io.amf.ASObject;
public class TopoShow {
private static int TOPOTYPE_SYSTEM = 0;
private static int TOPOTYPE_NODEGROUP = 1;
private static int TOPOTYPE_LEAFNODEGROUP = 2;
private static int TOPOTYPE_ROOM = 3;
private static int TOPOTYPE_BOX = 4;
private static int TOPOTYPE_NODE = 5;
private CommonService commonService;
public static Long sysID;
public static XtYhJbxx user;
private Long treeId;
public TopoShow() {
// 获取service
commonService = (CommonService) ServiceUtil
.getServiceObject("commonService");
System.out.println("----------------"+commonService.toString());
System.out.println("-------sysID---------"+sysID);
System.out.println("-------userID---------"+user.getYhid());
System.out.println("-------username---------"+user.getYhbh());
}
/**
* 一级拓扑展示:业务系统下的顶级节点组
* @param object
* @return
*/
public Topology getTopoShow(Object object) {
treeId = 1l;
Topology topology = new Topology();
try {
//当前系统
String sysSql =
"SELECT " +
" ST.SYSTEM_ID," +
" ST.SYSTEM_NAME," +
" ST.SYSTEM_DESC" +
" FROM SYSTEM_TABLE ST " +
" WHERE SYSTEM_STATE = 0 " +
" AND SYSTEM_ID = " + sysID;
System.out.println("getTopoShow...sysSql:"+sysSql);
List<Object []> sysList = (List<Object [] >)this.commonService.executeSQL(sysSql);
if (sysList != null && sysList.size() > 0) {
Object[] objs = sysList.get(0);
topology.setType(this.TOPOTYPE_SYSTEM);
topology.setTreeId(treeId++);
topology.setId(Long.parseLong(objs[0].toString()));
topology.setName(objs[1].toString());
//设置节点组
setChildNodeGroup(topology, 0l);
}
} catch (Exception e) {
e.printStackTrace();
}
return topology;
}
/**
* 二级拓扑展示:含有子节点组的节点组
* @param object
* @return
*/
public Topology getGroupTopoShow(Object object) {
treeId = 1l;
Topology topology = new Topology();
try {
ASObject as = (ASObject) object;
Long groupID = Long.parseLong(as.get("groupID").toString());
String back = as.get("back").toString();
String sql =
"SELECT " +
" NGT.GROUP_ID," +
" NGT.GROUP_NAME," +
" NGT.GROUP_LEVEL," +
" NGT.GROUP_DESC" +
" FROM NODEGROUP_TABLE NGT " +
" WHERE IS_VALID = 1 ";
if("0".equals(back)){//返回上一级节点组
sql += " AND NGT.GROUP_ID in (select NG.PARENT_GROUP_ID from NODEGROUP_TABLE NG where NG.GROUP_ID=" + groupID + ")";
}else{
sql += " AND NGT.GROUP_ID = " + groupID;
}
System.out.println("getGroupTopoShow...sql:" + sql);
List<Object []> list = (List<Object [] >)this.commonService.executeSQL(sql);
if (list != null && list.size() > 0) {
Object[] objs = list.get(0);
topology.setType(this.TOPOTYPE_NODEGROUP);
topology.setTreeId(treeId++);
topology.setId(Long.parseLong(objs[0].toString()));
topology.setName(objs[1].toString());
topology.setGroupLevel(objs[2].toString());
System.out.println("---group---glevel---" + topology.getGroupLevel());
int falseNum = this.getFalseNodeNumInGroup(objs[0].toString());
topology.setIsOk(falseNum > 0 ? 1 : 0);
topology.setChildSize(this.getNodeNum(objs[0].toString()).intValue());
topology.setFalseChildSize(falseNum);
topology.setOkChildSize(topology.getChildSize()-falseNum);
System.out.println("--getGroupTopoShow---" + topology.getName() +"---total=" + topology.getChildSize() + "---false=" + topology.getFalseChildSize() + "---ok=" +topology.getOkChildSize());
//设置节点组
setChildNodeGroup(topology, Long.parseLong(objs[0].toString()));
}
} catch (Exception e) {
e.printStackTrace();
}
return topology;
}
/**
* 三级拓扑展示:叶子节点组下的机房
* @param object
* @return
*/
public Topology getRoomTopoShow(Object object) {
treeId = 1l;
Topology topology = new Topology();
try {
ASObject as = (ASObject) object;
Long groupID = Long.parseLong(as.get("groupID").toString());
String sql =
"SELECT " +
" NGT.GROUP_ID," +
" NGT.GROUP_NAME," +
" NGT.GROUP_LEVEL," +
" NGT.GROUP_DESC" +
" FROM NODEGROUP_TABLE NGT " +
" WHERE IS_VALID = 1 " +
" AND NGT.GROUP_ID = " + groupID;
System.out.println("getBoxTopoShow...sql:" + sql);
List<Object []> list = (List<Object [] >)this.commonService.executeSQL(sql);
if (list != null && list.size() > 0) {
Object[] objs = list.get(0);
topology.setType(this.TOPOTYPE_LEAFNODEGROUP);
topology.setTreeId(treeId++);
topology.setId(Long.parseLong(objs[0].toString()));
topology.setName(objs[1].toString());
topology.setGroupLevel(objs[2].toString());
System.out.println("---box---glevel---" + topology.getGroupLevel());
// 设置不正常的节点
Object[] falseObjs = this.getFalseNodeInGroup(objs[0].toString());
int falseNum = (Integer)falseObjs[0];
topology.setFalseSeqIds(falseObjs[1].toString());
topology.setIsOk(falseNum > 0 ? 1 : 0);
topology.setChildSize(this.getNodeNum(objs[0].toString()).intValue());
topology.setFalseChildSize(falseNum);
topology.setOkChildSize(topology.getChildSize()-falseNum);
System.out.println("--getRoomTopoShow---" + topology.getName() +"---total=" + topology.getChildSize() + "---false=" + topology.getFalseChildSize() + "---ok=" +topology.getOkChildSize());
setChildRoom(topology, objs[0].toString());//设置机房
//setChildBox(topology, objs[0].toString());//设置机柜
}
} catch (Exception e) {
e.printStackTrace();
}
return topology;
}
/**
* 设置当前系统下某节点组下的节点组, 父节点组ID为0则显示当前系统下的一级节点组
*
* @param parentTopo
* @param sysID
* @param parGroupId
*/
private void setChildNodeGroup(Topology parentTopo, Long parGroupId){
try{
String ngtSql ="";
//--节点组
if("admin".equals(user.getYhbh())){//如果是admin登陆则无限制
ngtSql =
"SELECT " +
" NGT.GROUP_ID," +
" NGT.GROUP_NAME," +
" NGT.GROUP_LEVEL," +
" NGT.GROUP_DESC" +
" FROM NODEGROUP_TABLE NGT " +
" WHERE IS_VALID = 1 " +
" AND NGT.PARENT_GROUP_ID = " + parGroupId +
" AND NGT.SYSTEM_ID = " + sysID;
}else{
ngtSql =
"SELECT " +
" NGT.GROUP_ID," +
" NGT.GROUP_NAME," +
" NGT.GROUP_LEVEL," +
" NGT.GROUP_DESC" +
" FROM NODEGROUP_TABLE NGT " +
" WHERE IS_VALID = 1 " +
" AND NGT.PARENT_GROUP_ID = " + parGroupId +
" AND (( NGT.VIEW_LEVEL=1 AND NGT.CREATE_USER_ID="+user.getYhid()+")" +
" OR ( NGT.VIEW_LEVEL=2 AND NGT.CREATE_USERGROUP_ID " +
" IN (SELECT X.JSBH FROM Xt_Yh_Js_Index X WHERE X.YHBH='"+user.getYhbh()+"' AND X.TYPE = 1))" +
" OR (NGT.VIEW_LEVEL=3 AND NGT.SYSTEM_ID = "+sysID+") OR (NGT.VIEW_LEVEL=4 ))"+
" AND NGT.SYSTEM_ID ="+sysID;
}
System.out.println("setChildNodeGroup...nodegroupSql:"+ngtSql);
List<Object []> groupList = (List<Object []>)this.commonService.executeSQL(ngtSql);
if(groupList!=null && groupList.size()>0){
for (Object[] objs : groupList) {
//初始化之前先去查询子节点组个数
Long numLong = Long.parseLong("0");
if(objs[1]!=null){
Topology topo = new Topology();
topo.setTreeId(treeId++);
topo.setId(Long.parseLong(objs[0].toString()));
topo.setName(objs[1].toString());
topo.setGroupLevel(objs[2].toString());
// 设置不正常的节点
Object[] falseObjs = this.getFalseNodeInGroup(objs[0].toString());
int falseNum = (Integer)falseObjs[0];
topo.setFalseSeqIds(falseObjs[1].toString());
topo.setIsOk(falseNum > 0 ? 1 : 0);
topo.setChildSize(this.getNodeNum(objs[0].toString()).intValue());
topo.setFalseChildSize(falseNum);
topo.setOkChildSize(topo.getChildSize()-falseNum);
System.out.println("------11---" + topo.getName() +"---total=" + topo.getChildSize() + "---false=" + topo.getFalseChildSize() + "---ok=" +topo.getOkChildSize());
// 设置节点类型:节点组,叶子节点组
String isHaveChildSQl = "select count(*) from NODEGROUP_TABLE t where t.PARENT_GROUP_ID =" +objs[0].toString()+" and t.is_valid =1";
numLong = Long.parseLong(this.commonService.executeSQL(isHaveChildSQl).get(0).toString());
if(Integer.parseInt(numLong.toString())==0){
topo.setType(this.TOPOTYPE_LEAFNODEGROUP);
// 设置机柜
//setChildBox(topo, objs[0].toString());
}else{
topo.setType(this.TOPOTYPE_NODEGROUP);
// 设置子节点组
//setChildNodeGroup(topo, Long.parseLong(objs[0].toString()));
}
parentTopo.getChild().add(topo);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 设置节点组下的机房
* @return
*/
private void setChildRoom(Topology parentTopo, String groupID){
String getRoomByGroup =
"select" +
" nht.room_id," +
" nht.room_ispn," +
" nht.room_rows," +
" nht.room_cols," +
" nht.room_desc" +
" from node_room_table nht where nht.room_id in" +
" (select distinct nbt.room_id from node_room_lattice_table nbt where nbt.node_box_id in" +
" (select distinct nlt.node_box_id from node_lattice_table nlt where nlt.node_seq in" +
" (select distinct nt.seq_id from node_table nt where nt.node_state = 0 and nt.node_group_id = " + groupID + " )" +
" )" +
" )";
System.out.println("setChildRoom----:"+getRoomByGroup);
try {
List<Object []> roomList = (List<Object []>)this.commonService.executeSQL(getRoomByGroup);
//遍历机房
if(roomList!=null && roomList.size()>0){
for (Object[] objs : roomList) {
int isOk = this.isOkInRoom(objs[0].toString(), groupID);
Topology topo = new Topology();
topo.setType(this.TOPOTYPE_ROOM);
topo.setTreeId(treeId++);
topo.setId(Long.parseLong(objs[0].toString()));
topo.setName(objs[1].toString());
topo.setIsOk(isOk);
topo.setIspn(objs[1].toString());
//topo.setRoomRows(Long.parseLong(objs[2]==null?"0":objs[2].toString()));
//topo.setRoomCols(Long.parseLong(objs[3]==null?"0":objs[3].toString()));
System.out.println("------setChildRoom---" + topo.getName());
parentTopo.getChild().add(topo);
}
}
}catch (Exception e) {
e.printStackTrace();
}
}
/**
* 设置节点组下的机柜
* @return
*/
private void setChildBox(Topology parentTopo, String groupID){
String getBoxByGroup =
"select" +
" nbt.box_id," +
" nbt.descinfo," +
" nbt.ispn," +
" nbt.box_u_type" +
" from node_box_table nbt where nbt.box_id in" +
" (select nlt.node_box_id from node_lattice_table nlt where nlt.node_seq in" +
" (select distinct nt.seq_id from node_table nt where nt.node_state = 0 and nt.node_group_id = " + groupID + " )" +
" )";
System.out.println("setChildBox----:"+getBoxByGroup);
try {
List<Object []> boxList = (List<Object []>)this.commonService.executeSQL(getBoxByGroup);
//遍历机柜
if(boxList!=null && boxList.size()>0){
for (Object[] objs : boxList) {
int isOk = this.isOkInBox(objs[0].toString(), groupID);
Topology topo = new Topology();
topo.setType(this.TOPOTYPE_BOX);
topo.setTreeId(treeId++);
topo.setId(Long.parseLong(objs[0].toString()));
topo.setName(objs[1].toString());
topo.setIsOk(isOk);
topo.setIspn(objs[2].toString());
topo.setBoxUType(Long.parseLong(objs[3]==null?"0":objs[3].toString()));
System.out.println("------11---" + topo.getName());
parentTopo.getChild().add(topo);
}
}
}catch (Exception e) {
e.printStackTrace();
}
}
/**
* 得到节点组及其子节点组下所有不正常的节点总数
* @param groupId
* @return
* @throws Exception
*/
private int getFalseNodeNumInGroup(String groupId) throws Exception{
int falseNum = 0;
//状态不正常的节点 (过滤有效节点和有效监测设置)
//@2018-3-9 fang 修改 首先查询符合条件的id在拼接sql适配mysql
String gsql = "select group_id from nodegroup_table t where 1=1 ";
String gids = this.commonService.getGroupIdStartWith(gsql, "t.group_id = " +groupId);
/*String falseNodeSql="select count(distinct diw.seq_id) from detection_info_new diw " +
"left join node_table nt "+
"on diw.seq_id = nt.seq_id " +
"where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 " +
"and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) " +
"and nt.NODE_STATE = 0 "+
"and nt.node_group_id in " +
"(select t.group_id from nodegroup_table t "+
"start with t.group_id ="+groupId +
" connect by prior t.group_id = t.parent_group_id)";*/
String falseNodeSql="select count(distinct diw.seq_id) from detection_info_new diw " +
"left join node_table nt "+
"on diw.seq_id = nt.seq_id " +
"where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 " +
"and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) " +
"and nt.NODE_STATE = 0 "+
"and nt.node_group_id in " +
"("+gids+")";
System.out.println("getFalseNodeNumInGroup---sql:"+falseNodeSql);
try {
List<Object> falseList = this.commonService.executeSQL(falseNodeSql);
falseNum = Integer.parseInt(falseList.get(0).toString());
} catch (Exception e) {
e.printStackTrace();
}
return falseNum;
}
/**
* 得到节点组及其子节点组下所有不正常的节点的相关信息
* @param groupId
* @return
* @throws Exception
*/
private Object[] getFalseNodeInGroup(String groupId) throws Exception{
Object[] objs = new Object[2];
//状态不正常的节点 police_emergent=0 只显示紧急告警
//@2018-3-9 fang 修改 首先查询符合条件的id在拼接sql适配mysql
String gsql = "select group_id from nodegroup_table t where 1=1 ";
String gids = this.commonService.getGroupIdStartWith(gsql, "t.group_id = " +groupId);
/*String falseNodeSql="select distinct nt.node_id,nt.node_ip,nt.seq_id,"+
"nt.node_name from detection_info_new diw " +
"left join node_table nt "+
"on diw.seq_id = nt.seq_id " +
"where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 " +
"and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) " +
"and nt.NODE_STATE = 0 "+
"and nt.node_group_id in " +
"(select t.group_id from nodegroup_table t "+
"start with t.group_id ="+groupId +
" connect by prior t.group_id = t.parent_group_id)";*/
String falseNodeSql="select distinct nt.node_id,nt.node_ip,nt.seq_id,"+
"nt.node_name from detection_info_new diw " +
"left join node_table nt "+
"on diw.seq_id = nt.seq_id " +
"where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 " +
"and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) " +
"and nt.NODE_STATE = 0 "+
"and nt.node_group_id in " +
"("+gids+")";
System.out.println("getFalseNodeNumInGroup---sql:"+falseNodeSql);
List<Object []> falseList = this.commonService.executeSQL(falseNodeSql);
if(falseList!=null && falseList.size()>0){
StringBuffer sb = new StringBuffer();
for(Object[] falseObj : falseList){
sb.append(falseObj[2] + ",");
}
sb.deleteCharAt(sb.length()-1);
objs[0] = falseList.size();
objs[1] = sb.toString();
}else{
objs[0] = 0;
objs[1] = "";
}
return objs;
}
/**
* 检查机房下是否所有节点都正常
* @param roomId
* @param groupId
* @return 0 正常1 不正常
*/
private int isOkInRoom(String roomId, String groupId){
int isOk = 0;
String nibSql =
" select count(distinct diw.seq_id)" +
" from detection_info_new diw" +
" left join node_table nt on nt.seq_id = diw.seq_id "+
" where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 " +
" and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1)" +
" and nt.node_state = 0" +
" and nt.system_id="+sysID+
" and nt.node_group_id ="+groupId +
" and nt.seq_id in" +
" (select distinct nlt.node_seq from node_lattice_table nlt left join node_room_lattice_table nrlt on nlt.node_box_id=nrlt.node_box_id" +
" where nlt.node_seq is not null and nrlt.node_box_id is not null and nrlt.room_id="+roomId + ")";
System.out.println("isOkInRoom---sql:"+nibSql);
try {
List<Object> falseList = this.commonService.executeSQL(nibSql);
if(Long.parseLong(falseList.get(0).toString())>0){
isOk = 1;
}
} catch (Exception e) {
e.printStackTrace();
}
return isOk;
}
/**
* 检查机柜下是否所有节点都正常
* @param boxId
* @param groupId
* @return 0 正常1 不正常
*/
private int isOkInBox(String boxId, String groupId){
int isOk = 0;
String nibSql =
" select count(distinct diw.seq_id)" +
" from detection_info_new diw" +
" left join node_table nt on nt.seq_id = diw.seq_id "+
" where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 " +
" and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1)" +
" and nt.node_state = 0" +
" and nt.system_id="+sysID+
" and nt.node_group_id ="+groupId +
" and nt.seq_id in (select distinct nlt.node_seq from node_lattice_table nlt where nlt.node_seq is not null and nlt.node_box_id = "+boxId + ")";
System.out.println("isOkInBox---sql:"+nibSql);
try {
List<Object> falseList = this.commonService.executeSQL(nibSql);
if(Long.parseLong(falseList.get(0).toString())>0){
isOk = 1;
}
} catch (Exception e) {
e.printStackTrace();
}
return isOk;
}
/**
* 检查节点是否正常
* @param boxId
* @param groupId
* @return 0 正常1 不正常
*/
private int isOkNode(String seqId){
int isOk = 0;
if(seqId!=null && !"".equals(seqId)){
String sql = "select count(diw.seq_Id) from detection_info_new diw where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 and diw.seq_id = " + seqId +
" and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1)";
System.out.println("isOkNode---sql:"+sql);
try {
List<Object> falseList = this.commonService.executeSQL(sql);
if(Long.parseLong(falseList.get(0).toString())>0){
isOk = 1;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return isOk;
}
/**
* 得到节点组及其子节点组下所有节点总数
* @param groupId
* @return
* @throws Exception
*/
private Long getNodeNum(String groupId) throws Exception{
Long nodeNum = new Long(0l);
//@2018-3-9 fang 修改 首先查询符合条件的id在拼接sql适配mysql
String gsql = "select group_id from nodegroup_table t where 1=1 ";
String gids = this.commonService.getGroupIdStartWith(gsql, "t.group_id = " +groupId);
/*String sql="select count(*) from node_table t where t.node_group_id in " +
"(select t.group_id from nodegroup_table t start with t.group_id = "+groupId+
" connect by prior t.group_id = t.parent_group_id) and t.node_state = 0";*/
String sql="select count(*) from node_table t where t.node_group_id in " +
"("+gids+") and t.node_state = 0";
List gIdList= this.commonService.executeSQL(sql);
nodeNum = Long.parseLong(gIdList.get(0).toString());
return nodeNum;
}
/**
* 机柜展示
* @param object
* @return
*/
public Topology getNodeByBox(Object object){
Topology topology = new Topology();
topology.setType(TOPOTYPE_BOX);
try {
ASObject as = (ASObject) object;
Long boxID = Long.parseLong(as.get("boxId").toString());
String groupID = as.get("groupId").toString();
System.out.println("getNodeByBox---groupID=" + groupID);
topology.setId(boxID);
//初始化机柜位置
String boxLatSql = "select nlt.id," +
" nlt.lattice_position," +
" nlt.node_box_id," +
" nlt.node_seq" +
" from node_lattice_table nlt" +
" where nlt.node_box_id = " + boxID +
" order by nlt.lattice_position desc";
System.out.println("getNodeByBox---sql:"+boxLatSql);
List<Object []> boxLatList = (List<Object []>)this.commonService.executeSQL(boxLatSql);
if(boxLatList!=null && boxLatList.size()>0){
int i=0;
while(i<boxLatList.size()){
Object[] boxLatObj = (Object[])boxLatList.get(i);
Topology topo= new Topology();
topo.setId(Long.parseLong(boxLatObj[0]==null?"0":boxLatObj[0].toString()));
topo.setType(this.TOPOTYPE_NODE);
if(boxLatObj[3]!=null && !"".equals(boxLatObj[3])){//若放置了节点机
String seqID = boxLatObj[3].toString();
//节点是否正常
topo.setIsOk(isOkNode(seqID));
topo.setFalseSeqIds(seqID);
//设置节点信息
String nodeSql =
" select" +
" nt.node_id," +
" nt.node_ip," +
" nt.node_name," +
" nt.node_u_type,"+
" nt.node_group_id,"+
" nt.system_id," +
" nt.node_state," +
" nt.NODE_BEGIN_UTYPE" +
" from node_table nt" +
" where nt.seq_id=" + seqID; //+" and nt.node_state = 0"
List<Object []> nodeList = (List<Object []>)this.commonService.executeSQL(nodeSql);
if(nodeList!=null && nodeList.size()>0){
Object[] nodeObj = nodeList.get(0);
topo.setNodeIp(nodeObj[1]==null ? "" : nodeObj[1].toString());//节点IP
topo.setNodeName(nodeObj[2]==null ? "" : nodeObj[2].toString());
topo.setNodeUType(Long.parseLong(nodeObj[3]==null?"0":nodeObj[3].toString()));
topo.setNodeBeginUType(Long.parseLong(nodeObj[7]==null?"0":nodeObj[7].toString()));
// 设置节点是否属于本节点组
topo.setIsEdit(1);
for (Object[] nodeObj2 : nodeList) {
String gid = nodeObj2[4] == null ? "" : nodeObj2[4].toString();
if (gid.equals(groupID)) {// 如果节点是属于本节点组的
// 设置节点名为当前组中的节点名称
topo.setNodeName(nodeObj2[2]==null ? "" : nodeObj2[2].toString());
// 判断节点在当前组中是否有效
if (Long.parseLong(nodeObj2[6] == null ? "0"
: nodeObj2[6].toString()) == 0) {// 有效
topo.setIsEdit(0);
} else {// 节点无效
topo.setIsEdit(-1);
}
break;
}
}
}
}
topology.getChild().add(topo);
if(topo.getNodeUType()!=null && topo.getNodeUType()>0){
i += topo.getNodeUType();
}else{
i += 1;
}
//System.out.println("==========utype=" + (topo.getNodeUType()!=null ? topo.getNodeUType():"0") +"----i=" + i);
}//while end
}
System.out.println("===============child cnt = " + topology.getChild().size());
} catch (Exception e) {
e.printStackTrace();
}
return topology;
}
/**
* 机房展示
* @param object
* @return
*/
public Topology getBoxByRoom(Object object){
Topology topology = new Topology();
topology.setType(TOPOTYPE_BOX);
try {
ASObject as = (ASObject) object;
Long roomID = Long.parseLong(as.get("roomId").toString());
String groupID = as.get("groupId").toString();
System.out.println("getNodeByBox---groupID=" + groupID);
topology.setId(roomID);
//初始化机房位置--先查出机房的行
String roomLatSql = "select nht.room_rows from node_room_table nht where nht.room_id = " + roomID;
System.out.println("getBoxByRoom---roomLatSql:"+roomLatSql);
List<Object> roomRowList = (List<Object>)this.commonService.executeSQL(roomLatSql);
if(roomRowList!=null && roomRowList.size()>0){
long rows = Long.parseLong(roomRowList.get(0).toString());
for(int i=1; i <= rows; i++){
Topology row= new Topology();
// 初始化机房位置--按行查列
roomLatSql = "select nlt.id," +
" nlt.lattice_row_position," +
" nlt.lattice_col_position," +
" nlt.room_id," +
" nlt.node_box_id" +
" from node_room_lattice_table nlt" +
" where nlt.room_id = " + roomID +
" and nlt.lattice_row_position=" + i +
" order by nlt.lattice_row_position asc,nlt.lattice_col_position asc";
System.out.println("getBoxByRoom---roomLatSql:"+roomLatSql);
List<Object[]> roomColList = (List<Object[]>)this.commonService.executeSQL(roomLatSql);
for(int j=0; j<roomColList.size(); j++){
Object[] roomLatObj = (Object[])roomColList.get(j);
Topology colTopo= new Topology();
colTopo.setType(this.TOPOTYPE_BOX);
if(roomLatObj[4]!=null){// 存放了机柜,设置机柜信息,机柜是否正常
String boxSql =
" select" +
" nt.box_id," +
" nt.ispn,nt.box_u_type" +
" from node_box_table nt" +
" where nt.box_id = " + roomLatObj[4];
List<Object []> boxList = (List<Object []>)this.commonService.executeSQL(boxSql);
if(boxList!=null && boxList.size()>0){
Object[] boxObj = boxList.get(0);
colTopo.setId(Long.parseLong(boxObj[0]==null?"0":boxObj[0].toString()));
colTopo.setIspn(boxObj[1].toString());
colTopo.setBoxUType(Long.parseLong(boxObj[2]==null?"0":boxObj[2].toString()));
colTopo.setIsOk(isOkInBox(boxObj[0].toString(),groupID));
}
colTopo.setIsEdit(this.isEditBoxInRoom(roomLatObj[4].toString(), groupID));
}
// 列添加到行
row.getChild().add(colTopo);
}
topology.getChild().add(row);
}
}
System.out.println("===============child cnt = " + topology.getChild().size());
} catch (Exception e) {
e.printStackTrace();
}
return topology;
}
/**
* 机房下的机柜是否在当前节点组下有有效的节点0 有,-1 无有效节点
* @param boxID
* @param groupID
* @return
*/
private int isEditBoxInRoom(String boxID, String groupID) throws Exception{
// 机柜下的节点
String sql1 = "select distinct nlt.node_seq" +
" from node_lattice_table nlt" +
" where nlt.node_box_id = " + boxID;
// 当前节点组下在该机柜是否有有效的节点
String cntSql =" select count(nt.node_id) from node_table nt" +
" where nt.node_state=0 and nt.node_group_id=" + groupID+
" and nt.seq_id in(" + sql1 + ")";
List list= this.commonService.executeSQL(cntSql);
Long nodeNum = Long.parseLong(list.get(0).toString());
if(nodeNum>0){
return 0;
}else{
return -1;
}
}
}

View File

@@ -0,0 +1,539 @@
/**
* DesktopAction.java 版权所有(C) 2010 北京中科智源育成信息技术有限公司
*
* @author ZhengXi
* @date 2010-11-19
* @version V1.0
*/
package nis.nms.web.actions.nodePosition;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import nis.nms.domains.NodeBoxTable;
import nis.nms.domains.NodeLatticeTable;
import nis.nms.domains.NodeRoomLatticeTable;
import nis.nms.domains.NodeRoomTable;
import nis.nms.domains.NodeTable;
import nis.nms.domains.NodegroupTable;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import org.apache.log4j.Logger;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import com.nis.util.StringUtil;
@Results( { @Result(name = "showTopo", value = "/page/show/flexTopo.jsp"),
@Result(name = "showNode", value = "/page/show/showNode.jsp"),
@Result(name = "show3DRoom", value = "/page/show/show3DRoom.jsp"),
@Result(name = "showNodeRoom", value = "/page/show/showNodeRoom.jsp"),
@Result(name = "error", value = "/error.jsp") })
/**
* 拓扑图左面展示
*/
public class TopoShowAction extends BaseAction
{
private Logger logger = Logger.getLogger(TopoShowAction.class);
private static final long serialVersionUID = 1L;
private String action;
private CommonService commonService;
private List<NodegroupTable> nodegroupList;
private List<NodeRoomTable> nodeRoomList;
private String firstGroupId;
private String groupId;
private String nodeBoxId;
private String nodeBoxIspn;
public String executeAction()
{
String resultpage = "showTopo";
TopoShow.sysID = this.getSystemID();
TopoShow.user = this.getUser();
if ("showTopo".equals(this.action))
{
resultpage = "showTopo";
} else if ("showNode".equals(this.action))
{
resultpage = showNode();
} else if ("show3DRoom".equals(this.action))
{
resultpage = show3DRoom();
} else if ("getNodeRoom".equals(this.action))
{
resultpage = getNodeRoom();
} else if ("getNodeBox".equals(this.action))
{
resultpage = getNodeBox();
}
//
return resultpage;
}
/**
* 3D机房展示 查询节点组
*
* @author jinshujuan Jun 24, 2013
* @version 1.0
* @return
*/
private String show3DRoom()
{
try
{
String sql = null;
String hql = null;
if (!this.getAdminMark()) {
sql = " SELECT NGT.GROUP_ID,NGT.GROUP_NAME,NGT.GROUP_LEVEL,NGT.GROUP_DESC,ngt.leaf_group "
+ "FROM NODEGROUP_TABLE NGT WHERE NGT.IS_VALID = 1 AND NGT.SYSTEM_ID = "
+ getSystemID();
hql = " from NodegroupTable where isValid =1 and systemId = " + getSystemID();
sql += " AND (( NGT.VIEW_LEVEL=1 AND NGT.CREATE_USER_ID=" + getUser().getYhid()
+ ") OR ( NGT.VIEW_LEVEL=2 AND NGT.CREATE_USERGROUP_ID "
+ " IN (SELECT X.JSBH FROM Xt_Yh_Js_Index X WHERE X.YHBH='"
+ getUser().getYhbh()
+ "' AND X.TYPE = 1)) OR (NGT.VIEW_LEVEL=3 AND NGT.SYSTEM_ID = "
+ getSystemID() + ") OR (NGT.VIEW_LEVEL=4 ))";
hql += " and (( viewLevel =1 and createUserId = "
+ getUser().getYhid()
+ ") "
+ "or (viewLevel =2 and createUserId in (select t1.jsbh from XtYhJsIndex t1 where t1.yhbh ='"
+ getUser().getYhbh() + "' and type =1)) "
+ "or (viewLevel =3 and systemId=" + getSystemID() + ") or (viewLevel =4))";
}else{
// 管理员查询sql leaf_group=1父节点 leaf_group=0子节点
sql = " SELECT NGT.GROUP_ID,NGT.GROUP_NAME,NGT.GROUP_LEVEL,NGT.GROUP_DESC,ngt.leaf_group "
+ "FROM NODEGROUP_TABLE NGT WHERE NGT.IS_VALID = 1 ";
//查询该业务系统有效的节点组
hql = " from NodegroupTable where isValid =1 ";
}
sql += " order by NGT.show_index";
hql += " order by showIndex";
nodegroupList = commonService.find(hql);
for (NodegroupTable nodegroupTable: nodegroupList)
{
//@2018-3-9 fang 修改 首先查询符合条件的id在拼接sql适配mysql
String gsql = "select group_id from nodegroup_table t where 1=1 ";
String gids = this.commonService.getGroupIdStartWith(gsql, "t.group_id = " +nodegroupTable.getGroupId());
//获取每个节点组下正常、异常节点的个数
/*sql = "SELECT * from ("
+ "select count(distinct nt.node_id) from detection_info_new diw left join node_table nt on diw.seq_id = nt.seq_id "
+ "where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 and diw.DETECTION_SET_INFO_ID in "
+ "(select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) and nt.NODE_STATE = 0 "
+ "and nt.node_group_id in (select t.group_id from nodegroup_table t start with t.group_id ="
+ nodegroupTable.getGroupId()
+ " connect by prior t.group_id = t.parent_group_id)" + ") alramNode,"
+ "(SELECT count(DISTINCT t.node_ip) from node_table t WHERE t.system_id="
+ getSystemID() + " AND t.node_group_id= " + nodegroupTable.getGroupId()
+ ")allNode";*/
if(this.getAdminMark()){
sql = "SELECT * from ("
+ "select count(distinct nt.node_id) from detection_info_new diw left join node_table nt on diw.seq_id = nt.seq_id "
+ "where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 and diw.DETECTION_SET_INFO_ID in "
+ "(select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) and nt.NODE_STATE = 0 "
+ "and nt.node_group_id in ("+gids+")"
+ ") alramNode,"
+ "(SELECT count(DISTINCT t.node_ip) from node_table t WHERE "
+ " t.node_group_id= " + nodegroupTable.getGroupId()
+ ") allNode";
}else{
sql = "SELECT * from ("
+ "select count(distinct nt.node_id) from detection_info_new diw left join node_table nt on diw.seq_id = nt.seq_id "
+ "where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 and diw.DETECTION_SET_INFO_ID in "
+ "(select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1) and nt.NODE_STATE = 0 "
+ "and nt.node_group_id in ("+gids+")"
+ ") alramNode,"
+ "(SELECT count(DISTINCT t.node_ip) from node_table t WHERE t.system_id="
+ getSystemID() + " AND t.node_group_id= " + nodegroupTable.getGroupId()
+ ")allNode";
}
List countList = commonService.executeSQL(sql);
Object[] countObjs = (Object[]) countList.get(0);
BigDecimal bigDecimal = new BigDecimal(1);
int alramNodeSize = Integer.valueOf(countObjs[0].toString());//((BigDecimal) countObjs[0]).intValue();
int allNodeSize = Integer.valueOf(countObjs[0].toString());//((BigDecimal) countObjs[1]).intValue();
if (alramNodeSize > 0)
{
nodegroupTable.setStatus(1);
} else
{
nodegroupTable.setStatus(0);
}
//设置节点组的告警信息,当鼠标放在节点组上显示提示信息
String alramInfo = "\"" + nodegroupTable.getGroupName() + "\""+getI18nText("i18n_TopoShowAction.show3DRoom.alramInfo1_n81i");
if (allNodeSize > 0)
{
alramInfo += "|"+getI18nText("i18n_TopoShowAction.show3DRoom.nodeNum_n81i")+"" + allNodeSize + "|"+getI18nText("i18n_TopoShowAction.show3DRoom.normalNode_n81i")+""
+ (allNodeSize - alramNodeSize) + "|"+getI18nText("i18n_TopoShowAction.show3DRoom.abnormalNode_n81i")+"" + alramNodeSize;
} else
{
alramInfo += "|"+getI18nText("i18n_TopoShowAction.show3DRoom.alramInfo3_n81i");
}
nodegroupTable.setAlramInfo(alramInfo);
}
} catch (Exception e)
{
e.printStackTrace();
}
return "show3DRoom";
}
/**
* 获取节点组下的机房 TODO
*
* @author jinshujuan Jun 25, 2013
* @version 1.0
* @return
*/
public String getNodeRoom()
{
try
{
if (!StringUtil.isBlank(groupId))
{
// 设置节点组的机房
String hql = null;
if(this.getAdminMark()){
hql = " from NodeRoomTable nr where nr.roomId in (select DISTINCT nrl.roomId from NodeRoomLatticeTable nrl where nrl.nodeBoxId in "
+ "(select DISTINCT nl.nodeBoxId from NodeLatticeTable nl where nl.nodeSeqId in "
+ "(select DISTINCT nt.seqId from NodeTable nt where nt.nodeState=0 and nt.groupId=" + groupId + ")))";
}else{
hql = " from NodeRoomTable nr where nr.roomId in (select DISTINCT nrl.roomId from NodeRoomLatticeTable nrl where nrl.nodeBoxId in "
+ "(select DISTINCT nl.nodeBoxId from NodeLatticeTable nl where nl.nodeSeqId in "
+ "(select DISTINCT nt.seqId from NodeTable nt where nt.nodeState=0 and systemId="
+ getSystemID() + " and nt.groupId=" + groupId + ")))";
}
nodeRoomList = commonService.find(hql);
NodegroupTable nodegroupTable = (NodegroupTable) commonService
.get(NodegroupTable.class, Long.parseLong(groupId));
getRequest().setAttribute("nodegroupTable", nodegroupTable);
hql = " from NodeRoomLatticeTable where nodeBoxId is not NULL order by latticeRowPosition,latticeColPosition";
List<NodeRoomLatticeTable> nodeRoomLatticList = commonService.find(hql);
// 设置机房展示
for (NodeRoomTable nodeRoomTable: nodeRoomList)
{
// 机房设置节点组
//nodeRoomTable.setNodegroupTable(nodegroupTable);
/*hql = " from NodeRoomLatticeTable where roomId = "
+ nodeRoomTable.getRoomId()
+ " and nodeBoxId is not NULL order by latticeRowPosition,latticeColPosition";
List<NodeRoomLatticeTable> nodeRoomLatticList = commonService.find(hql);*/
Map<String, NodeBoxTable> nodeBoxMap = new HashMap<String, NodeBoxTable>();
for (NodeRoomLatticeTable nodeRoomLatticeTable: nodeRoomLatticList)
{
if (nodeRoomTable.getRoomId().intValue() == nodeRoomLatticeTable.getRoomId().intValue())
{
Long row = nodeRoomLatticeTable.getLatticeRowPosition();
Long col = nodeRoomLatticeTable.getLatticeColPosition();
Long nodeBoxId = nodeRoomLatticeTable.getNodeBoxId();
// 获取机柜
NodeBoxTable nodeBoxTable = (NodeBoxTable) commonService
.get(NodeBoxTable.class, nodeBoxId);
if (nodeBoxTable != null)
{
nodeBoxTable.setAlarm(boxIsAlarm(nodeBoxId, groupId));
nodeBoxTable.setHasNode(BoxhasNode(nodeBoxId, groupId));
nodeBoxTable.setDescinfo(nodeBoxTable.getDescinfo().replaceAll("\\r\\n", ""));
String key = row.toString() + col.toString();
nodeBoxMap.put(key, nodeBoxTable);
}
}
}
// 机房设置机柜放在位置的Map
String nodeBoxInfo = JSONObject.fromObject(nodeBoxMap).toString();
nodeRoomTable.setNodeBoxInfo(nodeBoxInfo);
}
}
} catch (Exception e)
{
e.printStackTrace();
}
return "showNodeRoom";
}
/**
*
* 检查机柜下是否所有节点都正常,有一个不正常则改机柜则为异常
*
* @author jinshujuan Jun 28, 2013
* @version 1.0
* @param boxId
* @param groupId
* @return
*/
private boolean boxIsAlarm(Long boxId, String groupId)
{
boolean isOk = false;
String nibSql = null;
if(this.getAdminMark()){
nibSql = " select count(distinct diw.seq_id)"
+ " from detection_info_new diw"
+ " left join node_table nt on nt.seq_id = diw.seq_id "
+ " where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 "
+ " and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1)"
+ " and nt.node_state = 0"
+ " and nt.node_group_id ="
+ groupId
+ " and nt.seq_id in (select distinct nlt.node_seq from node_lattice_table nlt where nlt.node_seq is not null and nlt.node_box_id = "
+ boxId + ")";
}else{
nibSql = " select count(distinct diw.seq_id)"
+ " from detection_info_new diw"
+ " left join node_table nt on nt.seq_id = diw.seq_id "
+ " where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 "
+ " and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1)"
+ " and nt.node_state = 0"
+ " and nt.system_id="
+ getSystemID()
+ " and nt.node_group_id ="
+ groupId
+ " and nt.seq_id in (select distinct nlt.node_seq from node_lattice_table nlt where nlt.node_seq is not null and nlt.node_box_id = "
+ boxId + ")";
}
try
{
List<Object> falseList = this.commonService.executeSQL(nibSql);
if (Long.parseLong(falseList.get(0).toString()) > 0)
{
isOk = true;
}
} catch (Exception e)
{
e.printStackTrace();
}
return isOk;
}
/**
*
* TODO 该机柜中是否存在本节点组下的节点
*
* @author jinshujuan Jul 4, 2013
* @version 1.0
* @param nodeBoxId2
* @param groupId2
* @return
*/
private boolean BoxhasNode(Long nodeBoxId, String groupId)
{
try
{
String sql = null;
if(this.getAdminMark()){
sql = "SELECT distinct nl.node_seq from node_lattice_table nl WHERE nl.node_box_id="
+ nodeBoxId
+ " AND nl.node_seq IN (SELECT DISTINCT nt.seq_id from node_table nt WHERE nt.node_state=0 "
+ " AND nt.node_group_id=" + groupId + ")";
}else{
sql = "SELECT distinct nl.node_seq from node_lattice_table nl WHERE nl.node_box_id="
+ nodeBoxId
+ " AND nl.node_seq IN (SELECT DISTINCT nt.seq_id from node_table nt WHERE nt.node_state=0 AND nt.system_id="
+ getSystemID() + " AND nt.node_group_id=" + groupId + ")";
}
List list = commonService.executeSQL(sql);
if (list.size() > 0)
{
return true;
}
} catch (Exception e)
{
// TODO: handle exception
}
return false;
}
/**
*
* TODO 获取机柜的位置信息以及每个位置上的节点机
*
* @author jinshujuan Jun 27, 2013
* @version 1.0
* @return
*/
private String getNodeBox()
{
try
{
if (!StringUtil.isBlank(nodeBoxId))
{
// 初始化机柜位置
String hql = " from NodeLatticeTable where nodeBoxId = " + nodeBoxId
+ " order by nodeposition desc";
List<NodeLatticeTable> nodeLatticeList = commonService.find(hql);
// 每个位置上如果放置了节点机 这设置节点机
for (NodeLatticeTable nodeLatticeTable: nodeLatticeList)
{
Long seqId = nodeLatticeTable.getNodeSeqId();
if (seqId != null)
{
if(this.getAdminMark()){
hql = " from NodeTable where nodeState = 0 "
+ " and seqId =" + seqId;
}else{
hql = " from NodeTable where nodeState = 0 and systemId = " + getSystemID()
+ " and seqId =" + seqId;
}
List<NodeTable> nodeList = commonService.find(hql);
if (nodeList.size() > 0)
{
NodeTable nodeTable = nodeList.get(0);
for (NodeTable node: nodeList)
{
if (node.getGroupId().toString().equals(groupId))
{
nodeTable = node;
break;
}
}
// 该节点是否在当前节点组中
if (nodeTable.getGroupId().toString().equals(groupId))
{
nodeLatticeTable.setGroupNode(true);
} else
{
nodeLatticeTable.setGroupNode(false);
}
// 该节点是否正常 DETECTIONED_STATE被监控状态是否正常 1正常 police_emergent 告警是否紧急 0紧急 监测是否有效 1有效
String sql = null;
if(this.getAdminMark()){
sql = "select count(diw.seq_Id) from detection_info_new diw where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 and diw.seq_id = "
+ seqId;
}else{
sql = "select count(diw.seq_Id) from detection_info_new diw where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 and diw.seq_id = "
+ seqId
+ " and diw.DETECTION_SET_INFO_ID in (select dst.ID from DETECTION_SET_INFO dst where dst.DETECTION_SET_STATE=1 "
+ " and ("
+ "dst.VIEW_LEVEL=4 "//无限制
+ "or (dst.VIEW_LEVEL=1 and dst.CREATE_USER_ID = "+this.getUserID()+")"//创建人可查看
+ "or (dst.VIEW_LEVEL=2 and dst.GROUP_ID in (select x.jsbh from Xt_Yh_Js_Index x where x.yhbh='"+this.getUser().getYhbh()+"' ))"//创建人所在组可查看
+ "or (dst.VIEW_LEVEL=3 and dst.SYSTEM_ID="+this.getSystemID()+")"//系统内人员可查看
+ "))";
}
List<Object> falseList = this.commonService.executeSQL(sql);
if (Long.parseLong(falseList.get(0).toString()) > 0)
{
nodeTable.setAlarm(true);
} else
{
nodeTable.setAlarm(false);
}
nodeLatticeTable.setNodeTable(nodeTable);
if(nodeLatticeTable.getNodepositionTemp()==null)
nodeLatticeTable.setNodepositionTemp(1l);
else
nodeLatticeTable.setNodepositionTemp(nodeLatticeTable.getNodepositionTemp()+1l);
}
}
}
outJsonArray(nodeLatticeList);
}
} catch (Exception e)
{
e.printStackTrace();
}
return null;
}
private String showNode()
{
return "showNode";
}
public String getAction()
{
return action;
}
public void setAction(String action)
{
this.action = action;
}
public CommonService getCommonService()
{
return commonService;
}
public void setCommonService(CommonService commonService)
{
this.commonService = commonService;
}
public List<NodegroupTable> getNodegroupList()
{
return nodegroupList;
}
public void setNodegroupList(List<NodegroupTable> nodegroupList)
{
this.nodegroupList = nodegroupList;
}
public String getGroupId()
{
return groupId;
}
public void setGroupId(String groupId)
{
this.groupId = groupId;
}
public List<NodeRoomTable> getNodeRoomList()
{
return nodeRoomList;
}
public void setNodeRoomList(List<NodeRoomTable> nodeRoomList)
{
this.nodeRoomList = nodeRoomList;
}
public String getNodeBoxId()
{
return nodeBoxId;
}
public void setNodeBoxId(String nodeBoxId)
{
this.nodeBoxId = nodeBoxId;
}
public String getFirstGroupId()
{
return firstGroupId;
}
public void setFirstGroupId(String firstGroupId)
{
this.firstGroupId = firstGroupId;
}
public String getNodeBoxIspn()
{
return nodeBoxIspn;
}
public void setNodeBoxIspn(String nodeBoxIspn)
{
this.nodeBoxIspn = nodeBoxIspn;
}
}

View File

@@ -0,0 +1,546 @@
package nis.nms.web.actions.pluginManage;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import nis.nms.domains.PluginInfo;
import nis.nms.domains.XtYhJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Page;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import com.nis.util.StringUtil;
@SuppressWarnings("unchecked")
@Results( {
@Result(name = "queryPluginInfoChild", value = "/page/pluginInfo/pluginInfoListChild.jsp"),
@Result(name = "queryPluginInfo", value = "/page/pluginInfo/pluginInfoList.jsp"),
@Result(name = "addPluginInfo", value = "/page/pluginInfo/addPluginInfo.jsp"),
@Result(name = "updatePluginInfo", value = "/page/pluginInfo/updatePluginInfo.jsp"),
@Result(name = "error", value = "/error.jsp") })
public class PluginManageAction extends BaseAction {
private Logger logger = Logger.getLogger(PluginManageAction.class);
private static final long serialVersionUID = 1L;
private CommonService commonService;
private int pageNo = 1;
private int pageSize = this.getDefaultPageSize(); // 每页显示的记录条数
private Page page;
private String action;
private List<PluginInfo> pluginList;
private PluginInfo pluginInfo;
private Long[] ids;
private String name;
private String fileName;
private Map<String, String> userMap = new HashMap<String, String>();
private String pluginId;
// 导入节点文件
private File myFile;
private String myFileFileName;
public File getMyFile() {
return myFile;
}
public void setMyFile(File myFile) {
this.myFile = myFile;
}
public String getMyFileFileName() {
return myFileFileName;
}
public void setMyFileFileName(String myFileFileName) {
this.myFileFileName = myFileFileName;
}
@Override
public String executeAction() throws Exception {
String resultpage = "";
if ("queryInfo".equals(this.action)) {
resultpage = this.queryPluginInfo();
} else if ("queryChild".equals(this.action)) {
resultpage = this.queryPluginInfoChild();
} else if ("openAdd".equals(this.action)) {
resultpage = "addPluginInfo";
} else if ("doAdd".equals(this.action)) {
resultpage = addPluginInfo();
} else if ("openUpdate".equals(this.action)) {
resultpage = this.openUpdatePlugin();
} else if ("doUpdate".equals(this.action)) {
resultpage = doUpdatePlugin();
} else if ("del".equals(this.action)) {
resultpage = delPluginInfo();
} else if ("downloadPlugin".equals(this.action)) {
resultpage = downloadPlugin();
} else if ("checkName".equals(this.action)) {
resultpage = checkName();
} else {
resultpage = this.queryPluginInfo();
}
return resultpage;
}
private String downloadPlugin() {
try {
if (ids != null && ids.length == 1) {
Long pid = ids[0];
PluginInfo pluginInfo = (PluginInfo) commonService.get(
PluginInfo.class, pid);
String fileName = pluginInfo.getFileName();
FileInputStream fis = null;
BufferedInputStream bis = null;
OutputStream fos = null;
BufferedOutputStream bos = null;
try {
if (!StringUtil.isBlank(fileName)) {
String uploadFilePath = getValue("serverPath")
+ getValue("uploadFilePath");
String realPath = uploadFilePath + fileName;
File uploadFile = new File(realPath);
String downFileName = "";
if (fileName.contains("_")) {
downFileName = fileName.substring(fileName.indexOf("_")+1);
}else {
downFileName = fileName;
}
if (uploadFile.exists()) {
fis = new FileInputStream(uploadFile);
bis = new BufferedInputStream(fis);
fos = getResponse().getOutputStream();
bos = new BufferedOutputStream(fos);
getResponse().setContentType(
"application/octec-stream");
getResponse().setHeader(
"Content-Disposition",
"attachment; filename=\""
+ new String(downFileName
.getBytes("gb2312"),
"ISO8859-1") + "\"");
getResponse().setContentLength(
(int) uploadFile.length());
int bytesRead = 0;
// 同上传类似使用输入输出流这里用的是缓冲输入输出流
byte[] buffer = new byte[8192];
while ((bytesRead = bis.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.flush();
} else {
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.targetFileIsNull_n81i');this.location='pluginManage.do?action=queryInfo&pageNo="
+ pageNo
+ "&pageSize="
+ pageSize
+ "'</script>");
return null;
}
}
} catch (Exception e) {
logger.error("Attachment failed to download", e);
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.fileReadFaild_n81i');this.location='pluginManage.do?action=queryInfo&pageNo="
+ pageNo + "&pageSize=" + pageSize + "'</script>");
return null;
} finally {
try {
if (fis != null) {
fis.close();
}
if (bis != null) {
bis.close();
}
if (fos != null) {
fos.close();
}
if (bos != null) {
bos.close();
}
} catch (Exception e) {
// TODO: handle exception
}
}
} else {
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.onlyOneToolToUse_n81i。');this.location='pluginManage.do?action=queryInfo&pageNo="
+ pageNo + "&pageSize=" + pageSize + "'</script>");
}
} catch (Exception e) {
logger.error(e.getStackTrace());
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.faild_n81i');this.location='pluginManage.do?action=queryInfo&pageNo="
+ pageNo + "&pageSize=" + pageSize + "'</script>");
}
return null;
}
public String queryPluginInfo() {
try {
initMap();
String hql = "from PluginInfo";
if (!StringUtils.isBlank(name)) {
hql += " where name like '%" + name + "%'";
}
if (!StringUtils.isBlank(fileName)) {
if (!hql.contains("where")) {
hql += " where fileName like '%" + fileName + "%'";
} else {
hql += " and fileName like '%" + fileName + "%'";
}
}
hql +=" order by updateTime desc";
page = commonService.findByPage(hql, pageNo, pageSize);
pluginList = (List<PluginInfo>) page.getResult();
formatPlugin();
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.faild_n81i');this.location='pluginManage.do?action=queryInfo&pageNo="
+ pageNo + "&pageSize=" + pageSize + "'</script>");
logger.error(e.getStackTrace());
}
return "queryPluginInfo";
}
private void formatPlugin() {
// TODO Auto-generated method stub
if (userMap.isEmpty()) {
return;
}
for (int i = 0; i < pluginList.size(); i++) {
pluginList.get(i).setCreatUserName(
userMap.get(pluginList.get(i).getCreatUserId().intValue()
+ ""));
pluginList.get(i).setUpdateUserName(
userMap.get(pluginList.get(i).getUpdateUserId().intValue()
+ ""));
String downFileName = "";
if (pluginList.get(i).getFileName().contains("_")) {
downFileName = pluginList.get(i).getFileName().substring(pluginList.get(i).getFileName().indexOf("_")+1);
}else {
downFileName = pluginList.get(i).getFileName();
}
pluginList.get(i).setFileName(downFileName);
}
}
private void initMap() {
// TODO Auto-generated method stub
try {
String hql = "from XtYhJbxx where zxbz=0";
List<XtYhJbxx> yhList = commonService.find(hql);
for (int i = 0; i < yhList.size(); i++) {
userMap.put("" + yhList.get(i).getYhid(), yhList.get(i)
.getYhmc());
}
} catch (Exception e) {
// TODO: handle exception
logger.error(e);
}
}
public String queryPluginInfoChild() {
try {
initMap();
String hql = "from PluginInfo";
if (!StringUtils.isBlank(name)) {
hql += " where Name like '%" + name + "%'";
}
if (!StringUtils.isBlank(fileName)) {
if (!hql.contains("where")) {
hql += " where fileName like '%" + fileName + "%'";
} else {
hql += " and fileName like '%" + fileName + "%'";
}
}
hql +=" order by updateTime desc";
page = commonService.findByPage(hql, pageNo, pageSize);
pluginList = (List<PluginInfo>) page.getResult();
formatPlugin();
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.faild_n81i');this.location='pluginManage.do?action=queryInfo&pageNo="
+ pageNo + "&pageSize=" + pageSize + "'</script>");
logger.error(e.getStackTrace());
}
return "queryPluginInfoChild";
}
// 新增
public String addPluginInfo() throws Exception {
try {
pluginInfo.setCreatTime(new Date());
pluginInfo.setCreatUserId(getUserID());
pluginInfo.setUpdateTime(new Date());
pluginInfo.setUpdateUserId(getUserID());
if (!StringUtils.isBlank(myFileFileName)) {
pluginInfo.setFileName(myFileFileName);
commonService.save(pluginInfo);
pluginInfo.setFileName(pluginInfo.getId() + "_"
+ myFileFileName);// 文件名加上id前缀防止文件名重复。
commonService.saveOrUpdate(pluginInfo);
// ------ 处理附件 start
// 物理上传文件
// -- 获取上传路径
String uploadFilePath = getValue("serverPath")
+ getValue("uploadFilePath");
// -- 上传路径设置
File itemDirFile = new File(uploadFilePath);
if (!itemDirFile.exists()) {
itemDirFile.mkdirs();
}
String filePath = uploadFilePath + pluginInfo.getFileName();
// -- 拷贝文件
this.copy(myFile, new File(filePath));
logger.info(myFile.getAbsolutePath() + "文件上传到" + filePath
+ "成功");
} else {
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.noTools_n81i');this.location='pluginManage.do?action=openAdd&pluginInfo="
+ pluginInfo + "'</script>");
}
} catch (Exception e) {
logger.error(e.getStackTrace());
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.faild_n81i');this.location='pluginManage.do?action=queryInfo'</script>");
}
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.success_n81i');this.location='pluginManage.do?action=queryInfo'</script>");
return null;
}
public String openUpdatePlugin() {
try {
if (ids != null && ids.length > 0) {
pluginId = String.valueOf(ids[0].intValue());
pluginInfo = (PluginInfo) commonService.get(PluginInfo.class,
ids[0]);
String downFileName = "";
if (pluginInfo.getFileName().contains("_")) {
downFileName = pluginInfo.getFileName().substring(pluginInfo.getFileName().indexOf("_")+1);
}else {
downFileName = pluginInfo.getFileName();
}
pluginInfo.setFileName(downFileName);
}
} catch (Exception e) {
logger.error(e.getStackTrace());
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.faild_n81i');this.location='pluginManage.do?action=queryInfo&pageNo="
+ pageNo + "&pageSize=" + pageSize + "'</script>");
}
return "updatePluginInfo";
}
public String doUpdatePlugin() throws Exception {
try {
PluginInfo info = (PluginInfo) commonService.get(PluginInfo.class, pluginInfo.getId());
info.setUpdateTime(new Date());
info.setUpdateUserId(getUserID());
info.setDes(pluginInfo.getDes());
// info.setFileName(pluginInfo.getFileName());
info.setName(pluginInfo.getName());
if (!StringUtils.isBlank(myFileFileName)) {
String uploadFilePath = getValue("serverPath")
+ getValue("uploadFilePath");
// 删除旧的附件
File oldFile = new File(uploadFilePath
+ info.getFileName());
if (oldFile.exists()) {
oldFile.delete();
}
info.setFileName(info.getId() + "_"
+ myFileFileName);
commonService.saveOrUpdate(info);
// 保存新的附件
File itemDirFile = new File(uploadFilePath);
if (!itemDirFile.exists()) {
itemDirFile.mkdirs();
}
String filePath = uploadFilePath + info.getFileName();
// -- 拷贝文件
this.copy(myFile, new File(filePath));
logger.info(myFile.getAbsolutePath() + "文件上传到" + filePath
+ "成功");
} else {
commonService.saveOrUpdate(info);
}
} catch (Exception e) {
logger.error(e.getStackTrace());
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.faild_n81i');this.location='pluginManage.do?action=queryInfo&pageNo="
+ pageNo + "&pageSize=" + pageSize + "'</script>");
}
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.success_n81i');this.location='pluginManage.do?action=queryInfo'</script>");
return null;
}
public String delPluginInfo() throws Exception {
try {
if (ids != null && ids.length > 0) {
for (Long pid : ids) {
PluginInfo pluginInfo = (PluginInfo) commonService.get(
PluginInfo.class, pid);
String uploadFilePath = getValue("serverPath")
+ getValue("uploadFilePath");
// 删除附件
File oldFile = new File(uploadFilePath
+ pluginInfo.getFileName());
if (oldFile.exists()) {
oldFile.delete();
}
// commonService.delete(pluginInfo);
commonService.delete("PluginInfo", pid);
}
}
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.success_n81i');this.location='pluginManage.do?action=queryInfo'</script>");
} catch (Exception e) {
logger.error(e.getStackTrace());
outHtmlString("<script type=\"text/javascript\">alert('i18n_PluginManageAction.downloadPlugin.faild_n81i');this.location='pluginManage.do?action=queryInfo&pageNo="
+ pageNo + "&pageSize=" + pageSize + "'</script>");
}
return null;
}
public String checkName() {
try {
String errorInfo = "";
if (!StringUtils.isBlank(name)) {
String hql = "from PluginInfo where name like '%" + name + "%'";
if (!StringUtils.isBlank(pluginId)) {
hql += " and ID!=" + pluginId;
}
System.out.println(hql);
List<PluginInfo> list = commonService.find(hql);
if (list != null && list.size() > 0) {
errorInfo = getI18nText("i18n_PluginManageAction.downloadPlugin.toolNameRepeat_n81i");
}
}
if (!StringUtil.isBlank(errorInfo)) {
outString(errorInfo);
}
} catch (Exception e) {
logger.error("File name validation failed", e);
e.printStackTrace();
}
return null;
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public Long[] getIds() {
return ids;
}
public void setIds(Long[] ids) {
this.ids = ids;
}
public List<PluginInfo> getPluginList() {
return pluginList;
}
public void setPluginList(List<PluginInfo> pluginList) {
this.pluginList = pluginList;
}
public PluginInfo getPluginInfo() {
return pluginInfo;
}
public void setPluginInfo(PluginInfo pluginInfo) {
this.pluginInfo = pluginInfo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getPluginId() {
return pluginId;
}
public void setPluginId(String pluginId) {
this.pluginId = pluginId;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,283 @@
package nis.nms.web.actions.sysManage;
import java.util.ArrayList;
import java.util.List;
import nis.nms.domains.Brand;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Page;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name = "brandInfoList", value = "/page/system/brandManage/brandInfoList.jsp"),
@Result(name = "toAddBrand", value = "/page/system/brandManage/addBrandInfo.jsp"),
@Result(name = "toUpdateBrand", value = "/page/system/brandManage/updateBrandInfo.jsp"),
@Result(name = "detailBrand", value = "/page/system/brandManage/detailBrandInfo.jsp"),
@Result(name = "error", value = "/error.jsp") })
public class BrandManageAction extends BaseAction {
/**
*
*/
private static final long serialVersionUID = 1L;
private CommonService commonService;
private int pageNo = 1;
private int pageSize = this.getDefaultPageSize(); // 每页显示的记录条数
private Page page;
private String action;// 系统操作
private List<Brand> brandListInfo = new ArrayList();
private Brand brand;//保存品牌信息
private String brandNameForSearch;// 品牌名称,品牌列表查询的时候输入的条件
private String ids;//品牌列表选中的品牌的id
private String position;
public String executeAction() {
try {
// 品牌管理
if (action.equals("queryBrandInfo")) {// 查询品牌列表
queryBrandInfo();
return "brandInfoList";
}
if (action.equals("toAddBrand")) {//新增品牌
toAddBrand();
return "toAddBrand";
}
if (action.equals("addBrand")) {//新增品牌
addBrand();
return null;
}
if (action.equals("toUpdateBrand")) {//修改品牌
toUpdateBrand();
return "toUpdateBrand";
}
if (action.equals("updateBrand")) {//修改品牌
updateBrand();
return null;
}
if (action.equals("detailBrand")) {//查看品牌详细信息
detailBrand();
return "detailBrand";
}
if (action.equals("deleteBrand")) {//删除品牌
return deleteBrand();
}
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return null;
}
/**
*
* 查询品牌信息:查询条件+分页
* @author hyx Mar 29, 2012
* @version 1.0
* @return
*/
public String queryBrandInfo() {
try {
String hql = "from Brand where 1=1 ";
String sqlCondition = "where 1=1";// 将查询条件记录到操作日志中
if (brandNameForSearch != null && !"".equals(brandNameForSearch)) {
hql += " and Upper(brandName) like '%" + brandNameForSearch.toUpperCase() + "%'";
sqlCondition += " and Upper(brandName) like '%" + brandNameForSearch.toUpperCase() + "%'";
}
hql += "order by id";
page = this.commonService.findByPage(hql, pageNo,pageSize);
brandListInfo = (ArrayList<Brand>)page.getResult();
// 将查询请求记入到操作日志表中
this.addDBOperationRpt(commonService, sqlCondition,
"Brand");
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return "brandInfoList";
}
//进入新增页面
public String toAddBrand() {
System.out.println(brandNameForSearch);
return null;
}
//添加品牌信息操作
public String addBrand() {
try {
if(brand!=null){
this.commonService.save(brand);
// 将添加操作写到操作日志中
this.addDBOperationRpt(commonService, "Brand", "INSERT",brand.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_BrandManageAction.addBrand.success_n81i');this.location='brandManage.do?action=queryBrandInfo'</script>");
}
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_BrandManageAction.addBrand.faild_n81i');this.location='brandManage.do?action=queryBrandInfo'</script>");
}
return null;
}
//进入修改页面
public String toUpdateBrand() {
try {
if(ids!=null&&!"".equals(ids) ){
List list = this.commonService.find("from Brand where id=?", Long.valueOf(ids));
if(list!=null && list.size()>0){
brand = (Brand)list.get(0);
}
}
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_BrandManageAction.addBrand.faild_n81i');this.location='brandManage!execute.do?action=queryBrandInfo'</script>");
}
return null;
}
// 进行修改品牌信息操作
public String updateBrand() {
try {
Brand brandForUpdate = (Brand) commonService.get(Brand.class, brand.getId());
brandForUpdate.setBrandDesc(brand.getBrandDesc());
brandForUpdate.setBrandName(brand.getBrandName());
brandForUpdate.setBrandOid(brand.getBrandOid());
this.commonService.update(brandForUpdate);
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "Brand", "UPDATE",brandForUpdate.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_BrandManageAction.addBrand.success_n81i');this.location='brandManage.do?action=queryBrandInfo&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
return null;
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_BrandManageAction.addBrand.faild_n81i');this.location='brandManage.do?action=queryBrandInfo&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
return null;
}
}
// 进行修改品牌信息操作
public String detailBrand() {
try {
String brandId = this.getRequest().getParameter("brandId");
brand = (Brand) commonService.get(Brand.class, Long.valueOf(brandId));
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "Brand", "SELECT",brand.getId());
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_BrandManageAction.addBrand.faild_n81i');this.location='brandManage.do?action=queryBrandInfo'</script>");
}
return null;
}
//删除品牌信息
public String deleteBrand()throws Exception{
try {
if(ids!=null&&!"".equals(ids)) {
String hql = "DELETE FROM Brand WHERE ID IN ("+ ids + ")";
this.commonService.delete(hql);
}
// this.getRequest().setAttribute("MSG", 1);
// outHtmlString("<script type=\"text/javascript\">this.location='brandManage.do?action=queryBrandInfo'</script>");
} catch (Exception e) {
e.printStackTrace();
//outHtmlString("<script type=\"text/javascript\">alert('操作失败');this.location='checkTypeSet.do?action=query'</script>");
}
return this.queryBrandInfo();
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public List getBrandListInfo()
{
return brandListInfo;
}
public void setBrandListInfo(List brandListInfo)
{
this.brandListInfo = brandListInfo;
}
public Brand getBrand()
{
return brand;
}
public void setBrand(Brand brand)
{
this.brand = brand;
}
public String getIds()
{
return ids;
}
public void setIds(String ids)
{
this.ids = ids;
}
public String getBrandNameForSearch()
{
return brandNameForSearch;
}
public void setBrandNameForSearch(String brandNameForSearch)
{
this.brandNameForSearch = brandNameForSearch;
}
}

View File

@@ -0,0 +1,120 @@
package nis.nms.web.actions.sysManage;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import com.mchange.v2.sql.filter.SynchronizedFilterCallableStatement;
import com.opensymphony.xwork2.ActionContext;
import nis.nms.domains.XtYhJbxx;
import nis.nms.util.BaseAction;
import nis.nms.util.Constant;
/**
* httpclient请求其它服务 单点登录
* @author th
*
*/
@SuppressWarnings("unchecked")
@Results( {
@Result(name="error", value = "/error.jsp"),
})
public class ConfigureTheDiffusionAction extends BaseAction{
private Logger logger =Logger.getLogger(this.getClass());
private static Map map=new HashMap();
private static final long serialVersionUID = 822071111080809529L;
private final String CONSUL_SYSTEM_URL=rb.getString("consul.system.url");
private String action;// 系统操作
@Override
public String executeAction() throws Exception {
try {
if (action.equals("query")) {//
queryConfig();
}else if(action.contains("checkToken")){
checkTokenInfo();
}
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return null;
}
//重定向consul服务项目
public void queryConfig(){
try {
HttpServletRequest request = getRequest();
StringBuilder str=new StringBuilder();
str.append("http://");
str.append(getRequest().getServerName());
str.append(":");
str.append(getRequest().getServerPort());
str.append(getRequest().getContextPath());
str.append("/sysManage/configureTheDiffusion.do?action=checkToken");
getRequest().getServerPort();
Locale i18nLang = (Locale) getRequest().getSession().getAttribute("i18n_lang");
XtYhJbxx user = (XtYhJbxx) getRequest().getSession().getAttribute(Constant.SESSION_CZY_NAME);
//生成验证信息的key值
String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
StringBuilder sb=new StringBuilder();
sb.append(CONSUL_SYSTEM_URL);
logger.info("request third project path is "+CONSUL_SYSTEM_URL);
sb.append("?_locale="+i18nLang);
sb.append("&userName="+user.getYhbh());
sb.append("&token="+str.toString()+"&uuid="+uuid);
sb.append("&projectName=nms");
logger.info("request third project is full path "+sb.toString());
//存入标记以备验证
map.put(uuid, "true");
/*getRequest().getSession().setAttribute("consulToken", "true");*/
getResponse().sendRedirect(sb.toString());
} catch (IOException e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('error');</script>");
}
}
//认证token
public void checkTokenInfo(){
String consulToken = getRequest().getParameter("consulToken");
System.out.println("consulToken-------------------------"+consulToken);
String object = (String) map.get(consulToken);
System.out.println("result-------------------------"+object);
//移除标记
map.remove(consulToken);
try {
getResponse().getWriter().write(object);
} catch (IOException e) {
e.printStackTrace();
}
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
}

View File

@@ -0,0 +1,678 @@
package nis.nms.web.actions.sysManage;
import java.io.IOException;
import java.util.List;
import nis.nms.core.Constants;
import nis.nms.domains.OptionTable;
import nis.nms.domains.SetDetDataCon;
import nis.nms.domains.TypeTable;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Constant;
import nis.nms.util.Page;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name="queryDictionaryInfo", value = "/page/system/dictionary/dictionaryInfoList.jsp"),
@Result(name="queryDeteDataConSet", value = "/page/system/dictionary/deteDataConSetList.jsp"),
@Result(name="addDictionaryInfo", value = "/page/system/dictionary/addDictionary.jsp"),
@Result(name="updateDictionaryInfo", value = "/page/system/dictionary/updateDictionary.jsp"),
@Result(name="updateDetDataConSet", value = "/page/system/dictionary/updateDetDataConSet.jsp"),
@Result(name="queryDictionarySource", value = "/page/system/dictionary/dictionarySourceList.jsp"),
@Result(name="addDictionarySource", value = "/page/system/dictionary/addDictionarySource.jsp"),
@Result(name="updDictionarySource", value = "/page/system/dictionary/updateDictionarySource.jsp"),
@Result(name="updDictionarySourceList", value = "/page/system/dictionary/updateDictionarySource.jsp"),
@Result(name="detailDictionaryInfo", value = "/page/system/dictionary/detailDictionary.jsp")
})
/**
* 监测设置相关操作
*/
public class DataDictionaryAction extends BaseAction {
private Logger logger = Logger.getLogger(DataDictionaryAction.class);
private static final long serialVersionUID = 1L;
private CommonService commonService;
private int pageNo = 1;
private int pageSize =this.getDefaultPageSize(); //每页显示的记录条数
private Page page;
private String action;
private List<TypeTable> typeTableList;
private List<OptionTable> optionTableist;
private TypeTable typeTable;
private OptionTable optionTable;
private String ddid;
private Long did;
private String optionId;
private Long didd;
//监测数据列表过滤条件配置相关
private List<SetDetDataCon> setDetDataConList;
private String setId;//监测数据列表过滤条件配置的id
private SetDetDataCon detDataConSet;
@Override
public String executeAction() throws Exception {
String resultpage = "";
if("query".equals(this.action)){
resultpage = this.queryDictionary();
}else if("openAdd".equals(this.action)){
resultpage = "addDictionaryInfo";
}else if("querySouce".equals(this.action)){
getTypeTableById();
resultpage = this.queryDictionarySouce();
}else if("openAddSource".equals(this.action)){
getTypeTableById();
resultpage = "addDictionarySource";
}else if("doAddSource".equals(this.action)){
addDataSource();
return null;
}else if("doAdd".equals(this.action)){
addData();
return null;
}else if("openUpdate".equals(this.action)){
resultpage = this.openUpdDD();
}else if("doUpdate".equals(this.action)){
doUpdData();
return null;
}else if("openUpdateSource".equals(this.action)){
getTypeTableById();
resultpage = this.openUpdDDS();
}else if("doUpdateSource".equals(this.action)){
doUpdDataSource();
return null;
}else if("checkAjax".equals(this.action)){
checkAjax();
return null;
}else if("checkDictionary".equals(this.action)){
checkDictionary();
return null;
}else if("queryDetectConditionSet".equals(this.action)) {//为 业务逻辑拓扑、告警信息、异常服务器、异常网元、系统预警信息菜单 设置过滤条件(告警级别、是否紧急)
resultpage = this.queryDeteDataConSet();
}else if("toUpdateDetectConditionSet".equals(this.action)) {//为 业务逻辑拓扑、告警信息、异常服务器、异常网元、系统预警信息菜单 设置过滤条件(告警级别、是否紧急)
resultpage = this.toUpdateDetectConditionSet();
}else if("updateDetectConditionSet".equals(this.action)) {//为 业务逻辑拓扑、告警信息、异常服务器、异常网元、系统预警信息菜单 设置过滤条件(告警级别、是否紧急)
this.updateDetectConditionSet();
return null;
}else if("updateCheck".equals(this.action)){
this.updateCheck();
return null;
}else if("updateSourceCheck".equals(this.action)){
this.updateSourceCheck();
return null;
}else{
resultpage = this.queryDictionary();
}
return resultpage;
}
public String queryDictionary(){
try {
//查询检测类别用字段
String hql = "from TypeTable order by showNum";
page = this.commonService.findByPage(hql, pageNo, pageSize);
typeTableList = (List<TypeTable>)page.getResult();
} catch (Exception e) {
logger.error("Query data dictionary information failed",e);
this.outHtmlString("<script>alert('i18n_DataDictionaryAction.queryDictionary.queryDictInfoErr_n81i');history.back();</script>");
return null;
}
return "queryDictionaryInfo";
}
public String queryDeteDataConSet(){
try {
//查询检测类别用字段
String hql = "from SetDetDataCon order by id";
page = this.commonService.findByPage(hql, pageNo, pageSize);
setDetDataConList = (List<SetDetDataCon>)page.getResult();
for(SetDetDataCon set:setDetDataConList) {
String policeLevel = set.getPoliceLevel()==null?"":set.getPoliceLevel().trim();
String policeEmergent = set.getPoliceEmergent()==null?"":set.getPoliceEmergent().trim();
if(StringUtils.isNotBlank(policeLevel)) {
String[] policeLevelArray = policeLevel.split(",");
String policeLevelForShow = "";
for(String level:policeLevelArray) {
if(StringUtils.isNotBlank(level)) {
policeLevelForShow = policeLevelForShow + level.trim() + getI18nText("i18n_DataDictionaryAction.queryDictionary.warningLevel_n81i")+",";
}
}
if(policeLevelForShow.endsWith(",")) {
policeLevelForShow = policeLevelForShow.substring(0, policeLevelForShow.length()-1);
}
set.setPoliceLevelForShow(policeLevelForShow);
}
//是否紧急
if(StringUtils.isNotBlank(policeEmergent)) {
if(policeEmergent.contains("0") && policeEmergent.contains("1")) {
set.setPoliceEmergentFowShow(getI18nText("i18n_DataDictionaryAction.queryDictionary.emergent_n81i")+""+getI18nText("i18n_DataDictionaryAction.queryDictionary.nonEmergent_n81i"));
}else if(policeEmergent.contains("0")) {
set.setPoliceEmergentFowShow(getI18nText("i18n_DataDictionaryAction.queryDictionary.emergent_n81i"));
}else if(policeEmergent.contains("1")) {
set.setPoliceEmergentFowShow(getI18nText("i18n_DataDictionaryAction.queryDictionary.nonEmergent_n81i"));
}
}
}
} catch (Exception e) {
logger.error("Query monitoring data list filter condition failed",e);
this.outHtmlString("<script>alert('i18n_DataDictionaryAction.queryDictionary.selectDetecateDataListErr_n81i');this.location='dataDictionary.do?action=queryDetectConditionSet;</script>");
return null;
}
return "queryDeteDataConSet";
}
public void checkDictionary(){
List list = null;
try {
list = this.commonService.find("from TypeTable where typeName=?",typeTable.getTypeName());
if(list!=null && list.size()>0){
this.outString("error1");
return ;
}
list = this.commonService.find("from TypeTable where typeIdentity=?",typeTable.getTypeIdentity());
if(list!=null && list.size()>0){
this.outString("error2");
return ;
}
} catch (Exception e) {
e.printStackTrace();
this.outString("exception");
logger.info("新增数据字典校验异常",e);
}
this.outString("success");
}
public void addData(){
//List list = null;
try {
//判断数据是否存在
/*list = this.commonService.find("from TypeTable where typeName=?",typeTable.getTypeName());
if(list!=null && list.size()>0){
this.outHtmlString("<script>alert('记录已存在,请重新输入!');history.back();</script>");
return;
}*/
//判断字典标识是否存在
/*list = this.commonService.find("from TypeTable where typeIdentity=?",typeTable.getTypeIdentity());
if(list!=null && list.size()>0){
this.outHtmlString("<script>alert('字典标识已存在,请重新输入!');history.back();</script>");
return;
}*/
typeTable.setTypeState(0l);
this.commonService.save(typeTable);
outHtmlString("<script type=\"text/javascript\">alert('i18n_DataDictionaryAction.queryDictionary.success_n81i');this.location='dataDictionary.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
} catch (Exception e) {
logger.error("Failed to add data dictionary",e);
this.outHtmlString("<script>alert('i18n_DataDictionaryAction.queryDictionary.addDictErr_n81i');history.back();</script>");
return;
}
}
public String openUpdDD(){
try {
if(ddid!=null && !"".equals(ddid)){
List list = this.commonService.find(
"from TypeTable where id=?", Long.parseLong(ddid));
if(list!=null && list.size()>0){
typeTable = (TypeTable)list.get(0);
}
}
} catch (Exception e) {
logger.error("Open modified page failed",e);
this.outHtmlString("<script>alert('i18n_DataDictionaryAction.queryDictionary.openUpdateViewErr_n81i');history.back();</script>");
return null;
}
return "updateDictionaryInfo";
}
public String toUpdateDetectConditionSet(){
try {
if(StringUtils.isNotBlank(setId)){
List list = this.commonService.find(
"from SetDetDataCon where id=?", Long.parseLong(setId));
if(list!=null && list.size()>0){
detDataConSet = (SetDetDataCon)list.get(0);
String level = detDataConSet.getPoliceLevel();
String emergent = detDataConSet.getPoliceEmergent();
String levelForShow = ",";
String emergentForShow = ",";
if(StringUtils.isNotBlank(level)) {
String[] levelArray = level.split(",");
for(String levelTmp:levelArray) {
if(StringUtils.isNotBlank(levelTmp)) {
levelForShow = levelForShow + levelTmp.trim() + ",";
}
}
detDataConSet.setPoliceLevel(levelForShow);
}
if(StringUtils.isNotBlank(emergent)) {
String[] emergentArray = emergent.split(",");
for(String emergentTmp:emergentArray) {
if(StringUtils.isNotBlank(emergentTmp)) {
emergentForShow = emergentForShow + emergentTmp.trim() + ",";
}
}
detDataConSet.setPoliceEmergent(emergentForShow);
}
}
}
} catch (Exception e) {
logger.error("Open modified page failed",e);
this.outHtmlString("<script>alert('i18n_DataDictionaryAction.queryDictionary.openUpdateViewErr_n81i');history.back();</script>");
return null;
}
return "updateDetDataConSet";
}
public String openUpdDDS(){
try {
if(optionId!=null && !"".equals(optionId)){
List list = this.commonService.find(
"from OptionTable where id=?", Long.parseLong(optionId));
if(list!=null && list.size()>0){
optionTable = (OptionTable)list.get(0);
}
}
} catch (Exception e) {
logger.error("Open modify source data page failed",e);
this.outHtmlString("<script>alert('i18n_DataDictionaryAction.queryDictionary.openUpdateSourceViewErr_n81i');history.back();</script>");
return null;
}
return "updDictionarySource";
}
public void updateCheck(){
List list;
try {
list = this.commonService.find("from TypeTable where typeName='"+typeTable.getTypeName()+"' and id <> "+typeTable.getId());
if (list != null && list.size() > 0) {
this.outString("error");
return ;
}
} catch (Exception e) {
e.printStackTrace();
this.outString("exception");
logger.info("更新数据字典校验异常",e);
}
this.outString("success");
}
public void doUpdData(){
try {
TypeTable nbt = (TypeTable) this.commonService.get(
TypeTable.class, typeTable.getId());
nbt.setShowNum(typeTable.getShowNum());
nbt.setTypeName(typeTable.getTypeName());
nbt.setTypeDesc(typeTable.getTypeDesc());
Long oldState = nbt.getTypeState();
nbt.setTypeState(typeTable.getTypeState());
this.commonService.update(nbt);
//2018-08-30如果是email需要修改session中的emailflag
if(nbt.getTypeIdentity()!=null&&nbt.getTypeIdentity().equals("emailflag")){
this.getRequest().getSession().setAttribute(Constant.EMAIL_FLAG , nbt.getTypeState());
}
//2018-09-19如果是dept需要修改session中的deptflag并将更新菜单 部门管理显示状态
if(nbt.getTypeIdentity()!=null&&nbt.getTypeIdentity().equals("deptflag")){
Long deptflag = nbt.getTypeState();
this.getRequest().getSession().setAttribute(Constant.DEPT_FLAG, deptflag);
String sql="update xt_mk_jbxx set zxbz=? where id=?";
this.commonService.updateBySql(sql, deptflag,Constants.DEPT_MK_ID);
}
//改变是否显示主动告警的启用状态时需要和各个nc通信SHOW_AUTO_ALARM_FLAG
if(nbt.getTypeIdentity().toLowerCase().equals(Constants.SHOW_AUTO_ALARM_FLAG.toLowerCase())
&& typeTable.getTypeState()!=oldState) {
// 用来实现即时向客户端发送节点是否报主动报警给DC发送信息通知各个:默认不报主动告警
boolean startActiveAlarm = (typeTable.getTypeState()==null || typeTable.getTypeState()==1 )? false : true;
logger.info("NC端是否报主动告警"+startActiveAlarm);
sendStartActiveAlarmState(startActiveAlarm, commonService);
}
outHtmlString("<script type=\"text/javascript\">alert('i18n_DataDictionaryAction.queryDictionary.success_n81i');this.location='dataDictionary.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
} catch (Exception e) {
logger.error("Update failed",e);
this.outHtmlString("<script>alert('i18n_DataDictionaryAction.queryDictionary.updateErr_n81i');history.back();</script>");
return;
}
}
public void updateDetectConditionSet(){
try {
SetDetDataCon set = (SetDetDataCon) this.commonService.get(
SetDetDataCon.class, detDataConSet.getId());
//根据多选组合值???????
String level = detDataConSet.getPoliceLevel();
String emergent = detDataConSet.getPoliceEmergent();
String levelForDB = "";
String emergentForDB = "";
if(StringUtils.isNotBlank(emergent)) {
emergentForDB = ",";
String[] emergentArray = emergent.split(",");
for(String emergentTmp:emergentArray) {
if(StringUtils.isNotBlank(emergentTmp)) {
emergentForDB = emergentForDB + emergentTmp.trim() + ",";
}
}
}
if(emergentForDB.contains(",1,") && StringUtils.isNotBlank(level) ) {//选择了非紧急,才有级别
levelForDB = ",";
String[] levelArray = level.split(",");
for(String levelTmp:levelArray) {
if(StringUtils.isNotBlank(levelTmp)) {
levelForDB = levelForDB + levelTmp.trim() + ",";
}
}
}
set.setPoliceEmergent(emergentForDB);
set.setPoliceLevel(levelForDB);
this.commonService.update(set);
outHtmlString("<script type=\"text/javascript\">alert('i18n_DataDictionaryAction.queryDictionary.success_n81i');this.location='dataDictionary.do?action=queryDetectConditionSet&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
} catch (Exception e) {
logger.error("Update failed",e);
this.outHtmlString("<script>alert('i18n_DataDictionaryAction.queryDictionary.updateErr_n81i');this.location='dataDictionary.do?action=queryDetectConditionSet;</script>");
return;
}
}
public void updateSourceCheck(){
List list;
try {
list = this.commonService.find("from OptionTable where (typeValue='"+optionTable.getTypeValue()+"' or typeCode='"+optionTable.getTypeCode()+"') and id <> "+optionTable.getId()+" and typeIdentity ='"+ddid+"'");
if (list != null && list.size() > 0) {
this.outString("error");
return ;
}
} catch (Exception e) {
e.printStackTrace();
this.outString("exception");
logger.info("更新数据字典校验异常",e);
}
this.outString("success");
}
public void doUpdDataSource(){
try {
/*List list = this.commonService.find("from OptionTable where typeCode='"+optionTable.getTypeCode()+"' and id <> "+optionTable.getId()+" and typeIdentity ='"+ddid+"'");
if (list != null && list.size() > 0) {
this.outHtmlString("<script>alert('记录已存在,请重新输入!');history.back();</script>");
return;
}*/
OptionTable nbt = (OptionTable) this.commonService.get(
OptionTable.class, optionTable.getId());
nbt.setShowNum(optionTable.getShowNum());
nbt.setTypeCode(optionTable.getTypeCode());
nbt.setTypeValue(optionTable.getTypeValue());
nbt.setTypeState(optionTable.getTypeState());
nbt.setTypeIdentity(ddid);
if(optionTable.getDelayTime()==null||optionTable.getDelayTime().equals("")){
optionTable.setDelayTime("0");
}
nbt.setDelayTime(optionTable.getDelayTime());
this.commonService.update(nbt);
outHtmlString("<script type=\"text/javascript\">alert('i18n_DataDictionaryAction.queryDictionary.success_n81i');this.location='dataDictionary.do?action=querySouce&ddid="+ddid+"&did="+did+"&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
} catch (Exception e) {
logger.error("Update failed",e);
this.outHtmlString("<script>alert('i18n_DataDictionaryAction.queryDictionary.updateErr_n81i');history.back();</script>");
return;
}
}
public String queryDictionarySouce(){
try {
if(ddid!=null){
String hql="from OptionTable where typeIdentity='"+ddid+"' order by showNum asc";
page = this.commonService.findByPage(hql, pageNo, pageSize);
optionTableist = (List<OptionTable>)page.getResult();
}
} catch (Exception e) {
logger.error("Query data dictionary source data information failed",e);
this.outHtmlString("<script>alert('i18n_DataDictionaryAction.queryDictionary.queryDictSourceInfoErr_n81i');history.back();</script>");
return null;
}
return "queryDictionarySource";
}
public void getTypeTableById(){
try {
if(did!=null){
List list = this.commonService.find(
"from TypeTable where id="+did);
if(list!=null && list.size()>0){
typeTable = (TypeTable)list.get(0);
}
}
} catch (Exception e) {
logger.error("Fetching category dictionary failed",e);
}
}
public void checkAjax(){
List list = null;
try {
list = this.commonService.find("from OptionTable where (typeCode=? or typeValue=?) and typeIdentity=?",optionTable.getTypeCode(),optionTable.getTypeValue(),ddid);
if(list!=null && list.size()>0){
this.outString("error");
return ;
}
} catch (Exception e) {
e.printStackTrace();
this.outString("exception");
logger.info("新增数据字典校验异常",e);
}
this.outString("success");
}
public void addDataSource(){
// List list = null;
try {
//判断数据是否存在
/*list = this.commonService.find("from OptionTable where typeCode=? and typeIdentity=?",optionTable.getTypeCode(),ddid);
if(list!=null && list.size()>0){
this.outHtmlString("<script>alert('记录已存在,请重新输入!');history.back();</script>");
return;
}*/
optionTable.setTypeState(0l);
optionTable.setTypeIdentity(ddid);
if(optionTable.getDelayTime()==null||optionTable.getDelayTime().equals("")){
optionTable.setDelayTime("0");
}
this.commonService.save(optionTable);
outHtmlString("<script type=\"text/javascript\">alert('i18n_DataDictionaryAction.queryDictionary.success_n81i');this.location='dataDictionary.do?action=querySouce&ddid="+ddid+"&did="+did+"&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
} catch (Exception e) {
logger.error("Failed to add data dictionary source data",e);
this.outHtmlString("<script>alert('i18n_DataDictionaryAction.queryDictionary.addDictSourceErr_n81i');history.back();</script>");
return;
}
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public List<TypeTable> getTypeTableList() {
return typeTableList;
}
public void setTypeTableList(List<TypeTable> typeTableList) {
this.typeTableList = typeTableList;
}
public TypeTable getTypeTable() {
return typeTable;
}
public void setTypeTable(TypeTable typeTable) {
this.typeTable = typeTable;
}
public String getDdid() {
return ddid;
}
public void setDdid(String ddid) {
this.ddid = ddid;
}
public Long getDid() {
return did;
}
public void setDid(Long did) {
this.did = did;
}
public List<OptionTable> getOptionTableist() {
return optionTableist;
}
public void setOptionTableist(List<OptionTable> optionTableist) {
this.optionTableist = optionTableist;
}
public OptionTable getOptionTable() {
return optionTable;
}
public void setOptionTable(OptionTable optionTable) {
this.optionTable = optionTable;
}
public String getOptionId() {
return optionId;
}
public void setOptionId(String optionId) {
this.optionId = optionId;
}
public Long getDidd() {
return didd;
}
public void setDidd(Long didd) {
this.didd = didd;
}
public List<SetDetDataCon> getSetDetDataConList()
{
return setDetDataConList;
}
public void setSetDetDataConList(List<SetDetDataCon> setDetDataConList)
{
this.setDetDataConList = setDetDataConList;
}
public String getSetId()
{
return setId;
}
public void setSetId(String setId)
{
this.setId = setId;
}
public SetDetDataCon getDetDataConSet()
{
return detDataConSet;
}
public void setDetDataConSet(SetDetDataCon detDataConSet)
{
this.detDataConSet = detDataConSet;
}
/**
* Parameter ddid 父级数据字典标识<br>
* Parameter nameLike 字典数据类型名称<br>
*
* @return 字典数据类型代码
*/
public String querySouceForAjax() {
String ddid = this.getRequest().getParameter("ddid").trim();
String nameLike = this.getRequest().getParameter("nameLike").trim();
try {
String sql = "select o.type_code from type_table t, option_table o"
+ " where t.type_identity = '" + ddid + "'"
+ " and t.type_state = 0"
+ " and t.type_identity = o.type_identity"
+ " and o.type_state = 0"
+ " and o.type_value like '%" + nameLike + "%'"
+ " order by o.show_num";
List<Object> list = this.commonService.createSQLQuery(sql).list();
StringBuffer sb = new StringBuffer();
if(!com.nis.util.StringUtil.isEmpty(list)){
for (Object node : list) {
sb.append(node).append(",");
}
sb.delete(sb.length()-1, sb.length());
}
this.getResponse().getWriter().write(sb.toString());
this.getResponse().getWriter().close();
}
catch (IOException e) {
logger.error("获取配置参数失败!", e);
}
return null;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,529 @@
package nis.nms.web.actions.sysManage;
import java.util.ArrayList;
import java.util.List;
import nis.nms.core.Resource;
import nis.nms.domains.TableGuide;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Page;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( { @Result(name = "guideIndex", value = "/page/systemManage/guide/guideIndex.jsp"),
@Result(name = "taskConfig", value = "/page/systemManage/guide/taskConfig.jsp"),
@Result(name = "monitorConfig", value = "/page/systemManage/guide/monitorConfig.jsp")})
public class GuideManageAction extends BaseAction
{
private static final long serialVersionUID = 1L;
private CommonService commonService;
private Page page;
private String isywxt = "no";
private String isyhz = "no";
private String isjf = "no";
private String isjg = "no";
private String isjdz = "no";
private String isrw = "no";
private String isjclb = "no";
private String isjcsz = "no";
private String action;// 系统操作
// 是否完成
private String ywxtCom;
private String yhzCom;
private String jfCom;
private String jgCom;
private String jdzCom;
private String jdCom;
private String rwCom;
private String jclbCom;
private String jclbSourceCom;
private String jcszCom;
private Long packNum;
private String packName;
private Long userid;
public String executeAction()
{
String resultPage = "";
try
{
if (action == null)
{
return "";
}
if (action.equals("index"))
{// 向导首页
resultPage = getUserMk();
} else if ("task".equals(action))
{
resultPage = "taskConfig";
} else if ("monitor".equals(action))
{
resultPage = "monitorConfig";
}
//
} catch (Exception e)
{
e.printStackTrace();
return "error";
}
return resultPage;
}
// 获取用户权限
public String getUserMk()
{
try
{
// List treeList = this.getYhJsMk(this.getUser().getYhbh());
String sql = " select distinct t.mkmc" + " from xt_mk_jbxx t"
+ " left join xt_js_mk_index xj on t.id = xj.mkbh"
+ " left join xt_yh_js_index xy on xj.jsbh = xy.jsbh"
+ " left join xt_yh_jbxx xyj on xyj.yhbh = xy.yhbh" + " where xy.yhbh = '"
+ this.getUser().getYhbh()
+ "' and (t.mktype <> 1 or t.mktype is null ) and t.zxbz = 0";
List mkNames = this.commonService.executeSQL(sql);
// String[] iss
// ={"业务系统管理","用户组管理","机房管理","机柜管理","节点组管理","任务管理","监测类别设置","监测设置"};
String n = "";
for (int i = 0; i < mkNames.size(); i++)
{
n = mkNames.get(i).toString();
if (n.equals(getI18nText("i18n_GuideManageAction.getUserMk.systemManage_n81i")))
{
isywxt = "yes";
} else if (n.equals(getI18nText("i18n_GuideManageAction.getUserMk.usergroupManage_n81i")))
{
isyhz = "yes";
} else if (n.equals(getI18nText("i18n_GuideManageAction.getUserMk.roomManage_n81i")))
{
isjf = "yes";
} else if (n.equals(getI18nText("i18n_GuideManageAction.getUserMk.boxManage_n81i")))
{
isjg = "yes";
} else if (n.equals(getI18nText("i18n_GuideManageAction.getUserMk.nodegroupManage_n81i")))
{
isjdz = "yes";
} else if (n.equals(getI18nText("i18n_GuideManageAction.getUserMk.missionManage_n81i")))
{
isrw = "yes";
} else if (n.equals(getI18nText("i18n_GuideManageAction.getUserMk.detecateTypeManage_n81i")))
{
isjclb = "yes";
} else if (n.equals(getI18nText("i18n_GuideManageAction.getUserMk.detecateSetsManage_n81i")))
{
isjcsz = "yes";
} else
{
continue;
}
}
String sqlCom = " from TableGuide where userId = " + this.getUserID()
+ " and systemId=" + this.getSystemID();
List completeMenu = this.commonService.find(sqlCom);
for (int j = 0; j < completeMenu.size(); j++)
{
TableGuide tg = (TableGuide) completeMenu.get(j);
if (tg.getGuideName().equals("ywxt"))
{
ywxtCom = "y";
} else if (tg.getGuideName().equals("yhz"))
{
yhzCom = "y";
} else if (tg.getGuideName().equals("jf"))
{
jfCom = "y";
} else if (tg.getGuideName().equals("jg"))
{
jgCom = "y";
} else if (tg.getGuideName().equals("jdz"))
{
jdzCom = "y";
} else if (tg.getGuideName().equals("jd"))
{
jdCom = "y";
} else if (tg.getGuideName().equals("rw"))
{
rwCom = "y";
} else if (tg.getGuideName().equals("jclb"))
{
jclbCom = "y";
} else if (tg.getGuideName().equals("jclbysj"))
{
jclbSourceCom = "y";
} else if (tg.getGuideName().equals("jcsz"))
{
jcszCom = "y";
} else
{
continue;
}
}
// HttpSession ss = this.getRequest().getSession();
//
// //业务系统管理完成
// if(ywxtCom!=null && ywxtCom.equals("y")){
// ywxtCom = "y";
// ss.setAttribute("ywxtCom","y");
// }
// //用户组管理
// if(yhzCom!=null && yhzCom.equals("y")){
// yhzCom = "y";
// }
//
// //机房管理
// if(jfCom!=null && jfCom.equals("y")){
// jfCom = "y";
// }
//
// //机柜管理
// if(jgCom!=null && jgCom.equals("y")){
// jgCom = "y";
// }
//
// //节点组管理
// if(jdzCom!=null && jdzCom.equals("y")){
// jdzCom = "y";
// }
//
// //任务管理
// if(rwCom!=null && rwCom.equals("y")){
// rwCom = "y";
// }
// //监测类别管理
// if(jclbCom!=null && jclbCom.equals("y")){
// jclbCom = "y";
// }
// //监测设置
// if(jcszCom!=null && jcszCom.equals("y")){
// jcszCom = "y";
// }
} catch (Exception e)
{
e.printStackTrace();
}
return "guideIndex";
}
public String setComplete()
{
String jsonStr = null;
try
{
TableGuide tg = null;
List nplist = this.commonService
.find("from TableGuide where userId=? and guideName = ? and systemId=?", this
.getUserID(), packName, this.getSystemID());
if (nplist == null || nplist.size() == 0)
{
tg = new TableGuide();
tg.setUserId(this.getUserID());
tg.setGuideId(packNum);
tg.setGuideName(packName);
tg.setSystemId(this.getSystemID());
this.commonService.save(tg);
this.addDBOperationRpt(commonService, "TableGuide", "INSERT", tg.getId());
} else
{
tg = (TableGuide) nplist.get(0);
tg.setUserId(this.getUserID());
tg.setGuideId(packNum);
tg.setGuideName(packName);
tg.setSystemId(this.getSystemID());
this.commonService.update(tg);
this.addDBOperationRpt(commonService, "TableGuide", "update", tg.getId());
}
jsonStr = "{\"resu\":\"over\"}";
this.outJson(jsonStr);
} catch (Exception e)
{
e.printStackTrace();
}
return null;
}
public GuideManageAction()
{
// TODO Auto-generated constructor stub
}
public List getYhJsMk(String yhbh)
{
List treeList = new ArrayList();
try
{
String sql = "select id,mkmc,mkurl from XtMkJbxx where id in "
+ "(select mkbh from XtJsMkIndex where jsbh in"
+ "(select a.jsbh from XtJsJbxx a where a.jsbh in("
+ "select jsbh from XtYhJsIndex where yhbh = '"
+ yhbh
+ "') and a.zxbz='0')) and zxbz='0' and (mktype <> 1 or mktype is null ) order by showlevel,showorder";
List menuList = this.commonService.find(sql);
for (int i = 0; i < menuList.size(); i++)
{
Object[] obj = (Object[]) menuList.get(i);// 0为id,1为mkmc,2为mkurl
Resource resource = new Resource();
resource.setRsCode(obj[0].toString());
resource.setRsid(obj[1].toString());
resource.setRsname(obj[2].toString());
treeList.add(resource);
}
} catch (Exception e)
{
e.printStackTrace();
}
return treeList;
}
public CommonService getCommonService()
{
return commonService;
}
public void setCommonService(CommonService commonService)
{
this.commonService = commonService;
}
public Page getPage()
{
return page;
}
public void setPage(Page page)
{
this.page = page;
}
public String getAction()
{
return action;
}
public void setAction(String action)
{
this.action = action;
}
public String getIsywxt()
{
return isywxt;
}
public void setIsywxt(String isywxt)
{
this.isywxt = isywxt;
}
public String getIsyhz()
{
return isyhz;
}
public void setIsyhz(String isyhz)
{
this.isyhz = isyhz;
}
public String getIsjf()
{
return isjf;
}
public void setIsjf(String isjf)
{
this.isjf = isjf;
}
public String getIsjg()
{
return isjg;
}
public void setIsjg(String isjg)
{
this.isjg = isjg;
}
public String getIsjdz()
{
return isjdz;
}
public void setIsjdz(String isjdz)
{
this.isjdz = isjdz;
}
public String getIsrw()
{
return isrw;
}
public void setIsrw(String isrw)
{
this.isrw = isrw;
}
public String getIsjclb()
{
return isjclb;
}
public void setIsjclb(String isjclb)
{
this.isjclb = isjclb;
}
public String getIsjcsz()
{
return isjcsz;
}
public void setIsjcsz(String isjcsz)
{
this.isjcsz = isjcsz;
}
public String getYwxtCom()
{
return ywxtCom;
}
public void setYwxtCom(String ywxtCom)
{
this.ywxtCom = ywxtCom;
}
public String getYhzCom()
{
return yhzCom;
}
public void setYhzCom(String yhzCom)
{
this.yhzCom = yhzCom;
}
public String getJfCom()
{
return jfCom;
}
public void setJfCom(String jfCom)
{
this.jfCom = jfCom;
}
public String getJgCom()
{
return jgCom;
}
public void setJgCom(String jgCom)
{
this.jgCom = jgCom;
}
public String getJdzCom()
{
return jdzCom;
}
public void setJdzCom(String jdzCom)
{
this.jdzCom = jdzCom;
}
public String getRwCom()
{
return rwCom;
}
public void setRwCom(String rwCom)
{
this.rwCom = rwCom;
}
public String getJclbCom()
{
return jclbCom;
}
public void setJclbCom(String jclbCom)
{
this.jclbCom = jclbCom;
}
public String getJcszCom()
{
return jcszCom;
}
public void setJcszCom(String jcszCom)
{
this.jcszCom = jcszCom;
}
public Long getPackNum()
{
return packNum;
}
public void setPackNum(Long packNum)
{
this.packNum = packNum;
}
public String getPackName()
{
return packName;
}
public void setPackName(String packName)
{
this.packName = packName;
}
public Long getUserid()
{
return userid;
}
public void setUserid(Long userid)
{
this.userid = userid;
}
public String getJdCom()
{
return jdCom;
}
public void setJdCom(String jdCom)
{
this.jdCom = jdCom;
}
public String getJclbSourceCom()
{
return jclbSourceCom;
}
public void setJclbSourceCom(String jclbSourceCom)
{
this.jclbSourceCom = jclbSourceCom;
}
}

View File

@@ -0,0 +1,605 @@
package nis.nms.web.actions.sysManage;
import java.util.Date;
import java.util.List;
import nis.nms.core.Resource;
import nis.nms.domains.NodePosition;
import nis.nms.domains.NodeTable;
import nis.nms.domains.NodegroupTable;
import nis.nms.domains.SystemTable;
import nis.nms.domains.XtJsJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Page;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name="queryNodeGroupInfo", value = "/page/systemManage/nodegroup/nodegroupInfoList.jsp"),
@Result(name="addNodeGroupInfo", value = "/page/systemManage/nodegroup/addNodegroupInfo.jsp"),
@Result(name="updateNodeGroupInfo", value = "/page/systemManage/nodegroup/updateNodegroupInfo.jsp"),
@Result(name="detailNodeGroupInfo", value = "/page/systemManage/nodegroup/detailNodegroupInfo.jsp"),
@Result(name="nodeMgmtList", value = "/page/systemManage/nodegroup/nodeMgmtList.jsp"),
@Result(name="error", value ="/error.jsp")
})
public class NodeGroupManageAction extends BaseAction{
private static final long serialVersionUID = 1L;
private CommonService commonService;
private int pageNo = 1;
private int pageSize =this.getDefaultPageSize(); //每页显示的记录条数
private Page page;
private String action;//系统操作
private List<NodegroupTable> nodeGroupList;
private NodegroupTable nodeGroup;
private Long nodeGroupId;
private Long[] ids;//用户组id集合
private List<XtJsJbxx> allUserGroup;//当前用户有权限的用户组
//查询条件
private String nameVo;
private String descVo;
private Long mkid;//业务系统ID
private List<Resource> treeList;//当前用户有权限的业务系统
private SystemTable system;//当前登录选择的业务系统
private List<SystemTable> systemList;
private List<NodeTable> nodeList;
public String executeAction(){
String resultPage = "";
try{
if(action==null){//管理页面,显示所有节点信息
resultPage = queryNodeGroupInfo();
}else if(action.equals("openAdd")){//转向添加节点组页面
resultPage = openAddNodeGroupInfo();
}else if(action.equals("doAdd")){//提交添加节点组信息
resultPage = addNodeGroupInfo();
}else if(action.equals("openUpdate")){//转向修改节点组页面
resultPage = openUpdateNodeGroupInfo();
}else if(action.equals("doUpdate")){//提交修改节点组信息
resultPage = updateNodeGroupInfo();
}else if(action.equals("stop")){//停用节点组
resultPage = stopNodeGroupInfo();
}else if(action.equals("start")){//启用节点组
resultPage = startNodeGroupInfo();
}else if(action.equals("detail")){//查看详情
resultPage = detailNodeGroupInfo();
}else if(action.equals("nodeMgmt")){//转向节点管理页面
resultPage = nodeMgmtList();
}else{//管理页面,显示所有节点信息
resultPage = queryNodeGroupInfo();
}
}catch (Exception e){
e.printStackTrace();
return "error";
}
return resultPage;
}
//管理节点组信息列表
public String queryNodeGroupInfo(){
try{
String hql = "from NodegroupTable where 1=1";
String sqlCondition = "where 1=1";
boolean ADMFlag = this.getAdminMark();
this.getRequest().setAttribute("ADMFlag", ADMFlag);
//当前登录用户非admin时才做查看权限限制
if(!ADMFlag){
//权限控制----------------------------------------------------begin
//如果当前登录选择了业务系统,则只做和本业务系统相关的操作
if(this.getSystemID()!=null){
hql += " and systemId = " + this.getSystemID();
sqlCondition += " and system_id=" + this.getSystemID();
}
//1 发布人查看,2 发布人所在组查看,3 系统内全部人员可看
hql += " and (";
hql += " (viewLevel=1 and createUserId=" + this.getUserID() + ")";
hql += " or (viewLevel=2 and createUsergroupId in (select jsbh from XtYhJsIndex " +
" where type=1 and yhbh='" + this.getUser().getYhbh() + "') )" ;
if(this.getSystemID()!=null){
hql += " or (viewLevel=3 and systemId=" + this.getSystemID() + ")";
}else{
hql += " or (viewLevel=3 and systemId in" +
" (select systemId from GorupSystemTable where userGroupId in" +
" (select jsbh from XtYhJsIndex where type=1 and yhbh='" + this.getUser().getYhbh() + "')" +
" ) )";
}
hql += ")";
//权限控制----------------------------------------------------end
}
if(nameVo!=null && !nameVo.trim().equals("")){
hql += " and Upper(groupName) like '%" + nameVo.trim().toUpperCase() + "%'";
sqlCondition += " and Upper(group_name) like '%" + nameVo.trim().toUpperCase() + "%'";
}
if(descVo!=null && !descVo.trim().equals("")){
hql += " and Upper(groupDesc) like '%" + descVo.trim().toUpperCase() + "%'";
sqlCondition += " and Upper(group_desc) like '%" + descVo.trim().toUpperCase() + "%'";
}
hql += " order by isValid desc,groupCreatetime desc";
sqlCondition += " order by is_valid asc,Group_createtime desc";
// 将查询请求记入到操作日志表中
this.addDBOperationRpt(commonService, sqlCondition, "nodegroup_table");
page = this.commonService.findByPage(hql, pageNo, pageSize);
nodeGroupList = (List<NodegroupTable>)page.getResult();
}catch (Exception e){
e.printStackTrace();
return "error";
}
return "queryNodeGroupInfo";
}
//打开添加节点组页面
public String openAddNodeGroupInfo(){
try {
//查询系统
/*treeList = new ArrayList();
String hql = "from SystemTable where systemState='0'" +//正常0;已删除或停用1
" and systemId in (select systemId from GorupSystemTable where userGroupId in" +
" (select jsbh from XtYhJsIndex where type=1 and yhbh='" + this.getUser().getYhbh() + "')" +
" )";//当前用户所在组有权限的系统
List<SystemTable> menuList = this.commonService.find(hql);
for (int i = 0; i < menuList.size(); i++) {
Resource resource = new Resource();
resource.setParRsCode("0");
resource.setRsCode(menuList.get(i).getSystemId().toString());
resource.setRsid(menuList.get(i).getSystemId().toString());
resource.setRsname(menuList.get(i).getSystemName().toString());
treeList.add(resource);
}*/
boolean ADMFlag = this.getAdminMark();
this.getRequest().setAttribute("ADMFlag", ADMFlag);
if(ADMFlag){//如果是admin登陆则无限制
String hql = "from SystemTable where systemState='0'";
systemList = this.commonService.find(hql);
}else{
system = (SystemTable)this.commonService.get(SystemTable.class, this.getSystemID());
}
//查询当前用户所在的有效用户组
this.queryAllUserGroup();
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_NodeGroupManageAction.openAddNodeGroupInfo.faild_n81i');" +
"this.location='nodeGroupManage.do?action=query'</script>");
}
return "addNodeGroupInfo";
}
//添加节点组
public String addNodeGroupInfo(){
try{
List list = this.commonService.find("from NodegroupTable where groupName=?", nodeGroup.getGroupName());
if(list!=null && list.size()>0){
this.outHtmlString("<script>alert('i18n_NodeGroupManageAction.addNodeGroupInfo.nodeGroupExists_n81i');history.back();</script>");
return null;
}
nodeGroup.setCreateUserId(this.getUserID());
nodeGroup.setSystemId(mkid);
nodeGroup.setGroupCreatetime(new Date());
nodeGroup.setParentGroupId(new Long(0l));
nodeGroup.setLeafGroup(new Long(0l));
nodeGroup.setGroupLevel(new Long(1l));
//获得新增节点组的显示序号
Long showNum = new Long(0l);
String indexSql = "select max(t.show_index) from nodegroup_table t where t.parent_group_id = 0";
List subNodeGroup = this.commonService.executeSQL(indexSql);
if(subNodeGroup.size()>0) {
Object showNumTemp = subNodeGroup.get(0);
if(showNumTemp!=null) {
showNum = new Long(showNumTemp.toString())+1l;
}
}
nodeGroup.setShowIndex(showNum);
this.commonService.save(nodeGroup);
//拓扑图的数据维护
List nplist = this.commonService.find(
"from NodePosition where nodeType='system' and nodeId=?",
nodeGroup.getSystemId()+"");//查找父ID
if (nplist != null && nplist.size() > 0) {
NodePosition parent = (NodePosition) nplist.get(0);
//查找是否有相同记录存在,不存在再添加
nplist = this.commonService
.find(
"from NodePosition where nodeType='nodeGroup' and nodeId=? and parent_id=?",
nodeGroup.getGroupId()+"", parent.getParent_id());
if (nplist == null || nplist.size() == 0) {
NodePosition np = new NodePosition();
np.setTableName("nodegroup_table");
np.setNodeType("nodeGroup");
np.setNodeId(nodeGroup.getGroupId() + "");
np.setPositionX(0l);
np.setPositionY(0l);
np.setImageUrl("/nmsweb/images/show/topic.png");
np.setViewTimeMark(new Date());
np.setViewType(1l);
np.setParent_id(parent.getId());
this.commonService.save(np);
this.addDBOperationRpt(commonService, "node_position", "INSERT",np.getId());
}
}
//将添加操作写到操作日志中
this.addDBOperationRpt(commonService, "nodegroup_table", "INSERT", nodeGroup.getGroupId());
this.sendNodeAndGroupId(nodeGroup.getGroupId(), null,commonService); //通知NMSServer更新节点组的监控信息
this.getRequest().setAttribute("MSG", 1);
}catch (Exception e){
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_NodeGroupManageAction.openAddNodeGroupInfo.faild_n81i');" +
"this.location='nodeGroupManage.do?action=query'</script>");
}
return queryNodeGroupInfo();
}
//打开修改节点组信息页面
public String openUpdateNodeGroupInfo(){
try{
if(ids!=null && ids.length>0){
nodeGroupId = ids[0];
}
List list = this.commonService.find(
"from NodegroupTable where groupId=?", nodeGroupId);
if(list!=null && list.size()>0){
nodeGroup = (NodegroupTable)list.get(0);
}
/*treeList = new ArrayList<Resource>();
String hql = "from SystemTable where systemState='0'" +//正常0;已删除或停用1
" and systemId in (select systemId from GorupSystemTable where userGroupId in" +
" (select jsbh from XtYhJsIndex where type=1 and yhbh='" + this.getUser().getYhbh() + "')" +
" )";//当前用户所在组有权限的系统
List<SystemTable> menuList = this.commonService.find(hql);
// 查询用户组属于的nms系统
for (SystemTable systable : menuList) {
Resource re = new Resource();
// 如果本节点组属于这个系统将其选中
if (nodeGroup!=null && systable.getSystemId()
.equals(nodeGroup.getSystemId())) {
re.setChecked("checked");
}
re.setRsid(systable.getSystemId().toString().trim());
re.setRsname(systable.getSystemName());
re.setRsdesc(systable.getSystemDesc());
// 系统的父id设为0
re.setParRsCode("0");
re.setRsCode(systable.getSystemId().toString());
treeList.add(re);// 添加系统结束
}*/
boolean ADMFlag = this.getAdminMark();
this.getRequest().setAttribute("ADMFlag", ADMFlag);
if(ADMFlag){//如果是admin登陆则无限制
String hql = "from SystemTable where systemState='0'";
systemList = this.commonService.find(hql);
}else{
system = (SystemTable)this.commonService.get(SystemTable.class, this.getSystemID());
}
//查询当前用户所在的有效用户组
this.queryAllUserGroup();
}catch (Exception e){
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_NodeGroupManageAction.openAddNodeGroupInfo.faild_n81i');" +
"this.location='nodeGroupManage.do?action=query'</script>");
}
return "updateNodeGroupInfo";
}
//修改节点组
public String updateNodeGroupInfo(){
try{
List list = this.commonService.find("from NodegroupTable where groupName=? and groupId<>?",
nodeGroup.getGroupName(),nodeGroup.getGroupId());
if(list!=null && list.size()>0){
this.outHtmlString("<script>alert('i18n_NodeGroupManageAction.addNodeGroupInfo.nodeGroupExists_n81i');history.back();</script>");
return null;
}
List noList = this.commonService.find("from NodegroupTable where groupId=?", nodeGroup.getGroupId());
NodegroupTable group = (NodegroupTable) this.commonService.get(NodegroupTable.class, nodeGroup.getGroupId());
boolean flag = false;
if(group != null){
// NodegroupTable group = (NodegroupTable)noList.get(0);
if(!group.getIsValid().equals(nodeGroup.getIsValid())){
flag = true;
}
group.setGroupName(nodeGroup.getGroupName());
group.setGroupType(nodeGroup.getGroupType());
group.setGroupDesc(nodeGroup.getGroupDesc());
group.setIsValid(nodeGroup.getIsValid());
group.setViewLevel(nodeGroup.getViewLevel());
group.setSystemId(mkid);
group.setCreateUsergroupId(nodeGroup.getCreateUsergroupId());
this.commonService.update(group);
//将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "nodegroup_table", "UPDATE", nodeGroup.getGroupId());
}
if(flag){
this.sendNodeAndGroupId(group.getGroupId(), null,commonService); //通知NMSServer更新节点组的监控信息
}
this.getRequest().setAttribute("MSG", 1);
}catch (Exception e){
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_NodeGroupManageAction.openAddNodeGroupInfo.faild_n81i');" +
"this.location='nodeGroupManage.do?action=query'</script>");
}
return queryNodeGroupInfo();
}
//停用节点组
public String stopNodeGroupInfo(){
try{
if(ids!=null && ids.length>0){
for(int i=0; i<ids.length; i++){
this.commonService.updateByHql(
"update NodegroupTable set isValid=0 where groupId=?", ids[i]);
this.sendNodeAndGroupId(ids[i], null,commonService); //通知NMSServer更新节点组的监控信息
//将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "nodegroup_table", "UPDATE", ids[i]);
}
}
//this.getRequest().setAttribute("MSG", 1);
}catch (Exception e){
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_NodeGroupManageAction.openAddNodeGroupInfo.faild_n81i');" +
"this.location='nodeGroupManage.do?action=query'</script>");
}
outHtmlString("<script type=\"text/javascript\">alert('i18n_NodeGroupManageAction.startNodeGroupInfo.faild_n81i');" +
"this.location='nodeGroupManage.do?action=query&pageNo=" + pageNo +
"&pageSize=" + pageSize + "'</script>");
return null;
//return queryNodeGroupInfo();
}
//启用节点组
public String startNodeGroupInfo(){
try{
if(ids!=null && ids.length>0){
for(int i=0; i<ids.length; i++){
this.commonService.updateByHql(
"update NodegroupTable set isValid=1 where groupId=?", ids[i]);
this.sendNodeAndGroupId(ids[i], null,commonService); //通知NMSServer更新节点组的监控信息
//将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "nodegroup_table", "UPDATE", ids[i]);
}
}
}catch (Exception e){
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_NodeGroupManageAction.openAddNodeGroupInfo.faild_n81i');" +
"this.location='nodeGroupManage.do?action=query'</script>");
}
outHtmlString("<script type=\"text/javascript\">alert('i18n_NodeGroupManageAction.startNodeGroupInfo.faild_n81i');" +
"this.location='nodeGroupManage.do?action=query&pageNo=" + pageNo +
"&pageSize=" + pageSize + "'</script>");
return null;
//this.getRequest().setAttribute("MSG", 1);
//return queryNodeGroupInfo();
}
//查看节点组详情
public String detailNodeGroupInfo(){
try{
List list = this.commonService.find(
"from NodegroupTable where groupId=?", nodeGroupId);
if(list!=null && list.size()>0){
nodeGroup = (NodegroupTable)list.get(0);
List syslist = this.commonService.find("from SystemTable where systemId=?", nodeGroup.getSystemId());
if(syslist!=null && syslist.size()>0){
SystemTable sys = (SystemTable)syslist.get(0);
nodeGroup.setSystemIdName(sys.getSystemName());
}
if (nodeGroup.getCreateUsergroupId()!=null && nodeGroup.getCreateUsergroupId().intValue()!=0) {
XtJsJbxx xtjsjbxx = (XtJsJbxx) this.commonService.get(
XtJsJbxx.class, nodeGroup.getCreateUsergroupId());
if (xtjsjbxx != null) {
nodeGroup.setUserGroupIdName(xtjsjbxx.getJsmc());
}
}
String hql = "from NodeTable where groupId = " + nodeGroup.getGroupId() + "";
nodeList = (List<NodeTable>)this.commonService.find(hql);
}
}catch (Exception e){
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_NodeGroupManageAction.openAddNodeGroupInfo.faild_n81i');" +
"this.location='nodeGroupManage.do?action=query'</script>");
}
return "detailNodeGroupInfo";
}
//查询当前用户所在的用户组
private void queryAllUserGroup(){
try {
//查询当前用户所在的有效用户组
String hql2 = "from XtJsJbxx where zxbz=0 and jsbh in" +//zxbz注销标志0是有效1是无效
" (select jsbh from XtYhJsIndex where type=1 and yhbh='" + this.getUser().getYhbh() + "')";
allUserGroup = this.commonService.find(hql2);
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_NodeGroupManageAction.openAddNodeGroupInfo.faild_n81i');" +
"this.location='nodeGroupManage.do?action=query'</script>");
}
}
/**==========================================节点操作开始========================= ==========**/
//打开节点管理页面
public String nodeMgmtList(){
try{
if(ids!=null && ids.length>0){
nodeGroupId = ids[0];
}
List list = this.commonService.find(
"from NodegroupTable where groupId=?", nodeGroupId);
if(list!=null && list.size()>0){
nodeGroup = (NodegroupTable)list.get(0);
}
}catch (Exception e){
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_NodeGroupManageAction.openAddNodeGroupInfo.faild_n81i');" +
"this.location='nodeGroupManage.do?action=query'</script>");
}
return "nodeMgmtList";
}
public NodeGroupManageAction() {
// TODO Auto-generated constructor stub
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public List<NodegroupTable> getNodeGroupList() {
return nodeGroupList;
}
public void setNodeGroupList(List<NodegroupTable> nodeGroupList) {
this.nodeGroupList = nodeGroupList;
}
public NodegroupTable getNodeGroup() {
return nodeGroup;
}
public void setNodeGroup(NodegroupTable nodeGroup) {
this.nodeGroup = nodeGroup;
}
public Long getNodeGroupId() {
return nodeGroupId;
}
public void setNodeGroupId(Long nodeGroupId) {
this.nodeGroupId = nodeGroupId;
}
public String getNameVo() {
return nameVo;
}
public void setNameVo(String nameVo) {
this.nameVo = nameVo;
}
public String getDescVo() {
return descVo;
}
public void setDescVo(String descVo) {
this.descVo = descVo;
}
public Long getMkid() {
return mkid;
}
public void setMkid(Long mkid) {
this.mkid = mkid;
}
public List<Resource> getTreeList() {
return treeList;
}
public void setTreeList(List<Resource> treeList) {
this.treeList = treeList;
}
public List<XtJsJbxx> getAllUserGroup() {
return allUserGroup;
}
public void setAllUserGroup(List<XtJsJbxx> allUserGroup) {
this.allUserGroup = allUserGroup;
}
public List<NodeTable> getNodeList() {
return nodeList;
}
public void setNodeList(List<NodeTable> nodeList) {
this.nodeList = nodeList;
}
public Long[] getIds() {
return ids;
}
public void setIds(Long[] ids) {
this.ids = ids;
}
public SystemTable getSystem() {
return system;
}
public void setSystem(SystemTable system) {
this.system = system;
}
public List<SystemTable> getSystemList() {
return systemList;
}
public void setSystemList(List<SystemTable> systemList) {
this.systemList = systemList;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,290 @@
package nis.nms.web.actions.sysManage;
import java.util.ArrayList;
import java.util.List;
import nis.nms.domains.SortInfo;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Page;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
@SuppressWarnings("unchecked")
@Results( {
@Result(name = "snmpDetectTypeList", value = "/page/system/snmpDetectTypeManage/snmpDetectTypeInfoList.jsp"),
@Result(name = "toAddSnmpDetectType", value = "/page/system/snmpDetectTypeManage/addSnmpDetectTypeInfo.jsp"),
@Result(name = "toUpdateSnmpDetectType", value = "/page/system/snmpDetectTypeManage/updateSnmpDetectTypeInfo.jsp"),
@Result(name = "detailSnmpDetectType", value = "/page/system/snmpDetectTypeManage/detailSnmpDetectTypeInfo.jsp"),
@Result(name = "error", value = "/error.jsp") })
public class SnmpDetectManageAction extends BaseAction {
/**
*
*/
private static final long serialVersionUID = 1L;
private CommonService commonService;
private int pageNo = 1;
private int pageSize = this.getDefaultPageSize(); // 每页显示的记录条数
private Page page;
private String action;// 系统操作
private List<SortInfo> sortInfoList = new ArrayList();
private SortInfo sortInfo;//保存snmp监测项信息
private String sortNameForSearch;// snmp监测类型名称,snmp监测项列表查询的时候输入的条件
private String ids;//snmp监测项列表选中的snmp监测项的id
private String position;
public String executeAction() {
try {
// snmp监测项管理
if (action.equals("querySnmpDetectTypeInfo")) {// 查询snmp监测项列表
querySnmpDetectTypeInfo();
return "snmpDetectTypeList";
}
if (action.equals("toAddSnmpDetectType")) {//新增snmp监测项页面
toAddSnmpDetectType();
return "toAddSnmpDetectType";
}
if (action.equals("addSnmpDetectType")) {//新增snmp监测项操作
addSnmpDetectType();
return null;
}
if (action.equals("toUpdateSnmpDetectType")) {//修改snmp监测项页面
toUpdateSnmpDetectType();
return "toUpdateSnmpDetectType";
}
if (action.equals("updateSnmpDetectType")) {//修改snmp监测项操作
updateSnmpDetectType();
return null;
}
if (action.equals("detailSnmpDetectType")) {//查看snmp监测项详细信息
detailSnmpDetectType();
return "detailSnmpDetectType";
}
if (action.equals("deleteSnmpDetectType")) {//删除snmp监测项
return deleteSnmpDetectType();
}
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return null;
}
/**
*
* 查询snmp监测项信息查询条件+分页
* @author hyx Apr 6, 2012
* @version 1.0
* @return
*/
public String querySnmpDetectTypeInfo() {
try {
String hql = "from SortInfo where 1=1 ";
String sqlCondition = "where 1=1";// 将查询条件记录到操作日志中
if (sortNameForSearch != null && !"".equals(sortNameForSearch)) {
hql += " and Upper(sortName) like '%" + sortNameForSearch.toUpperCase() + "%'";
sqlCondition += " and Upper(sortName) like '%" + sortNameForSearch.toUpperCase() + "%'";
}
hql += "order by id";
page = this.commonService.findByPage(hql, pageNo,pageSize);
sortInfoList = (ArrayList<SortInfo>)page.getResult();
// 将查询请求记入到操作日志表中
this.addDBOperationRpt(commonService, sqlCondition,
"SortInfo");
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return "snmpDetectTypeList";
}
//进入新增页面
public String toAddSnmpDetectType() {
System.out.println(sortNameForSearch);
return null;
}
// 添加snmp监测项操作
public String addSnmpDetectType() {
try {
if(sortInfo!=null){
this.commonService.save(sortInfo);
// 将添加操作写到操作日志中
this.addDBOperationRpt(commonService, "SortInfo", "INSERT",sortInfo.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_SnmpDetectManageAction.addSnmpDetectType.success_n81i');this.location='snmpDetectManage.do?action=querySnmpDetectTypeInfo'</script>");
}
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_SnmpDetectManageAction.addSnmpDetectType.faild_n81i');this.location='snmpDetectManage.do?action=querySnmpDetectTypeInfo'</script>");
}
return null;
}
//进入修改页面
public String toUpdateSnmpDetectType() {
try {
if(ids!=null&&!"".equals(ids) ){
List list = this.commonService.find("from SortInfo where id=?", Long.valueOf(ids));
if(list!=null && list.size()>0){
sortInfo = (SortInfo)list.get(0);
}
}
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_SnmpDetectManageAction.addSnmpDetectType.faild_n81i');this.location='snmpDetectManage!execute.do?action=querySnmpDetectTypeInfo'</script>");
}
return null;
}
// 进行修改snmp监测项操作
public String updateSnmpDetectType() {
try {
SortInfo sortForUpdate = (SortInfo) commonService.get(SortInfo.class, sortInfo.getId());
sortForUpdate.setSortName(sortInfo.getSortName());
sortForUpdate.setSortDesc(sortInfo.getSortDesc());
this.commonService.update(sortForUpdate);
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "SortInfo", "UPDATE",sortForUpdate.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_SnmpDetectManageAction.addSnmpDetectType.success_n81i');this.location='snmpDetectManage.do?action=querySnmpDetectTypeInfo&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
return null;
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_SnmpDetectManageAction.addSnmpDetectType.faild_n81i');this.location='snmpDetectManage.do?action=querySnmpDetectTypeInfo&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
return null;
}
}
// 进行修改snmp监测项操作
public String detailSnmpDetectType() {
try {
String sortId = this.getRequest().getParameter("sortId");
sortInfo = (SortInfo) commonService.get(SortInfo.class, Long.valueOf(sortId));
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "SortInfo", "SELECT",sortInfo.getId());
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_SnmpDetectManageAction.addSnmpDetectType.faild_n81i');this.location='snmpDetectManage.do?action=querySnmpDetectTypeInfo'</script>");
}
return null;
}
//删除snmp监测项
public String deleteSnmpDetectType()throws Exception{
try {
if(ids!=null&&!"".equals(ids)) {
String hql = "DELETE FROM SortInfo WHERE ID IN ("+ ids + ")";
this.commonService.delete(hql);
}
// this.getRequest().setAttribute("MSG", 1);
// outHtmlString("<script type=\"text/javascript\">this.location='brandManage.do?action=queryBrandInfo'</script>");
} catch (Exception e) {
e.printStackTrace();
//outHtmlString("<script type=\"text/javascript\">alert('操作失败');this.location='checkTypeSet.do?action=query'</script>");
}
return this.querySnmpDetectTypeInfo();
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getIds()
{
return ids;
}
public void setIds(String ids)
{
this.ids = ids;
}
public List<SortInfo> getSortInfoList()
{
return sortInfoList;
}
public void setSortInfoList(List<SortInfo> sortInfoList)
{
this.sortInfoList = sortInfoList;
}
public SortInfo getSortInfo()
{
return sortInfo;
}
public void setSortInfo(SortInfo sortInfo)
{
this.sortInfo = sortInfo;
}
public String getSortNameForSearch()
{
return sortNameForSearch;
}
public void setSortNameForSearch(String sortNameForSearch)
{
this.sortNameForSearch = sortNameForSearch;
}
}

View File

@@ -0,0 +1,320 @@
package nis.nms.web.actions.sysManage;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import nis.nms.domains.SystemTable;
import nis.nms.domains.TroubleState;
import nis.nms.domains.XtYhJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.MD5;
import nis.nms.util.Page;
import org.apache.log4j.Logger;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import com.nms.servlet.auto.run.AutoGetTroubleCode;
@SuppressWarnings("unchecked")
@Results( {
@Result(name = "openAddErrorInfo", value = "/page/system/addErrorInfo.jsp"),
@Result(name = "queryErrorInfo", value = "/page/system/errorInfoList.jsp"),
@Result(name = "updateErrorInfo", value = "/page/system/updateErrorInfo.jsp")
})
public class SysErrorManageAction extends BaseAction {
/**
*
*/
private static final long serialVersionUID = 1L;
private Logger logger = Logger.getLogger(SysErrorManageAction.class);
private CommonService commonService;
private int pageNo = 1;
private int pageSize = this.getDefaultPageSize(); // 每页显示的记录条数
private Page page;
private String action;
private List allErrorInfo = new ArrayList();
private String erid;
private TroubleState troubleState;
private SystemTable systemTable;
private XtYhJbxx xtyhxx;
private List<SystemTable> sysList;
private String sysId;
@Override
public String executeAction() throws Exception{
String resultpage = "";
try {
this.getRequest().setAttribute("ADMFlag", this.getAdminMark());
if ("openAddError".equals(this.action)) {
querySystemInfo();
resultpage = "openAddErrorInfo";
}else
if ("addErrorInfo".equals(this.action)) {
addErrorInfo();
return null;
}else
if ("openUpdError".equals(this.action)) {
updateErrorInfo();
querySystemInfo();
resultpage = "updateErrorInfo";
}else
if("doUpdError".equals(this.action)){
doUpdate();
return null;
}else if("checkAjax".equals(this.action)){
checkAjax();
return null;
}else
if ("query".equals(this.action)) {
resultpage = queryErrorInfo();
}else{
resultpage = queryErrorInfo();
}
} catch (Exception e) {
e.printStackTrace();
}
return resultpage;
}
public void checkAjax(){
Long code = troubleState.getTroubleCode();
String sql = "select count(*) from trouble_state t where TROUBLE_CODE ="+code+" and SYSTEM_ID ="+this.getSystemID();
List list;
try {
list = this.commonService.executeSQL(sql);
if(list!=null && list.get(0)!=null){
int num = Integer.parseInt(list.get(0).toString());
if(num>0){
this.outString("error");
return ;
}
}
} catch (Exception e) {
e.printStackTrace();
this.outString("exception");
}
this.outString("success");
}
public void addErrorInfo() {
try {
// if(checkCode(troubleState.getTroubleCode())){
SystemTable sys = null;
if(this.getAdminMark()){//是
sys = (SystemTable) commonService.get(SystemTable.class, troubleState.getSystem().getSystemId());
}else{
sys = (SystemTable) commonService.get(SystemTable.class, this.getSystemID());
}
XtYhJbxx user = this.getUser();
troubleState.setCreateDate(new Date());
troubleState.setSystem(sys);
troubleState.setCreateUser(user);
troubleState.setState("0");
this.commonService.save(troubleState);
// 将添加操作写到操作日志中
this.addDBOperationRpt(commonService, "trouble_state", "INSERT",
troubleState.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_SysErrorManageAction.addErrorInfo.success_n81i');this.location='sysErrorManage!execute.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
/*}else{
this.outHtmlString("<script>alert('故障代码已存在,请重新输入!');history.back();</script>");
return;
}*/
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_SysErrorManageAction.addErrorInfo.faild_n81i');this.location='sysErrorManage!execute.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
}
}
//管理业务系统列表
public List<SystemTable> querySystemInfo(){
try{
sysList = this.getAllSystemInfo(this.commonService);
}catch (Exception e){
e.printStackTrace();
}
return sysList;
}
public boolean checkCode(Long code){
boolean checkResu = true;
try {
String sql = "select count(*) from trouble_state t where TROUBLE_CODE ="+code+" and SYSTEM_ID ="+this.getSystemID();
List list = this.commonService.executeSQL(sql);
if(list!=null && list.get(0)!=null){
int num = Integer.parseInt(list.get(0).toString());
if(num>0){
checkResu = false;
}
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return checkResu;
}
public String queryErrorInfo() {
try {
String sql = "from TroubleState where 1=1 ";
sql += "order by id";
page = this.commonService.findByPage(sql, pageNo, pageSize);
allErrorInfo = (List<TroubleState>) page.getResult();
} catch (Exception e) {
e.printStackTrace();
}
return "queryErrorInfo";
}
public void updateErrorInfo() {
try {
troubleState =(TroubleState) commonService.get(TroubleState.class, Long.parseLong(erid));
} catch (Exception e) {
e.printStackTrace();
}
}
public void doUpdate() {
try {
TroubleState md = (TroubleState) commonService.get(TroubleState.class, troubleState
.getId());
SystemTable sys = null;
if(this.getAdminMark()){//是
sys = (SystemTable) commonService.get(SystemTable.class, troubleState.getSystem().getSystemId());
}else{
sys = (SystemTable) commonService.get(SystemTable.class, Long.parseLong(sysId));
}
//SystemTable sys = (SystemTable) commonService.get(SystemTable.class, troubleState.getSystem().getSystemId());
XtYhJbxx user = (XtYhJbxx) commonService.get(XtYhJbxx.class, troubleState.getCreateUser().getYhid());
md.setSystem(sys);
md.setCreateUser(user);
md.setLastUpDate(new Date());
md.setLastUpUser(this.getUser());
md.setTroubleCode(troubleState.getTroubleCode());
md.setTroubleDescr(troubleState.getTroubleDescr());
md.setTroubleInfo(troubleState.getTroubleInfo());
md.setState(troubleState.getState());
this.commonService.update(md);
// 将更新操作写到操作日志中
this.addDBOperationRpt(commonService, "Trouble_State", "UPDATE",
troubleState.getId());
outHtmlString("<script type=\"text/javascript\">alert('i18n_SysErrorManageAction.addErrorInfo.success_n81i');this.location='sysErrorManage!execute.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
} catch (Exception e) {
e.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_SysErrorManageAction.addErrorInfo.faild_n81i');this.location='sysErrorManage!execute.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
}
}
public Logger getLogger() {
return logger;
}
public void setLogger(Logger logger) {
this.logger = logger;
}
public List getAllErrorInfo() {
return allErrorInfo;
}
public void setAllErrorInfo(List allErrorInfo) {
this.allErrorInfo = allErrorInfo;
}
public String getErid() {
return erid;
}
public void setErid(String erid) {
this.erid = erid;
}
public TroubleState getTroubleState() {
return troubleState;
}
public void setTroubleState(TroubleState troubleState) {
this.troubleState = troubleState;
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public SystemTable getSystemTable() {
return systemTable;
}
public void setSystemTable(SystemTable systemTable) {
this.systemTable = systemTable;
}
public XtYhJbxx getXtyhxx() {
return xtyhxx;
}
public void setXtyhxx(XtYhJbxx xtyhxx) {
this.xtyhxx = xtyhxx;
}
public List<SystemTable> getSysList() {
return sysList;
}
public void setSysList(List<SystemTable> sysList) {
this.sysList = sysList;
}
public String getSysId() {
return sysId;
}
public void setSysId(String sysId) {
this.sysId = sysId;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,342 @@
package nis.nms.web.actions.sysManage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import nis.nms.core.Resource;
import nis.nms.domains.DetectionSetInfo;
import nis.nms.domains.NodeTable;
import nis.nms.domains.NodegroupTable;
import nis.nms.domains.SystemTable;
import nis.nms.domains.TopoInfo;
import nis.nms.domains.TopoManageInfo;
import nis.nms.domains.TopoNodeInfo;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
@SuppressWarnings("unchecked")
@Results( {
@Result(name="topoManageIndex", value = "/page/systemManage/topoManage/topoManageIndex.jsp"),
@Result(name="error", value = "/error.jsp")
})
public class TopoManageAction extends BaseAction{
private Logger logger=Logger.getLogger(this.getClass());
private String action;
private CommonService commonService;
private List<TopoInfo> topoInfoList;
private List<TopoInfo> allTopoInfoList;
private List<SystemTable> sysList;
private List<TopoNodeInfo> topoNodeList;
private List<Integer> typeList;
private NodegroupTable nodegroupTable;
private NodeTable nodeTable;
private Long systemId;
private Long topoInfoId;
private Long topoNodeId;
private Long topoNodeType;
private String groupIdShow; //节点组名称
private Long selectTopoInfoId; //节点类型为topo时 选择的topoId
private DetectionSetInfo detectionSetInfo;
private TopoNodeInfo topoNodeInfo;
private TopoManageInfo topoManageInfo;
private List<TopoManageInfo> topoManageInfos;
@Override
public String executeAction() throws Exception {
String result=null;
try {
if(action.equals("query")) {
result=queryTopoManageIndex();
}else if(action.equals("modify")){
modifyTopoManage();
}
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return result;
}
public String queryTopoManageIndex(){
try {
//查询所有业务系统列表
sysList = this.commonService.find("from SystemTable where 1=1");
//查询所有topo图列表
allTopoInfoList=this.commonService.find("from TopoInfo where 1=1");
//节点设置的几个状态属性
//1.节点 2.节点组 3.无任何操作 4.topo图
typeList=new ArrayList<Integer>(){{add(1);add(2);add(4);add(3);}};
//查询当前业务系统topo图列表
if(systemId==null){
systemId=sysList.get(0).getSystemId();
}
topoInfoList=this.commonService.find("from TopoInfo where 1=1 and systemId=?",systemId);
//查询所有节点内容
if(topoInfoList!=null&&topoInfoList.size()>0){
//判断用户选择的拓扑图是否为当前系统的拓扑图
boolean flag=true;
if(topoInfoId==null){
topoInfoId=topoInfoList.get(0).getId();
}else{
flag=topoInfoId.equals(topoInfoList.get(0).getId());
}
if(flag){
topoNodeList=this.commonService.find("from TopoNodeInfo where 1=1 and topoInfo.id=?",topoInfoId);
if(topoNodeList!=null&&topoNodeList.size()>0){
topoManageInfos=new ArrayList<TopoManageInfo>();
for (TopoNodeInfo topoInfo : topoNodeList) {
topoManageInfo=new TopoManageInfo();
topoManageInfo.setTopoNodeInfo(topoInfo);
if(topoInfo.getType()==1L){
List nodeTables = this.commonService.find("from NodeTable where 1=1 and id=?",topoInfo.getTypeId());
nodeTable = (NodeTable)nodeTables.get(0);
List find = this.commonService.find("from NodegroupTable where 1=1 and id=?",nodeTable.getGroupId());
nodegroupTable = (NodegroupTable) find.get(0);
topoManageInfo.setNodeGroupName(nodegroupTable.getGroupName());
topoManageInfo.setNodeGroupId(nodeTable.getGroupId());
topoManageInfo.setNodeId(nodeTable.getNodeId());
topoManageInfo.setNodeName(nodeTable.getNodeIp());
}else if(topoInfo.getType()==2L){
List find = this.commonService.find("from NodegroupTable where 1=1 and id=?",topoInfo.getTypeId());
nodegroupTable = (NodegroupTable) find.get(0);
topoManageInfo.setNodeGroupName(nodegroupTable.getGroupName());
topoManageInfo.setNodeGroupId(nodegroupTable.getGroupId());
}else if(topoInfo.getType()==4L){
topoManageInfo.setTopoInfoId(topoInfo.getTypeId());
}
topoManageInfos.add(topoManageInfo);
}
}
}else{
topoNodeList=this.commonService.find("from TopoNodeInfo where 1=1 and topoInfo.id=?",topoInfoId);
if(topoNodeList!=null&&topoNodeList.size()>0){
topoManageInfos=new ArrayList<TopoManageInfo>();
for (TopoNodeInfo topoInfo : topoNodeList) {
topoManageInfo=new TopoManageInfo();
topoInfo.setType(3L);
topoInfo.setTypeId(null);
topoManageInfo.setTopoNodeInfo(topoInfo);
topoManageInfos.add(topoManageInfo);
}
}
}
}else if(topoInfoId!=null){
topoNodeList=this.commonService.find("from TopoNodeInfo where 1=1 and topoInfo.id=?",topoInfoId);
if(topoNodeList!=null&&topoNodeList.size()>0){
topoManageInfos=new ArrayList<TopoManageInfo>();
for (TopoNodeInfo topoInfo : topoNodeList) {
topoManageInfo=new TopoManageInfo();
topoInfo.setType(3L);
topoInfo.setTypeId(null);
topoManageInfo.setTopoNodeInfo(topoInfo);
topoManageInfos.add(topoManageInfo);
}
}
}
} catch (Exception e) {
logger.error(e.getStackTrace());
e.printStackTrace();
return null;
}
return "topoManageIndex";
}
public void modifyTopoManage(){
String parameter = this.getRequest().getParameter("datas");
JSONArray fromObject = JSONArray.fromObject(parameter);
List<TopoManageInfo> results = (List) JSONArray.toCollection(fromObject, TopoManageInfo.class);
try {
TopoInfo topoInfo = (TopoInfo) this.commonService.get(TopoInfo.class, topoInfoId);
if(!topoInfo.getSystemId().equals(systemId)){
//将之前的topotu指向业务系统设为null
List<TopoInfo> find = this.commonService.find("from TopoInfo where 1=1 and systemId=?", systemId);
if(find!=null&&find.size()>0){
TopoInfo topoInfo2 = find.get(0);
topoInfo2.setSystemId(null);
this.commonService.update(topoInfo2);
}
//判断当前修改拓扑图是否为当前系统所有拓扑图 如果当前系统拓扑图发生改变 修改topoInfo中指向新业务系统
topoInfo.setSystemId(systemId);
this.commonService.update(topoInfo);
}
for (TopoManageInfo data : results) {
List find = this.commonService.find("from TopoNodeInfo where id=?", data.getNodeId());
TopoNodeInfo topoNodeInfo = (TopoNodeInfo) find.get(0);
topoNodeInfo.setType(data.getNodeType());
topoNodeInfo.setTypeId(data.getNodeTypeId());
this.commonService.update(topoNodeInfo);
}
}catch (Exception e) {
try {
this.getResponse().sendError(500);
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public List<TopoInfo> getTopoInfoList() {
return topoInfoList;
}
public void setTopoInfoList(List<TopoInfo> topoInfoList) {
this.topoInfoList = topoInfoList;
}
public List<SystemTable> getSysList() {
return sysList;
}
public void setSysList(List<SystemTable> sysList) {
this.sysList = sysList;
}
public List<TopoNodeInfo> getTopoNodeList() {
return topoNodeList;
}
public void setTopoNodeList(List<TopoNodeInfo> topoNodeList) {
this.topoNodeList = topoNodeList;
}
public List<Integer> getTypeList() {
return typeList;
}
public void setTypeList(List<Integer> typeList) {
this.typeList = typeList;
}
public NodegroupTable getNodegroupTable() {
return nodegroupTable;
}
public void setNodegroupTable(NodegroupTable nodegroupTable) {
this.nodegroupTable = nodegroupTable;
}
public NodeTable getNodeTable() {
return nodeTable;
}
public void setNodeTable(NodeTable nodeTable) {
this.nodeTable = nodeTable;
}
public Long getSystemId() {
return systemId;
}
public void setSystemId(Long systemId) {
this.systemId = systemId;
}
public Long getTopoInfoId() {
return topoInfoId;
}
public void setTopoInfoId(Long topoInfoId) {
this.topoInfoId = topoInfoId;
}
public Long getTopoNodeId() {
return topoNodeId;
}
public void setTopoNodeId(Long topoNodeId) {
this.topoNodeId = topoNodeId;
}
public Long getTopoNodeType() {
return topoNodeType;
}
public void setTopoNodeType(Long topoNodeType) {
this.topoNodeType = topoNodeType;
}
public String getGroupIdShow() {
return groupIdShow;
}
public void setGroupIdShow(String groupIdShow) {
this.groupIdShow = groupIdShow;
}
public DetectionSetInfo getDetectionSetInfo() {
return detectionSetInfo;
}
public void setDetectionSetInfo(DetectionSetInfo detectionSetInfo) {
this.detectionSetInfo = detectionSetInfo;
}
public List<TopoInfo> getAllTopoInfoList() {
return allTopoInfoList;
}
public void setAllTopoInfoList(List<TopoInfo> allTopoInfoList) {
this.allTopoInfoList = allTopoInfoList;
}
public Long getSelectTopoInfoId() {
return selectTopoInfoId;
}
public void setSelectTopoInfoId(Long selectTopoInfoId) {
this.selectTopoInfoId = selectTopoInfoId;
}
public TopoNodeInfo getTopoNodeInfo() {
return topoNodeInfo;
}
public void setTopoNodeInfo(TopoNodeInfo topoNodeInfo) {
this.topoNodeInfo = topoNodeInfo;
}
public TopoManageInfo getTopoManageInfo() {
return topoManageInfo;
}
public void setTopoManageInfo(TopoManageInfo topoManageInfo) {
this.topoManageInfo = topoManageInfo;
}
public List<TopoManageInfo> getTopoManageInfos() {
return topoManageInfos;
}
public void setTopoManageInfos(List<TopoManageInfo> topoManageInfos) {
this.topoManageInfos = topoManageInfos;
}
}

View File

@@ -0,0 +1,787 @@
package nis.nms.web.actions.sysManage;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import nis.nms.core.Resource;
import nis.nms.domains.GorupSystemTable;
import nis.nms.domains.SystemTable;
import nis.nms.domains.XtJsJbxx;
import nis.nms.service.CommonService;
import nis.nms.util.BaseAction;
import nis.nms.util.Constant;
import nis.nms.util.ExportUtils;
import nis.nms.util.Page;
@SuppressWarnings("unchecked")
@Results( {
@Result(name = "ok", value = "/page/system/usergroup/giveGrouppermission/geivegroupperm.jsp"),
@Result(name = "viewdate", value = "/page/system/usergroup/giveGrouppermission/viewgrouppermission.jsp"),
@Result(name = "viewdateForGuide", value = "/page/system/usergroup/giveGrouppermission/viewgrouppermissionForGuide.jsp"),
@Result(name = "groupList", value = "/page/system/usergroup/giveGrouppermission/groupInfoList.jsp"),
@Result(name = "showError", value = "/showImportError.jsp"),
@Result(name = "addgroupinfo", value = "/page/system/usergroup/giveGrouppermission/addgroupinfo.jsp")
})
public class UserGroupPerssionAction extends BaseAction {
private Logger logger = Logger.getLogger(UserGroupPerssionAction.class);
public List<Resource> listresources;
private Page page;
private XtJsJbxx role;// 保存用户组信息
private List allMkInfo = new ArrayList();// 保存所有系统信息
private String mkid;// 系统id
private XtJsJbxx userGroup;// 用户组信息
private List listJsInfo = new ArrayList();// 用户组列表信息页面
private List allJsInfo = new ArrayList();// 查询用户组信息
private int pageNo = 1;
private int pageSize = this.getDefaultPageSize(); // 每页显示的记录条数
private String jsmc;// 角色名称
private String jsbh;// 角色编号
public List<XtJsJbxx> groupList;
public String action = "";
private String fromWhere;
private String isComplete;
private static final long serialVersionUID = 1L;
private CommonService commonService;
// 导入节点文件
private File myFile;
private String myFileFileName;
public File getMyFile() {
return myFile;
}
public void setMyFile(File myFile) {
this.myFile = myFile;
}
public String getMyFileFileName() {
return myFileFileName;
}
public void setMyFileFileName(String myFileFileName) {
this.myFileFileName = myFileFileName;
}
public CommonService getCommonService() {
return commonService;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public UserGroupPerssionAction() {
// TODO Auto-generated constructor stub
}
public String executeAction() throws Exception {
String resultpage = "";
this.getRequest().setAttribute("fromWhere", fromWhere);
if ("toupdate".equals(this.action)) {
queryGroupByid();
resultpage = preSentGroupPerssion();
}
if ("viewdate".equals(this.action)) {
queryGroupByid();
resultpage = preSentGroupPerssion();
}
if ("viewdateForGuide".equals(this.action)) {
queryGroupByid();
resultpage = preSentGroupPerssion();
}
if ("query".equals(this.action)) {
resultpage = getGroupInfoList();
}
if ("update".equals(this.action)) {
giveGroupPerssions();
return "ok";
}
if ("addgroupInfo".equals(this.action)) {
addgroupInfo();
return null;
}
if ("openAddgroupPage".equals(this.action)) {
this.getRequest().setAttribute("fromWhere", fromWhere);
return this.queryMk();
}
if ("downloadExample".equals(this.action)) {
resultpage = downloadExample();
}
if ("importXls".equals(this.action)) {
resultpage = importXls();
}
if ("emportCurrentXls".equals(this.action)) {
resultpage = emportCurrentXls();
}
if ("emportAllXls".equals(this.action)) {
resultpage = emportAllXls();
}
if("AjaxCheck".equals(this.action)){
ajaxCheck();
return null;
}
if("checkUpdate".equals(this.action)){
checkUpdate();
return null;
}
return resultpage;
}
// 模板下载 程辉 2013-5-13新增
public String downloadExample() {
try {
String sql = "select xjj.jsmc,xjj.jsms,st.system_name from xt_js_jbxx xjj join gorup_system_table gst on xjj.jsbh=gst.user_group_id"+
" join system_table st on gst.system_id=st.system_id ";
// + "where rownum<4 order by xjj.jsmc";
//@2018年4月10日18:45:00 fang 修改rownum 适配 mysql
if(Constant.IS_MYSQL){
sql = sql + " order by xjj.jsmc limit 3";
}else{
sql = sql + " where rownum<4 order by xjj.jsmc";
}
List st= this.commonService.executeSQL(sql);
String[] title = { getI18nText("i18n_UserGroupPerssionAction.downloadExample.title.userGroup_n81i"),
getI18nText("i18n_UserGroupPerssionAction.downloadExample.title.userGroupDesc_n81i"),
getI18nText("i18n_UserGroupPerssionAction.downloadExample.title.system_n81i") };
String[] colu = { "0", "1","2" };
ExportUtils m = new ExportUtils();
m.setAutoSizeColumn(true);
m.exportExcel(getI18nText("i18n_UserGroupPerssionAction.downloadExample.usergroupTable_n81i"), st, title, colu,"downloadExample");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
// 导入 程辉 2013-5-8新增
public String importXls() {
String errorInfo = "";
try {
List<String> headerList = new ArrayList<String>();
List<List<String>> rowList = new ArrayList<List<String>>();
Workbook workbook = null;
if (myFileFileName.endsWith(".xlsx")) {
workbook = new XSSFWorkbook(new FileInputStream(myFile));
} else {
// 创建对Excel工作簿文件的引用
workbook = new HSSFWorkbook(new FileInputStream(myFile));
}
// 创建对工作表的引用,得到表的第一页
Sheet sheet = workbook.getSheetAt(0);
// 读取左上端单元
// 记录存储数据条数
int count = 0;
// 记录读入excel数据条数
int sum = (sheet.getLastRowNum());
for (short i = 1; i <= sheet.getLastRowNum(); i++) {
String JSMC ="";
String JSMS ="";
String SYSTEMNAME ="";
List<String> errorList = new ArrayList<String>();
Row row = sheet.getRow(i);
Cell cell_1 = row.getCell((short) 0);
Cell cell_2 = row.getCell((short) 1);
Cell cell_3 = row.getCell((short) 2);
if ((null == cell_1 || 3 == cell_1.getCellType())
&& (null == cell_2 || 3 == cell_2.getCellType())
&& (null == cell_3 || 3 == cell_3.getCellType())) {
sum--;
}else {
// 用户组名称
if (null == cell_1) {
errorInfo += getI18nText("i18n_UserGroupPerssionAction.downloadExample.errorInfo1_n81i",i+"");
} else if (cell_1.getCellType() == Cell.CELL_TYPE_STRING) {
if ("".equals(cell_1.getStringCellValue())) {
errorInfo += i +getI18nText("i18n_UserGroupPerssionAction.downloadExample.errorInfo1_n81i",i+"");
} else {
JSMC = cell_1.getStringCellValue().trim();
}
} else {
errorInfo += getI18nText("i18n_UserGroupPerssionAction.downloadExample.errorInfo2_n81i",i+"");
}
// 用户组描述
if (null == cell_2) {
} else if (cell_2.getCellType() == Cell.CELL_TYPE_STRING) {
if ("".equals(cell_2.getStringCellValue())) {
} else {
JSMS = cell_2.getStringCellValue()
.trim();
if(JSMS.length()>100){
errorInfo += getI18nText("i18n_UserGroupPerssionAction.downloadExample.errorInfo3_n81i",i+"");
}
}
}
// 可访问系统
if(null == cell_3){
errorInfo += getI18nText("i18n_UserGroupPerssionAction.downloadExample.errorInfo4_n81i",i+"");
}else if (cell_3.getCellType() == Cell.CELL_TYPE_STRING) {
if ("".equals(cell_3.getStringCellValue())) {
errorInfo += getI18nText("i18n_UserGroupPerssionAction.downloadExample.errorInfo4_n81i",i+"");
} else {
SYSTEMNAME = cell_3.getStringCellValue().trim();
}
} else {
errorInfo += getI18nText("i18n_UserGroupPerssionAction.downloadExample.errorInfo5_n81i",i+"");
}
if ("".equals(errorInfo)) {// 保存节点
errorInfo = this.saveNode(JSMC,JSMS,SYSTEMNAME);
}
if ("".equals(errorInfo)) {
count++;
} else {
errorList.add(JSMC);
errorList.add(JSMS);
errorList.add(SYSTEMNAME);
errorList.add(errorInfo);
rowList.add(errorList);
errorInfo = "";
}
}
}
headerList.add(getI18nText("i18n_UserGroupPerssionAction.downloadExample.usergroupName_n81i"));
headerList.add(getI18nText("i18n_UserGroupPerssionAction.downloadExample.usergroupDesc_n81i"));
headerList.add(getI18nText("i18n_UserGroupPerssionAction.downloadExample.system_n81i"));
headerList.add(getI18nText("i18n_UserGroupPerssionAction.downloadExample.errorInfo_n81i"));
this.getRequest().setAttribute("rowList", rowList);
this.getRequest().setAttribute("headerList", headerList);
if (count == sum && sum > 0) {
outHtmlString("<script type=\"text/javascript\">alert('i18n_UserGroupPerssionAction.downloadExample.success_n81i');this.location='userGroupPerssion.do?action=query'</script>");
return null;
// this.getRequest().setAttribute("MSG", 1);
// return this.getGroupInfoList();
} else if (sum == 0) {
this
.outHtmlString("<script>alert('i18n_UserGroupPerssionAction.downloadExample.selectFileIsNull_n81i');history.back();</script>");
return null;
}
} catch (Exception e) {
e.printStackTrace();
}
return "showError";
}
private String saveNode(String JSMC,String JSMS,String SYSTEMNAME) {
String desc = "";
XtJsJbxx xtJsJbxx = new XtJsJbxx();
String operate="save";
try {
// 保存节点信息
xtJsJbxx.setCtime(new Date());
xtJsJbxx.setJsmc(JSMC);
xtJsJbxx.setJsms(JSMS);
xtJsJbxx.setType(1L);
xtJsJbxx.setZxbz("0");
//判断用户组名称是否已存在
List<XtJsJbxx> JSMCList = this.commonService.find(
"from XtJsJbxx where JSMC=?", xtJsJbxx.getJsmc());
if (JSMCList != null && JSMCList.size() > 0) {
xtJsJbxx = JSMCList.get(0);
operate="update";
}
//判断可访问系统是否存在
List SYSTEMNAMEList = this.commonService.find(
"select st.systemId from SystemTable st where st.systemName=?", SYSTEMNAME);
if (null==SYSTEMNAMEList || SYSTEMNAMEList.size() == 0) {
return getI18nText("i18n_UserGroupPerssionAction.downloadExample.systemIsNull_n81i");
}
String SYSTEMID = SYSTEMNAMEList.get(0).toString();
if(operate.equals("save")){
this.commonService.save(xtJsJbxx);
}
//判断当前用户组是否具有当前可访问系统权限 如有 不可重复添加
List quanxianList = this.commonService.find(
"from GorupSystemTable where systemId=? and userGroupId=?", Long.parseLong(SYSTEMID),xtJsJbxx.getJsbh());
if (quanxianList != null && quanxianList.size() > 0) {
return getI18nText("i18n_UserGroupPerssionAction.downloadExample.hasPermission_n81i");
}
GorupSystemTable gorupSystemTable = new GorupSystemTable();
gorupSystemTable.setSystemId(Long.parseLong(SYSTEMID));
gorupSystemTable.setUserGroupId(xtJsJbxx.getJsbh());
this.commonService.save(gorupSystemTable);
} catch (Exception e) {
e.printStackTrace();
desc = getI18nText("i18n_UserGroupPerssionAction.downloadExample.nodeInfoImportErr_n81i");
}
return desc;
}
// 当前页导出 程辉 2013-5-8新增
public String emportCurrentXls() {
try {
String sql = "from XtJsJbxx where 1=1 and type=1";
String sqlCondition = "where zxbz<>2";// 将查询条件记录到操作日志中
if (jsmc != null && !"".equals(jsmc)) {
sql += " and jsmc like '%" + jsmc + "%'";
sqlCondition += " and jsmc = '" + jsmc + "'";
}
sql += " order by ctime desc";
page = this.commonService.findByPage(sql, pageNo, pageSize);
List<XtJsJbxx> allJsInfo = (List<XtJsJbxx>) page.getResult();
for (int i = 0; i < allJsInfo.size(); i++) {
if(allJsInfo.get(i).getZxbz().equals("0")){
allJsInfo.get(i).setZxbz(getI18nText("i18n_UserGroupPerssionAction.downloadExample.valid_n81i"));
}
if(allJsInfo.get(i).getZxbz().equals("1")){
allJsInfo.get(i).setZxbz(getI18nText("i18n_UserGroupPerssionAction.downloadExample.invalid_n81i"));
}
}
String[] title = { getI18nText("i18n_UserGroupPerssionAction.downloadExample.usergroupName_n81i"),
getI18nText("i18n_UserGroupPerssionAction.downloadExample.usergroupDesc_n81i"),
getI18nText("i18n_UserGroupPerssionAction.downloadExample.state_n81i") };
String[] colu = { "jsmc", "jsms","zxbz" };
String url = "userGroupPerssion.do?action=query&jsmc="+jsmc+"&pageSize="+pageSize+"&pageNo="+pageNo;
ExportUtils m = new ExportUtils();
m.setAutoSizeColumn(true);
m.exportExcel(url,getI18nText("i18n_UserGroupPerssionAction.downloadExample.usergroupTable_n81i"), allJsInfo, title, colu);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
// 导出全部 程辉 2013-5-8新增
public String emportAllXls() {
try {
String sql = "from XtJsJbxx where 1=1 and type=1";
String sqlCondition = "where zxbz<>2";// 将查询条件记录到操作日志中
if (jsmc != null && !"".equals(jsmc)) {
sql += " and jsmc like '%" + jsmc + "%'";
sqlCondition += " and jsmc = '" + jsmc + "'";
}
sql += " order by ctime desc";
List<XtJsJbxx> allJsInfo = this.commonService.find(sql);
for (int i = 0; i < allJsInfo.size(); i++) {
if(allJsInfo.get(i).getZxbz().equals("0")){
allJsInfo.get(i).setZxbz(getI18nText("i18n_UserGroupPerssionAction.downloadExample.valid_n81i"));
}
if(allJsInfo.get(i).getZxbz().equals("1")){
allJsInfo.get(i).setZxbz(getI18nText("i18n_UserGroupPerssionAction.downloadExample.invalid_n81i"));
}
}
String[] title = { getI18nText("i18n_UserGroupPerssionAction.downloadExample.usergroupName_n81i"),
getI18nText("i18n_UserGroupPerssionAction.downloadExample.usergroupDesc_n81i"),
getI18nText("i18n_UserGroupPerssionAction.downloadExample.state_n81i") };
String[] colu = { "jsmc", "jsms","zxbz" };
String url = "userGroupPerssion.do?action=query&jsmc="+jsmc+"&pageSize="+pageSize+"&pageNo="+pageNo;
ExportUtils m = new ExportUtils();
m.setAutoSizeColumn(true);
m.exportExcel(url,getI18nText("i18n_UserGroupPerssionAction.downloadExample.usergroupTable_n81i"), allJsInfo, title, colu);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public void ajaxCheck(){
List list;
try {
list = this.commonService.find("from XtJsJbxx where type=1 and jsmc=?", role.getJsmc());
if(list!=null && list.size()>0){
this.outString("error");
return;
}
} catch (Exception e) {
e.printStackTrace();
logger.info("添加用户组配置校验失败", e);
this.outString("exception");
}
this.outString("success");
}
// 新增用户组信息
public void addgroupInfo() {
try {
/*List list = this.commonService.find("from XtJsJbxx where type=1 and jsmc=?", role.getJsmc());
if(list!=null && list.size()>0){
this.outHtmlString("<script>alert('用户组已存在,请重新输入!');history.back();</script>");
return;
}*/
role.setZxbz("0");
role.setType(1l);
role.setCtime(new Date());
this.commonService.save(role);
// 将添加操作写到操作日志中
this.addDBOperationRpt(commonService, "XT_JS_JBXX", "INSERT", role
.getJsbh());
String[] sMk = mkid.split(",");
if (sMk != null) {
for (int i = 0; i < sMk.length; i++) {
GorupSystemTable groupsystemtable = new GorupSystemTable();
groupsystemtable.setUserGroupId(role.getJsbh());
groupsystemtable.setSystemId(Long.parseLong(sMk[i].trim()));
this.commonService.save(groupsystemtable);
}
this.getRequest().setAttribute("MSG", 1);
}
//记录用户操作用于设置向导
if(fromWhere!=null && !"".equals(fromWhere)){
if(fromWhere.equals("formGuide")){
outHtmlString("<script type=\"text/javascript\">alert('i18n_UserGroupPerssionAction.downloadExample.success_n81i');this.location='userGroupPerssion.do?action=query&isComplete=0'</script>");
}
}else{
outHtmlString("<script type=\"text/javascript\">alert('i18n_UserGroupPerssionAction.downloadExample.success_n81i');this.location='userGroupPerssion.do?action=query'</script>");
}
} catch (Exception e) {
outHtmlString("<script type=\"text/javascript\">alert('i18n_UserGroupPerssionAction.giveGroupPerssions.faild_n81i');this.location='userGroupPerssion.do?action=query'</script>");
this.getRequest().setAttribute("MSG", 2);
e.printStackTrace();
}
}
// 查询系统信息
public String queryMk() {
try {
List treeList = new ArrayList();
List<SystemTable> menuList = this.commonService
.find("from SystemTable where systemState='0' ");
for (int i = 0; i < menuList.size(); i++) {
Resource resource = new Resource();
resource.setParRsCode("0");
resource.setRsCode(menuList.get(i).getSystemId().toString());
resource.setRsid(menuList.get(i).getSystemId().toString());
resource.setRsname(menuList.get(i).getSystemName().toString());
treeList.add(resource);
}
this.getRequest().setAttribute("treeList", treeList);
String sqlCondition = "where systemState=0";// 将查询条件记录到操作日志中
// 将查询请求记入到操作日志表中
this.addDBOperationRpt(commonService, sqlCondition, "system_table");
} catch (Exception e) {
e.printStackTrace();
}
return "addgroupinfo";
}
// 根据角色编号查询角色信息
public void queryGroupByid() {
try {
listJsInfo = this.commonService.find(
"from XtJsJbxx where type=1 and jsbh=?", Long
.parseLong(jsbh));
String sqlCondition = "where jsbh=" + jsbh;// 将查询条件记录到操作日志中
// 将查询请求记入到操作日志表中
this.addDBOperationRpt(commonService, sqlCondition, "xt_js_jbxx");
} catch (Exception e) {
e.printStackTrace();
}
}
// 根据条件查询用户组
public String getGroupInfoList() {
try {
String sql = "from XtJsJbxx where 1=1 and type=1";
String sqlCondition = "where zxbz<>2";// 将查询条件记录到操作日志中
if (jsmc != null && !"".equals(jsmc)) {
sql += " and Upper(jsmc) like '%" + jsmc.toUpperCase() + "%'";
sqlCondition += " and jsmc = '" + jsmc + "'";
}
sql += " order by ctime desc";
page = this.commonService.findByPage(sql, pageNo, pageSize);
allJsInfo = (List<XtJsJbxx>) page.getResult();
// 将查询请求记入到操作日志表中
this.addDBOperationRpt(commonService, sqlCondition, "xt_js_jbxx");
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return "groupList";
}
/*// 根据条件查询用户组
public String getGroupInfoList() {
try {
String sql = "select xjj.JSBH , xjj.JSMC , xjj.JSMS , xjj.ZXBZ , xjj.CTIME , xjj.type from XT_JS_JBXX xjj left join gorup_system_table gst on gst.user_Group_Id = xjj.JSBH where 1=1 ";
String sqlCondition = "where zxbz<>2";// 将查询条件记录到操作日志中
if (jsmc != null && !"".equals(jsmc)) {
sql += " and jsmc like '%" + jsmc + "%'";
sqlCondition += " and jsmc = '" + jsmc + "'";
}
sql += " and xjj.type=1 and gst.system_id= "+getSystemID();
sql += " order by jsbh";
page = this.commonService.findByPageForSql(sql, pageNo, pageSize, XtJsJbxx.class);
allJsInfo = (List<XtJsJbxx>) page.getResult();
// 将查询请求记入到操作日志表中
this.addDBOperationRpt(commonService, sqlCondition, "xt_js_jbxx");
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return "groupList";
}*/
// 跳转到给用户组分配权限
public String preSentGroupPerssion() {
try {
listresources = new ArrayList<Resource>();
List<SystemTable> listsystem = this.commonService.findByProperty(SystemTable.class, "systemState", "0");
// 查询和角色关联的nms系统并选中
List<GorupSystemTable> usergrouplist = null;
if (!"".equals(jsbh)) {
usergrouplist = this.commonService.findByProperty(
GorupSystemTable.class, "userGroupId", Long
.valueOf(jsbh));
}
// 查询用户组下面的nms系统
for (SystemTable systable : listsystem) {
Resource re = new Resource();
// 如果本用户组有这个权限将其选中
for (GorupSystemTable grouprefsys : usergrouplist) {
if (systable.getSystemId()
.equals(grouprefsys.getSystemId())) {
re.setChecked("checked");
}
}
re.setRsid(systable.getSystemId().toString().trim());
re.setRsname(systable.getSystemName());
re.setRsdesc(systable.getSystemDesc());
// 系统的父id设为0
re.setParRsCode("0");
re.setRsCode(systable.getSystemId().toString());
listresources.add(re);// 添加系统结束
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if("viewdate".equals(this.action)){
return "viewdate";
}else if("viewdateForGuide".equals(this.action)){
return "viewdateForGuide";
}
return "ok";
}
public void checkUpdate(){
List list;
try {
list = this.commonService.find("from XtJsJbxx where type=1 and jsbh<>? and jsmc=?", role.getJsbh(), role.getJsmc());
if(list!=null && list.size()>0){
this.outString("error");
return;
}
} catch (Exception e) {
e.printStackTrace();
logger.info("修改用户组校验异常", e);
this.outString("exception");
}
this.outString("success");
}
// 给用户组分配权限
public void giveGroupPerssions() {
// nms系统id
String[] nmsSys = mkid.split(",");
// 先删除跟这个用户组关联的所以nms系统
try {
commonService.beginTransaction();
/*List list = this.commonService.find("from XtJsJbxx where type=1 and jsbh<>? and jsmc=?", role.getJsbh(), role.getJsmc());
if(list!=null && list.size()>0){
this.outHtmlString("<script>alert('用户组已存在,请重新输入!');history.back();</script>");
return;
}*/
//保存用户组信息
XtJsJbxx group = (XtJsJbxx) this.commonService.get(XtJsJbxx.class, role.getJsbh());
if(role!=null&&!"".equals(role.getJsmc())){
group.setJsmc(role.getJsmc());
}
if(role!=null){
group.setJsms(role.getJsms());
}
if(role!=null&&!"".equals(role.getZxbz())){
group.setZxbz(role.getZxbz());
}
//保存用户组信息修改
this.commonService.update(group);
this.commonService.delete(GorupSystemTable.class, "userGroupId", userGroup.getJsbh());
for (String systemId : nmsSys) {
GorupSystemTable groupys = new GorupSystemTable();
if (systemId != null && !"".equals(systemId)) {
groupys.setSystemId(Long.valueOf(systemId.trim()));
}
groupys.setUserGroupId(userGroup.getJsbh());
this.commonService.save(groupys);
}
commonService.commit();
outHtmlString("<script type=\"text/javascript\">alert('i18n_UserGroupPerssionAction.downloadExample.success_n81i');this.location='userGroupPerssion.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
} catch (Exception e1) {
commonService.rollback();
e1.printStackTrace();
outHtmlString("<script type=\"text/javascript\">alert('i18n_UserGroupPerssionAction.giveGroupPerssions.faild_n81i');this.location='userGroupPerssion.do?action=query&pageNo="+pageNo+"&pageSize="+pageSize+"'</script>");
}
}
public List<Resource> getListresources() {
return listresources;
}
public void setListresources(List<Resource> listresources) {
this.listresources = listresources;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public List<XtJsJbxx> getGroupList() {
return groupList;
}
public void setGroupList(List<XtJsJbxx> groupList) {
this.groupList = groupList;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public List getAllJsInfo() {
return allJsInfo;
}
public void setAllJsInfo(List allJsInfo) {
this.allJsInfo = allJsInfo;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public String getJsmc() {
return jsmc;
}
public void setJsmc(String jsmc) {
this.jsmc = jsmc;
}
public List getListJsInfo() {
return listJsInfo;
}
public void setListJsInfo(List listJsInfo) {
this.listJsInfo = listJsInfo;
}
public String getJsbh() {
return jsbh;
}
public void setJsbh(String jsbh) {
this.jsbh = jsbh;
}
public String getMkid() {
return mkid;
}
public void setMkid(String mkid) {
this.mkid = mkid;
}
public XtJsJbxx getUserGroup() {
return userGroup;
}
public void setUserGroup(XtJsJbxx userGroup) {
this.userGroup = userGroup;
}
public List getAllMkInfo() {
return allMkInfo;
}
public void setAllMkInfo(List allMkInfo) {
this.allMkInfo = allMkInfo;
}
public XtJsJbxx getRole() {
return role;
}
public void setRole(XtJsJbxx role) {
this.role = role;
}
public String getFromWhere() {
return fromWhere;
}
public void setFromWhere(String fromWhere) {
this.fromWhere = fromWhere;
}
public String getIsComplete() {
return isComplete;
}
public void setIsComplete(String isComplete) {
this.isComplete = isComplete;
}
}