Compare commits
135 Commits
develop_no
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7e95bb75c | ||
|
|
4f9a78e5d9 | ||
|
|
446c8884ad | ||
|
|
e147f29d55 | ||
|
|
96656f24cf | ||
|
|
bb6668d00f | ||
|
|
0f65e9aaa0 | ||
|
|
b4a1a363d8 | ||
|
|
44be854707 | ||
|
|
7a3d68a7b3 | ||
|
|
be04a04336 | ||
|
|
3639363a9b | ||
|
|
181f3d8fa0 | ||
|
|
a8f1a3c94a | ||
|
|
30ba1d160d | ||
|
|
b95e597b57 | ||
|
|
64e3c13513 | ||
|
|
d23b35f8c9 | ||
|
|
f98ba1951e | ||
|
|
650ffaace2 | ||
|
|
c2b33847f9 | ||
|
|
536f6a56be | ||
|
|
1b9fef3bc8 | ||
|
|
7bfcbe614a | ||
|
|
b57176c6c1 | ||
|
|
be5635f81f | ||
|
|
e8ead66d5e | ||
|
|
11424ee91d | ||
|
|
affdaf513a | ||
|
|
0c468202a0 | ||
|
|
76302ff82e | ||
|
|
a5246568ad | ||
|
|
2cb6de6773 | ||
|
|
71457cc369 | ||
|
|
7c93338dce | ||
|
|
15c8b83b94 | ||
|
|
715e9b3c73 | ||
|
|
5923554e52 | ||
|
|
355fa8e3cb | ||
|
|
560a6530dd | ||
|
|
a7d22d463d | ||
|
|
1c642b281e | ||
|
|
e1d439655a | ||
|
|
2037c2f3b0 | ||
|
|
fc73585977 | ||
|
|
5f321f96ab | ||
|
|
3373978073 | ||
|
|
67ed670053 | ||
|
|
14e3b828db | ||
|
|
956f19ae2f | ||
|
|
fdfc608290 | ||
|
|
a51718907d | ||
|
|
c9d7512a1b | ||
|
|
da9744d60d | ||
|
|
923aca94a8 | ||
|
|
96df029f43 | ||
|
|
f90ef5ab85 | ||
|
|
0fb4bf08a4 | ||
|
|
c8c75e566e | ||
|
|
85633ee524 | ||
|
|
89f92e99fc | ||
|
|
5786412116 | ||
|
|
0cbe9c7ff7 | ||
|
|
4304fe0077 | ||
|
|
1cc0a4f2ea | ||
|
|
cb9cf1eac8 | ||
|
|
e1efb84e1f | ||
|
|
d0ca7f89d4 | ||
|
|
e2e6ebfac1 | ||
|
|
3daab5e49d | ||
|
|
e5e63af738 | ||
|
|
1d5905fe47 | ||
|
|
52fe56b59d | ||
|
|
d51da59143 | ||
|
|
8bb1c6c857 | ||
|
|
25e6fa4a3f | ||
|
|
ea82be590e | ||
|
|
1a6e771458 | ||
|
|
2ad34a552c | ||
|
|
e14cca6824 | ||
|
|
2e8d2cb7b2 | ||
|
|
9fbd60ddf0 | ||
|
|
a31769f3cb | ||
|
|
a960bb53ec | ||
|
|
0858b89ffa | ||
|
|
65991514d7 | ||
|
|
3cd969978e | ||
|
|
44a8e8852e | ||
|
|
57793c7264 | ||
|
|
6885d467cb | ||
|
|
e5ce04e34b | ||
|
|
fa42935d46 | ||
|
|
a464bd9443 | ||
|
|
3087e5baf3 | ||
|
|
52bf2d3415 | ||
|
|
ee411339c8 | ||
|
|
3bf485b920 | ||
|
|
ab157b82db | ||
|
|
79de7b51df | ||
|
|
0ed34ac938 | ||
|
|
2eb2cd366e | ||
|
|
b03ec51aa4 | ||
|
|
37dfdf1e3b | ||
|
|
859b3c72f9 | ||
|
|
9d190788b1 | ||
|
|
7d08ab8539 | ||
|
|
e0661fbed4 | ||
|
|
23c118c6b7 | ||
|
|
634def997d | ||
|
|
b5d1b281a0 | ||
|
|
d0b4907271 | ||
|
|
a1f8e1779a | ||
|
|
d7d3f68222 | ||
|
|
3612bf09d9 | ||
|
|
3602e2f1c3 | ||
|
|
fa7fa0c859 | ||
|
|
8d42cab7e2 | ||
|
|
ebcb89ef13 | ||
|
|
dd31d432e1 | ||
|
|
ae283564cb | ||
|
|
968529084f | ||
|
|
c23c0d738e | ||
|
|
ca14bcb621 | ||
|
|
34648428ea | ||
|
|
427619d088 | ||
|
|
3c61dc7bad | ||
|
|
698fd13a65 | ||
|
|
436190fe8c | ||
|
|
b9c9b5aab9 | ||
|
|
2d4a1a6685 | ||
|
|
7210fca18f | ||
|
|
99dad7c0a4 | ||
|
|
d616166507 | ||
|
|
43f947fd69 | ||
|
|
b883c3b937 |
10
.classpath
10
.classpath
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
18
pom.xml
@@ -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>
|
||||
|
||||
31
src/main/java/com/nis/domain/Nets.java
Normal file
31
src/main/java/com/nis/domain/Nets.java
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
43
src/main/java/com/nis/domain/ScheduleCfg.java
Normal file
43
src/main/java/com/nis/domain/ScheduleCfg.java
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
66
src/main/java/com/nis/domain/ScheduleExceInfo.java
Normal file
66
src/main/java/com/nis/domain/ScheduleExceInfo.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
@@ -350,26 +359,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 +989,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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -36,5 +20,21 @@ public class TopicWebsiteTemplate extends StringAllTemplate{
|
||||
public void setCfgKeywords(String cfgKeywords) {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,8 +30,10 @@ public class NtcConnRecordLog extends BaseLogEntity<NtcConnRecordLog> {
|
||||
protected String totalByte;
|
||||
|
||||
protected String ispCode;//运营商
|
||||
protected String ispNum;//运营商 (entrance_id+device_id)
|
||||
protected String ispName;//运营商
|
||||
|
||||
|
||||
|
||||
|
||||
public String getIspCode() {
|
||||
return ispCode;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
@@ -27,13 +25,7 @@ public class NtcAsnRecord extends BaseLogEntity<NtcAsnRecord>{
|
||||
this.searchAsnType = searchAsnType;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
519
src/main/java/com/nis/quartz/ScheduleCfgJob.java
Normal file
519
src/main/java/com/nis/quartz/ScheduleCfgJob.java
Normal 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
38
src/main/java/com/nis/quartz/ScheduleStatusJob.java
Normal file
38
src/main/java/com/nis/quartz/ScheduleStatusJob.java
Normal 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 ));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
690
src/main/java/com/nis/util/ConfigConvertUtil.java
Normal file
690
src/main/java/com/nis/util/ConfigConvertUtil.java
Normal 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 cfgType,1为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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -818,4 +820,12 @@ 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";
|
||||
}
|
||||
|
||||
759
src/main/java/com/nis/util/IPUtil.java
Normal file
759
src/main/java/com/nis/util/IPUtil.java
Normal 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 起始ip,endIP 结束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
@@ -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 Node root;
|
||||
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) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置文件内容
|
||||
* @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();
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -286,7 +292,10 @@ public abstract class XLSXCovertCSVReader {
|
||||
if(!refnum.equals(preRefnum)){
|
||||
int len = countNullCell(refnum, preRefnum);
|
||||
for(int i=0;i<len;i++){
|
||||
rowlist.add(curCol, "");
|
||||
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;
|
||||
@@ -323,16 +333,25 @@ public abstract class XLSXCovertCSVReader {
|
||||
|
||||
int len = countNullCell(maxRefnum, refnum);
|
||||
for(int i=0;i<=len;i++){
|
||||
rowlist.add(curCol, "");
|
||||
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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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")) + ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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")) + ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,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;
|
||||
@@ -957,16 +958,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 +982,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 +1081,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 +1096,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 +1136,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 +1151,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 +1191,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 +1206,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 +1248,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 +1263,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 +1304,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<>();
|
||||
|
||||
Properties props=this.getMsgProp();
|
||||
for(int i=0;i<Constants.MULITY_THREAD_SIZE;i++) {
|
||||
CheckTopicWebsiteFormatThread t=new CheckTopicWebsiteFormatThread(serviceDict,regionDict, this.getMsgProp(), list, queue);
|
||||
CheckTopicWebsiteFormatThread t=new CheckTopicWebsiteFormatThread(serviceDict,regionDict, props, list, queue);
|
||||
futures.add(service.submit(t));
|
||||
|
||||
}
|
||||
service.shutdown();
|
||||
while(!service.isTerminated()) {
|
||||
@@ -1182,13 +1319,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 +1470,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 +1490,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 +1539,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 +1669,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 +1716,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 ip,isSend=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 +1899,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&®ionIds.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 +2750,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 +2797,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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1859,7 +1859,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 +1995,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 +2068,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 +2141,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());
|
||||
|
||||
@@ -424,7 +424,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 +439,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;
|
||||
|
||||
@@ -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,10 +33,14 @@ 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"})
|
||||
@@ -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,9 +119,19 @@ 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(!StringUtil.isEmpty(exUser)){
|
||||
exUser=exUser.substring(0, exUser.length()-1);
|
||||
message+="<br/> "+msgProp.getProperty("user")+" "+exUser+" "+msgProp.getProperty("user_check");
|
||||
}
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error",message);
|
||||
}else {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,6 +423,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);
|
||||
@@ -524,6 +530,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);
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>() {
|
||||
|
||||
@@ -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,13 +474,14 @@ 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,Integer[] searchIspCode,Model model){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
Map list = new HashMap();
|
||||
try {
|
||||
@@ -484,6 +496,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 +515,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 +535,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 +547,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 +655,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 +673,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 +744,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 +756,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())){
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
// 增加收/发件人、邮件主题查询
|
||||
@@ -120,9 +161,7 @@ public class MailLogController extends BaseController {
|
||||
if (StringUtils.isNotBlank(log.getSubject())) {
|
||||
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)) {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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.getName());
|
||||
systemService.deleteAuthenticationCache(keyPrefix + user.getId());
|
||||
}
|
||||
}
|
||||
/*if (!beanValidator(model, user)){
|
||||
return form(user, model);
|
||||
|
||||
76
src/main/java/com/nis/web/dao/SchedulerDao.java
Normal file
76
src/main/java/com/nis/web/dao/SchedulerDao.java
Normal 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);
|
||||
|
||||
}
|
||||
315
src/main/java/com/nis/web/dao/SchedulerDao.xml
Normal file
315
src/main/java/com/nis/web/dao/SchedulerDao.xml
Normal 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>
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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>
|
||||
@@ -33,6 +33,9 @@ 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();
|
||||
public List<AsnIpCfg> getASNIPList(AsnIpCfg entity);
|
||||
}
|
||||
|
||||
@@ -82,6 +82,9 @@
|
||||
<if test="asnIpGroup != null and asnIpGroup != ''">
|
||||
AND r.asn_Ip_Group =#{asnIpGroup,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="userRegion1 != null and userRegion1 != ''">
|
||||
AND r.user_region1 =#{userRegion1,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="cfgRegionCode != null">
|
||||
AND r.CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER}
|
||||
</if>
|
||||
@@ -560,7 +563,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 +671,22 @@
|
||||
</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>
|
||||
<select id="getASNIPList" resultMap="asnIpCfgMap" >
|
||||
select
|
||||
cfg_id,dest_ip_address
|
||||
from asn_ip_cfg r
|
||||
where r.is_valid!=-1
|
||||
and r.is_audit!=3
|
||||
and r.ip_type=#{ipType}
|
||||
and r.user_region1 = #{userRegion1}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -251,18 +251,20 @@
|
||||
</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>
|
||||
|
||||
|
||||
|
||||
@@ -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) ;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -99,4 +99,6 @@ public interface ConfigSynchronizationDao {
|
||||
public List<AppIpCfg> getAppIpFeatureList(BaseCfg entity);
|
||||
|
||||
public void updateCfgStatus(BaseCfg entity);
|
||||
|
||||
public PxyObjSpoofingIpPool getPxyObjSpoofingIpPool(Long cfgId);
|
||||
}
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -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">
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -371,6 +371,17 @@
|
||||
<if test="sourceCompileId != null">
|
||||
and source_compile_id=#{sourceCompileId}
|
||||
</if>
|
||||
<if test="isValid != null">
|
||||
and is_valid=#{isValid}
|
||||
</if>
|
||||
<if test="isAudit != null">
|
||||
and is_audit=#{isAudit}
|
||||
</if>
|
||||
<!-- 代理拦截策略 -->
|
||||
<if test="functionId != null and functionId=200">
|
||||
and a.user_region1=#{userRegion1}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
</select>
|
||||
<select id="getIpPortList" resultMap="ipPortMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
|
||||
|
||||
@@ -8,4 +8,5 @@ import com.nis.web.dao.MyBatisDao;
|
||||
@MyBatisDao
|
||||
public interface CodeSysIspInfoDicDao {
|
||||
List<SysIspInfo> getIspDicList();
|
||||
List<SysIspInfo> getIspListByIspNum();
|
||||
}
|
||||
|
||||
@@ -19,4 +19,9 @@
|
||||
<include refid="Base_Column_List" />
|
||||
from sys_isp_info
|
||||
</select>
|
||||
<select id="getIspListByIspNum" resultType="com.nis.domain.dashboard.SysIspInfo">
|
||||
select distinct s.isp_key_code ispKeyCode ,concat(d.entrance_id,d.device_id) ispNum,s.isp_key_name ispKeyName from sys_device_info d
|
||||
left join sys_isp_info s on d.isp=s.isp_key_code
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -26,4 +26,7 @@ public interface ConfigGroupInfoDao extends CrudDao<ConfigGroupInfo>{
|
||||
int delAsnGroup(@Param("groupName")String groupName);
|
||||
void updateIsAuditAll(@Param("groupType")Integer groupType,@Param("isAuditAll")Integer isAuditAll,@Param("groupIds")List groupIds);
|
||||
void updateIsUsed(@Param("groupType")Integer groupType,@Param("isUsed")Integer isUsed,@Param("groupIds")List groupIds);
|
||||
void deleteAllAsnGroup();
|
||||
void insertWithId(ConfigGroupInfo entity);
|
||||
void insertWithoutId(ConfigGroupInfo entity);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,14 @@
|
||||
<!-- 新增配置分组信息 -->
|
||||
<insert id="insertConfigGroupInfo" parameterType="com.nis.domain.specific.ConfigGroupInfo" useGeneratedKeys="true">
|
||||
insert into config_group_info (id,group_id,group_name,is_issued,insert_time,group_type,compile_id,asn_id,is_audit_all,is_used)
|
||||
values(#{id},#{groupId},#{groupName},#{isIssued},#{insertTime},#{groupType},#{compileId},#{asnId},#{isAuditAll},#{isUsed})
|
||||
</insert>
|
||||
<insert id="insertWithoutId" parameterType="com.nis.domain.specific.ConfigGroupInfo" useGeneratedKeys="true">
|
||||
insert into config_group_info (id,group_id,group_name,is_issued,insert_time,group_type,compile_id,asn_id,is_audit_all,is_used)
|
||||
values(#{id},#{groupId},#{groupName},#{isIssued},#{insertTime},#{groupType},#{compileId},#{asnId},#{isAuditAll},#{isUsed})
|
||||
</insert>
|
||||
<insert id="insertWithId" parameterType="com.nis.domain.specific.ConfigGroupInfo">
|
||||
insert into config_group_info (id,group_id,group_name,is_issued,insert_time,group_type,compile_id,asn_id,is_audit_all,is_used)
|
||||
values(#{id},#{groupId},#{groupName},#{isIssued},now(),#{groupType},#{compileId},#{asnId},#{isAuditAll},#{isUsed})
|
||||
</insert>
|
||||
<insert id="insertBatch">
|
||||
@@ -130,4 +138,24 @@
|
||||
</if>
|
||||
</where>
|
||||
</update>
|
||||
<update id="update" >
|
||||
UPDATE config_group_info
|
||||
<set>
|
||||
update_time=now(),
|
||||
<if test="groupName != null and groupName != ''">
|
||||
group_name =#{groupName},
|
||||
</if>
|
||||
</set>
|
||||
<where>
|
||||
<if test="groupType != null">
|
||||
and group_type =#{groupType}
|
||||
</if>
|
||||
<if test="groupId != null">
|
||||
and group_id =#{groupId}
|
||||
</if>
|
||||
</where>
|
||||
</update>
|
||||
<delete id="deleteAllAsnGroup" >
|
||||
delete from config_group_info where group_type=4
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -547,25 +547,11 @@ public abstract class BaseService {
|
||||
dstList.add(cfg);
|
||||
}
|
||||
} else if (cfgType == 7) { //ASN关键字配置
|
||||
/*//TODO 下发之前是否需要增加asn号的有效性校验,创建配置和下发配置不是在同一时间
|
||||
//TODO 考虑增加配置id、表名和ASN组织,以及ASN NO的关系。
|
||||
//TODO 如果ASNO 和组织关系没有了,数据需要清理,asn组织和配置id关系没有了,也需要清理
|
||||
int regionNum=0;
|
||||
//多个ASNNO存在一个ASN关键字配置中,
|
||||
for (int i = 0; i < srcList.size(); i++) {
|
||||
AsnKeywordCfg asnKeywordCfg=(AsnKeywordCfg)srcList.get(i);
|
||||
regionNum+=asnKeywordCfg.getCfgKeywords().split(",").length;
|
||||
|
||||
}
|
||||
|
||||
//List<Integer> groupIdList = ConfigServiceUtil.getId(2, srcList.size());
|
||||
List<Integer> regionIdList = ConfigServiceUtil.getId(3, regionNum);
|
||||
Integer regionIndex=0;*/
|
||||
List<Integer> listGroupId=new ArrayList<>();
|
||||
for (int i = 0; i < srcList.size(); i++) {
|
||||
AsnKeywordCfg asnKeywordCfg = (AsnKeywordCfg)srcList.get(i);
|
||||
GroupCfg group = new GroupCfg();
|
||||
group.setGroupId(Integer.parseInt(asnKeywordCfg.getUserRegion1()));
|
||||
group.setGroupId(asnKeywordCfg.getGroupId());
|
||||
group.setCompileId(baseCfg.getCompileId());
|
||||
group.setAuditTime(baseCfg.getAuditTime());
|
||||
group.setIsValid(baseCfg.getIsValid());
|
||||
@@ -580,7 +566,6 @@ public abstract class BaseService {
|
||||
StringCfg cfg = new StringCfg();
|
||||
BeanUtils.copyProperties(asnKeywordCfg, cfg);
|
||||
cfg.setGroupId(group.getGroupId());
|
||||
cfg.setRegionId(Integer.parseInt(asnKeywordCfg.getUserRegion2()));
|
||||
cfg.setAuditTime(baseCfg.getAuditTime());
|
||||
cfg.setIsValid(baseCfg.getIsValid());
|
||||
// 处理配置关键字转译
|
||||
@@ -1571,7 +1556,7 @@ public abstract class BaseService {
|
||||
BeanUtils.copyProperties(baseIpCfg, cfg);
|
||||
cfg.setGroupId(asnIpCfg.getAsnIpGroup());
|
||||
cfg.setRegionId(asnIpCfg.getRegionId());
|
||||
String userRegion = "ASN_ID=" + asnIpCfg.getUserRegion1();
|
||||
String userRegion = Constants.ASN_REGION_KEY+"=" +Constants.ASN_KEY+ asnIpCfg.getUserRegion1();
|
||||
cfg.setUserRegion(userRegion);
|
||||
cfg.setIsValid(isValid);
|
||||
cfg.setAuditTime(opTime);
|
||||
@@ -1945,7 +1930,7 @@ public abstract class BaseService {
|
||||
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||
maatCfg.setIsValid(info.getValue().get(0).getIsValid());
|
||||
// 设置自定义域
|
||||
String userRegion = "ASN_ID=" + info.getKey();
|
||||
String userRegion = Constants.ASN_REGION_KEY+"=" +Constants.ASN_KEY+ info.getKey();
|
||||
maatCfg.setUserRegion(userRegion);
|
||||
configCompileList.add(maatCfg);
|
||||
|
||||
@@ -2153,6 +2138,7 @@ public abstract class BaseService {
|
||||
long start=System.currentTimeMillis();
|
||||
ConfigGroupInfo configGroupInfo=configGroupInfoDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId());
|
||||
if(configGroupInfo==null) {//一般特定服务的组号是新增之后就有的,不会进入这一步。
|
||||
Date date = new Date();
|
||||
Integer groupId = ConfigServiceUtil.getId(2, 1).get(0);
|
||||
Integer compileId=ConfigServiceUtil.getId(1, 1).get(0);
|
||||
specificServiceCfg.setGroupId(groupId);
|
||||
@@ -2162,9 +2148,10 @@ public abstract class BaseService {
|
||||
configGroupInfo.setIsIssued(0);
|
||||
configGroupInfo.setGroupType(1);
|
||||
configGroupInfo.setCompileId(compileId);
|
||||
configGroupInfo.setInsertTime(date);
|
||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
|
||||
//更新group_id
|
||||
specificServiceCfg.setOpTime(new Date());
|
||||
specificServiceCfg.setOpTime(date);
|
||||
specificServiceCfgDao.update(specificServiceCfg);
|
||||
}
|
||||
Integer compileId = configGroupInfo.getCompileId();
|
||||
@@ -2193,7 +2180,7 @@ public abstract class BaseService {
|
||||
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
||||
List<DigestCfg> digestRegionList = new ArrayList();
|
||||
List<IpCfg> areaIpRegionList = new ArrayList();
|
||||
if(configGroupInfo.getIsIssued()==0) {//未下发,下发region compile,group.
|
||||
if(configGroupInfo.getIsIssued() != null && configGroupInfo.getIsIssued()==0) {//未下发,下发region compile,group.
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
maatCfg.initDefaultValue();
|
||||
@@ -2946,7 +2933,8 @@ public abstract class BaseService {
|
||||
}
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result =ConfigServiceUtil.auditCommonGroupRegionSources(json,action);
|
||||
logger.info("asn ip复用域 "+action+" 配置响应信息:"+result.getMsg());
|
||||
//logger.info("asn ip复用域 "+action+" 配置响应信息:"+result.getMsg());
|
||||
logger.info("asn ip复用域 "+action+" 配置响应信息:");
|
||||
}else {
|
||||
maatBean.setOpAction(action);
|
||||
//调用服务接口下发配置数据
|
||||
@@ -2959,7 +2947,8 @@ public abstract class BaseService {
|
||||
}
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
||||
logger.info("asn ip复用域删除配置响应信息:"+result.getMsg());
|
||||
logger.info("asn ip复用域删除配置响应信息:");
|
||||
//logger.info("asn ip复用域删除配置响应信息:"+result.getMsg());
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("asnIPRegionSendToMaat finish,cost:"+(end-start));
|
||||
@@ -2997,7 +2986,7 @@ public abstract class BaseService {
|
||||
if(!StringUtil.isEmpty(commonGroupIds)){
|
||||
commonGroupIds=commonGroupIds.substring(0, commonGroupIds.length()-1);
|
||||
}
|
||||
entity.setCommonGroupIds(commonGroupIds);
|
||||
/*entity.setCommonGroupIds(commonGroupIds);*/
|
||||
//return entity;
|
||||
}
|
||||
/**
|
||||
@@ -3010,14 +2999,9 @@ public abstract class BaseService {
|
||||
if(!StringUtil.isEmpty(asnList)){
|
||||
AsnGroupInfoDao asnGroupInfoDao=SpringContextHolder.getBean(AsnGroupInfoDao.class);
|
||||
ConfigGroupInfoDao configGroupInfoDao=SpringContextHolder.getBean(ConfigGroupInfoDao.class);
|
||||
|
||||
//1、修改域配置为下发状态
|
||||
AsnKeywordCfg asnCfg=new AsnKeywordCfg();
|
||||
BeanUtils.copyProperties(entity, asnCfg);
|
||||
asnCfg.setTableName(AsnKeywordCfg.getTablename());
|
||||
IpCfgDao ipCfgDao=SpringContextHolder.getBean(IpCfgDao.class);
|
||||
ipCfgDao.auditCfg(asnCfg);
|
||||
|
||||
StringCfgDao stringCfgDao=SpringContextHolder.getBean(StringCfgDao.class);
|
||||
//域和分组的关系
|
||||
Map<String,String> groupWithRegion=new HashMap<>();
|
||||
//需要标记为下发全部域的groupId集合
|
||||
List signAuditAllGroupList=new ArrayList<>();
|
||||
//需要标记下发的groupId
|
||||
@@ -3026,59 +3010,62 @@ public abstract class BaseService {
|
||||
List<AsnGroupInfo> auditRegionList=new ArrayList<>();
|
||||
//所有未被策略过的域
|
||||
List<AsnGroupInfo> notAuditRegionList=new ArrayList<>();
|
||||
//域和分组的关系
|
||||
Map<String,String> groupWithRegion=new HashMap<>();
|
||||
//所有策略所选asn No
|
||||
List<String> asnNoList=new ArrayList<>();
|
||||
List<String> asnGroupIdList=new ArrayList<>();
|
||||
//所有未下发过的asnNo
|
||||
List<String> notAuditAsnNoList=new ArrayList<>();
|
||||
List<String> notAuditGroupIdList=new ArrayList<>();
|
||||
//最新的asn域集合
|
||||
List<AsnKeywordCfg> newAsnList=new ArrayList<>();
|
||||
|
||||
//2、记录标记为下发all的groupId|存储组和asnno的关系|记录需要标记为已下发的group
|
||||
for (AsnKeywordCfg asnKeywordCfg : asnList) {
|
||||
asnKeywordCfg.setUserRegion2(StringUtil.isEmpty(asnKeywordCfg.getUserRegion2()) ? "1":"0");
|
||||
if("1".equals(asnKeywordCfg.getUserRegion2())){ //是否标记为下发ALL
|
||||
signAuditAllGroupList.add(Integer.parseInt(asnKeywordCfg.getUserRegion1()));
|
||||
//<!-- 是否自动更新ASN NO -->
|
||||
asnKeywordCfg.setUserRegion4(StringUtil.isEmpty(asnKeywordCfg.getUserRegion4()) ? "1":"0");
|
||||
if("1".equals(asnKeywordCfg.getUserRegion4())){ //是否标记为下发ALL
|
||||
signAuditAllGroupList.add(Integer.parseInt(asnKeywordCfg.getUserRegion3()));
|
||||
}
|
||||
for (String asnstr: asnKeywordCfg.getCfgKeywords().split(",")) {
|
||||
groupWithRegion.put(asnstr, asnKeywordCfg.getUserRegion1());
|
||||
groupWithRegion.put(asnKeywordCfg.getUserRegion2(), asnKeywordCfg.getUserRegion3());
|
||||
//需要标记为is_used=1的组织
|
||||
if(!isUsedGroupIdList.contains(Integer.parseInt(asnKeywordCfg.getUserRegion3()))){
|
||||
isUsedGroupIdList.add(Integer.parseInt(asnKeywordCfg.getUserRegion3()));
|
||||
}
|
||||
if(!isUsedGroupIdList.contains(Integer.parseInt(asnKeywordCfg.getUserRegion1()))){
|
||||
isUsedGroupIdList.add(Integer.parseInt(asnKeywordCfg.getUserRegion1()));
|
||||
}
|
||||
List<String> list=Arrays.asList(asnKeywordCfg.getCfgKeywords().split(","));
|
||||
asnNoList.addAll(list);
|
||||
//需要标记为is_used=1的asn no,根据groupId
|
||||
asnGroupIdList.add(asnKeywordCfg.getUserRegion2());
|
||||
|
||||
AsnKeywordCfg asnCfg=new AsnKeywordCfg();
|
||||
BeanUtils.copyProperties(entity, asnCfg,new String[]{"cfgId","userReigon1","userReigon2","userReigon3","userReigon4","userReigon5"});
|
||||
asnCfg.setTableName(AsnKeywordCfg.getTablename());
|
||||
asnCfg.setCfgId(asnKeywordCfg.getCfgId());
|
||||
asnCfg.setUserRegion1(asnKeywordCfg.getUserRegion1());
|
||||
asnCfg.setUserRegion2(asnKeywordCfg.getUserRegion2());
|
||||
asnCfg.setUserRegion3(asnKeywordCfg.getUserRegion3());
|
||||
asnCfg.setUserRegion4(asnKeywordCfg.getUserRegion4());
|
||||
asnCfg.setUserRegion5(asnKeywordCfg.getUserRegion5());
|
||||
stringCfgDao.updateAsnKeyword(asnCfg);
|
||||
}
|
||||
|
||||
//3、//根据asnNoList查询所有下发过的ASN NO
|
||||
if(!StringUtil.isEmpty(asnNoList)){
|
||||
auditRegionList=asnGroupInfoDao.findAsnGroupInfoByAsnNos(asnNoList, 1);
|
||||
//3、//根据asnGroupIdList查询所有下发过的ASN NO
|
||||
if(!StringUtil.isEmpty(asnGroupIdList)){
|
||||
auditRegionList=asnGroupInfoDao.findAsnGroupInfoByGroupIds(asnGroupIdList, 1);
|
||||
}
|
||||
//已下发过的ASN NO只需要下发组
|
||||
//已下发过的asn groupId只需要下发组
|
||||
if(!StringUtil.isEmpty(auditRegionList)){
|
||||
for (AsnGroupInfo asnGroupInfo : auditRegionList) {
|
||||
AsnKeywordCfg cfg = new AsnKeywordCfg();
|
||||
cfg.initDefaultValue();
|
||||
cfg.setTableName(AsnKeywordCfg.getTablename());
|
||||
cfg.setCfgType(asnList.get(0).getCfgType());
|
||||
cfg.setCompileId(entity.getCompileId());
|
||||
cfg.setCfgKeywords(asnGroupInfo.getGroupId().toString());//关键字
|
||||
cfg.setUserRegion1(groupWithRegion.get(asnGroupInfo.getAsnId().toString())); //组号
|
||||
cfg.setUserRegion2(asnGroupInfo.getRegionId().toString());//regionid
|
||||
cfg.setRegionId(asnGroupInfo.getRegionId());
|
||||
cfg.setGroupId(Integer.parseInt(groupWithRegion.get(asnGroupInfo.getGroupId().toString()))); //组号
|
||||
cfg.setUserRegion3("0"); //是否下发域
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setFunctionId(entity.getFunctionId());
|
||||
newAsnList.add(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
//4、查询所有未下发过的 ASN NO
|
||||
if(!StringUtil.isEmpty(asnNoList)){
|
||||
notAuditRegionList=asnGroupInfoDao.findAsnGroupInfoByAsnNos(asnNoList, 0);
|
||||
if(!StringUtil.isEmpty(asnGroupIdList)){
|
||||
notAuditRegionList=asnGroupInfoDao.findAsnGroupInfoByGroupIds(asnGroupIdList, 0);
|
||||
}
|
||||
|
||||
if(!StringUtil.isEmpty(notAuditRegionList)){
|
||||
@@ -3089,8 +3076,8 @@ public abstract class BaseService {
|
||||
cfg.setCompileId(entity.getCompileId());
|
||||
cfg.setCfgType(asnList.get(0).getCfgType());
|
||||
cfg.setCfgKeywords(asnGroupInfo.getAsnId().toString());//关键字
|
||||
cfg.setUserRegion1(groupWithRegion.get(asnGroupInfo.getAsnId().toString())); //groupId
|
||||
cfg.setUserRegion2(asnGroupInfo.getRegionId().toString());//regionid
|
||||
cfg.setGroupId(Integer.parseInt(groupWithRegion.get(asnGroupInfo.getGroupId().toString()))); //groupId
|
||||
cfg.setRegionId(asnGroupInfo.getRegionId());//regionid
|
||||
cfg.setUserRegion3("1"); //是否下发域
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
@@ -3098,17 +3085,184 @@ public abstract class BaseService {
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setFunctionId(entity.getFunctionId());
|
||||
newAsnList.add(cfg);
|
||||
notAuditAsnNoList.add(asnGroupInfo.getAsnId().toString());
|
||||
notAuditGroupIdList.add(asnGroupInfo.getGroupId().toString());
|
||||
}
|
||||
}
|
||||
//5、修改所有下发的asn no为已下发
|
||||
if(!StringUtil.isEmpty(notAuditAsnNoList)){
|
||||
asnGroupInfoDao.updateIsUsedAndIsValid(notAuditAsnNoList,1,null);
|
||||
//5、修改所有下发的asn为已下发
|
||||
if(!StringUtil.isEmpty(notAuditGroupIdList)){
|
||||
asnGroupInfoDao.updateIsUsedAndIsValid(notAuditGroupIdList,1,null);
|
||||
}
|
||||
//6、标记组已被策略标记为全部下发
|
||||
configGroupInfoDao.updateIsAuditAll(4, 1,signAuditAllGroupList );
|
||||
if(!StringUtil.isEmpty(signAuditAllGroupList)){
|
||||
configGroupInfoDao.updateIsAuditAll(4, 1,signAuditAllGroupList );
|
||||
}
|
||||
//7、标记组已被策略引用
|
||||
configGroupInfoDao.updateIsUsed(4, 1, isUsedGroupIdList);
|
||||
if(!StringUtil.isEmpty(isUsedGroupIdList)){
|
||||
configGroupInfoDao.updateIsUsed(4, 1, isUsedGroupIdList);
|
||||
}
|
||||
//8、maat配置转换
|
||||
if(!StringUtil.isEmpty(newAsnList)){
|
||||
Map<String,List> map = cfgConvert(strRegionList,newAsnList,7,entity,groupRelationList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*if(asnList!=null && asnList.size()>0){
|
||||
|
||||
for (AsnKeywordCfg asnKeywordCfg : asnList) {
|
||||
asnNoStr+=asnKeywordCfg.getCfgKeywords()+",";
|
||||
}
|
||||
|
||||
AsnKeywordCfg cfg = new AsnKeywordCfg();
|
||||
cfg.setTableName(AsnKeywordCfg.getTablename());
|
||||
cfg.setCompileId(entity.getCompileId());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setFunctionId(entity.getFunctionId());
|
||||
ipCfgDao.auditCfg(cfg);
|
||||
Map<String,List> map = cfgConvert(strRegionList,asnList,7,entity,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
strRegionList=map.get("dstList");
|
||||
}
|
||||
//修改配置选中的ASN NO 和 asn orga是否被策略引用过
|
||||
if(!StringUtil.isEmpty(asnNoStr)){
|
||||
asnNoStr=asnNoStr.substring(0, asnNoStr.length()-1);
|
||||
if(!StringUtil.isEmpty(asnNoStr)){
|
||||
//如果asnGroup由is_use=0,修改为is_use=1;查询asn no下所有未下发的asn ip,并进行下发,走POST接口【暂时不考虑】
|
||||
AsnIpCfgDao asnIpCfgDao=SpringContextHolder.getBean(AsnIpCfgDao.class);
|
||||
AsnIpCfg asnIp=new AsnIpCfg();
|
||||
asnIp.setIsAudit(0);
|
||||
asnIp.setIsValid(0);
|
||||
List<AsnIpCfg> asnIpList=asnIpCfgDao.findAllListByAsnGroup(asnIp, null, asnNoStr);
|
||||
|
||||
//下发asn IP和修改asn ip的状态必须在一个事物中
|
||||
//重新修改下发时间,下发人员信息
|
||||
AsnIpCfg auditAsnIpCfg=new AsnIpCfg();
|
||||
auditAsnIpCfg.setIsAudit(1);
|
||||
auditAsnIpCfg.setAuditTime(new Date());
|
||||
auditAsnIpCfg.setAuditorId(UserUtils.getUser().getId());
|
||||
auditAsnIpCfg.setIsValid(1);
|
||||
auditAllAsnRegionCfg(auditAsnIpCfg, null, asnNoStr);
|
||||
|
||||
AsnGroupInfoDao asnGroupInfoDao=SpringContextHolder.getBean(AsnGroupInfoDao.class);
|
||||
asnGroupInfoDao.updateIsUsed(asnNoStr, 1);
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
/**
|
||||
* ASN关键字配置处理 ip地址用
|
||||
* @param asnList
|
||||
* @param entity
|
||||
*/
|
||||
public void auditAsnCfgForIpAddr(List<GroupCfg> groupRelationList,List<StringCfg> strRegionList,BaseCfg entity,List<AsnKeywordCfg> asnList){
|
||||
//注意:一条配置是一个分组,keywords=asnNos|userRegion1=groupId|userRegion2=isAuditAll 0 1
|
||||
if(!StringUtil.isEmpty(asnList)){
|
||||
AsnGroupInfoDao asnGroupInfoDao=SpringContextHolder.getBean(AsnGroupInfoDao.class);
|
||||
ConfigGroupInfoDao configGroupInfoDao=SpringContextHolder.getBean(ConfigGroupInfoDao.class);
|
||||
StringCfgDao stringCfgDao=SpringContextHolder.getBean(StringCfgDao.class);
|
||||
//域和分组的关系
|
||||
Map<String,String> groupWithRegion=new HashMap<>();
|
||||
//需要标记为下发全部域的groupId集合
|
||||
List signAuditAllGroupList=new ArrayList<>();
|
||||
//需要标记下发的groupId
|
||||
List isUsedGroupIdList=new ArrayList<>();
|
||||
//所有已被策略引用过的域
|
||||
List<AsnGroupInfo> auditRegionList=new ArrayList<>();
|
||||
//所有未被策略过的域
|
||||
List<AsnGroupInfo> notAuditRegionList=new ArrayList<>();
|
||||
//所有策略所选asn No
|
||||
List<String> asnGroupIdList=new ArrayList<>();
|
||||
//所有未下发过的asnNo
|
||||
List<String> notAuditGroupIdList=new ArrayList<>();
|
||||
//最新的asn域集合
|
||||
List<AsnKeywordCfg> newAsnList=new ArrayList<>();
|
||||
|
||||
//2、记录标记为下发all的groupId|存储组和asnno的关系|记录需要标记为已下发的group
|
||||
for (AsnKeywordCfg asnKeywordCfg : asnList) {
|
||||
//<!-- 是否自动更新ASN NO -->
|
||||
asnKeywordCfg.setUserRegion4(StringUtil.isEmpty(asnKeywordCfg.getUserRegion4()) ? "1":"0");
|
||||
if("1".equals(asnKeywordCfg.getUserRegion4())){ //是否标记为下发ALL
|
||||
signAuditAllGroupList.add(Integer.parseInt(asnKeywordCfg.getUserRegion3()));
|
||||
}
|
||||
groupWithRegion.put(asnKeywordCfg.getUserRegion2(), asnKeywordCfg.getUserRegion5()); //UserRegion5 ip地址使用组
|
||||
//需要标记为is_used=1的组织
|
||||
if(!isUsedGroupIdList.contains(Integer.parseInt(asnKeywordCfg.getUserRegion3()))){
|
||||
isUsedGroupIdList.add(Integer.parseInt(asnKeywordCfg.getUserRegion3()));
|
||||
}
|
||||
//需要标记为is_used=1的asn no,根据groupId
|
||||
asnGroupIdList.add(asnKeywordCfg.getUserRegion2());
|
||||
|
||||
AsnKeywordCfg asnCfg=new AsnKeywordCfg();
|
||||
BeanUtils.copyProperties(entity, asnCfg,new String[]{"cfgId","userReigon1","userReigon2","userReigon3","userReigon4","userReigon5"});
|
||||
asnCfg.setTableName(AsnKeywordCfg.getTablename());
|
||||
asnCfg.setCfgId(asnKeywordCfg.getCfgId());
|
||||
asnCfg.setUserRegion1(asnKeywordCfg.getUserRegion1());
|
||||
asnCfg.setUserRegion2(asnKeywordCfg.getUserRegion2());
|
||||
asnCfg.setUserRegion3(asnKeywordCfg.getUserRegion3());
|
||||
asnCfg.setUserRegion4(asnKeywordCfg.getUserRegion4());
|
||||
asnCfg.setUserRegion5(asnKeywordCfg.getUserRegion5());
|
||||
stringCfgDao.updateAsnKeyword(asnCfg);
|
||||
}
|
||||
//3、//根据asnGroupIdList查询所有下发过的ASN NO
|
||||
if(!StringUtil.isEmpty(asnGroupIdList)){
|
||||
auditRegionList=asnGroupInfoDao.findAsnGroupInfoByGroupIds(asnGroupIdList, 1);
|
||||
}
|
||||
//已下发过的asn groupId只需要下发组
|
||||
if(!StringUtil.isEmpty(auditRegionList)){
|
||||
for (AsnGroupInfo asnGroupInfo : auditRegionList) {
|
||||
AsnKeywordCfg cfg = new AsnKeywordCfg();
|
||||
cfg.setCompileId(entity.getCompileId());
|
||||
cfg.setRegionId(asnGroupInfo.getRegionId());
|
||||
cfg.setGroupId(Integer.parseInt(groupWithRegion.get(asnGroupInfo.getGroupId().toString()))); //组号
|
||||
cfg.setUserRegion3("0"); //是否下发域
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
newAsnList.add(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
//4、查询所有未下发过的 ASN NO
|
||||
if(!StringUtil.isEmpty(asnGroupIdList)){
|
||||
notAuditRegionList=asnGroupInfoDao.findAsnGroupInfoByGroupIds(asnGroupIdList, 0);
|
||||
}
|
||||
|
||||
if(!StringUtil.isEmpty(notAuditRegionList)){
|
||||
for (AsnGroupInfo asnGroupInfo : notAuditRegionList) {
|
||||
AsnKeywordCfg cfg = new AsnKeywordCfg();
|
||||
cfg.initDefaultValue();
|
||||
cfg.setTableName(AsnKeywordCfg.getTablename());
|
||||
cfg.setCompileId(entity.getCompileId());
|
||||
cfg.setCfgType(asnList.get(0).getCfgType());
|
||||
cfg.setCfgKeywords(asnGroupInfo.getAsnId().toString());//关键字
|
||||
cfg.setGroupId(Integer.parseInt(groupWithRegion.get(asnGroupInfo.getGroupId().toString()))); //groupId
|
||||
cfg.setRegionId(asnGroupInfo.getRegionId());//regionid
|
||||
cfg.setUserRegion3("1"); //是否下发域
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setFunctionId(entity.getFunctionId());
|
||||
newAsnList.add(cfg);
|
||||
notAuditGroupIdList.add(asnGroupInfo.getGroupId().toString());
|
||||
}
|
||||
}
|
||||
//5、修改所有下发的asn为已下发
|
||||
if(!StringUtil.isEmpty(notAuditGroupIdList)){
|
||||
asnGroupInfoDao.updateIsUsedAndIsValid(notAuditGroupIdList,1,null);
|
||||
}
|
||||
//6、标记组已被策略标记为全部下发
|
||||
if(!StringUtil.isEmpty(signAuditAllGroupList)){
|
||||
configGroupInfoDao.updateIsAuditAll(4, 1,signAuditAllGroupList );
|
||||
}
|
||||
//7、标记组已被策略引用
|
||||
if(!StringUtil.isEmpty(isUsedGroupIdList)){
|
||||
configGroupInfoDao.updateIsUsed(4, 1, isUsedGroupIdList);
|
||||
}
|
||||
//8、maat配置转换
|
||||
if(!StringUtil.isEmpty(newAsnList)){
|
||||
Map<String,List> map = cfgConvert(strRegionList,newAsnList,7,entity,groupRelationList);
|
||||
|
||||
116
src/main/java/com/nis/web/service/ScheduleService.java
Normal file
116
src/main/java/com/nis/web/service/ScheduleService.java
Normal file
@@ -0,0 +1,116 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.nis.domain.ScheduleCfg;
|
||||
import com.nis.domain.ScheduleExceInfo;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.util.SchedulerTaskUtil;
|
||||
import com.nis.util.ServiceConfigTemplateUtil;
|
||||
import com.nis.web.dao.SchedulerDao;
|
||||
import com.nis.web.dao.configuration.ConfigSynchronizationDao;
|
||||
|
||||
@Service
|
||||
public class ScheduleService extends BaseService{
|
||||
@Autowired
|
||||
private SchedulerDao dao ;
|
||||
@Autowired
|
||||
private ConfigSynchronizationDao configSynchronizationDao;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void issueCompileInfo(ScheduleCfg cfg,Integer isValid) {
|
||||
Integer compileId = cfg.getCompileId();
|
||||
BaseCfg baseCfg = dao.getCfgTableInfo(cfg.getTableName(),compileId);//查询当前配置的最新状态
|
||||
Integer curIsValid = baseCfg.getIsValid();//当前配置的最新 是否有效信息
|
||||
if(curIsValid == isValid) {
|
||||
logger.info(String.format("当前isValid状态没有变化,不需执行,compileId:%s,isValid : %s", compileId,isValid));
|
||||
return;
|
||||
}
|
||||
//1、根据 compileId isvalid 查找new 判断是否已经下发过
|
||||
ScheduleExceInfo se = new ScheduleExceInfo();
|
||||
se.setCompileId(compileId);
|
||||
se.setIsValid(isValid);
|
||||
ScheduleExceInfo exceNew = dao.findScheduleExceNew(se);
|
||||
//2、如果已经下发,直接下发状态,否则下发配置
|
||||
Integer issueResult = 1;
|
||||
String errorInfo = null;
|
||||
String tableName = cfg.getTableName();
|
||||
SchedulerTaskUtil scheduler = new SchedulerTaskUtil();
|
||||
boolean udpateConfigStatus = false;
|
||||
|
||||
try {
|
||||
if(isValid == 1 && (exceNew == null || exceNew.getIsIssue() == 1)) {//生效配置需要下发
|
||||
udpateConfigStatus = scheduler.updateConfigByServiceAndCompile(cfg.getServiceId(), compileId, isValid, 1,configSynchronizationDao);
|
||||
logger.info(String.format("定时器下发配置内容,compileId:%s,isValid:%s,issueResult:%s,errorInfo:%s",compileId,isValid,issueResult,errorInfo));
|
||||
}else{//只需修改状态
|
||||
udpateConfigStatus = scheduler.updateConfigByServiceAndCompile(cfg.getServiceId(), compileId, isValid, 0,configSynchronizationDao);
|
||||
logger.info(String.format("定时器修改配置状态,compileId:%s,isValid:%s,issueResult:%s,errorInfo:%s",compileId,isValid,issueResult,errorInfo));
|
||||
}
|
||||
|
||||
} catch (NoSuchFieldException e) {
|
||||
udpateConfigStatus = false;
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
udpateConfigStatus = false;
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
udpateConfigStatus = false;
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
udpateConfigStatus = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
// logger.info(String.format("配置状态更新,compileId:%s,isValid:%s,issueResult:%s,errorInfo:%s",compileId,isValid,issueResult,errorInfo));
|
||||
|
||||
|
||||
if(udpateConfigStatus){//配置更新成功
|
||||
if(exceNew == null) {
|
||||
//新增exce_new 表状态
|
||||
exceNew = new ScheduleExceInfo();
|
||||
exceNew.setCompileId(compileId);
|
||||
exceNew.setIssueStatus(isValid);
|
||||
exceNew.setExceTime(new Date());
|
||||
exceNew.setIssueResult(issueResult);
|
||||
exceNew.setErrorInfo(errorInfo);
|
||||
exceNew.setIsIssue(0);
|
||||
exceNew.setScheduleId(cfg.getId());
|
||||
dao.insertScheduleExceNew(exceNew);
|
||||
}else {
|
||||
//修改 exce_new 表状态
|
||||
exceNew.setExceTime(new Date());
|
||||
exceNew.setIssueResult(issueResult);
|
||||
exceNew.setErrorInfo(errorInfo);
|
||||
exceNew.setScheduleId(cfg.getId());
|
||||
dao.updateScheduleExceNew(exceNew);
|
||||
}
|
||||
ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil();
|
||||
List<Map<String,Object>> serviceList = serviceTemplate.getServiceListByServiceId(cfg.getServiceId());
|
||||
//根据编译ID查询配置表中的配置信息
|
||||
for(Map<String,Object> service:serviceList){
|
||||
//获取业务下的配置域
|
||||
List<Map<String,Object>> cfgList = (List<Map<String, Object>>) service.get("cfgList");
|
||||
//查询子域配置详情
|
||||
if(cfgList!=null){
|
||||
for(Map<String,Object> m:cfgList){
|
||||
String regionTable = m.get("tableName").toString();
|
||||
//更新配置域表的isValid字段
|
||||
dao.updateCfgTableStatus(regionTable, compileId, isValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
//3、更新 配置表的 isValid 字段,添加 exce_log 记录
|
||||
dao.insertScheduleExceLog(exceNew);
|
||||
dao.updateCfgTableStatus(tableName, compileId, isValid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -15,6 +16,7 @@ import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.AsnGroupInfo;
|
||||
import com.nis.domain.configuration.AsnKeywordCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.maat.GroupReuseAddBean;
|
||||
import com.nis.domain.maat.GroupReuseCfg;
|
||||
import com.nis.domain.maat.MaatCfg;
|
||||
@@ -44,6 +46,8 @@ public class AsnGroupInfoService extends BaseService{
|
||||
private ConfigGroupInfoDao configGroupInfoDao;
|
||||
@Autowired
|
||||
private AsnIpCfgDao asnIpCfgDao;
|
||||
@Autowired
|
||||
private StringCfgDao stringCfgDao;
|
||||
|
||||
/**
|
||||
* @param page
|
||||
@@ -74,41 +78,52 @@ public class AsnGroupInfoService extends BaseService{
|
||||
String country=entity.getCountry().trim().toUpperCase();
|
||||
entity.setOrganization(org);
|
||||
entity.setCountry(country);
|
||||
int groupId=0;
|
||||
//获取组织
|
||||
ConfigGroupInfo configGroupInfo=configGroupInfoDao.getAsnGroupByName(org);
|
||||
|
||||
if(configGroupInfo==null) {
|
||||
List<Integer> groupIds= ConfigServiceUtil.getId(2,2);
|
||||
if(groupIds.size()>0) {
|
||||
groupId=groupIds.get(0).intValue();
|
||||
}else {
|
||||
throw new MaatConvertException("Get asn group id failed");
|
||||
int groupId=0;
|
||||
int onlyGroupId=0;//用于ip地址中下发配置组号
|
||||
//新增
|
||||
if(entity.getGroupId()==null){
|
||||
|
||||
//1、根据信的组织名称,获取组织config_group_info
|
||||
ConfigGroupInfo configGroupInfo=configGroupInfoDao.getAsnGroupByName(entity.getOrganization());
|
||||
if(configGroupInfo ==null){
|
||||
//新增组织
|
||||
List<Integer> groupIds= ConfigServiceUtil.getId(2,1);
|
||||
if(groupIds.size()>0) {
|
||||
groupId=groupIds.get(0).intValue();
|
||||
}else {
|
||||
throw new MaatConvertException("Get asn group id failed");
|
||||
}
|
||||
configGroupInfo=new ConfigGroupInfo();
|
||||
configGroupInfo.setGroupName(entity.getOrganization());
|
||||
configGroupInfo.setIsIssued(0);
|
||||
configGroupInfo.setGroupType(4);
|
||||
configGroupInfo.setIsAuditAll(0);
|
||||
configGroupInfo.setIsUsed(0);
|
||||
configGroupInfo.setGroupId(groupIds.get(0));
|
||||
configGroupInfo.setInsertTime(new Date());
|
||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
|
||||
}
|
||||
configGroupInfo=new ConfigGroupInfo();
|
||||
configGroupInfo.setGroupName(org.toUpperCase());
|
||||
configGroupInfo.setIsIssued(0);
|
||||
configGroupInfo.setGroupType(4);
|
||||
configGroupInfo.setIsAuditAll(0);
|
||||
configGroupInfo.setIsUsed(0);
|
||||
configGroupInfo.setGroupId(groupIds.get(1));
|
||||
configGroupInfo.setInsertTime(new Date());
|
||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
|
||||
}else {
|
||||
|
||||
List<Integer> groupIds= ConfigServiceUtil.getId(2,1);
|
||||
if(groupIds.size()>0) {
|
||||
groupId=groupIds.get(0).intValue();
|
||||
}else {
|
||||
throw new MaatConvertException("Get asn group id failed");
|
||||
}
|
||||
|
||||
}
|
||||
//新增
|
||||
if(entity.getGroupId()==null){
|
||||
//新增组号用于ip地址新增业务
|
||||
List<Integer> onlyGroupIds= ConfigServiceUtil.getId(2,1);
|
||||
if(onlyGroupIds.size()>0) {
|
||||
onlyGroupId=onlyGroupIds.get(0).intValue();
|
||||
}else {
|
||||
throw new MaatConvertException("Get asn group id failed");
|
||||
}
|
||||
Date createTime=new Date();
|
||||
entity.setCreatorId(UserUtils.getUser().getId());
|
||||
entity.setCreateTime(createTime);
|
||||
entity.setGroupId(groupId);
|
||||
entity.setOnlyGroupId(onlyGroupId);
|
||||
entity.setOrgGroupId(configGroupInfo.getGroupId());
|
||||
entity.setIsValid(0);
|
||||
//分组已被策略设定为下发全部域,则需要自动下发新增的asno
|
||||
if(configGroupInfo.getIsAuditAll() != null && configGroupInfo.getIsAuditAll().equals(1)){
|
||||
@@ -139,41 +154,43 @@ public class AsnGroupInfoService extends BaseService{
|
||||
}
|
||||
//修改
|
||||
}else{
|
||||
long id=entity.getId();
|
||||
AsnGroupInfo group=asnGroupInfoDao.getById(id);
|
||||
int count=asnGroupInfoDao.getCountGroupInfoByName(group.getOrganization());
|
||||
if(count==1&&!group.getOrganization().equalsIgnoreCase(entity.getOrganization())) {
|
||||
configGroupInfoDao.delAsnGroup(group.getOrganization());
|
||||
}
|
||||
ConfigGroupInfo configGroupInfo1=configGroupInfoDao.getAsnGroupByName(entity.getOrganization());
|
||||
if(configGroupInfo1==null) {
|
||||
List<Integer> groupIds= ConfigServiceUtil.getId(2,2);
|
||||
if(groupIds.size()>0) {
|
||||
groupId=groupIds.get(0).intValue();
|
||||
}else {
|
||||
throw new MaatConvertException("Get asn group id failed");
|
||||
}
|
||||
configGroupInfo1=new ConfigGroupInfo();
|
||||
configGroupInfo1.setGroupName(entity.getOrganization().toUpperCase());
|
||||
configGroupInfo1.setIsIssued(0);
|
||||
configGroupInfo1.setGroupType(4);
|
||||
configGroupInfo1.setIsUsed(0);
|
||||
configGroupInfo1.setIsAuditAll(0);
|
||||
configGroupInfo1.setGroupId(groupIds.get(1));
|
||||
configGroupInfo1.setInsertTime(new Date());
|
||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo1);
|
||||
//查询旧的asn group
|
||||
AsnGroupInfo oldGroup=asnGroupInfoDao.getById(entity.getId());
|
||||
//根据旧的组织名称查询config group info
|
||||
ConfigGroupInfo oldConfigGroupInfo=configGroupInfoDao.getAsnGroupByName(oldGroup.getOrganization());
|
||||
if(oldConfigGroupInfo ==null){
|
||||
//新增组织
|
||||
List<Integer> groupIds= ConfigServiceUtil.getId(2,1);
|
||||
if(groupIds.size()>0) {
|
||||
groupId=groupIds.get(0).intValue();
|
||||
}else {
|
||||
throw new MaatConvertException("Get asn group id failed");
|
||||
}
|
||||
oldConfigGroupInfo=new ConfigGroupInfo();
|
||||
oldConfigGroupInfo.setGroupName(entity.getOrganization());
|
||||
oldConfigGroupInfo.setIsIssued(0);
|
||||
oldConfigGroupInfo.setGroupType(4);
|
||||
oldConfigGroupInfo.setIsAuditAll(0);
|
||||
oldConfigGroupInfo.setIsUsed(0);
|
||||
oldConfigGroupInfo.setGroupId(groupIds.get(0));
|
||||
oldConfigGroupInfo.setInsertTime(new Date());
|
||||
configGroupInfoDao.insert(oldConfigGroupInfo);
|
||||
}else{
|
||||
ConfigGroupInfo newConfigGroupInfo=new ConfigGroupInfo();
|
||||
newConfigGroupInfo.setGroupId(oldConfigGroupInfo.getGroupId());
|
||||
newConfigGroupInfo.setId(oldConfigGroupInfo.getId());
|
||||
newConfigGroupInfo.setGroupName(entity.getOrganization());
|
||||
configGroupInfoDao.update(newConfigGroupInfo);
|
||||
}
|
||||
|
||||
Date editTime=new Date();
|
||||
entity.setEditorId(UserUtils.getUser().getId());
|
||||
entity.setEditTime(editTime);
|
||||
entity.setGroupId(groupId);
|
||||
asnGroupInfoDao.update(entity);
|
||||
asnIpCfgDao.updateAsn(String.valueOf(entity.getAsnId()),entity.getOrganization(),entity.getCountry(),entity.getDetail());
|
||||
if(configGroupInfo1.getIsUsed()!= null
|
||||
&& configGroupInfo1.getIsUsed().equals(1)){
|
||||
group.setGroupId(groupId);
|
||||
group.setAsnId(entity.getAsnId());
|
||||
auditAsn(group,configGroupInfo1,Constants.OPACTION_PUT);
|
||||
asnIpCfgDao.updateAsn(String.valueOf(entity.getAsnId()),entity.getOrganization(),entity.getCountry(),entity.getDetail(),String.valueOf(entity.getGroupId()));
|
||||
if(oldConfigGroupInfo.getIsUsed()!= null
|
||||
&& oldConfigGroupInfo.getIsUsed().equals(1)){
|
||||
auditAsn(entity,oldConfigGroupInfo,Constants.OPACTION_PUT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,13 +202,15 @@ public class AsnGroupInfoService extends BaseService{
|
||||
List srcList=new ArrayList<>();
|
||||
AsnKeywordCfg cfg=new AsnKeywordCfg();
|
||||
cfg.initDefaultValue();
|
||||
cfg.setGroupId(group.getGroupId());
|
||||
// cfg.setGroupId(group.getGroupId());
|
||||
cfg.setGroupId(entity.getOnlyGroupId());// 用于ip地址 asn
|
||||
cfg.setCfgKeywords(entity.getAsnId().toString());
|
||||
cfg.setRegionId(entity.getRegionId());
|
||||
cfg.setCfgType(Constants.NTC_ASN_NUMBER);
|
||||
cfg.setAuditTime(new Date());
|
||||
srcList.add(cfg);
|
||||
srcMap.put(group.getGroupId(), srcList);
|
||||
// srcMap.put(group.getGroupId(), srcList);
|
||||
srcMap.put(entity.getOnlyGroupId(), srcList);// 用于ip地址 asn
|
||||
GroupReuseAddBean commonGroupBean=new GroupReuseAddBean();
|
||||
List<GroupReuseCfg> commonGroupList=new ArrayList<>();
|
||||
commonGroupList=convertCommonRegion(srcMap,commonGroupList,1,2,4);
|
||||
@@ -216,14 +235,14 @@ public class AsnGroupInfoService extends BaseService{
|
||||
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void delete(String ids,String asnIds){
|
||||
public void delete(String ids,String asnIds,String groupIds){
|
||||
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
List<GroupReuseCfg> commonGroupList=new ArrayList<>();
|
||||
//查询已经被策略引用的asn
|
||||
List<AsnGroupInfo> asnList=asnGroupInfoDao.findAsnGroupInfoByAsnNos(Arrays.asList(asnIds.split(",")), 1);
|
||||
List<AsnGroupInfo> asnList=asnGroupInfoDao.findAsnGroupInfoByGroupIds(Arrays.asList(groupIds.split(",")), 1);
|
||||
//修改asn为无效,且解除引用
|
||||
asnGroupInfoDao.updateIsUsedAndIsValid(Arrays.asList(asnIds.split(",")), 0, -1);
|
||||
asnGroupInfoDao.updateIsUsedAndIsValid(Arrays.asList(groupIds.split(",")), 0, -1);
|
||||
//删除asn下的所有asn IP
|
||||
asnIpCfgDao.deleteByAsnId(asnIds);
|
||||
|
||||
@@ -353,20 +372,47 @@ public class AsnGroupInfoService extends BaseService{
|
||||
public AsnGroupInfo getGroupIdByNameAndASNId(String organization,String country,Long asnId) {
|
||||
return asnGroupInfoDao.getGroupIdByNameAndASNId(organization,country,asnId);
|
||||
}
|
||||
public Map<Long,AsnGroupInfo> getGroupList() {
|
||||
Map<Long,AsnGroupInfo> map=Maps.newConcurrentMap();
|
||||
for(AsnGroupInfo info:asnGroupInfoDao.findAsnGroupInfos()) {
|
||||
map.put(info.getAsnId(), info);
|
||||
public List<AsnGroupInfo> findAsnGroupInfos() {
|
||||
List<AsnGroupInfo> asnGroupInfos=new ArrayList<>();
|
||||
asnGroupInfos=asnGroupInfoDao.findAsnGroupInfos();
|
||||
return asnGroupInfos;
|
||||
}
|
||||
/**
|
||||
* 初始化asn旧数据信息
|
||||
* @param asnGroupInfos
|
||||
* @param asnNosMap
|
||||
* @return
|
||||
*/
|
||||
public void getGroupList(List<AsnGroupInfo> asnGroupInfoList,List<Map<Long, AsnGroupInfo>> asnNosMap) {
|
||||
for(AsnGroupInfo info:asnGroupInfoList) {
|
||||
////【1】 旧的asn group info
|
||||
////【2】 所有的asn group info
|
||||
////【3】 所有已审核通过的asn group info
|
||||
asnNosMap.get(1).put(info.getAsnId(), info);
|
||||
if(info.getIsValid() ==1){
|
||||
asnNosMap.get(3).put(info.getAsnId(), info);
|
||||
}
|
||||
info.setIsValid(0);
|
||||
info.setIssuedIPs(0l);
|
||||
asnNosMap.get(2).put(info.getAsnId(), info);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
public List<AsnGroupInfo> findAsnGroupList(AsnGroupInfo asnGroupInfo){
|
||||
List<AsnGroupInfo> list=asnGroupInfoDao.findAsnGroupInfoByAsnGroup(asnGroupInfo);
|
||||
return list;
|
||||
}
|
||||
public List<AsnGroupInfo> findAsnGroupList(List<String> asnNos,Integer isUsed){
|
||||
List<AsnGroupInfo> list=asnGroupInfoDao.findAsnGroupInfoByAsnNos(asnNos,null );
|
||||
return list;
|
||||
/**
|
||||
* 根据compileIds获取所有需要审核通过的asn
|
||||
* @param compileIds
|
||||
* @return
|
||||
*/
|
||||
public List<AsnKeywordCfg> findAsnKeywordCfgByCompileId(String compileIds){
|
||||
List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgByCompileId(compileIds);
|
||||
return asnKeywordCfgs;
|
||||
}
|
||||
public List<String> findAsnGroupIdByGroupIds(String groupIds){
|
||||
List<String> asGroupIds=asnGroupInfoDao.findAsnGroupIdByGroupIds(groupIds);
|
||||
return asGroupIds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.nis.web.service.basics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -18,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.AsnGroupInfo;
|
||||
import com.nis.domain.basics.AsnIpCfg;
|
||||
@@ -34,8 +34,10 @@ import com.nis.domain.maat.MaatCfg.StringCfg;
|
||||
import com.nis.domain.maat.ToMaatBean;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.IPUtil;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.CrudDao;
|
||||
import com.nis.web.dao.basics.AsnGroupInfoDao;
|
||||
@@ -103,6 +105,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void update(AsnIpCfg entity){
|
||||
//checkAsnIp(entity);
|
||||
List<AsnIpCfg> auditAsnIpList=new ArrayList<>();
|
||||
List<AsnGroupInfo> auditAsnGroupList=new ArrayList<>();
|
||||
Date editTime=new Date();
|
||||
@@ -167,47 +170,326 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
auditAllAsnRegionCfg(entity,auditAsnGroupList,null);
|
||||
}*/
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param asnIpCfgs
|
||||
* @param asnIds
|
||||
* @param isImportAll 增量或者全量
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void processGroup(Map<Long,AsnGroupInfo> asnNoMap){
|
||||
logger.warn("Start to save group");
|
||||
public void saveAsnIp(List<AsnIpCfg> asnIpCfgs,String asnIds,String isImportAll){
|
||||
logger.warn("Start to only save asn ip size:"+asnIpCfgs.size());
|
||||
long start=System.currentTimeMillis();
|
||||
Date createTime=new Date();
|
||||
int index=0;
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
Set<String> groupSet=new HashSet<>();
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
if(!asnNoMap.isEmpty()) {
|
||||
List<Integer> compileIds=ConfigServiceUtil.getId(1, asnNoMap.size());
|
||||
List<Integer> groupIds=ConfigServiceUtil.getId(2, asnNoMap.size());
|
||||
for(Entry<Long, AsnGroupInfo> e:asnNoMap.entrySet()) {
|
||||
AsnGroupInfo info=e.getValue();
|
||||
info.setAsnId(e.getKey());
|
||||
info.setIsValid(0);
|
||||
info.setCreatorId(UserUtils.getUser().getId());
|
||||
info.setCreateTime(createTime);
|
||||
info.setGroupId(groupIds.get(index));
|
||||
info.setCompileId(compileIds.get(index));
|
||||
if(!groupSet.contains(info.getOrganization())) {
|
||||
groupSet.add(info.getOrganization());
|
||||
}
|
||||
((AsnGroupInfoDao) batchSqlSession.getMapper(AsnGroupInfoDao.class)).insert(info);
|
||||
if(index%Constants.IMPORT_LIMIT==0) {
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
index++;
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
if(!StringUtil.isEmpty(asnIpCfgs)){
|
||||
//全量时需要删除asn 下的所有ip
|
||||
if("1".equals(isImportAll)){
|
||||
asnIpCfgDao.deleteByAsnId(asnIds);
|
||||
}
|
||||
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for (AsnIpCfg cfg : asnIpCfgs) {
|
||||
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
batchSaveConfigGroupInfo(groupSet);
|
||||
//刷新缓存
|
||||
//AsnCacheUtils.init(true);
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("end only save asn ip finish,cost:"+(end-start));
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void auditAsnIp(Map<Long, List<AsnIpCfg>> auditAsnIp,List<Map<Long, AsnGroupInfo>> asnNoMaps,String auditType,int auditSize){
|
||||
logger.warn("Start to audit and save asn ip size:"+auditSize);
|
||||
long start=System.currentTimeMillis();
|
||||
Date date=new Date();
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
Long asno=0l;
|
||||
List<Long> groupIds=Lists.newArrayList(auditAsnIp.size());
|
||||
List<AsnIpCfg> auditList=new ArrayList<>();
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
try{
|
||||
if(!auditAsnIp.isEmpty()){
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
//maat结构配置
|
||||
if(auditType.equals("maat")){
|
||||
//maat参数
|
||||
List<StringCfg> strRegionList = new ArrayList();
|
||||
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
||||
List<DigestCfg> digestRegionList = new ArrayList();
|
||||
List<IpCfg> areaIpRegionList = new ArrayList();
|
||||
|
||||
for (Entry<Long, List<AsnIpCfg>> e:auditAsnIp.entrySet()) {
|
||||
List<GroupCfg> groupRelationList = Lists.newArrayList();
|
||||
List<IpCfg> ipRegionList = new ArrayList();
|
||||
|
||||
//分组信息
|
||||
GroupCfg groupCfg=new GroupCfg();
|
||||
groupCfg.setAuditTime(e.getValue().get(0).getAuditTime());
|
||||
groupCfg.setCompileId(e.getValue().get(0).getCompileId());
|
||||
groupCfg.setGroupId(e.getValue().get(0).getAsnIpGroup());
|
||||
groupCfg.setIsCommonGroup(1);
|
||||
groupCfg.setIsValid(e.getValue().get(0).getIsValid());
|
||||
|
||||
groupRelationList.add(groupCfg);
|
||||
|
||||
//域信息
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(e.getValue(),Constants.VALID_YES,Integer.parseInt(e.getKey()+"")));
|
||||
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
maatCfg.initDefaultValue();
|
||||
BeanUtils.copyProperties(e.getValue().get(0), maatCfg);
|
||||
maatCfg.setAction(e.getValue().get(0).getAction());
|
||||
maatCfg.setAuditTime(e.getValue().get(0).getAuditTime());
|
||||
maatCfg.setStrRegionList(strRegionList);
|
||||
maatCfg.setNumRegionList(numRegionList);
|
||||
maatCfg.setDigestRegionList(digestRegionList);
|
||||
maatCfg.setGroupRelationList(groupRelationList);
|
||||
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||
maatCfg.setIpRegionList(ipRegionList);
|
||||
maatCfg.setIsValid(e.getValue().get(0).getIsValid());
|
||||
maatCfg.setCompileId(e.getValue().get(0).getCompileId());
|
||||
// 设置ASN自定义域
|
||||
String userRegion = Constants.ASN_REGION_KEY+"=" +Constants.ASN_KEY+ e.getValue().get(0).getUserRegion1();
|
||||
maatCfg.setUserRegion(userRegion);
|
||||
maatCfg.setGroupNum(groupRelationList.size());
|
||||
configCompileList.add(maatCfg);
|
||||
|
||||
groupIds.add(e.getKey());
|
||||
for (AsnIpCfg cfg : e.getValue()) {
|
||||
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg);
|
||||
}
|
||||
//组第一次下发,需要更新已下发过的组中
|
||||
asnNoMaps.get(3).put(Long.valueOf(e.getValue().get(0).getUserRegion1()), asnNoMaps.get(2).get(Long.valueOf(e.getValue().get(0).getUserRegion1())));
|
||||
}
|
||||
|
||||
}else{
|
||||
//复用接口
|
||||
for (Entry<Long, List<AsnIpCfg>> e:auditAsnIp.entrySet()) {
|
||||
groupIds.add(e.getKey());
|
||||
for (AsnIpCfg cfg : e.getValue()) {
|
||||
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg);
|
||||
}
|
||||
auditList.addAll(e.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
//第一次走maat配置的下发,需要将asn组修改为有效
|
||||
if(auditType.equals("maat") && !StringUtil.isEmpty(groupIds)){
|
||||
asnGroupInfoDao.updateIsUsedAndIsValid(groupIds, null, 1);
|
||||
}
|
||||
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
logger.warn("Start to audit asn ip ");
|
||||
long startAudit=System.currentTimeMillis();
|
||||
if(auditType.equals("maat")){
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(new Date());
|
||||
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("asn ip maat结构配置下发配置参数:"+json);
|
||||
//logger.info("asn ip maat结构配置下发配置参数:");
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||
logger.info("asn ip maat结构配置下发响应信息:"+result.getMsg());
|
||||
//logger.info("asn ip maat结构配置下发响应信息:");
|
||||
}else{
|
||||
if(!StringUtil.isEmpty(auditList)){
|
||||
asnIPRegionSendToMaat(auditList, 1, Constants.OPACTION_POST);
|
||||
}
|
||||
}
|
||||
long endAutit=System.currentTimeMillis();
|
||||
logger.warn("End to audit asn ip finish,cost:"+(endAutit-startAudit));
|
||||
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("end audit and save asn ip finish,cost:"+(end-start));
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param asnNoMaps 所有asn的信息
|
||||
* @param configGroupInfos asn组织的数据库信息
|
||||
* @param asnOrgMap asn和组织的关系
|
||||
* @param isImportAll 是否导入全量
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void processGroup(FunctionServiceDict service,List<Map<Long, AsnGroupInfo>> asnNoMaps,List<Map<String, ConfigGroupInfo>> asnOrgList,String isSend,String isImportAll){
|
||||
logger.warn("Start to save group");
|
||||
long start=System.currentTimeMillis();
|
||||
Map<Long, AsnGroupInfo> deleteAsnCompile=null;
|
||||
Date createTime=new Date();
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
int index=0;
|
||||
Integer serviceId=service.getServiceId();
|
||||
try{
|
||||
//1、删除所有asn ip
|
||||
//asnIpCfgDao.deleteAll();
|
||||
//2、删除所有的asn_group_info
|
||||
//asnGroupInfoDao.deleteAll();
|
||||
//3、删除所有的组织信息
|
||||
//configGroupInfoDao.deleteAllAsnGroup();
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
//4、遍历保存所有的config_group_info
|
||||
if(!StringUtil.isEmpty(asnOrgList)){
|
||||
Map<String,ConfigGroupInfo> newOrgMap=asnOrgList.get(0);//【0】 新的config group info
|
||||
Map<String,ConfigGroupInfo> oldOrgMap=asnOrgList.get(1);//【1】 旧的config group info
|
||||
|
||||
//入库旧的asn组织信息
|
||||
/*if(!StringUtil.isEmpty(oldOrgMap)){
|
||||
index=0;
|
||||
for(Entry<String, ConfigGroupInfo> e:oldOrgMap.entrySet()) {
|
||||
ConfigGroupInfo configGroupInfo=e.getValue();
|
||||
configGroupInfo.setIsIssued(0);
|
||||
((ConfigGroupInfoDao) batchSqlSession.getMapper(ConfigGroupInfoDao.class)).insertWithId(configGroupInfo);
|
||||
if(index != 0 && index%Constants.IMPORT_LIMIT==0) {
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
index++;
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}*/
|
||||
|
||||
//入库新的asn组织信息
|
||||
if(!StringUtil.isEmpty(newOrgMap)){
|
||||
index=0;
|
||||
List<Integer> groupIds=ConfigServiceUtil.getId(2, newOrgMap.size());
|
||||
for(Entry<String, ConfigGroupInfo> e:newOrgMap.entrySet()) {
|
||||
ConfigGroupInfo configGroupInfo=e.getValue();
|
||||
configGroupInfo.setGroupId(groupIds.get(index));
|
||||
configGroupInfo.setIsIssued(0);
|
||||
configGroupInfo.setIsUsed(0);
|
||||
configGroupInfo.setIsAuditAll(0);
|
||||
configGroupInfo.setGroupType(4);
|
||||
configGroupInfo.setInsertTime(createTime);
|
||||
asnOrgList.get(1).put(configGroupInfo.getGroupName(), configGroupInfo);
|
||||
((ConfigGroupInfoDao) batchSqlSession.getMapper(ConfigGroupInfoDao.class)).insertWithoutId(configGroupInfo);
|
||||
if(index != 0 && index%Constants.IMPORT_LIMIT==0) {
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
index++;
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
}
|
||||
|
||||
//5、遍历保存所有的asn_group_info
|
||||
if(!asnNoMaps.isEmpty()){
|
||||
Map<Long, AsnGroupInfo> newAsnGroup =asnNoMaps.get(0); //【0】 新的asn group info
|
||||
Map<Long, AsnGroupInfo> oldAsnGroup =asnNoMaps.get(1); //【1】 旧的asn group info
|
||||
Map<Long, AsnGroupInfo> allAsnGroup =asnNoMaps.get(2); //【2】 所有的asn group info
|
||||
Map<Long, AsnGroupInfo> auditedAsnNoMap=asnNoMaps.get(3); //【3】已下发的所有asn信息【失效所有的asn 编译】
|
||||
deleteAsnCompile=auditedAsnNoMap;
|
||||
//保存新增的asn 信息
|
||||
if(!newAsnGroup.isEmpty()){
|
||||
index=0;
|
||||
List<Integer> compileIds=ConfigServiceUtil.getId(1, newAsnGroup.size());
|
||||
List<Integer> groupIds=ConfigServiceUtil.getId(2, newAsnGroup.size());
|
||||
List<Integer> regionIds=ConfigServiceUtil.getId(3, newAsnGroup.size());
|
||||
int onlyGroupId=0;//用于ip地址中下发配置组号
|
||||
for(Entry<Long, AsnGroupInfo> e:newAsnGroup.entrySet()) {
|
||||
AsnGroupInfo asnGroupInfo=e.getValue();
|
||||
asnGroupInfo.setAsnId(e.getKey());
|
||||
asnGroupInfo.setIsValid(0);
|
||||
asnGroupInfo.setIsUsed(0);
|
||||
asnGroupInfo.setCreatorId(UserUtils.getUser().getId());
|
||||
asnGroupInfo.setCreateTime(createTime);
|
||||
asnGroupInfo.setGroupId(groupIds.get(index));
|
||||
asnGroupInfo.setCompileId(compileIds.get(index));
|
||||
asnGroupInfo.setRegionId(regionIds.get(index));
|
||||
asnGroupInfo.setOrgGroupId(asnOrgList.get(1).get(asnGroupInfo.getOrganization()).getGroupId());
|
||||
//新增组号用于ip地址新增业务
|
||||
List<Integer> onlyGroupIds= ConfigServiceUtil.getId(2,1);
|
||||
if(onlyGroupIds.size()>0) {
|
||||
onlyGroupId=onlyGroupIds.get(0).intValue();
|
||||
}else {
|
||||
throw new MaatConvertException("Get asn group id failed");
|
||||
}
|
||||
asnGroupInfo.setOnlyGroupId(onlyGroupId);
|
||||
asnNoMaps.get(0).put(e.getKey(), asnGroupInfo);//设置完各种id后更新map数据
|
||||
asnNoMaps.get(2).put(e.getKey(), asnGroupInfo);//设置完各种id后更新map数据
|
||||
((AsnGroupInfoDao) batchSqlSession.getMapper(AsnGroupInfoDao.class)).insertWithId(asnGroupInfo);
|
||||
if(index != 0 && index%Constants.IMPORT_LIMIT==0) {
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
index++;
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
//保存旧的asn信息
|
||||
/*if(!oldAsnGroup.isEmpty()){
|
||||
index=0;
|
||||
for(Entry<Long, AsnGroupInfo> e:oldAsnGroup.entrySet()) {
|
||||
AsnGroupInfo asnGroupInfo=e.getValue();
|
||||
asnGroupInfo.setIsValid(0);
|
||||
asnGroupInfo.setOrgGroupId(asnOrgList.get(1).get(asnGroupInfo.getOrganization()).getGroupId());
|
||||
((AsnGroupInfoDao) batchSqlSession.getMapper(AsnGroupInfoDao.class)).insertWithoutId(asnGroupInfo);
|
||||
if(index != 0 && index%Constants.IMPORT_LIMIT==0) {
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
index++;
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
//6、配置取消所有编译[编译取消,编译下的所有group和region都会取消(已和服务端确认)]
|
||||
/*if(!StringUtil.isEmpty(deleteAsnCompile)){
|
||||
long startAudit=System.currentTimeMillis();
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
List<GroupCfg> groupRelationList = new ArrayList();
|
||||
List<IpCfg> ipRegionList = new ArrayList();
|
||||
List<StringCfg> strRegionList = new ArrayList();
|
||||
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
||||
List<DigestCfg> digestRegionList = new ArrayList();
|
||||
List<IpCfg> areaIpRegionList = new ArrayList();
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(600);
|
||||
for(Entry<Long, AsnGroupInfo> e:deleteAsnCompile.entrySet()) {
|
||||
maatCfg.setCompileId(e.getValue().getCompileId());
|
||||
maatCfg.setServiceId(serviceId);
|
||||
maatCfg.setIsValid(0);//无效
|
||||
configCompileList.add(maatCfg);
|
||||
}
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(createTime);
|
||||
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口取消配置
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("ASN IP 业务的编译配置全部失效参数:"+json);
|
||||
long auditEnd=System.currentTimeMillis();
|
||||
logger.warn("Cancle all ASN compile finish,cost:"+(auditEnd-startAudit));
|
||||
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
||||
logger.info("ASN IP所有编译取消返回结果:"+result.getMsg());
|
||||
long resultEnd=System.currentTimeMillis();
|
||||
logger.warn("Cancle all ASN compile finish,cost:"+(resultEnd-auditEnd));
|
||||
}*/
|
||||
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("Save group finish,cost:"+(end-start));
|
||||
}
|
||||
@@ -223,6 +505,8 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
ConfigGroupInfo configGroupInfo=new ConfigGroupInfo();
|
||||
configGroupInfo.setGroupName(org);
|
||||
configGroupInfo.setIsIssued(0);
|
||||
configGroupInfo.setIsUsed(0);
|
||||
configGroupInfo.setIsAuditAll(0);
|
||||
configGroupInfo.setGroupType(4);
|
||||
configGroupInfo.setInsertTime(new Date());
|
||||
configGroupInfo.setGroupId(groupIds.get(index));
|
||||
@@ -375,6 +659,76 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
asnIPRegionSendToMaat(auditAsnIpList,Constants.VALID_YES,Constants.OPACTION_POST);
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算用户修改后的IP段
|
||||
* @param entity
|
||||
*/
|
||||
public void checkAsnIp(AsnIpCfg entity) {
|
||||
long start=System.currentTimeMillis();
|
||||
logger.info("开始计算ASN IP:");
|
||||
List<String[]> resultIpList=new ArrayList<>();
|
||||
boolean flag=true;
|
||||
if(!StringUtil.isEmpty(entity.getId())) {
|
||||
AsnIpCfg oldAsnIp=asnIpCfgDao.getOne(entity);
|
||||
if(oldAsnIp.getDestIpAddress().equals(entity.getDestIpAddress())) {
|
||||
flag=false;
|
||||
}
|
||||
}
|
||||
//开始校验
|
||||
if(flag) {
|
||||
String nowIp=entity.getDestIpAddress().split("/")[0];
|
||||
int nowIpMask=Integer.parseInt(entity.getDestIpAddress().split("/")[1]);
|
||||
List<String> nowIpList=IPUtil.getIPRange(nowIp,nowIpMask);
|
||||
|
||||
//根据asn 和iptype 获取asn下的所有ip(除当前IP外的)
|
||||
List<AsnIpCfg> asnIpList=asnIpCfgDao.getASNIPList(entity);
|
||||
int equal=0;
|
||||
int containsLeftAndRight=0;
|
||||
int containsLeft=0;
|
||||
int containsRight=0;
|
||||
int whithoutLeftAndRight=0;
|
||||
String equalStr="";
|
||||
String containsLeftAndRightStr="";
|
||||
String containsLeftStr="";
|
||||
String containsRightStr="";
|
||||
String whithoutLeftAndRightStr="";
|
||||
for (AsnIpCfg asnIpCfg : asnIpList) {
|
||||
String ip=asnIpCfg.getDestIpAddress().split("/")[0];
|
||||
int ipMask=Integer.parseInt(asnIpCfg.getDestIpAddress().split("/")[1]);
|
||||
List<String> ipList=IPUtil.getIPRange(ip, ipMask);
|
||||
//左等 && 右等
|
||||
if((nowIpList.get(0).equals(ipList.get(0))) && (nowIpList.get(nowIpList.size()-1).equals(ipList.get(ipList.size()-1)))) {
|
||||
equal++;
|
||||
equalStr+=asnIpCfg.getDestIpAddress()+",";
|
||||
//左在里面,右在里面
|
||||
}else if((ipList.contains(nowIpList.get(0))) && (ipList.contains(nowIpList.get(nowIpList.size()-1)))) {
|
||||
containsLeftAndRight++;
|
||||
containsLeftAndRightStr+=asnIpCfg.getDestIpAddress()+",";
|
||||
//只有左在里面
|
||||
}else if(ipList.contains(nowIpList.get(0))){
|
||||
containsLeft++;
|
||||
containsLeftStr+=asnIpCfg.getDestIpAddress()+",";
|
||||
//只有右在里面
|
||||
}else if(ipList.contains(nowIpList.get(nowIpList.size()-1))){
|
||||
containsRight++;
|
||||
containsRightStr+=asnIpCfg.getDestIpAddress()+",";
|
||||
//旧的左右都在新的里面
|
||||
}else if(nowIpList.contains(ipList.get(ipList.size()-1)) && nowIpList.contains(ipList.get(0))){
|
||||
whithoutLeftAndRight++;
|
||||
whithoutLeftAndRightStr+=asnIpCfg.getDestIpAddress()+",";
|
||||
}
|
||||
}
|
||||
logger.info("完全匹配:("+equal+")"+equalStr);
|
||||
logger.info("中间交集(被包含):("+containsLeftAndRight+")"+containsLeftAndRightStr);
|
||||
logger.info("左侧交集:("+containsLeft+")"+containsLeftStr);
|
||||
logger.info("右侧交集:("+containsLeft+")"+containsLeftStr);
|
||||
logger.info("中间交集(包含):("+whithoutLeftAndRight+")"+whithoutLeftAndRightStr);
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.info("结束计算ASN IP:"+(end-start));
|
||||
}
|
||||
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void delete(String ids) {
|
||||
/*for(String id:ids.split(",")) {
|
||||
@@ -510,114 +864,138 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
List<AsnGroupInfo> auditAsnGroupList=new ArrayList<>();
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
final SqlSession batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
Integer serviceId=0;
|
||||
try{
|
||||
int issuedNum=asnIpCfgs.size();
|
||||
for(int index = 0; index < asnIpCfgs.size();index++){
|
||||
AsnIpCfg t = asnIpCfgs.get(index);
|
||||
BaseIpCfg ipCfg=new BaseIpCfg();
|
||||
BeanUtils.copyProperties(t, ipCfg);
|
||||
ipCfg.setTableName(AsnIpCfg.getTablename());
|
||||
((IpCfgDao) batchSqlSession.getMapper(IpCfgDao.class)).audit(ipCfg);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
AsnGroupInfo asnGroupInfo=new AsnGroupInfo();
|
||||
asnGroupInfo.setAsnId(asn);
|
||||
asnGroupInfo=asnGroupInfoDao.getInfoByAsnNo(asnGroupInfo);
|
||||
Integer groupId=asnGroupInfo.getGroupId();
|
||||
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
List<GroupCfg> groupRelationList = new ArrayList();
|
||||
List<IpCfg> ipRegionList = new ArrayList();
|
||||
List<StringCfg> strRegionList = new ArrayList();
|
||||
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
||||
List<DigestCfg> digestRegionList = new ArrayList();
|
||||
List<IpCfg> areaIpRegionList = new ArrayList();
|
||||
|
||||
if(isValid==Constants.VALID_YES) {//审核通过
|
||||
if(asnGroupInfo.getIsValid()==0) {//ans组未下发过,下发编译配置
|
||||
asnGroupInfo.setIsValid(1);
|
||||
asnGroupInfo.setEditorId(UserUtils.getUser().getId());
|
||||
asnGroupInfo.setEditTime(new Date());
|
||||
asnGroupInfo.setIssuedIPs(issuedNum+0L);
|
||||
asnGroupInfoDao.updateValid(asnGroupInfo);
|
||||
maatCfg.initDefaultValue();
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
//group
|
||||
GroupCfg groupCfg=new GroupCfg();
|
||||
groupCfg.setCompileId(asnGroupInfo.getCompileId());
|
||||
groupCfg.setGroupId(groupId);
|
||||
groupCfg.setIsValid(Constants.VALID_YES);
|
||||
//asnGroupId标记为公共组
|
||||
groupCfg.setIsCommonGroup(1);
|
||||
groupCfg.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
groupRelationList.add(groupCfg);
|
||||
BeanUtils.copyProperties(asnIpCfgs.get(0), maatCfg);
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_YES,groupId));
|
||||
maatCfg.setCompileId(asnGroupInfo.getCompileId());
|
||||
maatCfg.setAction(asnIpCfgs.get(0).getAction());
|
||||
maatCfg.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
maatCfg.setIpRegionList(ipRegionList);
|
||||
maatCfg.setStrRegionList(strRegionList);
|
||||
maatCfg.setNumRegionList(numRegionList);
|
||||
maatCfg.setDigestRegionList(digestRegionList);
|
||||
maatCfg.setGroupRelationList(groupRelationList);
|
||||
maatCfg.setGroupNum(groupRelationList.size());
|
||||
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||
maatCfg.setIsValid(isValid);
|
||||
// 设置ASN自定义域
|
||||
String userRegion = "ASN_ID=" + asnIpCfgs.get(0).getUserRegion1();
|
||||
maatCfg.setUserRegion(userRegion);
|
||||
configCompileList.add(maatCfg);
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||
// 调用服务接口下发配置数据
|
||||
String json = gsonToJson(maatBean);
|
||||
logger.info("ASN IP配置下发配置参数:" + json);
|
||||
// 调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||
logger.info("ASN IP配置下发响应信息:" + result.getMsg());
|
||||
}else if(asnGroupInfo.getIsValid()==1){//已经下发过,走分组复用
|
||||
asnGroupInfo.setIssuedIPs(issuedNum+0l);
|
||||
asnGroupInfoDao.update(asnGroupInfo);
|
||||
asnIPRegionSendToMaat(asnIpCfgs,isValid,Constants.OPACTION_POST);
|
||||
}else {
|
||||
throw new RuntimeException("asnGroupInfo isValid value is "+asnGroupInfo.getIsValid());
|
||||
}
|
||||
}else if(isValid==Constants.VALID_NO) {//取消审核通过
|
||||
asnGroupInfo.setIssuedIPs(0L-issuedNum);
|
||||
asnGroupInfoDao.update(asnGroupInfo);
|
||||
//已经下发过的,调用分组复用配置删除接口
|
||||
GroupReuseAddBean maatBean = new GroupReuseAddBean();
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_NO,groupId));
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(strRegionList);
|
||||
groupReuseCfg.setNumRegionList(numRegionList);
|
||||
groupReuseList.add(groupReuseCfg);
|
||||
maatBean.setGroupReuseCfgList(groupReuseList);
|
||||
maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("ASN IP域删除配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
||||
logger.info("ASN IP域删除配置响应信息:"+result.getMsg());
|
||||
//如果一个asn组下没有IP了,修改有效状态
|
||||
if(hasValidAsnIp(asn)) {
|
||||
asnGroupInfo.setIsValid(0);
|
||||
asnGroupInfo.setEditorId(UserUtils.getUser().getId());
|
||||
asnGroupInfo.setEditTime(new Date());
|
||||
asnGroupInfoDao.updateValid(asnGroupInfo);
|
||||
if(!StringUtil.isEmpty(asnIpCfgs)){
|
||||
serviceId=asnIpCfgs.get(0).getServiceId();
|
||||
int issuedNum=asnIpCfgs.size();
|
||||
for(int index = 0; index < asnIpCfgs.size();index++){
|
||||
AsnIpCfg t = asnIpCfgs.get(index);
|
||||
BaseIpCfg ipCfg=new BaseIpCfg();
|
||||
BeanUtils.copyProperties(t, ipCfg);
|
||||
ipCfg.setTableName(AsnIpCfg.getTablename());
|
||||
((IpCfgDao) batchSqlSession.getMapper(IpCfgDao.class)).audit(ipCfg);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
AsnGroupInfo asnGroupInfo=new AsnGroupInfo();
|
||||
asnGroupInfo.setAsnId(asn);
|
||||
asnGroupInfo=asnGroupInfoDao.getInfoByAsnNo(asnGroupInfo);
|
||||
Integer groupId=asnGroupInfo.getGroupId();
|
||||
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
List<GroupCfg> groupRelationList = new ArrayList();
|
||||
List<IpCfg> ipRegionList = new ArrayList();
|
||||
List<StringCfg> strRegionList = new ArrayList();
|
||||
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
||||
List<DigestCfg> digestRegionList = new ArrayList();
|
||||
List<IpCfg> areaIpRegionList = new ArrayList();
|
||||
|
||||
if(isValid==Constants.VALID_YES) {//审核通过
|
||||
if(asnGroupInfo.getIsValid()==0) {//ans组未下发过,下发编译配置
|
||||
asnGroupInfo.setIsValid(1);
|
||||
asnGroupInfo.setEditorId(UserUtils.getUser().getId());
|
||||
asnGroupInfo.setEditTime(new Date());
|
||||
asnGroupInfo.setIssuedIPs(issuedNum+0L);
|
||||
asnGroupInfoDao.updateValid(asnGroupInfo);
|
||||
maatCfg.initDefaultValue();
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
//group
|
||||
GroupCfg groupCfg=new GroupCfg();
|
||||
groupCfg.setCompileId(asnGroupInfo.getCompileId());
|
||||
groupCfg.setGroupId(groupId);
|
||||
groupCfg.setIsValid(Constants.VALID_YES);
|
||||
//asnGroupId标记为公共组
|
||||
groupCfg.setIsCommonGroup(1);
|
||||
groupCfg.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
groupRelationList.add(groupCfg);
|
||||
BeanUtils.copyProperties(asnIpCfgs.get(0), maatCfg);
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_YES,groupId));
|
||||
maatCfg.setCompileId(asnGroupInfo.getCompileId());
|
||||
maatCfg.setAction(asnIpCfgs.get(0).getAction());
|
||||
maatCfg.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
maatCfg.setIpRegionList(ipRegionList);
|
||||
maatCfg.setStrRegionList(strRegionList);
|
||||
maatCfg.setNumRegionList(numRegionList);
|
||||
maatCfg.setDigestRegionList(digestRegionList);
|
||||
maatCfg.setGroupRelationList(groupRelationList);
|
||||
maatCfg.setGroupNum(groupRelationList.size());
|
||||
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||
maatCfg.setIsValid(isValid);
|
||||
// 设置ASN自定义域
|
||||
String userRegion = Constants.ASN_REGION_KEY+"=" +Constants.ASN_KEY+ asnIpCfgs.get(0).getUserRegion1();
|
||||
maatCfg.setUserRegion(userRegion);
|
||||
configCompileList.add(maatCfg);
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||
// 调用服务接口下发配置数据
|
||||
String json = gsonToJson(maatBean);
|
||||
logger.info("ASN IP配置下发配置参数:" + json);
|
||||
// 调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||
logger.info("ASN IP配置下发响应信息:" + result.getMsg());
|
||||
}else if(asnGroupInfo.getIsValid()==1){//已经下发过,走分组复用
|
||||
asnGroupInfo.setIssuedIPs(issuedNum+0l);
|
||||
asnGroupInfoDao.update(asnGroupInfo);
|
||||
asnIPRegionSendToMaat(asnIpCfgs,isValid,Constants.OPACTION_POST);
|
||||
}else {
|
||||
throw new RuntimeException("asnGroupInfo isValid value is "+asnGroupInfo.getIsValid());
|
||||
}
|
||||
}else if(isValid==Constants.VALID_NO) {//取消审核通过
|
||||
asnGroupInfo.setIssuedIPs(0L-issuedNum);
|
||||
asnGroupInfoDao.update(asnGroupInfo);
|
||||
|
||||
//如果一个asn组下没有IP了,修改有效状态,并且删除
|
||||
if(hasValidAsnIp(asn)) {
|
||||
//已经下发过的,调用分组复用配置删除接口
|
||||
GroupReuseAddBean maatBean = new GroupReuseAddBean();
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_NO,groupId));
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(strRegionList);
|
||||
groupReuseCfg.setNumRegionList(numRegionList);
|
||||
groupReuseList.add(groupReuseCfg);
|
||||
maatBean.setGroupReuseCfgList(groupReuseList);
|
||||
maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("ASN IP域删除配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
||||
logger.info("ASN IP域删除配置响应信息:"+result.getMsg());
|
||||
}else{
|
||||
asnGroupInfo.setIsValid(0);
|
||||
asnGroupInfo.setEditorId(UserUtils.getUser().getId());
|
||||
asnGroupInfo.setEditTime(new Date());
|
||||
asnGroupInfoDao.updateValid(asnGroupInfo);
|
||||
//asn group下没有asn ip之后,需要失效整个compileId,并且不保留公共组信息
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
maatCfg.setCompileId(asnGroupInfo.getCompileId());
|
||||
maatCfg.setServiceId(serviceId);
|
||||
maatCfg.setIsValid(0);//无效
|
||||
//configCompileList.add(addKeepGroupList(maatCfg,entity));
|
||||
configCompileList.add(maatCfg);
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(new Date());
|
||||
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口取消配置
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("asn ip配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
||||
logger.info("asn ip配置取消配置响应信息:"+result.getMsg());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
|
||||
@@ -372,6 +372,7 @@ public class AppCfgService extends BaseService {
|
||||
configGroupInfo.setGroupId(specificServiceCfg.getGroupId());
|
||||
configGroupInfo.setGroupName(specificServiceCfg.getSpecServiceName());
|
||||
configGroupInfo.setIsIssued(0);
|
||||
configGroupInfo.setInsertTime(new Date());
|
||||
configGroupInfo.setGroupType(1);
|
||||
configGroupInfo.setCompileId(compileId);
|
||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
|
||||
@@ -1168,7 +1169,9 @@ public class AppCfgService extends BaseService {
|
||||
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
||||
List<DigestCfg> digestRegionList = new ArrayList();
|
||||
List<IpCfg> areaIpRegionList = new ArrayList();
|
||||
Integer serviceId=0;
|
||||
this.auditAppIpCfg(entitys);
|
||||
serviceId=entitys.get(0).getServiceId();
|
||||
// for(AppIpCfg entity:entitys) {
|
||||
// // 保存区域IP信息
|
||||
// List<AreaIpCfg> areaIpCfgList = areaIpCfgDao.getByCompileId(entitys.get(0).getCompileId());
|
||||
@@ -1272,26 +1275,54 @@ public class AppCfgService extends BaseService {
|
||||
throw new RuntimeException("Unknown configGroupInfo isIssued value");
|
||||
}
|
||||
} else if (isAudit == 3) {
|
||||
//已经下发过的,调用分组复用配置删除接口
|
||||
GroupReuseAddBean maatBean = new GroupReuseAddBean();
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(entitys,Constants.VALID_NO,groupId));
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(strRegionList);
|
||||
groupReuseCfg.setNumRegionList(numRegionList);
|
||||
groupReuseList.add(groupReuseCfg);
|
||||
maatBean.setGroupReuseCfgList(groupReuseList);
|
||||
maatBean.setAuditTime(entitys.get(0).getAuditTime());
|
||||
maatBean.setCreatorName(entitys.get(0).getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("app协议IP域删除配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
||||
logger.info("app协议IP域删除配置响应信息:"+result.getMsg());
|
||||
//判断配置取消之后,是否还有有效的配置
|
||||
if(hasValidAppIp(configGroupInfo.getCompileId())){
|
||||
//已经下发过的,调用分组复用配置删除接口
|
||||
GroupReuseAddBean maatBean = new GroupReuseAddBean();
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(entitys,Constants.VALID_NO,groupId));
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(strRegionList);
|
||||
groupReuseCfg.setNumRegionList(numRegionList);
|
||||
groupReuseList.add(groupReuseCfg);
|
||||
maatBean.setGroupReuseCfgList(groupReuseList);
|
||||
maatBean.setAuditTime(entitys.get(0).getAuditTime());
|
||||
maatBean.setCreatorName(entitys.get(0).getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("app协议IP域删除配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
||||
logger.info("app协议IP域删除配置响应信息:"+result.getMsg());
|
||||
}else{
|
||||
//修改组的有效状态为无效。并发送compileid 配置取消 此后组的app ip不再自动下发。
|
||||
ConfigGroupInfo appConfigGroup=new ConfigGroupInfo();
|
||||
appConfigGroup.setIsIssued(0);
|
||||
appConfigGroup.setUpdateTime(new Date());
|
||||
appConfigGroup.setGroupId(configGroupInfo.getGroupId());
|
||||
configGroupInfoDao.updateConfigGroupInfobyGroupId(appConfigGroup);
|
||||
//asn group下没有asn ip之后,需要失效整个compileId,并且不保留公共组信息
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
maatCfg.setCompileId(configGroupInfo.getCompileId());
|
||||
maatCfg.setServiceId(serviceId);
|
||||
maatCfg.setIsValid(0);//无效
|
||||
//configCompileList.add(addKeepGroupList(maatCfg,entity));
|
||||
configCompileList.add(maatCfg);
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(new Date());
|
||||
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口取消配置
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("app Ip 取消配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
||||
logger.info("app Ip 取消配置响应信息:"+result.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1428,6 +1459,10 @@ public class AppCfgService extends BaseService {
|
||||
String userRegion = "APP_ID=" + entity.getAppCode() + Constants.USER_REGION_SPLIT + "DOMAIN_ID="
|
||||
+ entity.getCompileId() + Constants.USER_REGION_SPLIT + "DOMAIN_STR="
|
||||
+ keywordsEscape(entity.getCfgKeywords());
|
||||
if(!StringUtil.isEmpty(entity.getUserRegion5())){
|
||||
userRegion+=";"+Constants.INTERCEPT_DOMAN_INTENSITY_USER_REGION_KEY+"="+entity.getUserRegion5();
|
||||
}
|
||||
|
||||
maatCfg.setUserRegion(userRegion);
|
||||
configCompileList.add(maatCfg);
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
@@ -2116,4 +2151,13 @@ public class AppCfgService extends BaseService {
|
||||
|
||||
}
|
||||
|
||||
public boolean hasValidAppIp(Integer compileId){
|
||||
List<AppIpCfg> appIps=appCfgDao.findAppIpByCompileId(compileId);
|
||||
if(!StringUtil.isEmpty(appIps)){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,29 +77,32 @@ public class CachePolicyService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
entity.setPage(page);
|
||||
List<CachePolicyUserRegion> list = commonPolicyDao.getCachePolicyUserRegionList(entity);
|
||||
for (CachePolicyUserRegion c : list) {
|
||||
JSONObject jsonObject=JSONObject.fromObject(c.getUserRegion1());
|
||||
CachePolicyUserRegion stu=(CachePolicyUserRegion)JSONObject.toBean(jsonObject, CachePolicyUserRegion.class);
|
||||
c.setCache_cookied_cont(stu.getCache_cookied_cont());
|
||||
c.setCache_dyn_url(stu.getCache_dyn_url());
|
||||
c.setForce_caching(stu.getForce_caching());
|
||||
c.setIgnore_req_nocache(stu.getIgnore_req_nocache());
|
||||
c.setIgnore_res_nocache(stu.getIgnore_res_nocache());
|
||||
c.setInactive_time(stu.getInactive_time());
|
||||
c.setMax_cache_obj_size(stu.getMax_cache_obj_size());
|
||||
c.setMax_cache_size(stu.getMax_cache_size());
|
||||
c.setMin_use(stu.getMin_use());
|
||||
c.setNo_revalidate(stu.getNo_revalidate());
|
||||
c.setPinning_time(stu.getPinning_time());
|
||||
if(stu.getCache_key()!=null){
|
||||
String ignore=String.valueOf(stu.getCache_key().get("ignore_qs"));
|
||||
String cookie=String.valueOf(stu.getCache_key().get("cookie"));
|
||||
if(!ignore.equals("null") && ignore!=null){
|
||||
c.setIgnore_qs(ignore);
|
||||
}
|
||||
if(!cookie.equals("null") && cookie!=null){
|
||||
c.setCookie(cookie);
|
||||
}
|
||||
}
|
||||
if(!StringUtil.isBlank(c.getUserRegion1())) { // action为缓存白名单时 userRegion1 为null
|
||||
JSONObject jsonObject=JSONObject.fromObject(c.getUserRegion1());
|
||||
CachePolicyUserRegion stu=(CachePolicyUserRegion)JSONObject.toBean(jsonObject, CachePolicyUserRegion.class);
|
||||
c.setCache_cookied_cont(stu.getCache_cookied_cont());
|
||||
c.setCache_dyn_url(stu.getCache_dyn_url());
|
||||
c.setForce_caching(stu.getForce_caching());
|
||||
c.setIgnore_req_nocache(stu.getIgnore_req_nocache());
|
||||
c.setIgnore_res_nocache(stu.getIgnore_res_nocache());
|
||||
c.setInactive_time(stu.getInactive_time());
|
||||
c.setMax_cache_obj_size(stu.getMax_cache_obj_size());
|
||||
c.setMax_cache_size(stu.getMax_cache_size());
|
||||
c.setMin_use(stu.getMin_use());
|
||||
c.setNo_revalidate(stu.getNo_revalidate());
|
||||
c.setPinning_time(stu.getPinning_time());
|
||||
if(stu.getCache_key()!=null){
|
||||
String ignore=String.valueOf(stu.getCache_key().get("ignore_qs"));
|
||||
String cookie=String.valueOf(stu.getCache_key().get("cookie"));
|
||||
if(!ignore.equals("null") && ignore!=null){
|
||||
c.setIgnore_qs(ignore);
|
||||
}
|
||||
if(!cookie.equals("null") && cookie!=null){
|
||||
c.setCookie(cookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
page.setList(list);
|
||||
return page;
|
||||
@@ -109,20 +112,21 @@ public class CachePolicyService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
public List<CachePolicyUserRegion> getCachePolicyByUserRegionList(String ids){
|
||||
List<CachePolicyUserRegion> list = commonPolicyDao.getCachePolicyByUserRegionList(ids);
|
||||
for (CachePolicyUserRegion c : list) {
|
||||
JSONObject jsonObject=JSONObject.fromObject(c.getUserRegion1());
|
||||
CachePolicyUserRegion stu=(CachePolicyUserRegion)JSONObject.toBean(jsonObject, CachePolicyUserRegion.class);
|
||||
c.setCache_cookied_cont(stu.getCache_cookied_cont());
|
||||
c.setCache_dyn_url(stu.getCache_dyn_url());
|
||||
c.setForce_caching(stu.getForce_caching());
|
||||
c.setIgnore_req_nocache(stu.getIgnore_req_nocache());
|
||||
c.setIgnore_res_nocache(stu.getIgnore_res_nocache());
|
||||
c.setInactive_time(stu.getInactive_time());
|
||||
c.setMax_cache_obj_size(stu.getMax_cache_obj_size());
|
||||
c.setMax_cache_size(stu.getMax_cache_size());
|
||||
c.setMin_use(stu.getMin_use());
|
||||
c.setNo_revalidate(stu.getNo_revalidate());
|
||||
c.setPinning_time(stu.getPinning_time());
|
||||
if(stu.getCache_key()!=null){
|
||||
if(!StringUtil.isBlank(c.getUserRegion1())) { // action为缓存白名单时 userRegion1 为null
|
||||
JSONObject jsonObject=JSONObject.fromObject(c.getUserRegion1());
|
||||
CachePolicyUserRegion stu=(CachePolicyUserRegion)JSONObject.toBean(jsonObject, CachePolicyUserRegion.class);
|
||||
c.setCache_cookied_cont(stu.getCache_cookied_cont());
|
||||
c.setCache_dyn_url(stu.getCache_dyn_url());
|
||||
c.setForce_caching(stu.getForce_caching());
|
||||
c.setIgnore_req_nocache(stu.getIgnore_req_nocache());
|
||||
c.setIgnore_res_nocache(stu.getIgnore_res_nocache());
|
||||
c.setInactive_time(stu.getInactive_time());
|
||||
c.setMax_cache_obj_size(stu.getMax_cache_obj_size());
|
||||
c.setMax_cache_size(stu.getMax_cache_size());
|
||||
c.setMin_use(stu.getMin_use());
|
||||
c.setNo_revalidate(stu.getNo_revalidate());
|
||||
c.setPinning_time(stu.getPinning_time());
|
||||
if(stu.getCache_key()!=null){
|
||||
String ignore=String.valueOf(stu.getCache_key().get("ignore_qs"));
|
||||
String cookie=String.valueOf(stu.getCache_key().get("cookie"));
|
||||
if(!ignore.equals("null") && ignore!=null){
|
||||
@@ -131,7 +135,8 @@ public class CachePolicyService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
if(!cookie.equals("null") && cookie!=null){
|
||||
c.setCookie(cookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -81,13 +81,13 @@ public class DdosCfgService extends BaseService{
|
||||
if(StringUtil.isBlank(antiddosProtocol)) {
|
||||
entity.setAntiddosProtocol("");
|
||||
entity.setBpsThreadshold(0l);
|
||||
entity.setBpsThreadshold(0l);
|
||||
entity.setPpsThreadshold(0l);
|
||||
}
|
||||
if(bpsThreadshold==null) {
|
||||
entity.setBpsThreadshold(0l);
|
||||
}
|
||||
if(ppsThreadshold==null) {
|
||||
entity.setBpsThreadshold(0l);
|
||||
entity.setPpsThreadshold(0l);
|
||||
}
|
||||
//新增
|
||||
if(entity.getCfgId()==null){
|
||||
|
||||
@@ -426,14 +426,14 @@ public class DomainService extends CrudService<DomainDao,HttpUrlCfg> {
|
||||
return entity;
|
||||
}
|
||||
public void saveDomainCfg(CfgIndexInfo entity){
|
||||
if(entity.getAction()==128){
|
||||
/*if(entity.getAction()==128){
|
||||
entity.setCfgType("WHITE_LIST_DOMAIN");
|
||||
if(entity.getHttpUrlList().size()>0){
|
||||
for (int i = 0; i < entity.getHttpUrlList().size(); i++) {
|
||||
entity.getHttpUrlList().get(i).setCfgType("WHITE_LIST_DOMAIN");
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
//设置区域运营商信息
|
||||
setAreaEffectiveIds(entity);
|
||||
|
||||
|
||||
@@ -54,6 +54,10 @@ public class HttpRedirectCfgService extends CrudService<WebsiteCfgDao,CfgIndexIn
|
||||
@Autowired
|
||||
protected StringCfgDao stringCfgDao;
|
||||
|
||||
public List<CfgIndexInfo> getCfgIndexInfos(CfgIndexInfo entity){
|
||||
return websiteCfgDao.getCfgIndexInfos(entity);
|
||||
}
|
||||
|
||||
public CfgIndexInfo getHttpCfg(Long cfgId,Integer compileId){
|
||||
CfgIndexInfo entity = websiteCfgDao.getCfgIndexInfo(cfgId,compileId);
|
||||
List<HttpUrlCfg> httpUrlList = websiteCfgDao.getHttpUrlList(entity);
|
||||
|
||||
@@ -560,7 +560,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
}
|
||||
//asn配置下发
|
||||
auditAsnCfg(groupRelationList,strRegionList,entity,entity.getAsnKeywords());
|
||||
auditAsnCfgForIpAddr(groupRelationList,strRegionList,entity,entity.getAsnKeywords());
|
||||
//保存区域IP信息
|
||||
List<AreaIpCfg> areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId());
|
||||
if(!StringUtil.isEmpty(areaIpCfgList)){
|
||||
@@ -863,19 +863,15 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
List<NtcSubscribeIdCfg> subscribeIdList = stringCfgDao.findSubscribeIdCfgListByCfgIndexInfo(entity);
|
||||
entity.setIpPortList(ipPortList);
|
||||
entity.setNtcSubscribeIdCfgList(subscribeIdList);
|
||||
if(StringUtils.isNotBlank(entity.getCommonGroupIds())) {
|
||||
List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
|
||||
entity.setAsnKeywords(asnKeywordCfgs);
|
||||
}
|
||||
List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
|
||||
entity.setAsnKeywords(asnKeywordCfgs);
|
||||
return entity;
|
||||
}
|
||||
public CfgIndexInfo exportIpInfo(CfgIndexInfo entity){
|
||||
List<IpPortCfg> ipPortList = ipCfgDao.getIpPortList(entity);
|
||||
entity.setIpPortList(ipPortList);
|
||||
if(StringUtils.isNotBlank(entity.getUserRegion4())) {
|
||||
List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
|
||||
entity.setAsnKeywords(asnKeywordCfgs);
|
||||
}
|
||||
List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
|
||||
entity.setAsnKeywords(asnKeywordCfgs);
|
||||
return entity;
|
||||
}
|
||||
public BaseIpCfg getIpCfgById(String tableName,long id){
|
||||
|
||||
@@ -327,4 +327,14 @@ public class IpMultiplexService extends BaseService{
|
||||
public IpReuseDnatPolicyCfg getDnatCfg(Long cfgId,Integer compileId) {
|
||||
return ipMultiplexDao.getDnatCfg(cfgId,compileId);
|
||||
}
|
||||
|
||||
public List<IpReusePolicyCfg> findByUser(String userName) {
|
||||
List<IpReusePolicyCfg> list=ipMultiplexDao.findByUser(userName);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<IpReuseDnatPolicyCfg> findDnatUser(String userName) {
|
||||
List<IpReuseDnatPolicyCfg> list=ipMultiplexDao.findDnatUser(userName);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ public class UserManageService extends BaseService{
|
||||
return page;
|
||||
}
|
||||
|
||||
public List<UserManage> findList(UserManage entity) {
|
||||
List<UserManage> list=userManageDao.findList(entity);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<UserManage> findByPage(String ids ) {
|
||||
List<UserManage> list=userManageDao.findByList(ids);
|
||||
return list;
|
||||
|
||||
@@ -227,6 +227,7 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
|
||||
entity.setCompileId(compileId);
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||||
entity.setRequestId(StringUtil.isEmpty(entity.getRequestId()) ? 0:entity.getRequestId());
|
||||
websiteCfgDao.saveCfgIndex(entity);
|
||||
if(entity.getIpPortList()!=null){
|
||||
for(IpPortCfg cfg:entity.getIpPortList()){
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.nis.web.service.specific;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -16,6 +18,14 @@ public class ConfigGroupInfoService extends BaseService{
|
||||
public List<ConfigGroupInfo> findAllList(int groupType){
|
||||
return configGroupInfoDao.findAllList(groupType);
|
||||
}
|
||||
public Map<String,ConfigGroupInfo> getConfigGroupInfo(List<Map<String,ConfigGroupInfo>> orgList,int groupType){
|
||||
Map<String,ConfigGroupInfo> configGroupInfoMap=new HashMap<>();
|
||||
List<ConfigGroupInfo> configGroupInfos=this.findAllList(groupType);
|
||||
for (ConfigGroupInfo configGroupInfo : configGroupInfos) {
|
||||
orgList.get(1).put(configGroupInfo.getGroupName(), configGroupInfo);
|
||||
}
|
||||
return configGroupInfoMap;
|
||||
}
|
||||
public ConfigGroupInfo insertConfigGroupInfo(ConfigGroupInfo entity) {
|
||||
configGroupInfoDao.insertConfigGroupInfo(entity);
|
||||
return entity;
|
||||
|
||||
@@ -92,6 +92,7 @@ public class SpecificServiceCfgService extends BaseService{
|
||||
group.setGroupName(specificServiceCfg.getSpecServiceName());
|
||||
group.setIsIssued(0);
|
||||
group.setGroupType(1);
|
||||
group.setInsertTime(new Date());
|
||||
if(specificServiceCfg.getCfgType()==1) {
|
||||
Integer compileId = ConfigServiceUtil.getId(1, 1).get(0);
|
||||
group.setCompileId(compileId);
|
||||
|
||||
131
src/main/java/com/nis/web/task/StatisticASNIpNumer.java
Normal file
131
src/main/java/com/nis/web/task/StatisticASNIpNumer.java
Normal file
@@ -0,0 +1,131 @@
|
||||
package com.nis.web.task;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.nis.domain.basics.AsnGroupInfo;
|
||||
import com.nis.domain.basics.AsnIpCfg;
|
||||
import com.nis.util.IPUtil;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.basics.AsnGroupInfoDao;
|
||||
import com.nis.web.dao.basics.AsnIpCfgDao;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
/**
|
||||
* 定时统计ASN 下IPv4和IPV6的个数
|
||||
* @author intraUser
|
||||
*
|
||||
*/
|
||||
public class StatisticASNIpNumer {
|
||||
|
||||
private Logger logger = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
protected AsnIpCfgDao asnIpCfgDao;
|
||||
public void calculateASNIp() {
|
||||
logger.info("定时统计ASN IP个数开始。。。。。。。。。。。。。。");
|
||||
long start=System.currentTimeMillis();
|
||||
Map<Integer,Map<String,Long>> asnNumerMap=new HashMap<>();
|
||||
List<Object[]> asnIpList=new ArrayList<>();
|
||||
asnIpList=asnIpCfgDao.findAllAsnIpCfgList();
|
||||
|
||||
getAllASNIPNumber(asnIpList, asnNumerMap);
|
||||
|
||||
updateAllASNIPNumber(asnNumerMap);
|
||||
|
||||
long end=System.currentTimeMillis();
|
||||
logger.info("定时统计ASN IP个数结束:"+(end-start)+"。。。。。。。。。。。。。。");
|
||||
}
|
||||
public void getAllASNIPNumber(List<Object[]> asnIpList,Map<Integer,Map<String,Long>> asnNumerMap){
|
||||
logger.info("计算ASN IP开始:asn ip size:"+asnIpList.size()+"。。。。。。。。。。。。。。");
|
||||
long start=System.currentTimeMillis();
|
||||
if(!StringUtil.isEmpty(asnIpList)){
|
||||
try {
|
||||
for (Iterator iterator = asnIpList.iterator(); iterator.hasNext();) {
|
||||
Map asnIpMap=(Map) iterator.next();
|
||||
//groupId
|
||||
Integer asnGroupId = (Integer)asnIpMap.get("asn_ip_group");
|
||||
//ipType(4:v4,6:v6)
|
||||
Integer ipType= (Integer)asnIpMap.get("ip_type");
|
||||
//(1:mask,2:range,3:ip)
|
||||
//Integer ipPattern= (Integer)asnIpMap.get("ip_pattern");
|
||||
//dest_ip_address
|
||||
String ipAddress= (String)asnIpMap.get("dest_ip_address");
|
||||
long IPNumber=0;
|
||||
if(ipType.equals(4)){
|
||||
if(ipAddress.indexOf("/") > -1){
|
||||
Integer mask=Integer.parseInt(ipAddress.split("/")[1]);
|
||||
ipAddress=ipAddress.split("/")[0];
|
||||
IPNumber=IPUtil.getIpNum(ipAddress, mask);
|
||||
}else{
|
||||
IPNumber=1;
|
||||
}
|
||||
//判断组是否已经存在
|
||||
if(asnNumerMap.keySet().contains(asnGroupId)){
|
||||
asnNumerMap.get(asnGroupId).put("v4", asnNumerMap.get(asnGroupId).get("v4")+IPNumber);
|
||||
asnNumerMap.put(asnGroupId, asnNumerMap.get(asnGroupId));
|
||||
}else{
|
||||
Map<String, Long> map=new HashMap<>();
|
||||
map.put("v4", IPNumber);
|
||||
map.put("v6", 0l);
|
||||
asnNumerMap.put(asnGroupId, map);
|
||||
}
|
||||
}else{
|
||||
IPNumber=1;
|
||||
//判断组是否已经存在
|
||||
if(asnNumerMap.keySet().contains(asnGroupId)){
|
||||
asnNumerMap.get(asnGroupId).put("v6", asnNumerMap.get(asnGroupId).get("v6")+IPNumber);
|
||||
asnNumerMap.put(asnGroupId, asnNumerMap.get(asnGroupId));
|
||||
}else{
|
||||
Map<String, Long> map=new HashMap<>();
|
||||
map.put("v4", 0l);
|
||||
map.put("v6", IPNumber);
|
||||
asnNumerMap.put(asnGroupId, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("计算ASN IP个数失败",e);
|
||||
}
|
||||
}
|
||||
|
||||
long end=System.currentTimeMillis();
|
||||
logger.info("计算ASN IP个数结束:"+(end-start)+"。。。。。。。。。。。。。。");
|
||||
}
|
||||
public void updateAllASNIPNumber(Map<Integer,Map<String,Long>> asnNumerMap) {
|
||||
logger.info("修改ASN IP个数开始:asn size:"+asnNumerMap.size()+"。。。。。。。。。。。。。。");
|
||||
long start=System.currentTimeMillis();
|
||||
if(!StringUtil.isEmpty(asnNumerMap)){
|
||||
int index=0;
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try {
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, true);
|
||||
for(Entry<Integer,Map<String,Long>> e: asnNumerMap.entrySet()) {
|
||||
((AsnGroupInfoDao) batchSqlSession.getMapper(AsnGroupInfoDao.class)).updateIpNum(e.getValue().get("v4"),e.getValue().get("v6"),e.getKey());
|
||||
batchSqlSession.commit();
|
||||
index++;
|
||||
}
|
||||
}catch (Exception e) {
|
||||
logger.error("修改ASN IP个数失败", e);
|
||||
} finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.info("修改ASN IP个数结束:"+(end-start)+"。。。。。。。。。。。。。。");
|
||||
}
|
||||
}
|
||||
52
src/main/resources/applicationContext-quartz.xml
Normal file
52
src/main/resources/applicationContext-quartz.xml
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:tool="http://www.springframework.org/schema/tool"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:task="http://www.springframework.org/schema/task"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
|
||||
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
|
||||
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
|
||||
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd"
|
||||
default-lazy-init="true">
|
||||
|
||||
<!-- 配置加载 任务执行类 -->
|
||||
<bean id="scheduleCfgJobDetail" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
|
||||
<property name="jobClass" value="com.nis.quartz.ScheduleCfgJob"/>
|
||||
<property name="name" value="scheduleCfgJobDetail" />
|
||||
<property name="group" value="cfg" />
|
||||
</bean>
|
||||
|
||||
<!-- 定时检查 schedule_cfg 表 -->
|
||||
<bean id="scheduleCfgSimpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
|
||||
<property name="jobDetail">
|
||||
<ref bean="scheduleCfgJobDetail" />
|
||||
</property>
|
||||
<property name="repeatInterval" value="10000" /><!-- 间隔 10s 执行一次 -->
|
||||
<property name="startDelay" value="10000" /><!-- 延迟 10s 启动 -->
|
||||
<property name="name" value="scheduleCfgTri" />
|
||||
<property name="group" value="cfg" />
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- 定时任务 -->
|
||||
<bean id="NTCScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" >
|
||||
<property name="dataSource" ref="ProductDataSource" /><!-- 配置数据源 -->
|
||||
<property name="applicationContextSchedulerContextKey" value="applicationContextKey"/>
|
||||
<property name="configLocation" value="classpath:quartz.properties"/><!-- 加载配置文件 -->
|
||||
<property name="autoStartup" value="true" /><!-- 自启动 -->
|
||||
<property name="startupDelay" value="60" /><!-- 启动延迟时间 ,单位:s-->
|
||||
<property name="triggers">
|
||||
<list>
|
||||
<ref bean="scheduleCfgSimpleTrigger" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user