1、jar包直接放在lib文件夹下

2、增加hibernate interceptor 修改sql语句适配mycat
3、部分页面修改
4、增加分中心只显示数据展示分中心角色菜单
This commit is contained in:
fangshunjian
2018-12-21 22:13:42 +06:00
parent f248aa0ddc
commit df150d4dd7
170 changed files with 16335 additions and 13879 deletions

View File

@@ -12,12 +12,14 @@ import nis.nms.util.ConnectionOracle;
import nis.nms.util.HttpClientUtil;
import org.apache.log4j.Logger;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import com.nms.thread.service.NmsReportService;
public class NmsPortThread implements Runnable {
private Logger logger = Logger.getLogger(NmsPortThread.class);
private static Logger logger = Logger.getLogger(NmsPortThread.class);
@Override
public void run() {
@@ -38,7 +40,7 @@ public class NmsPortThread implements Runnable {
NmsReportService service = new NmsReportService(connection);
ArrayList<Map<String, String>> nmsPortInfo = service.getNmsPortInfo(nowLong, nowLong-interval*1000);
if (nmsPortInfo != null && nmsPortInfo.size() > 0) {
logger.debug(String.format("查询数量:%s", nmsPortInfo.size()));
Map<String, List<Map<String, String>>> data = new HashMap<String, List<Map<String, String>>>();
List<Map<String, String>> results = new ArrayList<Map<String, String>>();
@@ -56,13 +58,14 @@ public class NmsPortThread implements Runnable {
result.put("inpktsSpeed", info.get("INPKTSSPEED") == null ? "" : info.get("INPKTSSPEED"));
result.put("outpktsSpeed", info.get("OUTPKTSSPEED") == null ? "" : info.get("OUTPKTSSPEED"));
result.put("recvTime", info.get("DATA_CHECK_TIME") == null ? "" : info.get("DATA_CHECK_TIME"));
result.put("entranceId", info.get("ADDR") == null ? "" : info.get("ADDR"));
results.add(result);
}
data.put("trafficNetflowPortInfoList", results);
HttpClientUtil httpUtil = new HttpClientUtil();
JSONObject fromObject = JSONObject.fromObject(data);
httpUtil.post(BaseAction.rb.getString("nms.port.url"), fromObject.toString());
String dataStr = Json.toJson(data,JsonFormat.tidy());
logger.debug("url:" +BaseAction.rb.getString("nms.port.url") + ",data :" + dataStr);
httpUtil.post(BaseAction.rb.getString("nms.port.url"), dataStr);
logger.info("port上报完毕");
} else {
logger.info("暂无可上报的port数据");

View File

@@ -6,19 +6,19 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import nis.nms.util.BaseAction;
import nis.nms.util.ConnectionOracle;
import nis.nms.util.DateUtil;
import nis.nms.util.HttpClientUtil;
import org.apache.log4j.Logger;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import com.nms.thread.service.NmsReportService;
import nis.nms.util.BaseAction;
import nis.nms.util.ConnectionOracle;
import nis.nms.util.HttpClientUtil;
public class NmsRuleThread implements Runnable {
private Logger logger = Logger.getLogger(NmsRuleThread.class);
private static Logger logger = Logger.getLogger(NmsRuleThread.class);
@Override
public void run() {
@@ -39,7 +39,7 @@ public class NmsRuleThread implements Runnable {
NmsReportService service = new NmsReportService(connection);
ArrayList<Map<String, String>> nmsRuleInfo = service.getNmsRuleInfo(nowLong, nowLong-interval*1000);
if (nmsRuleInfo != null && nmsRuleInfo.size() > 0) {
logger.debug(String.format("查询数量:%s", nmsRuleInfo.size()));
Map<String, List<Map<String, String>>> data = new HashMap<String, List<Map<String, String>>>();
List<Map<String, String>> results = new ArrayList<Map<String, String>>();
@@ -67,9 +67,9 @@ public class NmsRuleThread implements Runnable {
}
data.put("nmsDiRuleList", results);
HttpClientUtil httpUtil = new HttpClientUtil();
JSONObject fromObject = JSONObject.fromObject(data);
httpUtil.post(BaseAction.rb.getString("nms.rule.url"), fromObject.toString());
String dataStr = Json.toJson(data,JsonFormat.tidy());
logger.debug("url:" +BaseAction.rb.getString("nms.rule.url") + ",data :" + dataStr);
httpUtil.post(BaseAction.rb.getString("nms.rule.url"), dataStr);
logger.info("rule上报完毕");
} else {
logger.info("暂无可上报的rule数据");

View File

@@ -7,11 +7,12 @@ import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import com.nis.util.StringUtil;
import com.nms.thread.service.NmsReportService;
import net.sf.json.JSONObject;
import nis.nms.util.BaseAction;
import nis.nms.util.ConnectionOracle;
import nis.nms.util.DateUtil;
@@ -19,7 +20,7 @@ import nis.nms.util.HttpClientUtil;
public class NmsStatusThread implements Runnable {
private Logger logger = Logger.getLogger(NmsStatusThread.class);
private static Logger logger = Logger.getLogger(NmsStatusThread.class);
@Override
public void run() {
@@ -38,8 +39,8 @@ public class NmsStatusThread implements Runnable {
try {
connection = ConnectionOracle.getConnection();
NmsReportService service = new NmsReportService(connection);
ArrayList<Map<String, String>> nmsReportInfo = service.getNmsStatusInfo(setId);
logger.debug(String.format("查询设备数量:%s", nmsReportInfo == null ? 0 : nmsReportInfo.size()));
Map<String, List<Map<String, String>>> tmp = new HashMap<String, List<Map<String, String>>>();
tmp.put("unknown", new ArrayList<Map<String, String>>());
for (Map<String, String> info : nmsReportInfo) {
@@ -91,10 +92,9 @@ public class NmsStatusThread implements Runnable {
Map<String, List<Map>> map = new HashMap<String, List<Map>>();
map.put("trafficNmsServerList", results);
HttpClientUtil httpUtil = new HttpClientUtil();
JSONObject fromObject = JSONObject.fromObject(map);
logger.info(BaseAction.rb.getString("nms.status.url"));
httpUtil.post(BaseAction.rb.getString("nms.status.url"), fromObject.toString());
String data = Json.toJson(map,JsonFormat.tidy());
logger.debug("url:" +BaseAction.rb.getString("nms.status.url") + ",data :" + data);
httpUtil.post(BaseAction.rb.getString("nms.status.url"), data);
logger.info("status上报完毕");
} catch (Exception e) {
logger.error(e);

View File

@@ -13,6 +13,10 @@ public class ThreadPoolConfig {
public static final Integer DC_HANDSHAKE_PERIOD = StringUtils.isNotBlank(BaseAction.rb.getString("dc.handshake.period"))? Integer.parseInt(BaseAction.rb.getString("dc.handshake.period")):60*5;
public static final String DETEC_TIMEOUT_CHECK_MANAGER = "DETEC_TIMEOUT_CHECK_MANAGER";
public static final Integer DETEC_TIMEOUT_ALARM_PERIOD_TIMES =2;
/**
* 超时告警 延迟时间,为了防止 国家中心,分中心 两个web 同时判断生成多条 记录
*/
public static final Integer DETEC_TIMEOUT_ALARM_PERIOD_DELAY =StringUtils.isNotBlank(BaseAction.rb.getString("detec.timeout.alarm.period.delay"))? Integer.parseInt(BaseAction.rb.getString("detec.timeout.alarm.period.delay")): 5;
public static final Integer DETEC_TIMEOUT_CHECK_PERIOD = StringUtils.isNotBlank(BaseAction.rb.getString("detec.timeout.check.period"))? Integer.parseInt(BaseAction.rb.getString("detec.timeout.check.period")): 15*60;
public static final Integer FLAG_DETEC_TIMEOUT = StringUtils.isNotBlank(BaseAction.rb.getString("flag_detec_timeout"))? Integer.parseInt(BaseAction.rb.getString("flag_detec_timeout")): 1;

View File

@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import nis.nms.util.BaseAction;
import nis.nms.util.ConnectionOracle;
import org.apache.log4j.Logger;
@@ -17,15 +18,21 @@ public class NmsReportService {
}
public ArrayList<Map<String, String>> getNmsStatusInfo(String setId) {
Integer systemId = null;
try {
systemId = Integer.parseInt(BaseAction.rb.getString("addr.system.id"));
} catch (Exception e) {
systemId = 100017;
}
//detectioned_state=1时正常
String sql = "select nt.node_ip, ds.host_name, din.detectioned_state, st.system_name "
String sql = "select nt.node_ip, ds.host_name, din.detectioned_state, st.addr as system_name "
+ "from node_table nt "
+ "left join detection_info_new din on din.SEQ_ID=nt.seq_id "
+ "left join di_systeminfo ds on nt.SEQ_ID=ds.SEQ_ID "
+ "left join system_table st ON nt.system_id=st.system_id "
+ "where nt.node_state=0 AND din.DETECTION_SET_INFO_ID=" + setId + " "
+ "group by nt.node_ip";
+ "where nt.node_state=0 AND din.DETECTION_SET_INFO_ID=" + setId
+ " and st.system_id < " + systemId
+ " group by nt.node_ip";
ArrayList<String> fields = new ArrayList<String>();
fields.add("node_ip");
fields.add("host_name");
@@ -77,10 +84,12 @@ public class NmsReportService {
public ArrayList<Map<String, String>> getNmsPortInfo(Long end, Long start) {
//end=1539073220004l,start=1539064699984l
String sql = "SELECT nt.node_ip, nt.node_name, ds.ifindex, ds.IFDESCR, ds.IFSPEED, ds.IFINOCTETS, ds.IFOUTOCTETS,ds.INOCTETSSPEED,ds.INPKTSSPEED,ds.OUTOCTETSSPEED, ds.OUTPKTSSPEED, ds.DATA_CHECK_TIME "
//只查询 网元类型为 特种设备1的端口信息
String sql = "SELECT DISTINCT nt.node_ip, nt.node_name, ds.ifindex, ds.IFDESCR, ds.IFSPEED, ds.IFINOCTETS, ds.IFOUTOCTETS,ds.INOCTETSSPEED,ds.INPKTSSPEED,ds.OUTOCTETSSPEED, ds.OUTPKTSSPEED, ds.DATA_CHECK_TIME,st.ADDR "
+ "FROM di_switchport ds "
+ "LEFT JOIN node_table nt ON nt.seq_id=ds.seq_id "
+ "WHERE nt.node_state=0 AND ds.data_check_time_digital<" + end + " AND ds.data_check_time_digital>=" + start;
+ " left join system_table st on st.system_id = nt.system_id "
+ "WHERE nt.network_element_type = 1 and nt.node_state=0 AND ds.data_check_time_digital<" + end + " AND ds.data_check_time_digital>=" + start;
ArrayList<String> fields = new ArrayList<String>();
fields.add("node_ip");
fields.add("node_name");
@@ -94,6 +103,7 @@ public class NmsReportService {
fields.add("OUTOCTETSSPEED");
fields.add("OUTPKTSSPEED");
fields.add("DATA_CHECK_TIME");
fields.add("ADDR");
try {
ArrayList<Map<String, String>> dbSelect = dao.dbSelect(sql, fields);

View File

@@ -297,6 +297,7 @@ public class ThreadService {
public List<String []> detectDatasTimeoutCheck(SetInfo setInfo,Date startTime,String errorSeqIds){
List<String []> alarmInfoList = new ArrayList<String[]>();
String sql = null;
Integer delay = ThreadPoolConfig.DETEC_TIMEOUT_ALARM_PERIOD_DELAY;
//无效状态跳过
if(!(StringUtils.isNotEmpty(setInfo.getCheckState()) && "1".equals(setInfo.getCheckState())))return alarmInfoList;//监测设置的状态是否有效,无效则不检查,返回空列表
int periodTimes = ThreadPoolConfig.DETEC_TIMEOUT_ALARM_PERIOD_TIMES;
@@ -307,7 +308,7 @@ public class ThreadService {
sql="select nt0.seq_id,nt0.node_ip,nt0.NODE_TYPE from " +
"(select distinct nt.seq_id,nt.node_ip,nt.NODE_TYPE from node_table nt left join nodegroup_table ngt on ngt.group_id = nt.node_group_id where nvl(ngt.is_valid, '1') = '1' and nt.node_id in (-9999,"+setInfo.getNodeIpsId()+", -9999) and nt.node_state = 0 " + systemidSql + ") nt0" +
" where (not exists (select din.seq_id from detection_info_new din where nt0.seq_id = din.seq_id and din.detection_set_info_id = '"+setInfo.getId()+"') " +
" or exists (select din.seq_id from detection_info_new din where nt0.seq_id = din.seq_id and din.detection_set_info_id = '"+setInfo.getId()+"' and din.DATA_CHECK_TIME < sysdate - "+((setInfo.getCheckGap()==null?5:setInfo.getCheckGap())*periodTimes+5)+"/24/60 ))";
" or exists (select din.seq_id from detection_info_new din where nt0.seq_id = din.seq_id and din.detection_set_info_id = '"+setInfo.getId()+"' and din.DATA_CHECK_TIME < sysdate - "+((setInfo.getCheckGap()==null?5:setInfo.getCheckGap())*periodTimes+delay)+"/24/60 ))";
// sql = "select din.seq_id from detection_info_new din where " +
// "(din.seq_id not in(select distinct nt.seq_id from node_table nt left join nodegroup_table ngt on ngt.group_id = nt.node_group_id where nvl(ngt.is_valid,'1') = '1' and nt.node_id in (0,"+setInfo.getNodeIpsId()+",0) and nt.node_state =0) or (din.seq_id in(select distinct nt.seq_id from node_table nt left join nodegroup_table ngt on ngt.group_id = nt.node_group_id where nvl(ngt.is_valid,'1') = '1' and nt.node_id in (0,"+setInfo.getNodeIpsId()+",0) and nt.node_state =0) and sysdate - din.DATA_CHECK_TIME - "+((setInfo.getCheckGap()==null?5:setInfo.getCheckGap())*Constants.DETEC_TIMEOUT_ALARM_PERIOD_TIMES+5)+"/24/60> 0 ) )"+
// " and din.detection_set_info_id = "+setInfo.getId();
@@ -326,7 +327,7 @@ public class ThreadService {
sql="select nt0.seq_id,nt0.node_ip,nt0.NODE_TYPE from " +
"(select distinct nt.seq_id,nt.node_ip,nt.NODE_TYPE from node_table nt left join nodegroup_table ngt on ngt.group_id = nt.node_group_id where nvl(ngt.is_valid, '1') = '1' and nt.node_group_id in ("+ids+") and nt.node_state = 0 " + systemidSql + ") nt0" +
" where (not exists (select din.seq_id from detection_info_new din where nt0.seq_id = din.seq_id and din.detection_set_info_id = '"+setInfo.getId()+"') " +
" or exists (select din.seq_id from detection_info_new din where nt0.seq_id = din.seq_id and din.detection_set_info_id = '"+setInfo.getId()+"' and din.DATA_CHECK_TIME < sysdate - "+((setInfo.getCheckGap()==null?5:setInfo.getCheckGap())*periodTimes+5)+"/24/60 ))";
" or exists (select din.seq_id from detection_info_new din where nt0.seq_id = din.seq_id and din.detection_set_info_id = '"+setInfo.getId()+"' and din.DATA_CHECK_TIME < sysdate - "+((setInfo.getCheckGap()==null?5:setInfo.getCheckGap())*periodTimes+delay)+"/24/60 ))";
/* sql="select nt0.seq_id,nt0.node_ip,nt0.NODE_TYPE from " +
"(select distinct nt.seq_id,nt.node_ip,nt.NODE_TYPE from node_table nt left join nodegroup_table ngt on ngt.group_id = nt.node_group_id where nvl(ngt.is_valid, '1') = '1' and nt.node_group_id in (select nt.group_id from NODEGROUP_TABLE nt where nt.leaf_group = 1 start with nt.group_id in (-9999,"+setInfo.getNodeGroupsId()+", -9999) connect by prior nt.group_id = nt.parent_group_id) and nt.node_state = 0) nt0" +
" where (not exists (select din.seq_id from detection_info_new din where nt0.seq_id = din.seq_id and din.detection_set_info_id = '"+setInfo.getId()+"') " +
@@ -903,7 +904,7 @@ public class ThreadService {
diStmt.setObject(14, alarms[10]);
String idstr=computeId(alarms[5], alarms[1], alarms[0]);
Long id =Long.parseLong(idstr);
System.out.println("id -> " + id);
// System.out.println("id -> " + id);
diwStmt.setObject(1, id);
diStmt.setObject(1, id);
@@ -1230,6 +1231,7 @@ public class ThreadService {
// publicInfo.put("notice_flag".toLowerCase(), "1");// 1已发送 0未发送
//-- 获取ID
//2018年12月1日20:45:42 id 改為 主鍵自增
ArrayList<String> fields = new ArrayList<String>();
String searchIdSql = "select seq_detection_info.nextval id from dual";
fields.add("id");

View File

@@ -5,10 +5,16 @@
#jdbc.username=nms
#jdbc.password=nms
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://10.0.6.247:3306/nms?useUnicode=true&characterEncoding=utf-8&useOldAliasMetadataBehavior=true
jdbc.username=nms
jdbc.password=nms
jdbc.url=jdbc:mysql://10.0.5.4:8066/nms?useUnicode=true&characterEncoding=utf-8&useOldAliasMetadataBehavior=true
jdbc.username=mycat
jdbc.password=ceiec2018!
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://127.0.0.1:3306/nms?useUnicode=true&characterEncoding=utf-8&useOldAliasMetadataBehavior=true
#jdbc.username=nms
#jdbc.password=nms
#jdbc.driver=org.gjt.mm.mysql.Driver
#jdbc.driver=com.mysql.jdbc.Driver

View File

@@ -1,4 +1,4 @@
log4j.rootLogger=error,stdout,logfile
log4j.rootLogger=debug,stdout,logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] [%t] - <%m>%n
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

View File

@@ -1,4 +1,3 @@
validate_user=true
defaultPageSize=30
##--email user address
@@ -10,9 +9,9 @@ email.password = wwr@intranet
##--
email.host = 10.0.6.100
#file save path
uploadServerPath=D:/Java/apache-tomcat-7.0.61-windows-x86/webapps/nmsweb/download/
common.ssl.ks = C\:\\Users\\Administrator\\git\\nmsweb\\src\\conf\\ssl\\client_ks
common.ssl.ts = C\:\\Users\\Administrator\\git\\nmsweb\\src\\conf\\ssl\\client_ts
uploadServerPath=D:/Software/apache-tomcat-7.0.77/wtpwebapps/nmsweb/download/
common.ssl.ks = E:\\WorkSpace\\nmsweb\\src\\conf\\ssl\\client_ks
common.ssl.ts = E:\\WorkSpace\\nmsweb\\src\\conf\\ssl\\client_ts
#--
common.single.socket.port = 60702
common.ssl.socket.port = 60703
@@ -25,69 +24,72 @@ common.date.format =yyyy-MM-dd HH\:mm\:ss
#---CreateJavaBean-------
packName = osDomains
toPath= D:/Java/apache-tomcat-7.0.61-windows-x86/webapps/nmsweb/src/osDomains/
toPath= D:/Software/apache-tomcat-7.0.77/wtpwebapps/nmsweb/src/osDomains/
#----class property
snmpDir = D:/Java/apache-tomcat-7.0.61-windows-x86/webapps/nmsweb/download2/
snmpDir = D:/Software/apache-tomcat-7.0.77/wtpwebapps/nmsweb/download2/
defaultSingleLogin=0
defaultRoomMaxRows =20
defaultRoomMaxCols =20
detec.switch.str = switchport
detec.systeminfo.str = systeminfo
#\u8d85\u5468\u671f\uff0c\u9ed8\u8ba4\u7d27\u6025\u72b6\u6001:0\uff1a\u7d27\u6025\uff1b1\uff1a\u975e\u7d27\u6025
#超周期,默认紧急状态:0紧急1非紧急
detec.timeout.police.emergent = 0
#\u8d85\u5468\u671f\uff0c\u9ed8\u8ba4\u544a\u8b66\u7ea7\u522b
#超周期,默认告警级别
detec.timeout.police.level = 0
#\u76d1\u6d4b\u6570\u636e\u8bbe\u7f6e\u544a\u8b66\u65f6\uff0c\u5bf9\u4e8e\u6307\u5b9a\u591a\u4e2a\u6807\u8bc6\u7b26\uff08\u5982\u591a\u4e2a\u76d8\u7b26\u3001\u591a\u4e2aCPU\u3001\u591a\u4e2a\u7f51\u5361\uff09\u7684\u5206\u9694\u7b26 --\u6682\u65f6\u672a\u4f7f\u7528
#监测数据设置告警时对于指定多个标识符如多个盘符、多个CPU、多个网卡的分隔符 --暂时未使用
alarm.set.marker.separator=|
#\u9ed8\u8ba4\u67e5\u8be2\u5386\u53f2\u76d1\u6d4b\u6570\u636e\u7684\u65f6\u95f4\uff1a\u5355\u4f4d\u5929
#默认查询历史监测数据的时间:单位天
default.search.history.detect.data.day=3
#\u4efb\u52a1\u914d\u7f6e-\u603b\u4f53\u6bd4\u4f8b\u56fe\u4e2d,\u8868\u683c\u8282\u70b9\u8d85\u8fc7\u4e00\u9875\u65f6\u7684\u53e0\u52a0\u5355\u4f4d,\u9ed8\u8ba4\u4e3a5
#任务配置-总体比例图中,表格节点超过一页时的叠加单位,默认为5
#nmstaskmanager.resultchart.foldunit=5
#\u5de5\u5177\u7ba1\u7406:\u4e0a\u4f20\u4e0b\u8f7d\u63d2\u4ef6\u7684\u8def\u5f84\u0084
serverPath=/home/nms/apache-tomcat-7.0.59/webapps/NMSNMSA
#工具管理:上传下载插件的路径„
serverPath=D:\Software\apache-tomcat-7.0.77\wtpwebapps/webapps/NMSNMSA
uploadFilePath=/download/
#\u6570\u636e\u5e93\u7c7b\u578b\uff1aoracle/mysql
#数据库类型:oracle/mysql
db_type=mysql
config.update.flag = 6
#\u8df3\u8f6c\u7cfb\u7edf\u7684url
#跳转系统的url
system.url=http://10.0.6.247:3000/login
target.system.user=admin
target.system.pwd=12345678
#\u76d1\u6d4b\u5165\u5e93\u603b\u63a7\u7ebf\u7a0b\u662f\u5426\u542f\u7528\uff0c1\uff1a\u542f\u7528
#监测入库总控线程是否启用1启用
flag.detect.insert.control=0
#\u76d1\u6d4b\u5165\u5e93\u603b\u63a7 \u8f6e\u8be2\u95f4\u9694 \uff0c\u5355\u4f4d s
#监测入库总控 轮询间隔 ,单位 s
detect.insert.control.period=60
#\u901a\u77e5\u76d1\u6d4b\u6570\u636e\u5165\u5e93\uff0c\u91ca\u653e\u9501\u8d85\u65f6\u65f6\u95f4\uff0c\u5355\u4f4d\uff1as
#通知监测数据入库,释放锁超时时间,单位:s
detect.insert.timeout=60
#\u7ebf\u7a0b\u6c60\u5927\u5c0f
#线程池大小
executor_socket_thread_size =10
#\u5468\u671f\u7ebf\u7a0b\u6c60\u5927\u5c0f
#周期线程池大小
executor_scheduled_thread_size=5
dc.handshake.start=30
#\u4e0edc\u63e1\u624b\u95f4\u9694
#与dc握手间隔
dc.handshake.period=300
detec.timeout.check.period=120
#\u662f\u5426\u542f\u52a8\u76d1\u6d4b\u8d85\u65f6\u68c0\u67e5\u5165\u5e93
#超时告警 延迟时间,为了防止 国家中心,分中心 两个web 同时判断生成多条 记录
detec.timeout.alarm.period.delay=5
#是否启动监测超时检查入库1开启非1关闭
flag_detec_timeout=1
#\u90ae\u4ef6\u5468\u671f
#邮件周期
mailing_period=120
use_mycat=true
consul.system.url=http://10.0.6.247:8787/thirdProjectLogin
nextval_function_name=nextval
currval_function_name=currval
nation.role.jsbh=224
#\u82e5\u7cfb\u7edf\u4e3arc\u7cfb\u7edf\uff0c\u914d\u7f6e\u6b64\u914d\u7f6e\uff0c\u83dc\u5355\u663e\u793a\u4e3arc\u7684\u83dc\u5355 \u503c\u4e3a\u5206\u4e2d\u5fc3\u89d2\u8272id
#若系统为rc系统配置此配置菜单显示为rc的菜单 值为分中心角色id
#region.role.jsbh=21
#\u5206\u4E2D\u5FC3\u7684id, \u56FD\u5BB6\u4E2D\u5FC3\u586B-1
system.id=100003
#分中心ID国家中心填写 -1填写的内容为 分中心对应的 system_table 的id后台只会判断当前业务系统下的 所有节点
system.id=-1
dept.mk.id=280
@@ -97,11 +99,13 @@ nms.report.open=0
nms.report.status.interval=300
nms.report.port.interval=300
nms.report.rule.interval=900
#nms握手监测设置id
nms.status.setId=7
nms.status.url=http\://192.168.11.64\:8080/galaxy-service/service/nms/v1/saveServerStatus
nms.port.url=http\://192.168.11.64\:8080/galaxy-service/service/nms/v1/trafficNetflowPortInfo
nms.rule.url=http\://192.168.11.64\:8080/galaxy-service/service/nms/v1/saveNmsDiRule
nms.status.url=http://10.0.7.21/galaxy-service//service/nms/v1/saveServerStatus
nms.port.url=http://10.0.7.21/galaxy-service/service/nms/v1/trafficNetflowPortInfo
nms.rule.url=http://10.0.7.21/galaxy-service/service/nms/v1/saveNmsDiRule
#默认节点组id
default.nodeGroupId=100000
prefabricate.view=100000,100003,100004,100005,100006,100007,100033,100035,100037
#下发,修改监测等是否直接通过 socket 通知dc
dc.notice=0

View File

@@ -64,6 +64,8 @@
</bean>
<bean id="mycatInterceptor" class="nis.nms.persistence.MycatInterceptor"/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="mappingDirectoryLocations">
@@ -81,6 +83,7 @@
<prop key="hibernate.current_session_context_class">thread</prop>
</props>
</property>
<property name="entityInterceptor" ref="mycatInterceptor"></property>
</bean>

View File

@@ -50,9 +50,6 @@ public class I18n {
}
}
// System.out.println(" replace : "+ group +" --> " + replacement);
if(replacement != null) {
replacement = Matcher.quoteReplacement(replacement);
}
matcher.appendReplacement(sb, replacement== null ? group : replacement);
}
matcher.appendTail(sb);
@@ -92,9 +89,6 @@ public class I18n {
}
}
// System.out.println(" replace : "+ group +" --> " + replacement);
if(replacement != null) {
replacement = Matcher.quoteReplacement(replacement);
}
matcher.appendReplacement(sb, replacement== null ? group : replacement);
}
matcher.appendTail(sb);
@@ -118,5 +112,6 @@ public class I18n {
return pro;
}
}

View File

@@ -1173,7 +1173,7 @@ public class HibernateGeneralDaoImpl<T> extends HibernateDaoSupport implements H
boolean resu = true;
try {
con.setAutoCommit(false);
cs = con.prepareCall("{call "+proName+"(?,?,?)}");
cs = con.prepareCall("/*#mycat:db_type=master*/{call "+proName+"(?,?,?)}");
cs.setString(1,tableName);
cs.setString(2,filedAndType);
cs.setString(3, fileds);
@@ -1201,7 +1201,7 @@ public class HibernateGeneralDaoImpl<T> extends HibernateDaoSupport implements H
boolean resu = true;
try {
con.setAutoCommit(false);
cs = con.prepareCall("{call "+proName+"(?,?,?)}");
cs = con.prepareCall("/*#mycat:db_type=master*/{call "+proName+"(?,?,?)}");
cs.setString(1,tableName);
cs.setString(2, fileds);
cs.execute();

View File

@@ -0,0 +1,32 @@
package nis.nms.persistence;
import java.util.regex.Pattern;
import org.hibernate.EmptyInterceptor;
/**
* mycat 拦截器修改select语句强制走主库
* @author ThinkPad
*
*/
public class MycatInterceptor extends EmptyInterceptor {
private static final long serialVersionUID = 1L;
static Pattern nextValPattern = Pattern.compile(".*\\s+nextval\\s*\\(.*",Pattern.CASE_INSENSITIVE);
static Pattern currValPattern = Pattern.compile(".*\\s+currval\\s*\\(.*",Pattern.CASE_INSENSITIVE);
public static String interceptSQL(String sql) {
//包含currvalnextval function 的sql语句强制走 主库
if(nextValPattern.matcher(sql).matches() || currValPattern.matcher(sql).matches()) {
sql ="/*#mycat:db_type=master*/" + sql;
}
return sql;
}
@Override
public String onPrepareStatement(String sql) {
sql = interceptSQL(sql);
return super.onPrepareStatement(sql);
}
}

View File

@@ -259,6 +259,10 @@ public class OracleToMysql {
m.appendReplacement(sb, temp.toString());
}
m.appendTail(sb);
// if(Constant.USE_MYCAT) {
// sb.insert(0, "/*#mycat:db_type=master*/");
// logger.debug(String.format("改写mycat强制走主库,sql -> %s", sb.toString()));
// }
return sb.toString();
}
@@ -285,6 +289,10 @@ public class OracleToMysql {
m.appendReplacement(sb, temp.toString());
}
m.appendTail(sb);
// if(Constant.USE_MYCAT) {
// sb.insert(0, "/*#mycat:db_type=master*/");
// logger.debug(String.format("改写mycat强制走主库,sql -> %s", sb.toString()));
// }
return sb.toString();
}

View File

@@ -6,10 +6,14 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -43,6 +47,7 @@ public class ConnectionOracle {
private String dbType;
public static void main(String []aregs) {
ConnectionOracle oracle = new ConnectionOracle();
}
public static ConnectionOracle getConnection() throws Exception {
return new ConnectionOracle();
@@ -111,12 +116,28 @@ public class ConnectionOracle {
}
selectSql = OracleToMysql.trans(selectSql);
dbResultSet = sta.executeQuery(selectSql);
ResultSetMetaData metaData = dbResultSet.getMetaData();
Map<String,Integer> colType = new HashMap<String,Integer>();
for(int i = 0;i<metaData.getColumnCount();i++) {
colType.put(metaData.getColumnLabel(i+1), metaData.getColumnType(i+1));
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 循环取值
while (dbResultSet.next()) {
recordInfo = new HashMap<String, String>();
for (int i = 0; i < fields.size(); ++i)
recordInfo.put((String) fields.get(i), dbResultSet
.getString(fields.get(i)));
for (int i = 0; i < fields.size(); ++i) {
Integer type = colType.get(fields.get(i));
if(type == 93) {
Timestamp timestamp = dbResultSet.getTimestamp((String) fields.get(i));
if(timestamp != null) {
recordInfo.put((String) fields.get(i), sdf.format(new Date(timestamp.getTime())));
}else {
recordInfo.put((String) fields.get(i), null);
}
}else {
recordInfo.put((String) fields.get(i), dbResultSet.getString(fields.get(i)));
}
}
selectResult.add(recordInfo);
}
dbResultSet.close(); // 断开结果集
@@ -150,12 +171,28 @@ public class ConnectionOracle {
}
}
dbResultSet = ps.executeQuery();
ResultSetMetaData metaData = dbResultSet.getMetaData();
Map<String,Integer> colType = new HashMap<String,Integer>();
for(int i = 0;i<metaData.getColumnCount();i++) {
colType.put(metaData.getColumnLabel(i+1), metaData.getColumnType(i+1));
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 循环取值
while (dbResultSet.next()) {
recordInfo = new HashMap<String, String>();
for (int i = 0; i < fields.size(); ++i)
recordInfo.put((String) fields.get(i), dbResultSet
.getString(fields.get(i)));
for (int i = 0; i < fields.size(); ++i) {
Integer type = colType.get(fields.get(i));
if(type == 93) {
Timestamp timestamp = dbResultSet.getTimestamp((String) fields.get(i));
if(timestamp != null) {
recordInfo.put((String) fields.get(i), sdf.format(new Date(timestamp.getTime())));
}else {
recordInfo.put((String) fields.get(i), null);
}
}else {
recordInfo.put((String) fields.get(i), dbResultSet.getString(fields.get(i)));
}
}
selectResult.add(recordInfo);
}
dbResultSet.close(); // 断开结果集
@@ -189,6 +226,10 @@ public class ConnectionOracle {
dbResultSet = ps.executeQuery();
// 循环取值
while (dbResultSet.next()) {
selectResult.add(dbResultSet.getString(1));
}
dbResultSet.close(); // 断开结果集

View File

@@ -199,5 +199,9 @@ public class Constant {
public static final String NEXTVAL_FUNCTION_NAME = StringUtils.isNotBlank(rb.getString("nextval_function_name"))?rb.getString("nextval_function_name"):"nextval";
public static final String CURRVAL_FUNCTION_NAME = StringUtils.isNotBlank(rb.getString("currval_function_name"))?rb.getString("currval_function_name"):"currval";
/**
* 是否启用 mycat nextval,currval 需要改写 sql
*/
public static final boolean USE_MYCAT = StringUtils.isNotBlank(rb.getString("use_mycat"))?Boolean.valueOf(rb.getString("use_mycat")):true;
}

View File

@@ -309,18 +309,23 @@ public class LoginAction extends BaseAction {
this.getRequest().getSession().setAttribute(Constant.SESSION_SYSTEM_LOGIN_NAME, "ALL");
return "ok";
} else {
String systemId = Constant.CURRENT_SYSTEM_ID;
//国家中心
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");
+ yhbh.trim() + "' and st.system_state = 0 and xyji.type=1 and xjj.zxbz=0 " // 业务系统启用+角色类型为用户组+用户组有效
+ (StringUtils.isNotBlank(systemId)&& "-1".equals(systemId.trim()) ? "" : " and st.system_Id = "+ systemId)
+ " 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) {
if (list != null && list.size() > 0 && StringUtils.isNotBlank(systemId) && "-1".equals(systemId.trim())) {
for (String obj : list) {
if (StringUtils.isNotBlank(obj)) {
if ((Constants.NATION_ROLE.trim()).equals(obj.trim())) {
@@ -517,7 +522,7 @@ public class LoginAction extends BaseAction {
try {
String sql = "";
String regionRoleId = Constants.REGION_ROLE;
if (!"admin".equals(yhbh)&&StringUtils.isNotBlank(regionRoleId) && !regionRoleId.equals("-1")) {
if (StringUtils.isNotBlank(regionRoleId) && !regionRoleId.equals("-1")) {
sql = "SELECT pid,id,mkmc,mkms,mkurl,mktb,iconimage,mktype FROM XtMkJbxx WHERE id IN(SELECT mkbh FROM XtJsMkIndex WHERE jsbh = "
+ regionRoleId + ")";
} else {

View File

@@ -44,14 +44,14 @@ public class QueryMenuTreeAction {
try {
StringBuffer hql = new StringBuffer();
if (yhmc != null
if(StringUtils.isNotBlank(regionRoleId)&&!regionRoleId.equals("-1")){
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 ="+regionRoleId+")");
}else 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(StringUtils.isNotBlank(regionRoleId)&&!regionRoleId.equals("-1")){
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 ="+regionRoleId+")");
}else {
if (yhbh != null) {
if(Constant.F_BUTTON_AUTHER){

View File

@@ -173,6 +173,9 @@ public class MonitorDataAction extends BaseAction {
if (!StringUtil.isBlank(requestType) && requestType.equals("topo")) {
queryMonitorDataInfoNewForTopo();
resultpage = "queryMonitorDataInfoChild";
} else if(!StringUtil.isBlank(requestType) && requestType.equals("newTopo")){
queryMonitorDataInfoNewForTopoDetail();
resultpage = "queryMonitorDataInfoNewTopo";
} else {
this.queryServerMonitorDataInfoNew();// 服务器监测-自动加载
resultpage = "queryServerMonitorDataInfoChild";
@@ -1007,7 +1010,7 @@ public class MonitorDataAction extends BaseAction {
try {
String[] linStrings = lines.split(",");// 选择的端口,可能是多个
String temp = "";
String source = "select max(to_char(data_check_time,'yyyy-mm-dd HH24:mi')) maxTime," + sortFiledType[0]
/*String source = "select max(to_char(data_check_time,'yyyy-mm-dd HH24:mi')) maxTime," + sortFiledType[0]
+ " from " + checkTypeInfo.getTableName() + " t where " + metadata.getFiledName() + " is not null"
// +" and t.data_check_time >= trunc(sysdate-30)"
+ " and t.detection_info_id in "
@@ -1020,6 +1023,38 @@ public class MonitorDataAction extends BaseAction {
} else {
source += " and t.data_check_time >= trunc(sysdate-1) ";
}
if (sortFiledType[1].toString().equals("NUMBER") || sortFiledType[1].toString().equals("Number")) {
temp = lines.substring(0, lines.length() - 1);
source += " and " + sortFiledType[0] + " in (" + temp + ") group by " + sortFiledType[0]
+ " order by maxTime desc";
} else if (sortFiledType[1].toString().indexOf("VARCHAR2") != -1) {
for (int i = 0; i < linStrings.length; i++) {
temp += "'" + linStrings[i] + "',";
}
temp = temp.substring(0, temp.length() - 1);
source += " and " + sortFiledType[0] + " in (" + temp + ") group by " + sortFiledType[0]
+ " order by maxTime desc";
}*/
/*String source = "select max(to_char(t.data_check_time,'yyyy-mm-dd HH24:mi')) maxTime," + sortFiledType[0]
+ " from " + checkTypeInfo.getTableName() + " t,detection_info d where " + metadata.getFiledName() + " is not null"
// +" and t.data_check_time >= trunc(sysdate-30)"
+ " and t.detection_info_id =d.id "
+ " and d.detection_set_info_id=" + dsiId + " and d.seq_id = "
+ seqId;*/
/**
* 2018年12月6日17:50:54 fang 在 astana 优化
*/
String source = "select max(to_char(t.data_check_time,'yyyy-mm-dd HH24:mi')) maxTime," + sortFiledType[0]
+ " from " + checkTypeInfo.getTableName() + " t where " + metadata.getFiledName() + " is not null "
// +" and t.data_check_time >= trunc(sysdate-30)"
+ " and t.detection_set_info_id=" + dsiId + " and t.seq_id = "
+ seqId;
if (null != startTime && !startTime.equals("") && null != endTime && !endTime.equals("")) {
source += " and to_char(data_check_time,'yyyy-mm-dd')>= '" + startTime
+ "' and to_char(data_check_time,'yyyy-mm-dd')<='" + endTime + "'";
} else {
source += " and t.data_check_time >= trunc(sysdate-1) ";
}
if (sortFiledType[1].toString().equals("NUMBER") || sortFiledType[1].toString().equals("Number")) {
temp = lines.substring(0, lines.length() - 1);
source += " and " + sortFiledType[0] + " in (" + temp + ") group by " + sortFiledType[0]
@@ -1032,12 +1067,11 @@ public class MonitorDataAction extends BaseAction {
source += " and " + sortFiledType[0] + " in (" + temp + ") group by " + sortFiledType[0]
+ " order by maxTime desc";
}
List lastList = this.commonService.executeSQL(source);
// ------------------以上确定最后一个数据点----------------------------
if (lastList != null && lastList.size() > 0) {
Object[] row = (Object[]) lastList.get(0);
String lastSource = "select * from ( select to_char(data_check_time,'yyyy-mm-dd HH24:mi'),"
/*String lastSource = "select * from ( select to_char(data_check_time,'yyyy-mm-dd HH24:mi'),"
+ metadata.getFiledName() + " from " + checkTypeInfo.getTableName() + " t where "
+ metadata.getFiledName() + " is not null"
// +" and t.data_check_time >= trunc(sysdate-30)"
@@ -1055,6 +1089,32 @@ public class MonitorDataAction extends BaseAction {
lastSource += " and " + sortFiledType[0] + " = " + row[1] + " order by data_check_time desc) ttt ";
} else if (sortFiledType[1].toString().indexOf("VARCHAR2") != -1) {
lastSource += " and " + sortFiledType[0] + " = '" + row[1] + "' order by data_check_time desc) ttt ";
}*/
/*String lastSource = "select to_char(t.data_check_time,'yyyy-mm-dd HH24:mi'),"
+ metadata.getFiledName() + " from " + checkTypeInfo.getTableName() + " t,detection_info d where "
+ metadata.getFiledName() + " is not null"
// +" and t.data_check_time >= trunc(sysdate-30)"
+ " and t.detection_info_id = d.id "
+ "and d.detection_set_info_id=" + dsiId
+ " and d.seq_id = " + seqId;*/
/**
* 2018年12月6日17:52:54 fang 在 astana 优化
*/
String lastSource = "select to_char(t.data_check_time,'yyyy-mm-dd HH24:mi'),"
+ metadata.getFiledName() + " from " + checkTypeInfo.getTableName() + " t where "
+ metadata.getFiledName() + " is not null "
+ "and t.detection_set_info_id=" + dsiId
+ " and t.seq_id = " + seqId;
if (null != startTime && !startTime.equals("") && null != endTime && !endTime.equals("")) {
lastSource += " and to_char(data_check_time,'yyyy-mm-dd')>= '" + startTime
+ "' and to_char(data_check_time,'yyyy-mm-dd')<='" + endTime + "'";
} else {
lastSource += " and t.data_check_time >= trunc(sysdate-1) ";
}
if (sortFiledType[1].toString().equals("NUMBER") || sortFiledType[1].toString().equals("Number")) {
lastSource += " and " + sortFiledType[0] + " = " + row[1] + " order by t.data_check_time desc ";
} else if (sortFiledType[1].toString().indexOf("VARCHAR2") != -1) {
lastSource += " and " + sortFiledType[0] + " = '" + row[1] + "' order by t.data_check_time desc ";
}
/* lastSource += " where rownum < 21"; */
@@ -1173,20 +1233,21 @@ public class MonitorDataAction extends BaseAction {
String[] cbStrings = checkLins(metadata, checkTypeInfo, sortFiledType, dsiId, seqId, linStrings[i]);
String source = "";
if (linStrings[i].equals(cbStrings[0])) {// 这是最后的那个
source = "select * from ( select to_char(data_check_time,'yyyy-mm-dd HH24:mi') checkTime,"
/*source = "select * from ( select to_char(data_check_time,'yyyy-mm-dd HH24:mi') checkTime,"
+ metadata.getFiledName() + " from " + checkTypeInfo.getTableName() + " t where "
+ metadata.getFiledName() + " is not null"
// +
// " and t.data_check_time >=
// to_date(to_char((sysdate-4),'yyyy-mm-dd'),'yyyy-mm-dd
// hh24:mi')"+
// +" and t.data_check_time >=
// trunc(sysdate-30)"
// + " and rownum <= 20"
+ " and t.detection_info_id in "
+ "(select d.id from detection_info d where d.detection_set_info_id=" + dsiId
+ " and d.seq_id = " + seqId + ")";
+ " and d.seq_id = " + seqId + ")";*/
/**
* 2018年12月6日18:22:39 fang 在astana 优化
*/
source = "select * from ( select to_char(data_check_time,'yyyy-mm-dd HH24:mi') checkTime,"
+ metadata.getFiledName() + " from " + checkTypeInfo.getTableName() + " t where "
+ metadata.getFiledName() + " is not null "
+ " and t.detection_set_info_id=" + dsiId
+ " and t.seq_id = " + seqId;
if (null != startTime && !startTime.equals("") && null != endTime && !endTime.equals("")) {
source += " and to_char(data_check_time,'yyyy-mm-dd')>= '" + startTime
+ "' and to_char(data_check_time,'yyyy-mm-dd')<='" + endTime + "'";
@@ -1209,15 +1270,17 @@ public class MonitorDataAction extends BaseAction {
// source += " where rownum < 21 ";
// }
} else {
/*source = "select * from ( select to_char(data_check_time,'yyyy-mm-dd HH24:mi') checkTime,"
+ metadata.getFiledName() + " from " + checkTypeInfo.getTableName() + " t where "
+ metadata.getFiledName() + " is not null"
+ " and t.detection_info_id in "
+ "(select d.id from detection_info d where d.detection_set_info_id=" + dsiId
+ " and d.seq_id = " + seqId + ")";*/
source = "select * from ( select to_char(data_check_time,'yyyy-mm-dd HH24:mi') checkTime,"
+ metadata.getFiledName() + " from " + checkTypeInfo.getTableName() + " t where "
+ metadata.getFiledName() + " is not null"
// +" and t.data_check_time >=
// trunc(sysdate-30)"
+ " and t.detection_info_id in "
+ "(select d.id from detection_info d where d.detection_set_info_id=" + dsiId
+ " and d.seq_id = " + seqId + ")";
+ " and t.detection_set_info_id=" + dsiId
+ " and t.seq_id = " + seqId;
if (null != startTime && !startTime.equals("") && null != endTime && !endTime.equals("")) {
source += " and to_char(data_check_time,'yyyy-mm-dd')>= '" + startTime
+ "' and to_char(data_check_time,'yyyy-mm-dd')<='" + endTime + "'";
@@ -1300,14 +1363,19 @@ public class MonitorDataAction extends BaseAction {
+ " is not null and seq_id=" + seqId + " and DETECTION_SET_INFO_ID= "+dsiId+" order by " + sortFiledType[0].toString();
dataList = this.commonService.executeSQL(getAllSort);
if (dataList != null && dataList.size() > 0) {
String source = "select * from (select to_char(data_check_time,'yyyy-mm-dd HH24:mi') checkTime,"
/*String source = "select * from (select to_char(data_check_time,'yyyy-mm-dd HH24:mi') checkTime,"
+ metadata.getFiledName() + " from " + checkTypeInfo.getTableName() + " t where "
+ metadata.getFiledName() + " is not null"
// + " and t.data_check_time >=
// trunc(sysdate-30)"
+ " and t.detection_info_id in "
+ "(select d.id from detection_info d where d.detection_set_info_id=" + dsiId
+ " and d.seq_id = " + seqId + ")";
+ " and d.seq_id = " + seqId + ")";*/
String source = "select * from (select to_char(data_check_time,'yyyy-mm-dd HH24:mi') checkTime,"
+ metadata.getFiledName() + " from " + checkTypeInfo.getTableName() + " t where "
+ metadata.getFiledName() + " is not null"
+ " and t.detection_set_info_id=" + dsiId
+ " and t.seq_id = " + seqId;
if (null != startTime && !startTime.equals("") && null != endTime && !endTime.equals("")) {
source += " and to_char(data_check_time,'yyyy-mm-dd')>= '" + startTime
@@ -2867,7 +2935,7 @@ public class MonitorDataAction extends BaseAction {
String linesLink = linkToString(linStrings, ",", "'");// lines要在checkLins方法后再做加单引号的处理因为checkLins方法里单个处理了
// for (int i = 0; i < linStrings.length; i++) {
String source = "";
source = "select * from ( select data_check_time_digital ," + specialColumn + " from "
source = "select data_check_time_digital ," + specialColumn + " from "
+ checkTypeInfo.getTableName() + " t where " + metadata.getFiledName() + " is not null"
+ " and t.detection_set_info_id=" + dsiId + " and t.seq_id = " + seqId + " ";
@@ -2898,7 +2966,7 @@ public class MonitorDataAction extends BaseAction {
* " order by data_check_time_digital desc) where rownum < 21 order by data_check_time_digital asc"
* ;
*/
source += " order by data_check_time_digital desc) tttt ";
//source += " order by data_check_time_digital asc ";
// @2018年4月10日18:45:00 fang 修改rownum 适配 mysql
if (Constant.IS_MYSQL) {

View File

@@ -134,8 +134,10 @@ public class TopoShowAction extends BaseAction
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.VALID=1 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 "
+ "left join detection_set_info dsi on diw.detection_set_info_id=dsi.id "
+ "where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 and diw.VALID=1 "
+ "and nt.NODE_STATE = 0 "
+ "and dsi.detection_set_state=1 "
+ "and nt.node_group_id in ("+gids+")"
+ ") alramNode,"
+ "(SELECT count(DISTINCT t.node_ip) from node_table t WHERE "
@@ -144,8 +146,10 @@ public class TopoShowAction extends BaseAction
}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.VALID=1 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 "
+ "left join detection_set_info dsi on diw.detection_set_info_id=dsi.id "
+ "where diw.DETECTIONED_STATE<>1 AND diw.police_emergent=0 and diw.VALID=1 "
+ "and nt.NODE_STATE = 0 "
+ "and dsi.detection_set_state=1 "
+ "and nt.node_group_id in ("+gids+")"
+ ") alramNode,"
+ "(SELECT count(DISTINCT t.node_ip) from node_table t WHERE t.system_id="
@@ -280,26 +284,26 @@ public class TopoShowAction extends BaseAction
nibSql = " select count(distinct diw.seq_id)"
+ " from detection_info_new diw"
+ " left join node_table nt on nt.seq_id = diw.seq_id "
+ " LEFT JOIN DETECTION_SET_INFO dst ON dst.id=diw.DETECTION_SET_INFO_ID "
+ " LEFT JOIN node_lattice_table nlt ON nlt.node_seq=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 dst.DETECTION_SET_STATE=1 AND nlt.node_seq IS NOT NULL AND nlt.node_box_id = " + boxId
+ " 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 + ")";
+ groupId;
}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 "
+ " LEFT JOIN DETECTION_SET_INFO dst ON dst.id=diw.DETECTION_SET_INFO_ID "
+ " LEFT JOIN node_lattice_table nlt ON nlt.node_seq=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 dst.DETECTION_SET_STATE=1 AND nlt.node_seq IS NOT NULL AND nlt.node_box_id = " + boxId
+ " 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 + ")";
+ groupId;
}
try
@@ -333,15 +337,17 @@ public class TopoShowAction extends BaseAction
{
String sql = null;
if(this.getAdminMark()){
sql = "SELECT distinct nl.node_seq from node_lattice_table nl WHERE nl.node_box_id="
sql = "SELECT distinct nl.node_seq from node_lattice_table nl "
+ "LEFT JOIN node_table nt ON nl.node_seq=nt.seq_id "
+ "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 + ")";
+ " AND 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="
sql = "SELECT distinct nl.node_seq from node_lattice_table nl "
+ "LEFT JOIN node_table nt ON nl.node_seq=nt.seq_id "
+ "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 + ")";
+ " AND nt.node_state=0 AND nt.node_group_id=" + groupId + " and nt.system_id=" + getSystemID();
}
List list = commonService.executeSQL(sql);
if (list.size() > 0)

View File

@@ -3,7 +3,9 @@ package nis.nms.web.actions.sysManage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -18,7 +20,9 @@ import nis.nms.domains.DetectionSetInfo;
import nis.nms.domains.NodeTable;
import nis.nms.domains.NodegroupTable;
import nis.nms.domains.SystemTable;
import nis.nms.domains.TopoImg;
import nis.nms.domains.TopoInfo;
import nis.nms.domains.TopoLineInfo;
import nis.nms.domains.TopoManageInfo;
import nis.nms.domains.TopoNodeInfo;
import nis.nms.service.CommonService;
@@ -37,6 +41,8 @@ public class TopoManageAction extends BaseAction{
private List<TopoInfo> allTopoInfoList;
private List<SystemTable> sysList;
private List<TopoNodeInfo> topoNodeList;
private List<TopoLineInfo> topoLineList;
private List<TopoImg> topoImgList;
private List<Integer> typeList;
private NodegroupTable nodegroupTable;
private NodeTable nodeTable;
@@ -44,20 +50,37 @@ public class TopoManageAction extends BaseAction{
private Long topoInfoId;
private Long topoNodeId;
private Long topoNodeType;
private Long topoLineId;
private String groupIdShow; //节点组名称
private Long selectTopoInfoId; //节点类型为topo时 选择的topoId
private DetectionSetInfo detectionSetInfo;
private TopoNodeInfo topoNodeInfo;
private TopoLineInfo topoLineInfo;
private TopoManageInfo topoManageInfo;
private List<TopoManageInfo> topoManageInfos;
private Integer diffTopoFlag; //不同topo图标记 如果为0代表当前topo不是该业务系统的
@Override
public String executeAction() throws Exception {
String result=null;
try {
if(action.equals("query")) {
result=queryTopoManageIndex();
}else if(action.equals("modify")){
modifyTopoManage();
}else if(action.equals("removeTopoNode")){
removeTopoNode();
}else if(action.equals("removeTopoLine")) {
removeTopoLine();
}else if(action.equals("addTopoNode")) {
addTopoNode();
}else if(action.equals("addTopoLine")) {
addTopoLine();
}else if(action.equals("modifyTopoLine")) {
modifyTopoLine();
}else if(action.equals("modifyTopoNode")) {
modifyTopoNode();
}else if(action.equals("coverTopoManage")) {
coverTopoManage();
}else if(action.equals("copyTopoManage")) {
copyTopoManage();
}
} catch (Exception e) {
e.printStackTrace();
@@ -66,7 +89,7 @@ public class TopoManageAction extends BaseAction{
return result;
}
public String queryTopoManageIndex(){
/*public String queryTopoManageIndex(){
try {
//查询所有业务系统列表
sysList = this.commonService.find("from SystemTable where 1=1");
@@ -152,9 +175,193 @@ public class TopoManageAction extends BaseAction{
return null;
}
return "topoManageIndex";
}*/
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图片信息 展示在左侧拖拽栏
topoImgList=this.commonService.find("from TopoImg where 1=1");
//查询当前业务系统topo图列表
if(systemId==null){
systemId=sysList.get(0).getSystemId();
}
topoInfoList=this.commonService.find("from TopoInfo where 1=1 and systemId=?",systemId);
if(null != topoInfoList && topoInfoList.size()>0) {
if(topoInfoId==null){
topoInfoId=topoInfoList.get(0).getId();
}else if(!topoInfoId.equals(topoInfoList.get(0).getId())){
diffTopoFlag=0;
}
}else if(topoInfoId!=null) {
diffTopoFlag=0;
}
if(topoInfoId!=null) {
//查询当前业务下所有的topo节点
topoNodeList=this.commonService.find("from TopoNodeInfo where 1=1 and topoInfo.id=?", topoInfoId);
if(null!=topoNodeList&&topoNodeList.size()>0) {
topoManageInfos=new ArrayList<TopoManageInfo>();
for(TopoNodeInfo topoNodeInfo:topoNodeList) {
topoManageInfo=new TopoManageInfo();
topoManageInfo.setTopoNodeInfo(topoNodeInfo);
if(topoNodeInfo.getType()==2L){
List nodeTables = this.commonService.find("from NodeTable where 1=1 and node_id=?",topoNodeInfo.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(topoNodeInfo.getType()==1L){
List find = this.commonService.find("from NodegroupTable where 1=1 and id=?",topoNodeInfo.getTypeId());
nodegroupTable = (NodegroupTable) find.get(0);
topoManageInfo.setNodeGroupName(nodegroupTable.getGroupName());
topoManageInfo.setNodeGroupId(nodegroupTable.getGroupId());
}else if(topoNodeInfo.getType()==4L){
topoManageInfo.setTopoInfoId(topoNodeInfo.getTypeId());
}
topoManageInfos.add(topoManageInfo);
}
}
//查询当前业务下所有的topo连线
topoLineList=this.commonService.find("from TopoLineInfo where 1=1 and topoInfo.id=?", topoInfoId);
}
} catch (Exception e) {
logger.error(e.getStackTrace());
e.printStackTrace();
return null;
}
return "topoManageIndex";
}
public void modifyTopoManage(){
// topo图拷贝
public void copyTopoManage() {
try {
String topoName = this.getRequest().getParameter("newTopoName");
TopoInfo newTopo=null;
List<TopoInfo> topoInfos = this.commonService.find("from TopoInfo where 1=1 and systemId=?", systemId);
if(null!=topoInfos&&topoInfos.size()>0) {
newTopo=(TopoInfo) topoInfos.get(0);
newTopo.setName(topoName);
this.commonService.update(newTopo);
//如果原业务系统有内容则清空
this.commonService.delete("delete from TopoNodeInfo where topoInfo.id="+newTopo.getId());
this.commonService.delete("delete from TopoLineInfo where topoInfo.id="+newTopo.getId());
}else {
newTopo=new TopoInfo();
newTopo.setFlag(1L);
newTopo.setName(topoName);
newTopo.setWidth(800L);
newTopo.setHeight(800L);
newTopo.setSystemId(systemId);
newTopo.setTopoInfoClass("");
newTopo.setCreateTime(new Date());
newTopo.setCreateUser(getUser().getYhid());
newTopo.setUpdateTime(new Date());
newTopo.setUpdateUser(getUser().getYhid());
this.commonService.save(newTopo);
}
//存放拷贝前node的id和拷贝后新生成的nodeId
Map<Long,TopoNodeInfo> nodePara=new HashMap<Long,TopoNodeInfo>();
List<TopoLineInfo> topoLineInfos = this.commonService.find("from TopoLineInfo where 1=1 and topoInfo.id=?", topoInfoId);
List<TopoNodeInfo> topoNodeInfos = this.commonService.find("from TopoNodeInfo where 1=1 and topoInfo.id=?", topoInfoId);
if(null!=topoNodeInfos&&topoNodeInfos.size()>0) {
for (int i=0;i<topoNodeInfos.size();i++) {
TopoNodeInfo topoNodeInfo2 = topoNodeInfos.get(i);
TopoNodeInfo newTopoNode = new TopoNodeInfo();
newTopoNode.setTopoInfo(newTopo);
newTopoNode.setType(3L);
newTopoNode.setHeight(topoNodeInfo2.getHeight());
newTopoNode.setWidth(topoNodeInfo2.getWidth());
newTopoNode.setText(topoNodeInfo2.getText());
newTopoNode.setThresholdValue(80.0);
newTopoNode.setTopoImg(topoNodeInfo2.getTopoImg());
newTopoNode.setTopoNodeInfoClass(topoNodeInfo2.getTopoNodeInfoClass());
newTopoNode.setX(topoNodeInfo2.getX());
newTopoNode.setY(topoNodeInfo2.getY());
newTopoNode.setCreateTime(new Date());
newTopoNode.setCreateUser(getUser().getYhid());
newTopoNode.setUpdateTime(new Date());
newTopoNode.setUpdateUser(getUser().getYhid());
this.commonService.save(newTopoNode);
nodePara.put(topoNodeInfo2.getId(),newTopoNode);
}
}
if(null!=topoLineInfos&&topoLineInfos.size()>0) {
for (TopoLineInfo topoLineInfo : topoLineInfos) {
TopoLineInfo newTopoLine=new TopoLineInfo();
newTopoLine.setTopoInfo(newTopo);
newTopoLine.setFlag(1L);
newTopoLine.setCreateTime(new Date());
newTopoLine.setCreateUser(getUser().getYhid());
newTopoLine.setFlag(1L);
/*TopoNodeInfo topoNodeInfo1 = new TopoNodeInfo();
TopoNodeInfo topoNodeInfo2 = new TopoNodeInfo();
Long long1 = nodePara.get(topoNodeInfo1.getId());
Long long2 = nodePara.get(topoNodeInfo2.getId());
topoNodeInfo1.setId(long1);
topoNodeInfo2.setId(long2);*/
Long id = topoLineInfo.getTopoNodeInfo1().getId();
Long id2 = topoLineInfo.getTopoNodeInfo2().getId();
TopoNodeInfo topoNodeInfo1 = nodePara.get(id);
TopoNodeInfo topoNodeInfo2 = nodePara.get(id2);
newTopoLine.setTopoNodeInfo1(topoNodeInfo1);
newTopoLine.setTopoNodeInfo2(topoNodeInfo2);
newTopoLine.setUpdateTime(new Date());
newTopoLine.setUpdateUser(getUser().getYhid());
newTopoLine.setTopoLineInfoClass(topoLineInfo.getTopoLineInfoClass());
this.commonService.save(newTopoLine);
}
}
} catch (Exception e) {
commonService.rollback();
try {
this.getResponse().sendError(500);
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
// topo图覆盖
public void coverTopoManage() {
try {
List<TopoInfo> find = this.commonService.find("from TopoInfo where 1=1 and id=?", topoInfoId);
if(null!=find&&find.size()>0) {
TopoInfo topoInfo = find.get(0);
topoInfo.setSystemId(systemId);
//将当前业务系统的topo图设置为空 确保一个业务系统只有一个topo图
this.commonService.delete("delete from TopoInfo where systemId="+systemId);
//将当前的topo图绑定给当前的业务系统
this.commonService.update(topoInfo);
}else {
throw new RuntimeException("覆盖失败");
}
} catch (Exception e) {
commonService.rollback();
try {
this.getResponse().sendError(500);
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
/*public void modifyTopoManage(){
String parameter = this.getRequest().getParameter("datas");
JSONArray fromObject = JSONArray.fromObject(parameter);
List<TopoManageInfo> results = (List) JSONArray.toCollection(fromObject, TopoManageInfo.class);
@@ -190,6 +397,112 @@ public class TopoManageAction extends BaseAction{
}
e.printStackTrace();
}
}*/
public void removeTopoNode() {
// 根据节点ID删除节点 同时删除与之想关联的连线信息
try {
this.commonService.delete("delete from TopoNodeInfo where id="+topoNodeId);
this.commonService.delete("delete from TopoLineInfo where src="+topoNodeId+" or dest="+topoNodeId);
} catch (Exception e) {
commonService.rollback();
try {
this.getResponse().sendError(500);
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
public void removeTopoLine() {
// 根据连线ID删除连线信息
try {
this.commonService.delete("delete from TopoLineInfo where id="+topoLineId);
} catch (Exception e) {
commonService.rollback();
try {
this.getResponse().sendError(500);
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
public void addTopoNode() {
//添加拓扑图节点
try {
String parameter = this.getRequest().getParameter("topoNodeData");
JSONObject fromObject = JSONObject.fromObject(parameter);
TopoNodeInfo node = (TopoNodeInfo) JSONObject.toBean(fromObject, TopoNodeInfo.class);
this.commonService.save(node);
this.outAjaxString(node.getId().toString());
} catch (Exception e) {
commonService.rollback();
try {
this.getResponse().sendError(500);
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
public void addTopoLine() {
//添加拓扑图连线
try {
String parameter = this.getRequest().getParameter("topoLineData");
JSONObject fromObject = JSONObject.fromObject(parameter);
TopoLineInfo line = (TopoLineInfo) JSONObject.toBean(fromObject, TopoLineInfo.class);
this.commonService.save(line);
this.outAjaxString(line.getId().toString());
} catch (Exception e) {
commonService.rollback();
try {
this.getResponse().sendError(500);
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
public void modifyTopoNode() {
// 修改topo图节点信息
try {
String parameter = this.getRequest().getParameter("topoNodeData");
JSONObject fromObject = JSONObject.fromObject(parameter);
TopoNodeInfo node = (TopoNodeInfo) JSONObject.toBean(fromObject, TopoNodeInfo.class);
node.setTopoNodeInfoClass("["+node.getTopoNodeInfoClass()+"]");
this.commonService.update(node);
} catch (Exception e) {
commonService.rollback();
try {
this.getResponse().sendError(500);
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
public void modifyTopoLine() {
//修改topo图连线信息
try {
String parameter = this.getRequest().getParameter("topoLineData");
JSONObject fromObject = JSONObject.fromObject(parameter);
TopoLineInfo line = (TopoLineInfo) JSONObject.toBean(fromObject, TopoLineInfo.class);
this.commonService.update(line);
} catch (Exception e) {
commonService.rollback();
try {
this.getResponse().sendError(500);
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
public String getAction() {
@@ -342,4 +655,45 @@ public class TopoManageAction extends BaseAction{
public void setTopoManageInfos(List<TopoManageInfo> topoManageInfos) {
this.topoManageInfos = topoManageInfos;
}
public List<TopoLineInfo> getTopoLineList() {
return topoLineList;
}
public void setTopoLineList(List<TopoLineInfo> topoLineList) {
this.topoLineList = topoLineList;
}
public List<TopoImg> getTopoImgList() {
return topoImgList;
}
public void setTopoImgList(List<TopoImg> topoImgList) {
this.topoImgList = topoImgList;
}
public Long getTopoLineId() {
return topoLineId;
}
public void setTopoLineId(Long topoLineId) {
this.topoLineId = topoLineId;
}
public TopoLineInfo getTopoLineInfo() {
return topoLineInfo;
}
public void setTopoLineInfo(TopoLineInfo topoLineInfo) {
this.topoLineInfo = topoLineInfo;
}
public Integer getDiffTopoFlag() {
return diffTopoFlag;
}
public void setDiffTopoFlag(Integer diffTopoFlag) {
this.diffTopoFlag = diffTopoFlag;
}
}