161 Commits

Author SHA1 Message Date
leijun
e5953a2f81 vpn cgi接口服务 报错信息调整 2019-02-26 17:11:32 +08:00
dongxiaoyan
e831718fe7 调整APP相关趋势图数据比较接近时的颜色区分 2019-02-25 09:29:53 +08:00
dongxiaoyan
e122f9587a 调整app趋势图透明度,添加纵轴单位 2019-02-22 18:11:51 +08:00
zhangwenqing
4c5bc5b6e9 修复AppSession组件'S2C'项关键字格式错误问题. 2019-02-22 17:02:24 +08:00
dongxiaoyan
8a0f4d280f 更改dns分组国际化,区分dns的两个分组 2019-02-22 11:30:33 +08:00
zhanghongqing
961cd7d5a1 流量统计app详情趋势统计图增加Gbps、PPS单位切换统计,导出图片增加标题与时间
(cherry picked from commit 2dd73adfbb)
2019-02-22 11:10:35 +08:00
zhangdongxu
d095635837 补提dns关键字组配置页面
(cherry picked from commit 2404bd69a4)
2019-02-22 10:57:19 +08:00
zhanghongqing
1afda42d88 调整dns、url新增界面分组配置的位置
(cherry picked from commit b8c9b88196)
2019-02-22 10:44:12 +08:00
tanghao
609a75db67 修复基本配置-common-group DNS关键字分组管理列表缺失bug
(cherry picked from commit 3a1580bb0c)
2019-02-22 10:08:40 +08:00
zhangdongxu
295a4662e8 dns 关键字分组配置:配置的分组Id,由groupId改为serviceGroupId
(cherry picked from commit d0994b7f98)
2019-02-22 09:55:05 +08:00
zhangwenqing
c028613095 增加APP IP、域名特征属性组件后台逻辑. 2019-02-21 18:54:12 +08:00
shangguanyanfei
2900eb1823 url分组配置审核修改公共组标识字段的值
(cherry picked from commit 16d1382909)
2019-02-21 18:40:24 +08:00
dongxiaoyan
006cfe89da 俄文国际化 2019-02-21 18:16:09 +08:00
shangguanyanfei
cf5db363fc url分组配置查询、添加和编辑页面的修改
(cherry picked from commit 80ede65fb1)
2019-02-21 17:49:54 +08:00
dongxiaoyan
23efabc29a 取消审核之后的组才可用的限制 2019-02-21 17:20:59 +08:00
zhanghongqing
6968a27bff dns/url公共分组中取表policy_group_info的组id由groupId改为serviceGroupId
(cherry picked from commit 31edf93fdc)
2019-02-21 15:42:26 +08:00
段冬梅
0e49a1d0ac 密码修改清理缓存时,由用户名清理缓存修改为登录ID来清理用户缓存。
(cherry picked from commit 60392b2493)
2019-02-21 10:08:43 +08:00
段冬梅
69f993f40f 修复客户端账号管理和SNAT策略导出选中配置出错BUG
(cherry picked from commit a2f311f18c)
2019-02-21 10:07:46 +08:00
shangguanyanfei
b935bad2d0 Url分组配置修改、删除和审核服务端
(cherry picked from commit efbb596bd5)
2019-02-21 09:58:10 +08:00
zhangwenqing
5e4f48088c 修改APP关联特征配置页面. 2019-02-21 09:57:49 +08:00
zhanghongqing
31ec0cd29a dns、url增加公共组后在列表三角号中显示公共组名称
(cherry picked from commit ff61fa313a)
2019-02-21 09:27:17 +08:00
dongxiaoyan
ad28ae4d13 appsession组件 特征组件,管控组件 2019-02-19 13:45:47 +08:00
dongxiaoyan
db20e37b13 TrafficPort趋势图单位由bytes改为 :Link Numbers
(cherry picked from commit fda327e4c1)
2019-02-18 19:33:10 +08:00
dongxiaoyan
c3f5cb7851 获取配置时间超时时间由10000毫秒改为30000毫秒;但是不能合并到devolop分支因basecontroller文件中添加了公共分组代码,
(cherry picked from commit 6ffdcd0dff)
2019-02-18 19:32:48 +08:00
shangguanyanfei
f91fd57901 url分组配置页面(url公共组)
(cherry picked from commit e5d8f038ea)
2019-02-18 19:30:21 +08:00
zhangdongxu
92a39366c9 dns关键字分组配置
(cherry picked from commit e4b44e6b8c)
2019-02-18 19:29:37 +08:00
dongxiaoyan
8685886b88 日志趋势图提示信息国际化
(cherry picked from commit ae4cca4dfe)
2019-02-18 19:28:51 +08:00
zhanghongqing
d1f64348f4 1、协议中菜单dns增加公共组配置,同时修改审核,取消审核公共组部分,并且界面回显展示组号。
2、协议菜单中http url 增加公共组配置,同时修改审核,取消审核公共组部分,并且界面回显展示组号。
2019-02-18 17:51:00 +08:00
dongxiaoyan
8194fb290c DNS-URL公共分组增加菜单 2019-02-18 17:27:23 +08:00
dongxiaoyan
f3d4f0deec 修改提示信息“No data to display”为“No data display within a specified time
range”;
时间格式化错误:最后的“。000”
2019-02-18 17:25:47 +08:00
段冬梅
ab37a155d0 asn下发时表单增加 asn最大为4294967295的校验;
asn根据asn组处理asn ip,此逻辑打开asn ip的下发功能;
asn no处理asn ip时,只有全量是才需要删除asn no下旧的asn ip

(cherry picked from commit 0f65e9aaa0)
2019-02-18 14:49:09 +08:00
段冬梅
3c42039573 asn ip导入入库时,判断是否全量,如果全量才需要删除旧的asnip
(cherry picked from commit 44be854707)
2019-02-18 14:41:24 +08:00
dongxiaoyan
9445070693 Merge branch 'devlop_urldns_common_group' of https://git.mesalab.cn/K18_NTCS_WEB/NTC.git into devlop_urldns_common_group 2019-02-18 10:40:16 +08:00
dongxiaoyan
5b49bf1d80 ASN分组逻辑调整,配置使用ANS号对应组织的分组改为使用ANS号新增的唯一分组 2019-02-18 10:39:49 +08:00
tanghao
ded26d9382 url组以及dns组页面 2019-02-18 10:17:39 +08:00
dongxiaoyan
e2292598e9 1、根据 刘老师和园园要求注释掉:“CEIEC All Rights Reserved,CEIEC ©”;
2、提示信息:“未找到该菜单!”修改为“The menu was not found!”,未国际化,以后考虑国际化;
3、提示信息:“缓存清理成功”修改为“Cache Cleaning Successful!”,未国际化,以后考虑国际化;
4、提示信息:“缓存清理失败”修改为“Cache Cleanup Failure!”,未国际化,以后考虑国际化;
5、部分页面乱码修改;
2019-02-17 11:19:11 +08:00
dongxiaoyan
90775bac0d Copyied! 修正为 Copied! 2019-02-17 11:13:32 +08:00
tanghao
10394d3fd6 1.policy_group_info表sql
2.表名修改命名规范
3.serviceGroupId赋值
2019-02-15 18:03:36 +08:00
tanghao
ba80f58516 新增公共查询url以及dns组数据信息方法 2019-02-15 15:45:32 +08:00
tanghao
29215bc96c 基本配置dns以及url分组功能 2019-02-15 10:00:59 +08:00
duandongmei
30ba1d160d 白名单的ipForm界面去掉误写的aa串 2019-01-30 17:35:59 +06:00
duandongmei
b95e597b57 ASN导入全量,删除asnip逻辑修改为基于asn no的批量删除。
每次删除定量的asn ip cfg遍历,基于本批asn no,asn ip数量大于maat_send_size即删除并入库最新asn ip信息
2019-01-30 11:07:22 +06:00
duandongmei
64e3c13513 单元格的值存储Map增加key重复性判断 2019-01-29 12:33:24 +06:00
duandongmei
d23b35f8c9 导入去掉组织、国家、详情非空校验,为空取ASN 2019-01-29 10:19:57 +06:00
段冬梅
f98ba1951e Merge branch 'bugfix-2019012816-traffic修改按钮下移问题' into 'develop'
修改流量统计中协议详情跟网站详情界面按钮下移问题

See merge request K18_NTCS_WEB/NTC!35
2019-01-29 12:00:01 +08:00
duandongmei
650ffaace2 导入处理无数据的单元格,记录所有有数据的单元格及下标,最后将无数据的单元格根据下标补全。 2019-01-29 09:51:47 +06:00
wangxin
c2b33847f9 去掉重复的ajaxKeyinfIsUsed调用 2019-01-28 22:18:08 +08:00
zhanghongqing
536f6a56be 修改流量统计中协议详情跟网站详情界面按钮下移问题 2019-01-28 16:43:04 +08:00
duandongmei
1b9fef3bc8 ip白名单打开方向属性 2019-01-28 13:56:01 +06:00
duandongmei
7bfcbe614a IP Spoofing的action导出由redirect修改为Spoofing 2019-01-28 11:13:15 +06:00
chenjinsong
b57176c6c1 修复日志导出:
去掉IP Spoofing的修改;
bgp导出无action合并


Conflicts:
	src/main/java/com/nis/util/excel/ExcelCsv.java
2019-01-28 10:52:42 +06:00
duandongmei
be5635f81f 多删除了commit提交语句bug更改 2019-01-28 09:47:55 +06:00
方顺健
e8ead66d5e Merge branch 'bugfix-20190127-zhangwq' into 'develop'
修复BUG:

See merge request K18_NTCS_WEB/NTC!33
2019-01-27 22:43:52 +08:00
zhangwenqing
11424ee91d 修复BUG:
1.修复DDOS配置流量阈值(Bps)/(Pps)默认值Bug
2.修正配置导入域名字段错误提示信息
3.SNAT/DNAT复用策略配置 暂不支持 跳转日志检索
4.缓存策略配置导出忽略doLog(与界面列表一致)
5.修复音视频样例配置上传文件二次选择取消后文件框中的文件名还存在
6.修复特定服务管理新增报错
2019-01-27 22:42:14 +08:00
方顺健
affdaf513a Merge branch 'bugfix-2019012720-del-css修改delete按钮字体' into 'develop'
修改界面delete按钮样式

See merge request K18_NTCS_WEB/NTC!29
2019-01-27 22:17:43 +08:00
zhanghongqing
0c468202a0 修改界面delete按钮样式 2019-01-27 20:56:22 +08:00
方顺健
76302ff82e Merge branch 'bugfix-20190127-import-letter' into 'develop'
1.业务配置-导入摸板修改 来函下拉框显示内容(改为只显示通过的来函)

See merge request K18_NTCS_WEB/NTC!27
2019-01-27 20:19:09 +08:00
方顺健
a5246568ad Merge branch 'bugfix-2019012718-export-ddos' into 'develop'
配置导出统一显示全部区域显示,子配置中去掉日志总量,在主配置显示

See merge request K18_NTCS_WEB/NTC!26
2019-01-27 20:18:40 +08:00
duandongmei
2cb6de6773 asn统计updatesql,不分批次提交 2019-01-27 18:07:43 +06:00
方顺健
71457cc369 Merge branch '20190126bugth' into 'develop'
1.首页面退出操作字体未对齐

See merge request K18_NTCS_WEB/NTC!25
2019-01-27 19:46:35 +08:00
shangguanyanfei
7c93338dce 1.业务配置-导入摸板修改 来函下拉框显示内容(改为只显示通过的来函)
2.业务配置模块页面-筛选按钮中的来函下拉框改为显示(通过的和配置取消的来函)
2019-01-27 18:55:56 +08:00
zhangwei
15c8b83b94 修改增加了定时器的业务配置列表,调整生效标识(is_valid)位置,增加定时器标识显示。 2019-01-27 16:44:03 +06:00
zhanghongqing
715e9b3c73 配置导出统一显示全部区域显示,子配置中去掉日志总量,在主配置显示 2019-01-27 18:32:02 +08:00
段冬梅
5923554e52 Merge branch 'bugfix-20190127-export-blockdrop' into 'develop'
业务配置-stream模块导出-阻断类型中 阻断 改为 封堵(丢弃)

See merge request K18_NTCS_WEB/NTC!24
2019-01-27 16:54:01 +08:00
tanghao
355fa8e3cb 1.首页面退出操作字体未对齐
2.基本配置-用户管理-新增用户bug
3.ASN IP配置导出bug(实际为公共界面所有超过阈值导出共性BUG)
4.ASN IP下拉框onchange事件
2019-01-27 16:24:39 +08:00
duandongmei
560a6530dd 关键字转url,来函为null的情况修复 2019-01-27 13:41:34 +06:00
shangguanyanfei
a7d22d463d 业务配置-stream模块导出-阻断类型中 阻断 改为 封堵(丢弃) 2019-01-27 15:02:56 +08:00
duandongmei
1c642b281e 修复asn v4和v6串列问题 2019-01-27 11:51:15 +06:00
duandongmei
e1d439655a Merge branch 'develop' of https://git.mesalab.cn/K18_NTCS_WEB/NTC.git into develop 2019-01-27 11:50:35 +06:00
duandongmei
2037c2f3b0 无变更 2019-01-27 11:50:13 +06:00
duandongmei
fc73585977 无变更 2019-01-27 11:48:26 +06:00
zhangwei
5f321f96ab 同步feature-traffic-log分支修改的增加定时器插件策略表单
Conflicts:
	src/main/resources/messages/message_en.properties
	src/main/webapp/WEB-INF/views/cfg/ipaddr/ipList.jsp

Conflicts:
	src/main/resources/messages/message_en.properties
	src/main/resources/messages/message_ru.properties
	src/main/webapp/WEB-INF/views/cfg/ipaddr/ipList.jsp
2019-01-27 11:18:34 +06:00
zhangwei
3373978073 修改编译jdk版本为1.8 2019-01-27 11:10:51 +06:00
段冬梅
67ed670053 Merge branch 'bugfix-20190127-Export' into 'develop'
配置导出时是否区分大小写时,为是时导出无显示问题解决,日志http网页关键字查询是选择关键字监测/封堵时界面对应列显示不同国际化问题解决。

See merge request K18_NTCS_WEB/NTC!22
2019-01-27 12:51:15 +08:00
zhanghongqing
14e3b828db 配置导出时是否区分大小写时,为是时导出无显示问题解决,日志http网页关键字查询是选择关键字监测/封堵时界面对应列显示不同国际化问题解决。 2019-01-27 12:46:18 +08:00
段冬梅
956f19ae2f Merge branch 'bugfix-20190127-export' into 'develop'
修复缓存策略配置、IP分组管理、DNS分组管理导出黑屏bug

See merge request K18_NTCS_WEB/NTC!21
2019-01-27 12:32:59 +08:00
段冬梅
fdfc608290 Merge branch 'dev-help-wwr' into 'develop'
新增编辑在帮助文档功能

See merge request K18_NTCS_WEB/NTC!17
2019-01-27 12:25:21 +08:00
duandongmei
a51718907d v6_num国际化更改 2019-01-27 10:21:55 +06:00
zhangwenqing
c9d7512a1b 修复缓存策略配置、IP分组管理、DNS分组管理导出黑屏bug 2019-01-27 12:03:39 +08:00
wangwenrui
da9744d60d 1.修改帮助显示,变更帮助页面实现,采用markdown格式文件
2.添加markdown工具栏国际化
2019-01-27 11:02:55 +08:00
duandongmei
923aca94a8 asn增加ipv4和ipv6个数 2019-01-26 20:21:46 +06:00
duandongmei
96df029f43 ASN定时计算v4和v6的IP个数;
界面展示ASNIPv4和v6数
2019-01-26 19:41:58 +06:00
zhangwei
f90ef5ab85 增加定时器功能 2019-01-26 18:02:44 +06:00
zhangwei
0fb4bf08a4 url白名单修改下发的maat的业务表名不做特殊处理。 2019-01-26 17:23:38 +06:00
duandongmei
c8c75e566e 受话人国际化更改为Callee 2019-01-26 10:51:14 +06:00
duandongmei
85633ee524 Merge branch 'develop' of https://git.mesalab.cn/K18_NTCS_WEB/NTC.git into develop 2019-01-26 10:48:13 +06:00
duandongmei
89f92e99fc ASN IP 导入并下发功能 2019-01-26 10:47:50 +06:00
董晓燕
5786412116 Merge branch 'bugfix-20190126-import' into 'develop'
修复APP特征配置导入bug

See merge request K18_NTCS_WEB/NTC!20
2019-01-26 12:07:01 +08:00
zhangwenqing
0cbe9c7ff7 修复APP特征配置导入bug 2019-01-26 11:56:10 +08:00
董晓燕
4304fe0077 Merge branch 'feature-2019012609-logs' into 'develop'
ddos日志去掉client查询条件,攻击类型在字典界面设置保留DNS_Flood,NTP_Flood,SYN_Flood

See merge request K18_NTCS_WEB/NTC!19
2019-01-26 11:31:18 +08:00
zhanghongqing
1cc0a4f2ea ddos日志去掉client查询条件,攻击类型在字典界面设置保留DNS_Flood,NTP_Flood,SYN_Flood 2019-01-26 10:27:05 +08:00
zhangwei
cb9cf1eac8 修改doLog参数选项的国际化 2019-01-25 13:54:39 +06:00
wangwenrui
e1efb84e1f Merge branch 'develop' into dev-help-wwr 2019-01-25 15:42:17 +08:00
王鑫
d0ca7f89d4 Merge branch 'bugfix-20190125-traffic' into 'develop'
修改流量统计滚动条文字对齐bug

See merge request K18_NTCS_WEB/NTC!18
2019-01-25 14:57:49 +08:00
zhanghongqing
e2e6ebfac1 修改流量统计滚动条文字对齐bug 2019-01-25 14:42:41 +08:00
dongxiaoyan
3daab5e49d add_pool_nam补充完整add_pool_name 2019-01-25 14:31:42 +08:00
dongxiaoyan
e5e63af738 添加默认动态ip池,并修改cfgid为0 2019-01-25 14:27:40 +08:00
wangwenrui
1d5905fe47 新增编辑在帮助文档功能 2019-01-25 14:19:00 +08:00
zhangwei
52fe56b59d 修改doLog的参数描述 2019-01-24 20:32:06 +06:00
zhangwei
d51da59143 修改通联关系日志中的查询条件描述domain->web 2019-01-24 20:24:33 +06:00
zhangwei
8bb1c6c857 dns业务去掉do_blacklist选项的显示 2019-01-24 20:14:50 +06:00
duandongmei
25e6fa4a3f 保护名单提示、正在提交、登出的国际化更新 2019-01-24 17:30:19 +06:00
duandongmei
ea82be590e domain和url域新增时增加警告提示信息【后期需在审核时也增加此警告】。
保护名单信息杨威提供后,再进行完善
2019-01-24 15:29:10 +06:00
zhanghongqing
1a6e771458 修改流量统计首页滚动条数字对齐
(cherry picked from commit 2ca0a4714dfedbea53272f43169e4cf502e377f9)
2019-01-24 14:57:01 +08:00
leijun
2ad34a552c snat地址池添加动态地址池信息 sql
(cherry picked from commit c01a1ac22d0b8bd27de1d739b3c692b1fb8e32fa)
2019-01-24 14:56:34 +08:00
leijun
e14cca6824 SNAT地址池添加一条动态地址池信息
app域名特征添加拦截强度

(cherry picked from commit 1d71820d1ee3fbd21f201af14781849de9fb75a3)
2019-01-24 14:56:09 +08:00
duandongmei
2e8d2cb7b2 ASN IP全量+数据入库提交 2019-01-23 19:32:47 +06:00
duandongmei
9fbd60ddf0 Merge branch 'develop' of https://git.mesalab.cn/K18_NTCS_WEB/NTC.git into develop 2019-01-23 19:28:44 +06:00
duandongmei
a31769f3cb ASN IP导入(全量+数据入库)开发 2019-01-23 19:28:13 +06:00
董晓燕
a960bb53ec Merge branch 'cherry-pick-6704549d' into 'develop'
Merge branch 'bugfix-20190123-import' into 'dev-ycx'

See merge request K18_NTCS_WEB/NTC!15
2019-01-23 18:45:54 +08:00
董晓燕
0858b89ffa Merge branch 'bugfix-20190123-import' into 'dev-ycx'
修正Ip Spoofing配置导入模板'direction'字段默认值批注;修改配置导入域名字段校验;修复配置导入属性验证发生异常后无提示信息问题(王鑫)

See merge request K18_NTCS_WEB/NTC!11

(cherry picked from commit 6704549d61a525406f33a02eb8f93762d272aa40)

38f563ce 修正Ip Spoofing配置导入模板'direction'字段默认值批注;修改配置导入域名字段校验;修复配置导入属性验证发生异常后无提示信息问题(王鑫)
2019-01-23 18:45:14 +08:00
董晓燕
65991514d7 Merge branch 'debug-26-流量统计bug' into 'develop'
修复流量B和b换算问题

See merge request K18_NTCS_WEB/NTC!12
2019-01-23 18:16:53 +08:00
tanghao
3cd969978e 修复流量B和b换算问题 2019-01-23 18:08:09 +08:00
董晓燕
44a8e8852e Merge branch 'cherry-pick-6fe94fa3' into 'develop'
修改用户行为查询时间设置

See merge request K18_NTCS_WEB/NTC!10
2019-01-23 16:39:51 +08:00
zhanghongqing
57793c7264 修改用户行为查询时间设置
(cherry picked from commit 6fe94fa3b8e8a9e6a8ed1ae3454db78fa5eb9c1d)
2019-01-23 16:39:24 +08:00
duandongmei
6885d467cb js国际化增加crlCheck信息,俄文国际化翻译 2019-01-23 11:30:26 +06:00
duandongmei
e5ce04e34b 国际化俄文翻译,并且去掉重复的desc国际化 2019-01-23 10:58:12 +06:00
duandongmei
fa42935d46 修复拥有用户管理权限的用户,修改其他用户密码后不生效问题。 2019-01-23 10:40:05 +06:00
zhanghongqing
a464bd9443 修改日志详情中title判断条件 2019-01-22 19:34:13 +08:00
zhangwei
3087e5baf3 新增定时任务相关国际化字典 2019-01-22 17:12:49 +06:00
李皓宸
52bf2d3415 日志检索->流量日志->邮件泛收和SSL泛收 移除cfgId查询条件,解决Js报错问题 2019-01-22 19:05:08 +08:00
李皓宸
ee411339c8 1.日志检索->国家代理->HTTP(S) 界面 原始请求体和原始应答体 列数据 增加点击下载功能
2.实时报表->流量统计->流量统计和协议统计 界面 "方向"查询条件增加"请选择"选项(默认)
2019-01-22 17:26:56 +08:00
zhanghongqing
3bf485b920 增加国际化配置,流量统计首页滚动条调整,保留两位小数 2019-01-22 17:22:49 +08:00
leijun
ab157b82db 日志检索-snat、dnat复用策略 页面标题国际化对应调整 2019-01-22 17:06:05 +08:00
tanghao
79de7b51df bps计算保留两位小数展示 2019-01-22 16:54:11 +08:00
zhanghongqing
0ed34ac938 修改鼠标点击列表copy中的的空格,去掉 2019-01-22 16:34:31 +08:00
zhanghongqing
2eb2cd366e 补充提交去掉注释 2019-01-22 16:02:01 +08:00
zhanghongqing
b03ec51aa4 解决日志详情中文字带换行空格问题 2019-01-22 15:44:18 +08:00
zhanghongqing
37dfdf1e3b 流量统计修改国际化名称 2019-01-22 10:21:01 +08:00
李皓宸
859b3c72f9 日志检索->国家代理->HTTP(S) 修正界面无法显示原始请求体和原始应答体数据问题 2019-01-22 10:08:58 +08:00
zhangwei
9d190788b1 修改日志客户端服务器端位置的国际化 2019-01-21 20:07:33 +06:00
leijun
7d08ab8539 通联日志重置后默认选中other 2019-01-21 19:45:31 +08:00
tanghao
e0661fbed4 1.修改bps计算方式 改为Gbps
2.调动pps以及bps页面位置
2019-01-21 17:49:41 +08:00
zhanghongqing
23c118c6b7 流量统计滚动条做动态单位换算 2019-01-21 17:27:31 +08:00
duandongmei
634def997d Merge branch 'develop' of https://git.mesalab.cn/K18_NTCS_WEB/NTC.git into develop 2019-01-21 15:18:48 +06:00
duandongmei
b5d1b281a0 //修改html特殊字符转换方法名
escapIntypeHtml
2019-01-21 15:17:44 +06:00
zhanghongqing
d0b4907271 去掉通联关系日志界面运营商展示,去掉流量统计app详情趋势运营商展示,同时修改导出去掉运营商列,app跳转到app详情界面时携带地域条件 2019-01-21 16:54:09 +08:00
duandongmei
a1f8e1779a 修复配置界面中下拉选择检索条件,js使用el表达式赋值时存在html特殊字符未转换问题;
导入字符串字段增加escapeHtml4转换;
域名校验不使用完整的域名格式校验。
2019-01-21 14:46:57 +06:00
zhangwenqing
d7d3f68222 修改关注网站配置导入 主题、网站大小写不敏感;修改App Ip配置导入模板 2019-01-21 15:47:32 +08:00
李皓宸
3612bf09d9 1.日志检索->协议->邮箱 增加 动作 查询条件,选"动作"时传入监测和阻断对应的Service
2.实时报表->流量统计和协议统计 增加 方向 查询条件,out为0 in为1
2019-01-21 14:54:35 +08:00
zhanghongqing
3602e2f1c3 调整流量统计滚动条数据列对齐,traffic中/S改为/s,请求方法改为post防止缓存,请求时间改为5分钟一次,traffic数据为当前时间15分钟内数据,其它滚动条为当前时间一小时数据。 2019-01-21 14:41:41 +08:00
zhangwenqing
fa7fa0c859 修改关注网站配置导入模板 2019-01-21 10:25:04 +08:00
zhanghongqing
8d42cab7e2 流量统计in/out改为大写,流量统计app趋势reset改为默认当前时间一小时 2019-01-19 23:16:45 +08:00
duandongmei
ebcb89ef13 证书的crl取消必填;
asn校验增加非空判断
2019-01-19 15:59:15 +06:00
duandongmei
dd31d432e1 Merge branch 'develop' of https://git.mesalab.cn/K18_NTCS_WEB/NTC.git into develop 2019-01-19 14:57:28 +06:00
duandongmei
ae283564cb 证书增加crl参数的输入,并增加crl的格式校验 2019-01-19 14:56:37 +06:00
zhangwei
968529084f 修改拦截策略的证书信息校验规则:
1. Keyring的下拉列表显示全部已生效的证书;
2. 如选择了实体证书,必须配置域名,或者IP与域名的组合配置;
3.
域名配置,如匹配方式为完全匹配,则域名必须与所选择的实体证书的CN和SAN相同。如匹配方式为后缀匹配,则域名须与所选择的实体证书的CN和SAN后缀相同;
4. 如选择了中间证书或者根证书,则可配置IP,或者域名,或者两者组合;
2019-01-19 14:39:40 +06:00
duandongmei
c23c0d738e ASN的自定义域增加AS前缀 2019-01-19 11:07:20 +06:00
duandongmei
ca14bcb621 编译配置生效时,校验编译下是否存在已经被删除的asn域配置。如果存在,提示用户重新编辑。 2019-01-19 10:32:07 +06:00
duandongmei
34648428ea Merge branch 'develop' of https://git.mesalab.cn/K18_NTCS_WEB/NTC.git into develop 2019-01-19 10:24:26 +06:00
duandongmei
427619d088 配置生效时,验证编译配置下的asn配置是否已经被删除,提醒用户重新编辑 2019-01-19 10:24:13 +06:00
zhangwei
3c61dc7bad 验证代理对象的证书是否被拦截策略引用,如被引用,则证书配置不能取消。 2019-01-18 20:21:04 +06:00
zhanghongqing
698fd13a65 通联关系日志展示运营商,修复排序功能 2019-01-18 20:49:40 +08:00
leijun
436190fe8c VPN服务器
新增添加IP重复验证
删除验证是否被IP复用-用户管理使用
IP复用-用户管理 删除验证是否被snat策略和dnat策略使用
2019-01-18 17:40:23 +08:00
duandongmei
b9c9b5aab9 asn ip去掉导入模板中的cfgDesc
;
修复主表中未存储commonGroupIds的bug;
asn ip导入时,asn_group_info的regionid
2019-01-18 15:15:06 +06:00
zhanghongqing
2d4a1a6685 流量统计app趋势及apptop100增加isp运营商查询条件 2019-01-18 16:34:58 +08:00
tanghao
7210fca18f 1.修复IP top10 使用类型报错 由integer改为Long
2.Bps修正为bps
2019-01-18 16:00:18 +08:00
dongxiaoyan
99dad7c0a4 恢复原Gbps单位 2019-01-18 15:09:37 +08:00
duandongmei
d616166507 asnKeywordCfg去掉userRegion4 2019-01-18 11:15:29 +06:00
duandongmei
43f947fd69 Merge branch 'develop' of https://git.mesalab.cn/K18_NTCS_WEB/NTC.git
into develop

Conflicts:
	src/main/java/com/nis/web/service/BaseService.java
	asn group中修改组织变更和asn no变更,不重新获取groupId逻辑
	ip addr 的asn 修改为手动输入,后台check
	app ip和asn ip配置取消,取消分组中最后一条配置时,失效整个compile,并且修改groupId的状态为为无效。
	无效的asn group删除时,删除其下的所有asn ip
2019-01-18 11:14:05 +06:00
duandongmei
b883c3b937 asnGroup界面更改;
asnregion下发逻辑变更
2019-01-18 11:01:07 +06:00
935 changed files with 158100 additions and 2897 deletions

View File

@@ -28,11 +28,6 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_144">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/jersey-client-2.23.1.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
@@ -158,5 +153,10 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@@ -1,13 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.8

View File

@@ -2,8 +2,8 @@
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="jst.jaxrs" version="1.1"/>
<installed facet="maven" version="1.0"/>
<installed facet="java" version="1.8"/>
</faceted-project>

18
pom.xml
View File

@@ -710,5 +710,23 @@
<artifactId>jersey-apache-connector</artifactId>
<version>2.23.1</version>
</dependency>
<!-- quartz -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz-jobs</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,31 @@
package com.nis.domain;
/**
* Created by dell on 2018-8-30.
*/
public class Nets {
private String StartIP;
private String EndIP;
private String NetMask;
public String getStartIP() {
return StartIP;
}
public void setStartIP(String startIP) {
StartIP = startIP;
}
public String getEndIP() {
return EndIP;
}
public void setEndIP(String endIP) {
EndIP = endIP;
}
public String getNetMask() {
return NetMask;
}
public void setNetMask(String netMask) {
NetMask = netMask;
}
}

View File

@@ -0,0 +1,43 @@
package com.nis.domain;
import com.nis.domain.configuration.BaseCfg;
/**
* 定时任务信息 schedule_info
* @author ThinkPad
*
*/
public class ScheduleCfg extends BaseCfg<ScheduleCfg>{
private static final long serialVersionUID = 7151915080876949497L;
private String name;//定时任务名称,预留
private String cronValid;//生效cron表达式
private String cronInvalid;//失效cron表达式
private String whereStr;//动态where 条件
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCronValid() {
return cronValid;
}
public void setCronValid(String cronValid) {
this.cronValid = cronValid;
}
public String getCronInvalid() {
return cronInvalid;
}
public void setCronInvalid(String cronInvalid) {
this.cronInvalid = cronInvalid;
}
public String getWhereStr() {
return whereStr;
}
public void setWhereStr(String whereStr) {
this.whereStr = whereStr;
}
}

View File

@@ -0,0 +1,66 @@
package com.nis.domain;
import java.util.Date;
import com.nis.domain.configuration.BaseCfg;
/**
* 定时任务执行信息 schedule_exce_log/schedule_exce_new
* `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增',
`schedule_id` bigint(20) NOT NULL COMMENT 'schedule_info 表的主键',
`exce_time` datetime DEFAULT NULL COMMENT '最新执行时间',
`issue_status` int(255) DEFAULT NULL COMMENT '下发状态1生效0失效',
`issue_result` int(255) DEFAULT NULL COMMENT '下发结果1成功0失败',
`error_info` varchar(255) DEFAULT NULL COMMENT '下发失败原因',
`compile_id` bigint(20) DEFAULT NULL COMMENT '编译id',
* @author fang
*
*/
public class ScheduleExceInfo extends BaseCfg<ScheduleExceInfo>{
private static final long serialVersionUID = 7151915080876949497L;
private Long scheduleId;//定时器id
private Date exceTime;//下发时间
private Integer issueStatus;//下发 的状态
private Integer issueResult;//下发结果
private String errorInfo;//动态where 条件
private Integer isIssue;//是否需要下发配置1需要0不需要
public Long getScheduleId() {
return scheduleId;
}
public void setScheduleId(Long scheduleId) {
this.scheduleId = scheduleId;
}
public Date getExceTime() {
return exceTime;
}
public void setExceTime(Date exceTime) {
this.exceTime = exceTime;
}
public Integer getIssueStatus() {
return issueStatus;
}
public void setIssueStatus(Integer issueStatus) {
this.issueStatus = issueStatus;
}
public Integer getIssueResult() {
return issueResult;
}
public void setIssueResult(Integer issueResult) {
this.issueResult = issueResult;
}
public String getErrorInfo() {
return errorInfo;
}
public void setErrorInfo(String errorInfo) {
this.errorInfo = errorInfo;
}
public Integer getIsIssue() {
return isIssue;
}
public void setIsIssue(Integer isIssue) {
this.isIssue = isIssue;
}
}

View File

@@ -32,7 +32,22 @@ public class AsnGroupInfo extends BaseCfg<AsnGroupInfo> implements Serializable{
private Integer isUsed;
private Integer regionId;
private Integer orgGroupId;
private Integer onlyGroupId;// ip地址独用组id
public Integer getOnlyGroupId() {
return onlyGroupId;
}
public void setOnlyGroupId(Integer onlyGroupId) {
this.onlyGroupId = onlyGroupId;
}
public Integer getOrgGroupId() {
return orgGroupId;
}
public void setOrgGroupId(Integer orgGroupId) {
this.orgGroupId = orgGroupId;
}
public Integer getIsUsed() {
return isUsed;

View File

@@ -0,0 +1,64 @@
package com.nis.domain.basics;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.util.excel.ExcelField;
public class UrlCommGroupCfg extends BaseStringCfg<UrlCommGroupCfg>{
private static final long serialVersionUID = 398247881810945300L;
private static final String tableName="http_url_cfg";
@ExcelField(title="key_word",sort=3)
protected String cfgKeywords;//url关键字配置
// protected Integer exprType;//表达式类型
// protected Integer matchMethod;//匹配类型
protected Integer isHexbin;//是否大小写敏感
protected String ratelimit;//限速比例,0到1之间
@ExcelField(title="group_name",sort=108)
protected String groupName;//公共组名称
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
// public Integer getExprType() {
// return exprType;
// }
// public void setExprType(Integer exprType) {
// this.exprType = exprType;
// }
// public Integer getMatchMethod() {
// return matchMethod;
// }
// public void setMatchMethod(Integer matchMethod) {
// this.matchMethod = matchMethod;
// }
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
public String getRatelimit() {
return ratelimit;
}
public void setRatelimit(String ratelimit) {
this.ratelimit = ratelimit;
}
public static String getTablename() {
return tableName;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
}

View File

@@ -44,22 +44,42 @@ public class AppComplexFeatureCfg extends BaseCfg<AppComplexFeatureCfg> {
private List<AppIpCfg> ipPortList = new ArrayList();
private String cfgRegionCode1;
//以下参数为APP PAYLOAD L3_HEADER的特殊属性使用偏移表达式处理
private String ver;
private String ihl;
private String tos;
private String totalLength;
private String flags;
private String fragmentOffset;
private String protocol;
private String icmpType;
private String icmpCode;
private String icmpIdentifier;
private String headerType;
//以下参数为APP payload payload的特殊属性偏移量表达式时处理
private Integer payloadOffset;
private Integer payloadSize;//下发综合服务接口时,为单独的域配置
private String payloadPacketDirection;//下发综合服务接口时,为单独的域配置
private String ver; // s: 为session组件复用时的属性含义 // s传输协议
private String ihl; // sL7层协议未知×
private String tos; // sL7层协议
private String totalLength; // s链接建立方式
private String flags; // sTCP包发送特性
private String fragmentOffset; // s域名初筛标识
private String protocol; // sS2C Frequent Payload Size
private String icmpType; // sS2C Payload Size Sequence
private String icmpCode; // sC2S Frequent Payload Size
private String icmpIdentifier; // sC2S Payload Size Sequence
private String headerType; // s传输服务端端口
//以下参数为APP payload payload的特殊属性偏移量表达式时处理
private Integer payloadOffset; // ssession size min
private Integer payloadSize;//下发综合服务接口时,为单独的域配置 // ssession size max
private String payloadPacketDirection;//下发综合服务接口时,为单独的域配置 // s清洗标识
private String sessionC2sRadio;
private String sessionS2cRadio;
public String getSessionC2sRadio() {
return sessionC2sRadio;
}
public void setSessionC2sRadio(String sessionC2sRadio) {
this.sessionC2sRadio = sessionC2sRadio;
}
public String getSessionS2cRadio() {
return sessionS2cRadio;
}
public void setSessionS2cRadio(String sessionS2cRadio) {
this.sessionS2cRadio = sessionS2cRadio;
}
public String getCfgRegionCode1() {
return cfgRegionCode1;

View File

@@ -8,6 +8,9 @@
*/
package com.nis.domain.configuration;
import java.util.ArrayList;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.nis.util.excel.ExcelField;
@@ -38,6 +41,10 @@ public class AppDomainCfg extends BaseCfg<AppDomainCfg> {
private String cfgKeywords;
@ExcelField(title="social_app",sort=2)
private String appName;
private AppFeatureProperties appFeaturePropCfg;
private List<AppFeatureProperties> appFeaturePropCfgList = new ArrayList();
/**
* 表达式类型
*/
@@ -71,6 +78,22 @@ public class AppDomainCfg extends BaseCfg<AppDomainCfg> {
public AppFeatureProperties getAppFeaturePropCfg() {
return appFeaturePropCfg;
}
public void setAppFeaturePropCfg(AppFeatureProperties appFeaturePropCfg) {
this.appFeaturePropCfg = appFeaturePropCfg;
}
public List<AppFeatureProperties> getAppFeaturePropCfgList() {
return appFeaturePropCfgList;
}
public void setAppFeaturePropCfgList(List<AppFeatureProperties> appFeaturePropCfgList) {
this.appFeaturePropCfgList = appFeaturePropCfgList;
}
public Integer getIsHex() {
return isHex;
}

View File

@@ -11,7 +11,6 @@ package com.nis.domain.configuration;
import java.util.ArrayList;
import java.util.List;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.util.excel.ExcelField;
@@ -37,8 +36,12 @@ public class AppFeatureIndex extends BaseCfg<AppFeatureIndex> {
private AppByteCfg strCfg;
private AppIpCfg ipCfg;
private List<AppIpCfg> ipPortList = new ArrayList();
private AppFeatureProperties appFeaturePropCfg;
private List<AppFeatureProperties> appFeaturePropCfgList = new ArrayList();
private List<AppStringFeatureCfg> strList = new ArrayList();
private List<AppComplexFeatureCfg> complexList = new ArrayList();
private List<AppComplexFeatureCfg> sessionList = new ArrayList();
private List<AppTcpCfg> numCfgList = new ArrayList();
protected Integer exprType ;
protected Integer matchMethod ;
@@ -194,4 +197,23 @@ public class AppFeatureIndex extends BaseCfg<AppFeatureIndex> {
this.relationTime = relationTime;
}
public List<AppComplexFeatureCfg> getSessionList() {
return sessionList;
}
public void setSessionList(List<AppComplexFeatureCfg> sessionList) {
this.sessionList = sessionList;
}
public AppFeatureProperties getAppFeaturePropCfg() {
return appFeaturePropCfg;
}
public void setAppFeaturePropCfg(AppFeatureProperties appFeaturePropCfg) {
this.appFeaturePropCfg = appFeaturePropCfg;
}
public List<AppFeatureProperties> getAppFeaturePropCfgList() {
return appFeaturePropCfgList;
}
public void setAppFeaturePropCfgList(List<AppFeatureProperties> appFeaturePropCfgList) {
this.appFeaturePropCfgList = appFeaturePropCfgList;
}
}

View File

@@ -0,0 +1,94 @@
package com.nis.domain.configuration;
import com.google.gson.annotations.Expose;
import com.nis.util.excel.ExcelField;
/**
*
* @ClassName:AppCorrelationIpCfg
* @Description:TODO(这里用一句话描述这个类的作用)
* @author zdx
* @date 2019年1月28日 下午6:09:24
* @version V1.0
*/
public class AppFeatureProperties extends BaseCfg<AppFeatureProperties> {
private static final long serialVersionUID = -5994798049255256431L;
private static final String tableName="app_feature_prop_cfg";
@Expose
@ExcelField(title="cfg_id",sort=0)
private Long cfgId;
private Integer compileId;
private Integer dropOpt;
private Integer loopOpt;
private String weakFeature;
private String whitelistFeature;
private Integer extendScanPktNum;
private Integer correlationValidTime;
private String correlationBlockAfter;
private Integer longStreamLockTime;
public Long getCfgId() {
return cfgId;
}
public void setCfgId(Long cfgId) {
this.cfgId = cfgId;
}
public Integer getCompileId() {
return compileId;
}
public void setCompileId(Integer compileId) {
this.compileId = compileId;
}
public Integer getDropOpt() {
return dropOpt;
}
public void setDropOpt(Integer dropOpt) {
this.dropOpt = dropOpt;
}
public Integer getLoopOpt() {
return loopOpt;
}
public void setLoopOpt(Integer loopOpt) {
this.loopOpt = loopOpt;
}
public String getWeakFeature() {
return weakFeature;
}
public void setWeakFeature(String weakFeature) {
this.weakFeature = weakFeature;
}
public String getWhitelistFeature() {
return whitelistFeature;
}
public void setWhitelistFeature(String whitelistFeature) {
this.whitelistFeature = whitelistFeature;
}
public Integer getExtendScanPktNum() {
return extendScanPktNum;
}
public void setExtendScanPktNum(Integer extendScanPktNum) {
this.extendScanPktNum = extendScanPktNum;
}
public Integer getCorrelationValidTime() {
return correlationValidTime;
}
public void setCorrelationValidTime(Integer correlationValidTime) {
this.correlationValidTime = correlationValidTime;
}
public String getCorrelationBlockAfter() {
return correlationBlockAfter;
}
public void setCorrelationBlockAfter(String correlationBlockAfter) {
this.correlationBlockAfter = correlationBlockAfter;
}
public Integer getLongStreamLockTime() {
return longStreamLockTime;
}
public void setLongStreamLockTime(Integer longStreamLockTime) {
this.longStreamLockTime = longStreamLockTime;
}
public static String getTablename() {
return tableName;
}
}

View File

@@ -1,7 +1,8 @@
package com.nis.domain.configuration;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import java.util.ArrayList;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
@@ -42,6 +43,9 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
protected String srcPort;
@ExcelField(title="server_port",sort=5)
protected String destPort;
private AppFeatureProperties appFeaturePropCfg;
private List<AppFeatureProperties> appFeaturePropCfgList = new ArrayList();
/**
* 方向
@@ -71,6 +75,18 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
public Integer getIpType() {
return ipType;
}
public AppFeatureProperties getAppFeaturePropCfg() {
return appFeaturePropCfg;
}
public void setAppFeaturePropCfg(AppFeatureProperties appFeaturePropCfg) {
this.appFeaturePropCfg = appFeaturePropCfg;
}
public List<AppFeatureProperties> getAppFeaturePropCfgList() {
return appFeaturePropCfgList;
}
public void setAppFeaturePropCfgList(List<AppFeatureProperties> appFeaturePropCfgList) {
this.appFeaturePropCfgList = appFeaturePropCfgList;
}
/**
* @param ipType the ipType to set
*/

View File

@@ -39,6 +39,9 @@ public class AppTopicDomainCfg extends BaseCfg<AppTopicDomainCfg> {
@ExcelField(title="topic",dictType="TOPIC",sort=2)
private Long topicId;
private String topic;
private String websiteService;
/**
* 表达式类型
*/
@@ -180,4 +183,20 @@ public class AppTopicDomainCfg extends BaseCfg<AppTopicDomainCfg> {
this.websiteServiceId = websiteServiceId;
}
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
public String getWebsiteService() {
return websiteService;
}
public void setWebsiteService(String websiteService) {
this.websiteService = websiteService;
}
}

View File

@@ -39,8 +39,6 @@ public class AsnKeywordCfg extends BaseStringCfg<AsnKeywordCfg>{
this.matchMethod=3;
this.isHexbin=0;
}
@ExcelField(title="organization",sort=3)
protected String userRegion4;
public static String getTablename() {
return tableName;

View File

@@ -16,6 +16,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.nis.domain.BaseEntity;
import com.nis.domain.ScheduleCfg;
import com.nis.domain.SysMenu;
import com.nis.util.Constants;
import com.nis.util.StringUtil;
@@ -60,6 +61,14 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
protected Integer compileIsIssued;
protected String exType;//导出类型
protected String hColumns;//导出隐藏列
/**
* 定时任务信息
*/
//protected List<ScheduleCfg> schedules;
/**
* 定时任务信息2019年1月18日18:54:53 修改
*/
protected ScheduleCfg schedule;
private String commonGroupIds; //公共组织id(考虑一个compile存在多个asn组织的情况)
public String getCommonGroupIds() {
@@ -278,7 +287,20 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
protected Integer regionId;//仅用于copy属性使用
protected Integer numberRegionGroupId;//仅用于copy属性使用
protected Integer numberRegionRegionId;//仅用于copy属性使用
private Integer groupType; //url组以及dns组相关功能使用
private Integer udFlag; //url组以及dns组相关功能使用 过滤数据库数据标记
public Integer getGroupType() {
return groupType;
}
public void setGroupType(Integer groupType) {
this.groupType = groupType;
}
public Integer getUdFlag() {
return udFlag;
}
public void setUdFlag(Integer udFlag) {
this.udFlag = udFlag;
}
public Integer getNumberRegionGroupId() {
return numberRegionGroupId;
}
@@ -350,26 +372,24 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
*/
public void setFunctionId(Integer functionId) {
this.functionId = functionId;
if(!StringUtil.isEmpty(functionId) && StringUtil.isEmpty(this.menuNameCode)){
List<SysMenu> list = UserUtils.getMenuList();
}
public String getMenuNameCode() {
if(!StringUtil.isEmpty(this.functionId) && StringUtil.isEmpty(menuNameCode)){
List<SysMenu> list = UserUtils.getMenuCfgList();
if(!StringUtil.isEmpty(list)) {
for (SysMenu menu :list) {
if (!StringUtil.isEmpty(menu.getCode())
&&menu.getFunctionId()!=null
&& menu.getFunctionId().equals(functionId)
&& menu.getFunctionId().equals(this.functionId)
//&& menu.getFunctionId().equals(functionId)
) {
this.setMenuNameCode(menu.getCode());
break;
}
}
}
}
}
public String getMenuNameCode() {
return menuNameCode;
}
public void setMenuNameCode(String menuNameCode) {
@@ -982,5 +1002,12 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
public void setDoBlackList(Integer doBlackList) {
this.doBlackList = doBlackList;
}
public ScheduleCfg getSchedule() {
return schedule;
}
public void setSchedule(ScheduleCfg schedule) {
this.schedule = schedule;
}
}

View File

@@ -75,7 +75,7 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
protected String organization; //仅用于copy属性使用
protected String country; //仅用于copy属性使用
protected String detail; //仅用于copy属性使用
@ExcelField(title="log_total",sort=42)
// @ExcelField(title="log_total",sort=42)
private Long totalLogs;
public String getOrganization() {

View File

@@ -238,7 +238,13 @@ public class BaseStringCfg<T> extends BaseCfg<T> {
for (int i = 0; i < list.size(); i++) {
BaseStringCfg base=(BaseStringCfg)list.get(i);
base.setIsHex(base.getIsHexbin());
base.setIsCaseInsenstive(base.getIsHexbin());
// base.setIsCaseInsenstive(base.getIsHexbin());
// '默认为0:大小写不敏感且非HEX;1:HEX格式二进制;2:大小写敏感且非HEX',
if(base.getIsHexbin()==2){
base.setIsCaseInsenstive(1);
}else{
base.setIsCaseInsenstive(0);
}
base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***"," "));
}
return list;
@@ -248,7 +254,13 @@ public class BaseStringCfg<T> extends BaseCfg<T> {
for (int i = 0; i < list.size(); i++) {
BaseStringCfg base=(BaseStringCfg)list.get(i);
base.setIsHex(base.getIsHexbin());
base.setIsCaseInsenstive(base.getIsHexbin());
// base.setIsCaseInsenstive(base.getIsHexbin());
// '默认为0:大小写不敏感且非HEX;1:HEX格式二进制;2:大小写敏感且非HEX',
if(base.getIsHexbin()==2){
base.setIsCaseInsenstive(1);
}else{
base.setIsCaseInsenstive(0);
}
}
return list;
}

View File

@@ -15,6 +15,7 @@ import com.google.gson.annotations.Expose;
import com.nis.domain.basics.AsnGroupInfo;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.basics.IpReuseIpCfg;
import com.nis.domain.basics.UrlCommGroupCfg;
import com.nis.util.Constants;
import com.nis.util.excel.ExcelField;
@@ -89,7 +90,8 @@ public class CfgIndexInfo extends BaseCfg<CfgIndexInfo> {
@ExcelField(title="log_total",sort=42)
private Long totalLogs;
private UrlCommGroupCfg urlCommGroupCfg;
private List<UrlCommGroupCfg> urlCommGroupList;
/*private CachePolicyUserRegion cachePolicyUserRegion;//缓存策略用户自定义域参数
public static class CachePolicyUserRegion{
@@ -411,4 +413,16 @@ public class CfgIndexInfo extends BaseCfg<CfgIndexInfo> {
public void setTotalLogs(Long totalLogs) {
this.totalLogs = totalLogs;
}
public List<UrlCommGroupCfg> getUrlCommGroupList() {
return urlCommGroupList;
}
public void setUrlCommGroupList(List<UrlCommGroupCfg> urlCommGroupList) {
this.urlCommGroupList = urlCommGroupList;
}
public UrlCommGroupCfg getUrlCommGroupCfg() {
return urlCommGroupCfg;
}
public void setUrlCommGroupCfg(UrlCommGroupCfg urlCommGroupCfg) {
this.urlCommGroupCfg = urlCommGroupCfg;
}
}

View File

@@ -211,7 +211,12 @@ public class ComplexkeywordCfg extends BaseCfg<ComplexkeywordCfg>{
for (int i = 0; i < list.size(); i++) {
ComplexkeywordCfg base=(ComplexkeywordCfg)list.get(i);
base.setIsHex(base.getIsHexbin());
base.setIsCaseInsenstive(base.getIsHexbin());
// '默认为0:大小写不敏感且非HEX;1:HEX格式二进制;2:大小写敏感且非HEX',
if(base.getIsHexbin()==2){
base.setIsCaseInsenstive(1);
}else{
base.setIsCaseInsenstive(0);
}
base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***"," "));
}
return list;

View File

@@ -29,6 +29,8 @@ public class DdosIpCfg extends BaseIpCfg {
private Long bpsThreadshold;// 即DDoS攻击保护动作触发阈值每秒Bit数和每秒包数
@ExcelField(title="pps_threadshold",sort=48)
private Long ppsThreadshold;
@ExcelField(title="log_total",sort=42)
private Long totalLogs;
public String getAntiddosProtocol() {
return antiddosProtocol;
@@ -54,6 +56,12 @@ public class DdosIpCfg extends BaseIpCfg {
public void setIndexTable(String indexTable) {
this.indexTable = indexTable;
}
public Long getTotalLogs() {
return totalLogs;
}
public void setTotalLogs(Long totalLogs) {
this.totalLogs = totalLogs;
}
}

View File

@@ -0,0 +1,242 @@
/**
*@Title: BaseEnhancedStringConfig.java
*@Package com.nis.domain.restful
*@Description TODO
*@author dell
*@date 2018年2月5日 下午5:42:52
*@version 版本号
*/
package com.nis.domain.configuration;
import java.util.List;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.taglibs.standard.functions.Functions;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.nis.util.excel.ExcelField;
/**
* @ClassName: BaseEnhancedStringConfig.java
* @Description: 基础增强字符串类配置
* @author (wx)
* @date 2018年2月5日 下午5:42:52
* @version V1.0
*/
public class DnsKeywordCfg extends BaseCfg<DnsKeywordCfg>{
/**
* @Fields serialVersionUID:TODO用一句话描述这个变量表示什么
*
* @since 1.0.0
*/
private static final long serialVersionUID = -1417089397345367232L;
private static final String tableName="dns_domain_cfg";
/**
* 匹配区域
*/
@Expose
@ExcelField(title="district",sort=301)
@SerializedName("district")
protected String district ;
protected String districtShowName;
protected String dnsGroupName;
/**
* 关键字
*/
@Expose
@SerializedName("keywords")
@ExcelField(title="key_word",sort=302)
protected String cfgKeywords;
protected String keywordsShowName;
/**
* 表达式类型
*/
@Expose
@SerializedName("exprType")
@ExcelField(title="expression_type",dictType="EXPRESSION_TYPE",sort=303)
protected Integer exprType ;
/**
* 匹配方式
*/
@Expose
@ExcelField(title="match_method",dictType="MATCH_METHOD",sort=304)
@SerializedName("matchMethod")
protected Integer matchMethod ;
/**
* 是否hex
*/
@ExcelField(title="is_hex",sort=305)
protected Integer isHex;
/**
* 是否hex
*/
@ExcelField(title="is_case_insenstive",sort=306)
protected Integer isCaseInsenstive;
/**
* 是否hex二进制
*/
@Expose
@SerializedName("isHexbin")
protected Integer isHexbin ;
/**
* district
* @return district
*/
public String getDistrict() {
return district;
}
/**
* copy属性使用
*/
protected Long dnsStrategyId;
protected Integer appCode;//仅用于copy属性使用
protected Integer behavCode;//仅用于copy属性使用
protected Integer specServiceId;//仅用于copy属性使用
public Integer getAppCode() {
return appCode;
}
public void setAppCode(Integer appCode) {
this.appCode = appCode;
}
public Integer getBehavCode() {
return behavCode;
}
public void setBehavCode(Integer behavCode) {
this.behavCode = behavCode;
}
public Integer getSpecServiceId() {
return specServiceId;
}
public void setSpecServiceId(Integer specServiceId) {
this.specServiceId = specServiceId;
}
public Long getDnsStrategyId() {
return dnsStrategyId;
}
public void setDnsStrategyId(Long dnsStrategyId) {
this.dnsStrategyId = dnsStrategyId;
}
/**
* @param district the district to set
*/
public void setDistrict(String district) {
this.district = district;
}
public String getCfgKeywords() {
// cfgKeywords = StringEscapeUtils.unescapeHtml4(cfgKeywords);
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
public String getDistrictShowName() {
return districtShowName;
}
public void setDistrictShowName(String districtShowName) {
this.districtShowName = districtShowName;
}
/**
* exprType
* 继承此类的类会覆盖该方法写自己的缺省值
* @return exprType
*/
public Integer getExprType() {
return this.exprType;
}
/**
* @param exprType the exprType to set
*/
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
/**
* matchMethod
* 继承此类的类会覆盖该方法写自己的缺省值
* @return matchMethod
*/
public Integer getMatchMethod() {
return this.matchMethod;
}
/**
* @param matchMethod the matchMethod to set
*/
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
/**
* isHexbin
* @return isHexbin
*/
public Integer getIsHexbin() {
return isHexbin;
}
/**
* @param isHexbin the isHexbin to set
*/
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
public Integer getIsHex() {
return isHex;
}
public void setIsHex(Integer isHex) {
this.isHex =isHex;
}
public Integer getIsCaseInsenstive() {
return isCaseInsenstive;
}
public void setIsCaseInsenstive(Integer isCaseInsenstive) {
this.isCaseInsenstive =isCaseInsenstive;
}
/* (non-Javadoc)
* @see com.nis.domain.configuration.BaseCfg#initDefaultValue()
*/
@Override
public void initDefaultValue() {
// TODO Auto-generated method stub
super.initDefaultValue();
this.exprType=0;
this.isHexbin = 0 ;
this.matchMethod=3;
}
public static List<DnsKeywordCfg> replaceComplexKeyList(List<DnsKeywordCfg> list){
for (int i = 0; i < list.size(); i++) {
DnsKeywordCfg base=(DnsKeywordCfg)list.get(i);
base.setIsHex(base.getIsHexbin());
// '默认为0:大小写不敏感且非HEX;1:HEX格式二进制;2:大小写敏感且非HEX',
if(base.getIsHexbin()==2){
base.setIsCaseInsenstive(1);
}else{
base.setIsCaseInsenstive(0);
}
base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***"," "));
}
return list;
}
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
public static String getTablename() {
return tableName;
}
public void setDnsGroupName(String dnsGroupName) {
this.dnsGroupName = dnsGroupName;
}
public String getDnsGroupName() {
return dnsGroupName;
}
}

View File

@@ -13,7 +13,7 @@ public class AsnIpTemplate extends BasicTemplate{
* @since 1.0.0
*/
private String cfgDesc;
/*private String cfgDesc;*/
private String userRegion1;
private String destIpAddress;
private String organization;
@@ -21,12 +21,12 @@ public class AsnIpTemplate extends BasicTemplate{
private String detail;
// @ExcelField(title="config_describe",align=2,sort=1)
public String getCfgDesc() {
/*public String getCfgDesc() {
return cfgDesc;
}
public void setCfgDesc(String cfgDesc) {
this.cfgDesc = cfgDesc;
}
}*/
@ExcelField(title="asn_no",align=2,sort=11)
public String getUserRegion1() {
return userRegion1;
@@ -42,14 +42,14 @@ public class AsnIpTemplate extends BasicTemplate{
public void setDestIpAddress(String destIpAddress) {
this.destIpAddress = destIpAddress;
}
@ExcelField(title="asn_name",align=2,sort=1)
@ExcelField(title="organization",align=2,sort=1)
public String getOrganization() {
return organization;
}
public void setOrganization(String organization) {
this.organization = organization;
}
@ExcelField(title="country_code",align=2,sort=14)
@ExcelField(title="country",align=2,sort=14)
public String getCountry() {
return country;
}

View File

@@ -7,28 +7,12 @@ import com.nis.util.excel.ExcelField;
* @author dell
*
*/
public class TopicWebsiteTemplate extends StringAllTemplate{
public class TopicWebsiteTemplate extends StringAllNotDoLogTemplate{
private Long topicId; // 主题
private Long websiteServiceId; // 网站
private String topic; // 主题
private String websiteService; // 网站
private String cfgKeywords; // 域名
@ExcelField(title="topic",dictType="TOPIC",sort=2)
public Long getTopicId() {
return topicId;
}
public void setTopicId(Long topicId) {
this.topicId = topicId;
}
@ExcelField(title="website_server",dictType="WEBSITE_SERVER",sort=3)
public Long getWebsiteServiceId() {
return websiteServiceId;
}
public void setWebsiteServiceId(Long websiteServiceId) {
this.websiteServiceId = websiteServiceId;
}
@ExcelField(title="domain_name",sort=4)
public String getCfgKeywords() {
return cfgKeywords;
@@ -37,4 +21,20 @@ public class TopicWebsiteTemplate extends StringAllTemplate{
this.cfgKeywords = cfgKeywords;
}
@ExcelField(title="topic",sort=2)
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
@ExcelField(title="website_server",sort=3)
public String getWebsiteService() {
return websiteService;
}
public void setWebsiteService(String websiteService) {
this.websiteService = websiteService;
}
}

View File

@@ -0,0 +1,37 @@
package com.nis.domain.configuration.template;
import com.nis.util.excel.ExcelField;
/**
* @Description: excel导入url分组 配置
*/
public class UrlCommGroupTemplate extends BasicTemplate{
private String cfgDesc;
private String cfgKeywords;
private String matchMethod;
@ExcelField(title="config_describe",align=2,sort=1)
public String getCfgDesc() {
return cfgDesc;
}
public void setCfgDesc(String cfgDesc) {
this.cfgDesc = cfgDesc;
}
@ExcelField(title="key_word",align=2,sort=2)
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
@ExcelField(title="match_method",dictType="MATCH_METHOD",sort=3)
public String getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(String matchMethod) {
this.matchMethod = matchMethod;
}
}

View File

@@ -18,6 +18,7 @@ public class SysIspInfo implements Serializable {
private Integer ispKeyCode;// 运营商唯一标识编码,
private Date createTime;
private String ispNum; // 出入口跟设备号拼接
public Long getId() {
return id;
@@ -67,6 +68,11 @@ public class SysIspInfo implements Serializable {
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getIspNum() {
return ispNum;
}
public void setIspNum(String ispNum) {
this.ispNum = ispNum;
}
}

View File

@@ -1,5 +1,6 @@
package com.nis.domain.log;
import com.google.gson.annotations.Expose;
import com.nis.util.excel.ExcelField;
public class NtcConnRecordLog extends BaseLogEntity<NtcConnRecordLog> {
@@ -29,6 +30,8 @@ public class NtcConnRecordLog extends BaseLogEntity<NtcConnRecordLog> {
protected String totalByte;
protected String ispCode;//运营商
protected String ispNum;//运营商 entrance_id+device_id
protected String ispName;//运营商
@@ -120,4 +123,20 @@ public class NtcConnRecordLog extends BaseLogEntity<NtcConnRecordLog> {
this.s2cByteNum = s2cByteNum;
}
public String getIspName() {
return ispName;
}
public void setIspName(String ispName) {
this.ispName = ispName;
}
public String getIspNum() {
return ispNum;
}
public void setIspNum(String ispNum) {
this.ispNum = ispNum;
}
}

View File

@@ -31,7 +31,7 @@ public class PxyHttpLog extends BaseLogEntity<NtcIpLog> {
@ExcelField(title="req_body",sort=78)
private String reqBody;
@ExcelField(title="resp_body",sort=79)
private String resBody;
private String respBody;
@ExcelField(title="website",sort=8)
private String website;
@@ -115,23 +115,30 @@ public class PxyHttpLog extends BaseLogEntity<NtcIpLog> {
public void setReqBody(String reqBody) {
this.reqBody = reqBody;
}
public String getResBody() {
return resBody;
public String getRespBody() {
return respBody;
}
public void setResBody(String resBody) {
this.resBody = resBody;
public void setRespBody(String respBody) {
this.respBody = respBody;
}
@Override
public String toString() {
return "{\"url\"=\"" + url + "\", \"reqLine\"=\"" + reqLine
+ "\", \"resLine\"=\"" + resLine + "\", \"cookie\"=\"" + cookie
+ "\", \"referer\"=\"" + referer + "\", \"userAgent\"=\""
+ userAgent + "\", \"contentLen\"=\"" + contentLen
+ "\", \"contentType\"=\"" + contentType
+ "\", \"setCookie\"=\"" + setCookie + "\", \"reqHeader\"=\""
+ reqHeader + "\", \"respHeader\"=\"" + respHeader
+ "\", \"reqBody\"=\"" + reqBody + "\", \"resBody\"=\""
+ resBody + "\"}";
return "PxyHttpLog [url=" + url + ", reqLine=" + reqLine + ", resLine=" + resLine + ", cookie=" + cookie
+ ", referer=" + referer + ", userAgent=" + userAgent + ", contentLen=" + contentLen + ", contentType="
+ contentType + ", setCookie=" + setCookie + ", reqHeader=" + reqHeader + ", respHeader=" + respHeader
+ ", reqBody=" + reqBody + ", respBody=" + respBody + ", website=" + website + ", cfgId=" + cfgId
+ ", foundTime=" + foundTime + ", recvTime=" + recvTime + ", transProto=" + transProto + ", addrType="
+ addrType + ", dIp=" + dIp + ", sIp=" + sIp + ", dPort=" + dPort + ", sPort=" + sPort + ", service="
+ service + ", entranceId=" + entranceId + ", deviceId=" + deviceId + ", direction=" + direction
+ ", streamDir=" + streamDir + ", capIp=" + capIp + ", addrList=" + addrList + ", serverLocate="
+ serverLocate + ", clientLocate=" + clientLocate + ", sAsn=" + sAsn + ", dAsn=" + dAsn
+ ", sSubscribeId=" + sSubscribeId + ", dSubscribeId=" + dSubscribeId + ", sceneFile=" + sceneFile
+ ", functionId=" + functionId + ", action=" + action + ", date=" + date + ", seltype=" + seltype
+ ", searchFoundStartTime=" + searchFoundStartTime + ", searchFoundEndTime=" + searchFoundEndTime
+ ", isLogTotalSearch=" + isLogTotalSearch + ", orderBy=" + orderBy + ", encapType=" + encapType
+ ", linkId=" + linkId + ", innerSmac=" + innerSmac + ", innerDmac=" + innerDmac + ", id=" + id
+ ", currentUser=" + currentUser + ", page=" + page + ", pageLog=" + pageLog + ", sqlMap=" + sqlMap
+ ", isNewRecord=" + isNewRecord + ", isFilterAction=" + isFilterAction + "]";
}
}

View File

@@ -54,6 +54,8 @@ public class ToUpdateMaatBeanStatus implements Serializable{
@Expose
private Integer isValid;
@Expose
private Integer service;
@Expose
@SerializedName("opTime")
private Date auditTime;
public Integer getCompileId() {
@@ -74,6 +76,12 @@ public class ToUpdateMaatBeanStatus implements Serializable{
public void setAuditTime(Date auditTime) {
this.auditTime = auditTime;
}
public Integer getService() {
return service;
}
public void setService(Integer service) {
this.service = service;
}
}
public String getVersion() {

View File

@@ -6,9 +6,7 @@ import com.nis.util.excel.ExcelField;
public class NtcAsnRecord extends BaseLogEntity<NtcAsnRecord>{
private static final long serialVersionUID = -4947912502754359817L;
@ExcelField(title="GBps",sort=10)
protected String GBps;
//@ExcelField(title="bps",sort=10)
@ExcelField(title="bps",sort=10)
protected String bps;
@ExcelField(title="pps",sort=9)
protected String pps;
@@ -28,12 +26,6 @@ public class NtcAsnRecord extends BaseLogEntity<NtcAsnRecord>{
}
protected String searchAsnType;//1:d_asn;2:s_asn
public String getGBps() {
return bps;
}
public void setGBps(String gBps) {
GBps = this.getBps();
}
public String getBps() {
return bps;
}

View File

@@ -0,0 +1,93 @@
package com.nis.persistence.interceptor;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.log4j.Logger;
import com.nis.domain.ScheduleCfg;
import com.nis.domain.configuration.BaseCfg;
import com.nis.util.ServiceConfigTemplateUtil;
/**
* 定时任务 拦截器
* 1、拦截 select 操作
* 2、判断是否 form 查询配置主表
* 3、如果是配置主表查询对应的 scheduleCfg信息
* @author fang
*
*/
@Intercepts({@Signature(type = Executor.class,
method = "query",
args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})})
public class ScheduleSelectInterceptor extends BaseInterceptor{
private static final long serialVersionUID = -265785145929843646L;
private static final Logger logger = Logger.getLogger(ScheduleSelectInterceptor.class);
@Override
@SuppressWarnings("all")
public Object intercept(Invocation invocation) throws Throwable {
final MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
final Executor executor = (Executor)invocation.getTarget();
// select sql 查询结果
Object result = invocation.proceed();
if(result != null ) {
if(result instanceof Collection) {
Collection c = (Collection)result;
// if(c.size()==1) {//如果只查询一个 配置可以判定为是 form update 页面查询
if(c.size() >0) {//配置列表需要查询是否为定时任务,所以需要遍历
Iterator iterator = c.iterator();
while(iterator.hasNext()){
Object next = iterator.next();
if(next instanceof BaseCfg<?>) {
BaseCfg cfg = (BaseCfg)next;
//结果集的类名
String simpleName = next.getClass().getSimpleName();
//根据类名查找对应的 表名
String tableName = ServiceConfigTemplateUtil.getCfgTableNameByClassName(simpleName);
if(tableName != null) {//是配置主表
Configuration configuration = mappedStatement.getConfiguration();
MappedStatement scheduleStmt = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.findScheduleList");
ScheduleCfg sc = new ScheduleCfg();
sc.setTableName(tableName);
sc.setCfgId(cfg.getCfgId());
sc.setCompileId(cfg.getCompileId());
//executor.clearLocalCache();
List<ScheduleCfg> schedules = executor.query(scheduleStmt, sc, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
if(schedules != null&& schedules.size() > 0) {
cfg.setSchedule(schedules.get(0));
}
logger.debug(String.format("配置bean中赋值scheduleCfg,表名:%s,类名:%s,cfgId:%s,compileId:%s,schedules num:%s", tableName,simpleName,sc.getCfgId(),sc.getCompileId(),schedules==null?0:schedules.size()));
}
}else{
break;
}
}
}
}
}
return result;
}
@Override
public Object plugin(Object target) {
return Plugin.wrap(target, this);
}
@Override
public void setProperties(Properties properties) {
}
}

View File

@@ -0,0 +1,389 @@
package com.nis.persistence.interceptor;
import java.lang.reflect.Array;
import java.sql.SQLException;
import java.text.DateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ParameterMapping;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.TypeHandlerRegistry;
import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;
import com.alibaba.druid.sql.ast.statement.SQLUpdateSetItem;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement;
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
import com.google.common.collect.Lists;
import com.nis.domain.ScheduleCfg;
import com.nis.domain.ScheduleExceInfo;
import com.nis.domain.configuration.BaseCfg;
import com.nis.util.ServiceConfigTemplateUtil;
import com.nis.web.security.UserUtils;
import jersey.repackaged.com.google.common.collect.Sets;
/**
* 定时任务 拦截器
* 1、拦截insert,update,delete操作
* 2、判断是否是需要下发配置的表
* 3、如果是需要下发配置的表则同时将数据保存到schedule_cfg表中并调用定时任务
* @author fang
*
*/
@Intercepts({@Signature(
type= Executor.class,
method = "update",
args = {MappedStatement.class,Object.class})})
public class ScheduleUpdateInterceptor extends BaseInterceptor{
private static final long serialVersionUID = -265785145929843646L;
private static final Logger logger = Logger.getLogger(ScheduleUpdateInterceptor.class);
private static final String TABLE_NAME_INSERT_REG = "^\\s*insert\\s+into\\s+([\\w_-]+)\\s*\\(";
private static final Pattern TABLE_NAME_INSERT_PATTERN = Pattern.compile(TABLE_NAME_INSERT_REG, Pattern.CASE_INSENSITIVE);//大小写
private static final String TABLE_NAME_UPDATE_REG = "^\\s*update\\s+([\\w_-]+)";
private static final Pattern TABLE_NAME_UPDATE_PATTERN = Pattern.compile(TABLE_NAME_UPDATE_REG, Pattern.CASE_INSENSITIVE);//大小写
private static final String TABLE_NAME_DELETE_REG = "^\\s*delete\\s+from\\s+([\\w_-]+)";
private static final Pattern TABLE_NAME_DELETE_PATTERN = Pattern.compile(TABLE_NAME_DELETE_REG, Pattern.CASE_INSENSITIVE);//大小写
/**
* 排除拦截的id
*/
private static final Set<String> EXCLUDE_MAPPER_IDS = Sets.newHashSet();
static {
EXCLUDE_MAPPER_IDS.add("com.nis.web.dao.SchedulerDao.updateCfgTableStatus");
EXCLUDE_MAPPER_IDS.add("com.nis.web.dao.basics.ServiceDictInfoDao");
}
/**
* is_valid 字段名
*/
private static final String IS_VALID_COLUMN = "is_valid";
/**
* is_audit 字段名
*/
private static final String IS_AUDIT_COLUMN = "is_audit";
@Override
@SuppressWarnings("all")
public Object intercept(Invocation invocation) throws Throwable {
final MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
final Executor executor = (Executor)invocation.getTarget();
Object parameter = invocation.getArgs()[1];//被拦截的 sql 参数
BoundSql boundSql = mappedStatement.getBoundSql(parameter);
Object result = invocation.proceed();//被拦截的 sql 操作 继续执行
String curProceedId = mappedStatement.getId();
//不需要拦截的操作直接返回结果
if(EXCLUDE_MAPPER_IDS.contains(curProceedId)) {
return result;
}
String tableName = null;//操作的表名
//mybatis 整个mapper 信息
Configuration configuration = mappedStatement.getConfiguration();
//被拦截的 sql语句
String sql = boundSql.getSql();
//所有需要拦截的表名
Set<String> tableNames = ServiceConfigTemplateUtil.getCompileTableName();
switch (mappedStatement.getSqlCommandType()) {
case INSERT://新增配置
Matcher insertMatcher = TABLE_NAME_INSERT_PATTERN.matcher(sql);
tableName = insertMatcher.find()?insertMatcher.group(1):tableName;
if(tableName != null && tableNames.contains(tableName.toLowerCase())) {
insertCfg(executor,parameter, configuration,tableName);
}
break;
case UPDATE://更新配置
Matcher updateMatcher = TABLE_NAME_UPDATE_PATTERN.matcher(sql);
tableName = updateMatcher.find()?updateMatcher.group(1):tableName;
if(tableName != null && tableNames.contains(tableName.toLowerCase())) {
updateCfg(executor,boundSql, configuration,tableName);
}
break;
case DELETE://删除配置
Matcher deleteMatcher = TABLE_NAME_DELETE_PATTERN.matcher(sql);
tableName = deleteMatcher.find()?deleteMatcher.group(1):tableName;
if(tableName != null && tableNames.contains(tableName.toLowerCase())) {
deleteCfg(executor,parameter, configuration,tableName);
}
break;
default:
break;
}
logger.debug(sql);
return result;
}
@Override
public Object plugin(Object target) {
return Plugin.wrap(target, this);
}
/**
* @throws SQLException
*
*/
@SuppressWarnings("all")
private void insertCfg(Executor executor,Object parameterObject,Configuration configuration,String tableName) throws SQLException {
List<BaseCfg> cfgList = Lists.newArrayList();
//确保 单个,批量都适用
if(parameterObject instanceof BaseCfg<?>) {//单个添加
BaseCfg<?> baseCfg = (BaseCfg<?>)parameterObject;
cfgList.add(baseCfg);
}else if(parameterObject instanceof Collection) {
Collection<BaseCfg<?>> bcCollection = (Collection<BaseCfg<?>>)parameterObject;
cfgList.addAll(bcCollection);
}else if(parameterObject.getClass().isArray()) {
int length = Array.getLength(parameterObject);
for(int i = 0;i< length;i++) {
BaseCfg<?> baseCfg = (BaseCfg<?>)Array.get(parameterObject, i);
cfgList.add(baseCfg);
}
}
//整理需要 insert 的 schedule_cfg 的数据
List<ScheduleCfg> scheduleList = Lists.newArrayList();
for(BaseCfg<?> baseCfg : cfgList) {
baseCfg.setIsValid(0);//设置默认值
baseCfg.setIsAudit(0);//设置默认值
ScheduleCfg scList = copyScheduleCfgFromBaseCfg(baseCfg, tableName);
if(scList!=null){
scheduleList.add(scList);
}
}
if(scheduleList.size() > 0) {
for(ScheduleCfg sc : scheduleList) {
MappedStatement statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.insert");
executor.update(statement, sc);
}
}
}
/**
*
*/
@SuppressWarnings("all")
private void updateCfg(Executor executor,BoundSql boundSql,Configuration configuration,String tableName) throws SQLException {
/*
* 条件1 is_valid=0,is_audit=0; 未生效之前修改,来自修改页面
*1、首先将所有相关定时任务信息取消
*2、 新增 定时任务信息
*/
Object parameterObject = boundSql.getParameterObject();
if(parameterObject instanceof BaseCfg) {
BaseCfg bc = (BaseCfg)parameterObject;
Integer isValid = bc.getIsValid();
Integer isAudit = bc.getIsAudit();
Integer compileId = bc.getCompileId();
Long cfgId = bc.getCfgId();
if(isValid == 0 && isAudit == 0) {
ScheduleCfg sc = new ScheduleCfg();
sc.setCompileId(compileId);
sc.setEditorId(bc.getEditorId());
sc.setEditTime(bc.getEditTime());
sc.setCfgId(cfgId);
//根据 compileId 删除之前的
MappedStatement statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.deleteByCompileId");
executor.update(statement, sc);
//新增 更改的
ScheduleCfg schedule = copyScheduleCfgFromBaseCfg(bc, tableName);
if(schedule != null ) {
statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.insert");
executor.update(statement, schedule);
//配置信息新增,或取消之后重新修改,需要修改 exce_new表的状态
statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.updateScheduleExceNew");
ScheduleExceInfo exceNew = new ScheduleExceInfo();
exceNew.setCompileId(compileId);
exceNew.setIssueStatus(1);
exceNew.setIsIssue(1);//定时任务执行时需要下发配置
executor.update(statement, exceNew);
}
return;
}
}
//完整的sql语句已经完成 ? 替换
String sql = showSql(configuration, boundSql);
log.debug(String.format("cfg update sql : " , sql));
//其它剩余基本判定为 修改状态的 update
MySqlStatementParser parser = new MySqlStatementParser(sql);
MySqlUpdateStatement updateSqlStmt = (MySqlUpdateStatement)parser.parseStatement();
List<SQLUpdateSetItem> items = updateSqlStmt.getItems();
/* 分别获取 is_audit & is_valid 的值*/
Integer isValid = null;
Integer isAudit = null;
for(SQLUpdateSetItem item : items) {
if(IS_VALID_COLUMN.equalsIgnoreCase(item.getColumn().toString())) {
isValid = Integer.valueOf(item.getValue().toString());
continue;
}
if(IS_AUDIT_COLUMN.equalsIgnoreCase(item.getColumn().toString())) {
isAudit = Integer.valueOf(item.getValue().toString());
continue;
}
if(isValid != null && isAudit != null) {
break;
}
}
//isValid 和 isAudit 同时为空,目前发现有 取消来函的 update 操作有此情况
if(isValid == null && isAudit == null) {
return;
}
//获取当前的update 条件
String whereStr = updateSqlStmt.getWhere().toString();
StringBuilder whereSb = new StringBuilder();
whereSb.append(" and table_name = '");
whereSb.append(tableName);
whereSb.append("' and ( ");
whereSb.append(whereStr);
whereSb.append(" )");
//根据当前的 update 条件 查出所有符合条件的 schedule_cfg 数据
MappedStatement scheduleStmt = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.findScheduleList");
ScheduleCfg sc = new ScheduleCfg();
sc.setWhereStr(whereSb.toString());
List<ScheduleCfg> schedules = executor.query(scheduleStmt, sc, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
if(schedules != null && schedules.size() > 0) {//有符合条件的 定时任务
Set<Integer> compileSet = Sets.newHashSet();//保存操作的所有 compileId
Date now = new Date();//当前时间
//1、将符合条件的是 ScheduleCfg update del_flag = 0
for(ScheduleCfg scfg : schedules) {
compileSet.add(scfg.getCompileId());
scfg.setEditorId(UserUtils.getUser().getId());
scfg.setEditTime(now);
MappedStatement statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.deleteByCompileId");
executor.update(statement, scfg);
}
//2、把原信息 重新保存,并修改 is_valid ,is_audit 状态
for(ScheduleCfg scfg : schedules) {
MappedStatement statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.insert");
scfg.setIsValid(isValid);
scfg.setIsAudit(isAudit);
executor.update(statement, scfg);
}
//手动 审核通过,立即生效时 已经下发,修改 exce_new 表的是否需要下发字段为 不需要 0
if(isValid == 1 && isAudit == 1) {
for(Integer ci : compileSet) {
MappedStatement statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.findScheduleExceNew");
ScheduleExceInfo se = new ScheduleExceInfo();
se.setCompileId(ci);
se.setIsValid(isValid);
List<ScheduleExceInfo> seList = executor.query(statement, se, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
if(seList == null || seList.size() < 1) {//没有执行记录,新增一条
//配置信息新增,或取消之后重新修改,需要修改 exce_new表的状态
statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.insertScheduleExceNew");
ScheduleExceInfo exceNew = new ScheduleExceInfo();
exceNew.setCompileId(ci);
exceNew.setIssueStatus(1);
exceNew.setIsIssue(0);//已经下发,定时任务不需要下发
exceNew.setExceTime(new Date());
executor.update(statement, exceNew);
}else {
//配置信息新增,或取消之后重新修改,需要修改 exce_new表的状态
statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.updateScheduleExceNew");
ScheduleExceInfo exceNew = new ScheduleExceInfo();
exceNew.setCompileId(ci);
exceNew.setIssueStatus(1);
exceNew.setIsIssue(0);//已经下发,定时任务不需要下发
executor.update(statement, exceNew);
}
}
}
}
}
/**
* 暂时没有发现有 删除操作
*/
@SuppressWarnings("all")
private void deleteCfg(Executor executor,Object parameterObject,Configuration configuration,String tableName) throws SQLException {
}
/**
* 从 basecfg 实体类中获取 schedule cfg
* @param baseCfg
* @param tableName
* @return
*/
private ScheduleCfg copyScheduleCfgFromBaseCfg(BaseCfg<?> baseCfg,String tableName){
ScheduleCfg schedule = baseCfg.getSchedule();
if(schedule != null ) {
BeanUtils.copyProperties(baseCfg, schedule,new String[]{"userRegion1","userRegion2","userRegion3","userRegion4","userRegion5"});
schedule.setTableName(tableName);
}
return schedule;
}
/*如果参数是String则添加单引号 如果是日期,则转换为时间格式器并加单引号; 对参数是null和不是null的情况作了处理*/
private static String getParameterValue(Object obj) {
String value = null;
if (obj instanceof String) {
value = "'" + obj.toString() + "'";
} else if (obj instanceof Date) {
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.getDefault());
value = "'" + formatter.format(new Date()) + "'";
} else {
if (obj != null) {
value = obj.toString();
} else {
value = "null";
}
}
return value;
}
// 进行?的替换
public static String showSql(Configuration configuration, BoundSql boundSql) {
Object parameterObject = boundSql.getParameterObject(); // 获取参数
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
String sql = boundSql.getSql().replaceAll("[\\s]+", " "); // sql语句中多个空格都用一个空格代替
if (parameterMappings != null && parameterMappings.size() >0 && parameterObject != null) {
TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry(); // 获取类型处理器注册器类型处理器的功能是进行java类型和数据库类型的转换<br>       // 如果根据parameterObject.getClass()可以找到对应的类型,则替换
if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
sql = sql.replaceFirst("\\?", Matcher.quoteReplacement(getParameterValue(parameterObject)));
} else {
MetaObject metaObject = configuration.newMetaObject(parameterObject);// MetaObject主要是封装了originalObject对象提供了get和set的方法用于获取和设置originalObject的属性值,主要支持对JavaBean、Collection、Map三种类型对象的操作
for (ParameterMapping parameterMapping : parameterMappings) {
String propertyName = parameterMapping.getProperty();
if (metaObject.hasGetter(propertyName)) {
Object obj = metaObject.getValue(propertyName);
sql = sql.replaceFirst("\\?", Matcher.quoteReplacement(getParameterValue(obj)));
} else if (boundSql.hasAdditionalParameter(propertyName)) {
Object obj = boundSql.getAdditionalParameter(propertyName); // 该分支是动态sql
sql = sql.replaceFirst("\\?", Matcher.quoteReplacement(getParameterValue(obj)));
}else{sql=sql.replaceFirst("\\?","缺失");}//打印出缺失,提醒该参数缺失并防止错位
}
}
}
return sql;
}
@Override
public void setProperties(Properties properties) {
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,519 @@
package com.nis.quartz;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import org.quartz.CalendarIntervalScheduleBuilder;
import org.quartz.CalendarIntervalTrigger;
import org.quartz.CronScheduleBuilder;
import org.quartz.DateBuilder;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobBuilder;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;
import org.quartz.PersistJobDataAfterExecution;
import org.quartz.ScheduleBuilder;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.TriggerKey;
import org.quartz.impl.matchers.GroupMatcher;
import org.quartz.impl.triggers.CalendarIntervalTriggerImpl;
import org.quartz.impl.triggers.CronTriggerImpl;
import org.quartz.spi.MutableTrigger;
import com.nis.domain.ScheduleCfg;
import com.nis.util.Constants;
import com.nis.util.DateUtil;
import com.nis.util.DateUtils;
import com.nis.util.StringUtils;
import com.nis.web.dao.SchedulerDao;
import com.nis.web.service.SpringContextHolder;
/**
* 定时任务 配置定时任务加载
* 1、每 n s 执行一次,每次读取 schedule_cfg 最新的数据
* 2、删除或新增 定时任务
* 3、单线程执行
* @author fang
*
*/
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class ScheduleCfgJob implements Job {
private static final Logger log = Logger.getLogger(ScheduleCfgJob.class);
/**
* 状态组格式statusGroup-compileId
*/
private static final String STATUS_GROUP = "statusGroup-";
private static final String STATUS_JOB = "STATUS-JOB";
/**
* 生效标识valid-cronexp
*/
private static final String VALID_KEY = "valid-";
/**
* 失效标识invalid-cronexp
*/
private static final String INVALID_KEY = "invalid-";
private static final JobKey STATUS_JOBKEY = JobKey.jobKey(STATUS_JOB, "statusGroup");
private static final JobDetail STATUS_JOBDETAIL = JobBuilder.newJob(ScheduleStatusJob.class)
.withIdentity(STATUS_JOBKEY)
.storeDurably(true)
.build();
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
Scheduler scheduler = context.getScheduler();
SchedulerDao dao = SpringContextHolder.getBean(SchedulerDao.class);
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
long scheduleCfgId = dataMap.get("scheduleCfgId") == null ? 0:dataMap.getLong("scheduleCfgId");
long limit = dataMap.get("limit") == null ? 1000:dataMap.getLong("limit");
log.info(String.format("定时配置任务开始执行scheduleCfgId:%s,limit:%s",scheduleCfgId,limit ));
List<ScheduleCfg> newlyCfg = null;
int totalNum = 0;
do {
newlyCfg = dao.findNewlyCfg(scheduleCfgId, limit);
if(newlyCfg != null && newlyCfg.size() > 0) {
totalNum += newlyCfg.size();
for(ScheduleCfg cfg : newlyCfg) {//先取消之前的定时配置
Integer compileId = cfg.getCompileId();
try {
//取消之前所有的 trigger
GroupMatcher<TriggerKey> groupMatcher= GroupMatcher.triggerGroupEquals(STATUS_GROUP + compileId);
Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(groupMatcher);
if(triggerKeys != null && triggerKeys.size() > 0) {
for(TriggerKey tk : triggerKeys) {
scheduler.unscheduleJob(tk);
}
log.info(String.format("定时任务取消成功compile:%s", compileId));
}
} catch (Exception e) {
log.error(String.format("定时任务取消异常compileId:%s", compileId),e);
}
}
for(ScheduleCfg cfg : newlyCfg) {
Integer compileId = cfg.getCompileId();
try {
//判断状态,重新添加最新的 trigger
Integer isValid = cfg.getIsValid();
Integer isAudit = cfg.getIsAudit();
//添加定时任务的条件
if((isValid == 1 && isAudit == 1) || (isValid == 0 && isAudit == 0)) {
//添加定时任务包括valid 和 invalid
addJob(scheduler, cfg);
log.info(String.format("定时任务添加成功compile:%s", compileId));
}
} catch (Exception e) {
log.error(String.format("定时任务更新异常compileId:%s", compileId),e);
}
}
//最后 保存此次 最后的id
ScheduleCfg lastCfg = newlyCfg.get(newlyCfg.size() -1);
scheduleCfgId = lastCfg.getId();
dataMap.put("scheduleCfgId", scheduleCfgId);
log.info(String.format("加载定时任务total num :%s", newlyCfg.size()));
}
} while (newlyCfg != null && newlyCfg.size() > 0);
log.info(String.format("定时配置任务结束执行total num:%s",totalNum));
}
/**
* 将定时任务信息添加到 定时器框架中调度
* @param scheduler
* @param cfg
* @throws SchedulerException
*/
/*public static void addJob(Scheduler scheduler,ScheduleCfg cfg) throws SchedulerException {
Integer compileId = cfg.getCompileId();
String cronValid = cfg.getCronValid();
String cronInvalid = cfg.getCronInvalid();
Trigger validTrigger = createTrigger(cronValid, compileId, true, cfg);
Trigger invalidTrigger = createTrigger(cronInvalid, compileId, false, cfg);
boolean jobExist = scheduler.checkExists(STATUS_JOBKEY);
if(!jobExist) {//判断 job 是否存在,不存在添加
scheduler.addJob(STATUS_JOBDETAIL, false);
}
boolean checkExists = scheduler.checkExists(validTrigger.getKey());
if(!checkExists) {//判断 valid trigger 是否存在,不存在添加
scheduler.scheduleJob(validTrigger);
}else {
log.warn(String.format("Trigger already exists:%s ", validTrigger.getKey().toString()));
}
checkExists = scheduler.checkExists(invalidTrigger.getKey());
if(!checkExists) {//判断 invalid trigger 是否存在,不存在添加
scheduler.scheduleJob(invalidTrigger);
}else {
log.warn(String.format("Trigger already exists:%s ", invalidTrigger.getKey().toString()));
}
}*/
public static void addJob(Scheduler scheduler,ScheduleCfg cfg) throws SchedulerException {
List<Trigger> triList = createTrigger(cfg);
boolean jobExist = scheduler.checkExists(STATUS_JOBKEY);
if(!jobExist) {//判断 job 是否存在,不存在添加
scheduler.addJob(STATUS_JOBDETAIL, false);
}
for(Trigger tri : triList) {
boolean checkExists = scheduler.checkExists(tri.getKey());
if(!checkExists) {//判断 valid trigger 是否存在,不存在添加
log.debug(String.format("定时任务添加,%s", tri.getKey()));
scheduler.scheduleJob(tri);
log.info(String.format("定时任务添加成功,%s", tri.getKey()));
}else {
log.warn(String.format("Trigger already exists:%s ", tri.getKey().toString()));
}
}
}
/**
* 将页面配置的内容 转换成 trigger
* @param cfg
* @return
*/
public static List<Trigger> createTrigger(ScheduleCfg cfg){
String mode = cfg.getUserRegion1().toUpperCase();//定时任务运行模式:一次,每天,每周,每月
List<Trigger> triList = null;
switch (mode) {
case "SINGLE"://单次运行
triList = createSimpleTrigger(cfg);
break;
case "EVERYDAY"://每天运行 0 0 0 2/1 * ? ,不符合要求,定义每天都执行,然后在 代码判断 间隔时间
triList = createCalendarIntervalTrigger(cfg);
break;
case "EVERYWEEK"://每周运行
triList = createCalendarIntervalTrigger(cfg);
break;
case "EVERYMONTH"://每月运行
triList = createEveryMonthTrigger(cfg);
break;
default:
log.warn(String.format("unknown mode : %s ", mode));
break;
}
return triList;
}
/**
* 将时间转换成 时分秒
* @param time
* @return
*/
public static List<Integer> parseTime(String time) {
if(StringUtils.isNoneBlank(time)) {
String[] split = time.split(":");
List<Integer> tl = new ArrayList<Integer>(3);
for(String s : split) {
tl.add(Integer.valueOf(s));
}
return tl;
}
return null;
}
public static Trigger createCronTrigger(String cron,Integer compileId,boolean isValid,ScheduleCfg cfg) {
String triggerName = isValid ? (VALID_KEY + cron) : (INVALID_KEY + cron);
JobDataMap dataMap = new JobDataMap();
dataMap.put("isValid", isValid);
dataMap.put("cfg", cfg);
return TriggerBuilder.newTrigger()
.withIdentity(createTiggerKey(triggerName, STATUS_GROUP+compileId))
.withSchedule(CronScheduleBuilder.cronSchedule(cron))
.usingJobData(dataMap)
.forJob(STATUS_JOBDETAIL)
.build();
}
/**
* 一次执行
* @param cfg
* @return
*/
public static List<Trigger> createSimpleTrigger(ScheduleCfg cfg){
List<Trigger> triList = new ArrayList<Trigger>();
Integer compileId = cfg.getCompileId();
String cronValid = cfg.getCronValid();
String cronInvalid = cfg.getCronInvalid();
Date validDate = DateUtil.convertStringToDate(cronValid, Constants.COMMON_DATE_FORMAT);
Date invalidDate = DateUtil.convertStringToDate(cronInvalid, Constants.COMMON_DATE_FORMAT);
JobDataMap dataMap = new JobDataMap();
dataMap.put("isValid", true);
dataMap.put("cfg", cfg);
String triName = VALID_KEY + cfg.getUserRegion1() + "_" + cronValid;
Trigger trigger = TriggerBuilder.newTrigger()
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
.withSchedule(SimpleScheduleBuilder.simpleSchedule())
.usingJobData(dataMap)
.forJob(STATUS_JOBDETAIL)
.startAt(validDate)
.build();
triList.add(trigger);
dataMap = new JobDataMap();
dataMap.put("isValid", false);
dataMap.put("cfg", cfg);
triName = INVALID_KEY + cfg.getUserRegion1() + "_" + cronInvalid;
trigger = TriggerBuilder.newTrigger()
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
.withSchedule(SimpleScheduleBuilder.simpleSchedule())
.usingJobData(dataMap)
.forJob(STATUS_JOBDETAIL)
.startAt(invalidDate)
.build();
triList.add(trigger);
return triList;
}
/**
* 间隔 n 天 或 n 周执行
* @param cfg
* @return
*/
public static List<Trigger> createCalendarIntervalTrigger(ScheduleCfg cfg) {
List<Trigger> triList = new ArrayList<Trigger>();
Integer compileId = cfg.getCompileId();
String cronValid = cfg.getCronValid();
String cronInvalid = cfg.getCronInvalid();
String dayOrWeek = cfg.getUserRegion1();
Integer interval = Integer.valueOf(cfg.getUserRegion2());
List<Integer> validList = parseTime(cronValid);
List<Integer> invalidList = parseTime(cronInvalid);
Date validStartTime = DateBuilder.todayAt(validList.get(0), validList.get(1), validList.get(2));
Date invalidTime = DateBuilder.todayAt(invalidList.get(0), invalidList.get(1), invalidList.get(2));
CalendarIntervalScheduleBuilder intervalBuilder = null;
if("EVERYDAY".equalsIgnoreCase(dayOrWeek)) {
intervalBuilder = CalendarIntervalScheduleBuilder.calendarIntervalSchedule().withIntervalInDays(interval);
//valid
JobDataMap dataMap = new JobDataMap();
dataMap.put("isValid", true);
dataMap.put("cfg", cfg);
String triName = VALID_KEY + dayOrWeek+"("+interval+")" + "_" + DateUtils.formatDate(validStartTime, Constants.COMMON_DATE_FORMAT);
Trigger validTri = TriggerBuilder.newTrigger()
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
.withSchedule(intervalBuilder)
.usingJobData(dataMap)
.forJob(STATUS_JOBDETAIL)
.startAt(validStartTime)
.build();
triList.add(validTri);
//invalid
dataMap = new JobDataMap();
dataMap.put("isValid", false);
dataMap.put("cfg", cfg);
triName = INVALID_KEY + dayOrWeek +"("+interval+")" + "_" + DateUtils.formatDate(invalidTime, Constants.COMMON_DATE_FORMAT);
validTri = TriggerBuilder.newTrigger()
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
.withSchedule(intervalBuilder)
.usingJobData(dataMap)
.forJob(STATUS_JOBDETAIL)
.startAt(invalidTime)
.build();
triList.add(validTri);
}else if("EVERYWEEK".equalsIgnoreCase(dayOrWeek)) {
intervalBuilder = CalendarIntervalScheduleBuilder.calendarIntervalSchedule().withIntervalInWeeks(interval);
String[] weeks = cfg.getUserRegion3().split(",");
for(String week : weeks) {
if(StringUtils.isNoneBlank(week)) {
Date temp = closestAfterWeek(validStartTime, Integer.valueOf(week));
JobDataMap dataMap = new JobDataMap();
dataMap.put("isValid", true);
dataMap.put("cfg", cfg);
String triName = VALID_KEY + dayOrWeek +week+"("+interval+")" + "_" + DateUtils.formatDate(temp, Constants.COMMON_DATE_FORMAT);
Trigger validTri = TriggerBuilder.newTrigger()
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
.withSchedule(intervalBuilder)
.usingJobData(dataMap)
.forJob(STATUS_JOBDETAIL)
.startAt(temp)
.build();
triList.add(validTri);
//invalid
dataMap = new JobDataMap();
dataMap.put("isValid", false);
dataMap.put("cfg", cfg);
temp = closestAfterWeek(invalidTime, Integer.valueOf(week));
triName = INVALID_KEY + dayOrWeek +week+"("+interval+")" + "_" + DateUtils.formatDate(temp, Constants.COMMON_DATE_FORMAT);
validTri = TriggerBuilder.newTrigger()
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
.withSchedule(intervalBuilder)
.usingJobData(dataMap)
.forJob(STATUS_JOBDETAIL)
.startAt(temp)
.build();
triList.add(validTri);
}
}
}
return triList;
}
/**
* 每月 执行
* @param cfg
* @return
*/
public static List<Trigger> createEveryMonthTrigger(ScheduleCfg cfg){
String dayWeek = cfg.getUserRegion3();
String cronInvalid = cfg.getCronInvalid();
String cronValid = cfg.getCronValid();
StringBuilder cronSb = new StringBuilder();
Trigger trigger = null;
List<Integer> validList = parseTime(cronValid);//time 转换
List<Integer> invalidList = parseTime(cronInvalid);//time 转换
List<Trigger> triList = new ArrayList<Trigger>();
String userRegion4 = cfg.getUserRegion4().toUpperCase();
if("day".equalsIgnoreCase(dayWeek)) {//指定天
boolean hasL = userRegion4.contains("L");
StringBuilder chooseSb = new StringBuilder();
for(String str : userRegion4.split(",")) {
if(!"L".equalsIgnoreCase(str.trim())) {
chooseSb.append(",").append(str);
}
}
chooseSb.deleteCharAt(0);
cronSb.append(validList.get(2)).append(" ")//秒
.append(validList.get(1)).append(" ")//分
.append(validList.get(0)).append(" ")//小时
.append(chooseSb.toString()).append(" ")//日
.append(cfg.getUserRegion2()).append(" ")//月
.append("?").append(" ");//周
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), true, cfg);
triList.add(trigger);
cronSb.setLength(0);
cronSb.append(invalidList.get(2)).append(" ")//秒
.append(invalidList.get(1)).append(" ")//分
.append(invalidList.get(0)).append(" ")//小时
.append(chooseSb.toString()).append(" ")//日
.append(cfg.getUserRegion2()).append(" ")//月
.append("?").append(" ");//周
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), false, cfg);
triList.add(trigger);
if(hasL) {// 月的最后一天quartz 不支持 1,L 这种指定,所以 L单独处理一下
cronSb.setLength(0);
cronSb.append(validList.get(2)).append(" ")//秒
.append(validList.get(1)).append(" ")//分
.append(validList.get(0)).append(" ")//小时
.append("L").append(" ")//日
.append(cfg.getUserRegion2()).append(" ")//月
.append("?").append(" ");//周
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), true, cfg);
triList.add(trigger);
cronSb.setLength(0);
cronSb.append(invalidList.get(2)).append(" ")//秒
.append(invalidList.get(1)).append(" ")//分
.append(invalidList.get(0)).append(" ")//小时
.append("L").append(" ")//日
.append(cfg.getUserRegion2()).append(" ")//月
.append("?").append(" ");//周
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), false, cfg);
triList.add(trigger);
}
}else if ("week".equalsIgnoreCase(dayWeek)) {//指定周1#2: 第一周的周二4L:最后一周的周四
for(String nthWeek : userRegion4.split(",")) {//第几周
for(String week : cfg.getUserRegion5().split(",")) {//星期几
cronSb.setLength(0);
cronSb.append(validList.get(2)).append(" ")//秒
.append(validList.get(1)).append(" ")//分
.append(validList.get(0)).append(" ")//小时
.append("?").append(" ")//日
.append(cfg.getUserRegion2()).append(" ");//月
if("L".equalsIgnoreCase(nthWeek)) {
cronSb.append(week).append("L");//周
}else {
cronSb.append(week).append("#").append(nthWeek);//周
}
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), true, cfg);
triList.add(trigger);
cronSb.setLength(0);
cronSb.append(invalidList.get(2)).append(" ")//秒
.append(invalidList.get(1)).append(" ")//分
.append(invalidList.get(0)).append(" ")//小时
.append("?").append(" ")//日
.append(cfg.getUserRegion2()).append(" ");//月
if("L".equalsIgnoreCase(nthWeek)) {
cronSb.append(week).append("L");//周
}else {
cronSb.append(week).append("#").append(nthWeek);//周
}
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), false, cfg);
triList.add(trigger);
}
}
}
return triList;
}
/**
* 查找最近的 星期几 ,包括今天
* @param date
* @param w 周一开始 1 -7
* @return
*/
public static Date closestAfterWeek(Date date,int w) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int i = cal.get(Calendar.DAY_OF_WEEK);//周日开始 1-7
i = (i==1)? 7: i-1;//转换为 周一到 周日 1-7
cal.add(Calendar.DAY_OF_MONTH, (i>w)?(7-(i-w)) : (w-i));
return cal.getTime();
}
public static TriggerKey createTiggerKey(String name,String group) {
TriggerKey key = new TriggerKey(name, group);
return key;
}
/**
* jquery cron 生成的cron 表达式quartz 不能直接使用,需要做些修改
* @param cron
* @return
*/
public static String modifyCronExp(String cron) {
String[] cronArr = cron.split("\\s");
if("*".equals(cronArr[4])) {
cronArr[4] = "?";
}else {
cronArr[3] = "*";
cronArr[2] = "?";
}
return "0 " + StringUtils.join(cronArr, " ");
}
public static void main(String[] args) {
CronTriggerImpl cron = new CronTriggerImpl();
try {
String exp = "0 0 0 ? 1,2 1#4";
cron.setCronExpression(exp);
System.out.println(cron);
} catch (ParseException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,38 @@
package com.nis.quartz;
import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import com.nis.domain.ScheduleCfg;
import com.nis.web.service.ScheduleService;
import com.nis.web.service.SpringContextHolder;
/**
* 定时任务 真正执行类
* 配置状态下发
* 从trigger 的 jobDataMap 中取出 相关数据compile,isValid
* @author fang
*
*/
public class ScheduleStatusJob implements Job{
private static final Logger log = Logger.getLogger(ScheduleStatusJob.class);
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
//从trigger中 获取 配置信息
JobDataMap jobDataMap = context.getTrigger().getJobDataMap();
boolean isValid = jobDataMap.getBoolean("isValid");
ScheduleCfg cfg = (ScheduleCfg)jobDataMap.get("cfg");
Integer compileId = cfg.getCompileId();
log.debug(String.format("任务开始执行compileId:%s,isValid:%s",compileId,isValid ));
//配置下发,并修改 配置表的状态,保存下发记录等
ScheduleService scheduleService = SpringContextHolder.getBean(ScheduleService.class);
scheduleService.issueCompileInfo(cfg, isValid?1:0);
log.debug(String.format("任务开始执行compileId:%s,isValid:%s",compileId,isValid ));
}
}

View File

@@ -194,6 +194,15 @@ public class CodeDicUtils {
}
return result;
}
/**
* 用于显示日志isp运营商的信息
* @param name
* @return
*/
public static List<SysIspInfo> getIspListByIspNum(){
List<SysIspInfo> result = codeSysIspInfoDicDao.getIspListByIspNum();;
return result;
}
public static void main(String[] args) {
getCodeList(APP_CODE);
}

View File

@@ -0,0 +1,690 @@
package com.nis.util;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringEscapeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import com.google.common.collect.Lists;
import com.googlecode.ipv6.IPv6Address;
import com.googlecode.ipv6.IPv6Network;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.FileDigestCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.maat.MaatCfg.DigestCfg;
import com.nis.domain.maat.MaatCfg.GroupCfg;
import com.nis.domain.maat.MaatCfg.IpCfg;
import com.nis.domain.maat.MaatCfg.NumBoundaryCfg;
import com.nis.domain.maat.MaatCfg.StringCfg;
public class ConfigConvertUtil {
private static Logger logger = LoggerFactory.getLogger(ConfigConvertUtil.class);
/**
* 配置域转换
* @param ipList
* @param strList
* @param complexStrList
* @param numList
* @param fileList
* @param regionIds
* @param groupIds
* @param entity
* @param compileId
* @param auditTime
* @param groupRelationList
* @param ipRegionList
* @param strRegionList
* @param numRegionList
* @param digestRegionList
* @param areaIpRegionList
* @param userRegion
*/
public static String configCovert(List<IpPortCfg> ipList,List<BaseStringCfg> strList,List<ComplexkeywordCfg> complexStrList,
List<com.nis.domain.configuration.NumBoundaryCfg > numList,
List<FileDigestCfg> fileList,List<Integer> regionIds,List<Integer> groupIds,BaseCfg entity,
Integer compileId,Date auditTime,List<GroupCfg> groupRelationList,
List<IpCfg> ipRegionList,
List<StringCfg> strRegionList,
List<NumBoundaryCfg> numRegionList,
List<DigestCfg> digestRegionList,
List<IpCfg> areaIpRegionList,String userRegion){
List list1 = new ArrayList();
List<BaseStringCfg> list2 = new ArrayList();
List<ComplexkeywordCfg> list3 = new ArrayList();
List<com.nis.domain.configuration.NumBoundaryCfg> list4 = new ArrayList();
List<FileDigestCfg> list5 = new ArrayList();
if(ipList.size()>0){
for(int index=0;index<ipList.size();index++){
IpPortCfg ip = ipList.get(index);
if(ip.getCompileId().equals(compileId)){
ip.setRegionId(regionIds.get(0));
regionIds.remove(0);
ip.setGroupId(groupIds.get(0));
groupIds.remove(0);
ip.setIsValid(entity.getIsValid());
ip.setAuditTime(auditTime);
list1.add(ip);
}
}
}
for(int index=0;index<strList.size();index++){
BaseStringCfg str = strList.get(index);
if(str.getCompileId().equals(compileId)){
str.setRegionId(regionIds.get(0));
regionIds.remove(0);
str.setGroupId(groupIds.get(0));
groupIds.remove(0);
str.setIsValid(entity.getIsValid());
str.setAuditTime(auditTime);
list2.add(str);
if(entity.getServiceId().equals(513)||entity.getServiceId().equals(515)){
if(userRegion.equals("")){
userRegion += Constants.USERREGION_DOMAIN_STR+"="+str.getCfgKeywords();
}else{
userRegion += Constants.USER_REGION_SPLIT+Constants.USERREGION_DOMAIN_STR+"="+str.getCfgKeywords();
}
}
}
}
for(int index=0;index<complexStrList.size();index++){
ComplexkeywordCfg str = complexStrList.get(index);
if(str.getCompileId().equals(compileId)){
str.setRegionId(regionIds.get(0));
regionIds.remove(0);
str.setGroupId(groupIds.get(0));
groupIds.remove(0);
str.setIsValid(entity.getIsValid());
str.setAuditTime(auditTime);
list3.add(str);
if(entity.getServiceId().equals(129) && str.getDistrict()!=null){//http监测
String dictValue = DictUtils.getDictCode(Constants.HTTP_HEADER_DICT_MODULE, str.getDistrict());
if(StringUtil.isEmpty(dictValue) || dictValue.equals("默认")){
if(userRegion.equals("")){
userRegion += Constants.HTTP_HEADER_USER_REGION_KEY+"="+str.getDistrict();
}else{
userRegion += Constants.USER_REGION_SPLIT+Constants.HTTP_HEADER_USER_REGION_KEY+"="+str.getDistrict();
}
}
}
}
}
for(int index=0;index<numList.size();index++){
com.nis.domain.configuration.NumBoundaryCfg num = numList.get(index);
if(num.getCompileId().equals(compileId)){
num.setRegionId(regionIds.get(0));
regionIds.remove(0);
num.setGroupId(groupIds.get(0));
groupIds.remove(0);
num.setIsValid(entity.getIsValid());
num.setAuditTime(auditTime);
list4.add(num);
}
}
for(int index=0;index<fileList.size();index++){
FileDigestCfg file = fileList.get(index);
if(file.getCompileId().equals(compileId)){
file.setRegionId(regionIds.get(0));
regionIds.remove(0);
file.setGroupId(groupIds.get(0));
groupIds.remove(0);
file.setIsValid(entity.getIsValid());
file.setAuditTime(auditTime);
list5.add(file);
}
}
if(list1.size()>0){
ipList.removeAll(list1);
Map<String,List> map = cfgToMaatConvert(ipRegionList,list1,1,groupRelationList);
groupRelationList=map.get("groupList");
ipRegionList=map.get("dstList");
if(map.get("numRegionList")!=null){
numRegionList.addAll(map.get("numRegionList"));
}
}
if(list2.size()>0){
strList.removeAll(list2);
Map<String,List> map = cfgToMaatConvert(strRegionList,list2,2,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
if(list3.size()>0){
complexStrList.removeAll(list3);
Map<String,List> map = cfgToMaatConvert(strRegionList,list3,3,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
if(list4.size()>0){
numList.removeAll(list4);
Map<String,List> map = cfgToMaatConvert(numRegionList,list4,4,groupRelationList);
groupRelationList=map.get("groupList");
numRegionList=map.get("dstList");
}
if(list5.size()>0){
fileList.removeAll(list5);
Map<String,List> map = cfgToMaatConvert(digestRegionList,list5,5,groupRelationList);
groupRelationList=map.get("groupList");
digestRegionList=map.get("dstList");
}
return userRegion;
}
// asn IP 复用转换
public static List<IpCfg> groupReuseCfgAddRemoveConvert(List<? extends BaseCfg<?>> ipCfgList, Integer isValid,
Integer groupId) {
logger.warn("convert data start");
long start = System.currentTimeMillis();
Date opTime = new Date();
List<IpCfg> maatIpList = new ArrayList<>();
if (ipCfgList.size() > 0) {
// 只用一次instanceof,取代循环中每次都用一次instanceof
if (ipCfgList.get(0) instanceof AsnIpCfg) {
for (BaseCfg<?> _cfg : ipCfgList) {
IpCfg cfg = new IpCfg();
BaseIpCfg baseIpCfg = new BaseIpCfg();
AsnIpCfg asnIpCfg = (AsnIpCfg) _cfg;
BeanUtils.copyProperties(asnIpCfg, baseIpCfg);
BeanUtils.copyProperties(baseIpCfg, cfg);
cfg.setGroupId(asnIpCfg.getAsnIpGroup());
cfg.setRegionId(asnIpCfg.getRegionId());
String userRegion = "ASN_ID=" + asnIpCfg.getUserRegion1();
cfg.setUserRegion(userRegion);
cfg.setIsValid(isValid);
cfg.setAuditTime(opTime);
List<IpCfg> cfgs = ipConvert(cfg, baseIpCfg);
maatIpList.addAll(cfgs);
}
} else if (ipCfgList.get(0) instanceof AppIpCfg) {
for (BaseCfg<?> _cfg : ipCfgList) {
IpCfg cfg = new IpCfg();
BaseIpCfg baseIpCfg = new BaseIpCfg();
AppIpCfg appIpCfg = (AppIpCfg) _cfg;
BeanUtils.copyProperties(appIpCfg, baseIpCfg);
BeanUtils.copyProperties(baseIpCfg, cfg);
cfg.setGroupId(groupId);
cfg.setRegionId(Integer.parseInt(appIpCfg.getUserRegion1()));
String userRegion = "APP_ID=" + appIpCfg.getAppCode();
cfg.setUserRegion(userRegion);
cfg.setIsValid(isValid);
cfg.setAuditTime(opTime);
List<IpCfg> cfgs = ipConvert(cfg, baseIpCfg);
maatIpList.addAll(cfgs);
}
}
}
long end = System.currentTimeMillis();
logger.warn("convert data finish,cost:" + (end - start));
return maatIpList;
}
/**
* 界面配置list转换为服务接口端的list用于批量下发时regionId,groupId已在该方法前被批量获取
*
* @param <T>
* @param <T>
* @param dstList
* @param srcList
* @param cfgType1为IP类型2为字符串类型3为增强字符串4数值类型5摘要类,6回调类[但字符串类域配置和增强字符串域配置在接口参数中同属于strRegionList]
* @param baseCfg配置基本信息
* @param groupRelationList
* 配置分组列表
* @return
*/
public static <T> Map<String, List> cfgToMaatConvert(List dstList, List<T> srcList, Integer cfgType,List groupRelationList) {
Map<String, List> map = new HashMap();
if (cfgType == 1) {
List numRegionList = new ArrayList();
Integer groupId = 0;
Integer numGroupId = 0;
for (int i = 0; i < srcList.size(); i++) {
List<Integer> regionIdList = Lists.newArrayList();
T srcCfg = srcList.get(i);
BaseIpCfg baseIpCfg = new BaseIpCfg();
BeanUtils.copyProperties(srcCfg, baseIpCfg);
regionIdList.add(baseIpCfg.getRegionId());
IpCfg cfg = new IpCfg();
BeanUtils.copyProperties(baseIpCfg, cfg);
//多条IP配置属于同一个分组
if (groupId == 0) {
GroupCfg group = new GroupCfg();
groupId = baseIpCfg.getGroupId();
group.setGroupId(groupId);
group.setCompileId(baseIpCfg.getCompileId());
group.setAuditTime(baseIpCfg.getAuditTime());
group.setIsValid(baseIpCfg.getIsValid());
groupRelationList.add(group);
}
cfg.setGroupId(groupId);
cfg.setAuditTime(baseIpCfg.getAuditTime());
cfg.setIsValid(baseIpCfg.getIsValid());
List<IpCfg> cfgs = ipConvert(cfg, baseIpCfg);
if (cfgs.size() > 1) {
List<Integer> ids = ConfigServiceUtil.getId(3, cfgs.size() - 1);
regionIdList.addAll(ids);
}
for (int j = i; j < cfgs.size() + i; j++) {
cfgs.get(j - i).setRegionId(regionIdList.get(j));
}
dstList.addAll(cfgs);
// 如果protocolId非空非零需要构造数值型域配置多条相同协议的IP只需要一条数值域配置目前没有不同协议IP&情况)
if (baseIpCfg.getProtocolId() != null && baseIpCfg.getProtocolId() != 0) {
if (numGroupId == 0) {
GroupCfg group1 = new GroupCfg();
group1.setGroupId(ConfigServiceUtil.getId(2, 1).get(0));
group1.setCompileId(baseIpCfg.getCompileId());
group1.setAuditTime(baseIpCfg.getAuditTime());
group1.setIsValid(baseIpCfg.getIsValid());
groupRelationList.add(group1);
NumBoundaryCfg numCfg = new NumBoundaryCfg();
numCfg.initDefaultValue();
numCfg.setLowBoundary(baseIpCfg.getProtocolId());
numCfg.setUpBoundary(baseIpCfg.getProtocolId());
numCfg.setRegionId(ConfigServiceUtil.getId(3, 1).get(0));
numCfg.setAuditTime(baseIpCfg.getAuditTime());
numCfg.setGroupId(group1.getGroupId());
numCfg.setIsValid(baseIpCfg.getIsValid());
numRegionList.add(numCfg);
map.put("numRegionList", numRegionList);
numGroupId++;
}
}
}
} else if (cfgType == 2 || cfgType == 3) {
for (int i = 0; i < srcList.size(); i++) {
// 一条业务配置创建一个分组
BaseCfg baseCfg = new BaseCfg();
BeanUtils.copyProperties(srcList.get(i), baseCfg,new String[]{"menuNameCode"});//拷贝公共属性
GroupCfg group = new GroupCfg();
StringCfg cfg = new StringCfg();
BeanUtils.copyProperties(srcList.get(i), cfg,new String[]{"menuNameCode"});//拷贝公共属性以及私有属性
group.setGroupId(baseCfg.getGroupId());
group.setCompileId(baseCfg.getCompileId());
group.setAuditTime(baseCfg.getAuditTime());
group.setIsValid(baseCfg.getIsValid());
groupRelationList.add(group);
cfg.setGroupId(group.getGroupId());
cfg.setRegionId(baseCfg.getRegionId());
cfg.setAuditTime(baseCfg.getAuditTime());
cfg.setIsValid(baseCfg.getIsValid());
// 处理配置关键字转译
cfg.setCfgKeywords(keywordsEscape(cfg.getCfgKeywords()));
// 增强字符串转换
cfg.setDistrict(keywordsEscape(cfg.getDistrict()));
dstList.add(cfg);
}
} else if (cfgType == 4) {
for (int i = 0; i < srcList.size(); i++) {
BaseCfg baseCfg = new BaseCfg();
BeanUtils.copyProperties(srcList.get(i), baseCfg);//拷贝公共属性
// 一条业务配置创建一个分组
com.nis.domain.maat.MaatCfg.NumBoundaryCfg cfg = new com.nis.domain.maat.MaatCfg.NumBoundaryCfg();
BeanUtils.copyProperties(srcList.get(i), cfg);
GroupCfg group = new GroupCfg();
group.setGroupId(baseCfg.getGroupId());
group.setCompileId(baseCfg.getCompileId());
group.setAuditTime(baseCfg.getAuditTime());
group.setIsValid(baseCfg.getIsValid());
groupRelationList.add(group);
cfg.setGroupId(group.getGroupId());
cfg.setRegionId(baseCfg.getRegionId());
cfg.setAuditTime(baseCfg.getAuditTime());
cfg.setIsValid(baseCfg.getIsValid());
dstList.add(cfg);
}
} else if (cfgType == 5) {
for (int i = 0; i < srcList.size(); i++) {
BaseCfg baseCfg = new BaseCfg();
BeanUtils.copyProperties(srcList.get(i), baseCfg);//拷贝公共属性
// 一条业务配置创建一个分组
com.nis.domain.maat.MaatCfg.DigestCfg cfg = new com.nis.domain.maat.MaatCfg.DigestCfg();
BeanUtils.copyProperties(srcList.get(i), cfg);
GroupCfg group = new GroupCfg();
group.setGroupId(baseCfg.getGroupId());
group.setCompileId(baseCfg.getCompileId());
group.setAuditTime(baseCfg.getAuditTime());
group.setIsValid(baseCfg.getIsValid());
groupRelationList.add(group);
cfg.setGroupId(group.getGroupId());
cfg.setRegionId(baseCfg.getRegionId());
cfg.setAuditTime(baseCfg.getAuditTime());
cfg.setIsValid(baseCfg.getIsValid());
dstList.add(cfg);
}
} else {
dstList.addAll(srcList);
}
map.put("groupList", groupRelationList);
map.put("dstList", dstList);
return map;
}
/**
* 关键字特殊字符转义处理
* @param cfgKeywords
* @return
*/
public static String keywordsEscape(String cfgKeywords) {
if (StringUtils.isNotEmpty(cfgKeywords)) {
// 不转译特殊字符
cfgKeywords = cfgKeywords.trim();// 首先去掉首尾空格
cfgKeywords = StringEscapeUtils.unescapeHtml4(cfgKeywords);
cfgKeywords = cfgKeywords.replace("\\", "\\\\");
cfgKeywords = cfgKeywords.replace("&", "\\&");
cfgKeywords = cfgKeywords.replace(" ", "\\b");
// ***and***在界面表示多个关键字的与表达式此特殊字符串在common.js中使用定义maat端以&表示
cfgKeywords = cfgKeywords.replace(Constants.KEYWORD_EXPR, "&");
}
return cfgKeywords;
}
/**
* 界面IP配置转换为MAAT类或者回调类IP配置
*
* @param dstIp
* @param srcIp
* @return
*/
public static List<IpCfg> ipConvert(IpCfg dstIp, BaseIpCfg srcIp) {
List<IpCfg> ipConvertList = Lists.newArrayList();
boolean isRange = ((srcIp.getIpPattern() != null && srcIp.getIpPattern() == 2)
|| (srcIp.getSrcIpAddress() != null && srcIp.getSrcIpAddress().indexOf("-") > -1)
|| (srcIp.getDestIpAddress() != null && srcIp.getDestIpAddress().indexOf("-") > -1));
if (isRange) {
List<IpCfg> tempList = Lists.newArrayList();
List<IpCfg> tempList1 = Lists.newArrayList();
if (srcIp.getIpType().intValue() == 4) {
if (srcIp.getSrcIpAddress() != null) {
String startIpPart = srcIp.getSrcIpAddress().split("-")[0];
String endIpPart = srcIp.getSrcIpAddress().split("-")[1];
Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]);
Integer endNum = Integer.parseInt(endIpPart.split("\\.")[3]);
for (int i = startNum; i <= endNum; i++) {
IpCfg tempIp = new IpCfg();
BeanUtils.copyProperties(dstIp, tempIp);
tempIp.setSrcIp(startIpPart.substring(0, startIpPart.lastIndexOf(".") + 1) + i);
tempIp.setSrcIpMask("255.255.255.255");
tempList.add(tempIp);
}
} else {
dstIp.setSrcIp("0.0.0.0");
dstIp.setSrcIpMask("255.255.255.255");
tempList.add(dstIp);
}
if (srcIp.getDestIpAddress() != null) {
String startIpPart = srcIp.getDestIpAddress().split("-")[0];
String endIpPart = srcIp.getDestIpAddress().split("-")[1];
Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]);
Integer endNum = Integer.parseInt(endIpPart.split("\\.")[3]);
for (IpCfg _cfg : tempList) {
for (int i = startNum; i <= endNum; i++) {
IpCfg tempIp = new IpCfg();
BeanUtils.copyProperties(_cfg, tempIp);
tempIp.setDstIp(startIpPart.substring(0, startIpPart.lastIndexOf(".") + 1) + i);
tempIp.setDstIpMask("255.255.255.255");
// 处理
convertPortValues(tempIp, srcIp);
if (!tempIp.getSrcIp().equals(tempIp.getDstIp())) {
tempList1.add(tempIp);
}
}
}
tempList.clear();
} else {
for (IpCfg _cfg : tempList) {
_cfg.setDstIp("0.0.0.0");
_cfg.setSrcIpMask("255.255.255.255");
convertPortValues(_cfg, srcIp);
}
}
if (tempList1.size() > 0) {
ipConvertList.addAll(tempList1);
} else {
ipConvertList.addAll(tempList);
}
} else if (srcIp.getIpType().intValue() == 6) {
if (srcIp.getSrcIpAddress() != null) {
IPv6Address address1 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[0]);
IPv6Address address2 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[1]);
IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2);
dstIp.setSrcIp(address1.toString());
dstIp.setSrcIpMask(network.getNetmask().asAddress().toString());
} else {
dstIp.setSrcIp("::");
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
}
if (srcIp.getDestIpAddress() != null) {
IPv6Address address1 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[0]);
IPv6Address address2 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[1]);
IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2);
dstIp.setDstIp(address1.toString());
dstIp.setDstIpMask(network.getNetmask().asAddress().toString());
} else {
dstIp.setDstIp("::");
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
}
ipConvertList.add(dstIp);
} else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
} else {
if (srcIp.getSrcIpAddress() != null) {
if (srcIp.getSrcIpAddress().indexOf("/") != -1) {
if (srcIp.getIpType() == 4 /* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
Integer srcMaskNum = Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]);
if (srcMaskNum == 0) {
dstIp.setSrcIpMask("0.0.0.0");
} else {
dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum));
}
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getSrcIpAddress());
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString());
} /*
* else { Pattern
* patternV4Subnet=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP); Pattern
* patternV6Subnet=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP); Matcher
* matchernV4Subnet=patternV4Subnet.matcher(srcIp.getSrcIpAddress()); Matcher
* matcherV6Subnet=patternV6Subnet.matcher(srcIp.getSrcIpAddress());
* if(matchernV4Subnet.matches()) { Integer srcMaskNum =
* Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]); if(srcMaskNum==0){
* dstIp.setSrcIpMask("0.0.0.0"); }else{
* dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum)); }
* dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); }else
* if(matcherV6Subnet.matches()){ IPv6Network strangeNetwork =
* IPv6Network.fromString(srcIp.getSrcIpAddress());
* dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
* dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else
* { throw new RuntimeException("Invalid IP/subnet mask format"); } }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
} else {
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
dstIp.setSrcIp(srcIp.getSrcIpAddress());
dstIp.setSrcIpMask("255.255.255.255");
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
dstIp.setSrcIp(srcIp.getSrcIpAddress());
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
} /*
* else {//all Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
* Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP); Matcher
* matcherV4=patternV4.matcher(srcIp.getSrcIpAddress()); Matcher
* matcherV6=patternV6.matcher(srcIp.getSrcIpAddress()); if(matcherV4.matches())
* { dstIp.setSrcIp(srcIp.getSrcIpAddress());
* dstIp.setSrcIpMask("255.255.255.255"); }else if(matcherV6.matches()) {
* dstIp.setSrcIp(srcIp.getSrcIpAddress());
* dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else { throw
* new RuntimeException("Invalid IP format"); } }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
}
} else {
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
dstIp.setSrcIp(srcIp.getSrcIpAddress());
dstIp.setSrcIpMask("255.255.255.255");
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
dstIp.setSrcIp(srcIp.getSrcIpAddress());
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
} /*
* else {//all dstIp.setSrcIp(srcIp.getSrcIpAddress());
* dstIp.setSrcIpMask("255.255.255.255"); }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
}
if (srcIp.getDestIpAddress() != null) {
if (srcIp.getDestIpAddress().indexOf("/") != -1) {
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
Integer dstMaskNum = Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]);
if (dstMaskNum == 0) {
dstIp.setDstIpMask("0.0.0.0");
} else {
dstIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));
;
}
dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getDestIpAddress());
dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString());
} /*
* else { Pattern
* patternV4Subnet=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP); Pattern
* patternV6Subnet=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP); Matcher
* matchernV4Subnet=patternV4Subnet.matcher(srcIp.getDestIpAddress()); Matcher
* matcherV6Subnet=patternV6Subnet.matcher(srcIp.getDestIpAddress());
* if(matchernV4Subnet.matches()) { Integer dstMaskNum =
* Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]); if(dstMaskNum==0){
* dstIp.setDstIpMask("0.0.0.0"); }else{
* dstIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));; }
* dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]); }else
* if(matcherV6Subnet.matches()){ IPv6Network strangeNetwork =
* IPv6Network.fromString(srcIp.getDestIpAddress());
* dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
* dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else
* { throw new RuntimeException("Invalid IP/subnet mask format"); } }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
} else {
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
dstIp.setDstIp(srcIp.getDestIpAddress());
dstIp.setDstIpMask("255.255.255.255");
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
dstIp.setDstIp(srcIp.getDestIpAddress());
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
} /*
* else {//all Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
* Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP); Matcher
* matcherV4=patternV4.matcher(srcIp.getDestIpAddress()); Matcher
* matcherV6=patternV6.matcher(srcIp.getDestIpAddress());
* if(matcherV4.matches()) { dstIp.setDstIp(srcIp.getDestIpAddress());
* dstIp.setDstIpMask("255.255.255.255"); }else if(matcherV6.matches()) {
* dstIp.setDstIp(srcIp.getDestIpAddress());
* dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else { throw
* new RuntimeException("invalid ip format"); } }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
}
} else {
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
dstIp.setDstIp(srcIp.getDestIpAddress());
dstIp.setDstIpMask("255.255.255.255");
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
dstIp.setDstIp(srcIp.getDestIpAddress());
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
} /*
* else {//all dstIp.setDstIp(srcIp.getDestIpAddress());
* dstIp.setDstIpMask("255.255.255.255"); }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
}
if (srcIp.getSrcPort() != null) {
if (srcIp.getSrcPort().indexOf("/") != -1) {
String srcMaskNum = srcIp.getSrcPort().split("/")[1];
dstIp.setSrcPortMask(srcMaskNum);
dstIp.setSrcPort(srcIp.getSrcPort().split("/")[0]);
} else {
dstIp.setSrcPort(srcIp.getSrcPort());
dstIp.setSrcPortMask("65535");
}
} else {
dstIp.setSrcPort("0");
dstIp.setSrcPortMask("65535");
}
if (srcIp.getDestPort() != null) {
if (srcIp.getDestPort().indexOf("/") != -1) {
String dstMaskNum = srcIp.getDestPort().split("/")[1];
dstIp.setDstPortMask(dstMaskNum);
dstIp.setDstPort(srcIp.getDestPort().split("/")[0]);
} else {
dstIp.setDstPort(srcIp.getDestPort());
dstIp.setDstPortMask("65535");
}
} else {
dstIp.setDstPort("0");
dstIp.setDstPortMask("65535");
}
ipConvertList.add(dstIp);
}
return ipConvertList;
}
/**
* 设置端口值
*
* @param dstIp
* @param srcIp
*/
public static void convertPortValues(IpCfg dstIp, BaseIpCfg srcIp) {
if (srcIp.getSrcPort() != null) {
if (srcIp.getSrcPort().indexOf("/") != -1) {
String srcMaskNum = srcIp.getSrcPort().split("/")[1];
dstIp.setSrcPortMask(srcMaskNum);
dstIp.setSrcPort(srcIp.getSrcPort().split("/")[0]);
} else {
dstIp.setSrcPort(srcIp.getSrcPort());
dstIp.setSrcPortMask("65535");
}
} else {
dstIp.setSrcPort("0");
dstIp.setSrcPortMask("65535");
}
if (srcIp.getDestPort() != null) {
if (srcIp.getDestPort().indexOf("/") != -1) {
String dstMaskNum = srcIp.getDestPort().split("/")[1];
dstIp.setDstPortMask(dstMaskNum);
dstIp.setDstPort(srcIp.getDestPort().split("/")[0]);
} else {
dstIp.setDstPort(srcIp.getDestPort());
dstIp.setDstPortMask("65535");
}
} else {
dstIp.setDstPort("0");
dstIp.setDstPortMask("65535");
}
}
}

View File

@@ -2,6 +2,7 @@ package com.nis.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -11,6 +12,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.SysDataDictionaryName;
import com.nis.domain.basics.AsnGroupInfo;
import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.basics.SysDictInfo;
import com.nis.domain.configuration.BaseStringCfg;
@@ -18,6 +20,7 @@ import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.PxyObjTrustedCaCrl;
import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.web.dao.SysDictDao;
import com.nis.web.dao.basics.AsnGroupInfoDao;
import com.nis.web.dao.basics.ServiceDictInfoDao;
import com.nis.web.dao.basics.SysDictInfoDao;
import com.nis.web.dao.configuration.PxyObjKeyringDao;
@@ -41,6 +44,7 @@ public class ConfigDictUtils {
private final static SpecificServiceCfgDao specificServiceCfgDao = SpringContextHolder.getBean(SpecificServiceCfgDao.class);
private final static WebsiteCfgDao websiteCfgDao = SpringContextHolder.getBean(WebsiteCfgDao.class);
private final static PxyObjKeyringDao pxyObjKeyringDao = SpringContextHolder.getBean(PxyObjKeyringDao.class);
private final static AsnGroupInfoDao asnGroupInfoDao = SpringContextHolder.getBean(AsnGroupInfoDao.class);
/**
* 根据主键查询配置详情
@@ -203,4 +207,38 @@ public class ConfigDictUtils {
}
return crlFIle;
}
/**
* 根据compileId获取配置内容
* @param compileId
* @return
*/
public static List<Integer> getASNIPNum(Long groupId ) {
List<Integer> ipNum=new ArrayList<>();
try {
if(!StringUtil.isEmpty(groupId)){
List<Object[]> list=asnGroupInfoDao.getASNIPNum(groupId);
if(!StringUtil.isEmpty(list)){
int index=0;
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
if(index==0){
Map map=(Map) iterator.next();
if(map != null){
ipNum.add(0, (Integer) map.get("v4_num"));
ipNum.add(1, (Integer) map.get("v6_num"));
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
if(ipNum.size() ==0){
ipNum.add(0, 0);
ipNum.add(1, 0);
}
return ipNum;
}
}

View File

@@ -744,10 +744,14 @@ public class ConfigServiceUtil {
result= response.readEntity(String.class);
logger.info("cgi info:"+result);
}else{
if(response!= null) {
throw new MaatConvertException("<spring:message code=\"cgi_service_failed\"/>:"+response.readEntity(String.class));
}else {
throw new MaatConvertException("<spring:message code=\"cgi_service_failed\"/>");
Map<String, String> map = new HashMap<String, String>();
map = (Map<String, String>) JSON.parse(result);
String error = map.get("error");
if (!StringUtil.isEmpty(error)) {
error=cgiError(error);
throw new MaatConvertException(error);
}else{
throw new MaatConvertException(null);
}
}
} catch (Exception e) {
@@ -760,6 +764,28 @@ public class ConfigServiceUtil {
return result;
}
public static String cgiError(String error){
String cgiError="";
String er=error.toLowerCase().trim();
String errors=Constants.CGI_ERROR;
if(!StringUtil.isEmpty(errors)){
String [] ers=errors.toLowerCase().split(",");
for (int i = 0; i < ers.length; i++) {
if(ers[i].trim().equals(er)){
cgiError=error;
break;
}
}
}
return cgiError;
}
/**
* 配置全量更新指令下发
* @param params

View File

@@ -13,6 +13,7 @@ public final class Constants {
*/
public static final int IMPORT_LIMIT=Configurations.getIntProperty("import_limit",10000);
public static final Object IMPORT_LOCK=new Object();
public static final Object IMPORT_ASN_LOCK=new Object();
public static final String ADD_COMMON_REGION=Configurations.getStringProperty("addRegionToCommonGroup","");
public static final String UPDATE_COMMON_REIGON=Configurations.getStringProperty("updateRegionToCommonGroup","");
public static final String DELETE_COMMON_REIGON=Configurations.getStringProperty("deleteRegionToCommonGroup","");
@@ -498,6 +499,7 @@ public final class Constants {
public static final String VOIP_ACCOUNT_REGION = Configurations.getStringProperty("voip_account","av_voip_account");
public static final String NTC_ASN_NUMBER = Configurations.getStringProperty("ntc_asn_number","NTC_ASN_NUMBER");
public static final String ASN_KEY = Configurations.getStringProperty("asn_key","AS");
public static final String ASN_REGION_KEY = Configurations.getStringProperty("asn_region_key","ASN_ID");
public static final String MAAT_VERSION = Configurations.getStringProperty("maat_version","1.0");
public static final Integer INSERT_ACTION = Configurations.getIntProperty("insert_action",1);
public static final Integer UPDATE_ACTION = Configurations.getIntProperty("update_action",2);
@@ -723,6 +725,9 @@ public final class Constants {
public static final String TREND_TOTAL_REPORT=Configurations.getStringProperty("trendTotalReport","trendTotalReport");
public static final String TRAFFIC_APP_TREND=Configurations.getStringProperty("trafficAppTrend","trafficAppTrend");
public static final String APPCONN_RECORD_TOP100=Configurations.getStringProperty("appConnRecordTop100","appConnRecordTop100");
public static final String TRAFFIC_APP_PPS_TREND=Configurations.getStringProperty("trafficAppPpsTrend","trafficAppPpsTrend");
public static final String TRAFFIC_APP_BPS_TREND=Configurations.getStringProperty("trafficAppBpsTrend","trafficAppBpsTrend");
/**
* httpclient 工具超时时间设置
*/
@@ -818,4 +823,16 @@ public final class Constants {
* 流量日志的HTTP泛收接口URL
*/
public static final String NTC_HTTP_RECORD_LOG = Configurations.getStringProperty("ntcHttpRecordLog","");
/**
* 日期格式化
*/
public static final String COMMON_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
/**
* 时间格式化
*/
public static final String COMMON_TIME_FORMAT = "HH:mm:ss";
/**
* vpn cgi接口报错信息
*/
public static final String CGI_ERROR = Configurations.getStringProperty("cgiError","");;
}

View File

@@ -0,0 +1,759 @@
package com.nis.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.nis.domain.Nets;
import javax.servlet.http.HttpServletRequest;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* <p>对IPV4进行处理工具类.</p>
* @author 中电积至有限公司 darnell
* @version 1.0 创建时间2018-08-30
*
*/
public class IPUtil {
private static Logger logger = LoggerFactory.getLogger(IPUtil.class);
private static byte pos []= new byte []{(byte)128,64,32,16,8,4,2,1};
private static final Pattern IPV4Pattern = Pattern.
compile("\\b((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\b");
private static final Pattern IPV6_STD_PATTERN =
Pattern.compile(
"^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$");
private static final Pattern IPV6_HEX_COMPRESSED_PATTERN =
Pattern.compile(
"^((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)$");
/**
*
* <p>将10进制IP转为字符串网络序。IP((0-255).(0-255).(0-255).(0-255))格式.
* ip10为字符串形式能给处理带来方便.
* </p>
* <pre>
* IpUtil.getIpString("3232235777") = "192.168.1.1"
* </pre>
* @see #getIpDesimal(String)
* @param ip10 10进制IP
* @return 返回如<code>0.0.0.0</code>格式IP
*/
public static String getIpString(String ip10) {
StringBuffer sb = new StringBuffer("");
if (ip10.indexOf("-") > -1) {
Integer intIP = Integer.parseInt(setStrEmpty(ip10));
sb.append(String.valueOf(intIP&0x000000FF));
sb.append(".");
sb.append(String.valueOf((intIP&0x0000FFFF)>>>8));
sb.append(".");//将高8位置0然后右移16位
sb.append(String.valueOf((intIP&0x00FFFFFF)>>>16));
sb.append(".");
sb.append(String.valueOf(intIP>>>24&0xFF));//直接右移24位
return sb.toString();
} else {
Long longIP = Long.parseLong(setStrEmpty(ip10));
sb.append(String.valueOf(longIP&0x000000FF));
sb.append(".");
sb.append(String.valueOf((longIP&0x0000FFFF)>>>8));
sb.append(".");//将高8位置0然后右移16位
sb.append(String.valueOf((longIP&0x00FFFFFF)>>>16));
sb.append(".");
sb.append(String.valueOf(longIP>>>24&0xFF));//直接右移24位
return sb.toString();
}
}
/**
*
* <p>将10进制IP转为字符串主机序。IP((0-255).(0-255).(0-255).(0-255))格式.
* ip10为字符串形式能给处理带来方便.
* </p>
* <pre>
* IpUtil.getIpHostString("3232235777") = "192.168.1.1"
* </pre>
* @see #getIpDesimal(String)
* @param ip10 10进制IP
* @return 返回如<code>0.0.0.0</code>格式IP
*/
//将10进制整数形式转换成127.0.0.1形式的IP地址按网络序
public static String getIpHostString(String ip10) {
StringBuffer sb = new StringBuffer(32);
if (ip10.indexOf("-") > -1) {
Integer intIP = Integer.parseInt(setStrEmpty(ip10));
sb.append(String.valueOf(intIP >>> 24));// 直接右移24位
sb.append(".");
sb.append(String.valueOf((intIP & 0x00FFFFFF) >>> 16)); // 将高8位置0然后右移16位
sb.append(".");
sb.append(String.valueOf((intIP & 0x0000FFFF) >>> 8));
sb.append(".");
sb.append(String.valueOf(intIP & 0x000000FF));
return sb.toString();
} else {
Long longIP = Long.parseLong(setStrEmpty(ip10));
sb.append(String.valueOf(longIP >>> 24));// 直接右移24位
sb.append(".");
sb.append(String.valueOf((longIP & 0x00FFFFFF) >>> 16)); // 将高8位置0然后右移16位
sb.append(".");
sb.append(String.valueOf((longIP & 0x0000FFFF) >>> 8));
sb.append(".");
sb.append(String.valueOf(longIP & 0x000000FF));
return sb.toString();
}
}
/**
* 判断一个IP地址是否属于某一个子网
*
* @param ip IP地址
* @param prefix 子网地址
* @param prefixLen 掩码长度
* @return true or false
*/
public static boolean inPrefix(String ip, String prefix, int prefixLen) {
String binPrefix = toBinaryString(prefix);
if (binPrefix.length() > prefixLen) {
binPrefix = binPrefix.substring(0,prefixLen);
}
String binIP = toBinaryString(ip);
binIP = binIP.substring(0,prefixLen);
if (binIP.equals(binPrefix)) {
return true;
} else {
return false;
}
}
/**
* 获得两个IP间的范围如192.168.0.128-192.168.2.256。
* 注意:本方法不做合法性检查!
*
* @param startIp 起始IP
* @param endIp 中止IP
* @return 范围内的IP地址数组
*/
public static List<String> getIPRange(String startIp, String endIp) {
List<String> list = new ArrayList<String>();
try{
long start = getIpHostDesimal(startIp);
long end = getIpHostDesimal(endIp);
for (long i = start; i <= end; i++) {
list.add(getIpHostString(String.valueOf(i)));
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
/**
* 验证IP为保留三个IP区域私有地址
* @param ip IPV4
* @return boolean true 私有地址 false 公有地址
*/
public static boolean internalIp(String ip) {
byte[] addr = getAddress(ip);
return internalIp(addr);
}
private static boolean internalIp(byte[] addr) {
final byte b0 = addr[0];
final byte b1 = addr[1];
//10.x.x.x/8
final byte SECTION_1 = 0x0A;
//172.16.x.x/12
final byte SECTION_2 = (byte) 0xAC;
final byte SECTION_3 = (byte) 0x10;
final byte SECTION_4 = (byte) 0x1F;
//192.168.x.x/16
final byte SECTION_5 = (byte) 0xC0;
final byte SECTION_6 = (byte) 0xA8;
switch (b0) {
case SECTION_1:
return true;
case SECTION_2:
if (b1 >= SECTION_3 && b1 <= SECTION_4) {
return true;
}
case SECTION_5:
switch (b1) {
case SECTION_6:
return true;
}
default:
return false;
}
}
/**
* 获得子网的所有IP地址192.168.0.1/24。
* 注意:本方法不做合法性检查!
* @param prefix 子网所属IP地址
* @param prefixLen 子网掩码
* @return List<String>
*/
public static List<String> getIPRange(String prefix, int prefixLen) {
String binPrefix = toBinaryString(prefix);
if (binPrefix.length() > prefixLen) {
binPrefix = binPrefix.substring(0,prefixLen);
}
StringBuffer ip1 = new StringBuffer(binPrefix);
StringBuffer ip2 = new StringBuffer(binPrefix);
for (int i = ip1.length(); i < 32; i++) {
ip1.append('0');
}
for (int i = ip2.length(); i < 32; i++) {
ip2.append('1');
}
return getIPRange(toIPString(ip1.toString()),toIPString(ip2.toString()));
}
/**
*
* <p>根据标准ip段获取该段子网掩码
* </p>
* @param startIP 起始ipendIP 结束ip
* @return 返回如<code>子网掩码</code>格式IP
*/
public static String getMask(String startIP,String endIP) {
byte start [] = getAddress(startIP);
byte end [] = getAddress(endIP);
byte mask [] = new byte [start.length];
boolean flag=false;
for(int i=0; i<start.length; i++){
mask[i]=(byte)~(start[i]^end[i]);
if (flag) {
mask[i]=0;
}
if(mask[i]!=-1){
mask[i]=getMask(mask[i]);
flag=true;
}
}
return toString(mask);
}
private static byte getMask(byte b) {
if (b==0) {
return b;
}
byte p = pos[0];
for(int i=0;i<8;i++){
if ((b&pos[i])==0) {
break;
}
p=(byte)(p>>1);
}
p=(byte)(p<<1);
return (byte)(b&p);
}
private static byte[] getAddress(String address) {
String subStr [] = address.split("\\.");
if(subStr.length!=4) {
throw new IllegalArgumentException("所传入的IP地址不符合IPv4的规范");
}
byte b [] = new byte [4];
for (int i=0;i<b.length;i++) {
b [i]=(byte)Integer.parseInt(subStr[i]);
}
return b;
}
/**
* 将IPv4形式掩码形式转为整型掩码位数
* @param netmarks
* @return
*/
public static int getNetMask(String netmarks)
{
if(!isMask(netmarks)){
throw(new RuntimeException("掩码格式错误!"));
}
StringBuffer sbf;
String str;
int inetmask=0,count=0;
String[] ipList=netmarks.split("\\.");
for(int n=0;n<ipList.length;n++)
{
sbf = toBin(Integer.parseInt(ipList[n]));
str=sbf.reverse().toString();
count=0;
for(int i=0;i<str.length();i++){
i=str.indexOf('1',i);
if(i==-1){break;}
count++;
}
inetmask+=count;
}
return inetmask;
}
/**
* 计算子网大小
* @param netmask
* @return
*/
public static int getPoolMax(int netmask)
{
if(netmask<=0||netmask>=32)
{
return 0;
}
int bits=32-netmask;
return (int) Math.pow(2,bits) -2;
}
private static StringBuffer toBin(int x)
{
StringBuffer result=new StringBuffer();
result.append(x%2);
x/=2;
while(x>0){
result.append(x%2);
x/=2;
}
return result;
}
/**
* 根据起始IP地址和子网掩码计算终止IP
* @return String 子网的结束IP
*/
public static String getEndIP(String StartIP,int netmask)
{
return getEndIP(StartIP,convertMask(netmask));
}
/**
* 根据起始IP地址和子网掩码计算终止IP
* @return String 子网的结束IP
*/
public static String getEndIP(String StartIP, String netmask)
{
Nets nets = new Nets();
String[] start=Negation(StartIP,netmask).split("\\.");
nets.setStartIP(start[0]+"."+start[1]+"."+start[2]+"."+(Integer.valueOf(start[3])+1));
nets.setEndIP(TaskOR(Negation(StartIP,netmask),netmask));
nets.setNetMask(netmask);
return nets.getEndIP();
}
/**
* temp1根据temp2取反
*/
private static String Negation(String StartIP,String netmask)
{
String[] temp1=StartIP.trim().split("\\.");
String[] temp2=netmask.trim().split("\\.");
int[] rets=new int[4];
for (int i =0;i<4;i++) {
rets[i]=Integer.parseInt(temp1[i])&Integer.parseInt(temp2[i]);
}
return rets[0]+"."+rets[1]+"."+rets[2]+"."+rets[3];
}
/**
* temp1根据temp2取或
*/
private static String TaskOR(String StartIP,String netmask)
{
String[] temp1=StartIP.trim().split("\\.");
String[] temp2=netmask.trim().split("\\.");
int[] rets=new int[4];
for (int i =0;i<4;i++) {
rets[i]=255-(Integer.parseInt(temp1[i])^Integer.parseInt(temp2[i]));
}
//return rets[0]+"."+rets[1]+"."+rets[2]+"."+(rets[3]-1);
return rets[0]+"."+rets[1]+"."+rets[2]+"."+(rets[3]);
}
/**
* <p>将整型的掩码转换成IPv4型(30 -> 255.255.255.252).</p>
*
* @param mask 整型掩码.
* @return IPv4型掩码.
* @exception RuntimeException 掩码错误.
*/
public static String convertMask(int mask) {
if (mask > 32 || mask < 8) {
throw(new RuntimeException("掩码错误应为8-32的整数。"));
}
return toIPString(maskToBinaryString(mask));
}
/**
* <p>将整型的掩码转换成反向IPv4型(30 -> 255.255.255.252).</p>
*
* @param mask 整型掩码.
* @return IPv4型反向掩码.
* @exception Exception 掩码错误.
*/
public static String convertReverseMask(int mask) throws Exception {
if (mask > 32 || mask < 8) {
throw(new Exception("掩码错误应为8-32的整数。"));
}
return toIPString(reverseMaskToBinaryString(mask));
}
/**
* 将整型掩码转换成二进制字符串
* @param mask 整型掩码
* @return 二进制型掩码.
*/
private static String maskToBinaryString(int mask) {
StringBuffer str = new StringBuffer();
for(int i=1;i<=32;i++) {
if (i <= mask) {
str.append('1');
} else {
str.append('0');
}
}
return str.toString();
}
/**
* 将整型掩码转换成二进制字符串
* @param mask 整型掩码
* @return 反向二进制型掩码.
*/
private static String reverseMaskToBinaryString(int mask) {
StringBuffer str = new StringBuffer();
for(int i=1;i<=32;i++) {
if (i <= mask) {
str.append('0');
} else {
str.append('1');
}
}
return str.toString();
}
/**
* 将二进制字符串转换成IPv4型字符串
* @param binary 二进制字符串
* @return IPv4型IP.
*/
private static String toIPString(String binary) {
if (binary.length() < 32) {
for (int i=binary.length();i<32;i++) {
binary = "0" + binary;
}
}
String part1 = binary.substring(0,8);
String part2 = binary.substring(8,16);
String part3 = binary.substring(16,24);
String part4 = binary.substring(24);
return Integer.parseInt(part1,2) + "."
+ Integer.parseInt(part2,2) + "."
+ Integer.parseInt(part3,2) + "."
+ Integer.parseInt(part4,2);
}
/**
* 获取子网的网络地址.
*
* @param ip IP地址.
* @param mask 掩码.
* @return 网络地址.
* @exception Exception IP地址错误或掩码错误.
*/
public static String getSubNetIP(String ip, int mask) throws Exception {
if (!isIP(ip)) {
throw(new Exception("IP地址不合法"));
}
String s1 = toBinaryString(ip);
String s2 = maskToBinaryString(mask);
return toIPString(Long.toBinaryString(Long.parseLong(s1,2)&Long.parseLong(s2,2)));
}
/**
* <p>将整型掩码转换成IPv4型的反码(30 -> 0.0.0.3).</p>
*
* @param mask 整型掩码.
* @return IPv4型反码.
* @exception Exception 掩码错误.
*/
public static String reverseMask(int mask) throws Exception {
if (mask > 32 || mask < 8) {
throw(new Exception("掩码错误应为8-32的整数。"));
}
String str = maskToBinaryString(mask);
str = str.replace('0','2');
str = str.replace('1','0');
str = str.replace('2','1');
return toIPString(str);
}
/**
* 将IPv4型字符串转换成长度为32的二进制字符串
* 需要加验证是否为IP
*/
public static String toBinaryString(String ip) {
String[] array = ip.split("[.]");
String str = "";
for (int i=0; i<array.length; i++) {
String s = Integer.toBinaryString(Integer.parseInt(array[i]));
if (s.length() < 8) {
for (int j=s.length();j<8;j++) {
s = "0" + s;
}
}
str += s;
}
return str;
}
/**
*
* <p>验证Ip是否符合规则.给定字符串,判断是否符合正则验证的ip格式.</p>
* <pre>例子说明:</pre>
* @param ip ip字符
* @return <code>true</code> ip符合验证规则, <code>false</code> ip不符合验证规则.
*/
public static boolean isIP(String ip) {
if (ip == null) {
return false;
}
Matcher mat = IPV4Pattern.matcher(ip);
return mat.matches();
}
public static boolean isIPv6StdAddress(final String input) {
return IPV6_STD_PATTERN.matcher(input).matches();
}
public static boolean isIPv6HexCompressedAddress(final String input) {
return IPV6_HEX_COMPRESSED_PATTERN.matcher(input).matches();
}
public static boolean isIPv6Address(final String input) {
return isIPv6StdAddress(input) || isIPv6HexCompressedAddress(input);
}
/**
*
* <p>在web方式下获取客户端IP地址.</p>
* <p>
* 使用该方法,需要在有javaee.jar扩展包前提下.
* </p>
* @param request HttpServletRequest请求对象
* @return 返回字符串IP地址
*/
public static String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
/**
*
* <p>验证mask是否符合规则.给定字符串,判断是否符合正则验证的mask格式.</p>
* <pre>例子说明:</pre>
* @param mask mask字符
* @return <code>true</code> mask符合验证规则, <code>false</code> mask不符合验证规则.
*/
public static boolean isMask(String mask) {
if (mask == null) {
return false;
}
if(!isIP(mask)){
return false;
}
String[] ips = mask.split("\\.");
String binaryVal = "";
for (int i = 0; i < ips.length; i++)
{
String binaryStr = Integer.toBinaryString(Integer.parseInt(ips[i]));
Integer times = 8 - binaryStr.length();
for(int j = 0; j < times; j++)
{
binaryStr = "0" + binaryStr;
}
binaryVal += binaryStr;
}
if(binaryVal.indexOf("01")!=-1){
return false;
}
return true;
}
/**
*
* <p>将IP进制转换成十进制网络字节序</p>
* <p>
* IP是一个字符串符合IP的规则(0-255).(0-255).(0-255).(0-255).
* 将ip转换成长整型的原因是处理时间类型简单入库节省空间,查询提高效率.
* </p>
* <pre>
* IpUtil.getIpDesimal("192.168.1.1") = 3232235777
* IpUtil.getIpDesimal("192.168.1.256") = -1 //不符合Ip规则
* </pre>
* @see #getIpString(String)
* @param ip 符合IP规则的字符串
* @return <code>-1</code> 验证ip不合法,<code>ip</code> 计算ip返回长整型.
*/
public static long getIpDesimal(String ip) {
long ip10 = 0;
if (!isIP(ip)) {
return -1; // ip 不合法
}
String[] ss = ip.trim().split("\\.");
for (int i = 0; i < 4; i++) {
ip10 += Math.pow(256, i) * Long.parseLong(ss[i]);
}
return ip10;
}
/**
*
* <p>将IP进制转换成十进制主机字节序</p>
* <p>
* IP是一个字符串符合IP的规则(0-255).(0-255).(0-255).(0-255).
* 将ip转换成长整型的原因是处理时间类型简单入库节省空间,查询提高效率.
* </p>
* <pre>
* IpUtil.getIpHostDesimal("192.168.1.1") = 3232235777
* IpUtil.getIpHostDesimal("192.168.1.256") = -1 //不符合Ip规则
* </pre>
* @see #getIpString(String)
* @param ip 符合IP规则的字符串
* @return <code>-1</code> 验证ip不合法,<code>ip</code> 计算ip返回长整型.
*/
public static long getIpHostDesimal(String ip) {
long ip10 = 0;
if (!isIP(ip)) {
return -1; // ip 不合法
}
String[] ss = ip.trim().split("\\.");
for (int i = 0; i < 4; i++) {
ip10 += Math.pow(256, 3 - i) * Long.parseLong(ss[i]);
}
return ip10;
}
/**
*
* <p>获取IP/mask 包含IP数量适合完整IPw网段</p>
* <p>
*
*
* </p>
* <pre>
*
*
* </pre>
* @param ip 符合IP规则的字符串
* @param mask 掩码格式
* @return <code>-1</code> 验证ip不合法,<code>ip</code> 计算ip返回长整型.
*/
public static long getIpNum(String ip, int mask) {
long num = 0;
if (isIP(ip)) {
String endIp = getEndIP(ip, mask);
num = getIpHostDesimal(endIp) - getIpHostDesimal(ip) +1;
} else {
throw new IllegalArgumentException("所传入的IP地址不符合IPV4规范");
}
return num;
}
// 此方法用于判断数据为空就置为0
private static String setStrEmpty(String str) {
if ("".equals(str) || str == null) {
str = "0";
}
return str;
}
private static String toString(byte[] address) {
StringWriter sw = new StringWriter(16);
sw.write(Integer.toString(address[0]&0xFF));
for(int i=1;i<address.length;i++){
sw.write(".");
sw.write(Integer.toString(address[i]&0xFF));
}
return sw.toString();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,46 +1,66 @@
package com.nis.util;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections.map.CaseInsensitiveMap;
import org.apache.log4j.Logger;
import org.dom4j.Attribute;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
import com.beust.jcommander.internal.Sets;
import com.nis.domain.FunctionServiceDict;
import jersey.repackaged.com.google.common.collect.Lists;
@SuppressWarnings("all")
public class ServiceConfigTemplateUtil {
private Logger logger = Logger.getLogger(getClass());
private static final Logger logger = Logger.getLogger(ServiceConfigTemplateUtil.class);
private static Node root;
static {
if(root == null) {//2018年12月28日11:37:50 fang 改为只加载一次,且方法改为 static
SAXReader reader = new SAXReader();
org.dom4j.Document document = null;
String configPath = "/service/service_config.xml";
InputStream is = null;
try {
is = ServiceConfigTemplateUtil.class.getResourceAsStream(configPath);
document = reader.read(is);
root = document.getRootElement();
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
} finally {
if(is != null ){
try {
is.close();
} catch (IOException e) { }
}
}
}
}
private Node root;
/**
* 配置文件内容
* @return
*/
public ServiceConfigTemplateUtil(){
SAXReader reader = new SAXReader();
org.dom4j.Document document = null;
String configPath = "/service/service_config.xml";
try {
document = reader.read(ServiceConfigTemplateUtil.class.getResourceAsStream(configPath));
root = document.getRootElement();
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
}
}
/**
* 获取业务节点列表
* @return
*/
public List<Node> getServiceNodeList(){
public static List<Node> getServiceNodeList(){
List<Node> nodes = root.selectNodes("service");
return nodes;
}
@@ -48,7 +68,7 @@ public class ServiceConfigTemplateUtil {
* 获取业务列表
* @return
*/
public List<Map<String,Object>> getServiceList(){
public static List<Map<String,Object>> getServiceList(){
List<Map<String,Object>> list =new ArrayList();
List<Element> elements = root.selectNodes("service");
for(Element element:elements){
@@ -63,12 +83,47 @@ public class ServiceConfigTemplateUtil {
}
return list;
}
/**
*
* @return
*/
public static Set<String> getCompileTableName(){
Set<String> result = Sets.newHashSet();
List<Element> elements = root.selectNodes("service");
for(Element element:elements){
String ev = element.attribute("tableName").getStringValue();
if(StringUtils.isNotBlank(ev)) {
result.add(ev.toLowerCase());
}
}
return result;
}
/**
* 根据类名 获取对应的 表名
* @param className
* @return
*/
public static String getCfgTableNameByClassName(String className) {
if(className == null) return null;
List<Element> elements = root.selectNodes("service");
for(Element element:elements){
String ev = element.attribute("tableName").getStringValue();
String cn = element.attribute("className").getStringValue();
if(className.equalsIgnoreCase(cn)) {
return ev.toLowerCase();
}
}
return null;
}
/**
*
* @param functionId
* @return
*/
public List<Map<String,Object>> getServiceListByFunctionId(Integer functionId){
public static List<Map<String,Object>> getServiceListByFunctionId(Integer functionId){
List<Map<String,Object>> list =new ArrayList();
if(!StringUtil.isEmpty(functionId)) {
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(functionId);
@@ -133,7 +188,7 @@ public class ServiceConfigTemplateUtil {
* 获取业务配置列表
* @return
*/
public List<Map<String,Object>> getServiceCfgList(Element serviceNode){
public static List<Map<String,Object>> getServiceCfgList(Element serviceNode){
List<Map<String,Object>> list = new ArrayList();
List<Element> elements = serviceNode.selectNodes("serviceCfg");
for(Element element:elements){
@@ -149,7 +204,7 @@ public class ServiceConfigTemplateUtil {
* 获取用户自定义域列表
* @return
*/
public List<Map<String,Object>> getUserRegionList(Element serviceNode){
public static List<Map<String,Object>> getUserRegionList(Element serviceNode){
List<Map<String,Object>> list = new ArrayList();
List<Element> elements = serviceNode.selectNodes("userRegion");
for(Element element:elements){
@@ -167,7 +222,7 @@ public class ServiceConfigTemplateUtil {
* @param attribute
* @return
*/
public List getXmlParamListByTag(String tag,String attribute){
public static List getXmlParamListByTag(String tag,String attribute){
List list =new ArrayList();
List<Element> elements = root.selectNodes(tag);
for(Element element:elements){
@@ -196,6 +251,7 @@ public class ServiceConfigTemplateUtil {
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();

View File

@@ -268,6 +268,7 @@ public class ExcelCsv {
for (String key : keyList) {
List<E> list=dataMap.get(key);
List<List<String>> listT=new ArrayList<List<String>>();
for (E e : list){
int colunm = 0;
List<String> lisb=new ArrayList<String>();
@@ -286,8 +287,8 @@ public class ExcelCsv {
}
}
// If is dict, get dict label
String valStr=val==null?"":val.toString();
if (StringUtils.isNotBlank(ef.dictType())){
String valStr=val==null?"":val.toString();
if("type".equals(ef.dictType()) || "attribute".equals(ef.dictType())
|| "label".equals(ef.dictType())){
// Get basic info
@@ -297,9 +298,34 @@ public class ExcelCsv {
String dict=DictUtils.getDictLabel(ef.dictType(), valStr, valStr);
//如果找不到字典国际化值,把字典本身作为默认值放进去,不然导出就是空了
val = msgProp.getProperty(dict,dict);
//业务配置-stream 阻断类型中 阻断 改为 封堵(丢弃)
if("block_type".equals(ef.title()) && dict.equals("action_reject")
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("35")
|| Reflections.invokeGetter(e, "serviceId").toString().equals("33")
|| Reflections.invokeGetter(e, "serviceId").toString().equals("36"))){
dict="block_drop";
val = msgProp.getProperty(dict,dict);
}
//ip spoofing redirect动作修改为Spoofing
if(ef.title().equals("block_type")
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("518"))) {
dict="action_spoofing";
val = msgProp.getProperty(dict,dict);
}
}
}
if(ef.title().equals("whether_area_block")&&!StringUtil.isEmpty(val)){
Integer whetherAreaBlock=Integer.parseInt(valStr);
if(whetherAreaBlock.equals(0)){
val = msgProp.getProperty("all","all");
}else if(whetherAreaBlock.equals(1)){
val = msgProp.getProperty("selective","selective");
}else{
val ="";
}
}
if(ef.title().equals("is_hex") && !StringUtil.isEmpty(val)){
Integer isHex=Integer.parseInt(val.toString());
if(isHex.equals(0) || isHex.equals(2)){
@@ -312,7 +338,7 @@ public class ExcelCsv {
}
if(ef.title().equals("is_case_insenstive") && !StringUtil.isEmpty(val)){
Integer isCaseSenstive=Integer.parseInt(val.toString());
if(isCaseSenstive.equals(0) || isCaseSenstive.equals(1)){
if(isCaseSenstive.equals(0)){
val = msgProp.getProperty("case_insenstive","case_insenstive");
}else if(isCaseSenstive.equals(1)){
val = msgProp.getProperty("case_senstive","case_senstive");

View File

@@ -496,7 +496,7 @@ public class ExportExcel {
commentStr=commentStr+""+msgProp.getProperty("required")+"\n";
index++;
}
if(("domain_name".equals(headerStr)) && (region.getFunctionId().equals(560))){
if("domain_name".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//1、非空
@@ -1113,9 +1113,9 @@ public class ExportExcel {
commentStr="";
}
if(StringUtil.isEmpty(defaultValue)){
defaultValue="0";
defaultValue = region.getConfigDirection().split(",")[0];
}
defaultValue = region.getFunctionId().equals(301)?"1":defaultValue;
}
/*}*/
/*if(StringUtil.isEmpty(commentStr)){
@@ -2266,6 +2266,20 @@ public class ExportExcel {
String dict=DictUtils.getDictLabel(ef.dictType(), valStr, valStr);
//如果找不到字典国际化值,把字典本身作为默认值放进去,不然导出就是空了
val = msgProp.getProperty(dict,dict);
//业务配置-stream 阻断类型中 阻断 改为 封堵(丢弃)
if("block_type".equals(ef.title()) && dict.equals("action_reject")
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("35")
|| Reflections.invokeGetter(e, "serviceId").toString().equals("33")
|| Reflections.invokeGetter(e, "serviceId").toString().equals("36"))){
dict="block_drop";
val = msgProp.getProperty(dict,dict);
}
//ip spoofing redirect动作修改为Spoofing
if(ef.title().equals("block_type")
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("518"))) {
dict="action_spoofing";
val = msgProp.getProperty(dict,dict);
}
}
}
@@ -2291,7 +2305,7 @@ public class ExportExcel {
}
if(ef.title().equals("is_case_insenstive") && !StringUtil.isEmpty(val)){
Integer isCaseSenstive=Integer.parseInt(val.toString());
if(isCaseSenstive.equals(0) || isCaseSenstive.equals(1)){
if(isCaseSenstive.equals(0)){
val = msgProp.getProperty("case_insenstive","case_insenstive");
}else if(isCaseSenstive.equals(1)){
val = msgProp.getProperty("case_senstive","case_senstive");

View File

@@ -20,6 +20,7 @@ import java.util.concurrent.BlockingQueue;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@@ -468,7 +469,7 @@ public class ImportBigExcel extends XLSXCovertCSVReader{
if(StringUtils.endsWith(s, ".0") && !s.endsWith("0.0.0.0")){
val = StringUtils.substringBefore(s, ".0");
}else{
val = String.valueOf(val.toString().trim());
val=val == null ? "" : StringEscapeUtils.escapeHtml4(val.toString().trim());
}
}else if (valType == Integer.class){
val = Double.valueOf(val.toString().trim()).intValue();

View File

@@ -8,7 +8,9 @@ import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
@@ -32,6 +34,8 @@ import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import com.nis.util.StringUtil;
/**
* 使用CVS模式解决XLSX文件可以有效解决用户模式内存溢出的问题
@@ -102,6 +106,7 @@ public abstract class XLSXCovertCSVReader {
// The last column printed to the output stream
private int lastColumnNumber = -1;
private List<Object> rowlist = new ArrayList<Object>();
private Map<Integer,Object> rowMap = new HashMap<Integer, Object>();
// Gathers characters as they are seen.
private StringBuffer value;
// private String[] record;
@@ -128,6 +133,7 @@ public abstract class XLSXCovertCSVReader {
this.nextDataType = xssfDataType.NUMBER;
this.formatter = new DataFormatter();
rowlist.clear();// 每次读取都清空行集合
rowMap.clear();
}
/*
@@ -287,6 +293,9 @@ public abstract class XLSXCovertCSVReader {
int len = countNullCell(refnum, preRefnum);
for(int i=0;i<len;i++){
rowlist.add(curCol, "");
if(!rowMap.containsKey(thisColumn)){
rowMap.put(thisColumn, "");
}
curCol++;
}
}
@@ -298,6 +307,7 @@ public abstract class XLSXCovertCSVReader {
}
// System.out.println("refnum="+refnum+"preRefnum="+preRefnum+"curCol="+curCol);
rowlist.add(curCol, thisVal);
rowMap.put(thisColumn, thisVal);
rowData.add(new IndexValue(refnum,lastContents) );
curCol++;
// record[thisColumn] = thisStr;
@@ -324,15 +334,24 @@ public abstract class XLSXCovertCSVReader {
int len = countNullCell(maxRefnum, refnum);
for(int i=0;i<=len;i++){
rowlist.add(curCol, "");
if(!rowMap.containsKey(thisColumn)){
rowMap.put(thisColumn, "");
}
curCol++;
}
int totalLen= countTotalCell(maxRefnum);
if(rowlist.size()<totalLen) {
List<Object> tempList=new ArrayList<>(totalLen);
for(int i=0;i<(totalLen-rowlist.size());i++) {
tempList.add("");
//修改某一个单元格为空,字段映射顺序错乱问题
for(int i=0;i<totalLen;i++) {
if(!StringUtil.isEmpty(rowMap.get(i))){
tempList.add(rowMap.get(i));
}else{
tempList.add(i,"");
}
}
tempList.addAll(rowlist);
//tempList.addAll(rowlist);
rowlist= tempList;
}
}
@@ -343,6 +362,7 @@ public abstract class XLSXCovertCSVReader {
optRows(sheetIndex,lastColumnNumber,rowlist);
rowlist.clear();
rowMap.clear();
// rows.add(record.clone());
isCellNull = false;
// for (int i = 0; i < record.length; i++) {
@@ -352,6 +372,7 @@ public abstract class XLSXCovertCSVReader {
}
rowlist.clear();
rowData.clear();
rowMap.clear();
curCol = 0;
preRefnum = null;
refnum = null;

View File

@@ -45,6 +45,7 @@ public class CheckAppFeatureComplexStringFormatThread implements Callable<String
public String call() throws Exception {
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
StringBuffer msg=new StringBuffer();
boolean error = false;
while(!srcQueue.isEmpty()) {
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
if(regionDict.getRegionType().intValue()==3) {
@@ -57,10 +58,15 @@ public class CheckAppFeatureComplexStringFormatThread implements Callable<String
//msg=e.getMessage();
//msg.append(e.getMessage());
//break;
error = true;
}
}
dataList.clear();
}
if(error) {
msg.append("validate_error");
}
return msg.toString();
}
public List<AppComplexFeatureCfg> checkAppComplexFeatureCfg(StringBuffer msg,

View File

@@ -45,6 +45,7 @@ public class CheckComplexStringFormatThread implements Callable<String>{
public String call() throws Exception {
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
StringBuffer msg=new StringBuffer();
boolean error = false;
while(!srcQueue.isEmpty()) {
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
if(regionDict.getRegionType().intValue()==3) {
@@ -57,10 +58,15 @@ public class CheckComplexStringFormatThread implements Callable<String>{
//msg=e.getMessage();
//msg.append(e.getMessage());
//break;
error = true;
}
}
dataList.clear();
}
if(error) {
msg.append("validate_error");
}
return msg.toString();
}
public List<ComplexkeywordCfg> checkComplexStringCfg(StringBuffer msg,

View File

@@ -42,6 +42,7 @@ public class CheckDnsResStrategyFormatThread implements Callable<String>{
public String call() throws Exception {
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
StringBuffer msg=new StringBuffer();
boolean error = false;
while(!srcQueue.isEmpty()) {
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
if(regionDict.getRegionType().intValue()==6) {
@@ -53,10 +54,15 @@ public class CheckDnsResStrategyFormatThread implements Callable<String>{
// TODO: handle exception
//msg=e.getMessage();
//break;
error = true;
}
}
dataList.clear();
}
if(error) {
msg.append("validate_error");
}
return msg.toString();
}
public List<DnsResStrategy> checkDnsResStrategyCfg(StringBuffer msg,List<?> list)

View File

@@ -1,6 +1,7 @@
package com.nis.util.excel.thread;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -19,14 +20,17 @@ import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.basics.AsnGroupInfo;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.basics.PolicyGroupInfo;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.DnsResStrategy;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.template.IpRateLimitTemplate;
import com.nis.domain.specific.ConfigGroupInfo;
//import com.nis.util.AsnCacheUtils;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
public class CheckIpFormatThread implements Callable<String>{
private Logger logger=Logger.getLogger(CheckIpFormatThread.class);
@@ -36,8 +40,16 @@ public class CheckIpFormatThread implements Callable<String>{
// private DnsResStrategyService dnsResStrategyService;
private FunctionServiceDict serviceDict;
private FunctionRegionDict regionDict;
//【0】 新的asn group info
//【1】 旧的asn group info
//【2】 所有的asn group info
//【3】 所有已审核通过的asn group info
private List<Map<Long,AsnGroupInfo>> asnNoMaps;
private Map<Long,AsnGroupInfo> asnGroupInfos;
private Map<String,List<IpPortCfg>> asnIpMap;
//组织之间的关系
//【0】 新的组织信息
//【1】 旧的组织信息
private List<Map<String,ConfigGroupInfo>> asnOrgList;
// private DnsResStrategyDao dnsResStrategyDao;
public CheckIpFormatThread(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,Properties prop,BlockingQueue<? extends Object> srcQueue,BlockingQueue<BaseIpCfg> destQueue) {
this.serviceDict=serviceDict;
@@ -51,11 +63,12 @@ public class CheckIpFormatThread implements Callable<String>{
public String call() throws Exception {
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
StringBuffer msg=new StringBuffer();
boolean error = false;
while(!srcQueue.isEmpty()) {
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
if(regionDict.getRegionType().intValue()==1) {
try {
List<BaseIpCfg> ipcfgs=this.checkIpCfg(msg,asnNoMaps, dataList);
List<BaseIpCfg> ipcfgs=this.checkIpCfg(msg,asnNoMaps,asnIpMap, dataList);
boolean success=destQueue.addAll(ipcfgs);
}catch (Exception e) {
logger.error("checkIpCfg error,",e);
@@ -63,13 +76,18 @@ public class CheckIpFormatThread implements Callable<String>{
// TODO: handle exception
//msg.append(e.getMessage());
//break;
error = true;
}
}
dataList.clear();
}
if(error) {
msg.append("validate_error");
}
return msg.toString();
}
public List<BaseIpCfg> checkIpCfg(StringBuffer msg,List<Map<Long,AsnGroupInfo>> asnNos, List<Object> list)
public List<BaseIpCfg> checkIpCfg(StringBuffer msg,List<Map<Long,AsnGroupInfo>> asnNos,Map<String, List<IpPortCfg>> asnIpCfgs, List<Object> list)
throws ServiceException {
logger.warn("start to validate ip...");
long start=System.currentTimeMillis();
@@ -252,12 +270,9 @@ public class CheckIpFormatThread implements Callable<String>{
}
}
if (regionDict.getFunctionId().equals(600)) {//asn
//组织的非空和长度校验
String organization=baseIpCfg.getOrganization();
if(StringUtils.isBlank(organization)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("organization","Organization"))
+ ";");
}else {
if(!StringUtils.isBlank(organization)) {
if(organization.length() > 1024){
errInfo.append(prop.getProperty("asn_name")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":1024") + ";");
}else {
@@ -266,33 +281,25 @@ public class CheckIpFormatThread implements Callable<String>{
}
baseIpCfg.setOrganization(organization.trim().toUpperCase());
}
}
//国家的非空和长度校验
String country=baseIpCfg.getCountry();
if(StringUtils.isBlank(country)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("country"))
+ ";");
if(!StringUtils.isBlank(country) && country.length() > 512){
errInfo.append(prop.getProperty("country_code")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":512") + ";");
}else {
if(country.length() > 512){
errInfo.append(prop.getProperty("country_code")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":512") + ";");
}else {
baseIpCfg.setCountry(country.trim().toUpperCase());
}
baseIpCfg.setCountry(country.trim().toUpperCase());
}
//详情可以为空
String detail=baseIpCfg.getDetail();
if(StringUtils.isBlank(detail)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("detail"))
+ ";");
}else {
if(!StringUtils.isBlank(detail)) {
if(detail.length() > 1024||detail.length()<4){
errInfo.append(prop.getProperty("details")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";");
}else {
baseIpCfg.setDetail(detail.trim());
}
}
//asn id
//asn id 校验
String userRegion1 = baseIpCfg.getUserRegion1();
if(StringUtils.isBlank(userRegion1)) {
errInfo.append(
@@ -306,55 +313,66 @@ public class CheckIpFormatThread implements Callable<String>{
String.format(prop.getProperty("must_between"),"1","4294967295" )
+ ";");
}else {
// ConfigGroupInfo configGroupInfo=asnIpCfgService.getConfigGroupInfoByAsnNo(asnNo);
if(StringUtil.isEmpty(baseIpCfg.getOrganization())){
baseIpCfg.setOrganization(asnNo.toString());
baseIpCfg.setCfgDesc(asnNo.toString());
}
if(asnNos!=null) {
AsnGroupInfo configGroupInfo=asnGroupInfos==null?null:asnGroupInfos.get(asnNo);//从缓存中取
//缓存中没有
if(configGroupInfo==null) {
//数据库中是否已经存在
AsnGroupInfo asnGroupInfo=asnNos.get(1)==null?null:asnNos.get(1).get(asnNo);
if(asnGroupInfo==null) {
synchronized (Constants.IMPORT_LOCK) {
if(StringUtils.isNotBlank(baseIpCfg.getOrganization())&&StringUtils.isNotBlank(baseIpCfg.getCountry())) {
if(StringUtils.isNotBlank(baseIpCfg.getOrganization())) {
AsnGroupInfo groupInfo=new AsnGroupInfo();
groupInfo.setOrganization(baseIpCfg.getOrganization().trim().toUpperCase());
groupInfo.setCountry(baseIpCfg.getCountry().trim().toUpperCase());
groupInfo.setDetail(baseIpCfg.getDetail().trim());
groupInfo.setCountry(StringUtil.isEmpty(baseIpCfg.getCountry()) ? "":baseIpCfg.getCountry().trim().toUpperCase());
groupInfo.setDetail(StringUtil.isEmpty(baseIpCfg.getDetail()) ? "":baseIpCfg.getDetail().trim().toUpperCase());
groupInfo.setIsUsed(0);
groupInfo.setIsValid(0);
groupInfo.setAsnId(asnNo);
if(asnNos.get(0).containsKey(asnNo)) {
if(!asnNos.get(0).get(asnNo).getOrganization().equals(baseIpCfg.getOrganization().trim().toUpperCase())) {
if(asnNos.get(2).containsKey(asnNo)) {
if(!asnNos.get(2).get(asnNo).getOrganization().equalsIgnoreCase(baseIpCfg.getOrganization().trim())) {
//一个asn号不能被两个组织拥有
logger.error("ASN "+asnNo+" Found two Organization "+asnNos.get(0).get(asnNo).getOrganization()+" "+baseIpCfg.getOrganization().trim().toUpperCase());
errInfo.append(asnNos.get(0).get(asnNo).getOrganization()+" "+baseIpCfg.getOrganization().trim().toUpperCase()+" "+prop.getProperty("asn_no")+" "+asnNo+" "+prop.getProperty("repeat")
logger.error("ASN "+asnNo+" Found two Organization "+asnNos.get(2).get(asnNo).getOrganization()+" "+baseIpCfg.getOrganization().trim().toUpperCase());
errInfo.append(asnNos.get(2).get(asnNo).getOrganization()+" "+baseIpCfg.getOrganization().trim().toUpperCase()+" "+prop.getProperty("asn_no")+" "+asnNo+" "+prop.getProperty("repeat")
+";");
}else {
asnNos.get(0).put(asnNo,groupInfo);
asnNos.get(2).put(asnNo,groupInfo);
if(!asnOrgList.get(0).containsKey(groupInfo.getOrganization()) && !asnOrgList.get(1).containsKey(groupInfo.getOrganization())){
ConfigGroupInfo configGroupInfo=new ConfigGroupInfo();
configGroupInfo.setGroupName(groupInfo.getOrganization());
asnOrgList.get(0).put(groupInfo.getOrganization(), configGroupInfo);
}
}
}else {
asnNos.get(0).put(asnNo,groupInfo);
}
}else {
if(StringUtils.isNotBlank(baseIpCfg.getOrganization())) {
logger.error("ASN "+asnNo+" Organization is Null");
}
if(StringUtils.isNotBlank(baseIpCfg.getCountry())) {
logger.error("ASN "+asnNo+" Country is Null");
asnNos.get(2).put(asnNo,groupInfo);
if(!asnOrgList.get(0).containsKey(groupInfo.getOrganization()) && !asnOrgList.get(1).containsKey(groupInfo.getOrganization())){
ConfigGroupInfo configGroupInfo=new ConfigGroupInfo();
configGroupInfo.setGroupName(groupInfo.getOrganization());
asnOrgList.get(0).put(groupInfo.getOrganization(), configGroupInfo);
}
}
}
}
}else {
if(!configGroupInfo.getOrganization().equalsIgnoreCase(baseIpCfg.getOrganization().trim())) {
if(!asnGroupInfo.getOrganization().equalsIgnoreCase(baseIpCfg.getOrganization().trim())) {
errInfo.append(prop.getProperty("organization","Organization")+" "+prop.getProperty("mismatch","Mismatch"));
}
if(!configGroupInfo.getCountry().equalsIgnoreCase(baseIpCfg.getCountry().trim())) {
errInfo.append(prop.getProperty("country","Country")+" "+prop.getProperty("mismatch","Mismatch"));
}
if(!configGroupInfo.getDetail().equalsIgnoreCase(baseIpCfg.getDetail().trim())) {
errInfo.append(prop.getProperty("detail","Detail")+" "+prop.getProperty("mismatch","Mismatch"));
}
if(StringUtils.isBlank(errInfo.toString())) {
asnNos.get(1).put(asnNo,configGroupInfo);
//已下发过的asn no
if(asnGroupInfo.getIsValid() ==1){
asnNos.get(3).put(asnNo,asnGroupInfo);
}
asnNos.get(1).put(asnNo,asnGroupInfo);
asnGroupInfo.setOrganization(organization);
asnGroupInfo.setCountry(baseIpCfg.getCountry());
asnGroupInfo.setDetail(baseIpCfg.getDetail());
asnNos.get(2).put(asnNo,asnGroupInfo);
}
}
}
@@ -937,6 +955,16 @@ public class CheckIpFormatThread implements Callable<String>{
errTip.append(errInfo);
errTip.append("<br>");
}else {
synchronized (Constants.IMPORT_ASN_LOCK) {
//asn根据asn号分组存储asn ip信息
if(StringUtil.isEmpty(asnIpCfgs.get(baseIpCfg.getUserRegion1()))){
List<IpPortCfg> asnIpList=new ArrayList<>();
asnIpList.add(baseIpCfg);
asnIpCfgs.put(baseIpCfg.getUserRegion1(), asnIpList);
}else{
asnIpCfgs.get(baseIpCfg.getUserRegion1()).add(baseIpCfg);
}
}
ipList.add(baseIpCfg);
}
}
@@ -1384,11 +1412,16 @@ public class CheckIpFormatThread implements Callable<String>{
public void setAsnNoMaps(List<Map<Long, AsnGroupInfo>> asnNoMaps) {
this.asnNoMaps = asnNoMaps;
}
public Map<Long, AsnGroupInfo> getAsnGroupInfos() {
return asnGroupInfos;
public List<Map<String, ConfigGroupInfo>> getAsnOrgList() {
return asnOrgList;
}
public void setAsnGroupInfos(Map<Long, AsnGroupInfo> asnGroupInfos) {
this.asnGroupInfos = asnGroupInfos;
public void setAsnOrgList(List<Map<String, ConfigGroupInfo>> asnOrgList) {
this.asnOrgList = asnOrgList;
}
public Map<String, List<IpPortCfg>> getAsnIpMap() {
return asnIpMap;
}
public void setAsnIpMap(Map<String, List<IpPortCfg>> asnIpMap) {
this.asnIpMap = asnIpMap;
}
}

View File

@@ -44,6 +44,7 @@ public class CheckStringFormatThread implements Callable<String>{
public String call() throws Exception {
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
StringBuffer msg=new StringBuffer();
boolean error = false;
while(!srcQueue.isEmpty()) {
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
if(regionDict.getRegionType().intValue()==2) {
@@ -55,10 +56,15 @@ public class CheckStringFormatThread implements Callable<String>{
// TODO: handle exception
//msg=e.getMessage();
//break;
error = true;
}
}
dataList.clear();
}
if(error) {
msg.append("validate_error");
}
return msg.toString();
}
@@ -84,7 +90,7 @@ public class CheckStringFormatThread implements Callable<String>{
}
StringBuffer errTip = new StringBuffer();
Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f");
Pattern domainPattern = Pattern.compile(Constants.DOMAIN_REGEXP);
Pattern domainPattern = Pattern.compile("^[a-zA-Z0-9.-]*$");
for (int i = 0; i < list.size(); i++) {
StringBuffer errInfo = new StringBuffer();
BaseStringCfg baseStringCfg = new BaseStringCfg();
@@ -463,8 +469,12 @@ public class CheckStringFormatThread implements Callable<String>{
if (hexP.indexOf("1") != -1 && isHex.intValue() == 1) {
boolean bl = Pattern.compile("^([0-9|a-f|A-F]*)$").matcher(keyword).matches();
if(!bl) {
String message = prop.getProperty("key_word");
if(regionDict.getFunctionId().equals(403) || regionDict.getFunctionId().equals(200)) {
message = prop.getProperty("domain_name");
}
errInfo.append(
prop.getProperty("key_word") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
message + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
}
}
}

View File

@@ -3,12 +3,14 @@ package com.nis.util.excel.thread;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.collections.map.CaseInsensitiveMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.jets3t.service.ServiceException;
@@ -20,6 +22,7 @@ import com.nis.domain.FunctionServiceDict;
import com.nis.domain.configuration.AppTopicDomainCfg;
import com.nis.domain.configuration.WebsiteDomainTopic;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.web.security.UserUtils;
import com.nis.web.service.SpringContextHolder;
import com.nis.web.service.configuration.AppCfgService;
@@ -44,6 +47,7 @@ public class CheckTopicWebsiteFormatThread implements Callable<String>{
public String call() throws Exception {
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
StringBuffer msg=new StringBuffer();
boolean error = false;
while(!srcQueue.isEmpty()) {
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
if(regionDict.getRegionType().intValue()==2) {
@@ -55,10 +59,15 @@ public class CheckTopicWebsiteFormatThread implements Callable<String>{
// TODO: handle exception
//msg=e.getMessage();
//break;
error = true;
}
}
dataList.clear();
}
if(error) {
msg.append("validate_error");
}
return msg.toString();
}
@@ -84,7 +93,7 @@ public class CheckTopicWebsiteFormatThread implements Callable<String>{
}
StringBuffer errTip = new StringBuffer();
Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f");
Pattern domainPattern = Pattern.compile(Constants.DOMAIN_REGEXP);
Pattern domainPattern = Pattern.compile("^[a-zA-Z0-9.-]*$");
for (int i = 0; i < list.size(); i++) {
StringBuffer errInfo = new StringBuffer();
AppTopicDomainCfg baseStringCfg = new AppTopicDomainCfg();
@@ -99,16 +108,36 @@ public class CheckTopicWebsiteFormatThread implements Callable<String>{
}
if (regionDict.getRegionType().equals(2)) {
// 主题、网站
Long topicId = baseStringCfg.getTopicId();
Long websiteServiceId = baseStringCfg.getWebsiteServiceId();
if (topicId == null) {
errInfo.append(prop.getProperty("topic") +" "+ prop.getProperty("not_exist") + ";");
// 主题、网站验
String topic = baseStringCfg.getTopic();
String websiteService = baseStringCfg.getWebsiteService();
if(StringUtils.isBlank(topic)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("topic") + " ") + ";");
}else {
Map<String, String> dictMap = DictUtils.getDictOptionInReversion("TOPIC");
CaseInsensitiveMap topicDictMap = new CaseInsensitiveMap(dictMap);
String topicDictCode = (String)topicDictMap.get(topic);
if(StringUtils.isBlank(topicDictCode)) {
errInfo.append(prop.getProperty("topic") +" "+ prop.getProperty("not_exist") + ";");
}else {
baseStringCfg.setTopicId(Long.parseLong(topicDictCode));
}
}
if (websiteServiceId == null) {
errInfo.append(prop.getProperty("website_server") +" "+ prop.getProperty("not_exist") + ";");
if(StringUtils.isBlank(websiteService)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("website_server") + " ") + ";");
}else {
Map<String, String> dictMap = DictUtils.getDictOptionInReversion("WEBSITE_SERVER");
CaseInsensitiveMap websiteDictMap = new CaseInsensitiveMap(dictMap);
String websiteServiceDictCode = (String)websiteDictMap.get(websiteService);
if(StringUtils.isBlank(websiteServiceDictCode)) {
errInfo.append(prop.getProperty("website_server") +" "+ prop.getProperty("not_exist") + ";");
}else {
baseStringCfg.setWebsiteServiceId(Long.parseLong(websiteServiceDictCode));
}
}
String keyword = baseStringCfg.getCfgKeywords();
@@ -258,7 +287,7 @@ public class CheckTopicWebsiteFormatThread implements Callable<String>{
boolean bl = Pattern.compile("^([0-9|a-f|A-F]*)$").matcher(keyword).matches();
if(!bl) {
errInfo.append(
prop.getProperty("key_word") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
prop.getProperty("domain_name") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
}
}
}

View File

@@ -46,6 +46,7 @@ import com.nis.domain.Page;
import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.basics.AsnGroupInfo;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.basics.PolicyGroupInfo;
import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.basics.SysDictInfo;
import com.nis.domain.configuration.AppComplexFeatureCfg;
@@ -120,6 +121,7 @@ import com.nis.domain.maat.MaatCfg.NumBoundaryCfg;
import com.nis.domain.maat.MaatCfg.StringCfg;
import com.nis.domain.maat.ToMaatBean;
import com.nis.domain.report.NtcPzReport;
import com.nis.domain.specific.ConfigGroupInfo;
import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.exceptions.MaatConvertException;
//import com.nis.util.AsnCacheUtils;
@@ -154,6 +156,7 @@ import com.nis.web.service.SystemService;
import com.nis.web.service.UserService;
import com.nis.web.service.basics.AsnGroupInfoService;
import com.nis.web.service.basics.AsnIpCfgService;
import com.nis.web.service.basics.DnsKeywordCfgService;
import com.nis.web.service.basics.IpReuseIpCfgService;
import com.nis.web.service.basics.PolicyGroupInfoService;
import com.nis.web.service.basics.ServiceDictInfoService;
@@ -330,6 +333,8 @@ public class BaseController {
protected PxyObjSpoofingIpPoolService pxyObjSpoofingIpPoolService;// 欺骗IP池
@Autowired
protected AsnGroupInfoService asnGroupInfoService;// asn组
@Autowired
protected DnsKeywordCfgService dnsKeywordCfgService;//DNS关键字分组配置
/**
* 管理基础路径
*/
@@ -638,6 +643,8 @@ public class BaseController {
}
}
}
List<PolicyGroupInfo> policyGroupInfos = policyGroupInfoService.findPolicyGroupInfosByTypeforUD(cfg.getGroupType(), cfg.getUdFlag());
model.addAttribute("policyGroupInfos", policyGroupInfos);
}
protected void initUpdateFormCondition(Model model, BaseCfg cfg) {
@@ -702,6 +709,8 @@ public class BaseController {
model.addAttribute("regionList", regionList);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
model.addAttribute("serviceList", serviceList);
List<PolicyGroupInfo> policyGroupInfos = policyGroupInfoService.findPolicyGroupInfosByTypeforUD(cfg.getGroupType(), cfg.getUdFlag());
model.addAttribute("policyGroupInfos", policyGroupInfos);
}
public List<AreaBean> getAreaIsps(String areaEffectiveIds, List<AreaBean> areaIspList, List<SysDictInfo> isps,
@@ -957,16 +966,19 @@ public class BaseController {
* @throws InterruptedException
* @throws ExecutionException
*/
public BlockingQueue<BaseIpCfg> checkIpCfgMulity(StringBuffer _msg,FunctionServiceDict serviceDict, FunctionRegionDict regionDict,List<Map<Long,AsnGroupInfo>> asnNos,Map<Long,AsnGroupInfo> asnGroupInfos, BlockingQueue<? extends Object> list) throws ServiceException, InterruptedException, ExecutionException{
public BlockingQueue<BaseIpCfg> checkIpCfgMulity(StringBuffer _msg,FunctionServiceDict serviceDict, FunctionRegionDict regionDict,List<Map<Long,AsnGroupInfo>> asnNos,List<Map<String,ConfigGroupInfo>> asnOrgList,Map<String,List<IpPortCfg>> asnIpMap, BlockingQueue<? extends Object> list) throws ServiceException, InterruptedException, ExecutionException{
logger.warn("start checkIpCfgMulity ,size "+list.size());
long start=System.currentTimeMillis();
BlockingQueue<BaseIpCfg> queue=new ArrayBlockingQueue<>(list.size());
ExecutorService service=Executors.newFixedThreadPool(Constants.MULITY_THREAD_SIZE);
List<Future<String>> futures=new ArrayList<>();
Properties props=this.getMsgProp();
for(int i=0;i<Constants.MULITY_THREAD_SIZE;i++) {
CheckIpFormatThread t=new CheckIpFormatThread(serviceDict,regionDict, this.getMsgProp(), list, queue);
CheckIpFormatThread t=new CheckIpFormatThread(serviceDict,regionDict, props, list, queue);
t.setAsnNoMaps(asnNos);
t.setAsnGroupInfos(asnGroupInfos);
t.setAsnOrgList(asnOrgList);
t.setAsnIpMap(asnIpMap);
futures.add(service.submit(t));
}
service.shutdown();
@@ -978,13 +990,85 @@ public class BaseController {
e.printStackTrace();
}
}
boolean valideteError=false;
for(Future<String> future:futures) {
String msg = future.get();
if(StringUtils.isNotBlank(msg)) {
if(msg.equals("validate_error")) {
valideteError=true;
}else if(msg.endsWith("validate_error")) {
_msg.append(msg.substring(0, msg.length()-1-"validate_error".length()));
valideteError=true;
}else {
_msg.append(msg);
}
//throw new ServiceException(msg);
_msg.append(msg);
}
}
if(valideteError) {
_msg.append(props.getProperty("validate_error", "Unexpected error occurred while validating"));
}
long end=System.currentTimeMillis();
logger.warn("checkIpCfgMulity finish,cost:"+(end-start)+",size:"+queue.size());
return queue;
}
/**
* 多线程验证
* @param serviceDict
* @param regionDict
* @param asnNos
* @param list
* @return
* @throws ServiceException
* @throws InterruptedException
* @throws ExecutionException
*/
public BlockingQueue<BaseIpCfg> checkAsnIpCfgMulity(StringBuffer _msg,FunctionServiceDict serviceDict, FunctionRegionDict regionDict,List<Map<Long,AsnGroupInfo>> asnNos,List<Map<String,ConfigGroupInfo>> asnOrgList,Map<String,List<IpPortCfg>> asnIpMap, BlockingQueue<? extends Object> list) throws ServiceException, InterruptedException, ExecutionException{
logger.warn("start checkIpCfgMulity ,size "+list.size());
long start=System.currentTimeMillis();
BlockingQueue<BaseIpCfg> queue=new ArrayBlockingQueue<>(list.size());
ExecutorService service=Executors.newFixedThreadPool(Constants.MULITY_THREAD_SIZE);
List<Future<String>> futures=new ArrayList<>();
Properties props=this.getMsgProp();
for(int i=0;i<Constants.MULITY_THREAD_SIZE;i++) {
CheckIpFormatThread t=new CheckIpFormatThread(serviceDict,regionDict, props, list, queue);
t.setAsnNoMaps(asnNos);
t.setAsnOrgList(asnOrgList);
t.setAsnIpMap(asnIpMap);
futures.add(service.submit(t));
}
service.shutdown();
while(!service.isTerminated()) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
boolean valideteError=false;
for(Future<String> future:futures) {
String msg = future.get();
if(StringUtils.isNotBlank(msg)) {
if(msg.equals("validate_error")) {
valideteError=true;
}else if(msg.endsWith("validate_error")) {
_msg.append(msg.substring(0, msg.length()-1-"validate_error".length()));
valideteError=true;
}else {
_msg.append(msg);
}
//throw new ServiceException(msg);
}
}
if(valideteError) {
_msg.append(props.getProperty("validate_error", "Unexpected error occurred while validating"));
}
long end=System.currentTimeMillis();
logger.warn("checkIpCfgMulity finish,cost:"+(end-start)+",size:"+queue.size());
return queue;
@@ -1005,8 +1089,10 @@ public class BaseController {
BlockingQueue<BaseStringCfg<?>> queue=new ArrayBlockingQueue<>(list.size());
ExecutorService service=Executors.newFixedThreadPool(Constants.MULITY_THREAD_SIZE);
List<Future<String>> futures=new ArrayList<>();
Properties props=this.getMsgProp();
for(int i=0;i<Constants.MULITY_THREAD_SIZE;i++) {
CheckStringFormatThread t=new CheckStringFormatThread(serviceDict,regionDict, this.getMsgProp(), list, queue);
CheckStringFormatThread t=new CheckStringFormatThread(serviceDict,regionDict, props, list, queue);
futures.add(service.submit(t));
}
service.shutdown();
@@ -1018,13 +1104,26 @@ public class BaseController {
e.printStackTrace();
}
}
boolean valideteError=false;
for(Future<String> future:futures) {
String msg = future.get();
if(StringUtils.isNotBlank(msg)) {
if(msg.equals("validate_error")) {
valideteError=true;
}else if(msg.endsWith("validate_error")) {
_msg.append(msg.substring(0, msg.length()-1-"validate_error".length()));
valideteError=true;
}else {
_msg.append(msg);
}
//throw new ServiceException(msg);
_msg.append(msg);
}
}
if(valideteError) {
_msg.append(props.getProperty("validate_error", "Unexpected error occurred while validating"));
}
long end=System.currentTimeMillis();
logger.warn("checkStringCfgMulity finish,cost:"+(end-start)+",size:"+queue.size());
return queue;
@@ -1045,8 +1144,10 @@ public class BaseController {
BlockingQueue<ComplexkeywordCfg> queue=new ArrayBlockingQueue<>(list.size());
ExecutorService service=Executors.newFixedThreadPool(Constants.MULITY_THREAD_SIZE);
List<Future<String>> futures=new ArrayList<>();
Properties props=this.getMsgProp();
for(int i=0;i<Constants.MULITY_THREAD_SIZE;i++) {
CheckComplexStringFormatThread t=new CheckComplexStringFormatThread(serviceDict,regionDict, this.getMsgProp(), list, queue);
CheckComplexStringFormatThread t=new CheckComplexStringFormatThread(serviceDict,regionDict, props, list, queue);
futures.add(service.submit(t));
}
service.shutdown();
@@ -1058,13 +1159,26 @@ public class BaseController {
e.printStackTrace();
}
}
boolean valideteError=false;
for(Future<String> future:futures) {
String msg = future.get();
if(StringUtils.isNotBlank(msg)) {
if(msg.equals("validate_error")) {
valideteError=true;
}else if(msg.endsWith("validate_error")) {
_msg.append(msg.substring(0, msg.length()-1-"validate_error".length()));
valideteError=true;
}else {
_msg.append(msg);
}
//throw new ServiceException(msg);
_msg.append(msg);
}
}
if(valideteError) {
_msg.append(props.getProperty("validate_error", "Unexpected error occurred while validating"));
}
long end=System.currentTimeMillis();
logger.warn("checkComplexStringCfgMulity finish,cost:"+(end-start)+",size:"+queue.size());
return queue;
@@ -1085,8 +1199,10 @@ public class BaseController {
BlockingQueue<DnsResStrategy> queue=new ArrayBlockingQueue<>(list.size());
ExecutorService service=Executors.newFixedThreadPool(Constants.MULITY_THREAD_SIZE);
List<Future<String>> futures=new ArrayList<>();
Properties props=this.getMsgProp();
for(int i=0;i<Constants.MULITY_THREAD_SIZE;i++) {
CheckDnsResStrategyFormatThread t=new CheckDnsResStrategyFormatThread(serviceDict,regionDict, this.getMsgProp(), list, queue);
CheckDnsResStrategyFormatThread t=new CheckDnsResStrategyFormatThread(serviceDict,regionDict, props, list, queue);
futures.add(service.submit(t));
}
service.shutdown();
@@ -1098,13 +1214,26 @@ public class BaseController {
e.printStackTrace();
}
}
boolean valideteError=false;
for(Future<String> future:futures) {
String msg = future.get();
if(StringUtils.isNotBlank(msg)) {
_msg.append(msg);
if(msg.equals("validate_error")) {
valideteError=true;
}else if(msg.endsWith("validate_error")) {
_msg.append(msg.substring(0, msg.length()-1-"validate_error".length()));
valideteError=true;
}else {
_msg.append(msg);
}
//throw new ServiceException(msg);
}
}
if(valideteError) {
_msg.append(props.getProperty("validate_error", "Unexpected error occurred while validating"));
}
long end=System.currentTimeMillis();
logger.warn("checkDnsResStrategyCfgMulity finish,cost:"+(end-start)+",size:"+queue.size());
return queue;
@@ -1127,8 +1256,10 @@ public class BaseController {
BlockingQueue<AppComplexFeatureCfg> queue=new ArrayBlockingQueue<>(list.size());
ExecutorService service=Executors.newFixedThreadPool(Constants.MULITY_THREAD_SIZE);
List<Future<String>> futures=new ArrayList<>();
Properties props=this.getMsgProp();
for(int i=0;i<Constants.MULITY_THREAD_SIZE;i++) {
CheckAppFeatureComplexStringFormatThread t = new CheckAppFeatureComplexStringFormatThread(serviceDict,regionDict, this.getMsgProp(), list, queue);
CheckAppFeatureComplexStringFormatThread t=new CheckAppFeatureComplexStringFormatThread(serviceDict,regionDict, props, list, queue);
futures.add(service.submit(t));
}
service.shutdown();
@@ -1140,13 +1271,26 @@ public class BaseController {
e.printStackTrace();
}
}
boolean valideteError=false;
for(Future<String> future:futures) {
String msg = future.get();
if(StringUtils.isNotBlank(msg)) {
_msg.append(msg);
if(msg.equals("validate_error")) {
valideteError=true;
}else if(msg.endsWith("validate_error")) {
_msg.append(msg.substring(0, msg.length()-1-"validate_error".length()));
valideteError=true;
}else {
_msg.append(msg);
}
//throw new ServiceException(msg);
}
}
if(valideteError) {
_msg.append(props.getProperty("validate_error", "Unexpected error occurred while validating"));
}
long end=System.currentTimeMillis();
logger.warn("checkAppComplexFeatureStringCfgMulity finish,cost:"+(end-start)+",size:"+queue.size());
return queue;
@@ -1168,10 +1312,11 @@ public class BaseController {
BlockingQueue<AppTopicDomainCfg> queue=new ArrayBlockingQueue<>(list.size());
ExecutorService service=Executors.newFixedThreadPool(Constants.MULITY_THREAD_SIZE);
List<Future<String>> futures=new ArrayList<>();
for(int i=0;i<Constants.MULITY_THREAD_SIZE;i++) {
CheckTopicWebsiteFormatThread t=new CheckTopicWebsiteFormatThread(serviceDict,regionDict, this.getMsgProp(), list, queue);
futures.add(service.submit(t));
Properties props=this.getMsgProp();
for(int i=0;i<Constants.MULITY_THREAD_SIZE;i++) {
CheckTopicWebsiteFormatThread t=new CheckTopicWebsiteFormatThread(serviceDict,regionDict, props, list, queue);
futures.add(service.submit(t));
}
service.shutdown();
while(!service.isTerminated()) {
@@ -1182,13 +1327,26 @@ public class BaseController {
e.printStackTrace();
}
}
boolean valideteError=false;
for(Future<String> future:futures) {
String msg = future.get();
if(StringUtils.isNotBlank(msg)) {
if(msg.equals("validate_error")) {
valideteError=true;
}else if(msg.endsWith("validate_error")) {
_msg.append(msg.substring(0, msg.length()-1-"validate_error".length()));
valideteError=true;
}else {
_msg.append(msg);
}
//throw new ServiceException(msg);
_msg.append(msg);
}
}
if(valideteError) {
_msg.append(props.getProperty("validate_error", "Unexpected error occurred while validating"));
}
long end=System.currentTimeMillis();
logger.warn("checkTopicWebsiteCfgMulity finish,cost:"+(end-start)+",size:"+queue.size());
return queue;
@@ -1320,6 +1478,8 @@ public class BaseController {
*/
public void _import(HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes,
MultipartFile[] files, Integer serviceDictId, String regionDictIds, Integer requestId, String attribute, String classify) {
int isNullIndex=0;
int ipIndex=0;
logger.warn("import start...");
long start=System.currentTimeMillis();
ImportBigExcel ei=null;
@@ -1338,9 +1498,19 @@ public class BaseController {
List<Map<Long,AsnGroupInfo>> asnNoMaps=Lists.newArrayList();
Map<Long,AsnGroupInfo> newAsnNoMap=Maps.newConcurrentMap();
Map<Long,AsnGroupInfo> OldAsnNoMap=Maps.newConcurrentMap();
Map<Long,AsnGroupInfo> asnGroupInfos=null;
asnNoMaps.add(newAsnNoMap);
asnNoMaps.add(OldAsnNoMap);
Map<Long,AsnGroupInfo> allAsnNoMap=Maps.newConcurrentMap();
Map<Long,AsnGroupInfo> auditedAsnNoMap=Maps.newConcurrentMap();
Map<Long,String> orgGroupInfoMap=Maps.newConcurrentMap();
asnNoMaps.add(newAsnNoMap); //【0】 新的asn group info
asnNoMaps.add(OldAsnNoMap); //【1】 旧的asn group info
asnNoMaps.add(allAsnNoMap); //【2】 所有的asn group info
asnNoMaps.add(auditedAsnNoMap);//【3】 所有已审核通过的asn group info
List<Map<String,ConfigGroupInfo>> asnOrgList=Lists.newArrayList(); //组织信息
Map<String,ConfigGroupInfo> newOrgMap=Maps.newConcurrentMap();
Map<String,ConfigGroupInfo> oldOrgMap=Maps.newConcurrentMap();
asnOrgList.add(newOrgMap); //【0】 新的组织信息
asnOrgList.add(oldOrgMap);//【1】 旧的组织信息
Map<String,List<IpPortCfg>> asnIpMaps=Maps.newConcurrentMap();
FunctionRegionDict appRegion = null;
FunctionRegionDict appFeatureRegion = null;
if(serviceDict!=null) {
@@ -1377,69 +1547,74 @@ public class BaseController {
if (serviceDict!=null&&serviceDict.getAction().equals(64)) {
BlockingQueue<IpRateLimitTemplate> list = ei.getDataList(IpRateLimitTemplate.class
);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null,null, list);
} else if(serviceDict!=null&&serviceDict.getAction().equals(32)) {
BlockingQueue<IpAllNotDoLogTemplate> list = ei.getDataList(IpAllNotDoLogTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
} else {
BlockingQueue<IpAllTemplate> list = ei.getDataList(IpAllTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
}
} else if (regionDict.getFunctionId().equals(7)&&serviceDict!=null&&serviceDict.getAction().intValue()==16) {
BlockingQueue<DnsIpTemplate> list = ei.getDataList(DnsIpTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
}else if(regionDict.getFunctionId().equals(401)) {
BlockingQueue<DnsFakeIpTemplate> list = ei.getDataList(DnsFakeIpTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
}else if (regionDict.getFunctionId().equals(212)) {
BlockingQueue<IpPayloadTemplate> list = ei.getDataList(IpPayloadTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
} else if (regionDict.getFunctionId().equals(510)
&& "p2p_ip".equals(regionDict.getConfigServiceType())) { // P2p IP
BlockingQueue<P2pIpTemplate> list = ei.getDataList(P2pIpTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
} else if (regionDict.getFunctionId().equals(600)) {// ASN IP
ei.setHasImportLimit(false);
//加载asn缓存
//AsnCacheUtils.init(true);
//从数据库中读取
asnGroupInfos=asnGroupInfoService.getGroupList();
//OldAsnNoMap.putAll(asnGroupInfoService.getGroupList());
List<AsnGroupInfo> asnGroupInfoList=asnGroupInfoService.findAsnGroupInfos();
//初始化所有数据库中的asn信息
asnGroupInfoService.getGroupList(asnGroupInfoList,asnNoMaps);
//初始化所有数据库中的组织信息
Map<String,ConfigGroupInfo> oldOrgMapData=configGroupInfoService.getConfigGroupInfo(asnOrgList,4);
BlockingQueue<AsnIpTemplate> list = ei.getDataList(AsnIpTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, asnNoMaps,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, asnNoMaps,asnOrgList,asnIpMaps, list);
}else if (regionDict.getFunctionId().equals(301)) {// DDOS IP
BlockingQueue<DdosIpTemplate> list = ei.getDataList(DdosIpTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
}else if(regionDict.getFunctionId().equals(207)){// HTTP(s)阻断
BlockingQueue<HttpsRejectIpTemplate> list = ei.getDataList(HttpsRejectIpTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
}else if(regionDict.getFunctionId().equals(208)){// HTTP(s)重定向
BlockingQueue<HttpsRedirectIpTemplate> list = ei.getDataList(HttpsRedirectIpTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
}else if(regionDict.getFunctionId().equals(209)){// HTTP(s)替换
BlockingQueue<HttpsReplaceIpTemplate> list = ei.getDataList(HttpsReplaceIpTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
}else if(regionDict.getFunctionId().equals(211)){// HTTP(s)白名单
BlockingQueue<IpAllNotDoLogTemplate> list = ei.getDataList(IpAllNotDoLogTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
}else if(regionDict.getFunctionId().equals(200)) {// 拦截策略
if(serviceDict.getAction().equals(64)) {
BlockingQueue<IpRateLimitTemplate> list = ei.getDataList(IpRateLimitTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null,null, list);
}else {
BlockingQueue<IpAllNotDoLogTemplate> list = ei.getDataList(IpAllNotDoLogTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null,null, list);
}
}else if(regionDict.getFunctionId().equals(3)) { // IP白名单
BlockingQueue<IpWhitelistTemplate> list = ei.getDataList(IpWhitelistTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null,null, list);
}else if(regionDict.getFunctionId().equals(214)) { // IpSpoofing
BlockingQueue<IpSpoofingTemplate> list = ei.getDataList(IpSpoofingTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null,null, list);
}else if(regionDict.getFunctionId().equals(405) || regionDict.getFunctionId().equals(563) || regionDict.getFunctionId().equals(565)
|| regionDict.getFunctionId().equals(566)) { // APP Feature IP
BlockingQueue<IpAllNotDoLogTemplate> list = ei.getDataList(IpAllNotDoLogTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null,null, list);
}else {
BlockingQueue<IpAllTemplate> list = ei.getDataList(IpAllTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,asnGroupInfos, list);
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null,null, list);
}
} else if (regionDict.getRegionType().equals(2)) {// 字符串类
if (regionDict.getFunctionId().equals(510)
@@ -1502,6 +1677,9 @@ public class BaseController {
} else if(regionDict.getFunctionId().equals(563)){// APP Payload
BlockingQueue<AppPayloadTemplate> list = ei.getDataList(AppPayloadTemplate.class);
appComplexFeatureCfgs = this.checkAppComplexFeatureStringCfgMulity(errTip,serviceDict, regionDict, list);
} else if(regionDict.getFunctionId().equals(565) || regionDict.getFunctionId().equals(564) || regionDict.getFunctionId().equals(566)){// APP Feature StrPlus
BlockingQueue<ComplexStringAllNotDoLogTemplate> list = ei.getDataList(ComplexStringAllNotDoLogTemplate.class);
complexkeywordCfgs = this.checkComplexStringCfgMulity(errTip,serviceDict, regionDict, list);
} else {
BlockingQueue<ComplexStringAllTemplate> list = ei.getDataList(ComplexStringAllTemplate.class
);
@@ -1546,22 +1724,179 @@ public class BaseController {
}
if (regionDict.getRegionType().equals(1)) {// IP
if(regionDict.getFunctionId().intValue()==600) {//ans ip
List<SysDataDictionaryItem> isImportAll=DictUtils.getDictList("IS_ASN_IP_IMPORT_ALL");
//处理组,新的组会在这里保存
if(!asnNoMaps.get(0).isEmpty()) {
asnIpCfgService.processGroup(asnNoMaps.get(0));
//处理config_group_info和asn_group_info
asnIpCfgService.processGroup(serviceDict,asnNoMaps,asnOrgList,isSend,isImportAll.get(0).getItemCode());
if(!asnIpMaps.isEmpty()){
//未下发过的组织下asn ip信息
Map<Long,List<AsnIpCfg>> newAsnIpMap=Maps.newConcurrentMap();
int newAsnIpIndex=0;
//下发过的组织下asn ip信息
Map<Long,List<AsnIpCfg>> oldAsnIpMap=Maps.newConcurrentMap();
int oldAsnIpIndex=0;
int index=0;
List<AsnIpCfg> asnIpCfgs=Lists.newArrayList();
String asnIds="";
List<Integer> regionIds=Lists.newArrayList();
try {
regionIds = ConfigServiceUtil.getId(3,ipPortCfgs.size());
} catch (Exception e1) {
e1.printStackTrace();
logger.info("获取域ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e1.getMessage());
}
for (Entry<String, List<IpPortCfg>> e:asnIpMaps.entrySet()) {
for (BaseIpCfg cfg : e.getValue()) {
if(cfg != null){
AsnIpCfg asnIpCfg=new AsnIpCfg();
BeanUtils.copyProperties(cfg, asnIpCfg,new String[] {"cfgId"});
asnIpCfg.setTableName(AsnIpCfg.getTablename());
asnIpCfg.setAction(serviceDict==null?0:serviceDict.getAction());
asnIpCfg.setCfgRegionCode(regionDict.getConfigRegionCode());
asnIpCfg.setCfgType(regionDict.getConfigRegionValue());
asnIpCfg.setCreateTime(date);
asnIpCfg.setCreatorId(UserUtils.getUser().getId());
asnIpCfg.setDoLog(2);
asnIpCfg.setFunctionId(regionDict.getFunctionId());
if(isSend.equals("1")) {
asnIpCfg.setIsAudit(Constants.AUDIT_YES);
asnIpCfg.setIsValid(Constants.VALID_YES);
asnIpCfg.setAuditorId(UserUtils.getUser().getId());
asnIpCfg.setAuditTime(date);
}else {
asnIpCfg.setIsAudit(Constants.AUDIT_NOT_YET);
asnIpCfg.setIsValid(Constants.VALID_NO);
}
asnIpCfg.setIsAreaEffective(0);
asnIpCfg.setLable("0");
asnIpCfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
asnIpCfg.setAttribute(attribute);
asnIpCfg.setClassify(classify);
asnIpCfg.setServiceId(serviceDict==null?0:serviceDict.getServiceId());
asnIpCfg.setRegionId(regionIds.get(index));
//设置group id,compileId
asnIpCfg.setAsnIpGroup(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getGroupId());
asnIpCfg.setCompileId(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getCompileId());
if(isSend.equals("1")) {
//已下发
if(asnNoMaps.get(3).keySet().contains(Long.valueOf(asnIpCfg.getUserRegion1()))){
//groupId已经在了
if(oldAsnIpMap.keySet().contains(Long.valueOf(asnIpCfg.getAsnIpGroup()))){
oldAsnIpMap.get(Long.valueOf(asnIpCfg.getAsnIpGroup())).add(asnIpCfg);
oldAsnIpIndex++;
}else{
List list=new ArrayList<>();
list.add(asnIpCfg);
oldAsnIpMap.put(Long.valueOf(asnIpCfg.getAsnIpGroup()), list);
oldAsnIpIndex++;
}
}else{//未下发
//groupId已经在了
if(newAsnIpMap.keySet().contains(Long.valueOf(asnIpCfg.getAsnIpGroup()))){
newAsnIpMap.get(Long.valueOf(asnIpCfg.getAsnIpGroup())).add(asnIpCfg);
newAsnIpIndex++;
}else{
List list=new ArrayList<>();
list.add(asnIpCfg);
newAsnIpMap.put(Long.valueOf(asnIpCfg.getAsnIpGroup()), list);
newAsnIpIndex++;
}
}
}else{
asnIpCfgs.add(asnIpCfg);
}
index++;
if(!((","+asnIds).indexOf(","+e.getKey()+",")>-1)){
asnIds+=e.getKey()+",";
}
ipIndex++;
}else{
isNullIndex++;
}
}
//处理ASN IP时分组处理当处理完某一组的asnip量达到maat下发最大值时保存已处理的asn ipisSend=1并下发
if(isSend.equals("1")) {
//未下发过的asnGroup
if(!newAsnIpMap.isEmpty() && newAsnIpIndex >= Constants.MAAT_JSON_SEND_SIZE){
if(!StringUtil.isEmpty(asnIpCfgs) && !StringUtil.isEmpty(asnIds)){
asnIds=asnIds.substring(0,asnIds.length()-1);
asnIpCfgService.saveAsnIp(asnIpCfgs,asnIds,isImportAll.get(0).getItemCode());
asnIds="";
asnIpCfgs.clear();
}
asnIpCfgService.auditAsnIp(newAsnIpMap,asnNoMaps,"maat",newAsnIpIndex);
newAsnIpMap.clear();
newAsnIpIndex=0;
}
//已下发过的asnGroup
if(!oldAsnIpMap.isEmpty() && oldAsnIpIndex >= Constants.MAAT_JSON_SEND_SIZE){
if(!StringUtil.isEmpty(asnIpCfgs) && !StringUtil.isEmpty(asnIds)){
asnIds=asnIds.substring(0,asnIds.length()-1);
asnIpCfgService.saveAsnIp(asnIpCfgs,asnIds,isImportAll.get(0).getItemCode());
asnIds="";
asnIpCfgs.clear();
}
asnIpCfgService.auditAsnIp(oldAsnIpMap,asnNoMaps,"common",oldAsnIpIndex);
oldAsnIpMap.clear();
oldAsnIpIndex=0;
}
}else {
if(!StringUtil.isEmpty(asnIpCfgs) && asnIpCfgs.size()>Constants.MAAT_JSON_SEND_SIZE ){
if(!StringUtil.isEmpty(asnIds)){
asnIds=asnIds.substring(0,asnIds.length()-1);
asnIpCfgService.saveAsnIp(asnIpCfgs,asnIds,isImportAll.get(0).getItemCode());
asnIds="";
asnIpCfgs.clear();
}
}
}
}
//处理ASN IP时最后一批未达到maat提交总量时也需要保存。
if(!StringUtil.isEmpty(asnIpCfgs) && !StringUtil.isEmpty(asnIds)){
asnIds=asnIds.substring(0,asnIds.length()-1);
asnIpCfgService.saveAsnIp(asnIpCfgs,asnIds,isImportAll.get(0).getItemCode());
asnIds="";
asnIpCfgs.clear();
}
if(isSend.equals("1")) {
//未下发过的asnGroup
if(!newAsnIpMap.isEmpty() ){
asnIpCfgService.auditAsnIp(newAsnIpMap,asnNoMaps,"maat",newAsnIpIndex);
newAsnIpMap.clear();
newAsnIpIndex=0;
}
//已下发过的asnGroup
if(!oldAsnIpMap.isEmpty() ){
asnIpCfgService.auditAsnIp(oldAsnIpMap,asnNoMaps,"common",oldAsnIpIndex);
oldAsnIpMap.clear();
oldAsnIpIndex=0;
}
}
}
//全量下发删除asnNo对应的已有的IP
if(isImportAll.get(0).getItemCode().equals("1")) {
logger.warn("Delete and send ip reuse regions start");
long _start=System.currentTimeMillis();
deleteIps(asnNoMaps.get(1));
long _end=System.currentTimeMillis();
logger.warn("Delete and send ip reuse regions end,cost:"+(_end-_start));
//是否全量下发所有的asn info信息
/*
//每次批量之后需要更新已下发的组
if(isImportAll.get(0).getItemCode().equals("1")){
asnNoMaps.get(3).clear();
}
List<AsnIpCfg> asnIpCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
//处理asn ip
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
List<AsnIpCfg> asnIpCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
int index=0;
//未下发过的组织下asn ip信息
Map<Long,List<AsnIpCfg>> newAsnIpMap=Maps.newConcurrentMap();
int newAsnIpIndex=0;
//下发过的组织下asn ip信息
Map<Long,List<AsnIpCfg>> oldAsnIpMap=Maps.newConcurrentMap();
int oldAsnIpIndex=0;
while(!ipPortCfgs.isEmpty()) {
ipPortCfgs.drainTo(_ipPortCfgs, Constants.MAAT_JSON_SEND_SIZE);
List<Integer> regionIds=Lists.newArrayList();
@@ -1572,63 +1907,110 @@ public class BaseController {
logger.info("获取域ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
int ind=0;
index=0;
for (BaseIpCfg cfg : _ipPortCfgs) {
AsnIpCfg _cfg=new AsnIpCfg();
BeanUtils.copyProperties(cfg, _cfg,new String[] {"cfgId"});
_cfg.setTableName(AsnIpCfg.getTablename());
_cfg.setAction(serviceDict==null?0:serviceDict.getAction());
_cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
_cfg.setCfgType(regionDict.getConfigRegionValue());
_cfg.setCreateTime(date);
_cfg.setCreatorId(UserUtils.getUser().getId());
_cfg.setDoLog(2);
_cfg.setFunctionId(regionDict.getFunctionId());
AsnIpCfg asnIpCfg=new AsnIpCfg();
BeanUtils.copyProperties(cfg, asnIpCfg,new String[] {"cfgId"});
asnIpCfg.setTableName(AsnIpCfg.getTablename());
asnIpCfg.setAction(serviceDict==null?0:serviceDict.getAction());
asnIpCfg.setCfgRegionCode(regionDict.getConfigRegionCode());
asnIpCfg.setCfgType(regionDict.getConfigRegionValue());
asnIpCfg.setCreateTime(date);
asnIpCfg.setCreatorId(UserUtils.getUser().getId());
asnIpCfg.setDoLog(2);
asnIpCfg.setFunctionId(regionDict.getFunctionId());
if(isSend.equals("1")) {
_cfg.setIsAudit(Constants.AUDIT_YES);
_cfg.setIsValid(Constants.VALID_YES);
_cfg.setAuditorId(UserUtils.getUser().getId());
_cfg.setAuditTime(date);
asnIpCfg.setIsAudit(Constants.AUDIT_YES);
asnIpCfg.setIsValid(Constants.VALID_YES);
asnIpCfg.setAuditorId(UserUtils.getUser().getId());
asnIpCfg.setAuditTime(date);
}else {
_cfg.setIsAudit(Constants.AUDIT_NOT_YET);
_cfg.setIsValid(Constants.VALID_NO);
}
_cfg.setIsAreaEffective(0);
_cfg.setLable("0");
_cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
_cfg.setAttribute(attribute);
_cfg.setClassify(classify);
// _cfg.setServiceId(0);
_cfg.setServiceId(serviceDict==null?0:serviceDict.getServiceId());
//设置region id
if(regionIds!=null&&regionIds.size()==_ipPortCfgs.size()) {
_cfg.setRegionId(regionIds.get(ind));
asnIpCfg.setIsAudit(Constants.AUDIT_NOT_YET);
asnIpCfg.setIsValid(Constants.VALID_NO);
}
asnIpCfg.setIsAreaEffective(0);
asnIpCfg.setLable("0");
asnIpCfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
asnIpCfg.setAttribute(attribute);
asnIpCfg.setClassify(classify);
asnIpCfg.setServiceId(serviceDict==null?0:serviceDict.getServiceId());
asnIpCfg.setRegionId(regionIds.get(index));
//设置group id,compileId
if(asnNoMaps.get(0).containsKey(Long.parseLong(_cfg.getUserRegion1()))) {
_cfg.setAsnIpGroup(asnNoMaps.get(0).get(Long.parseLong(_cfg.getUserRegion1())).getGroupId());
_cfg.setCompileId(asnNoMaps.get(0).get(Long.parseLong(_cfg.getUserRegion1())).getCompileId());
}else if(asnNoMaps.get(1).containsKey(Long.parseLong(_cfg.getUserRegion1()))) {
_cfg.setAsnIpGroup(asnNoMaps.get(1).get(Long.parseLong(_cfg.getUserRegion1())).getGroupId());
_cfg.setCompileId(asnNoMaps.get(1).get(Long.parseLong(_cfg.getUserRegion1())).getCompileId());
}else {
//AsnGroupInfo info=AsnCacheUtils.get(Long.parseLong(_cfg.getUserRegion1()));
AsnGroupInfo info=asnGroupInfos.get(Long.parseLong(_cfg.getUserRegion1()));
if(info!=null) {
_cfg.setAsnIpGroup(info.getGroupId());
_cfg.setCompileId(info.getCompileId());
asnIpCfg.setAsnIpGroup(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getGroupId());
asnIpCfg.setCompileId(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getCompileId());
if(isSend.equals("1")) {
//已下发
if(asnNoMaps.get(3).keySet().contains(Long.valueOf(asnIpCfg.getUserRegion1()))){
//groupId已经在了
if(oldAsnIpMap.keySet().contains(Long.valueOf(asnIpCfg.getAsnIpGroup()))){
oldAsnIpMap.get(Long.valueOf(asnIpCfg.getAsnIpGroup())).add(asnIpCfg);
oldAsnIpIndex++;
}else{
List list=new ArrayList<>();
list.add(asnIpCfg);
oldAsnIpMap.put(Long.valueOf(asnIpCfg.getAsnIpGroup()), list);
oldAsnIpIndex++;
}
}else{//未下发
//groupId已经在了
if(newAsnIpMap.keySet().contains(Long.valueOf(asnIpCfg.getAsnIpGroup()))){
newAsnIpMap.get(Long.valueOf(asnIpCfg.getAsnIpGroup())).add(asnIpCfg);
newAsnIpIndex++;
}else{
List list=new ArrayList<>();
list.add(asnIpCfg);
newAsnIpMap.put(Long.valueOf(asnIpCfg.getAsnIpGroup()), list);
newAsnIpIndex++;
}
}
*//**********************新的asn ip达到最大量后发送一次***********************//*
//未下发过的asnGroup
if(newAsnIpIndex==Constants.MAAT_JSON_SEND_SIZE){
asnIpCfgService.auditAsnIp(newAsnIpMap,asnNoMaps,"maat",newAsnIpIndex);
newAsnIpMap.clear();
newAsnIpIndex=0;
}
*//**********************新的asn ip达到最大量后发送一次***********************//*
//已下发过的asnGroup
if(oldAsnIpIndex==Constants.MAAT_JSON_SEND_SIZE){
asnIpCfgService.auditAsnIp(oldAsnIpMap,asnNoMaps,"common",oldAsnIpIndex);
oldAsnIpMap.clear();
oldAsnIpIndex=0;
}
}else{
asnIpCfgs.add(asnIpCfg);
}
asnIpCfgs.add(_cfg);
ind++;
//仅仅需要保存的数
if(asnIpCfgs.size()==Constants.MAAT_JSON_SEND_SIZE){
asnIpCfgService.saveAsnIp(asnIpCfgs);
asnIpCfgs.clear();
}
index++;
}
if(isSend.equals("1")) {
//未下发过的asnGroup
if(!newAsnIpMap.isEmpty()){
asnIpCfgService.auditAsnIp(newAsnIpMap,asnNoMaps,"maat",newAsnIpIndex);
newAsnIpMap.clear();
newAsnIpIndex=0;
}
//已下发过的asnGroup
if(!oldAsnIpMap.isEmpty()){
asnIpCfgService.auditAsnIp(oldAsnIpMap,asnNoMaps,"common",oldAsnIpIndex);
oldAsnIpMap.clear();
oldAsnIpIndex=0;
}
}
//仅仅需要保存的数
if(!StringUtil.isEmpty(asnIpCfgs)){
asnIpCfgService.saveAsnIp(asnIpCfgs);
asnIpCfgs.clear();
}
ipCfgService.saveAndSend(regionDict, serviceDict, specificServiceCfg, asnIpCfgs, cfgIndexInfos, appPolicyCfgs,appFeatureIndexs,asnNoMaps,isSend.equals("1"));
cfgIndexInfos.clear();
appPolicyCfgs.clear();
_ipPortCfgs.clear();
asnIpCfgs.clear();
}
}*/
}else if(regionDict.getFunctionId().intValue()==214) { // IpSpoofing
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
while(!ipPortCfgs.isEmpty()) {
@@ -2376,7 +2758,10 @@ public class BaseController {
ei.loadInitParams(IpWhitelistTemplate.class, msgProp, regionDict, serviceDict);
} else if(regionDict.getFunctionId().equals(214)) { // IpSpoofing
ei.loadInitParams(IpSpoofingTemplate.class, msgProp, regionDict, serviceDict);
} else {
} else if(regionDict.getFunctionId().equals(405) || regionDict.getFunctionId().equals(563) || regionDict.getFunctionId().equals(565)
|| regionDict.getFunctionId().equals(566)) { // APP Feature IP
ei.loadInitParams(IpAllNotDoLogTemplate.class, msgProp, regionDict, serviceDict);
} else {
ei.loadInitParams(IpAllTemplate.class, msgProp, regionDict, serviceDict);
}
} else if (regionDict.getRegionType().equals(2)) {// 字符串类
@@ -2420,6 +2805,8 @@ public class BaseController {
ei.loadInitParams(ComplexStringAllNotDoLogTemplate.class, this.getMsgProp(), regionDict, serviceDict);
}else if(regionDict.getFunctionId().equals(563)) {// APP Payload
ei.loadInitParams(AppPayloadTemplate.class, this.getMsgProp(), regionDict, serviceDict);
}else if(regionDict.getFunctionId().equals(565) || regionDict.getFunctionId().equals(564) || regionDict.getFunctionId().equals(566)){// APP Feature StrPlus
ei.loadInitParams(ComplexStringAllNotDoLogTemplate.class, this.getMsgProp(), regionDict, serviceDict);
} else {
ei.loadInitParams(ComplexStringAllTemplate.class, msgProp, regionDict, serviceDict);
}
@@ -3395,7 +3782,7 @@ public class BaseController {
List<NtcPzReport> list=null;
try {
//调用带有超时时间的方法设置与页面ajax获取total log 超时时间保持一致 页面设置在pzlog.js
String json=ConfigServiceUtil.getReport(Constants.BUSINESSTYPE_CONFIG, compileIds, serviceIds, startDate==null?null:sdf.format(startDate), endDate==null?null:sdf.format(endDate),Constants.CLIENT_CONNECT_TIMEOUT,10000);
String json=ConfigServiceUtil.getReport(Constants.BUSINESSTYPE_CONFIG, compileIds, serviceIds, startDate==null?null:sdf.format(startDate), endDate==null?null:sdf.format(endDate),Constants.CLIENT_CONNECT_TIMEOUT,30000);
list=getList(json);
} catch (Exception e) {
logger.error("获取日志总量失败!",e);

View File

@@ -1,14 +1,22 @@
package com.nis.web.controller;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.nis.domain.SysMenu;
import com.nis.util.StringUtil;
@@ -100,6 +108,29 @@ public class SystemController extends BaseController{
model.addAttribute("menuList",newList);
return "/help";
}
@RequestMapping("saveHelp")
@ResponseBody
public boolean saveHelp(HttpServletRequest request, HttpServletResponse response,ModelMap model,@RequestParam(required=true,value="editedHelpInfo")String editedHelpInfo,@RequestParam(required=true,value="helpHrefVal")String helpHrefVal){
try {
StringBuffer helpInfo=new StringBuffer();
helpInfo.append(URLDecoder.decode(editedHelpInfo,"utf-8"));
String htmlName=URLDecoder.decode(helpHrefVal,"utf-8");
String htmlPath=request.getServletContext().getRealPath("/")+htmlName;
File file=new File(htmlPath);
OutputStream out=new FileOutputStream(file);
out.write(helpInfo.toString().getBytes());
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
}

View File

@@ -22,7 +22,9 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.Page;
import com.nis.domain.basics.AsnGroupInfo;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.configuration.AsnKeywordCfg;
import com.nis.domain.specific.ConfigGroupInfo;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseController;
/**
@@ -83,8 +85,13 @@ public class AsnGroupController extends BaseController {
asnGroupInfoService.saveOrUpdate(cfg);
addMessage(redirectAttributes,"success","save_success");
} catch (Exception e) {
logger.error("新增失败",e);
addMessage(redirectAttributes,"error","save_failed");
e.printStackTrace();
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error", "request_service_failed");
}else {
addMessage(redirectAttributes,"error","save_failed");
}
}
return "redirect:" + adminPath + "/basics/asnGroup/asnGroupList";
@@ -99,15 +106,19 @@ public class AsnGroupController extends BaseController {
*/
//@RequiresPermissions(value={"basics:classification:del","basics:attribute:del","basics:label:del"},logical=Logical.OR)
@RequestMapping(value={"delete"})
public String delete(RedirectAttributes redirectAttributes,String ids,String asnIds) {
public String delete(RedirectAttributes redirectAttributes,String ids,String asnIds,String groupIds) {
try {
asnGroupInfoService.delete(ids,asnIds);
asnGroupInfoService.delete(ids,asnIds,groupIds);
//TODO 查询本次删除的所有asnOrg组中是否存在asn 没有is_used=0的asn如果存在则需要将整个组删除
addMessage(redirectAttributes,"success","delete_success");
} catch (Exception e) {
logger.error("删除失败",e);
addMessage(redirectAttributes,"error","delete_failed");
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error", "request_service_failed");
}else {
addMessage(redirectAttributes,"error","delete_failed");
}
}
return "redirect:" + adminPath + "/basics/asnGroup/asnGroupList";
}
@@ -162,14 +173,16 @@ public class AsnGroupController extends BaseController {
*/
@ResponseBody
@RequestMapping(value = {"/checkAsnNo"})
public boolean checkIp(AsnGroupInfo cfg, HttpServletRequest request, HttpServletResponse response){
AsnGroupInfo policyGroup = asnGroupInfoService.getInfoByAsnNo(cfg);
if(policyGroup == null){
return true;
public AsnGroupInfo checkAsnNo(AsnGroupInfo cfg, HttpServletRequest request, HttpServletResponse response){
AsnGroupInfo policyGroup=null;
policyGroup = asnGroupInfoService.getInfoByAsnNo(cfg);
if(policyGroup != null){
ConfigGroupInfo group=configGroupInfoService.getAsnOrganization(policyGroup.getOrganization());
if(group != null){
policyGroup.setCommonGroupIds(group.getGroupId().toString());
}
}
return false;
return policyGroup;
}
/**
* 校验asn号是否已存在
@@ -182,7 +195,6 @@ public class AsnGroupController extends BaseController {
if(asnIpCfg == null){
return false;
}
return true;
}
/**
@@ -219,4 +231,64 @@ public class AsnGroupController extends BaseController {
}
return orgaList;
}
/**
* 校验是否有配置的ASN域已被删除
* @param model
* @return
*/
@RequestMapping(value="checkAsnRegionIsDeleted")
@ResponseBody
public Map<Integer,String> checkAsnRegionIsDeleted(@RequestParam(required=true,value="compileIds")String compileIds,Model model){
Map<Integer,String> resultMap=new HashMap<>();
try {
if(!StringUtil.isEmpty(compileIds)){
compileIds=compileIds.substring(0,compileIds.length()-1);
Map<Integer, List<String>> compileWithGroupMap=new HashMap<>();
Map<String, String> groupIdWithAsn=new HashMap<>();
//先查询此compileId下是否有is_valid=0和is_audit=0的asn_keyword_cfgs
List<AsnKeywordCfg> asnList=asnGroupInfoService.findAsnKeywordCfgByCompileId(compileIds);
String groupIds="";
for (AsnKeywordCfg asnKeywordCfg : asnList) {
//根据asnKeyword的userRegion2[asn group Id]
groupIds+=asnKeywordCfg.getUserRegion2()+",";
if(compileWithGroupMap.keySet().contains(asnKeywordCfg.getCompileId())){
List<String> groupList=compileWithGroupMap.get(asnKeywordCfg.getCompileId());
groupList.add(asnKeywordCfg.getUserRegion2());
compileWithGroupMap.put(asnKeywordCfg.getCompileId(), groupList);
}else{
List<String> groupList=new ArrayList<>();
groupList.add(asnKeywordCfg.getUserRegion2());
compileWithGroupMap.put(asnKeywordCfg.getCompileId(), groupList);
}
groupIdWithAsn.put(asnKeywordCfg.getUserRegion2(), asnKeywordCfg.getCfgKeywords());
}
if(!StringUtil.isEmpty(groupIds)){
Properties prop=this.getMsgProp();
groupIds=groupIds.substring(0,groupIds.length()-1);
List<String> groupIdList=asnGroupInfoService.findAsnGroupIdByGroupIds(groupIds);
for (Integer compileId : compileWithGroupMap.keySet()) {
for (String groupIdOld : compileWithGroupMap.get(compileId)) {
if(!groupIdList.contains(groupIdOld)){
String tip=prop.getProperty("deletedAsnTip").replace("asnId", groupIdWithAsn.get(groupIdOld));
tip=tip.replace("cfgId", compileId+"");
resultMap.put(compileId, tip);
}
}
}
}
}
} catch (Exception e) {
logger.error("校验编译下的asn是否被删除失败",e);
return resultMap;
}
/*List<AsnGroupInfo> orgaList=new ArrayList<>();
try {
orgaList=asnGroupInfoService.findAsnGroupList(asnGroup);
} catch (Exception e) {
logger.error("异步获取ASN NO信息失败",e);
return orgaList;
}*/
return resultMap;
}
}

View File

@@ -0,0 +1,194 @@
package com.nis.web.controller.basics;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jersey.repackaged.com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Maps;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.basics.AsnGroupInfo;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.DnsKeywordCfg;
import com.nis.exceptions.MaatConvertException;
//import com.nis.util.AsnCacheUtils;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping(value = "${adminPath}/basics/dns/keyword")
public class DnsKeywordController extends BaseController{
@RequestMapping(value = {"/list"})
public String list(Model model,HttpServletRequest request
,HttpServletResponse response,@ModelAttribute("cfg")DnsKeywordCfg entity
){
Page<DnsKeywordCfg> page = dnsKeywordCfgService.findPage(new Page<DnsKeywordCfg>(request, response,"r"), entity);
model.addAttribute("page", page);
initPageCondition(model, entity);
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
model.addAttribute("regionList", regionList);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId());
model.addAttribute("serviceList", serviceList);
return "/basics/dnsKeywordCfgList";
}
@RequestMapping(value = {"/addForm"})
public String addForm(Model model,HttpServletRequest request
,HttpServletResponse response,@ModelAttribute("cfg")CfgIndexInfo cfg
,RedirectAttributes redirectAttributes){
cfg.setGroupType(12);
initFormCondition(model,cfg);
model.addAttribute("_cfg", cfg);
return "/basics/dnsKeywordCfgFormAdd";
}
@RequestMapping(value = {"/updateForm"})
public String updateForm(Model model,HttpServletRequest request
,HttpServletResponse response,String ids,@ModelAttribute("cfg")DnsKeywordCfg cfg
,RedirectAttributes redirectAttributes){
cfg = dnsKeywordCfgService.get(Long.parseLong(ids));
cfg.setGroupType(12);
initFormCondition(model, cfg);
//List<ConfigGroupInfo> groupInfos=configGroupInfoService.findAllList(4);
//model.addAttribute("policyGroups", groupInfos);
model.addAttribute("cfg", cfg);
return "/basics/dnsKeywordCfgFormUpdate";
}
@RequestMapping(value = {"/save"})
@RequiresPermissions(value={"dns:keyword:config"})
public String save(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")CfgIndexInfo cfg,RedirectAttributes redirectAttributes){
try{
dnsKeywordCfgService.saveDnsKeywordCfg(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
e.printStackTrace();
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","save_failed");
}
}
return "redirect:" + adminPath +"/basics/dns/keyword/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/update"})
@RequiresPermissions(value={"dns:keyword:config"})
public String update(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")DnsKeywordCfg cfg,RedirectAttributes redirectAttributes){
try{
dnsKeywordCfgService.update(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
e.printStackTrace();
addMessage(redirectAttributes,"error","save_failed");
}
return "redirect:" + adminPath +"/basics/dns/keyword/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/audit"})
@RequiresPermissions(value={"dns:keyword:config"})
public String audit(Model model,@ModelAttribute("cfg")DnsKeywordCfg cfg
,Integer isAudit
,Integer isValid
,String ids
,Integer functionId
, HttpServletRequest request
,HttpServletResponse response
,RedirectAttributes redirectAttributes) {
//选中配置审核
/*if(!StringUtil.isEmpty(ids)) {
List<DnsKeywordCfg> infoList=dnsKeywordCfgService.getByIds(ids);
Map<Long,List<DnsKeywordCfg>> dnsKeywordMap=Maps.newHashMap();
for(DnsKeywordCfg entity:infoList) {
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(new Date());
entity.setFunctionId(functionId);
if(dnsKeywordMap.containsKey(Long.parseLong(entity.getUserRegion1()))) {
dnsKeywordMap.get(Long.parseLong(entity.getUserRegion1())).add(entity);
}else {
List<DnsKeywordCfg> keywords=Lists.newArrayList();
keywords.add(entity);
dnsKeywordMap.put(Long.parseLong(entity.getUserRegion1()), keywords);
}
}
*//********************每次下发一个组的region保证事物********************//*
for (Long groupId : dnsKeywordMap.keySet()) {
try {
dnsKeywordCfgService.auditDnsKeywordBatch(dnsKeywordMap.get(groupId),groupId,isValid);
} catch (Exception e) {
logger.error("配置下发失败:",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error", "request_service_failed");
}else {
addMessage(redirectAttributes,"error", "audit_failed");
}
}
}
}else {
//条件下所有配置审核
Page<AsnIpCfg> searchPage=new Page<AsnIpCfg>(request,response,"a");
Page<AsnIpCfg> auditPage=new Page<AsnIpCfg>(request,response,"a");
BeanUtils.copyProperties(searchPage, auditPage);
try {
auditAll(auditPage,isValid , cfg);
addMessage(redirectAttributes,"success", "audit_success");
} catch (Exception e) {
logger.error("配置下发失败:",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error", "request_service_failed");
}else {
addMessage(redirectAttributes,"error", "audit_failed");
}
}
return list(model, request, response, cfg);
}*/
return "redirect:" + adminPath +"/basics/dns/keyword/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/delete"})
@RequiresPermissions(value={"dns:keyword:config"})
public String delete(Integer isValid
,String ids,Integer functionId
,RedirectAttributes redirectAttributes){
try{
dnsKeywordCfgService.delete(ids);
addMessage(redirectAttributes,"success","delete_success");
}catch(Exception e){
logger.error("Delete failed",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","delete_failed");
}
}
return "redirect:" + adminPath +"/basics/dns/keyword/list?functionId="+functionId;
}
}

View File

@@ -24,6 +24,7 @@ import com.google.common.collect.Maps;
import com.nis.domain.Page;
import com.nis.domain.SysUser;
import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.configuration.UserManage;
import com.nis.util.ConfigDictUtils;
import com.nis.util.Configurations;
import com.nis.util.Constants;
@@ -232,8 +233,36 @@ public class ServiceDictInfoController extends BaseController {
@RequestMapping(value={"delete"})
public String delete(ServiceDictInfo serviceDictInfo, RedirectAttributes redirectAttributes, String itType, String mulitId) {
try {
serviceDictInfoService.deleteDict(mulitId);
addMessage(redirectAttributes,"success", "delete_success");
String exIp="";
String id="";
Properties msgProp = getMsgProp();
if(itType.equals("5")){
String [] ids=mulitId.split(",");
for (int i = 0; i < ids.length; i++) {
ServiceDictInfo dict= serviceDictInfoService.getDictById(Integer.valueOf(ids[i]));
if(dict!=null){
UserManage user =new UserManage();
user.setServerIp(dict.getItemValue()+",");
List<UserManage> list=userManageService.findList(user);
if(list!=null && list.size()>0){
exIp+=dict.getItemValue()+"";
}else{
id+=ids[i]+",";
}
}
}
}else{
id=mulitId;
}
if(!StringUtil.isEmpty(id)){
serviceDictInfoService.deleteDict(id);
}
if(!StringUtil.isEmpty(exIp)){
exIp=exIp.substring(0, exIp.length()-1);
addMessage(redirectAttributes,"error", "IP "+exIp+" "+msgProp.getProperty("user_check"));
}else{
addMessage(redirectAttributes,"success", "delete_success");
}
} catch (Exception e) {
e.printStackTrace();
addMessage(redirectAttributes,"error", "delete_failed");
@@ -593,4 +622,17 @@ public class ServiceDictInfoController extends BaseController {
return dicName;
}
@ResponseBody
@RequestMapping(value = "ajaxIpRepeat")
public boolean ajaxIpRepeat(String oldIp, String ip,Integer type) {
if (ip !=null && ip.equals(oldIp)) {
return true;
} else if (ip !=null && serviceDictInfoService.getByItemValue(ip,type) == null) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,261 @@
package com.nis.web.controller.basics;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Maps;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.basics.UrlCommGroupCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
import com.nis.web.service.basics.UrlCommGroupService;
import jersey.repackaged.com.google.common.collect.Lists;
@Controller
@RequestMapping(value = "${adminPath}/basics/url")
public class UrlCommGroupController extends BaseController{
@Autowired
private UrlCommGroupService urlCommGroupService;
@RequestMapping(value = {"/list"})
public String list(Model model,HttpServletRequest request
,HttpServletResponse response,@ModelAttribute("cfg")UrlCommGroupCfg entity
){
Page<UrlCommGroupCfg> page = urlCommGroupService.findPage(new Page<UrlCommGroupCfg>(request, response,"r"), entity);
model.addAttribute("page", page);
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
model.addAttribute("regionList", regionList);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId());
model.addAttribute("serviceList", serviceList);
return "/basics/urlCommGroupList";
}
@RequestMapping(value = {"/addForm"})
public String addForm(Model model,HttpServletRequest request
,HttpServletResponse response,@ModelAttribute("cfg")CfgIndexInfo cfg
,RedirectAttributes redirectAttributes){
// UrlCommGroupCfg urlCfg = new UrlCommGroupCfg();
// urlCfg.setCfgType("NTC_URL_REGION");
// cfg.setUrlCommGroupCfg(urlCfg);
// List<UrlCommGroupCfg> urlList = new ArrayList<UrlCommGroupCfg>();
// urlList.add(urlCfg);
// cfg.setUrlCommGroupList(urlList);
// initFormCondition(model, entity);
cfg.setGroupType(11);
initFormCondition(model,cfg);
//List<ConfigGroupInfo> groupInfos=configGroupInfoService.findAllList(4);
//model.addAttribute("policyGroups", groupInfos);
model.addAttribute("_cfg", cfg);
return "/basics/urlCommGroupFormAdd";
}
@RequestMapping(value = {"/save"})
@RequiresPermissions(value={"http:url:config"})
public String save(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")CfgIndexInfo cfg,RedirectAttributes redirectAttributes){
// System.out.println("URL分组");
try{
urlCommGroupService.saveUrlCommGroupCfg(cfg);
}catch(Exception e){
logger.error("信息保存失败",e);
e.printStackTrace();
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","save_failed");
}
}
return "redirect:" + adminPath +"/basics/url/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/updateForm"})
public String updateForm(Model model,HttpServletRequest request
,HttpServletResponse response,String ids,@ModelAttribute("cfg")UrlCommGroupCfg cfg
,RedirectAttributes redirectAttributes){
cfg = urlCommGroupService.get(Long.parseLong(ids));
// initUpdateFormCondition(model, cfg);
cfg.setGroupType(11);
initUpdateFormCondition(model,cfg);
//List<ConfigGroupInfo> groupInfos=configGroupInfoService.findAllList(4);
//model.addAttribute("policyGroups", groupInfos);
model.addAttribute("_cfg", cfg);
return "/basics/urlCommGroupFormUpdate";
}
@RequestMapping(value = {"/update"})
@RequiresPermissions(value={"http:url:config"})
public String update(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")UrlCommGroupCfg cfg,RedirectAttributes redirectAttributes){
try{
urlCommGroupService.update(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
e.printStackTrace();
addMessage(redirectAttributes,"error","save_failed");
}
return "redirect:" + adminPath +"/basics/url/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/audit"})
@RequiresPermissions(value={"http:url:config"})
public String audit(Model model,@ModelAttribute("cfg")UrlCommGroupCfg cfg
,Integer isAudit
,Integer isValid
,String ids
,Integer functionId
, HttpServletRequest request
,HttpServletResponse response
,RedirectAttributes redirectAttributes) {
//选中配置审核
if(!StringUtil.isEmpty(ids)) {
List<UrlCommGroupCfg> urlGroupCfgs=urlCommGroupService.getByIds(ids);
// Map<Long,List<UrlCommGroupCfg>> urlcfgMap=Maps.newHashMap();
// for(UrlCommGroupCfg urlCommCfg:urlGroupCfgs) {
// urlCommCfg.setIsAudit(isAudit);
// urlCommCfg.setIsValid(isValid);
// urlCommCfg.setAuditorId(UserUtils.getUser().getId());
// urlCommCfg.setAuditTime(new Date());
// urlCommCfg.setFunctionId(functionId);
// if(urlcfgMap.containsKey(Long.parseLong(urlCommCfg.getUserRegion3()))) {
// urlcfgMap.get(Long.parseLong(urlCommCfg.getUserRegion3())).add(urlCommCfg);
// }else {
// List<UrlCommGroupCfg> _urlCfgs=Lists.newArrayList();
// _urlCfgs.add(urlCommCfg);
// urlcfgMap.put(Long.parseLong(urlCommCfg.getUserRegion3()), _urlCfgs);
// }
// }
/********************每次下发一个组的region保证事物********************/
// for (Long groupId : urlcfgMap.keySet()) {
// try {
// urlCommGroupService.audit(urlcfgMap.get(groupId),groupId,isValid);
// } catch (Exception e) {
// logger.error("配置下发失败:",e);
// if(e instanceof MaatConvertException) {
// addMessage(redirectAttributes,"error", "request_service_failed");
// }else {
// addMessage(redirectAttributes,"error", "audit_failed");
// }
//
// }
// }
for (UrlCommGroupCfg urlCommGroup : urlGroupCfgs) {
try {
urlCommGroupService.audit(urlCommGroup,isAudit,isValid);
} catch (Exception e) {
logger.error("审核失败",e);
e.printStackTrace();
addMessage(redirectAttributes,"error","audit_failed");
}
}
}
return "redirect:" + adminPath +"/basics/url/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/delete"})
@RequiresPermissions(value={"http:url:config"})
public String delete(Integer isValid
,String ids,Integer functionId
,RedirectAttributes redirectAttributes){
try{
urlCommGroupService.delete(ids);
addMessage(redirectAttributes,"success","delete_success");
}catch(Exception e){
logger.error("Delete failed",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","delete_failed");
}
}
return "redirect:" + adminPath +"/basics/url/list?functionId="+functionId;
}
//urlComm配置导出
@RequestMapping(value = "/exportUrlComm")
public void exportAsnIp(Model model,HttpServletRequest request,HttpServletResponse response,
@ModelAttribute("cfg")UrlCommGroupCfg entity,String ids,RedirectAttributes redirectAttributes){
try {
//export data info
List<String> titleList=new ArrayList<String>();
Map<String, Class<?>> classMap=new HashMap<String, Class<?>>();
Map<String, List> dataMap=new HashMap<String, List>();
Map<String, String> noExportMap=new HashMap<String, String>();
List<UrlCommGroupCfg> list = new ArrayList<UrlCommGroupCfg>();
if (!StringUtil.isEmpty(ids)) {
list = urlCommGroupService.findByPage(ids);
} else {
Page<UrlCommGroupCfg> pageInfo=new Page<UrlCommGroupCfg>(request, response,"r");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<UrlCommGroupCfg> page = urlCommGroupService.findPage(pageInfo, entity);
list=page.getList();
}
//
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), UrlCommGroupCfg.class);
String cfgIndexInfoNoExport=",block_type,do_log,action"
+ ",letter,whether_area_block,classification,attribute,label,expression_type,match_method"
+",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,asn_no,is_hex,is_case_insenstive,";
// 时间过滤
if (entity.getSearch_create_time_start() == null ) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), list);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("urlGroupConfig export failed",e);
addMessage(redirectAttributes,"error","export_failed");
}
//return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId();
}
}

View File

@@ -346,6 +346,7 @@ public class AppCfgController extends BaseController {
public String ipCfgForm(Model model, String ids, AppIpCfg entity) {
if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppIpCfg(Long.parseLong(ids));
entity.setAppFeaturePropCfgList(appMultiFeatureCfgService.getAppFeaturePropCfg(entity.getCompileId(), entity.getFunctionId(), null));
initUpdateFormCondition(model, entity);
} else {
initFormCondition(model, entity);
@@ -671,6 +672,7 @@ public class AppCfgController extends BaseController {
public String domainCfgForm(Model model, String ids, AppDomainCfg entity) {
if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppDomainCfg(Long.parseLong(ids));
entity.setAppFeaturePropCfgList(appMultiFeatureCfgService.getAppFeaturePropCfg(entity.getCompileId(), entity.getFunctionId(), null));
initUpdateFormCondition(model, entity);
} else {
initFormCondition(model, entity);
@@ -1859,7 +1861,12 @@ public class AppCfgController extends BaseController {
for (int i = 0; i < ipLists.size(); i++) {
AppTopicDomainCfg appTop = ipLists.get(i);
appTop.setIsHex(appTop.getIsHexbin());
appTop.setIsCaseInsenstive(appTop.getIsHexbin());
// '默认为0:大小写不敏感且非HEX;1:HEX格式二进制;2:大小写敏感且非HEX',
if(appTop.getIsHexbin()==2){
appTop.setIsCaseInsenstive(1);
}else{
appTop.setIsCaseInsenstive(0);
}
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), AppTopicDomainCfg.class);
@@ -1990,7 +1997,12 @@ public class AppCfgController extends BaseController {
for (AppHttpCfg http : ipLists) {
http.setIsHex(http.getIsHexbin());
http.setIsCaseInsenstive(http.getIsHexbin());
// '默认为0:大小写不敏感且非HEX;1:HEX格式二进制;2:大小写敏感且非HEX',
if(http.getIsHexbin()==2){
http.setIsCaseInsenstive(1);
}else{
http.setIsCaseInsenstive(0);
}
http.setCfgKeywords(Functions.replace(http.getCfgKeywords(), "***and***", " "));
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(http.getSpecServiceId());
http.setAppName(app.getSpecServiceName());
@@ -2058,7 +2070,12 @@ public class AppCfgController extends BaseController {
}
for (AppDomainCfg domain : ipLists) {
domain.setIsHex(domain.getIsHexbin());
domain.setIsCaseInsenstive(domain.getIsHexbin());
// '默认为0:大小写不敏感且非HEX;1:HEX格式二进制;2:大小写敏感且非HEX',
if(domain.getIsHexbin()==2){
domain.setIsCaseInsenstive(1);
}else{
domain.setIsCaseInsenstive(0);
}
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(domain.getSpecServiceId());
domain.setAppName(app.getSpecServiceName());
}
@@ -2126,7 +2143,12 @@ public class AppCfgController extends BaseController {
for (AppSslCertCfg ssl : ipLists) {
ssl.setIsHex(ssl.getIsHexbin());
ssl.setIsCaseInsenstive(ssl.getIsHexbin());
// '默认为0:大小写不敏感且非HEX;1:HEX格式二进制;2:大小写敏感且非HEX',
if(ssl.getIsHexbin()==2){
ssl.setIsCaseInsenstive(1);
}else{
ssl.setIsCaseInsenstive(0);
}
ssl.setCfgKeywords(Functions.replace(ssl.getCfgKeywords(), "***and***", " "));
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(ssl.getSpecServiceId());
ssl.setAppName(app.getSpecServiceName());

View File

@@ -1,6 +1,5 @@
package com.nis.web.controller.configuration;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -12,52 +11,25 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.taglibs.standard.functions.Functions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.Page;
import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.configuration.AppBuiltInFeatureFile;
import com.nis.domain.configuration.AppByteCfg;
import com.nis.domain.configuration.AppComplexFeatureCfg;
import com.nis.domain.configuration.AppDomainCfg;
import com.nis.domain.configuration.AppFeatureIndex;
import com.nis.domain.configuration.AppHeaderCfg;
import com.nis.domain.configuration.AppHttpCfg;
import com.nis.domain.configuration.AppFeatureProperties;
import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.configuration.AppPolicyCfg;
import com.nis.domain.configuration.AppSslCertCfg;
import com.nis.domain.configuration.AppStringFeatureCfg;
import com.nis.domain.configuration.AppTcpCfg;
import com.nis.domain.configuration.AppTopicDomainCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg;
import com.nis.domain.configuration.PxyObjTrustedCaCert;
import com.nis.domain.configuration.WebsiteDomainTopic;
import com.nis.domain.maat.ToMaatResult;
import com.nis.domain.maat.ToMaatResult.ResponseData;
import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.exceptions.CallExternalProceduresException;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.FileUtils;
import com.nis.util.JsonMapper;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@@ -110,15 +82,27 @@ public class AppFeatureCfgController extends BaseController {
appMultiFeatureCfgService.getAppIpRangeCfg(entity.getCompileId(), entity.getFunctionId()));
entity.setStrList(appMultiFeatureCfgService.getAppStringFeatureCfg(entity.getCompileId(),
entity.getFunctionId(), null));
entity.setComplexList(appMultiFeatureCfgService.getAppComplexFeatureCfg(entity.getCompileId(),
entity.getFunctionId(), null));
entity.setComplexList(appMultiFeatureCfgService.getAppComplexFeatureCfgNotRegionCode(entity.getCompileId(),
entity.getFunctionId(), 6));
entity.setSessionList(appMultiFeatureCfgService.getAppComplexFeatureCfg(entity.getCompileId(),
entity.getFunctionId(), 6));
entity.setNumCfgList(
appMultiFeatureCfgService.getAppTcpCfg(entity.getCompileId(), entity.getFunctionId(), null));
entity.setAppFeaturePropCfgList(appMultiFeatureCfgService.getAppFeaturePropCfg(entity.getCompileId(), entity.getFunctionId(), null));
initUpdateFormCondition(model, entity);
} else {
initFormCondition(model, entity);
}
// 获取L7 Protocol
SpecificServiceCfg specificServiceCfg = new SpecificServiceCfg();
specificServiceCfg.setCfgType(3);
List<SpecificServiceCfg> l7ProtoList = specificServiceCfgService.findAllSpecificServiceCfg(specificServiceCfg, null);
model.addAttribute("_cfg", entity);
model.addAttribute("l7ProtoList", l7ProtoList);
if(entity.getFunctionId() == 567) { // APP关联特征配置
return "/cfg/app/appCorrelationFeatureCfgForm";
}
return "/cfg/app/appMultiFeatureCfgForm";
}
@@ -269,8 +253,26 @@ public class AppFeatureCfgController extends BaseController {
Integer.valueOf(cfgRegionCode[i]));
map.put("numCfgList", numCfgList);
}
if ("8".equals(cfgRegionType[i])) {
List<AppComplexFeatureCfg> sessionList = appMultiFeatureCfgService
.getAppComplexFeatureCfg(compileId, functionId, Integer.valueOf(cfgRegionCode[i]));
map.put("sessionList", sessionList);
}
if ("9".equals(cfgRegionType[i])) {
List<AppFeatureProperties> featureList = appMultiFeatureCfgService
.getAppFeaturePropCfg(compileId, functionId, null);
map.put("featureList", featureList);
}
tabList.add(map);
}
// 获取L7 Protocol
SpecificServiceCfg specificServiceCfg = new SpecificServiceCfg();
specificServiceCfg.setCfgType(3);
List<SpecificServiceCfg> l7ProtoList = specificServiceCfgService.findAllSpecificServiceCfg(specificServiceCfg, null);
model.addAttribute("l7ProtoList", l7ProtoList);
} else {
Map<String, Object> map = new HashMap();
map.put("regionType", "0");
@@ -424,7 +426,12 @@ public class AppFeatureCfgController extends BaseController {
for (int i = 0; i < list.size(); i++) {
AppComplexFeatureCfg base = (AppComplexFeatureCfg) list.get(i);
base.setIsHex(base.getIsHexbin());
base.setIsCaseInsenstive(base.getIsHexbin());
// '默认为0:大小写不敏感且非HEX;1:HEX格式二进制;2:大小写敏感且非HEX',
if(base.getIsHexbin()==2){
base.setIsCaseInsenstive(1);
}else{
base.setIsCaseInsenstive(0);
}
base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***", " "));
}
return list;
@@ -434,7 +441,12 @@ public class AppFeatureCfgController extends BaseController {
for (int i = 0; i < list.size(); i++) {
AppStringFeatureCfg base = (AppStringFeatureCfg) list.get(i);
base.setIsHex(base.getIsHexbin());
base.setIsCaseInsenstive(base.getIsHexbin());
// '默认为0:大小写不敏感且非HEX;1:HEX格式二进制;2:大小写敏感且非HEX',
if(base.getIsHexbin()==2){
base.setIsCaseInsenstive(1);
}else{
base.setIsCaseInsenstive(0);
}
base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***", " "));
}
return list;

View File

@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.eclipse.jetty.util.ajax.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
@@ -23,10 +24,8 @@ import com.google.common.collect.Maps;
import com.nis.domain.Page;
import com.nis.domain.basics.IpReuseIpCfg;
import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.IpReuseDnatPolicyCfg;
import com.nis.domain.configuration.IpReusePolicyCfg;
import com.nis.domain.configuration.UserManage;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants;
@@ -34,11 +33,15 @@ import com.nis.util.DateUtils;
import com.nis.util.StringUtil;
import com.nis.util.StringUtils;
import com.nis.web.controller.BaseController;
import com.nis.web.service.configuration.IpMultiplexService;
@Controller
@RequestMapping("${adminPath}/maintenance/userManage")
public class UserManageController extends BaseController{
@Autowired
private IpMultiplexService ipMultiplexService;
@RequestMapping(value = {"/list"})
@RequiresPermissions(value={"user:manage:view"})
public String list(Model model,HttpServletRequest request,HttpServletResponse response
@@ -69,13 +72,30 @@ public class UserManageController extends BaseController{
public String delete(Integer isValid
,String ids
,RedirectAttributes redirectAttributes,HttpServletRequest request){
String deleteSuccessIp="";
String message="";
Properties msgProp = getMsgProp();
String exUser="";
try{
for (String id : ids.split(",")) {
UserManage user=userManageService.getUserById(id);
if(user != null && !StringUtil.isEmpty(user.getServerIp())) {
//判断用户是否存在snat、dnat复用策略中
boolean flag=true;
if(user!=null && !StringUtil.isEmpty(user.getUserName())){
//snat
List<IpReusePolicyCfg> snatList=ipMultiplexService.findByUser(user.getUserName());
if(snatList!=null && snatList.size()>0){
exUser+=user.getUserName()+"";
flag=false;
}else{
//dnat
List<IpReuseDnatPolicyCfg> dnatList=ipMultiplexService.findDnatUser(user.getUserName());
if(dnatList!=null && dnatList.size()>0){
exUser+=user.getUserName()+"";
flag=false;
}
}
}
if(user != null && !StringUtil.isEmpty(user.getServerIp()) && flag) {
boolean lastIp=false;
int deleteIpLenth=1;
String serverIp=user.getServerIp().substring(0, user.getServerIp().length()-1);
@@ -99,11 +119,21 @@ public class UserManageController extends BaseController{
}
}
}
addMessage(redirectAttributes,"success","delete_success");
if(!StringUtil.isEmpty(exUser)){
exUser=exUser.substring(0, exUser.length()-1);
addMessage(redirectAttributes,"error", msgProp.getProperty("user")+" "+exUser+" "+msgProp.getProperty("user_check"));
}else{
addMessage(redirectAttributes,"success","delete_success");
}
}catch(Exception e){
logger.error("Delete failed",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",message);
if(!StringUtil.isEmpty(exUser)){
exUser=exUser.substring(0, exUser.length()-1);
message+="<br/> "+msgProp.getProperty("user")+" "+exUser+" "+msgProp.getProperty("user_check");
}
if(!StringUtil.isEmpty(e.getMessage())) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error",message);
}
@@ -244,10 +274,18 @@ public class UserManageController extends BaseController{
}
} catch (MaatConvertException e) {
addMessage(redirectAttributes,"error",message);
if(!StringUtil.isEmpty(e.getMessage())) {
addMessage(redirectAttributes,"error",e.getMessage());
}else{
addMessage(redirectAttributes,"error",message);
}
return "redirect:" + adminPath +"/maintenance/userManage/list";
} catch (Exception e) {
addMessage(redirectAttributes,"error",message);
if(!StringUtil.isEmpty(e.getMessage())) {
addMessage(redirectAttributes,"error",e.getMessage());
}else{
addMessage(redirectAttributes,"error",message);
}
return "redirect:" + adminPath +"/maintenance/userManage/list";
}
return "redirect:" + adminPath +"/maintenance/userManage/list";

View File

@@ -302,6 +302,7 @@ public class IpMultiplexController extends CommonController {
public List<IpAddrPoolCfg> ajaxGetAddrPools(HttpServletRequest request, HttpServletResponse response) {
List<IpAddrPoolCfg> addrPools = ipAddrPoolCfgService.getEffectiveAddrPool();
List<IpAddrPoolCfg> addrPoolsNew = new ArrayList<>();
Properties msgProp = getMsgProp();
for (IpAddrPoolCfg addrPool : addrPools) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("addr_pool_id", addrPool.getCfgId());
@@ -309,6 +310,7 @@ public class IpMultiplexController extends CommonController {
Map<String, Object> resultMap = ConfigServiceUtil.getCGIInfo(url, Constants.IP_NUM_GET, params);
if (!StringUtil.isEmpty(resultMap) && !StringUtil.isEmpty(resultMap.get("num"))
&& Integer.parseInt(resultMap.get("num").toString()) > 0) {
addrPool.setAddrPoolName(msgProp.getProperty(addrPool.getAddrPoolName(),addrPool.getAddrPoolName()));
addrPoolsNew.add(addrPool);
}
}

View File

@@ -66,6 +66,7 @@ import com.nis.domain.configuration.template.SnatTemplate;
import com.nis.domain.configuration.template.StringAllNotDoLogTemplate;
import com.nis.domain.configuration.template.StringAllTemplate;
import com.nis.domain.configuration.template.TopicWebsiteTemplate;
import com.nis.domain.configuration.template.UrlCommGroupTemplate;
import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants;
@@ -423,6 +424,12 @@ public class IpController extends BaseController{
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, IpSpoofingTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(405) || regionDict.getFunctionId().equals(563) || regionDict.getFunctionId().equals(565)
|| regionDict.getFunctionId().equals(566)) { // APP Feature IP
List<IpAllNotDoLogTemplate> classList=new ArrayList<IpAllNotDoLogTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, IpAllNotDoLogTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else{
List<IpAllTemplate> classList=new ArrayList<IpAllTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, IpAllTemplate.class, 2);
@@ -484,6 +491,11 @@ public class IpController extends BaseController{
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, TopicWebsiteTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(111)) {// url分组配置
List<UrlCommGroupTemplate> classList=new ArrayList<UrlCommGroupTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, UrlCommGroupTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else{
List<StringAllTemplate> classList=new ArrayList<StringAllTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, StringAllTemplate.class, 2);
@@ -524,6 +536,11 @@ public class IpController extends BaseController{
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, AppPayloadTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(565) || regionDict.getFunctionId().equals(564) || regionDict.getFunctionId().equals(566)){// APP Feature
List<ComplexStringAllNotDoLogTemplate> classList=new ArrayList<ComplexStringAllNotDoLogTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, ComplexStringAllNotDoLogTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else{
List<ComplexStringAllTemplate> classList=new ArrayList<ComplexStringAllTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, ComplexStringAllTemplate.class, 2);

View File

@@ -27,6 +27,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.Page;
import com.nis.domain.basics.PolicyGroupInfo;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg;
@@ -402,8 +403,12 @@ public class WebsiteController extends BaseController {
public String dnsForm(Model model, String ids, CfgIndexInfo entity) {
if (StringUtils.isNotBlank(ids)) {
entity = websiteCfgService.getDnsCfg(Long.parseLong(ids), null);
entity.setGroupType(12);
//entity.setUdFlag(1);
initUpdateFormCondition(model, entity);
} else {
entity.setGroupType(12);
//entity.setUdFlag(1);
initFormCondition(model, entity);
}
// 获取所有响应策略信息
@@ -452,6 +457,8 @@ public class WebsiteController extends BaseController {
}
}
}
List<PolicyGroupInfo> policyGroupInfos = policyGroupInfoService.findPolicyGroupInfosByTypeforUD(12, null);
model.addAttribute("policyGroupInfos", policyGroupInfos);// 显示分组名称 12dns 1有效
model.addAttribute("_cfg", cfg);
model.addAttribute("index", index);
model.addAttribute("tabList", tabList);

View File

@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.Page;
import com.nis.domain.basics.PolicyGroupInfo;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.HttpUrlCfg;
@@ -201,6 +202,8 @@ public class WhiteListController extends CommonController {
if (entity.getHttpUrlList().size() == 0) {
entity.getHttpUrlList().add(urlCfg);
}
entity.setGroupType(11);
//entity.setUdFlag(1);
initUpdateFormCondition(model, entity);
} else {
HttpUrlCfg urlCfg = new HttpUrlCfg();
@@ -209,6 +212,8 @@ public class WhiteListController extends CommonController {
List<HttpUrlCfg> urlList = new ArrayList<HttpUrlCfg>();
urlList.add(urlCfg);
entity.setHttpUrlList(urlList);
entity.setGroupType(11);
//entity.setUdFlag(1);
initFormCondition(model, entity);
}
model.addAttribute("_cfg", entity);
@@ -244,6 +249,8 @@ public class WhiteListController extends CommonController {
}
}
}
List<PolicyGroupInfo> policyGroupInfos = policyGroupInfoService.findPolicyGroupInfosByTypeforUD(11, null);
model.addAttribute("policyGroupInfos", policyGroupInfos);// 显示分组名称 11url 1有效
model.addAttribute("_cfg", cfg);
model.addAttribute("index", index);
model.addAttribute("tabList", tabList);

View File

@@ -256,7 +256,7 @@ public class CachePolicyController extends BaseController{
classMap.put(entity.getMenuNameCode(), CachePolicyUserRegion.class);
classMap.put("PXY_CACHE_HTTP_URL", HttpUrlCfg.class);
classMap.put("PXY_CACHE_HTTP_COOKIE", HttpUrlCfg.class);
String cfgIndexInfoNoExport=",block_type,policy_name,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,&action:block_type-";
String cfgIndexInfoNoExport=",block_type,do_log,policy_name,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,&action:block_type-";
String httpUrlInfoNoExport=",block_type,do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+",letter,whether_area_block,classification,attribute,label"

View File

@@ -88,12 +88,12 @@ public class InterceptController extends CommonController {
}
// 获取证书信息
List<PxyObjKeyring> certificateList = new ArrayList<PxyObjKeyring>();
if (entity.getFunctionId().equals(200)) {
certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "ip");
}
if (entity.getFunctionId().equals(201)) {
certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "domain");
}
// if (entity.getFunctionId().equals(200)) {
certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, null);
// }
// if (entity.getFunctionId().equals(201)) {
// certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "domain");
// }
model.addAttribute("certificateList", certificateList);
model.addAttribute("_cfg", entity);

View File

@@ -41,6 +41,7 @@ import com.google.common.collect.Maps;
import com.nis.domain.Page;
import com.nis.domain.basics.PolicyGroupInfo;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.DnsIpCfg;
import com.nis.domain.configuration.DnsResStrategy;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.PxyObjKeyring;
@@ -911,4 +912,31 @@ public class PxyObjKeyringController extends BaseController {
}
return "redirect:" + adminPath + "/proxy/intercept/strateagy/trustedCertList?functionId=" + functionId;
}
/**
* 验证Keyring是否有被使用
*
* @param entity
* @param request
* @param response
* @return
*/
@ResponseBody
@RequestMapping(value = { "/ajaxKeyinfIsUsed" })
public boolean ajaxKeyinfIsUsed(String[] compileIds, HttpServletRequest request, HttpServletResponse response) {
for(String compileId:compileIds){
CfgIndexInfo cfg = new CfgIndexInfo();
cfg.setIsAudit(1);
cfg.setIsValid(1);
cfg.setFunctionId(200);//代理拦截策略
cfg.setServiceId(512);
cfg.setUserRegion1(compileId);
List<CfgIndexInfo> list = httpRedirectCfgService.getCfgIndexInfos(cfg);
if (list.size() > 0) {
return false;
}
}
return true;
}
}

View File

@@ -263,12 +263,13 @@ public class DashboardController extends BaseController{
list = gson.fromJson(fromJsonList.get("data").toString(), new TypeToken<List<TrafficIpActiveStatistic>>() {}.getType()) ;
if(list.size()>0) {
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat f = new DecimalFormat("0.00");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//两个时间段之间的秒数
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
for(TrafficIpActiveStatistic data:list) {
data.setAvgByte(lf.format(Integer.parseInt(data.get_byte())*8/allSeconds));
data.setAvgPacket(lf.format(Integer.parseInt(data.get_packet())/allSeconds));
data.setAvgByte(f.format(Long.parseLong(data.get_byte())*8/1024/1024/1024/allSeconds));
data.setAvgPacket(lf.format(Long.parseLong(data.get_packet())/allSeconds));
}
}
Collections.sort(list, new Comparator<TrafficIpActiveStatistic>() {

View File

@@ -47,6 +47,7 @@ import com.nis.util.DateUtil;
import com.nis.util.DateUtils;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
import com.nis.util.StringUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.dao.dashboard.codedic.CodeResult;
@@ -261,7 +262,7 @@ public class TrafficStatisticsInfoController extends BaseController {
*/
@RequestMapping(value="bandwidthTransThree")
@ResponseBody
public Map bandwidthTransThree(String beginDate,String endDate,String searchQuotaType){
public Map bandwidthTransThree(String beginDate,String endDate,String searchQuotaType,String searchDirection,Model model){
Map<String, Object> fromJsonList = new HashMap<String, Object>();
Map map = new HashMap();
//String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_BANDWIDTH_TRANS_TWO;
@@ -270,11 +271,16 @@ public class TrafficStatisticsInfoController extends BaseController {
try {
url=urlAddDate(url,beginDate,endDate);
url=url+"&searchQuotaType="+searchQuotaType;
if (!StringUtil.isEmpty(searchDirection)) {
url=url+"&searchDirection="+searchDirection;
}
String string = HttpClientUtil.get(url);
Gson gson = new GsonBuilder().create();
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
logger.debug("bandwidthTransThree服务查询数据成功");
Map result = (Map)fromJsonList.get("data");
model.addAttribute("searchDirection", searchDirection);
return result;
} catch (Exception e) {
e.printStackTrace();
@@ -301,7 +307,7 @@ public class TrafficStatisticsInfoController extends BaseController {
*/
@RequestMapping(value="protocolList")
@ResponseBody
public List protocolList(Model model,Integer entranceId,Integer[] protoType,@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate){
public List protocolList(Model model,Integer entranceId,Integer[] protoType,@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate,@RequestParam(required=false)String searchDirection){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Map<String, Object> fromJsonList = new HashMap<String, Object>();
List list = new ArrayList();
@@ -318,6 +324,9 @@ public class TrafficStatisticsInfoController extends BaseController {
if(entranceId!=null){
url=url+"&entranceId="+entranceId;
}
if (!StringUtil.isEmpty(searchDirection)) {
url=url+"&searchDirection="+searchDirection;
}
String string = HttpClientUtil.get(url);
Gson gson = new GsonBuilder().create();
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
@@ -327,6 +336,7 @@ public class TrafficStatisticsInfoController extends BaseController {
Long totalPackets=0l;
Double totalGByte=0d;
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat f = new DecimalFormat("0.00");
DecimalFormat df = new DecimalFormat("0.0000000000");
List<CodeResult> appCodeList = CodeDicUtils.getCodeList("appCode");
//两个时间段之间的秒数
@@ -342,8 +352,8 @@ public class TrafficStatisticsInfoController extends BaseController {
m.put("linkNum", lf.format(m.get("linkNum")));
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
m.put("pps",lf.format(avgPacket));
double avgByte=Double.parseDouble(m.get("GByte").toString())*1024*1024*1024*8/allSeconds;
m.put("bps",lf.format(avgByte));
double avgByte=Double.parseDouble(m.get("GByte").toString())*8/allSeconds;
m.put("bps",f.format(avgByte));
totalLink+=Long.parseLong( m.get("linkNum").toString());
totalPackets+=Long.parseLong(m.get("packets").toString());
// 协议没匹配的匹配app码表
@@ -362,7 +372,7 @@ public class TrafficStatisticsInfoController extends BaseController {
m.put("totalGByte", totalGByte);
}
}
model.addAttribute("searchDirection", searchDirection);
} catch (Exception e) {
e.printStackTrace();
logger.error("协议详情数据获取错误"+e);
@@ -414,6 +424,7 @@ public class TrafficStatisticsInfoController extends BaseController {
Long totalPackets=0l;
Double totalGByte=0d;
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat f = new DecimalFormat("0.00");
DecimalFormat df = new DecimalFormat("0.0000000000");
//两个时间段之间的秒数
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -431,8 +442,8 @@ public class TrafficStatisticsInfoController extends BaseController {
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
m.put("pps",lf.format(avgPacket));
double avgByte=Double.parseDouble(m.get("GByte").toString())*1024*1024*1024*8/allSeconds;
m.put("bps",lf.format(avgByte));
double avgByte=Double.parseDouble(m.get("GByte").toString())*8/allSeconds;
m.put("bps",f.format(avgByte));
}
for (Object object : list) {
Map m=(Map) object;
@@ -453,7 +464,7 @@ public class TrafficStatisticsInfoController extends BaseController {
* App趋势界面 独立IP访问数量趋势图
*/
@RequestMapping(value="appTrendList")
public String appTrendList(Model model,String beginDate,String endDate,String appName,Integer appType){
public String appTrendList(Model model,String beginDate,String endDate,String appName,Integer appType,Integer entranceId){
if(StringUtil.isBlank(beginDate)||StringUtil.isBlank(endDate)){
Calendar cal = Calendar. getInstance ();
cal.setTime(new Date());
@@ -463,17 +474,27 @@ public class TrafficStatisticsInfoController extends BaseController {
}
model.addAttribute("appName", appName);
model.addAttribute("appType", appType);
model.addAttribute("entranceId", entranceId);
model.addAttribute("beginDate", beginDate);
model.addAttribute("endDate", endDate);
return "/dashboard/trafficAppTrendList";
}
@RequestMapping("ajaxAppTrend")
@ResponseBody
public Map ajaxAppTrend(String beginDate,String endDate,Integer appType,Integer entranceId,Model model){
public Map ajaxAppTrend(String beginDate,String endDate,Integer appType,Integer entranceId,String searchQuotaType,Integer[] searchIspCode,Model model){
Map<String, Object> fromJsonList = new HashMap<String, Object>();
Map list = new HashMap();
try {
String url=Constants.DASHBOARD_URL+Constants.TRAFFIC_APP_TREND;
//TRAFFIC_APP_PPS_TREND
String trafficApp=Constants.TRAFFIC_APP_TREND;
if("Unique Ip".equals(searchQuotaType)){
trafficApp=Constants.TRAFFIC_APP_TREND;
}else if("Gbps".equals(searchQuotaType)){
trafficApp=Constants.TRAFFIC_APP_BPS_TREND;
}else if("pps".equals(searchQuotaType)){
trafficApp=Constants.TRAFFIC_APP_PPS_TREND;
}
String url=Constants.DASHBOARD_URL+trafficApp;
URIBuilder uriBuilder = new URIBuilder(url);
uriBuilder.addParameter("searchStartTime",beginDate);
uriBuilder.addParameter("searchEndTime",endDate);
@@ -484,6 +505,10 @@ public class TrafficStatisticsInfoController extends BaseController {
if(entranceId!=null){
url=url+"&searchEntranceId="+entranceId;
}
if(searchIspCode!=null&&searchIspCode.length>0){
String str=StringUtils.join(searchIspCode,",");
url=url+"&searchIspCode="+str;
}
String string = HttpClientUtil.get(url);
Gson gson = new GsonBuilder().create();
fromJsonList = gson.fromJson(string, new TypeToken<Map<String, Object>>(){}.getType());
@@ -499,7 +524,7 @@ public class TrafficStatisticsInfoController extends BaseController {
}
@RequestMapping("ajaxAppTopList")
@ResponseBody
public List ajaxAppTopList(String beginDate,String endDate,Integer appType,Integer entranceId,Integer searchQuota,Model model){
public List ajaxAppTopList(String beginDate,String endDate,Integer appType,Integer entranceId,Integer searchQuota,Integer[] searchIspCode,Model model){
Map<String, Object> fromJsonList = new HashMap<String, Object>();
List<Map> list = new ArrayList<Map>();
try {
@@ -519,6 +544,10 @@ public class TrafficStatisticsInfoController extends BaseController {
}else{
url=url+"&searchQuota="+1; // 默认是按照link 排序
}
if(searchIspCode!=null&&searchIspCode.length>0){
String str=StringUtils.join(searchIspCode,",");
url=url+"&searchIspCode="+str;
}
String string = HttpClientUtil.get(url);
Gson gson = new GsonBuilder().create();
fromJsonList = gson.fromJson(string, new TypeToken<Map<String, Object>>(){}.getType());
@@ -527,13 +556,14 @@ public class TrafficStatisticsInfoController extends BaseController {
if(list.size()>0) {
//两个时间段之间的秒数
DecimalFormat dl = new DecimalFormat("0");
DecimalFormat f = new DecimalFormat("0.00");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
for(Map m:list) {
double avgPacket=Double.parseDouble(m.get("pktNum").toString())/allSeconds;
m.put("pps",dl.format(avgPacket));
double avgByte=Double.parseDouble(m.get("byteNum").toString())*8/allSeconds;
m.put("bps",dl.format(avgByte));
double avgByte=Double.parseDouble(m.get("byteNum").toString())*8/1024/1024/1024/allSeconds;
m.put("bps",f.format(avgByte));
}
}
} catch (Exception e) {
@@ -634,6 +664,7 @@ public class TrafficStatisticsInfoController extends BaseController {
DecimalFormat df = new DecimalFormat("0.000000000");
DecimalFormat dl = new DecimalFormat("0");
DecimalFormat pf = new DecimalFormat("0.000000000");
DecimalFormat f = new DecimalFormat("0.00");
// Double totalLink=0d;
Double totalGbyte=0d;
Double totalPackets=0d;
@@ -651,8 +682,8 @@ public class TrafficStatisticsInfoController extends BaseController {
double avgPacket=Double.parseDouble(m.get("pktCount").toString())/allSeconds;
m.put("pps",dl.format(avgPacket));
double avgByte=Double.parseDouble(m.get("byteCount").toString())*8/allSeconds;
m.put("bps",dl.format(avgByte));
double avgByte=Double.parseDouble(m.get("byteCount").toString())*8/1024/1024/1024/allSeconds;
m.put("bps",f.format(avgByte));
}
List<WebsiteDomainTopic> codeList = appCfgService.getDomainDict(new WebsiteDomainTopic());
Map<Long, String> map = new HashMap<Long,String>();
@@ -722,6 +753,7 @@ public class TrafficStatisticsInfoController extends BaseController {
Long totalPackets=0l;
Double totalGByte=0d;
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat f = new DecimalFormat("0.00");
//两个时间段之间的秒数
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
@@ -733,8 +765,8 @@ public class TrafficStatisticsInfoController extends BaseController {
totalGByte+=Double.parseDouble(lf.format(m.get("count")));
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
m.put("pps",lf.format(avgPacket));
double avgByte=Double.parseDouble(m.get("count").toString())*8/allSeconds;
m.put("bps",lf.format(avgByte));
double avgByte=Double.parseDouble(m.get("count").toString())*8/1024/1024/1024/allSeconds;
m.put("bps",f.format(avgByte));
m.remove("domainData");
Double value1=0d;
if(StringUtil.isBlank(m.get("topicId").toString())){

View File

@@ -116,6 +116,10 @@ public class BgpLogController extends BaseController {
if (fromJson.getStatus().intValue() == 200) {
Page<NtcBGPLog> data = fromJson.getData();
list = data.getList();
for (NtcBGPLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
}
}
titleList.add("bgp_control");

View File

@@ -30,6 +30,7 @@ import com.nis.domain.log.NtcMailLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@@ -46,6 +47,28 @@ public class MailLogController extends BaseController {
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
if (StringUtil.isEmpty(log.getService())) {
String searchService = "";
for (int i = 0; i < serviceList.size(); i++) {
if (i != 0) {
searchService += ",";
}
searchService += (serviceList.get(i).getServiceId() == null ? ""
: serviceList.get(i).getServiceId());
// log.setAction(serviceList.get(i).getAction());
}
if (StringUtils.isNotBlank(searchService)) {
params.put("searchService", searchService);
}
} else {
log.setAction(serviceList.get(0).getAction());
}
initLogSearchValue(log, params);
// 增加收/发件人、邮件主题查询
@@ -59,9 +82,6 @@ public class MailLogController extends BaseController {
params.put("searchSubject", StringEscapeUtils.unescapeHtml(log.getSubject()));
}
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_MAIL_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
@@ -108,6 +128,27 @@ public class MailLogController extends BaseController {
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
if (StringUtil.isEmpty(log.getService())) {
String searchService = "";
for (int i = 0; i < serviceList.size(); i++) {
if (i != 0) {
searchService += ",";
}
searchService += (serviceList.get(i).getServiceId() == null ? ""
: serviceList.get(i).getServiceId());
// log.setAction(serviceList.get(i).getAction());
}
if (StringUtils.isNotBlank(searchService)) {
params.put("searchService", searchService);
}
} else {
log.setAction(serviceList.get(0).getAction());
}
initLogSearchValue(log, params);
// 增加收/发件人、邮件主题查询
@@ -121,8 +162,6 @@ public class MailLogController extends BaseController {
params.put("searchSubject", StringEscapeUtils.unescapeHtml(log.getSubject()));
}
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_MAIL_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
@@ -151,7 +190,7 @@ public class MailLogController extends BaseController {
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("mail_control", cfgIndexInfoNoExport);
dataMap.put("mail_control", list);
String timeRange= initLogMap(log,"mail_control");
String timeRange = initLogMap(log, "mail_control");
noExportMap.put("timeRange", timeRange);
/* } */
if ("csv".equals(type)) {

View File

@@ -23,6 +23,7 @@ import com.nis.domain.Page;
import com.nis.domain.PageLog;
import com.nis.domain.SysUser;
import com.nis.domain.configuration.WebsiteDomainTopic;
import com.nis.domain.dashboard.SysIspInfo;
import com.nis.domain.log.NtcConnRecordLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.exceptions.MaatConvertException;
@@ -119,6 +120,19 @@ public class NtcConnRecordLogController extends BaseController {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcConnRecordLog> data = fromJson.getData();
List<SysIspInfo> ispList = CodeDicUtils.getIspListByIspNum();
/*if(data.getList()!=null&&data.getList().size()>0){
for (NtcConnRecordLog cnn : data.getList()) {
String isNum=cnn.getEntranceId()+""+cnn.getDeviceId();
for (SysIspInfo sysIspInfo : ispList) {
if(isNum.equals(sysIspInfo.getIspNum())){
cnn.setIspName(sysIspInfo.getIspKeyName());
break;
}
}
}
}*/
page.setCount(data.getCount());
page.setLast(data.getLast());
page.setList(data.getList());

View File

@@ -110,6 +110,20 @@ public class UserController extends BaseController{
// 如果新密码为空,则不更换密码
if (StringUtils.isNotBlank(user.getNewPassword())) {
user.setPassword(StringUtils.entryptPassword(user.getNewPassword()));
//密码修改之后更新此用户的redis缓存
RealmSecurityManager securityManager = (RealmSecurityManager) SecurityUtils.getSecurityManager();
Collection<Realm> realm = securityManager.getRealms();
for (Realm realm2 : realm) {
SystemAuthorizingRealm userRealm = (SystemAuthorizingRealm) realm2;
RedisCache<Object, AuthenticationInfo> cache = (RedisCache<Object, AuthenticationInfo>) userRealm.getAuthenticationCache();
String keyPrefix = cache.getKeyPrefix();
for (AuthenticationInfo auth : cache.values()) {
userRealm.getAuthenticationCache().remove(auth.getPrincipals().getPrimaryPrincipal());
}
systemService.deleteAuthenticationCache(keyPrefix + user.getLoginId());
systemService.deleteAuthenticationCache(keyPrefix + user.getId());
}
}
/*if (!beanValidator(model, user)){
return form(user, model);
@@ -317,7 +331,7 @@ public class UserController extends BaseController{
for (AuthenticationInfo auth : cache.values()) {
userRealm.getAuthenticationCache().remove(auth.getPrincipals().getPrimaryPrincipal());
}
systemService.deleteAuthenticationCache(keyPrefix + user.getName());
systemService.deleteAuthenticationCache(keyPrefix + user.getLoginId());
systemService.deleteAuthenticationCache(keyPrefix + user.getId());
}

View File

@@ -0,0 +1,76 @@
package com.nis.web.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.nis.domain.ScheduleCfg;
import com.nis.domain.ScheduleExceInfo;
import com.nis.domain.configuration.BaseCfg;
@MyBatisDao
public interface SchedulerDao extends CrudDao<ScheduleCfg> {
List<ScheduleCfg> findScheduleList(ScheduleCfg cfg);
/**
* 查找最新的修改数据
* @param id
* @param size
* @return
*/
List<ScheduleCfg> findNewlyCfg(@Param("id")Long id,@Param("limit")Long limit);
/**
* 更新 del_flag 字段为删除标识
* @param cfg
* @return
*/
int deleteByCompileId(ScheduleCfg cfg);
/**
* 查找 配置 下发 最新记录
* @param compileId
* @param isValid
* @return
*/
ScheduleExceInfo findScheduleExceNew(ScheduleExceInfo se);
/**
* 修改配置表状态
* @param tableName
* @param compileId
* @param isValid
* @return
*/
int updateCfgTableStatus(@Param("tableName")String tableName,@Param("compileId")Integer compileId,@Param("isValid")Integer isValid);
/**
* 查询 配置信息
* @param compileId
* @return
*/
BaseCfg getCfgTableInfo(@Param("tableName")String tableName,@Param("compileId")Integer compileId);
/**
* 保存执行记录
* @param exceInfo
* @return
*/
int insertScheduleExceLog(ScheduleExceInfo exceInfo);
/**
* 保存最新记录表
* @param exceInfo
* @return
*/
int insertScheduleExceNew(ScheduleExceInfo exceInfo);
/**
* 更新最新记录表
* @param exceInfo
* @return
*/
int updateScheduleExceNew(ScheduleExceInfo exceInfo);
}

View File

@@ -0,0 +1,315 @@
<?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.nis.web.dao.SchedulerDao" >
<resultMap type="com.nis.domain.ScheduleCfg" id="scheduleCfgMap">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="cronValid" column="cron_valid"/>
<result property="cronInvalid" column="cron_invalid"/>
<result property="cfgId" column="cfg_id"/>
<result property="compileId" column="compile_id"/>
<result property="serviceId" column="service_id"/>
<result property="isValid" column="is_valid"/>
<result property="isAudit" column="is_audit"/>
<result property="functionId" column="function_id"/>
<result property="creatorId" column="creator_id"/>
<result property="createTime" column="create_time"/>
<result property="editorId" column="editor_id"/>
<result property="editTime" column="edit_time"/>
<result property="tableName" column="table_name"/>
<result property="userRegion1" column="user_region1"/>
<result property="userRegion2" column="user_region2"/>
<result property="userRegion3" column="user_region3"/>
<result property="userRegion4" column="user_region4"/>
<result property="userRegion5" column="user_region5"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
<resultMap type="com.nis.domain.ScheduleExceInfo" id="scheduleExceInfoMap">
<id property="id" column="id"/>
<result property="scheduleId" column="schedule_id"/>
<result property="exceTime" column="exce_time"/>
<result property="issueStatus" column="issue_status"/>
<result property="issueResult" column="issue_result"/>
<result property="errorInfo" column="error_info"/>
<result property="compileId" column="compile_id"/>
<result property="isIssue" column="is_issue"/>
</resultMap>
<resultMap id="baseCfgMap" type="com.nis.domain.configuration.BaseCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="do_log" property="doLog" jdbcType="INTEGER" />
<result column="do_blacklist" property="doBlackList" jdbcType="INTEGER" />
</resultMap>
<sql id="scheduleCfgColumns">
a.ID,
a.NAME,
a.cron_valid,
a.cron_invalid,
a.SERVICE_ID,
a.COMPILE_ID,
a.CFG_ID,
a.IS_VALID,
a.IS_AUDIT,
a.function_id,
a.CREATOR_ID,
a.CREATE_TIME,
a.EDITOR_ID,
a.EDIT_TIME,
a.table_name,
a.user_region1,
a.user_region2,
a.user_region3,
a.user_region4,
a.user_region5
</sql>
<select id="findScheduleList" resultMap="scheduleCfgMap">
select
<include refid="scheduleCfgColumns"/>
from schedule_cfg a
<where>
del_Flag = #{DEL_FLAG_NORMAL}
<if test="id != null">
and id = #{id}
</if>
<if test="compileId != null">
and compile_id = #{compileId}
</if>
<if test="isValid != null">
and IS_VALID = #{isValid}
</if>
<if test="isAudit != null">
and IS_AUDIT = #{isAudit}
</if>
<if test="compileId != null">
and CFG_ID = #{cfgId}
</if>
<if test="functionId != null">
and function_id = #{functionId}
</if>
<if test="tableName != null and tableName != ''">
and table_name = #{tableName}
</if>
<!-- 动态where条件 -->
<if test=" whereStr != null and whereStr !=''">
${whereStr}
</if>
</where>
order by a.id
</select>
<!-- 查找最新的更新数据 -->
<select id="findNewlyCfg" resultMap="scheduleCfgMap">
select
a.ID,
a.NAME,
a.cron_valid,
a.cron_invalid,
a.SERVICE_ID,
a.COMPILE_ID,
a.CFG_ID,
a.IS_VALID,
a.IS_AUDIT,
a.CREATOR_ID,
a.CREATE_TIME,
a.EDITOR_ID,
a.EDIT_TIME,
a.table_name,
a.user_region1,
a.user_region2,
a.user_region3,
a.user_region4,
a.user_region5
from schedule_cfg a
<where>
del_Flag = 1
and id > #{id}
</where>
order by a.id
limit #{limit}
</select>
<insert id="insert" parameterType="com.nis.domain.ScheduleCfg" useGeneratedKeys="true" keyProperty="id" >
insert into schedule_cfg (
NAME,
cron_valid,
cron_invalid,
SERVICE_ID,
COMPILE_ID,
CFG_ID,
IS_VALID,
IS_AUDIT,
function_id,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
table_name,
user_region1,
user_region2,
user_region3,
user_region4,
user_region5
) values (
#{name,jdbcType=VARCHAR},
#{cronValid,jdbcType=VARCHAR},
#{cronInvalid,jdbcType=VARCHAR},
#{serviceId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{cfgId,jdbcType=INTEGER},
#{isValid,jdbcType=INTEGER},
#{isAudit,jdbcType=INTEGER},
#{functionId,jdbcType=INTEGER},
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{tableName,jdbcType=VARCHAR},
#{userRegion1,jdbcType=VARCHAR},
#{userRegion2,jdbcType=VARCHAR},
#{userRegion3,jdbcType=VARCHAR},
#{userRegion4,jdbcType=VARCHAR},
#{userRegion5,jdbcType=VARCHAR}
)
</insert>
<!-- 根据 compileId 将定时任务失效,定时任务的修改策略为:删除之前的所有配置,新增 -->
<update id="deleteByCompileId" parameterType="com.nis.domain.ScheduleCfg">
update schedule_cfg
<set>
<if test="editorId != null ">
editor_Id = #{editorId,jdbcType=VARCHAR},
</if>
<if test="editTime != null ">
edit_Time = #{editTime,jdbcType=TIMESTAMP},
</if>
del_flag = #{DEL_FLAG_DELETE}
</set>
WHERE compile_Id = #{compileId} and del_flag =1
</update>
<!-- 查找 配置 下发 最新记录 -->
<select id="findScheduleExceNew" resultMap="scheduleExceInfoMap" >
SELECT
id,
schedule_id,
exce_time,
issue_status,
issue_result,
error_info,
compile_id,
is_issue
FROM
schedule_exce_new
WHERE
compile_id = #{compileId} and issue_status = #{isValid}
</select>
<!-- 修改配置表状态 -->
<update id="updateCfgTableStatus">
update ${tableName} set is_valid = #{isValid} ,is_audit = 1 where compile_id = #{compileId}
</update>
<!-- 查询最新的配置状态 -->
<select id="getCfgTableInfo" resultMap="baseCfgMap">
select * from ${tableName} where compile_id = #{compileId};
</select>
<!-- 保存执行记录 -->
<insert id="insertScheduleExceLog" parameterType="com.nis.domain.ScheduleExceInfo">
INSERT INTO schedule_exce_log (
schedule_id,
exce_time,
issue_status,
issue_result,
error_info,
compile_id,
is_issue
) VALUES (
#{scheduleId},
#{exceTime},
#{issueStatus},
#{issueResult},
#{errorInfo},
#{compileId},
0
);
</insert>
<!-- 保存最新记录表 -->
<insert id="insertScheduleExceNew" parameterType="com.nis.domain.ScheduleExceInfo">
INSERT INTO schedule_exce_new (
schedule_id,
exce_time,
issue_status,
issue_result,
error_info,
compile_id,
is_issue
) VALUES (
#{scheduleId},
#{exceTime},
#{issueStatus},
#{issueResult},
#{errorInfo},
#{compileId},
0
);
</insert>
<!-- 更新最新记录表 -->
<update id="updateScheduleExceNew" parameterType="com.nis.domain.ScheduleExceInfo">
UPDATE schedule_exce_new
<set>
<if test="scheduleId != null">
schedule_id = #{scheduleId},
</if>
<if test=" exceTime != null">
exce_time = #{exceTime},
</if>
<if test=" issueResult != null">
issue_result = #{issueResult},
</if>
<if test=" errorInfo != null">
error_info = #{errorInfo},
</if>
<if test=" isIssue != null">
is_issue = #{isIssue},
</if>
</set>
WHERE
compile_Id = #{compileId} and issue_status = #{issueStatus}
</update>
</mapper>

View File

@@ -30,6 +30,12 @@ public interface AsnGroupInfoDao extends CrudDao<AsnGroupInfo> {
Long getCount();
void modifyIssuedIp(AsnGroupInfo info);
List<AsnGroupInfo> findAsnGroupInfoByAsnGroup(AsnGroupInfo asnGroupInfo);
void updateIsUsedAndIsValid(@Param("asnNos")List asnNos,@Param("isUsed")Integer isUsed,@Param("isValid")Integer isValid);
List<AsnGroupInfo> findAsnGroupInfoByAsnNos(@Param("asnNos")List asnNos,@Param("isUsed")Integer isUsed);
void updateIsUsedAndIsValid(@Param("groupIds")List groupIds,@Param("isUsed")Integer isUsed,@Param("isValid")Integer isValid);
List<AsnGroupInfo> findAsnGroupInfoByGroupIds(@Param("groupIds")List groupIds,@Param("isUsed")Integer isUsed);
List<String> findAsnGroupIdByGroupIds(@Param("groupIds")String groupIds);
void deleteAll();
void insertWithId(AsnGroupInfo asnGroupInfo);
void insertWithoutId(AsnGroupInfo asnGroupInfo);
void updateIpNum(@Param("v4Num")long v4Num,@Param("v6Num")long v6Num,@Param("groupId")Integer groupId);
List<Object[]> getASNIPNum(@Param("asnNo")Long asnNo);
}

View File

@@ -17,10 +17,11 @@
<result column="issued_ips" property="issuedIPs" jdbcType="INTEGER" />
<result column="is_used" property="isUsed" jdbcType="INTEGER" />
<result column="region_id" property="regionId" jdbcType="INTEGER" />
<result column="org_group_id" property="orgGroupId" jdbcType="INTEGER" />
</resultMap>
<sql id="AsnGroupInfoColumns">
r.id,r.group_id,r.compile_id,r.organization,r.country,r.detail,r.is_valid,r.create_time,r.edit_time,
r.creator_id,r.editor_id,r.asn_id,r.issued_ips,r.is_used,r.region_id
r.creator_id,r.editor_id,r.asn_id,r.issued_ips,r.is_used,r.region_id,r.org_group_id,r.only_group_id
</sql>
<!-- 查出所有 有效数据-->
@@ -62,6 +63,9 @@
</if>
<if test="isValid != null and isValid != ''">
AND r.is_valid =#{isValid }
</if>
<if test="orgGroupId != null and orgGroupId != ''">
AND r.org_group_id =#{orgGroupId }
</if>
AND r.is_valid !=-1
<!-- 数据范围过滤 -->
@@ -102,7 +106,9 @@
edit_time,
asn_id,
is_used,
region_id
region_id,
org_group_id,
only_group_id
)values (
#{groupId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
@@ -116,10 +122,81 @@
#{editTime,jdbcType=TIMESTAMP},
#{asnId,jdbcType=INTEGER},
#{isUsed,jdbcType=INTEGER},
#{regionId,jdbcType=INTEGER}
#{regionId,jdbcType=INTEGER},
#{orgGroupId,jdbcType=INTEGER},
#{onlyGroupId,jdbcType=INTEGER}
)
</insert>
<insert id="insertWithoutId" parameterType="com.nis.domain.basics.AsnGroupInfo" >
insert into asn_group_info(
group_id,
compile_id,
organization,
country,
detail,
is_valid,
creator_id,
create_time,
editor_id,
edit_time,
asn_id,
is_used,
region_id,
org_group_id
)values (
#{groupId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{organization,jdbcType=VARCHAR},
#{country,jdbcType=VARCHAR},
#{detail,jdbcType=VARCHAR},
#{isValid,jdbcType=INTEGER},
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{asnId,jdbcType=INTEGER},
#{isUsed,jdbcType=INTEGER},
#{regionId,jdbcType=INTEGER},
#{orgGroupId,jdbcType=INTEGER}
)
</insert>
<insert id="insertWithId" parameterType="com.nis.domain.basics.AsnGroupInfo" >
insert into asn_group_info(
id,
group_id,
compile_id,
organization,
country,
detail,
is_valid,
creator_id,
create_time,
editor_id,
edit_time,
asn_id,
is_used,
region_id,
org_group_id,
only_group_id
)values (
#{id,jdbcType=INTEGER},
#{groupId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{organization,jdbcType=VARCHAR},
#{country,jdbcType=VARCHAR},
#{detail,jdbcType=VARCHAR},
#{isValid,jdbcType=INTEGER},
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{asnId,jdbcType=INTEGER},
#{isUsed,jdbcType=INTEGER},
#{regionId,jdbcType=INTEGER},
#{orgGroupId,jdbcType=INTEGER},
#{onlyGroupId,jdbcType=INTEGER}
)
</insert>
<update id="update" parameterType="com.nis.domain.basics.AsnGroupInfo" >
update asn_group_info
<set >
@@ -159,6 +236,9 @@
</if>
<if test="regionId != null" >
region_id = #{regionId,jdbcType=INTEGER},
</if>
<if test="orgGroupId != null" >
org_group_id = #{orgGroupId,jdbcType=INTEGER},
</if>
</trim>
</set>
@@ -181,10 +261,10 @@
</if>
</set>
<where>
<if test="asnNos != null" >
and asn_id in
<foreach collection ="asnNos" item="asnId" separator ="," open="(" close=")">
#{asnId}
<if test="groupIds != null" >
and group_id in
<foreach collection ="groupIds" item="groupId" separator ="," open="(" close=")">
#{groupId}
</foreach >
</if>
<if test="isValid != null" >
@@ -351,7 +431,7 @@
</if>
</where>
</select>
<select id="findAsnGroupInfoByAsnNos" resultMap="AsnGroupInfoMap">
<select id="findAsnGroupInfoByGroupIds" resultMap="AsnGroupInfoMap">
SELECT
<include refid="AsnGroupInfoColumns"/>
FROM
@@ -360,12 +440,31 @@
<if test="isUsed != null" >
AND r.is_used = #{isUsed,jdbcType=INTEGER}
</if>
<if test="asnNos != null" >
and r.asn_id in
<foreach collection ="asnNos" item="asnId" separator ="," open="(" close=")">
#{asnId}
</foreach >
<if test="groupIds != null" >
and r.group_id in
<foreach collection ="groupIds" item="groupId" separator ="," open="(" close=")">
#{groupId}
</foreach >
</if>
</where>
</select>
<select id="findAsnGroupIdByGroupIds" resultType="java.lang.String">
SELECT
group_id
FROM
asn_group_info r
<where>
AND r.is_valid != -1
and r.group_id in (${groupIds})
</where>
</select>
<delete id="deleteAll" >
delete from asn_group_info
</delete>
<update id="updateIpNum" >
update asn_group_info set v4_num=#{v4Num},v6_num=#{v6Num} where group_id=#{groupId}
</update>
<select id="getASNIPNum" resultType="map">
select v4_num,v6_num from asn_group_info where asn_id=#{asnNo}
</select>
</mapper>

View File

@@ -33,6 +33,8 @@ public interface AsnIpCfgDao extends CrudDao<AsnIpCfg>{
public void ajaxDeleteAsnIp(@Param("ids")String ids);
public int hasValidAsnIp(@Param("asnId")Long asnNo);
public AsnIpCfg getOne(AsnIpCfg cfg);
public void updateAsn(@Param("asnId")String asnNo,@Param("organization")String organization,@Param("country")String country,@Param("detail")String detail);
public void updateAsn(@Param("asnId")String asnNo,@Param("organization")String organization,@Param("country")String country,@Param("detail")String detail,@Param("groupId")String groupId);
public void updateAsnIpByAsnGroups(@Param("entity")AsnIpCfg entity,@Param("asnGroups")List<AsnGroupInfo> asnGroups,@Param("asnIds")String asnIds);
public void deleteAll();
public List<Object[]> findAllAsnIpCfgList();
}

View File

@@ -560,7 +560,7 @@
delete from asn_ip_cfg where asn_ip_group in (${ids})
</update>
<update id="updateAsn" parameterType="java.lang.String" >
update asn_ip_cfg set organization=#{organization}, country=#{country}, detail=#{detail} where user_region1 =#{asnId} and is_valid=0
update asn_ip_cfg set organization=#{organization}, country=#{country}, detail=#{detail},user_region1 =#{asnId} where asn_ip_group =#{groupId} and is_valid=0
</update>
<select id="findOtherIps" resultType="java.lang.Integer" parameterType="java.lang.Integer">
select 1 from asn_ip_cfg where is_valid=1 and asn_ip_group=#{groupId} and cfg_id !=#{cfgId} limit 1
@@ -668,5 +668,13 @@
</if>
</where>
</update>
<delete id="deleteAll" >
delete from asn_ip_cfg
</delete>
<select id="findAllAsnIpCfgList" resultType="map">
select
<include refid="columns"></include>
from asn_ip_cfg r
where r.is_valid !=-1
</select>
</mapper>

View File

@@ -26,4 +26,5 @@ public interface PolicyGroupInfoDao extends CrudDao<PolicyGroupInfo> {
PolicyGroupInfo getGroupInfo(PolicyGroupInfo policyGroupInfo);
List<PolicyGroupInfo> findPolicyByGroupInfoList(@Param("ids")String ids);
List<PolicyGroupInfo> findPolicyGroupInfosByTypeForUD(@Param("groupType")Integer groupType,@Param("flag")Integer flag);
}

View File

@@ -251,19 +251,29 @@
</trim>
</select>
<!-- 查出所有 有效数据-->
<select id="findPolicyByGroupInfoList" resultMap="PolicyGroupInfoMap">
<!-- 查出所有 有效数据-->
<select id="findPolicyByGroupInfoList" resultMap="PolicyGroupInfoMap">
SELECT
<include refid="PolicyGroupInfoColumns"/>
<trim prefix="," prefixOverrides=",">
, s.name as creator_name
,e.name as editor_name
</trim>
FROM policy_group_info r
left join sys_user s on r.creator_id=s.id
left join sys_user e on r.editor_id=e.id
where r.CFG_ID in (${ids})
FROM
policy_group_info r
left join sys_user s on r.creator_id=s.id
left join sys_user e on r.editor_id=e.id
WHERE
r.group_id IN (${ids})
</select>
<select id="findPolicyGroupInfosByTypeForUD" resultMap="PolicyGroupInfoMap">
SELECT
<include refid="PolicyGroupInfoColumns"/>
FROM policy_group_info r
where r.is_valid=1 and r.group_type=#{groupType,jdbcType=INTEGER}
<if test="flag!=null and flag != ''">
and ud_flag=#{flag}
</if>
</select>
</mapper>

View File

@@ -0,0 +1,38 @@
package com.nis.web.dao.basics;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.nis.domain.basics.UrlCommGroupCfg;
import com.nis.web.dao.CrudDao;
import com.nis.web.dao.MyBatisDao;
@MyBatisDao
public interface UrlCommGroupDao extends CrudDao<UrlCommGroupCfg>{
// 查询列表
public List<UrlCommGroupCfg> findAllPageList(UrlCommGroupCfg entity);
public List<UrlCommGroupCfg> findByPage(@Param("ids")String ids);
public List<UrlCommGroupCfg> findInfoByCfgId(@Param("cfgId")Long cfgId);
//新增
public int insertUrlCommGroupCfg(UrlCommGroupCfg entity);
public Integer findUrlUdFlag(@Param("groupId")Integer groupId);
public int updateUrlUdFlag(@Param("groupId")Integer groupId,@Param("udFlag")Integer udFlag);
//修改
public int update(UrlCommGroupCfg entity);
//删除
public int delete(@Param("ids")String ids);
public List<UrlCommGroupCfg> getByIds(@Param("ids")String ids);
public Integer getGroupIdCount(@Param("groupId")String groupId);
}

View File

@@ -0,0 +1,388 @@
<?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.nis.web.dao.basics.UrlCommGroupDao">
<resultMap id="urlCommGroupCfgMap" type="com.nis.domain.basics.UrlCommGroupCfg">
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="cfg_keywords" property="cfgKeywords" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="expr_type" property="exprType" jdbcType="INTEGER" />
<result column="match_method" property="matchMethod" jdbcType="INTEGER" />
<result column="is_hexbin" property="isHexbin" jdbcType="INTEGER" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
<result column="ratelimit" property="ratelimit" jdbcType="VARCHAR" />
<result column="user_region1" property="userRegion1" jdbcType="VARCHAR" />
<result column="user_region2" property="userRegion2" jdbcType="VARCHAR" />
<result column="user_region3" property="userRegion3" jdbcType="VARCHAR" />
<result column="user_region4" property="userRegion4" jdbcType="VARCHAR" />
<result column="user_region5" property="userRegion5" jdbcType="VARCHAR" />
<result column="group_name" property="groupName" jdbcType="VARCHAR" />
</resultMap>
<select id="findAllPageList" parameterType="com.nis.domain.basics.UrlCommGroupCfg" resultMap="urlCommGroupCfgMap">
SELECT
r.cfg_id,r.cfg_desc,r.cfg_keywords,r.action,r.is_valid,r.is_audit,r.creator_id,
r.create_time,r.editor_id,r.edit_time,r.auditor_id,r.audit_time,r.service_id,
r.request_id,r.compile_id,r.is_area_effective,r.classify,r.attribute,r.lable,
r.expr_type,r.match_method,r.is_hexbin,r.area_effective_ids,r.function_id,
r.cfg_region_code,r.cfg_type,r.ratelimit,r.user_region1,r.user_region2,
r.user_region3,r.user_region4,r.user_region5,
s.name AS creator_name,e.name AS editor_name,u.name AS auditor_name,c.group_name
FROM
http_url_cfg r
LEFT JOIN sys_user s ON r.creator_id = s.id
LEFT JOIN sys_user e ON r.editor_id = e.id
LEFT JOIN sys_user u ON r.auditor_id = u.id
LEFT JOIN policy_group_info c ON c.service_group_id=r.user_region3
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="page !=null and page.where != null and page.where != ''">
AND ${page.where}
</if>
<if test="cfgId != null">
AND r.CFG_ID=#{cfgId,jdbcType=BIGINT}
</if>
<if test="cfgDesc != null and cfgDesc != ''">
AND r.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
</if>
<if test="cfgKeywords != null and cfgKeywords != ''">
AND r.cfg_keywords like concat(concat('%',#{cfgKeywords,jdbcType=VARCHAR}),'%')
</if>
<if test="cfgRegionCode != null">
AND r.CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER}
</if>
<if test="cfgType != null and cfgType != ''">
AND r.CFG_TYPE like concat(concat('%',#{cfgType,jdbcType=VARCHAR}),'%')
</if>
<if test="action != null">
AND r.ACTION=#{action,jdbcType=INTEGER}
</if>
<if test="isValid != null">
AND r.IS_VALID=#{isValid,jdbcType=INTEGER}
</if>
<if test="isValid == null">
AND r.IS_VALID != -1
</if>
<if test="isAudit != null">
AND r.IS_AUDIT=#{isAudit,jdbcType=INTEGER}
</if>
<if test="creatorName != null and creatorName !=''">
AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
</if>
<if test="createTime != null and createTime !=''">
AND r.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP}
</if>
<if test="editorName != null and editorName !=''">
AND EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
</if>
<if test="editTime != null and editTime !='' ">
AND r.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP}
</if>
<if test="auditorName != null and auditorName !=''">
AND AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%')
</if>
<if test="auditTime != null and auditTime !=''">
AND r.AUDIT_TIME=#{auditTime,jdbcType=TIMESTAMP}
</if>
<if test="serviceId != null">
AND r.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
</if>
<if test="requestId != null">
AND r.REQUEST_ID=#{requestId,jdbcType=INTEGER}
</if>
<if test="isAreaEffective != null">
AND r.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
</if>
<if test="classify != null and classify !=''">
AND r.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%')
</if>
<if test="attribute != null and attribute !=''">
AND r.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%')
</if>
<if test="lable != null and lable !=''">
AND r.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%')
</if>
<if test="areaEffectiveIds != null and areaEffectiveIds !=''">
AND r.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%')
</if>
<if test="functionId != null">
AND r.FUNCTION_ID=#{functionId,jdbcType=INTEGER}
</if>
<!-- 数据范围过滤 -->
${sqlMap.dsf}
</trim>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY r.is_audit,r.create_time desc
</otherwise>
</choose>
</select>
<select id="findByPage" resultMap="urlCommGroupCfgMap">
SELECT
r.cfg_id,r.cfg_desc,r.cfg_keywords,r.action,r.is_valid,r.is_audit,r.creator_id,
r.create_time,r.editor_id,r.edit_time,r.auditor_id,r.audit_time,r.service_id,
r.request_id,r.compile_id,r.is_area_effective,r.classify,r.attribute,r.lable,
r.expr_type,r.match_method,r.is_hexbin,r.area_effective_ids,r.function_id,
r.cfg_region_code,r.cfg_type,r.ratelimit,r.user_region1,r.user_region2,
r.user_region3,r.user_region4,r.user_region5,
s.name AS creator_name,e.name AS editor_name,u.name AS auditor_name
FROM
http_url_cfg r
LEFT JOIN sys_user s ON r.creator_id = s.id
LEFT JOIN sys_user e ON r.editor_id = e.id
LEFT JOIN sys_user u ON r.auditor_id = u.id
where r.CFG_ID in (${ids})
</select>
<select id="findInfoByCfgId" resultMap="urlCommGroupCfgMap">
SELECT
r.cfg_id,r.cfg_desc,r.cfg_keywords,r.action,r.is_valid,r.is_audit,r.creator_id,
r.create_time,r.editor_id,r.edit_time,r.auditor_id,r.audit_time,r.service_id,
r.request_id,r.compile_id,r.is_area_effective,r.classify,r.attribute,r.lable,
r.expr_type,r.match_method,r.is_hexbin,r.area_effective_ids,r.function_id,
r.cfg_region_code,r.cfg_type,r.ratelimit,r.user_region1,r.user_region2,
r.user_region3,r.user_region4,r.user_region5
FROM
http_url_cfg r
where r.CFG_ID =#{cfgId}
</select>
<select id="get" resultMap="urlCommGroupCfgMap">
SELECT
r.cfg_id,r.cfg_desc,r.cfg_keywords,r.action,r.is_valid,r.is_audit,r.creator_id,
r.create_time,r.editor_id,r.edit_time,r.auditor_id,r.audit_time,r.service_id,
r.request_id,r.compile_id,r.is_area_effective,r.classify,r.attribute,r.lable,
r.expr_type,r.match_method,r.is_hexbin,r.area_effective_ids,r.function_id,
r.cfg_region_code,r.cfg_type,r.ratelimit,r.user_region1,r.user_region2,
r.user_region3,r.user_region4,r.user_region5
from http_url_cfg r
where r.cfg_id=#{cfgId}
</select>
<insert id="insertUrlCommGroupCfg" parameterType="com.nis.domain.basics.UrlCommGroupCfg">
insert into http_url_cfg (
CFG_DESC,
cfg_keywords,
action,
is_valid,
is_audit,
creator_id,
create_time,
editor_id,
edit_time,
auditor_id,
audit_time,
service_id,
request_id,
compile_id,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
expr_type,
match_method,
is_hexbin,
area_effective_ids,
function_id,
cfg_region_code,
cfg_type,
ratelimit,
user_region1,
user_region2,
user_region3,
user_region4,
user_region5
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{cfgKeywords,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
#{isValid,jdbcType=INTEGER},
#{isAudit,jdbcType=INTEGER},
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{exprType,jdbcType=INTEGER},
#{matchMethod,jdbcType=INTEGER},
#{isHexbin,jdbcType=INTEGER},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER},
#{cfgRegionCode,jdbcType=INTEGER},
#{cfgType,jdbcType=VARCHAR},
#{ratelimit,jdbcType=VARCHAR},
#{userRegion1,jdbcType=VARCHAR},
#{userRegion2,jdbcType=VARCHAR},
#{userRegion3,jdbcType=VARCHAR},
#{userRegion4,jdbcType=VARCHAR},
#{userRegion5,jdbcType=VARCHAR}
)
</insert>
<select id="findUrlUdFlag" parameterType="java.lang.Integer" resultType="java.lang.Integer">
SELECT ud_flag from policy_group_info
where service_group_id=#{groupId}
and group_type=11
</select>
<update id="updateUrlUdFlag" parameterType="java.lang.Integer">
UPDATE policy_group_info SET ud_flag =#{udFlag}
WHERE service_group_id=#{groupId}
and group_type=11
</update>
<update id="update" parameterType="com.nis.domain.basics.UrlCommGroupCfg" >
update http_url_cfg
<set >
<trim suffixOverrides=",">
<if test="cfgDesc != null and cfgDesc != ''" >
cfg_desc = #{cfgDesc,jdbcType=VARCHAR},
</if>
<if test="cfgKeywords != null and cfgKeywords != ''" >
cfg_keywords = #{cfgKeywords,jdbcType=VARCHAR},
</if>
<if test="action != null" >
action = #{action,jdbcType=INTEGER},
</if>
<if test="isValid != null" >
is_valid = #{isValid,jdbcType=INTEGER},
</if>
<if test="isAudit != null" >
is_audit = #{isAudit,jdbcType=INTEGER},
</if>
<if test="editorId != null" >
editor_id = #{editorId,jdbcType=INTEGER},
</if>
<if test="editTime != null and editTime != ''" >
edit_time = #{editTime,jdbcType=TIMESTAMP},
</if>
<if test="auditorId != null" >
AUDITOR_ID = #{auditorId,jdbcType=INTEGER},
</if>
<if test="auditTime != null and auditTime != ''" >
AUDIT_TIME = #{auditTime,jdbcType=TIMESTAMP},
</if>
<if test="serviceId != null" >
service_id = #{serviceId,jdbcType=INTEGER},
</if>
<if test="requestId != null" >
request_id = #{requestId,jdbcType=INTEGER},
</if>
<if test="compileId != null and compileId != ''" >
compile_id = #{compileId,jdbcType=INTEGER},
</if>
<if test="isAreaEffective != null" >
is_area_effective = #{isAreaEffective,jdbcType=INTEGER},
</if>
<if test="classify != null and classify != ''" >
classify = #{classify,jdbcType=VARCHAR},
</if>
<if test="attribute != null and attribute != ''" >
attribute = #{attribute,jdbcType=VARCHAR},
</if>
<if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR},
</if>
<if test="exprType != null" >
expr_type = #{exprType,jdbcType=INTEGER},
</if>
<if test="matchMethod != null" >
match_method = #{matchMethod,jdbcType=INTEGER},
</if>
<if test="isHexbin != null" >
is_hexbin = #{isHexbin,jdbcType=INTEGER},
</if>
<if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
</if>
<if test="functionId != null" >
function_id = #{functionId,jdbcType=INTEGER},
</if>
<if test="cfgType != null and cfgType != ''" >
cfg_type = #{cfgType,jdbcType=VARCHAR},
</if>
<if test="cfgRegionCode != null " >
cfg_region_code = #{cfgRegionCode,jdbcType=INTEGER},
</if>
<if test="ratelimit != null and ratelimit != ''" >
ratelimit = #{ratelimit,jdbcType=VARCHAR},
</if>
<if test="userRegion1 != null and userRegion1 != ''" >
user_region1 = #{userRegion1,jdbcType=VARCHAR},
</if>
<if test="userRegion2 != null and userRegion2 != ''" >
user_region2 = #{userRegion2,jdbcType=VARCHAR},
</if>
<if test="userRegion3 != null and userRegion3 != ''" >
user_region3 = #{userRegion3,jdbcType=VARCHAR},
</if>
<if test="userRegion4 != null and userRegion4 != ''" >
user_region4 = #{userRegion4,jdbcType=VARCHAR},
</if>
<if test="userRegion5 != null and userRegion5 != ''" >
user_region5 = #{userRegion5,jdbcType=VARCHAR},
</if>
</trim>
</set>
<where>
and cfg_id = #{cfgId,jdbcType=INTEGER}
</where>
</update>
<delete id="delete" parameterType="java.lang.String" >
delete from http_url_cfg where cfg_id in (${ids})
</delete>
<select id="getByIds" resultMap="urlCommGroupCfgMap">
select
r.cfg_id,r.cfg_desc,r.cfg_keywords,r.action,r.is_valid,r.is_audit,r.creator_id,
r.create_time,r.editor_id,r.edit_time,r.auditor_id,r.audit_time,r.service_id,
r.request_id,r.compile_id,r.is_area_effective,r.classify,r.attribute,r.lable,
r.expr_type,r.match_method,r.is_hexbin,r.area_effective_ids,r.function_id,
r.cfg_region_code,r.cfg_type,r.ratelimit,r.user_region1,r.user_region2,
r.user_region3,r.user_region4,r.user_region5
from http_url_cfg r
where r.cfg_id in (${ids}) and is_valid !=-1
</select>
<select id="getGroupIdCount" parameterType="java.lang.String" resultType="java.lang.Integer">
SELECT COUNT(cfg_id) groupCount from http_url_cfg
WHERE user_region3= #{groupId}
and is_valid=1
</select>
</mapper>

View File

@@ -123,4 +123,6 @@ public interface AppCfgDao {
//app ssl证书特征配置CRUD
public List<AppSslCertCfg> findAppBySslList(@Param("ids")String ids);
//查找此分组下是否有App IP
public List<AppIpCfg> findAppIpByCompileId(@Param("compileId")Integer compileId) ;
}

View File

@@ -136,6 +136,7 @@
<result column="ratelimit" property="ratelimit" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="do_log" property="doLog" jdbcType="INTEGER" />
<result column="user_region5" property="userRegion5" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="AppTopicDomainCfgMap" type="com.nis.domain.configuration.AppTopicDomainCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
@@ -410,7 +411,7 @@
r.CREATOR_ID,r.CREATE_TIME,r.EDITOR_ID,r.EDIT_TIME,r.AUDITOR_ID,r.AUDIT_TIME,
r.SERVICE_ID,r.REQUEST_ID,r.COMPILE_ID,r.IS_AREA_EFFECTIVE,r.CLASSIFY,
r.ATTRIBUTE,r.LABLE,r.AREA_EFFECTIVE_IDS,r.RATELIMIT,r.FUNCTION_ID,r.CFG_TYPE,r.CFG_REGION_CODE,
r.DOMAIN,r.EXPR_TYPE,r.MATCH_METHOD,r.IS_HEXBIN,r.DO_LOG
r.DOMAIN,r.EXPR_TYPE,r.MATCH_METHOD,r.IS_HEXBIN,r.DO_LOG,r.USER_REGION5
</sql>
<sql id="AppTopicDomainCfg_Column" >
@@ -1818,11 +1819,11 @@
CREATOR_ID,CREATE_TIME,EDITOR_ID,EDIT_TIME,AUDITOR_ID,AUDIT_TIME,
SERVICE_ID,REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,CLASSIFY,
ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS,RATELIMIT,FUNCTION_ID,CFG_TYPE,CFG_REGION_CODE,
DOMAIN,EXPR_TYPE,MATCH_METHOD,IS_HEXBIN,DO_LOG
DOMAIN,EXPR_TYPE,MATCH_METHOD,IS_HEXBIN,DO_LOG,USER_REGION5
)values (
<include refid="AppCommonCfg_Value_List" />,
#{cfgKeywords,jdbcType=VARCHAR},#{exprType,jdbcType=INTEGER},#{matchMethod,jdbcType=INTEGER},
#{isHexbin,jdbcType=INTEGER},#{doLog,jdbcType=INTEGER}
#{isHexbin,jdbcType=INTEGER},#{doLog,jdbcType=INTEGER},#{userRegion5,jdbcType=VARCHAR}
)
</insert>
<insert id="insertAppDomainCfgBatch" parameterType="com.nis.domain.configuration.AppDomainCfg" >
@@ -2424,6 +2425,9 @@
<if test="doLog != null" >
do_log = #{doLog,jdbcType=INTEGER},
</if>
<if test="userRegion5 != null" >
USER_REGION5 = #{userRegion5,jdbcType=INTEGER},
</if>
</trim>
</set>
where cfg_id = #{cfgId,jdbcType=BIGINT}
@@ -3109,4 +3113,7 @@
left join request_info ri on r.request_id=ri.id
where r.CFG_ID in (${ids})
</select>
<select id="findAppIpByCompileId" resultMap="AppIpCfgMap">
select * from app_ip_cfg where is_valid=1 and compile_Id = #{compileId}
</select>
</mapper>

View File

@@ -1,34 +1,16 @@
package com.nis.web.dao.configuration;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.nis.domain.configuration.AppByteCfg;
import com.nis.domain.configuration.AppComplexFeatureCfg;
import com.nis.domain.configuration.AppComplexKeywordCfg;
import com.nis.domain.configuration.AppDomainCfg;
import com.nis.domain.configuration.AppFeatureIndex;
import com.nis.domain.configuration.AppHeaderCfg;
import com.nis.domain.configuration.AppHttpCfg;
import com.nis.domain.configuration.AppIdCfg;
import com.nis.domain.configuration.AppIdCfg.AppFeaturesIndex;
import com.nis.domain.configuration.AppInnerRuleCfg;
import com.nis.domain.configuration.AppFeatureProperties;
import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.configuration.AppPolicyCfg;
import com.nis.domain.configuration.AppSslCertCfg;
import com.nis.domain.configuration.AppStringCfg;
import com.nis.domain.configuration.AppStringFeatureCfg;
import com.nis.domain.configuration.AppTcpCfg;
import com.nis.domain.configuration.AppTopicDomainCfg;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.WebsiteDomainTopic;
import com.nis.web.dao.CrudDao;
import com.nis.web.dao.MyBatisDao;
@@ -59,6 +41,8 @@ public interface AppMultiFeatureCfgDao {
//数值类特征配置
public List<AppTcpCfg> getAppTcpCfg(@Param("compileId")Integer compileId,
@Param("functionId")Integer functionId,@Param("cfgRegionCode")Integer cfgRegionCode);
public List<AppComplexFeatureCfg> getAppComplexFeatureCfgNotRegionCode(@Param("compileId")Integer compileId,
@Param("functionId")Integer functionId,@Param("cfgRegionCode")Integer cfgRegionCode);
public int insertAppTcpCfg(AppTcpCfg entity);
public void deleteAppTcpCfg(BaseCfg entity);
@@ -71,4 +55,11 @@ public interface AppMultiFeatureCfgDao {
public void deleteAppIpRangeCfg(BaseCfg entity);
public List<AppFeatureIndex> findAppByFeatureIndexList(@Param("ids")String ids);
//App特征属性配置
public List<AppFeatureProperties> getAppFeaturePropCfg(@Param("compileId")Integer compileId,
@Param("functionId")Integer functionId,@Param("cfgRegionCode")Integer cfgRegionCode);
public int insertAppFeaturePropCfg(AppFeatureProperties entity);
public void deleteAppFeaturePropCfg(BaseCfg entity);
}

View File

@@ -118,6 +118,12 @@
<result column="payload_offset" property="payloadOffset" jdbcType="INTEGER" />
<result column="payload_size" property="payloadSize" jdbcType="INTEGER" />
<result column="payload_packet_direction" property="payloadPacketDirection" jdbcType="VARCHAR" />
<result column="user_region1" property="userRegion1" jdbcType="VARCHAR" />
<result column="user_region2" property="userRegion2" jdbcType="VARCHAR" />
<result column="user_region3" property="userRegion3" jdbcType="VARCHAR" />
<result column="user_region4" property="userRegion4" jdbcType="VARCHAR" />
<result column="user_region5" property="userRegion5" jdbcType="VARCHAR" />
</resultMap>
<!-- APP字符串类配置映射 -->
<resultMap id="AppStringFeatureCfgMap" type="com.nis.domain.configuration.AppStringFeatureCfg" >
@@ -181,6 +187,36 @@
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="do_log" property="doLog" jdbcType="INTEGER" />
</resultMap>
<!-- APP 特征属性配置映射 -->
<resultMap id="AppFeaturePropCfgMap" type="com.nis.domain.configuration.AppFeatureProperties" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="drop_opt" property="dropOpt" jdbcType="INTEGER" />
<result column="loop_opt" property="loopOpt" jdbcType="INTEGER" />
<result column="weak_feature" property="weakFeature" jdbcType="VARCHAR" />
<result column="whitelist_feature" property="whitelistFeature" jdbcType="VARCHAR" />
<result column="extend_scan_pkt_num" property="extendScanPktNum" jdbcType="INTEGER" />
<result column="correlation_valid_time" property="correlationValidTime" jdbcType="INTEGER" />
<result column="correlation_block_after" property="correlationBlockAfter" jdbcType="VARCHAR" />
<result column="long_stream_lock_time" property="longStreamLockTime" jdbcType="INTEGER" />
</resultMap>
<sql id="AppFeaturePropCfg_Column" >
r.CFG_ID, r.compile_id,r.function_id,r.service_id,r.request_id,r.is_valid,
r.is_audit,r.creator_id,r.create_time,r.editor_id,r.edit_time,r.auditor_id,r.audit_time,
r.drop_opt,r.loop_opt,r.weak_feature,r.whitelist_feature,
r.extend_scan_pkt_num,r.correlation_valid_time,r.correlation_block_after,r.long_stream_lock_time
</sql>
<sql id="AppFeatureIndex_Column" >
r.CFG_ID,r.CFG_DESC,r.ACTION,r.IS_VALID,r.IS_AUDIT,
@@ -206,6 +242,7 @@
r.SERVICE_ID,r.REQUEST_ID,r.COMPILE_ID,r.IS_AREA_EFFECTIVE,r.CLASSIFY,
r.ATTRIBUTE,r.LABLE,r.AREA_EFFECTIVE_IDS,r.FUNCTION_ID,r.CFG_TYPE,r.CFG_REGION_CODE,
r.DISTRICT,r.CFG_KEYWORDS,r.EXPR_TYPE,r.MATCH_METHOD,r.IS_HEXBIN,r.DO_LOG,
r.USER_REGION1,r.USER_REGION2,r.USER_REGION3,r.USER_REGION4,r.USER_REGION5,
r.ver,r.ihl,r.tos,r.total_length,r.flags,r.fragment_offset,r.protocol,r.icmp_type,r.icmp_code,r.icmp_identifier,
r.header_type,r.payload_offset,r.payload_size,r.payload_packet_direction
</sql>
@@ -511,6 +548,16 @@
AND r.cfg_region_code = #{cfgRegionCode,jdbcType=BIGINT}
</if>
</select>
<select id="getAppComplexFeatureCfgNotRegionCode" resultMap="AppComplexFeatureCfgMap">
SELECT
<include refid="AppComplexFeatureCfg_Column" />
FROM app_complex_feature_cfg r
WHERE r.compile_id=#{compileId} and r.function_id=#{functionId}
<if test="cfgRegionCode !=null ">
AND r.cfg_region_code != #{cfgRegionCode,jdbcType=BIGINT}
</if>
</select>
<!-- 新增app_ip_range子配置 -->
<insert id="insertAppIpRangeCfg" parameterType="com.nis.domain.configuration.AppIpCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
@@ -653,5 +700,39 @@
where r.CFG_ID in (${ids})
</select>
<insert id="insertAppFeaturePropCfg" parameterType="com.nis.domain.configuration.AppFeatureProperties" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into app_feature_prop_cfg(
compile_id,function_id,service_id,request_id,is_valid,
is_audit,creator_id,create_time,editor_id,edit_time,auditor_id,
audit_time,drop_opt,loop_opt,weak_feature,whitelist_feature,
extend_scan_pkt_num,correlation_valid_time,correlation_block_after,long_stream_lock_time
)values (
#{compileId,jdbcType=INTEGER},#{functionId,jdbcType=INTEGER},#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},#{isValid,jdbcType=INTEGER},#{isAudit,jdbcType=INTEGER},
#{creatorId,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},#{auditorId,jdbcType=INTEGER},#{auditTime,jdbcType=TIMESTAMP},
#{dropOpt,jdbcType=INTEGER},#{loopOpt,jdbcType=INTEGER},
#{weakFeature,jdbcType=VARCHAR},#{whitelistFeature,jdbcType=VARCHAR},#{extendScanPktNum,jdbcType=INTEGER},
#{correlationValidTime,jdbcType=INTEGER},#{correlationBlockAfter,jdbcType=VARCHAR},
#{longStreamLockTime,jdbcType=INTEGER}
)
</insert>
<!-- 删除App 特征属性子配置 -->
<delete id="deleteAppFeaturePropCfg" >
delete from app_feature_prop_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
<!-- 查询特征属性配置列表 -->
<select id="getAppFeaturePropCfg" resultMap="AppFeaturePropCfgMap">
SELECT
<include refid="AppFeaturePropCfg_Column" />
FROM app_feature_prop_cfg r
WHERE r.compile_id=#{compileId} and r.function_id=#{functionId}
<if test="cfgRegionCode !=null ">
AND r.cfg_region_code = #{cfgRegionCode,jdbcType=BIGINT}
</if>
</select>
</mapper>

View File

@@ -65,7 +65,7 @@
<result column="user_region3" property="userRegion3" jdbcType="VARCHAR" />
<result column="user_region4" property="userRegion4" jdbcType="VARCHAR" />
<result column="user_region5" property="userRegion5" jdbcType="VARCHAR" />
<result column="source_compile_id" property="sourceCompileId" jdbcType="INTEGER" />
<!-- <result column="source_compile_id" property="sourceCompileId" jdbcType="INTEGER" /> -->
<result column="cancel_request_id" property="cancelRequestId" jdbcType="INTEGER" />
<result column="do_blacklist" property="doBlackList" jdbcType="INTEGER" />
</resultMap>

View File

@@ -99,4 +99,6 @@ public interface ConfigSynchronizationDao {
public List<AppIpCfg> getAppIpFeatureList(BaseCfg entity);
public void updateCfgStatus(BaseCfg entity);
public PxyObjSpoofingIpPool getPxyObjSpoofingIpPool(Long cfgId);
}

View File

@@ -733,6 +733,39 @@
<result column="dns_strategy_id" property="dnsStrategyId" jdbcType="INTEGER" />
<result column="dns_strategy_name" property="dnsStrategyName" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="PxyObjSpoofingPoolMap" type="com.nis.domain.configuration.PxyObjSpoofingIpPool" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
<result column="ip_type" property="ipType" jdbcType="INTEGER" />
<result column="ip_address" property="ipAddress" jdbcType="VARCHAR" />
<result column="direction" property="direction" jdbcType="INTEGER" />
<result column="protocol" property="protocol" jdbcType="INTEGER" />
<result column="location" property="location" jdbcType="INTEGER" />
<result column="port" property="port" jdbcType="VARCHAR" />
<!-- <result column="action" property="action" jdbcType="INTEGER" /> -->
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="location" property="location" jdbcType="INTEGER"/>
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="group_id" property="groupId" jdbcType="INTEGER" />
<result column="group_name" property="groupName" jdbcType="INTEGER" />
<result column="user_region" property="userRegion" jdbcType="VARCHAR" />
</resultMap>
<sql id="BaseCfg_Column" >
a.cfg_id,a.cfg_desc,a.action,a.is_valid,a.is_audit,a.creator_id,a.audit_time,
a.service_id,a.request_id,a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable,
@@ -877,12 +910,13 @@
a.ip_type,a.src_ip_address,a.ip_pattern,a.port_pattern,a.src_port
,a.protocol,a.direction,a.dest_port,a.dest_ip_address,a.cfg_type,a.compile_id
</sql>
<sql id="PxyObjSpoofingIpPoolColumns">
a.CFG_ID, a.CFG_DESC,a.CFG_REGION_CODE, a.IP_TYPE, a.IP_ADDRESS,
a.DIRECTION,a.PROTOCOL,a.IS_VALID,a.IS_AUDIT,a.location,a.port,
a.CREATOR_ID,a.CREATE_TIME,a.EDITOR_ID,a.EDIT_TIME,a.AUDITOR_ID,a.AUDIT_TIME,
a.SERVICE_ID,a.REQUEST_ID,a.COMPILE_ID,a.IS_AREA_EFFECTIVE,a.CLASSIFY,
a.ATTRIBUTE,a.LABLE,a.AREA_EFFECTIVE_IDS,a.FUNCTION_ID,a.GROUP_ID,a.user_region
<sql id="PxyObjSpoofingIpPoolColumns">
r.CFG_ID, r.CFG_DESC,r.CFG_REGION_CODE, r.IP_TYPE, r.IP_ADDRESS,
r.DIRECTION,r.PROTOCOL,r.IS_VALID,r.IS_AUDIT,r.location,r.port,
r.CREATOR_ID,r.CREATE_TIME,r.EDITOR_ID,r.EDIT_TIME,r.AUDITOR_ID,r.AUDIT_TIME,
r.SERVICE_ID,r.REQUEST_ID,r.COMPILE_ID,r.IS_AREA_EFFECTIVE,r.CLASSIFY,
r.ATTRIBUTE,r.LABLE,r.AREA_EFFECTIVE_IDS,r.FUNCTION_ID,r.GROUP_ID,r.user_region
</sql>
<!-- <sql id="WebsiteDomainTopic_Column">
id,website_service_id websiteServiceId,domain,topic_id topicId,create_time createTime,creator_id creatorId,is_valid isValid
@@ -938,7 +972,16 @@
<if test="action != null">
AND a.action=#{action,jdbcType=INTEGER}
</if>
and a.is_valid=#{isValid} and a.is_audit=#{isAudit} and a.is_valid!=-1
<if test="isValid != null">
AND a.is_valid=#{isValid,jdbcType=INTEGER}
</if>
<if test="isAudit != null">
AND a.is_audit=#{isAudit,jdbcType=INTEGER}
</if>
<if test="compileId != null">
AND a.compile_id=#{compileId,jdbcType=INTEGER}
</if>
and a.is_valid!=-1
</trim>
ORDER BY a.CFG_ID
</select>
@@ -961,7 +1004,16 @@
<if test="action != null">
AND a.action=#{action,jdbcType=INTEGER}
</if>
and a.is_valid=#{isValid} and a.is_audit=#{isAudit} and a.is_valid!=-1
<if test="isValid != null">
AND a.is_valid=#{isValid,jdbcType=INTEGER}
</if>
<if test="isAudit != null">
AND a.is_audit=#{isAudit,jdbcType=INTEGER}
</if>
<if test="compileId != null">
AND a.compile_id=#{compileId,jdbcType=INTEGER}
</if>
and a.is_valid!=-1
</trim>
ORDER BY a.CFG_ID
</select>
@@ -1602,6 +1654,13 @@
and function_id=#{functionId,jdbcType=INTEGER}
</trim>
</update>
<select id="getPxyObjSpoofingIpPool" resultMap="PxyObjSpoofingPoolMap" >
SELECT
<include refid="PxyObjSpoofingIpPoolColumns"/>
FROM pxy_obj_spoofing_ip_pool r
where r.CFG_ID=#{cfgId,jdbcType=BIGINT}
</select>
<!-- <select id="findAppPolicyList" resultMap="AppPolicyCfgMap" parameterType="com.nis.domain.configuration.AppPolicyCfg" >
select
<include refid="AppPolicyCfg_Column"/>

View File

@@ -0,0 +1,27 @@
package com.nis.web.dao.configuration;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.DnsKeywordCfg;
import com.nis.web.dao.CrudDao;
import com.nis.web.dao.MyBatisDao;
/**
* @ClassName:DnsKeyworkCfgDao
* @Description:TODO(这里用一句话描述这个类的作用)
* @author zdx
* @date 2019年2月15日 下午5:55:26
* @version V1.0
*/
@MyBatisDao
public interface DnsKeywordCfgDao extends CrudDao<DnsKeywordCfg>{
public void saveDnsKeywordsCfg(ComplexkeywordCfg entity);
public List<DnsKeywordCfg> findPage(DnsKeywordCfg entity);
public List<DnsKeywordCfg> getByIds(@Param("ids")String ids);
public void delete(@Param("ids")String ids);
}

View File

@@ -0,0 +1,340 @@
<?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.nis.web.dao.configuration.DnsKeywordCfgDao" >
<resultMap id="CfgIndexInfoMap" type="com.nis.domain.configuration.CfgIndexInfo" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="dns_strategy_id" property="dnsStrategyId" jdbcType="INTEGER" />
<result column="dns_strategy_name" property="dnsStrategyName" jdbcType="VARCHAR" />
<result column="do_log" property="doLog" jdbcType="INTEGER" />
<result column="user_region1" property="userRegion1" jdbcType="VARCHAR" />
<result column="user_region2" property="userRegion2" jdbcType="VARCHAR" />
<result column="user_region3" property="userRegion3" jdbcType="VARCHAR" />
<result column="user_region4" property="userRegion4" jdbcType="VARCHAR" />
<result column="user_region5" property="userRegion5" jdbcType="VARCHAR" />
<result column="source_compile_id" property="sourceCompileId" jdbcType="INTEGER" />
<result column="cancel_request_id" property="cancelRequestId" jdbcType="INTEGER" />
<result column="do_blacklist" property="doBlackList" jdbcType="INTEGER" />
</resultMap>
<resultMap id="stringCfgMap" type="com.nis.domain.configuration.BaseStringCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="cfg_keywords" property="cfgKeywords" jdbcType="VARCHAR" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="expr_type " property="exprType" jdbcType="INTEGER" />
<result column="match_method" property="matchMethod" jdbcType="INTEGER" />
<result column="is_hexbin" property="isHexbin" jdbcType="INTEGER" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="dnsKeywordCfgMap" type="com.nis.domain.configuration.DnsKeywordCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="cfg_keywords" property="cfgKeywords" jdbcType="VARCHAR" />
<result column="district" property="district" jdbcType="VARCHAR" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="expr_type " property="exprType" jdbcType="INTEGER" />
<result column="match_method" property="matchMethod" jdbcType="INTEGER" />
<result column="is_hexbin" property="isHexbin" jdbcType="INTEGER" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
</resultMap>
<sql id="configIndexColumn" >
a.CFG_ID,a.CFG_DESC,a.ACTION,a.IS_VALID,a.IS_AUDIT,
a.CREATOR_ID,a.CREATE_TIME,a.EDITOR_ID,a.EDIT_TIME,a.AUDITOR_ID,a.AUDIT_TIME,
a.SERVICE_ID,a.REQUEST_ID,a.COMPILE_ID,a.IS_AREA_EFFECTIVE,a.CLASSIFY,
a.ATTRIBUTE,a.LABLE,a.AREA_EFFECTIVE_IDS,a.function_id,a.dns_strategy_id,a.user_region1,
a.user_region2,a.user_region3,a.user_region4,a.user_region5,a.do_log,a.source_compile_id,a.cancel_request_id,
a.do_blacklist
</sql>
<sql id="ipCfgColumn" >
a.cfg_id,a.cfg_desc,a.ip_type,a.src_ip_address,a.ip_pattern,a.port_pattern,a.src_port
,a.protocol,a.protocol_id,a.direction,a.cfg_type,a.action,a.dest_port,a.dest_ip_address
,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id
,a.edit_time,a.auditor_id,a.audit_time,a.service_id,a.request_id,
a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable
,a.area_effective_ids,a.function_id,a.cfg_region_code
</sql>
<sql id="strCfgColumn" >
a.cfg_id,a.cfg_desc,a.cfg_keywords,a.cfg_type,
a.action,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id,a.edit_time, a.auditor_id,
a.audit_time,a.service_id,a.request_id,a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable,
a.expr_type,a.match_method,a.is_hexbin,a.area_effective_ids,a.function_id,a.cfg_region_code
</sql>
<sql id="complexCfgColumn" >
a.cfg_id,a.cfg_desc,a.cfg_keywords,a.cfg_type,a.district,a.user_region1,
a.action,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id,a.edit_time, a.auditor_id,
a.audit_time,a.service_id,a.request_id,a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable,
a.expr_type,a.match_method,a.is_hexbin,a.area_effective_ids,a.function_id,a.cfg_region_code
</sql>
<!-- dns域名查询 -->
<select id="findPage" resultMap="dnsKeywordCfgMap" parameterType="com.nis.domain.configuration.DnsKeywordCfg">
SELECT
<include refid="complexCfgColumn" />
,s.name as creator_name,e.name as editor_name,u.name as auditor_name
FROM dns_domain_cfg a
left join sys_user s on a.creator_id=s.id
left join sys_user e on a.editor_id=e.id
left join sys_user u on a.auditor_id=u.id
where service_id=-2 and function_id=#{functionId}
<if test="cfgType != null and cfgType != ''">
and a.cfg_type =#{cfgType,jdbcType=VARCHAR}
</if>
</select>
<select id="get" resultMap="dnsKeywordCfgMap">
select
<include refid="complexCfgColumn"></include>
from dns_domain_cfg a
where a.cfg_id=#{cfgId}
</select>
<select id="getByIds" resultMap="dnsKeywordCfgMap">
select
<include refid="complexCfgColumn"></include>
from dns_domain_cfg a
where a.cfg_id in (${ids}) and is_valid !=-1
</select>
<update id="updateCfgValid" parameterType="com.nis.domain.configuration.BaseCfg">
update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER},
editor_id = #{editorId,jdbcType=INTEGER} ,
edit_time = #{editTime,jdbcType=TIMESTAMP}
<if test="isAudit !=null ">
,is_audit = #{isAudit,jdbcType=BIGINT}
</if>
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="cfgId !=null ">
AND cfg_id = #{cfgId,jdbcType=BIGINT}
</if>
<if test="compileId !=null ">
AND compile_id = #{compileId,jdbcType=INTEGER}
</if>
and function_id=#{functionId,jdbcType=INTEGER}
</trim>
</update>
<update id="auditCfg" parameterType="com.nis.domain.configuration.BaseCfg">
update ${tableName} set is_audit = #{isAudit,jdbcType=INTEGER},
auditor_id = #{auditorId,jdbcType=INTEGER},
audit_time = #{auditTime,jdbcType=TIMESTAMP}
<if test="isValid != null" >
,is_valid = #{isValid,jdbcType=INTEGER}
</if>
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="cfgId !=null ">
AND cfg_id = #{cfgId,jdbcType=BIGINT}
</if>
<if test="compileId !=null ">
AND compile_id = #{compileId,jdbcType=INTEGER}
</if>
and function_id=#{functionId,jdbcType=INTEGER}
</trim>
</update>
<!-- insert dns_domain_cfg表信息 -->
<insert id="saveDnsKeywordsCfg" parameterType="com.nis.domain.configuration.DnsKeywordCfg" >
insert into dns_domain_cfg (
CFG_DESC,
ACTION,
IS_VALID,
IS_AUDIT,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
AUDITOR_ID,
AUDIT_TIME,
SERVICE_ID,
REQUEST_ID,
COMPILE_ID,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
AREA_EFFECTIVE_IDS,
function_id,
district,
cfg_keywords,
cfg_type,
cfg_region_code,
expr_type,
match_method,
is_hexbin,
user_region1
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER},
#{district,jdbcType=VARCHAR},
#{cfgKeywords,jdbcType=VARCHAR},
#{cfgType,jdbcType=VARCHAR},
#{cfgRegionCode,jdbcType=INTEGER},
#{exprType,jdbcType=INTEGER},
#{matchMethod,jdbcType=INTEGER},
#{isHexbin,jdbcType=INTEGER},
#{userRegion1,jdbcType=VARCHAR}
)
</insert>
<!-- 删除dns公共组域名配置 -->
<delete id="deleteDnsDomainCfg">
delete from dns_domain_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
<delete id="delete" parameterType="java.lang.String" >
delete from dns_domain_cfg where cfg_id in (${ids})
</delete>
<update id="update" parameterType="com.nis.domain.configuration.DnsKeywordCfg" >
update dns_domain_cfg
<set >
<trim suffixOverrides=",">
<if test="cfgDesc != null and cfgDesc != ''" >
cfg_desc = #{cfgDesc,jdbcType=VARCHAR},
</if>
<if test="action != null" >
action = #{action,jdbcType=INTEGER},
</if>
<if test="isValid != null" >
is_valid = #{isValid,jdbcType=INTEGER},
</if>
<if test="isAudit != null" >
is_audit = #{isAudit,jdbcType=INTEGER},
</if>
<if test="editorId != null" >
editor_id = #{editorId,jdbcType=INTEGER},
</if>
<if test="editTime != null and editTime != ''" >
edit_time = #{editTime,jdbcType=TIMESTAMP},
</if>
<if test="auditorId != null" >
AUDITOR_ID = #{auditorId,jdbcType=INTEGER},
</if>
<if test="auditTime != null and auditTime != ''" >
AUDIT_TIME = #{auditTime,jdbcType=TIMESTAMP},
</if>
<if test="serviceId != null" >
service_id = #{serviceId,jdbcType=INTEGER},
</if>
<if test="requestId != null" >
request_id = #{requestId,jdbcType=INTEGER},
</if>
<if test="isAreaEffective != null" >
is_area_effective = #{isAreaEffective,jdbcType=INTEGER},
</if>
<if test="classify != null and classify != ''" >
classify = #{classify,jdbcType=VARCHAR},
</if>
<if test="attribute != null and attribute != ''" >
attribute = #{attribute,jdbcType=VARCHAR},
</if>
<if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR},
</if>
<if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
</if>
<if test="functionId != null" >
function_id = #{functionId,jdbcType=INTEGER},
</if>
<if test="district != null" >
district = #{district,jdbcType=VARCHAR},
</if>
<if test="cfgKeywords != null and cfgKeywords != ''" >
cfg_keywords = #{cfgKeywords,jdbcType=VARCHAR},
</if>
<if test="cfgType != null" >
cfg_type = #{cfgType,jdbcType=INTEGER},
</if>
<if test="cfgRegionCode != null" >
cfg_region_code = #{cfgRegionCode,jdbcType=INTEGER},
</if>
<if test="exprType != null and exprType != ''" >
expr_type = #{exprType,jdbcType=VARCHAR},
</if>
<if test="matchMethod != null" >
match_method = #{matchMethod,jdbcType=INTEGER},
</if>
<if test="isHexbin != null" >
is_hexbin = #{isHexbin,jdbcType=INTEGER},
</if>
<if test="userRegion1 != null and userRegion1 != ''" >
user_region1 = #{userRegion1,jdbcType=VARCHAR},
</if>
<if test="compileId != null and compileId != ''" >
compile_id = #{compileId,jdbcType=INTEGER},
</if>
</trim>
</set>
<where>
and cfg_id = #{cfgId,jdbcType=INTEGER}
</where>
</update>
</mapper>

View File

@@ -48,4 +48,8 @@ public interface IpMultiplexDao extends CrudDao<IpMultiplexDao>{
List<IpReusePolicyCfg> findByPage(@Param("ids")String ids);
List<BaseIpCfg> findPageByDnat(@Param("ids")String ids);
List<IpReusePolicyCfg> findByUser(@Param("userName")String userName);
List<IpReuseDnatPolicyCfg> findDnatUser(@Param("userName")String userName);
}

View File

@@ -775,7 +775,7 @@
sys_user u on r.auditor_id = u.id
left join
request_info ri on r.request_id = ri.id
where a.CFG_ID in (${ids})
where r.CFG_ID in (${ids})
</select>
<select id="findPageByDnat" resultMap="dnatPolicyMap">
@@ -801,4 +801,22 @@
</select>
<select id="findByUser" resultMap="policyMap">
SELECT
<include refid="policyColumns"/>
FROM
ip_reuse_policy_cfg r
where r.IS_VALID != -1
and r.user_name =#{userName}
</select>
<select id="findDnatUser" resultMap="dnatPolicyMap">
SELECT
<include refid="dnatPolicyColumns"/>
FROM
ip_reuse_dnat_policy a
where a.IS_VALID != -1
and a.translated_user_id =#{userName}
</select>
</mapper>

View File

@@ -254,6 +254,7 @@
select
<include refid="Base_Column_List" />
from request_info
where is_audit in(1,3)
</select>
<select id="findAllLwhhList" resultMap="BaseResultMap">

View File

@@ -58,4 +58,6 @@ public interface StringCfgDao extends CrudDao<BaseStringCfg>{
// 导入配置时数据批量入库使用
public void saveStringCfgBatch(BaseStringCfg cfg);
public void saveComplexkeywordCfgBatch(ComplexkeywordCfg cfg);
public List<AsnKeywordCfg> findAsnKeywordCfgByCompileId(@Param("compileIds")String compileIds);
}

View File

@@ -977,4 +977,8 @@
#{isHexbin,jdbcType=INTEGER}
)
</insert>
<select id="findAsnKeywordCfgByCompileId" resultMap="AsnKeywordMap" >
select <include refid="AsnKeywordCfg_Column" /> from asn_keyword_cfg r
where r.compile_id in (${compileIds}) and r.is_audit=0 and r.is_valid=0
</select>
</mapper>

View File

@@ -167,6 +167,6 @@
FROM user_manage a
left join sys_user s on a.creator_id=s.id
left join sys_user e on a.editor_id=e.id
where a.CFG_ID in (${ids})
where a.id in (${ids})
</select>
</mapper>

Some files were not shown because too many files have changed in this diff Show More