Commit 8de216c3 by liuyz

提交预警、用户组、用户

parent 1175e063
......@@ -9,6 +9,8 @@
<value>classpath:com/gaowj/business/host/hostDAO.xml</value>
<value>classpath:com/gaowj/business/trigger/triggerDAO.xml</value>
<value>classpath:com/gaowj/business/usergroup/usergroupDAO.xml</value>
<value>classpath:com/gaowj/business/user/userDAO.xml</value>
<value>classpath:com/gaowj/business/warning/warningDAO.xml</value>
</list>
</property>
</bean>
......@@ -37,4 +39,20 @@
</bean>
</property>
</bean>
<bean id="UserBusiness" class="com.gaowj.business.user.UserBusinessImpl">
<property name="userDAO">
<bean class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.gaowj.business.user.userDAO" />
<property name="sqlSessionFactory" ref="sqlSessionFactory-monitoring" />
</bean>
</property>
</bean>
<bean id="WarningBusiness" class="com.gaowj.business.warning.WarningBusinessImpl">
<property name="warningDAO">
<bean class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.gaowj.business.warning.warningDAO" />
<property name="sqlSessionFactory" ref="sqlSessionFactory-monitoring" />
</bean>
</property>
</bean>
</beans>
//此乃本模块与后台交互的方法接口部分
var userModule = function(format) {
this.module = "";
this.action = "";
this.format = format;
};
//定义数据交互
userModule.prototype = BusinessObject;
//插入数据
userModule.prototype.insertUser = function(){};
//修改数据
userModule.prototype.updateUser = function(){};
//删除数据
userModule.prototype.deleteUser = function(){};
//创建一个数据操作对象,然后再后续使用
userModule.act = new userModule("json").delegate("userAct");
//创建一个数据获取对象,然后再后续使用
userModule.data = new userModule("json").delegate("userData");
//说明: 1、所有方法里统一传递josn格式的参数,用于后台交互,如data.listTables(param) ,如没有参数则传'{}',如data.listTables({})
// 2、前后台数据获取传输协议 如:json[{'0':{pageCount':'2','pageNo':'1','pageSize':'20','rowSet':'[{0},{1}....]'}}]
// 3、前后台增删改的返回状态 如:json[{'0':{'rowSet':{'NAME':'-1','VALUE':'保存失败'}}}]
/**
* 序号:1
* 功能:定义分页(EasyUI)
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:无需更改
**/
var ls_width = $(window).width();
var ls_height = $(window).height();
var local_page=1;
var rows=20;
var listPageSize = [10,20,50,100,500,1000];
var queryData = eval("({'page':'"+local_page+"','rows':'"+rows+"'})");
var tab_n = 0;
//重置分页参数
function resetQueryData(){
queryData = "";
queryData = eval("({'page':'"+local_page+"','rows':'"+rows+"'})");
}
//定义附件关联模块ID(1:一般业务,2:测试信息,3:审批业务,999:其它数据 )
var ls_module_id='2';
//定义当前模块业务类型(YBYW:一般业务,SPGL:审批业务)
var ls_ywlx = 'YBYW';
/****/
/**
* 序号:2
* 功能:构建下拉框内容
* 参数:
* 说明:方便新增、修改页面里的下拉选项加载数据
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
//加载用户组列表
var v_usergrp_data = usergroupModule.data.listAll().rowSet;
$('#FIELD_HOSTID').val(v_host_data[0].HOSTID);
$('#FIELD_usrgrpid').combobox({
data : v_host_data,
valueField : 'HOSTID',
textField : 'NAME',
editable:false,
panelHeight:'auto'
});
/****/
/**
* 序号:3
* 功能:构建主页面列表
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
//定义grid列表
var ls_title="用户维护";
var is_column = [ [
{field : 'Alias',title : '用户名',width : 350,align : 'left'
},
{field : 'USERS_STATUS',title : '状态',width : 350,align : 'left',formatter:function(value,row,index){
for(var i=0;i<v_status_data.length;i++){
if(v_status_data[i].CODE_ID==value){
return v_status_data[i].CODE_NAME;
}
}
}
}
] ];
//列表加载完成回调
function dataOnLoadSuccess(){
}
//设置颜色和每行高度
function rowstyler(index,row){
return 'color:green;height:30px;';
}
//展示列表
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/usergroupData_list",Object.assign({},$("#tusergroupTab_searchForm").getFormVal(),queryData),is_column,60,80);
/****/
/**
* 序号:4
* 功能:设置主页面操作列菜单
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
//操用列显示更多(一般情况下无需更改)
function formatMenu(value, data,index) {
var returnData="";
return returnData
+ "<span class=\"icon-ext-moremenu\" style=\"padding-left:20px;*width:20px;\"></span>"
+ "<span data-p1="+index+" class=\"easyui-tooltip\" style=\"color:blue;cursor:pointer;\">更多</span>";
}
//上浮横向菜单集里的具体菜单项(需更改)
function getOptionMenu(data,index){
//上浮菜单具体按钮
var optionMenu=new Array();
optionMenu[0]=makeBtnOneParama('编辑','icon-edit',"editRow",index);
optionMenu[1]=makeBtnOneParama('删除','icon-clear',"deleteRow",index);
var splitStr=' | ';
var returnData='';
for(var i=0;i<optionMenu.length;i++){
returnData+=splitStr+optionMenu[i];
}
return returnData.substr(splitStr.length-1);
}
//单个按钮构造
function makeBtn(text,cssClass,click){
return "<span class=\""+cssClass+"\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\""+click+"\">"+text+"</a>";
}
//单按钮单参数构造
function makeBtnOneParama(text,cssClass,clickName,index){
return makeBtn(text,cssClass,clickName+"('"+ index + "')");
}
//返回菜单集的菜单个数(需更改)
function getOptionMenuCount(){
var is_menu_count = 2;
return is_menu_count;
}
/****/
/**
* 序号:5
* 功能:新增修改弹出
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
//加载增加子页面
function addRow(){
var is_row={OPETYPE:'insert'};
openEditRow("usergroupView_usergroupTabDetail",is_row,"新增",true,0.65,0.95,0,0);
}
//加载增加子页面成功后的回调
function addUrlOnloadCallback(is_row){
$('#USERS_STATUS').val(0);
$('#USERS_STATUS').combobox({
data : v_status_data,
valueField : 'CODE_ID',
textField : 'CODE_NAME',
editable:false,
panelHeight:'auto'
});
}
//保存
function insertData(is_entity){
var v_result = usergroupModule.act.insertUsergroup(is_entity);
$('#list').datagrid('reload');
return v_result;
}
//加载修改子页面
function editRow(index) {
var is_row = $('#list').datagrid('getRows')[index];
is_row.OPETYPE = 'update';
openEditRow("usergroupView_usergroupTabDetail",is_row,"编辑",true,0.65,0.95,0,0);
}
//加载修改子页面成功后的回调
function updateUrlOnloadCallback(is_row){
for(k in is_row){
is_row['FIELD_'+k]=is_row[k];
}
$("#inputForm").form('load',is_row);
$('#USERS_STATUS').combobox({
data : v_status_data,
valueField : 'CODE_ID',
textField : 'CODE_NAME',
editable:false,
panelHeight:'auto'
});
}
//保存
function updateData(is_entity){
var v_result = usergroupModule.act.updateUsergroup(is_entity);
$('#list').datagrid('reload');
return v_result;
}
/****/
/**
* 序号:6
* 功能:单个删除
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
function deleteRow(index){
var is_row = $('#list').datagrid('getData').rowSet[index];
var code = is_row.USRGRPID;
$.messager.confirm('提示', '确定删除?', function(r) {
if (r) {
var v_query = {};
v_query.FIELD_CODE = code;
var v_result = usergroupModule.act.deleteUsergroup(v_query);
$.messager.alert('提示',v_result.VALUE);
$('#list').datagrid('reload');
}
});
}
/****/
/**
* 序号:7
* 功能:批量删除
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
function deleteBatchRow(){
var code="";
var rows = $('#list').datagrid('getSelections');
console.log(rows)
for(var i=0; i<rows.length; i++){
code = code + rows[i].USRGRPID+",";
}
if(rows == null || rows == ""){
$.messager.alert('提示',"请选择需删除的记录!",'info');
return;
}
if(code.length>0){
code = code.substring(0,code.length - 1);
}
$.messager.confirm('提示', '确定删除?', function(r) {
if (r) {
var v_query = {};
v_query.FIELD_CODE = code;
var v_result = usergroupModule.act.deleteUsergroup(v_query);
$.messager.alert('提示',v_result.VALUE);
$('#list').datagrid('reload');
}
});
}
/****/
/**
* 序号:8
* 功能:刷新
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
function refreshRow(){
$("#usergroupTab_searchForm")[0].reset();
$('#list').datagrid('load',$("#usergroupTab_searchForm").getFormVal());
}
/****/
/**
* 序号:9
* 功能:查询
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
function searchRow(){
var v_query = $("#usergroupTab_searchForm").getFormVal();
$('#list').datagrid('load',v_query);
}
/****/
/**
* 序号:10
* 功能:高级查询弹出
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
//加载高级查询子页面
function advsearchRow(){
var is_row={OPETYPE:'ww'};
openAdvsearchRow("studentView_studentAdvsearch",is_row,"高级查询",true,0.65,0.95,0,0);
}
//加载高级查询子页面成功后的回调
function addAdvsearchCallback(is_row){
}
//高级查询
function advsearchData(is_entity){
$('#list').datagrid('load',is_entity);
}
/****/
/**
* 序号:11
* 功能:处理接口附件
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
function uploadcommonRow(index){
}
/****/
/**
* 序号:12
* 功能:批量处理接口附件
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
function uploadcommonBatchRow(){
}
/****/
\ No newline at end of file
<%@page contentType="text/html; charset=UTF-8"%>
<%@ include file="/gaowj/header-simple-1.0.jsp"%>
<div id="userTab">
<link rel="stylesheet" type="text/css" href="${ctx}/jwapp/common/css/content_body.css" charset="utf-8"></link>
<link rel="stylesheet" type="text/css" href="${ctx}/jwapp/common/css/content_table.css" charset="utf-8"></link>
<link rel="stylesheet" type="text/css" href="${ctx}/jwapp/common/css/content_input.css" charset="utf-8"></link>
</div>
<table id="list" style="width: 100%; height: 100%;"></table>
<div id="tb">
<form id="userTab_searchForm" style="float:left">
名称: <input id="FIELD_NAME" name="FIELD_NAME" type="text" style="width: 200px" >
</form>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:searchRow()">查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()">刷新</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="javascript:addRow()">新增</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear',plain:true" onclick="javascript:deleteBatchRow()">删除</a>
</div>
<div id="detail" style="overflow:auto;"></div>
<script type="text/javascript" src="${ctx}/jwapp/pages/standard/js/jwStandardModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/monitoring/pages/user/js/userModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/monitoring/pages/user/js/userTab.js" charset="utf-8"></script>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'userTabDetail.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This is my JSP page. <br>
</body>
</html>
......@@ -16,9 +16,9 @@ usergroupModule.prototype.updateUsergroup = function(){};
usergroupModule.prototype.deleteUsergroup = function(){};
//创建一个数据操作对象,然后再后续使用
usergroupModule.act = new triggerModule("json").delegate("usergroupAct");
usergroupModule.act = new usergroupModule("json").delegate("usergroupAct");
//创建一个数据获取对象,然后再后续使用
usergroupModule.data = new triggerModule("json").delegate("usergroupData");
usergroupModule.data = new usergroupModule("json").delegate("usergroupData");
//说明: 1、所有方法里统一传递josn格式的参数,用于后台交互,如data.listTables(param) ,如没有参数则传'{}',如data.listTables({})
// 2、前后台数据获取传输协议 如:json[{'0':{pageCount':'2','pageNo':'1','pageSize':'20','rowSet':'[{0},{1}....]'}}]
......
......@@ -173,6 +173,17 @@ function editRow(index) {
//加载修改子页面成功后的回调
function updateUrlOnloadCallback(is_row){
for(k in is_row){
is_row['FIELD_'+k]=is_row[k];
}
$("#inputForm").form('load',is_row);
$('#USERS_STATUS').combobox({
data : v_status_data,
valueField : 'CODE_ID',
textField : 'CODE_NAME',
editable:false,
panelHeight:'auto'
});
}
//保存
function updateData(is_entity){
......@@ -194,14 +205,13 @@ function updateData(is_entity){
* 备注:需更改
**/
function deleteRow(index){
var is_row = $('#list').datagrid('getData')[index];
var code = is_row.UUID;
var is_row = $('#list').datagrid('getData').rowSet[index];
var code = is_row.USRGRPID;
$.messager.confirm('提示', '确定删除?', function(r) {
if (r) {
var v_query = {};
v_query.FIELD_CODE = code;
var v_result = studentModule.studentActAction.deleteStudent(v_query);
var v_result = usergroupModule.act.deleteUsergroup(v_query);
$.messager.alert('提示',v_result.VALUE);
$('#list').datagrid('reload');
}
......@@ -222,8 +232,9 @@ function deleteRow(index){
function deleteBatchRow(){
var code="";
var rows = $('#list').datagrid('getSelections');
console.log(rows)
for(var i=0; i<rows.length; i++){
code = code + rows[i].TRIGGERID+",";
code = code + rows[i].USRGRPID+",";
}
if(rows == null || rows == ""){
$.messager.alert('提示',"请选择需删除的记录!",'info');
......@@ -236,7 +247,7 @@ function deleteBatchRow(){
if (r) {
var v_query = {};
v_query.FIELD_CODE = code;
var v_result = triggerModule.act.deleteTrigger(v_query);
var v_result = usergroupModule.act.deleteUsergroup(v_query);
$.messager.alert('提示',v_result.VALUE);
$('#list').datagrid('reload');
}
......
......@@ -8,7 +8,7 @@
<table id="list" style="width: 100%; height: 100%;"></table>
<div id="tb">
<form id="usergroupTab_searchForm" style="float:left">
名称: <input id="FIELD_HOSTID" name="FIELD_HOSTID" type="text" style="width: 200px" class="easyui-combobox">
名称: <input id="FIELD_NAME" name="FIELD_NAME" type="text" style="width: 200px" >
</form>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:searchRow()">查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()">刷新</a>
......
......@@ -8,19 +8,15 @@
<table id="list" style="width: 100%; height: 100%;"></table>
<div id="tb">
<form id="warningTab_searchForm" style="float:left">
是否已毕业: <input id="FIELD_STATUS" name="FIELD_STATUS" type="text" style="width: 100px" class="easyui-combobox">&nbsp;&nbsp;
姓名: <input class="easyui-textbox" id="FIELD_NAME" name="FIELD_NAME" style="width:200px"/>&nbsp;&nbsp;
状态: <input id="FIELD_VALUE" name="FIELD_VALUE" type="text" style="width: 100px" class="easyui-combobox">&nbsp;&nbsp;
主机: <input id="FIELD_HOSTID" name="FIELD_HOSTID" type="text" style="width: 200px" class="easyui-combobox">
</form>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:searchRow()">查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ext-advsearch',plain:true" onclick="javascript:advsearchRow()">高级查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()">刷新</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="javascript:addRow()">新增</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear',plain:true" onclick="javascript:deleteBatchRow()">删除</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ext-file',plain:true" onclick="javascript:uploadcommonBatchRow()">附件</a>
</div>
<div id="detail" style="overflow:auto;"></div>
<div id="advsearch" style="overflow:auto;"></div>
<div id="uploadcommon" style="overflow:auto;"></div>
<script type="text/javascript" src="${ctx}/jwapp/pages/standard/js/jwStandardModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/monitoring/pages/host/js/hostModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/monitoring/pages/warning/js/warningModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/monitoring/pages/warning/js/warningTab.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/monitoring/pages/warning/js/warningTab.js" charset="utf-8"></script>
\ No newline at end of file
......@@ -5,15 +5,10 @@
<struts>
<package name="src_monitoring" extends="gaowj">
<action name="warningView_*" class="com.gaowj.monitoring.action.viewAction" method="{1}">
<action name="warningView_*" class="com.gaowj.warning.action.viewAction" method="{1}">
<result name="{1}">/monitoring/pages/warning/{1}.jsp</result>
</action>
<action name="warningAct_*" class="com.gaowj.monitoring.action.actAction" method="{1}">
<result name="json" type="json">
<param name="root">jsonObject</param>
</result>
</action>
<action name="warningData_*" class="com.gaowj.monitoring.action.dataAction" method="{1}">
<action name="warningData_*" class="com.gaowj.warning.action.dataAction" method="{1}">
<result name="json" type="json">
<param name="root">jsonObject</param>
</result>
......@@ -60,5 +55,20 @@
<param name="root">jsonObject</param>
</result>
</action>
<action name="userView_*" class="com.gaowj.user.action.viewAction" method="{1}">
<result name="{1}">/monitoring/pages/host/{1}.jsp</result>
</action>
<action name="userAct_*" class="com.gaowj.user.action.actAction" method="{1}">
<result name="json" type="json">
<param name="root">jsonObject</param>
</result>
</action>
<action name="userData_*" class="com.gaowj.user.action.dataAction" method="{1}">
<result name="json" type="json">
<param name="root">jsonObject</param>
</result>
</action>
</package>
</struts>
package com.gaowj.business;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Page;
@Service
public interface UserBusiness {
/**
* 分页获取记录
*
* @param entity
* @throws BusinessException
*/
Page<Map<String, Object>> list_user(int pageNo, int pageSize, Map<String, Object> query) throws BusinessException;
}
package com.gaowj.business;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Page;
@Service
public interface WarningBusiness {
/**
* 分页获取记录
*
* @param entity
* @throws BusinessException
*/
Page<Map<String, Object>> list_warning(int pageNo, int pageSize, Map<String, Object> query) throws BusinessException;
}
package com.gaowj.business.user;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.RowBounds;
import com.gaowj.business.UserBusiness;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Page;
public class UserBusinessImpl implements UserBusiness{
private userDAO userDAO;
public userDAO getUserDAO() {
return userDAO;
}
public void setUserDAO(userDAO userDAO) {
this.userDAO = userDAO;
}
@Override
public Page<Map<String, Object>> list_user(int pageNo, int pageSize, Map<String, Object> query)
throws BusinessException {
// 计算起始记录
int pageStart = (pageNo - 1) * pageSize;
// 获取列表
List<Map<String, Object>> items = userDAO.list_user(new RowBounds(pageStart, pageSize), query);
// 获取列表个数
int count = userDAO.list_count_user(query);
// 创建分页对象
Page<Map<String, Object>> page = new Page<Map<String, Object>>();
page.setStart(pageStart);
page.setLimit(pageSize);
page.setCount(count);
page.setItems(items);
return page;
}
}
package com.gaowj.business.user;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.RowBounds;
import com.gaowj.business.exception.BusinessException;
public interface userDAO {
List<Map<String, Object>> list_user(RowBounds rowbounds, Map<String, Object> query) throws BusinessException;
int list_count_user(Map<String, Object> query) throws BusinessException;
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gaowj.business.user.userDAO">
<sql id="Where_Clause">
<trim prefix="WHERE" prefixOverrides="AND |OR">
<if test="NAME != null and NAME != ''">
and u.NAME = #{NAME}
</if>
</trim>
</sql>
<select id="list_user" parameterType="map" resultType="upperCaseKeyMap">
SELECT u.*,gr.*
FROM users u
LEFT JOIN users_groups ug ON ug.userid = u.userid
LEFT JOIN usrgrp gr ON ug.usrgrpid = gr.usrgrpid
<include refid="Where_Clause" />
order by u.userid DESC
</select>
<select id="list_count_user" parameterType="map" resultType="int">
SELECT count(*)
FROM users u
LEFT JOIN users_groups ug ON ug.userid = u.userid
LEFT JOIN usrgrp gr ON ug.usrgrpid = gr.usrgrpid
<include refid="Where_Clause" />
</select>
</mapper>
\ No newline at end of file
......@@ -4,7 +4,7 @@
<sql id="Where_Clause">
<trim prefix="WHERE" prefixOverrides="AND |OR">
<if test="NAME != null and NAME != ''">
and t.NAME = #{NAME}
and t.NAME LIKE #{NAME}
</if>
and t.usrgrpid > 12
</trim>
......
package com.gaowj.business.warning;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.RowBounds;
import com.gaowj.business.WarningBusiness;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Page;
public class WarningBusinessImpl implements WarningBusiness{
private warningDAO warningDAO;
public warningDAO getWarningDAO() {
return warningDAO;
}
public void setWarningDAO(warningDAO warningDAO) {
this.warningDAO = warningDAO;
}
@Override
public Page<Map<String, Object>> list_warning(int pageNo, int pageSize, Map<String, Object> query)
throws BusinessException {
// 计算起始记录
int pageStart = (pageNo - 1) * pageSize;
// 获取列表
List<Map<String, Object>> items = warningDAO.list_warning(new RowBounds(pageStart, pageSize), query);
// 获取列表个数
int count = warningDAO.list_count_warning(query);
// 创建分页对象
Page<Map<String, Object>> page = new Page<Map<String, Object>>();
page.setStart(pageStart);
page.setLimit(pageSize);
page.setCount(count);
page.setItems(items);
return page;
}
}
package com.gaowj.business.warning;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.RowBounds;
public interface warningDAO {
List<Map<String, Object>> list_warning(RowBounds rowBounds, Map<String, Object> query);
int list_count_warning(Map<String, Object> query);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gaowj.business.warning.warningDAO">
<sql id="Where_Clause">
<trim prefix="WHERE" prefixOverrides="AND |OR">
<if test="HOSTID != null and HOSTID != ''">
and h.hostid = #{HOSTID}
</if>
<if test="VALUE != null and VALUE != ''">
and h.VALUE = #{VALUE}
</if>
</trim>
</sql>
<select id="list_warning" parameterType="map" resultType="upperCaseKeyMap">
SELECT * from hosts_event_view h
<include refid="Where_Clause" />
order by h.eventid DESC
</select>
<select id="list_count_warning" parameterType="map" resultType="int">
SELECT count(*) from hosts_event_view h
<include refid="Where_Clause" />
</select>
</mapper>
\ No newline at end of file
package com.gaowj.monitoring.action;
import com.gaowj.business.action.BasicAction;
import net.sf.json.JSONObject;
public class actAction extends BasicAction {
/**
*
*/
private static final long serialVersionUID = -6496396449440750926L;
private JSONObject jsonObject = new JSONObject();
public JSONObject getJsonObject() {
return jsonObject;
}
public void setJsonObject(JSONObject jsonObject) {
this.jsonObject = jsonObject;
}
}
......@@ -3,6 +3,7 @@ package com.gaowj.trigger.action;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.exception.BusinessException;
......@@ -10,13 +11,21 @@ import com.gaowj.business.util.RequestUtils;
import com.gaowj.business.util.Status;
import com.zabbix4j.ZabbixApi;
import com.zabbix4j.ZabbixApiException;
import com.zabbix4j.host.HostCreateRequest;
import com.zabbix4j.action.ActionCondition;
import com.zabbix4j.action.ActionCreateRequest;
import com.zabbix4j.action.ActionCreateRequest.Params;
import com.zabbix4j.action.ActionCreateRequest.Params.Filter;
import com.zabbix4j.action.ActionDeleteRequest;
import com.zabbix4j.action.ActionGetRequest;
import com.zabbix4j.action.ActionGetResponse;
import com.zabbix4j.action.ActionObject;
import com.zabbix4j.action.ActionOperation;
import com.zabbix4j.action.OperationMessage;
import com.zabbix4j.action.OperationMessageGroup;
import com.zabbix4j.trigger.TriggerCreateRequest;
import com.zabbix4j.trigger.TriggerCreateResponse;
import com.zabbix4j.trigger.TriggerDeleteRequest;
import com.zabbix4j.trigger.TriggerDeleteResponse;
import com.zabbix4j.trigger.TriggerUpdateRequest;
import com.zabbix4j.trigger.TriggerUpdateResponse;
import net.sf.json.JSONObject;
......@@ -68,8 +77,44 @@ public class actAction extends BasicAction {
5 - disaster.*/
params.setPriority(Integer.valueOf(entity.get("PRIORITY").toString()));
params.setComments(entity.get("COMMENTS").toString());
TriggerCreateResponse response = zabbixApi.trigger().create(request);
TriggerCreateResponse.Result result = response.getResult();
List<Integer> triggerids = result.getTriggerids();
zabbixApi.trigger().create(request);
ActionCreateRequest request2 = new ActionCreateRequest();
Params e = request2.createParam();
e.setName(UUID.randomUUID().toString());
e.setStatus(0);
e.setEventsource(0);
e.setDef_shortdata("Problem: {TRIGGER.NAME}");
//触发器信息
Filter filter = e.createFilter();
ActionCondition conditions = new ActionCondition();
conditions.setConditiontype(2);
conditions.setOperator(0);
conditions.setValue(triggerids.get(0).toString());
filter.addActionConditon(conditions);
//操作持续时间
ActionOperation actionOperation = new ActionOperation();
actionOperation.setOperationtype(0);
actionOperation.setEsc_period(60);
//用户组信息
List<OperationMessageGroup> opmessage_grp = new ArrayList<OperationMessageGroup>();
OperationMessageGroup grp = new OperationMessageGroup();
grp.setUsrgrpid(7);
opmessage_grp.add(grp);
actionOperation.setOpmessage_grp(opmessage_grp);
//消息类型信息
OperationMessage opmessage = new OperationMessage();
opmessage.setMediatypeid(4);
opmessage.setDefault_msg(1);
actionOperation.setOpmessage(opmessage);
List<ActionOperation> operations = new ArrayList<ActionOperation>();
operations.add(actionOperation);
e.setOperations(operations);
zabbixApi.action().create(request2);
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("保存失败"));
......@@ -106,19 +151,32 @@ public class actAction extends BasicAction {
return "json";
}
public String deleteTrigger() throws BusinessException{
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
public String deleteTrigger() throws BusinessException {
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request, RequestUtils.UPDATEDATAFIELDPREFIX);
jsonObject = new JSONObject();
try {
TriggerDeleteRequest request=new TriggerDeleteRequest();
List<Integer> list_triggerid=new ArrayList<Integer>();
String code=entity.get("CODE").toString();
for(String c:code.split(",")){
TriggerDeleteRequest request = new TriggerDeleteRequest();
List<Integer> list_triggerid = new ArrayList<Integer>();
String code = entity.get("CODE").toString();
for (String c : code.split(",")) {
list_triggerid.add(Integer.valueOf(c));
}
request.setParams(list_triggerid);
zabbixApi.trigger().delete(request);
List<Integer> list_actionid = new ArrayList<Integer>();
ActionDeleteRequest request3 = new ActionDeleteRequest();
ActionGetRequest request2 = new ActionGetRequest();
ActionGetRequest.Params params = request2.getParams();
params.setTriggerids(list_triggerid);
ActionGetResponse response = zabbixApi.action().get(request2);
List<ActionObject> result = response.getResult();
for (ActionObject action : result) {
list_actionid.add(action.getActionid());
}
request3.setParams(list_actionid);
zabbixApi.action().delete(request3);
zabbixApi.trigger().delete(request);
jsonObject.putAll(Status.getStatusSuccessMessage("删除成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("删除失败"));
......
package com.gaowj.user.action;
import java.util.List;
import java.util.Map;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.RequestUtils;
import com.gaowj.business.util.Status;
import com.zabbix4j.ZabbixApi;
import com.zabbix4j.ZabbixApiException;
import com.zabbix4j.action.ActionCreateRequest;
import com.zabbix4j.action.ActionCreateRequest.Params;
import com.zabbix4j.usergroup.UserGroupCreateRequest;
import net.sf.json.JSONObject;
public class actAction extends BasicAction{
/**
*
*/
private static final long serialVersionUID = -6496396449440750926L;
private JSONObject jsonObject = new JSONObject();
public JSONObject getJsonObject() {
return jsonObject;
}
public void setJsonObject(JSONObject jsonObject) {
this.jsonObject = jsonObject;
}
private static ZabbixApi zabbixApi;
static {
String url = "http://192.168.1.142/api_jsonrpc.php";
zabbixApi = new ZabbixApi(url);
try {
zabbixApi.login("Admin", "zabbix");
} catch (ZabbixApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String insertUser() throws BusinessException {
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request, RequestUtils.UPDATEDATAFIELDPREFIX);
jsonObject = new JSONObject();
try {
/*ActionCreateRequest request = new ActionCreateRequest();
List<Params> params = request.getParams();*/
/*UserGroupCreateRequest request = new UserGroupCreateRequest();
UserGroupCreateRequest.Params params = request.getParams();
params.setName(entity.get("NAME").toString());
params.setUsers_status(Integer.valueOf(entity.get("USERS_STATUS").toString()));
zabbixApi.usergroup().create(request);
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));*/
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("保存失败"));
e.printStackTrace();
}
return "json";
}
}
package com.gaowj.user.action;
import com.gaowj.business.action.BasicAction;
public class dataAction extends BasicAction{
}
package com.gaowj.user.action;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.exception.BusinessException;
public class viewAction extends BasicAction{
/**
*
*/
private static final long serialVersionUID = 949181442473248671L;
public String userTab() throws BusinessException{
return "userTab";
}
public String userTabDetail() throws BusinessException{
return "userTabDetail";
}
}
......@@ -55,17 +55,17 @@ public class actAction extends BasicAction {
}
}
public String insertUsergroup() throws BusinessException{
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
public String insertUsergroup() throws BusinessException {
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request, RequestUtils.UPDATEDATAFIELDPREFIX);
jsonObject = new JSONObject();
try {
UserGroupCreateRequest request=new UserGroupCreateRequest();
UserGroupCreateRequest request = new UserGroupCreateRequest();
UserGroupCreateRequest.Params params = request.getParams();
params.setName(entity.get("NAME").toString());
params.setUsers_status(Integer.valueOf(entity.get("USERS_STATUS").toString()));
zabbixApi.usergroup().create(request);
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));
zabbixApi.usergroup().create(request);
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("保存失败"));
e.printStackTrace();
......@@ -79,6 +79,7 @@ public class actAction extends BasicAction {
try {
UserGroupUpdateRequest request=new UserGroupUpdateRequest();
UserGroupUpdateRequest.Params params = request.getParams();
params.setUsrgrpid(Integer.valueOf(entity.get("USRGRPID").toString()));
params.setName(entity.get("NAME").toString());
params.setUsers_status(Integer.valueOf(entity.get("USERS_STATUS").toString()));
......@@ -96,12 +97,12 @@ public class actAction extends BasicAction {
jsonObject = new JSONObject();
try {
UserGroupDeleteRequest request=new UserGroupDeleteRequest();
List<Integer> list_triggerid=new ArrayList<Integer>();
List<Integer> list_userid=new ArrayList<Integer>();
String code=entity.get("CODE").toString();
for(String c:code.split(",")){
list_triggerid.add(Integer.valueOf(c));
list_userid.add(Integer.valueOf(c));
}
request.setParams(list_triggerid);
request.setParams(list_userid);
zabbixApi.usergroup().delete(request);
jsonObject.putAll(Status.getStatusSuccessMessage("删除成功"));
......
package com.gaowj.monitoring.action;
package com.gaowj.warning.action;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import com.gaowj.business.WarningBusiness;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Page;
import com.gaowj.business.util.QueryParamUtil;
import com.gaowj.business.util.RequestUtils;
import net.sf.json.JSONObject;
public class dataAction extends BasicAction {
public class dataAction extends BasicAction{
/**
*
*/
......@@ -14,7 +24,7 @@ public class dataAction extends BasicAction {
private JSONObject jsonObject = new JSONObject();
private int rows = 20;// 每页显示的记录数
private int page = 1;// 当前第几页
public JSONObject getJsonObject() {
return jsonObject;
}
......@@ -42,5 +52,30 @@ public class dataAction extends BasicAction {
setPageNo(page);
this.page = getPageNo();
}
public String list() throws BusinessException {
WarningBusiness business = BusinessManager.getBusiness(WarningBusiness.class);
Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
try {
query = QueryParamUtil.StringToDate(query);
Page<Map<String, Object>> pageRows = business.list_warning(pageNo,pageSize, query);
setPageCount((pageRows.getCount() - 1) / pageSize + 1);
Map<String, Object> data = new HashMap<String, Object>();
data.put("rowSet", QueryParamUtil.DateToString(pageRows.getItems()));
data.put("pageNo", pageNo);
data.put("pageSize", pageSize);
data.put("pageCount", pageCount);
data.put("rows", data.get("rowSet"));
data.put("total", pageRows.getCount());
jsonObject = new JSONObject();
jsonObject.putAll(data);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "json";
}
}
package com.gaowj.monitoring.action;
package com.gaowj.warning.action;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.exception.BusinessException;
public class viewAction extends BasicAction {
public class viewAction extends BasicAction{
/**
*
*/
......
package com.zabbix4j.action;
public class ActionObject {
private Integer actionid;
private String esc_period;
private Integer evaltype;
private Integer eventsource;
private String name;
private String def_longdata;
private String def_shortdata;
private String r_longdata;
private String r_shortdata;
private Integer recovery_msg;
private Integer status;
public Integer getActionid() {
return this.actionid;
}
public void setActionid(Integer actionid) {
this.actionid = actionid;
}
public Integer getEvaltype() {
return this.evaltype;
}
public void setEvaltype(Integer evaltype) {
this.evaltype = evaltype;
}
public Integer getEventsource() {
return this.eventsource;
}
public void setEventsource(Integer eventsource) {
this.eventsource = eventsource;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getDef_longdata() {
return this.def_longdata;
}
public void setDef_longdata(String def_longdata) {
this.def_longdata = def_longdata;
}
public String getDef_shortdata() {
return this.def_shortdata;
}
public void setDef_shortdata(String def_shortdata) {
this.def_shortdata = def_shortdata;
}
public String getR_longdata() {
return this.r_longdata;
}
public void setR_longdata(String r_longdata) {
this.r_longdata = r_longdata;
}
public String getR_shortdata() {
return this.r_shortdata;
}
public void setR_shortdata(String r_shortdata) {
this.r_shortdata = r_shortdata;
}
public Integer getRecovery_msg() {
return this.recovery_msg;
}
public void setRecovery_msg(Integer recovery_msg) {
this.recovery_msg = recovery_msg;
}
public Integer getStatus() {
return this.status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getEsc_period() {
return esc_period;
}
public void setEsc_period(String esc_period) {
this.esc_period = esc_period;
}
}
......@@ -5,6 +5,8 @@ package com.gaowj.system.login;
import java.io.IOException;
import javax.servlet.http.Cookie;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.exception.BusinessException;
//import com.gaowj.business.listener.myHttpSessionAttributeListener;
......
......@@ -3,9 +3,6 @@ package com.gaowj.student;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import com.gaowj.business.TriggerBusiness;
import com.gaowj.business.StudentBusiness;
import com.gaowj.business.SystemOpeBusiness;
import com.gaowj.business.action.BasicAction;
......@@ -16,6 +13,8 @@ import com.gaowj.business.util.RequestUtils;
import com.gaowj.business.util.Status;
import com.gaowj.standard.utils.CacheKit;
import net.sf.json.JSONObject;
public class actAction extends BasicAction {
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment