diff --git a/lib/maat-tools-0.0.1-SNAPSHOT.jar b/lib/maat-tools-0.0.1-SNAPSHOT.jar new file mode 100644 index 000000000..b62052acb Binary files /dev/null and b/lib/maat-tools-0.0.1-SNAPSHOT.jar differ diff --git a/src/main/java/com/nis/domain/configuration/AppIdCfg.java b/src/main/java/com/nis/domain/configuration/AppIdCfg.java index 6e66b5556..20281e980 100644 --- a/src/main/java/com/nis/domain/configuration/AppIdCfg.java +++ b/src/main/java/com/nis/domain/configuration/AppIdCfg.java @@ -32,11 +32,6 @@ public class AppIdCfg extends BaseCfg { */ private String appId; - /** - * 编译id - */ - private Integer compileId; - /** * appName * @return appName @@ -69,22 +64,6 @@ public class AppIdCfg extends BaseCfg { this.appId = appId; } - /** - * compileId - * @return compileId - */ - - public Integer getCompileId() { - return compileId; - } - - /** - * @param compileId the compileId to set - */ - public void setCompileId(Integer compileId) { - this.compileId = compileId; - } - /* (non-Javadoc) * @see com.nis.domain.configuration.BaseCfg#initDefaultValue() */ diff --git a/src/main/java/com/nis/domain/configuration/BaseCfg.java b/src/main/java/com/nis/domain/configuration/BaseCfg.java index e5e153481..f89173a85 100644 --- a/src/main/java/com/nis/domain/configuration/BaseCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseCfg.java @@ -22,7 +22,12 @@ import com.nis.domain.BaseEntity; * @version V1.0 */ public class BaseCfg extends BaseEntity { + protected String seltype;//选中类型,页面搜索用 protected String tableName; + /** + * 编译id + */ + protected Integer compileId ; @Expose @SerializedName("maatTable") protected String maatTable; @@ -630,6 +635,33 @@ public class BaseCfg extends BaseEntity { public void setSearch_audit_time_end(Date search_audit_time_end) { this.search_audit_time_end = search_audit_time_end; } + /** + * seltype + * @return seltype + */ + public String getSeltype() { + return seltype; + } + /** + * @param seltype the seltype to set + */ + public void setSeltype(String seltype) { + this.seltype = seltype; + } + /** + * compileId + * @return compileId + */ + + public Integer getCompileId() { + return compileId; + } + /** + * @param compileId the compileId to set + */ + public void setCompileId(Integer compileId) { + this.compileId = compileId; + } } diff --git a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java index 67ea4bdd9..586c01a3c 100644 --- a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java @@ -98,10 +98,6 @@ public class BaseIpCfg extends BaseCfg { @Expose @SerializedName("protocolId") protected Integer protocolId ; - /** - * 编译id - */ - protected Long compileId ; /** * ipType * @return ipType @@ -270,20 +266,6 @@ public class BaseIpCfg extends BaseCfg { public void setProtocolId(Integer protocolId) { this.protocolId = protocolId; } - /** - * compileId - * @return compileId - */ - - public Long getCompileId() { - return compileId; - } - /** - * @param compileId the compileId to set - */ - public void setCompileId(Long compileId) { - this.compileId = compileId; - } @Override public void initDefaultValue(){ super.initDefaultValue(); diff --git a/src/main/java/com/nis/domain/configuration/BaseStringCfg.java b/src/main/java/com/nis/domain/configuration/BaseStringCfg.java index 47644c805..b5f99ee4c 100644 --- a/src/main/java/com/nis/domain/configuration/BaseStringCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseStringCfg.java @@ -47,10 +47,6 @@ public class BaseStringCfg extends BaseCfg { public void setCfgKeywords(String cfgKeywords) { this.cfgKeywords = cfgKeywords; } - /** - * 编译id - */ - protected Long compileId ; /** * 表达式类型 */ @@ -120,19 +116,5 @@ public class BaseStringCfg extends BaseCfg { super.initDefaultValue(); this.isHexbin = 0; } - /** - * compile_id - * @return compile_id - */ - - public Long getCompileId() { - return compileId; - } - /** - * @param compile_id the compile_id to set - */ - public void setCompileId(Long compileId) { - this.compileId = compileId; - } } diff --git a/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java b/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java index e97195218..3717ad101 100644 --- a/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java +++ b/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java @@ -39,10 +39,6 @@ public class ComplexkeywordCfg extends BaseCfg{ @Expose @SerializedName("keywords") protected String keywords; - /** - * 编译id - */ - protected Long compileId; /** * 表达式类型 */ @@ -89,20 +85,6 @@ public class ComplexkeywordCfg extends BaseCfg{ public void setKeywords(String keywords) { this.keywords = keywords; } - /** - * compileId - * @return compileId - */ - - public Long getCompileId() { - return compileId; - } - /** - * @param compileId the compileId to set - */ - public void setCompileId(Long compileId) { - this.compileId = compileId; - } /** * exprType * 继承此类的类会覆盖该方法写自己的缺省值 diff --git a/src/main/java/com/nis/domain/configuration/MultipleCfg.java b/src/main/java/com/nis/domain/configuration/MultipleCfg.java new file mode 100644 index 000000000..a7c04354c --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/MultipleCfg.java @@ -0,0 +1,156 @@ +/** + *@Title: MultipleCfg.java + *@Package com.nis.domain.configuration + *@Description TODO + *@author dell + *@date 2018年3月13日 上午8:59:32 + *@version 版本号 + */ +package com.nis.domain.configuration; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: MultipleCfg.java + * @Description: TODO + * @author (dell) + * @date 2018年3月13日 上午8:59:32 + * @version V1.0 + */ +public class MultipleCfg extends BaseCfg { + + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = -8369567908781421920L; + private String mainTable; + private String mainTableType; + private List otherTables;//key 表名,value 类型 +// private BaseCfg mainCfg; + //ip配置 + private Map ipCfg; + //字符串配置 + private Map stringCfg; + //数值类配置 + private Map numCfg; + //增强字符串配置 + private Map complexCfg; + //地域配置 + private AreaIpCfg areaIpCfg; + /** + * mainTable + * @return mainTable + */ + + public String getMainTable() { + return mainTable; + } + /** + * @param mainTable the mainTable to set + */ + public void setMainTable(String mainTable) { + this.mainTable = mainTable; + } + /** + * areaIpCfg + * @return areaIpCfg + */ + + public AreaIpCfg getAreaIpCfg() { + return areaIpCfg; + } + /** + * @param areaIpCfg the areaIpCfg to set + */ + public void setAreaIpCfg(AreaIpCfg areaIpCfg) { + this.areaIpCfg = areaIpCfg; + } + /** + * ipCfg + * @return ipCfg + */ + + public Map getIpCfg() { + return ipCfg; + } + /** + * @param ipCfg the ipCfg to set + */ + public void setIpCfg(Map ipCfg) { + this.ipCfg = ipCfg; + } + /** + * stringCfg + * @return stringCfg + */ + + public Map getStringCfg() { + return stringCfg; + } + /** + * @param stringCfg the stringCfg to set + */ + public void setStringCfg(Map stringCfg) { + this.stringCfg = stringCfg; + } + /** + * numCfg + * @return numCfg + */ + + public Map getNumCfg() { + return numCfg; + } + /** + * @param numCfg the numCfg to set + */ + public void setNumCfg(Map numCfg) { + this.numCfg = numCfg; + } + /** + * complexCfg + * @return complexCfg + */ + + public Map getComplexCfg() { + return complexCfg; + } + /** + * @param complexCfg the complexCfg to set + */ + public void setComplexCfg(Map complexCfg) { + this.complexCfg = complexCfg; + } + /** + * mainTableType + * @return mainTableType + */ + + public String getMainTableType() { + return mainTableType; + } + /** + * @param mainTableType the mainTableType to set + */ + public void setMainTableType(String mainTableType) { + this.mainTableType = mainTableType; + } + /** + * otherTables + * @return otherTables + */ + + public List getOtherTables() { + return otherTables; + } + /** + * @param otherTables the otherTables to set + */ + public void setOtherTables(List otherTables) { + this.otherTables = otherTables; + } +} diff --git a/src/main/java/com/nis/domain/configuration/MultipleSearchCfg.java b/src/main/java/com/nis/domain/configuration/MultipleSearchCfg.java new file mode 100644 index 000000000..76500dcbc --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/MultipleSearchCfg.java @@ -0,0 +1,200 @@ +/** + *@Title: MultipleCfg.java + *@Package com.nis.domain.configuration + *@Description TODO + *@author dell + *@date 2018年3月13日 上午8:59:32 + *@version 版本号 + */ +package com.nis.domain.configuration; + +import java.util.List; + +/** + * @ClassName: MultipleCfg.java + * @Description: TODO + * @author (dell) + * @date 2018年3月13日 上午8:59:32 + * @version V1.0 + */ +public class MultipleSearchCfg extends BaseCfg { + + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = -8369567908781421920L; + private String mainTable;//主表名 + private String mainTableType;//主表类型 + private String ipTable;//查询条件IP表名,界面限制查询条件除了共用属性之外只能查一个条件 + private String stringTable;//查询条件字符串表名,界面限制查询条件除了共用属性之外只能查一个条件 + private String complexTable;//查询条件增强字符串串表名,界面限制查询条件除了共用属性之外只能查一个条件 + private List otherTables;//key 表名,value 类型 + //ip配置 + private BaseIpCfg ipCfg; + //字符串配置 + private BaseStringCfg stringCfg; + //数值类配置 + private NumBoundaryCfg numCfg; + //增强字符串配置 + private ComplexkeywordCfg complexCfg; + //地域配置 + private AreaIpCfg areaIpCfg; + /** + * mainTable + * @return mainTable + */ + + public String getMainTable() { + return mainTable; + } + /** + * @param mainTable the mainTable to set + */ + public void setMainTable(String mainTable) { + this.mainTable = mainTable; + } + /** + * ipCfg + * @return ipCfg + */ + + public BaseIpCfg getIpCfg() { + return ipCfg; + } + /** + * @param ipCfg the ipCfg to set + */ + public void setIpCfg(BaseIpCfg ipCfg) { + this.ipCfg = ipCfg; + } + /** + * stringCfg + * @return stringCfg + */ + + public BaseStringCfg getStringCfg() { + return stringCfg; + } + /** + * @param stringCfg the stringCfg to set + */ + public void setStringCfg(BaseStringCfg stringCfg) { + this.stringCfg = stringCfg; + } + /** + * numCfg + * @return numCfg + */ + + public NumBoundaryCfg getNumCfg() { + return numCfg; + } + /** + * @param numCfg the numCfg to set + */ + public void setNumCfg(NumBoundaryCfg numCfg) { + this.numCfg = numCfg; + } + /** + * complexCfg + * @return complexCfg + */ + + public ComplexkeywordCfg getComplexCfg() { + return complexCfg; + } + /** + * @param complexCfg the complexCfg to set + */ + public void setComplexCfg(ComplexkeywordCfg complexCfg) { + this.complexCfg = complexCfg; + } + /** + * areaIpCfg + * @return areaIpCfg + */ + + public AreaIpCfg getAreaIpCfg() { + return areaIpCfg; + } + /** + * @param areaIpCfg the areaIpCfg to set + */ + public void setAreaIpCfg(AreaIpCfg areaIpCfg) { + this.areaIpCfg = areaIpCfg; + } + /** + * mainTableType + * @return mainTableType + */ + + public String getMainTableType() { + return mainTableType; + } + /** + * @param mainTableType the mainTableType to set + */ + public void setMainTableType(String mainTableType) { + this.mainTableType = mainTableType; + } + /** + * otherTables + * @return otherTables + */ + + public List getOtherTables() { + return otherTables; + } + /** + * @param otherTables the otherTables to set + */ + public void setOtherTables(List otherTables) { + this.otherTables = otherTables; + } + /** + * ipTable + * @return ipTable + */ + + public String getIpTable() { + return ipTable; + } + /** + * @param ipTable the ipTable to set + */ + public void setIpTable(String ipTable) { + this.ipTable = ipTable; + } + /** + * stringTable + * @return stringTable + */ + + public String getStringTable() { + return stringTable; + } + /** + * @param stringTable the stringTable to set + */ + public void setStringTable(String stringTable) { + this.stringTable = stringTable; + } + /** + * complexTable + * @return complexTable + */ + + public String getComplexTable() { + return complexTable; + } + /** + * @param complexTable the complexTable to set + */ + public void setComplexTable(String complexTable) { + this.complexTable = complexTable; + } + +} diff --git a/src/main/java/com/nis/domain/configuration/NumBoundaryCfg.java b/src/main/java/com/nis/domain/configuration/NumBoundaryCfg.java index f00eec491..8e917a89a 100644 --- a/src/main/java/com/nis/domain/configuration/NumBoundaryCfg.java +++ b/src/main/java/com/nis/domain/configuration/NumBoundaryCfg.java @@ -39,7 +39,6 @@ public class NumBoundaryCfg extends BaseCfg { @Expose @SerializedName("upBoundary") protected Long upBoundary; - protected Long compileId; /* (non-Javadoc) * @see com.nis.domain.configuration.BaseCfg#initDefaultValue() */ @@ -76,19 +75,4 @@ public class NumBoundaryCfg extends BaseCfg { public void setUpBoundary(Long upBoundary) { this.upBoundary = upBoundary; } - /** - * compileId - * @return compileId - */ - - public Long getCompileId() { - return compileId; - } - /** - * @param compileId the compileId to set - */ - public void setCompileId(Long compileId) { - this.compileId = compileId; - } - } diff --git a/src/main/java/com/nis/domain/configuration/TableBean.java b/src/main/java/com/nis/domain/configuration/TableBean.java new file mode 100644 index 000000000..62ad3ba8f --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/TableBean.java @@ -0,0 +1,80 @@ +/** + *@Title: TableBean.java + *@Package com.nis.domain.configuration + *@Description TODO + *@author dell + *@date 2018年3月24日 下午5:20:51 + *@version 版本号 + */ +package com.nis.domain.configuration; + +import java.io.Serializable; + +/** + * @ClassName: TableBean.java + * @Description: TODO + * @author (dell) + * @date 2018年3月24日 下午5:20:51 + * @version V1.0 + */ +public class TableBean implements Serializable{ + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = -7276874824312210708L; + private String tableName; + private String tableType; + private boolean canEmpty; + public TableBean(){ + + } + public TableBean(String tableName,String tableType){ + this.tableName=tableName; + this.tableType=tableType; + } + /** + * tableName + * @return tableName + */ + + public String getTableName() { + return tableName; + } + /** + * @param tableName the tableName to set + */ + public void setTableName(String tableName) { + this.tableName = tableName; + } + /** + * tableType + * @return tableType + */ + + public String getTableType() { + return tableType; + } + /** + * @param tableType the tableType to set + */ + public void setTableType(String tableType) { + this.tableType = tableType; + } + /** + * canEmpty + * @return canEmpty + */ + + public boolean isCanEmpty() { + return canEmpty; + } + /** + * @param canEmpty the canEmpty to set + */ + public void setCanEmpty(boolean canEmpty) { + this.canEmpty = canEmpty; + } +} diff --git a/src/main/java/com/nis/domain/maat/MaatCfg.java b/src/main/java/com/nis/domain/maat/MaatCfg.java index 5a731b75b..1cecaf7b6 100644 --- a/src/main/java/com/nis/domain/maat/MaatCfg.java +++ b/src/main/java/com/nis/domain/maat/MaatCfg.java @@ -9,6 +9,7 @@ package com.nis.domain.maat; import java.io.Serializable; +import java.util.List; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; @@ -35,28 +36,28 @@ public class MaatCfg implements Serializable { private static final long serialVersionUID = -7745084076394247318L; @Expose @SerializedName("strCfg") - private BaseStringCfg[] strCfg; + private List strCfg; @Expose @SerializedName("ipCfg") - private BaseIpCfg[] ipCfg; + private List ipCfg; @Expose @SerializedName("numCfg") - private NumBoundaryCfg[] numCfg; + private List numCfg; @Expose @SerializedName("complexStrCfg") - private ComplexkeywordCfg[] complexStrCfg; + private List complexStrCfg; /** * strCfg * @return strCfg */ - public BaseStringCfg[] getStrCfg() { + public List getStrCfg() { return strCfg; } /** * @param strCfg the strCfg to set */ - public void setStrCfg(BaseStringCfg[] strCfg) { + public void setStrCfg(List strCfg) { this.strCfg = strCfg; } /** @@ -64,13 +65,13 @@ public class MaatCfg implements Serializable { * @return ipCfg */ - public BaseIpCfg[] getIpCfg() { + public List getIpCfg() { return ipCfg; } /** * @param ipCfg the ipCfg to set */ - public void setIpCfg(BaseIpCfg[] ipCfg) { + public void setIpCfg(List ipCfg) { this.ipCfg = ipCfg; } /** @@ -78,13 +79,13 @@ public class MaatCfg implements Serializable { * @return numCfg */ - public NumBoundaryCfg[] getNumCfg() { + public List getNumCfg() { return numCfg; } /** * @param numCfg the numCfg to set */ - public void setNumCfg(NumBoundaryCfg[] numCfg) { + public void setNumCfg(List numCfg) { this.numCfg = numCfg; } /** @@ -92,13 +93,13 @@ public class MaatCfg implements Serializable { * @return complexStrCfg */ - public ComplexkeywordCfg[] getComplexStrCfg() { + public List getComplexStrCfg() { return complexStrCfg; } /** * @param complexStrCfg the complexStrCfg to set */ - public void setComplexStrCfg(ComplexkeywordCfg[] complexStrCfg) { + public void setComplexStrCfg(List complexStrCfg) { this.complexStrCfg = complexStrCfg; } diff --git a/src/main/java/com/nis/domain/maat/ToMaatBean.java b/src/main/java/com/nis/domain/maat/ToMaatBean.java index 8adca69c4..5a8a3073d 100644 --- a/src/main/java/com/nis/domain/maat/ToMaatBean.java +++ b/src/main/java/com/nis/domain/maat/ToMaatBean.java @@ -37,7 +37,7 @@ public class ToMaatBean implements Serializable{ private static final long serialVersionUID = 5123156423588372849L; @Expose @SerializedName("serviceCfg") - private List serviceCfg; + private List> serviceCfg; @Expose @SerializedName("areaCfg") private List areaCfg; @@ -58,7 +58,7 @@ public class ToMaatBean implements Serializable{ private String lable; @Expose @SerializedName("compileId") - private Long compileId; + private Integer compileId; @Expose @SerializedName("isAreaEffective") private Integer isAreaEffective; @@ -72,18 +72,19 @@ public class ToMaatBean implements Serializable{ @SerializedName("serviceId") private Integer serviceId; + /** * serviceCfg * @return serviceCfg */ - public List getServiceCfg() { + public List> getServiceCfg() { return serviceCfg; } /** * @param serviceCfg the serviceCfg to set */ - public void setServiceCfg(List serviceCfg) { + public void setServiceCfg(List> serviceCfg) { this.serviceCfg = serviceCfg; } /** @@ -176,13 +177,13 @@ public class ToMaatBean implements Serializable{ * @return compileId */ - public Long getCompileId() { + public Integer getCompileId() { return compileId; } /** * @param compileId the compileId to set */ - public void setCompileId(Long compileId) { + public void setCompileId(Integer compileId) { this.compileId = compileId; } /** @@ -242,22 +243,6 @@ public class ToMaatBean implements Serializable{ this.serviceId = serviceId; } public static void main(String[] args) { - Gson gson=new GsonBuilder().disableHtmlEscaping() - .setDateFormat("yyyy-MM-dd HH:mm:ss") - .setPrettyPrinting()/*.serializeNulls()*/ - .excludeFieldsWithoutExposeAnnotation() - .create(); - ToMaatBean bean=new ToMaatBean(); - List cfg=new ArrayList<>(); - MaatCfg[] ma=new MaatCfg[1]; - MaatCfg mc=new MaatCfg(); - IpPortCfg[] a=new IpPortCfg[1]; - a[0]=new IpPortCfg(); - mc.setIpCfg(a); - ma[0]=mc; - cfg.add(ma); - bean.setServiceCfg(cfg); - System.out.println(gson.toJson(bean)); } } diff --git a/src/main/java/com/nis/domain/maat/ToMaatUnAuditBean.java b/src/main/java/com/nis/domain/maat/ToMaatUnAuditBean.java new file mode 100644 index 000000000..a05f22baa --- /dev/null +++ b/src/main/java/com/nis/domain/maat/ToMaatUnAuditBean.java @@ -0,0 +1,51 @@ +/** + *@Title: ToMaatBean.java + *@Package com.nis.domain.configuration + *@Description TODO + *@author dell + *@date 2018年2月28日 下午2:03:08 + *@version 版本号 + */ +package com.nis.domain.maat; + +import java.io.Serializable; +import java.util.List; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +/** + * @ClassName: ToMaatBean.java + * @Description: TODO + * @author (dell) + * @date 2018年2月28日 下午2:03:08 + * @version V1.0 + */ +public class ToMaatUnAuditBean implements Serializable{ + + /** + * @Fields serialVersionUID:TODO(转换为maat格式的java bean) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = 5123156423588372849L; + @Expose + @SerializedName("serviceCfg") + private List serviceCfg; + /** + * serviceCfg + * @return serviceCfg + */ + + public List getServiceCfg() { + return serviceCfg; + } + /** + * @param serviceCfg the serviceCfg to set + */ + public void setServiceCfg(List serviceCfg) { + this.serviceCfg = serviceCfg; + } + +} diff --git a/src/main/java/com/nis/domain/maat/UnAuditBean.java b/src/main/java/com/nis/domain/maat/UnAuditBean.java new file mode 100644 index 000000000..8dd8b8ec5 --- /dev/null +++ b/src/main/java/com/nis/domain/maat/UnAuditBean.java @@ -0,0 +1,66 @@ +/** + *@Title: UnAuditBean.java + *@Package com.nis.domain.maat + *@Description TODO + *@author dell + *@date 2018年3月26日 下午1:30:07 + *@version 版本号 + */ +package com.nis.domain.maat; + +import java.io.Serializable; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +/** + * @ClassName: UnAuditBean.java + * @Description: TODO + * @author (dell) + * @date 2018年3月26日 下午1:30:07 + * @version V1.0 + */ +public class UnAuditBean implements Serializable{ + + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = -3497633085090859526L; + @Expose + @SerializedName("compileId") + private Integer compileId; + @Expose + @SerializedName("maatTable") + private String maatTable; + /** + * compileId + * @return compileId + */ + + public Integer getCompileId() { + return compileId; + } + /** + * @param compileId the compileId to set + */ + public void setCompileId(Integer compileId) { + this.compileId = compileId; + } + /** + * maatTable + * @return maatTable + */ + + public String getMaatTable() { + return maatTable; + } + /** + * @param maatTable the maatTable to set + */ + public void setMaatTable(String maatTable) { + this.maatTable = maatTable; + } +} diff --git a/src/main/java/com/nis/util/Constants.java b/src/main/java/com/nis/util/Constants.java index d9e85751c..ccf3c5578 100644 --- a/src/main/java/com/nis/util/Constants.java +++ b/src/main/java/com/nis/util/Constants.java @@ -11,7 +11,13 @@ public final class Constants { public static final String DEFAULT_CAPTCHA_PARAM = "captcha"; public static final String DEFAULT_MOBILE_PARAM = "mobileLogin"; public static final String DEFAULT_MESSAGE_PARAM = "message"; - + /** + * 表类型 + */ + public static final int TABLE_TYPE_IP = 1; + public static final int TABLE_TYPE_STRING = 2; + public static final int TABLE_TYPE_NUMBER = 3; + public static final int TABLE_TYPE_COMPLEX = 4; /** * 词典数据key */ diff --git a/src/main/java/com/nis/web/controller/configuration/ComplexStringCfgController.java b/src/main/java/com/nis/web/controller/configuration/ComplexStringCfgController.java index b0d980bfc..90dfe9ffc 100644 --- a/src/main/java/com/nis/web/controller/configuration/ComplexStringCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/ComplexStringCfgController.java @@ -13,10 +13,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import com.nis.domain.Page; import com.nis.domain.ServiceConfigInfo; -import com.nis.domain.configuration.BaseCfg; +import com.nis.domain.basics.ServiceDictInfo; +import com.nis.domain.configuration.BaseIpCfg; import com.nis.domain.configuration.ComplexkeywordCfg; import com.nis.domain.configuration.RequestInfo; -import com.nis.domain.basics.ServiceDictInfo; +import com.nis.main.ConvertTool; import com.nis.util.Constants; import com.nis.web.controller.BaseController; @@ -74,44 +75,39 @@ public class ComplexStringCfgController extends BaseController{ model.addAttribute("serviceId", serviceId); model.addAttribute("audit", Constants.CFG_PAGE); logger.info("sercice id is "+serviceId); - if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - logger.info("table name is "+tableName); - String className=complexStringCfgService.getClassName(tableName); - logger.info("class name is "+className); - String packageName=ComplexkeywordCfg.class.getPackage().getName(); - try { - //通过反射获得ComplexkeywordCfg的子类的实例,并调用子类的initDefaultValue初始化默认值 - Class clazz=Class.forName(packageName+"."+className); - ComplexkeywordCfg cfg=(ComplexkeywordCfg)clazz.newInstance(); - cfg.setTableName(tableName); - cfg.initDefaultValue(); - cfg.setAction(action); - cfg.setServiceId(serviceId); - model.addAttribute("_cfg", cfg); - model.addAttribute("tableName", tableName); - List requestInfos=requestInfoService.getValidRequestInfo(); - model.addAttribute("requestInfos", requestInfos); - List fls=serviceDictInfoService.findFlDict(); - model.addAttribute("fls", fls); - List xzs=serviceDictInfoService.findXzDict(); - model.addAttribute("xzs", xzs); - List lables=serviceDictInfoService.findLableDict(); - model.addAttribute("lables", lables); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { - // TODO Auto-generated catch block - logger.error("打开新增IP窗口失败",e); - e.printStackTrace(); - } + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + String tableName=serviceConfigInfo.getTableName(); + if(!StringUtils.isBlank(tableName)){ + logger.info("table name is "+tableName); + String className=complexStringCfgService.getClassName(tableName); + logger.info("class name is "+className); + String packageName=ComplexkeywordCfg.class.getPackage().getName(); + try { + //通过反射获得ComplexkeywordCfg的子类的实例,并调用子类的initDefaultValue初始化默认值 + Class clazz=Class.forName(packageName+"."+className); + ComplexkeywordCfg cfg=(ComplexkeywordCfg)clazz.newInstance(); + cfg.setTableName(tableName); + cfg.initDefaultValue(); + cfg.setAction(action); + cfg.setServiceId(serviceId); + model.addAttribute("_cfg", cfg); + model.addAttribute("tableName", tableName); + List requestInfos=requestInfoService.getValidRequestInfo(); + model.addAttribute("requestInfos", requestInfos); + List fls=serviceDictInfoService.findFlDict(); + model.addAttribute("fls", fls); + List xzs=serviceDictInfoService.findXzDict(); + model.addAttribute("xzs", xzs); + List lables=serviceDictInfoService.findLableDict(); + model.addAttribute("lables", lables); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + // TODO Auto-generated catch block + logger.error("打开新增IP窗口失败",e); + e.printStackTrace(); } } - }else{ - logger.error("未获取到正确的serviceId"); } - return "/cfg/complexCfgForm"; } @RequestMapping(value = {"updateForm"}) @@ -121,7 +117,13 @@ public class ComplexStringCfgController extends BaseController{ model.addAttribute("action", action); model.addAttribute("tableName", tableName); model.addAttribute("audit", Constants.CFG_PAGE); - if(!StringUtils.isBlank(tableName)){ + try{ + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + } + } logger.info("table name is "+tableName); ComplexkeywordCfg searchBean=new ComplexkeywordCfg(); searchBean.setCfgId(cfgId); @@ -136,32 +138,9 @@ public class ComplexStringCfgController extends BaseController{ model.addAttribute("xzs", xzs); List lables=serviceDictInfoService.findAllLableDict(); model.addAttribute("lables", lables); - }else if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - logger.info("table name is "+tableName); - ComplexkeywordCfg searchBean=new ComplexkeywordCfg(); - searchBean.setCfgId(cfgId); - searchBean.setTableName(tableName); - ComplexkeywordCfg cfg=complexStringCfgService.getStringCfgById(searchBean); - model.addAttribute("_cfg", cfg); - List requestInfos=requestInfoService.getAllRequestInfo(); - model.addAttribute("requestInfos", requestInfos); - List fls=serviceDictInfoService.findAllFlDict(); - model.addAttribute("fls", fls); - List xzs=serviceDictInfoService.findAllXzDict(); - model.addAttribute("xzs", xzs); - List lables=serviceDictInfoService.findAllLableDict(); - model.addAttribute("lables", lables); - - } - } - }else{ - logger.error("未获取到正确的表名"); + }catch(Exception e){ + logger.error("发生异常", e); } - return "/cfg/complexCfgForm"; } @@ -179,15 +158,21 @@ public class ComplexStringCfgController extends BaseController{ model.addAttribute("cfgName",cfgName); model.addAttribute("cfgType","complex"); model.addAttribute("audit", Constants.CFG_PAGE); + model.addAttribute("serviceId",cfg.getServiceId()); + model.addAttribute("action",cfg.getAction()); logger.info("saveOrUpdateStringCfg loaded"); - if(cfg==null){ - logger.error("无法保存空的配置!"); - addMessage(model,"保存失败!"); - }else if(!StringUtils.isBlank(cfg.getTableName())){ + try { + String tableName=cfg.getTableName(); int serviceId=cfg.getServiceId(); - long compileId=getCompileId(cfg); -// cfg.setCreatorId(cfg.getCurrentUser().getId()); -// cfg.setCreateTime(new Date()); + if(StringUtils.isBlank(cfg.getTableName())){ + + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + cfg.setTableName(tableName); + } + } + int compileId = new ConvertTool().getCompileId(); cfg.setIsValid(Constants.VALID_NO); cfg.setIsAudit(Constants.AUDIT_NOT_YET); cfg.setCompileId(compileId); @@ -200,41 +185,13 @@ public class ComplexStringCfgController extends BaseController{ cfg.setEditTime(new Date()); complexStringCfgService.updateStringCfg(cfg); } - model.addAttribute("serviceId",serviceId); - model.addAttribute("action",cfg.getAction()); addMessage(model,"保存成功,正在为您跳转页面..."); - }else if(cfg.getServiceId()!=null){ - int serviceId=cfg.getServiceId(); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - long compileId=getCompileId(cfg); - cfg.setTableName(tableName); -// cfg.setCreatorId(cfg.getCurrentUser().getId()); -// cfg.setCreateTime(new Date()); - cfg.setIsValid(Constants.VALID_NO); - cfg.setIsAudit(Constants.AUDIT_NOT_YET); - cfg.setCompileId(compileId); - if(cfg.getCfgId()==null){ - cfg.setCreatorId(cfg.getCurrentUser().getId()); - cfg.setCreateTime(new Date()); - complexStringCfgService.addStringCfg(cfg); - }else{ - cfg.setEditorId(cfg.getCurrentUser().getId()); - cfg.setEditTime(new Date()); - complexStringCfgService.updateStringCfg(cfg); - } - model.addAttribute("serviceId",serviceId); - model.addAttribute("action",cfg.getAction()); - addMessage(model,"保存成功,正在为您跳转页面..."); - } - } - }else{ + } catch (Exception e) { + // TODO Auto-generated catch block + logger.error("保存失败!",e); addMessage(model,"保存失败!"); - logger.error("无法确定IP配置的表名!"); } - return "/cfg/resultPage";//StringEscapeUtils.escapeHtml4("?serviceId="+cfg.getServiceId()+"&action="+cfg.getAction()+"&cfgName="+cfgName); + return "/cfg/resultPage"; } /** @@ -250,53 +207,47 @@ public class ComplexStringCfgController extends BaseController{ public String auditStringCfg(String cfgName,ComplexkeywordCfg cfg,Model model) { model.addAttribute("cfgName", cfgName); model.addAttribute("audit", Constants.AUDIT_PAGE); - if(cfg==null){ - logger.error("无法审核空的配置!"); - }else if(!StringUtils.isBlank(cfg.getTableName())){ - int audit=complexStringCfgService.getIsAudit(cfg); + model.addAttribute("serviceId", cfg.getServiceId()); + model.addAttribute("action", cfg.getAction()); + try{ + String tableName=cfg.getTableName(); + String maatTable=null; + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(cfg.getServiceId()); + if(serviceConfigInfo!=null){ + if(StringUtils.isBlank(tableName)){ + tableName=serviceConfigInfo.getTableName(); + cfg.setTableName(tableName); + } + maatTable=serviceConfigInfo.getMaatTable(); + } + ComplexkeywordCfg bean=complexStringCfgService.getStringCfgById(cfg); + bean.setTableName(tableName); + int audit=bean.getIsAudit().intValue(); if(audit==Constants.AUDIT_YES&&cfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ logger.error("审核通过的配置只能取消审核通过!"); }else{ cfg.setAuditorId(cfg.getCurrentUser().getId()); cfg.setAuditTime(new Date()); - + bean.setIsAudit(cfg.getIsAudit()); if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 cfg.setIsValid(Constants.VALID_NO); + bean.setIsValid(Constants.VALID_NO); + bean.setMaatTable(maatTable); }else if(cfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 cfg.setIsValid(Constants.VALID_YES); + bean.setIsValid(Constants.VALID_YES); } - int result=complexStringCfgService.auditStringCfg(cfg); - model.addAttribute("serviceId", cfg.getServiceId()); - model.addAttribute("action", cfg.getAction()); - } - - }else if(cfg.getServiceId()!=null){ - int serviceId=cfg.getServiceId(); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - cfg.setTableName(tableName); - int audit=complexStringCfgService.getIsAudit(cfg); - if(audit==Constants.AUDIT_YES&&cfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ - logger.error("审核通过的配置只能取消审核通过!"); - }else{ - cfg.setAuditorId(cfg.getCurrentUser().getId()); - cfg.setAuditTime(new Date()); - - if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 - cfg.setIsValid(Constants.VALID_NO); - }else if(cfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 - cfg.setIsValid(Constants.VALID_YES); - } - int result=complexStringCfgService.auditStringCfg(cfg); - model.addAttribute("serviceId", serviceId); - model.addAttribute("action", cfg.getAction()); - } + int result=complexStringCfgService.auditStringCfg(bean,cfg); + if(result!=0){ + addMessage(model,"审核成功!"); + }else{ + addMessage(model,"审核失败!"); } + } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch(Exception e){ + logger.error("发生异常",e); + addMessage(model,"审核失败!"); } return "redirect:" + adminPath + "/cfg/complex/list"; } @@ -316,7 +267,13 @@ public class ComplexStringCfgController extends BaseController{ model.addAttribute("action", action); model.addAttribute("cfgType","complex"); model.addAttribute("audit", Constants.CFG_PAGE); - if(!StringUtils.isBlank(tableName)){ + try{ + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + } + } int audit=complexStringCfgService.getIsAudit(tableName,cfgId); //未审核时可删除 if(audit!=Constants.AUDIT_YES){ @@ -332,29 +289,9 @@ public class ComplexStringCfgController extends BaseController{ logger.error("通过审核的配置不能删除!"); } - }else if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - ComplexkeywordCfg cfg=new ComplexkeywordCfg(); - cfg.setCfgId(cfgId); - cfg.setTableName(tableName); - int audit=complexStringCfgService.getIsAudit(cfg); - //未审核时可删除 - if(audit!=Constants.AUDIT_YES){ - cfg.setEditorId(cfg.getCurrentUser().getId()); - cfg.setEditTime(new Date()); - cfg.setIsValid(Constants.VALID_DEL); - int result=complexStringCfgService.deleteStringCfg(cfg); - addMessage(model,"删除成功,正在为您跳转页面..."); - }else{ - logger.error("通过审核的配置不能删除!"); - } - } - } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch(Exception e){ + logger.error("删除失败", e); + addMessage(model,"删除失败!"); } return "/cfg/resultPage"; } @@ -367,7 +304,14 @@ public class ComplexStringCfgController extends BaseController{ * @exception * @since 1.0.0 */ - protected long getCompileId(BaseCfg cfg){ - return 0; + protected long getCompileId(ComplexkeywordCfg cfg){ + long compileId=0l; + try { + compileId = cfg.getCompileId()==null?new ConvertTool().getCompileId():cfg.getCompileId(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compileId; } } diff --git a/src/main/java/com/nis/web/controller/configuration/IpCfgController.java b/src/main/java/com/nis/web/controller/configuration/IpCfgController.java index 7747fa609..6d8279a79 100644 --- a/src/main/java/com/nis/web/controller/configuration/IpCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/IpCfgController.java @@ -18,6 +18,7 @@ import com.nis.domain.ServiceConfigInfo; import com.nis.domain.basics.ServiceDictInfo; import com.nis.domain.configuration.BaseIpCfg; import com.nis.domain.configuration.RequestInfo; +import com.nis.main.ConvertTool; import com.nis.util.Constants; import com.nis.web.controller.BaseController; @@ -123,7 +124,6 @@ public class IpCfgController extends BaseController{ ipcfg.setAction(action); ipcfg.setServiceId(serviceId); model.addAttribute("_cfg", ipcfg); - long compileId=this.getCompileId(); model.addAttribute("tableName", tableName); List requestInfos=requestInfoService.getValidRequestInfo(); model.addAttribute("requestInfos", requestInfos); @@ -230,13 +230,21 @@ public class IpCfgController extends BaseController{ model.addAttribute("cfgName",cfgName); model.addAttribute("cfgType", "ip"); model.addAttribute("audit", Constants.CFG_PAGE); + model.addAttribute("serviceId",ipCfg.getServiceId()); + model.addAttribute("action",ipCfg.getAction()); + model.addAttribute("tableName", ipCfg.getTableName()); logger.info("saveOrUpdateIpCfg loaded"); - if(ipCfg==null){ - logger.error("无法保存空的配置!"); - addMessage(model,"保存失败!"); - }else if(!StringUtils.isBlank(ipCfg.getTableName())){ + try{ + String tableName=ipCfg.getTableName(); int serviceId=ipCfg.getServiceId(); - long compileId=getCompileId(); + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + ipCfg.setTableName(tableName); + } + } + int compileId=new ConvertTool().getCompileId().intValue(); ipCfg.setIsValid(Constants.VALID_NO); ipCfg.setIsAudit(Constants.AUDIT_NOT_YET); ipCfg.setCompileId(compileId); @@ -249,42 +257,12 @@ public class IpCfgController extends BaseController{ ipCfg.setEditTime(new Date()); ipCfgService.updateIpCfg(ipCfg); } - model.addAttribute("serviceId",serviceId); - model.addAttribute("action",ipCfg.getAction()); - model.addAttribute("tableName", ipCfg.getTableName()); addMessage(model,"保存成功,正在为您跳转页面..."); - }else if(ipCfg.getServiceId()!=null){ - int serviceId=ipCfg.getServiceId(); - model.addAttribute("serviceId",serviceId); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - long compileId=getCompileId(); - ipCfg.setTableName(tableName); -// ipCfg.setCreatorId(ipCfg.getCurrentUser().getId()); -// ipCfg.setCreateTime(new Date()); - ipCfg.setIsValid(Constants.VALID_NO); - ipCfg.setIsAudit(Constants.AUDIT_NOT_YET); - ipCfg.setCompileId(compileId); - if(ipCfg.getCfgId()==null){ - ipCfg.setCreatorId(ipCfg.getCurrentUser().getId()); - ipCfg.setCreateTime(new Date()); - }else{ - ipCfg.setEditorId(ipCfg.getCurrentUser().getId()); - ipCfg.setEditTime(new Date()); - ipCfgService.updateIpCfg(ipCfg); - } - model.addAttribute("action",ipCfg.getAction()); - model.addAttribute("tableName", ipCfg.getTableName()); - addMessage(model,"保存成功,正在为您跳转页面..."); - } - } - }else{ + }catch(Exception e){ + logger.error("保存失败",e); addMessage(model,"保存失败!"); - logger.error("无法确定IP配置的表名!"); } - return "/cfg/resultPage";//StringEscapeUtils.escapeHtml4("?serviceId="+ipCfg.getServiceId()+"&action="+ipCfg.getAction()+"&cfgName="+cfgName); + return "/cfg/resultPage"; } /** @@ -300,52 +278,47 @@ public class IpCfgController extends BaseController{ public String auditIpCfg(String cfgName,BaseIpCfg ipCfg,Model model) { model.addAttribute("cfgName", cfgName); model.addAttribute("audit", Constants.AUDIT_PAGE); - if(ipCfg==null){ - logger.error("无法审核空的配置!"); - }else if(!StringUtils.isBlank(ipCfg.getTableName())){ - int audit=ipCfgService.getIsAudit(ipCfg); + model.addAttribute("serviceId", ipCfg.getServiceId()); + model.addAttribute("action", ipCfg.getAction()); + try{ + String tableName=ipCfg.getTableName(); + String maatTable=null; + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(ipCfg.getServiceId()); + if(serviceConfigInfo!=null){ + if(StringUtils.isBlank(tableName)){ + tableName=serviceConfigInfo.getTableName(); + ipCfg.setTableName(tableName); + } + maatTable=serviceConfigInfo.getMaatTable(); + } + BaseIpCfg bean=ipCfgService.getIpCfgById(ipCfg); + bean.setTableName(tableName); + int audit=bean.getIsAudit().intValue(); if(audit==Constants.AUDIT_YES&&ipCfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ logger.error("审核通过的配置只能取消审核通过!"); }else{ ipCfg.setAuditorId(ipCfg.getCurrentUser().getId()); ipCfg.setAuditTime(new Date()); - + bean.setIsAudit(ipCfg.getIsAudit()); if(ipCfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 ipCfg.setIsValid(Constants.VALID_NO); + bean.setIsValid(Constants.VALID_NO); + bean.setMaatTable(maatTable); }else if(ipCfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 ipCfg.setIsValid(Constants.VALID_YES); + bean.setIsValid(Constants.VALID_YES); } - int result=ipCfgService.auditIpCfg(ipCfg); - model.addAttribute("serviceId", ipCfg.getServiceId()); - model.addAttribute("action", ipCfg.getAction()); - } - }else if(ipCfg.getServiceId()!=null){ - int serviceId=ipCfg.getServiceId(); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - ipCfg.setTableName(tableName); - int audit=ipCfgService.getIsAudit(ipCfg); - if(audit==Constants.AUDIT_YES&&ipCfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ - logger.error("审核通过的配置只能取消审核通过!"); - }else{ - ipCfg.setAuditorId(ipCfg.getCurrentUser().getId()); - ipCfg.setAuditTime(new Date()); - - if(ipCfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 - ipCfg.setIsValid(Constants.VALID_NO); - }else if(ipCfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 - ipCfg.setIsValid(Constants.VALID_YES); - } - int result=ipCfgService.auditIpCfg(ipCfg); - model.addAttribute("serviceId", serviceId); - model.addAttribute("action", ipCfg.getAction()); - } + int result=ipCfgService.auditIpCfg(bean,ipCfg); + if(result!=0){ + addMessage(model,"审核成功!"); + }else{ + addMessage(model, "审核失败"); } + } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch(Exception e){ + logger.error("审核失败", e); + addMessage(model, "审核失败"); } return "redirect:" + adminPath + "/cfg/ip/list"; } @@ -366,7 +339,13 @@ public class IpCfgController extends BaseController{ model.addAttribute("action", action); model.addAttribute("cfgType", "ip"); model.addAttribute("audit", Constants.AUDIT_PAGE); - if(!StringUtils.isBlank(tableName)){ + try{ + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + } + } int audit=ipCfgService.getIsAudit(tableName,cfgId); //未审核时可删除 if(audit!=Constants.AUDIT_YES){ @@ -381,32 +360,11 @@ public class IpCfgController extends BaseController{ addMessage(model,"删除成功,正在为您跳转页面..."); }else{ logger.error("通过审核的配置不能删除!"); + addMessage(model,"删除失败!"); } - - }else if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - BaseIpCfg ipCfg=new BaseIpCfg(); - ipCfg.setCfgId(cfgId); - ipCfg.setTableName(tableName); - int audit=ipCfgService.getIsAudit(ipCfg); - //未审核时可删除 - if(audit!=Constants.AUDIT_YES){ - ipCfg.setEditorId(ipCfg.getCurrentUser().getId()); - ipCfg.setEditTime(new Date()); - ipCfg.setIsValid(Constants.VALID_DEL); - int result=ipCfgService.deleteIpCfg(ipCfg); - model.addAttribute("tableName", tableName); - addMessage(model,"删除成功,正在为您跳转页面..."); - }else{ - logger.error("通过审核的配置不能删除!"); - } - } - } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch(Exception e){ + logger.error("删除失败", e); + addMessage(model,"删除失败!"); } return "/cfg/resultPage"; } @@ -419,7 +377,14 @@ public class IpCfgController extends BaseController{ * @exception * @since 1.0.0 */ - protected long getCompileId(){ - return 0; + protected long getCompileId(BaseIpCfg cfg){ + long compileId=0l; + try { + compileId = cfg.getCompileId()==null?new ConvertTool().getCompileId():cfg.getCompileId(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compileId; } } diff --git a/src/main/java/com/nis/web/controller/configuration/MultipleCfgController.java b/src/main/java/com/nis/web/controller/configuration/MultipleCfgController.java new file mode 100644 index 000000000..bf46b696b --- /dev/null +++ b/src/main/java/com/nis/web/controller/configuration/MultipleCfgController.java @@ -0,0 +1,1105 @@ +package com.nis.web.controller.configuration; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + +import com.nis.domain.Page; +import com.nis.domain.ServiceConfigInfo; +import com.nis.domain.basics.ServiceDictInfo; +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.MultipleCfg; +import com.nis.domain.configuration.MultipleSearchCfg; +import com.nis.domain.configuration.NumBoundaryCfg; +import com.nis.domain.configuration.RequestInfo; +import com.nis.domain.configuration.TableBean; +import com.nis.main.ConvertTool; +import com.nis.util.Constants; +import com.nis.web.controller.BaseController; +import com.nis.web.service.configuration.MultipleCfgService; + +/** + * 文本增强(多域)组合配置服务 + * @author dell + * + */ +@Controller +@RequestMapping("${adminPath}/cfg/multiple") +public class MultipleCfgController extends BaseController{ + @Autowired + protected MultipleCfgService multipleCfgService; + /** + * + * list(查询列表,分开查) + * (这里描述这个方法适用条件 – 可选) + * @param model + * @param audit + * @param cfgName + * @param cfg + * @param request + * @param response + * @return + *String + * @exception + * @since 1.0.0 + */ + @SuppressWarnings({"unchecked","rawtypes"}) + @RequestMapping(value = {"list"}) + public String list(Model model,Integer audit,String cfgName,@ModelAttribute("cfg")MultipleSearchCfg cfg,HttpServletRequest request,HttpServletResponse response) { + model.addAttribute("cfgName", cfgName); + model.addAttribute("cfgType", "multiple"); + model.addAttribute("audit", audit); + model.addAttribute("mainTable", cfg.getMainTable()); + Page resultPage=new Page(request,response); + Integer serviceId=cfg.getServiceId(); + model.addAttribute("serviceId", serviceId); + List otherTables=null; + if(cfg.getOtherTables()==null){ + otherTables=new ArrayList(); + cfg.setOtherTables(otherTables); + }else{ + otherTables=cfg.getOtherTables(); + } + if(cfg.getMainTable()==null){ + logger.error("cannot get main table"); + return "/cfg/multipleCfgList"; + }else{//从菜单url获取mainTable + String mainTable=cfg.getMainTable(); + //获取相关表名 + List serviceConfigInfos=serviceConfigInfoService.findList(serviceId); + List resultList=new ArrayList(); + resultPage.setList(resultList); + + List mainList=null; + //查询主表,将主表中的数据set到结果中 + for(ServiceConfigInfo info:serviceConfigInfos){ + int type=info.getTableType(); + String tableName=info.getTableName(); + if(mainTable.equals(tableName)){ + cfg.setMainTableType(String.valueOf(type)); + if(Constants.TABLE_TYPE_COMPLEX==type){//增强字符串类型 + ComplexkeywordCfg _cfg=cfg.getComplexCfg()==null?new ComplexkeywordCfg():cfg.getComplexCfg(); + _cfg.setTableName(mainTable); + this.setProperties(cfg, null, null, null, _cfg); + Page mainPage=complexStringCfgService.findPage(new Page(request,response,"r"), _cfg); + setPageProps(mainPage,resultPage); + mainList=mainPage.getList();//主表结果 + if(mainList!=null){ + //遍历主表结果,将主表结果数据set到到返回结果中 + for(int i=0;i cfgMap=new HashMap(); + cfgMap.put(mainTable, (ComplexkeywordCfg)mainList.get(i)); + resultCfg.setComplexCfg(cfgMap); + this.setPropertiesToMultipleCfg(resultCfg, mainList.get(i),"select"); + resultList.add(resultCfg); + } + } + }else{ + logger.info("no data"); + return "/cfg/multipleCfgList"; + } + + }else if(Constants.TABLE_TYPE_STRING==type){//字符串类型 + BaseStringCfg _cfg=cfg.getStringCfg()==null?new BaseStringCfg():cfg.getStringCfg(); + _cfg.setTableName(mainTable); + this.setProperties(cfg, null, _cfg, null,null); + Page mainPage=stringCfgService.findPage(new Page(request,response,"r"), _cfg); + mainList=mainPage.getList();//主表结果 + setPageProps(mainPage,resultPage); + if(mainList!=null){ + //遍历主表结果,将主表结果数据set到到返回结果中 + for(int i=0;i cfgMap=new HashMap(); + cfgMap.put(mainTable, (BaseStringCfg)mainList.get(i)); + resultCfg.setStringCfg(cfgMap); + this.setPropertiesToMultipleCfg(resultCfg, mainList.get(i),"select"); + resultList.add(resultCfg); + } + } + }else{ + logger.info("no data"); + return "/cfg/multipleCfgList"; + } + }else if(Constants.TABLE_TYPE_IP==type){//字符串类型 + BaseIpCfg _cfg=cfg.getIpCfg()==null?new BaseIpCfg():cfg.getIpCfg(); + _cfg.setTableName(mainTable); + this.setProperties(cfg, _cfg,null,null,null); + Page mainPage=ipCfgService.findPage(new Page(request,response,"r"), _cfg); + mainList=mainPage.getList();//主表结果 + setPageProps(mainPage,resultPage); + if(mainList!=null){ + //遍历主表结果,将主表结果数据set到到返回结果中 + for(int i=0;i cfgMap=new HashMap(); + cfgMap.put(mainTable, (BaseIpCfg)mainList.get(i)); + resultCfg.setIpCfg(cfgMap); + this.setPropertiesToMultipleCfg(resultCfg, mainList.get(i),"select"); + resultList.add(resultCfg); + } + } + }else{ + logger.info("no data"); + return "/cfg/multipleCfgList"; + } + }else if(Constants.TABLE_TYPE_NUMBER==type){ + NumBoundaryCfg _cfg=cfg.getNumCfg()==null?new NumBoundaryCfg():cfg.getNumCfg(); + _cfg.setTableName(mainTable); + this.setProperties(cfg, null,null,_cfg,null); + Page mainPage=numCfgService.findPage(new Page(request,response,"r"), _cfg); + mainList=mainPage.getList();//主表结果 + setPageProps(mainPage,resultPage); + if(mainList!=null){ + //遍历主表结果,将主表结果数据set到到返回结果中 + for(int i=0;i cfgMap=new HashMap(); + cfgMap.put(mainTable, (NumBoundaryCfg)mainList.get(i)); + resultCfg.setNumCfg(cfgMap); + this.setPropertiesToMultipleCfg(resultCfg, mainList.get(i),"select"); + resultList.add(resultCfg); + } + } + }else{ + logger.info("no data"); + return "/cfg/multipleCfgList"; + } + } + break; + } + } + + if(mainList!=null&&mainList.size()>0){ + Page page=new Page(request,response,"r"); + StringBuffer compileIds=new StringBuffer(); + for(int i=0;i list=complexStringCfgService + .findPage(page, _cfg) + .getList(); + for(MultipleCfg resultCfg:resultPage.getList()){ + BaseCfg main=null; + if(resultCfg.getComplexCfg()!=null&&resultCfg.getComplexCfg().containsKey(mainTable)){ + main=resultCfg.getComplexCfg().get(mainTable); + }else if(resultCfg.getStringCfg()!=null&&resultCfg.getStringCfg().containsKey(mainTable)){ + main=resultCfg.getStringCfg().get(mainTable); + }else if(resultCfg.getIpCfg().containsKey(mainTable)){ + main=resultCfg.getIpCfg().get(mainTable); + }else if(resultCfg.getNumCfg().containsKey(mainTable)){ + main=resultCfg.getNumCfg().get(mainTable); + } + for(ComplexkeywordCfg prop:list){ + if(main.getCompileId().longValue()==prop.getCompileId().longValue()){ + prop.setTableName(info.getTableName()); + if(resultCfg.getComplexCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), prop); + resultCfg.setComplexCfg(map); + }else{ + resultCfg.getComplexCfg().put(info.getTableName(), prop); + } + break; + } + } + } + }else if(Constants.TABLE_TYPE_STRING==type){//字符串类型 + BaseStringCfg _cfg=cfg.getStringCfg()==null?new BaseStringCfg():cfg.getStringCfg(); + _cfg.setTableName(info.getTableName()); + this.setProperties(cfg, null, _cfg, null,null); + List list=stringCfgService + .findPage(page, _cfg) + .getList(); + for(MultipleCfg resultCfg:resultPage.getList()){ + BaseCfg main=null; + if(resultCfg.getComplexCfg()!=null&&resultCfg.getComplexCfg().containsKey(mainTable)){ + main=resultCfg.getComplexCfg().get(mainTable); + }else if(resultCfg.getStringCfg()!=null&&resultCfg.getStringCfg().containsKey(mainTable)){ + main=resultCfg.getStringCfg().get(mainTable); + }else if(resultCfg.getIpCfg()!=null&&resultCfg.getIpCfg().containsKey(mainTable)){ + main=resultCfg.getIpCfg().get(mainTable); + }else if(resultCfg.getNumCfg()!=null&&resultCfg.getNumCfg().containsKey(mainTable)){ + main=resultCfg.getNumCfg().get(mainTable); + } + for(BaseStringCfg prop:list){ + if(main.getCompileId().longValue()==prop.getCompileId().longValue()){ + prop.setTableName(info.getTableName()); + if(resultCfg.getStringCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), prop); + resultCfg.setStringCfg(map); + }else{ + resultCfg.getStringCfg().put(info.getTableName(), prop); + } + break; + } + } + } + }else if(Constants.TABLE_TYPE_IP==type){//IP类型 + tableBean.setCanEmpty(true); + BaseIpCfg _cfg=cfg.getIpCfg()==null?new BaseIpCfg():cfg.getIpCfg(); + _cfg.setTableName(info.getTableName()); + this.setProperties(cfg, _cfg,null,null,null); + List list=ipCfgService + .findPage(page, _cfg) + .getList(); + for(MultipleCfg resultCfg:resultPage.getList()){ + BaseCfg main=null; + if(resultCfg.getComplexCfg()!=null&&resultCfg.getComplexCfg().containsKey(mainTable)){ + main=resultCfg.getComplexCfg().get(mainTable); + }else if(resultCfg.getStringCfg()!=null&&resultCfg.getStringCfg().containsKey(mainTable)){ + main=resultCfg.getStringCfg().get(mainTable); + }else if(resultCfg.getIpCfg()!=null&&resultCfg.getIpCfg().containsKey(mainTable)){ + main=resultCfg.getIpCfg().get(mainTable); + }else if(resultCfg.getNumCfg()!=null&&resultCfg.getNumCfg().containsKey(mainTable)){ + main=resultCfg.getNumCfg().get(mainTable); + } + for(BaseIpCfg prop:list){ + if(main.getCompileId().longValue()==prop.getCompileId().longValue()){ + prop.setTableName(info.getTableName()); + if(resultCfg.getIpCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), prop); + resultCfg.setIpCfg(map); + }else{ + resultCfg.getIpCfg().put(info.getTableName(), prop); + } + break; + } + } + } + }else if(Constants.TABLE_TYPE_NUMBER==type){ + NumBoundaryCfg _cfg=cfg.getNumCfg()==null?new NumBoundaryCfg():cfg.getNumCfg(); + _cfg.setTableName(info.getTableName()); + this.setProperties(cfg, null,null,_cfg,null); + List list=numCfgService + .findPage(page, _cfg) + .getList(); + for(MultipleCfg resultCfg:resultPage.getList()){ + BaseCfg main=null; + if(resultCfg.getComplexCfg()!=null&&resultCfg.getComplexCfg().containsKey(mainTable)){ + main=resultCfg.getComplexCfg().get(mainTable); + }else if(resultCfg.getStringCfg()!=null&&resultCfg.getStringCfg().containsKey(mainTable)){ + main=resultCfg.getStringCfg().get(mainTable); + }else if(resultCfg.getIpCfg()!=null&&resultCfg.getIpCfg().containsKey(mainTable)){ + main=resultCfg.getIpCfg().get(mainTable); + }else if(resultCfg.getNumCfg()!=null&&resultCfg.getNumCfg().containsKey(mainTable)){ + main=resultCfg.getNumCfg().get(mainTable); + } + for(NumBoundaryCfg prop:list){ + if(main.getCompileId().longValue()==prop.getCompileId().longValue()){ + prop.setTableName(info.getTableName()); + if(resultCfg.getNumCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), prop); + resultCfg.setNumCfg(map); + }else{ + resultCfg.getNumCfg().put(info.getTableName(), prop); + } + break; + } + } + } + } + } + } + }else{ + for(ServiceConfigInfo info:serviceConfigInfos){ + int type=info.getTableType(); + TableBean tableBean=new TableBean(info.getTableName(),String.valueOf(type)); + if(!mainTable.equals(info.getTableName())){ + otherTables.add(tableBean); + } + } + + } + } + model.addAttribute("mainTableType", cfg.getMainTableType()); + model.addAttribute("action", cfg.getAction()); + model.addAttribute("page", resultPage); + List requestInfos=requestInfoService.getAllRequestInfo(); + model.addAttribute("requestInfos", requestInfos); + List fls=serviceDictInfoService.findAllFlDict(); + model.addAttribute("fls", fls); + List xzs=serviceDictInfoService.findAllXzDict(); + model.addAttribute("xzs", xzs); + List lables=serviceDictInfoService.findAllLableDict(); + model.addAttribute("lables", lables); + return "/cfg/multipleCfgList"; + } + @RequestMapping(value = {"form"}) + public String cfgForm(int action,String mainTable,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response) { + model.addAttribute("cfgName", cfgName); + model.addAttribute("action", action); + model.addAttribute("serviceId", serviceId); + model.addAttribute("audit", Constants.CFG_PAGE); + model.addAttribute("mainTable", mainTable); + model.addAttribute("operator", "save"); + logger.info("sercice id is "+serviceId); + MultipleCfg cfg=new MultipleCfg(); + cfg.setMainTable(mainTable); + cfg.setAction(action); + cfg.setServiceId(serviceId); + List serviceConfigInfos=serviceConfigInfoService.findList(serviceId); + List otherTables=new ArrayList(); + cfg.setOtherTables(otherTables); + for(ServiceConfigInfo info:serviceConfigInfos){ + int type=info.getTableType(); + TableBean tableBean=new TableBean(info.getTableName(), String.valueOf(type)); + if(mainTable.equals(info.getTableName())){ + cfg.setMainTableType(String.valueOf(type)); + model.addAttribute("mainTableType", String.valueOf(type)); + }else{ + otherTables.add(tableBean); + } + String tableName=info.getTableName(); + if(Constants.TABLE_TYPE_IP==type){//ip类型 + tableBean.setCanEmpty(true); + BaseIpCfg ipCfg=(BaseIpCfg)this.getClassBean(info.getTableName(), true); + if(cfg.getIpCfg()==null){ + Map map=new HashMap(); + map.put(tableName,ipCfg); + cfg.setIpCfg(map); + }else{ + Map map=cfg.getIpCfg(); + map.put(tableName,ipCfg); + } + }else if(Constants.TABLE_TYPE_STRING==type){//字符串类型 + BaseStringCfg stringCfg=(BaseStringCfg)this.getClassBean(info.getTableName(), true); + if(cfg.getStringCfg()==null){ + Map map=new HashMap(); + map.put(tableName,stringCfg); + cfg.setStringCfg(map); + }else{ + Map map=cfg.getStringCfg(); + map.put(tableName,stringCfg); + } + }else if(Constants.TABLE_TYPE_NUMBER==type){//数值类型 + NumBoundaryCfg numCfg=(NumBoundaryCfg)this.getClassBean(info.getTableName(), true); + if(cfg.getNumCfg()==null){ + Map map=new HashMap(); + map.put(tableName,numCfg); + cfg.setNumCfg(map); + }else{ + Map map=cfg.getNumCfg(); + map.put(tableName,numCfg); + } + + }else if(Constants.TABLE_TYPE_COMPLEX==type){//增强字符串类型 + ComplexkeywordCfg complexCfg=(ComplexkeywordCfg)this.getClassBean(info.getTableName(), true); + if(cfg.getComplexCfg()==null){ + Map map=new HashMap(); + map.put(tableName,complexCfg); + cfg.setComplexCfg(map); + }else{ + Map map=cfg.getComplexCfg(); + map.put(tableName,complexCfg); + } + + } + } + cfg.setAction(action); + cfg.setServiceId(serviceId); + model.addAttribute("_cfg", cfg); + List requestInfos=requestInfoService.getValidRequestInfo(); + model.addAttribute("requestInfos", requestInfos); + List fls=serviceDictInfoService.findFlDict(); + model.addAttribute("fls", fls); + List xzs=serviceDictInfoService.findXzDict(); + model.addAttribute("xzs", xzs); + List lables=serviceDictInfoService.findLableDict(); + model.addAttribute("lables", lables); + + return "/cfg/multipleCfgForm"; + } + @RequestMapping(value = {"updateForm"}) + public String updateCfgForm(String cfgName,MultipleCfg cfg,Model model,HttpServletRequest request,HttpServletResponse response) { + model.addAttribute("operator", "update"); + model.addAttribute("cfgName", cfgName); + model.addAttribute("serviceId", cfg.getServiceId()); + model.addAttribute("action", cfg.getAction()); + model.addAttribute("audit", Constants.CFG_PAGE); + MultipleCfg resultCfg=new MultipleCfg(); + String mainTable=cfg.getMainTable(); + model.addAttribute("mainTable", mainTable); + resultCfg.setMainTable(mainTable); + String mainTableType=cfg.getMainTableType(); + model.addAttribute("mainTableType", mainTableType); + resultCfg.setMainTableType(mainTableType); + resultCfg.setAction(cfg.getAction()); + int serviceId=cfg.getServiceId(); + cfg.setServiceId(serviceId); + int compileId=cfg.getCompileId().intValue(); + resultCfg.setCompileId(compileId); + List serviceConfigInfos=serviceConfigInfoService.findList(serviceId); + List otherTables=new ArrayList(); + resultCfg.setOtherTables(otherTables); + for(ServiceConfigInfo info:serviceConfigInfos){ + String tableName=info.getTableName(); + int type=info.getTableType(); + if(!tableName.equals(mainTable)){ + TableBean bean=new TableBean(tableName,String.valueOf(type)); + if(Constants.TABLE_TYPE_IP==type){ + bean.setCanEmpty(true); + } + otherTables.add(bean); + } + if(Constants.TABLE_TYPE_IP==type){ + BaseIpCfg searchIpCfg=new BaseIpCfg(); + searchIpCfg.setTableName(info.getTableName()); + searchIpCfg.setCompileId(compileId); + BaseIpCfg resultIpCfg=ipCfgService.get(searchIpCfg); + if(resultIpCfg!=null){ + if(resultCfg.getIpCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), resultIpCfg); + resultCfg.setIpCfg(map); + }else{ + Map map=resultCfg.getIpCfg(); + map.put(info.getTableName(), resultIpCfg); + } + if(mainTable.equals(info.getTableName())){ + this.setPropertiesToMultipleCfg(resultCfg, resultIpCfg,"update"); + } + } + }else if(Constants.TABLE_TYPE_STRING==type){ + BaseStringCfg searchStringCfg=new BaseStringCfg(); + searchStringCfg.setTableName(info.getTableName()); + searchStringCfg.setCompileId(compileId); + BaseStringCfg resultStringCfg=stringCfgService.get(searchStringCfg); + if(resultStringCfg!=null){ + if(resultCfg.getStringCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), resultStringCfg); + resultCfg.setStringCfg(map); + }else{ + Map map=resultCfg.getStringCfg(); + map.put(info.getTableName(), resultStringCfg); + } + if(mainTable.equals(info.getTableName())){ + this.setPropertiesToMultipleCfg(resultCfg, resultStringCfg,"update"); + } + } + }else if(Constants.TABLE_TYPE_NUMBER==type){ + NumBoundaryCfg searchNumCfg=new NumBoundaryCfg(); + searchNumCfg.setTableName(info.getTableName()); + searchNumCfg.setCompileId(compileId); + NumBoundaryCfg resultNumCfg=numCfgService.get(searchNumCfg); + if(resultNumCfg!=null){ + if(resultCfg.getNumCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), resultNumCfg); + resultCfg.setNumCfg(map); + }else{ + Map map=resultCfg.getNumCfg(); + map.put(info.getTableName(), resultNumCfg); + } + if(mainTable.equals(info.getTableName())){ + this.setPropertiesToMultipleCfg(resultCfg, resultNumCfg,"update"); + } + } + }else if(Constants.TABLE_TYPE_COMPLEX==type){ + ComplexkeywordCfg searchComplexCfg=new ComplexkeywordCfg(); + searchComplexCfg.setTableName(info.getTableName()); + searchComplexCfg.setCompileId(compileId); + ComplexkeywordCfg resultComplexCfg=complexStringCfgService.get(searchComplexCfg); + if(resultComplexCfg!=null){ + if(resultCfg.getComplexCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), resultComplexCfg); + resultCfg.setComplexCfg(map); + }else{ + Map map=resultCfg.getComplexCfg(); + map.put(info.getTableName(), resultComplexCfg); + } + if(mainTable.equals(info.getTableName())){ + this.setPropertiesToMultipleCfg(resultCfg, resultComplexCfg,"update"); + } + } + } + } + model.addAttribute("_cfg", resultCfg); + List requestInfos=requestInfoService.getAllRequestInfo(); + model.addAttribute("requestInfos", requestInfos); + List fls=serviceDictInfoService.findAllFlDict(); + model.addAttribute("fls", fls); + List xzs=serviceDictInfoService.findAllXzDict(); + model.addAttribute("xzs", xzs); + List lables=serviceDictInfoService.findAllLableDict(); + model.addAttribute("lables", lables); + + return "/cfg/multipleCfgForm"; + } + @RequestMapping(value = {"deleteCfg"}) + public String deleteCfg(String cfgName,MultipleCfg cfg,Model model,HttpServletRequest request,HttpServletResponse response) { + model.addAttribute("operator", "delete"); + model.addAttribute("cfgName", cfgName); + model.addAttribute("cfgType", "multiple"); + model.addAttribute("serviceId", cfg.getServiceId()); + model.addAttribute("action", cfg.getAction()); + model.addAttribute("audit", Constants.CFG_PAGE); + MultipleCfg resultCfg=new MultipleCfg(); + String mainTable=cfg.getMainTable(); + model.addAttribute("mainTable", mainTable); + resultCfg.setMainTable(mainTable); + String mainTableType=cfg.getMainTableType(); + model.addAttribute("mainTableType", mainTableType); + resultCfg.setMainTableType(mainTableType); + resultCfg.setAction(cfg.getAction()); + int serviceId=cfg.getServiceId(); + cfg.setServiceId(serviceId); + int compileId=cfg.getCompileId().intValue(); + resultCfg.setCompileId(compileId); + List serviceConfigInfos=serviceConfigInfoService.findList(serviceId); + Date date=new Date(); + for(ServiceConfigInfo info:serviceConfigInfos){ + int type=info.getTableType(); + if(Constants.TABLE_TYPE_IP==type){ + BaseIpCfg searchIpCfg=new BaseIpCfg(); + searchIpCfg.setTableName(info.getTableName()); + searchIpCfg.setCompileId(compileId); + searchIpCfg.setIsValid(Constants.VALID_DEL); + searchIpCfg.setIsAudit(Constants.AUDIT_NOT_YET); + searchIpCfg.setEditorId(cfg.getCurrentUser().getId()); + searchIpCfg.setEditTime(date); + if(resultCfg.getIpCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), searchIpCfg); + resultCfg.setIpCfg(map); + }else{ + Map map=resultCfg.getIpCfg(); + map.put(info.getTableName(), searchIpCfg); + } + }else if(Constants.TABLE_TYPE_STRING==type){ + BaseStringCfg searchStringCfg=new BaseStringCfg(); + searchStringCfg.setTableName(info.getTableName()); + searchStringCfg.setCompileId(compileId); + searchStringCfg.setIsValid(Constants.VALID_DEL); + searchStringCfg.setIsAudit(Constants.AUDIT_NOT_YET); + searchStringCfg.setEditorId(cfg.getCurrentUser().getId()); + searchStringCfg.setEditTime(date); + if(resultCfg.getStringCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), searchStringCfg); + resultCfg.setStringCfg(map); + }else{ + Map map=resultCfg.getStringCfg(); + map.put(info.getTableName(), searchStringCfg); + } + }else if(Constants.TABLE_TYPE_NUMBER==type){ + NumBoundaryCfg searchNumCfg=new NumBoundaryCfg(); + searchNumCfg.setTableName(info.getTableName()); + searchNumCfg.setCompileId(compileId); + searchNumCfg.setIsValid(Constants.VALID_DEL); + searchNumCfg.setIsAudit(Constants.AUDIT_NOT_YET); + searchNumCfg.setEditorId(cfg.getCurrentUser().getId()); + searchNumCfg.setEditTime(date); + if(resultCfg.getNumCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), searchNumCfg); + resultCfg.setNumCfg(map); + }else{ + Map map=resultCfg.getNumCfg(); + map.put(info.getTableName(), searchNumCfg); + } + }else if(Constants.TABLE_TYPE_COMPLEX==type){ + ComplexkeywordCfg searchComplexCfg=new ComplexkeywordCfg(); + searchComplexCfg.setTableName(info.getTableName()); + searchComplexCfg.setCompileId(compileId); + searchComplexCfg.setIsValid(Constants.VALID_DEL); + searchComplexCfg.setIsAudit(Constants.AUDIT_NOT_YET); + searchComplexCfg.setEditorId(cfg.getCurrentUser().getId()); + searchComplexCfg.setEditTime(date); + if(resultCfg.getComplexCfg()==null){ + Map map=new HashMap(); + map.put(info.getTableName(), searchComplexCfg); + resultCfg.setComplexCfg(map); + }else{ + Map map=resultCfg.getComplexCfg(); + map.put(info.getTableName(), searchComplexCfg); + } + } + } + try{ + multipleCfgService.deleteCfg(resultCfg); + }catch (Exception e) { + logger.error("删除失败"); + addMessage(model,"删除,正在为您跳转页面..."); + } + addMessage(model,"删除成功,正在为您跳转页面..."); + return "/cfg/resultPage"; + } + + /** + * + * saveOrUpdateCfg(保存配置) + * (这里描述这个方法适用条件 – 可选) + * @return + *String + * @exception + * @since 1.0.0 + */ + @RequestMapping(value = {"saveOrUpdateCfg"}) + public String saveOrUpdateCfg(String operator,String cfgName,Model model, MultipleCfg cfg) { + model.addAttribute("cfgName",cfgName); + model.addAttribute("action",cfg.getAction()); + model.addAttribute("cfgType", "multiple"); + model.addAttribute("audit", Constants.CFG_PAGE); + logger.info("saveOrUpdateCfg loaded"); + int serviceId=cfg.getServiceId(); + Date date=new Date(); + String mainTable=cfg.getMainTable(); + model.addAttribute("mainTable",mainTable); + model.addAttribute("serviceId",serviceId); + model.addAttribute("action",cfg.getAction()); + try{ + List serviceConfigInfos=serviceConfigInfoService.findList(cfg.getServiceId()); + Integer compileId=0; + if(operator.equals("save")){ + compileId=new ConvertTool().getCompileId(); + }else if(operator.equals("update")){ + compileId=cfg.getCompileId(); + } + for(ServiceConfigInfo info:serviceConfigInfos){ + if(Constants.TABLE_TYPE_IP==info.getTableType()){ + if(cfg.getIpCfg()!=null){ + for(Entry ipCfg:cfg.getIpCfg().entrySet()){ + if(!isNull(ipCfg.getValue())){ + ipCfg.getValue().setTableName(ipCfg.getKey()); + ipCfg.getValue().setIsValid(Constants.VALID_NO); + ipCfg.getValue().setIsAudit(Constants.AUDIT_NOT_YET); + ipCfg.getValue().setCompileId(compileId); + setProperties(cfg,ipCfg.getValue(),null,null,null); + if(ipCfg.getValue().getCfgId()==null){ + ipCfg.getValue().setCreatorId(cfg.getCurrentUser().getId()); + ipCfg.getValue().setCreateTime(date); + }else{ + ipCfg.getValue().setEditorId(cfg.getCurrentUser().getId()); + ipCfg.getValue().setEditTime(date); + } + } + } + } + }else if(Constants.TABLE_TYPE_STRING==info.getTableType()){ + if(cfg.getStringCfg()!=null){ + for(Entry stringCfg:cfg.getStringCfg().entrySet()){ + if(!isNull(stringCfg.getValue())){ + stringCfg.getValue().setTableName(stringCfg.getKey()); + stringCfg.getValue().setIsValid(Constants.VALID_NO); + stringCfg.getValue().setIsAudit(Constants.AUDIT_NOT_YET); + stringCfg.getValue().setCompileId(compileId); + setProperties(cfg,null,stringCfg.getValue(),null,null); + if(stringCfg.getValue().getCfgId()==null){ + stringCfg.getValue().setCreatorId(cfg.getCurrentUser().getId()); + stringCfg.getValue().setCreateTime(date); + }else{ + stringCfg.getValue().setEditorId(cfg.getCurrentUser().getId()); + stringCfg.getValue().setEditTime(date); + } + } + } + } + }else if(Constants.TABLE_TYPE_NUMBER==info.getTableType()){ + if(cfg.getNumCfg()!=null){ + for(Entry numCfg:cfg.getNumCfg().entrySet()){ + if(!isNull(numCfg.getValue())){ + numCfg.getValue().setTableName(info.getTableName()); + numCfg.getValue().setIsValid(Constants.VALID_NO); + numCfg.getValue().setIsAudit(Constants.AUDIT_NOT_YET); + numCfg.getValue().setCompileId(compileId); + setProperties(cfg,null,null,numCfg.getValue(),null); + if(numCfg.getValue().getCfgId()==null){ + numCfg.getValue().setCreatorId(cfg.getCurrentUser().getId()); + numCfg.getValue().setCreateTime(date); + }else{ + numCfg.getValue().setEditorId(cfg.getCurrentUser().getId()); + numCfg.getValue().setEditTime(date); + } + } + } + + } + }else if(Constants.TABLE_TYPE_COMPLEX==info.getTableType()){ + if(cfg.getComplexCfg()!=null){ + for(Entry complexCfg:cfg.getComplexCfg().entrySet()){ + if(!isNull(complexCfg.getValue())){ + complexCfg.getValue().setTableName(info.getTableName()); + complexCfg.getValue().setIsValid(Constants.VALID_NO); + complexCfg.getValue().setIsAudit(Constants.AUDIT_NOT_YET); + complexCfg.getValue().setCompileId(compileId); + setProperties(cfg,null,null,null,complexCfg.getValue()); + if(complexCfg.getValue().getCfgId()==null){ + complexCfg.getValue().setCreatorId(cfg.getCurrentUser().getId()); + complexCfg.getValue().setCreateTime(date); + }else{ + complexCfg.getValue().setEditorId(cfg.getCurrentUser().getId()); + complexCfg.getValue().setEditTime(new Date()); + } + } + } + + } + } + } + if("save".equals(operator)){ + multipleCfgService.addCfg(cfg); + }else if("update".equals(operator)){ + multipleCfgService.updateCfg(cfg); + } + addMessage(model,"保存成功,正在为您跳转页面..."); + }catch (Exception e) { + e.printStackTrace(); + logger.error("保存失败!",e); + // TODO: handle exception + addMessage(model,"保存失败!"); + } + return "/cfg/resultPage"; + } + /** + * + * auditIpCfg(审核IP配置) + * (审核流程只在审核页面) + * @return + *String + * @exception + * @since 1.0.0 + */ + @RequestMapping(value = {"auditCfg"}) + public String auditCfg(String cfgName,MultipleCfg cfg,Model model) { + model.addAttribute("cfgName", cfgName); + model.addAttribute("audit", Constants.AUDIT_PAGE); + model.addAttribute("serviceId", cfg.getServiceId()); + model.addAttribute("action", cfg.getAction()); + model.addAttribute("mainTable", cfg.getMainTable()); + int compileId=cfg.getCompileId().intValue(); + int audit=cfg.getIsAudit(); + MultipleCfg searchCfg=new MultipleCfg(); + List serviceConfigInfos=serviceConfigInfoService.findList(cfg.getServiceId()); + Date date=new Date(); + for(ServiceConfigInfo info:serviceConfigInfos){ + int type=info.getTableType(); + String tableName=info.getTableName(); + if(Constants.TABLE_TYPE_IP==type){ + BaseIpCfg searchIpCfg=new BaseIpCfg(); + searchIpCfg.setTableName(tableName); + searchIpCfg.setCompileId(compileId); + searchIpCfg.setAuditorId(searchIpCfg.getCurrentUser().getId()); + searchIpCfg.setAuditTime(date); + if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 + searchIpCfg.setIsValid(Constants.VALID_NO); + }else if(audit==Constants.AUDIT_YES){//审核通过,设置有效标志为1 + searchIpCfg.setIsValid(Constants.VALID_YES); + } + if(searchCfg.getIpCfg()==null){ + Map map=new HashMap(); + map.put(tableName, searchIpCfg); + searchCfg.setIpCfg(map); + }else{ + Map map=searchCfg.getIpCfg(); + map.put(tableName, searchIpCfg); + } + }else if(Constants.TABLE_TYPE_STRING==type){ + BaseStringCfg searchStringCfg=new BaseStringCfg(); + searchStringCfg.setTableName(tableName); + searchStringCfg.setCompileId(compileId); + searchStringCfg.setAuditorId(searchStringCfg.getCurrentUser().getId()); + searchStringCfg.setAuditTime(date); + if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 + searchStringCfg.setIsValid(Constants.VALID_NO); + }else if(audit==Constants.AUDIT_YES){//审核通过,设置有效标志为1 + searchStringCfg.setIsValid(Constants.VALID_YES); + } + if(searchCfg.getStringCfg()==null){ + Map map=new HashMap(); + map.put(tableName, searchStringCfg); + searchCfg.setStringCfg(map); + }else{ + Map map=searchCfg.getStringCfg(); + map.put(tableName, searchStringCfg); + } + }else if(Constants.TABLE_TYPE_NUMBER==type){ + NumBoundaryCfg searchNumCfg=new NumBoundaryCfg(); + searchNumCfg.setTableName(tableName); + searchNumCfg.setCompileId(compileId); + searchNumCfg.setAuditorId(searchNumCfg.getCurrentUser().getId()); + searchNumCfg.setAuditTime(date); + if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 + searchNumCfg.setIsValid(Constants.VALID_NO); + }else if(audit==Constants.AUDIT_YES){//审核通过,设置有效标志为1 + searchNumCfg.setIsValid(Constants.VALID_YES); + } + if(searchCfg.getNumCfg()==null){ + Map map=new HashMap(); + map.put(tableName, searchNumCfg); + searchCfg.setNumCfg(map); + }else{ + Map map=searchCfg.getNumCfg(); + map.put(tableName, searchNumCfg); + } + }else if(Constants.TABLE_TYPE_COMPLEX==type){ + ComplexkeywordCfg searchComplexCfg=new ComplexkeywordCfg(); + searchComplexCfg.setTableName(tableName); + searchComplexCfg.setCompileId(compileId); + searchComplexCfg.setAuditorId(searchComplexCfg.getCurrentUser().getId()); + searchComplexCfg.setAuditTime(date); + if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 + searchComplexCfg.setIsValid(Constants.VALID_NO); + }else if(audit==Constants.AUDIT_YES){//审核通过,设置有效标志为1 + searchComplexCfg.setIsValid(Constants.VALID_YES); + } + if(searchCfg.getComplexCfg()==null){ + Map map=new HashMap(); + map.put(tableName, searchComplexCfg); + searchCfg.setComplexCfg(map); + }else{ + Map map=searchCfg.getComplexCfg(); + map.put(tableName, searchComplexCfg); + } + } + } + multipleCfgService.auditCfg(searchCfg); + + return "redirect:" + adminPath + "/cfg/multiple/list"; + } + /** + * + * getClassBean(通过表名获取类) + * (这里描述这个方法适用条件 – 可选) + * @param tableName 表名 + * @param initDefaultValue 是否初始化bean的默认值 + * @return + *BaseCfg + * @exception + * @since 1.0.0 + */ + @SuppressWarnings("rawtypes") + protected BaseCfg getClassBean(String tableName,boolean initDefaultValue){ + logger.info("table name is "+tableName); + String className=ipCfgService.getClassName(tableName); + logger.info("class name is "+className); + String packageName=BaseCfg.class.getPackage().getName(); + + //通过反射获得BaseCfg的子类的实例,并调用子类的initDefaultValue初始化默认值 + try { + Class clazz = Class.forName(packageName+"."+className); + BaseCfg cfg=(BaseCfg)clazz.newInstance(); + cfg.setTableName(tableName); + if(initDefaultValue){ + cfg.initDefaultValue(); + } + return cfg; + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + @SuppressWarnings("rawtypes") + protected boolean isNull(BaseCfg cfg) { + if(cfg==null)return true; + try { + Field[] fieldArray=cfg.getClass().getDeclaredFields(); + for(Field field:fieldArray){ + field.setAccessible(true); + if(field.get(cfg)!=null&&!"serialVersionUID".equals(field.getName())){ + return false; + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return true; + } + @SuppressWarnings("rawtypes") + protected void setPropertiesToMultipleCfg(MultipleCfg resultCfg,BaseCfg _cfg,String option){ + resultCfg.setAction(_cfg.getAction()); + resultCfg.setAreaEffectiveIds(_cfg.getAreaEffectiveIds()); + resultCfg.setAttribute(_cfg.getAttribute()); + resultCfg.setClassify(_cfg.getClassify()); + resultCfg.setLable(_cfg.getLable()); + resultCfg.setCompileId(_cfg.getCompileId()); + resultCfg.setIsAreaEffective(_cfg.getIsAreaEffective()); + resultCfg.setIsAudit(_cfg.getIsAudit()); + resultCfg.setIsValid(_cfg.getIsValid()); + resultCfg.setRequestId(_cfg.getRequestId()); + resultCfg.setServiceId(_cfg.getServiceId()); + if("select".equals(option)){//列表时设置以下属性 + resultCfg.setCreatorId(_cfg.getCreatorId()); + resultCfg.setCreatorName(_cfg.getCreatorName()); + resultCfg.setCreateTime(_cfg.getCreateTime()); + resultCfg.setEditorId(_cfg.getEditorId()); + resultCfg.setEditorName(_cfg.getEditorName()); + resultCfg.setEditTime(_cfg.getEditTime()); + resultCfg.setAuditorId(_cfg.getAuditorId()); + resultCfg.setAuditorName(_cfg.getAuditorName()); + resultCfg.setAuditTime(_cfg.getAuditTime()); + } + } + protected void setProperties(MultipleSearchCfg source,BaseIpCfg ipCfg,BaseStringCfg stringCfg,NumBoundaryCfg numCfg,ComplexkeywordCfg complexCfg){ + if(ipCfg!=null){ + ipCfg.setAction(source.getAction()); + ipCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + ipCfg.setAttribute(source.getAttribute()); + ipCfg.setClassify(source.getClassify()); + ipCfg.setLable(source.getLable()); + ipCfg.setIsAreaEffective(source.getIsAreaEffective()); + ipCfg.setRequestId(source.getRequestId()); + ipCfg.setServiceId(source.getServiceId()); + ipCfg.setCreatorId(source.getCreatorId()); + ipCfg.setCreatorName(source.getCreatorName()); + ipCfg.setCreateTime(source.getCreateTime()); + ipCfg.setEditorId(source.getEditorId()); + ipCfg.setEditorName(source.getEditorName()); + ipCfg.setEditTime(source.getEditTime()); + ipCfg.setAuditorId(source.getAuditorId()); + ipCfg.setAuditorName(source.getAuditorName()); + ipCfg.setAuditTime(source.getAuditTime()); + } + if(stringCfg!=null){ + stringCfg.setAction(source.getAction()); + stringCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + stringCfg.setAttribute(source.getAttribute()); + stringCfg.setClassify(source.getClassify()); + stringCfg.setLable(source.getLable()); + stringCfg.setIsAreaEffective(source.getIsAreaEffective()); + stringCfg.setRequestId(source.getRequestId()); + stringCfg.setServiceId(source.getServiceId()); + stringCfg.setCreatorId(source.getCreatorId()); + stringCfg.setCreatorName(source.getCreatorName()); + stringCfg.setCreateTime(source.getCreateTime()); + stringCfg.setEditorId(source.getEditorId()); + stringCfg.setEditorName(source.getEditorName()); + stringCfg.setEditTime(source.getEditTime()); + stringCfg.setAuditorId(source.getAuditorId()); + stringCfg.setAuditorName(source.getAuditorName()); + stringCfg.setAuditTime(source.getAuditTime()); + } + if(numCfg!=null){ + numCfg.setAction(source.getAction()); + numCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + numCfg.setAttribute(source.getAttribute()); + numCfg.setClassify(source.getClassify()); + numCfg.setLable(source.getLable()); + numCfg.setIsAreaEffective(source.getIsAreaEffective()); + numCfg.setRequestId(source.getRequestId()); + numCfg.setServiceId(source.getServiceId()); + numCfg.setCreatorId(source.getCreatorId()); + numCfg.setCreatorName(source.getCreatorName()); + numCfg.setCreateTime(source.getCreateTime()); + numCfg.setEditorId(source.getEditorId()); + numCfg.setEditorName(source.getEditorName()); + numCfg.setEditTime(source.getEditTime()); + numCfg.setAuditorId(source.getAuditorId()); + numCfg.setAuditorName(source.getAuditorName()); + numCfg.setAuditTime(source.getAuditTime()); + } + if(complexCfg!=null){ + complexCfg.setAction(source.getAction()); + complexCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + complexCfg.setAttribute(source.getAttribute()); + complexCfg.setClassify(source.getClassify()); + complexCfg.setLable(source.getLable()); + complexCfg.setIsAreaEffective(source.getIsAreaEffective()); + complexCfg.setRequestId(source.getRequestId()); + complexCfg.setServiceId(source.getServiceId()); + complexCfg.setCreatorId(source.getCreatorId()); + complexCfg.setCreatorName(source.getCreatorName()); + complexCfg.setCreateTime(source.getCreateTime()); + complexCfg.setEditorId(source.getEditorId()); + complexCfg.setEditorName(source.getEditorName()); + complexCfg.setEditTime(source.getEditTime()); + complexCfg.setAuditorId(source.getAuditorId()); + complexCfg.setAuditorName(source.getAuditorName()); + complexCfg.setAuditTime(source.getAuditTime()); + } + } + protected void setProperties(MultipleCfg source,BaseIpCfg ipCfg,BaseStringCfg stringCfg,NumBoundaryCfg numCfg,ComplexkeywordCfg complexCfg){ + if(ipCfg!=null){ + ipCfg.setAction(source.getAction()); + ipCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + ipCfg.setAttribute(source.getAttribute()); + ipCfg.setClassify(source.getClassify()); + ipCfg.setLable(source.getLable()); + ipCfg.setIsAreaEffective(source.getIsAreaEffective()); + ipCfg.setRequestId(source.getRequestId()); + ipCfg.setServiceId(source.getServiceId()); + } + if(stringCfg!=null){ + stringCfg.setAction(source.getAction()); + stringCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + stringCfg.setAttribute(source.getAttribute()); + stringCfg.setClassify(source.getClassify()); + stringCfg.setLable(source.getLable()); + stringCfg.setIsAreaEffective(source.getIsAreaEffective()); + stringCfg.setRequestId(source.getRequestId()); + stringCfg.setServiceId(source.getServiceId()); + } + if(numCfg!=null){ + numCfg.setAction(source.getAction()); + numCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + numCfg.setAttribute(source.getAttribute()); + numCfg.setClassify(source.getClassify()); + numCfg.setLable(source.getLable()); + numCfg.setIsAreaEffective(source.getIsAreaEffective()); + numCfg.setRequestId(source.getRequestId()); + numCfg.setServiceId(source.getServiceId()); + } + if(complexCfg!=null){ + complexCfg.setAction(source.getAction()); + complexCfg.setAreaEffectiveIds(source.getAreaEffectiveIds()); + complexCfg.setAttribute(source.getAttribute()); + complexCfg.setClassify(source.getClassify()); + complexCfg.setLable(source.getLable()); + complexCfg.setIsAreaEffective(source.getIsAreaEffective()); + complexCfg.setRequestId(source.getRequestId()); + complexCfg.setServiceId(source.getServiceId()); + } + } + protected void setPageProps(Page source,Page target){ + target.setCount(source.getCount()); + target.setPageNo(source.getPageNo()); + target.setPageSize(source.getPageSize()); + } +} diff --git a/src/main/java/com/nis/web/controller/configuration/NumCfgController.java b/src/main/java/com/nis/web/controller/configuration/NumCfgController.java index f064d3d71..c5dc854a8 100644 --- a/src/main/java/com/nis/web/controller/configuration/NumCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/NumCfgController.java @@ -13,9 +13,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import com.nis.domain.Page; import com.nis.domain.ServiceConfigInfo; import com.nis.domain.basics.ServiceDictInfo; -import com.nis.domain.configuration.BaseCfg; +import com.nis.domain.configuration.ComplexkeywordCfg; import com.nis.domain.configuration.NumBoundaryCfg; import com.nis.domain.configuration.RequestInfo; +import com.nis.main.ConvertTool; import com.nis.util.Constants; import com.nis.web.controller.BaseController; @@ -27,7 +28,6 @@ import com.nis.web.controller.BaseController; @Controller @RequestMapping("${adminPath}/cfg/num") public class NumCfgController extends BaseController{ - @RequestMapping(value = {"list"}) public String cfgList(Model model,Integer audit,Integer pageNo,Integer pageSize,String cfgName,@ModelAttribute("cfg")NumBoundaryCfg cfg,HttpServletRequest request,HttpServletResponse response) { model.addAttribute("cfgName", cfgName); @@ -136,16 +136,11 @@ public class NumCfgController extends BaseController{ model.addAttribute("cfgType","num"); model.addAttribute("audit", Constants.CFG_PAGE); logger.info("saveOrUpdateStringCfg loaded"); - if(cfg==null){ - logger.error("无法保存空的配置!"); - addMessage(model,"保存失败!"); - }else if(cfg.getServiceId()!=null){ + try{ int serviceId=cfg.getServiceId(); ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); if(serviceConfigInfo!=null){ - long compileId=getCompileId(cfg); -// cfg.setCreatorId(cfg.getCurrentUser().getId()); -// cfg.setCreateTime(new Date()); + int compileId=new ConvertTool().getCompileId(); cfg.setIsValid(Constants.VALID_NO); cfg.setIsAudit(Constants.AUDIT_NOT_YET); cfg.setCompileId(compileId); @@ -162,11 +157,11 @@ public class NumCfgController extends BaseController{ model.addAttribute("action",cfg.getAction()); addMessage(model,"保存成功,正在为您跳转页面..."); } - }else{ + }catch(Exception e){ + logger.error("保存失败", e); addMessage(model,"保存失败!"); - logger.error("无法确定IP配置的表名!"); } - return "/cfg/resultPage";//StringEscapeUtils.escapeHtml4("?serviceId="+cfg.getServiceId()+"&action="+cfg.getAction()+"&cfgName="+cfgName); + return "/cfg/resultPage"; } /** @@ -182,31 +177,42 @@ public class NumCfgController extends BaseController{ public String auditStringCfg(String cfgName,NumBoundaryCfg cfg,Model model) { model.addAttribute("cfgName", cfgName); model.addAttribute("audit", Constants.AUDIT_PAGE); - if(cfg==null){ - logger.error("无法审核空的配置!"); - }else if(cfg.getServiceId()!=null){ + model.addAttribute("serviceId", cfg.getServiceId()); + model.addAttribute("action", cfg.getAction()); + try{ int serviceId=cfg.getServiceId(); ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); if(serviceConfigInfo!=null){ - int audit=numCfgService.getIsAudit(cfg); + NumBoundaryCfg bean=numCfgService.getNumCfgById(cfg); + bean.setTableName(serviceConfigInfo.getTableName()); + int audit=bean.getIsAudit().intValue(); if(audit==Constants.AUDIT_YES&&cfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ logger.error("审核通过的配置只能取消审核通过!"); }else{ cfg.setAuditorId(cfg.getCurrentUser().getId()); cfg.setAuditTime(new Date()); - + bean.setIsAudit(cfg.getIsAudit()); if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 cfg.setIsValid(Constants.VALID_NO); + bean.setIsValid(Constants.VALID_NO); + bean.setMaatTable(serviceConfigInfo.getMaatTable()); }else if(cfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 cfg.setIsValid(Constants.VALID_YES); + bean.setIsValid(Constants.VALID_YES); } - int result=numCfgService.auditNumCfg(cfg); - model.addAttribute("serviceId", serviceId); - model.addAttribute("action", cfg.getAction()); + int result=numCfgService.auditNumCfg(bean,cfg); + if(result!=0){ + addMessage(model, "审核成功"); + }else{ + addMessage(model, "审核失败"); + } + } } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch (Exception e) { + // TODO: handle exception + logger.error("审核失败",e); + addMessage(model, "审核失败"); } return "redirect:" + adminPath + "/cfg/num/list"; } @@ -257,7 +263,14 @@ public class NumCfgController extends BaseController{ * @exception * @since 1.0.0 */ - protected long getCompileId(BaseCfg cfg){ - return 0; + protected long getCompileId(NumBoundaryCfg cfg){ + long compileId=0l; + try { + compileId = cfg.getCompileId()==null?new ConvertTool().getCompileId():cfg.getCompileId(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compileId; } } diff --git a/src/main/java/com/nis/web/controller/configuration/StringCfgController.java b/src/main/java/com/nis/web/controller/configuration/StringCfgController.java index c1da0c564..96061ea8b 100644 --- a/src/main/java/com/nis/web/controller/configuration/StringCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/StringCfgController.java @@ -14,9 +14,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import com.nis.domain.Page; import com.nis.domain.ServiceConfigInfo; import com.nis.domain.basics.ServiceDictInfo; -import com.nis.domain.configuration.BaseCfg; import com.nis.domain.configuration.BaseStringCfg; +import com.nis.domain.configuration.ComplexkeywordCfg; import com.nis.domain.configuration.RequestInfo; +import com.nis.main.ConvertTool; import com.nis.util.Constants; import com.nis.web.controller.BaseController; @@ -121,7 +122,13 @@ public class StringCfgController extends BaseController{ model.addAttribute("action", action); model.addAttribute("tableName", tableName); model.addAttribute("audit", Constants.CFG_PAGE); - if(!StringUtils.isBlank(tableName)){ + try{ + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + } + } logger.info("table name is "+tableName); BaseStringCfg searchBean=new BaseStringCfg(); searchBean.setCfgId(cfgId); @@ -136,32 +143,10 @@ public class StringCfgController extends BaseController{ model.addAttribute("xzs", xzs); List lables=serviceDictInfoService.findAllLableDict(); model.addAttribute("lables", lables); - }else if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - logger.info("table name is "+tableName); - BaseStringCfg searchBean=new BaseStringCfg(); - searchBean.setCfgId(cfgId); - searchBean.setTableName(tableName); - BaseStringCfg stringCfg=stringCfgService.getStringCfgById(searchBean); - model.addAttribute("_cfg", stringCfg); - List requestInfos=requestInfoService.getAllRequestInfo(); - model.addAttribute("requestInfos", requestInfos); - List fls=serviceDictInfoService.findAllFlDict(); - model.addAttribute("fls", fls); - List xzs=serviceDictInfoService.findAllXzDict(); - model.addAttribute("xzs", xzs); - List lables=serviceDictInfoService.findAllLableDict(); - model.addAttribute("lables", lables); - - } - } - }else{ - logger.error("未获取到正确的表名"); + }catch (Exception e) { + // TODO: handle exception + logger.error("发生异常",e); } - return "/cfg/stringCfgForm"; } @@ -179,15 +164,20 @@ public class StringCfgController extends BaseController{ model.addAttribute("cfgName",cfgName); model.addAttribute("cfgType","string"); model.addAttribute("audit", Constants.CFG_PAGE); + model.addAttribute("serviceId",stringCfg.getServiceId()); + model.addAttribute("action",stringCfg.getAction()); logger.info("saveOrUpdateStringCfg loaded"); - if(stringCfg==null){ - logger.error("无法保存空的配置!"); - addMessage(model,"保存失败!"); - }else if(!StringUtils.isBlank(stringCfg.getTableName())){ + try{ + String tableName=stringCfg.getTableName(); int serviceId=stringCfg.getServiceId(); - long compileId=getCompileId(stringCfg); -// stringCfg.setCreatorId(stringCfg.getCurrentUser().getId()); -// stringCfg.setCreateTime(new Date()); + if(StringUtils.isBlank(stringCfg.getTableName())){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + stringCfg.setTableName(tableName); + } + } + int compileId=new ConvertTool().getCompileId(); stringCfg.setIsValid(Constants.VALID_NO); stringCfg.setIsAudit(Constants.AUDIT_NOT_YET); stringCfg.setCompileId(compileId); @@ -200,41 +190,13 @@ public class StringCfgController extends BaseController{ stringCfg.setEditTime(new Date()); stringCfgService.updateStringCfg(stringCfg); } - model.addAttribute("serviceId",serviceId); - model.addAttribute("action",stringCfg.getAction()); addMessage(model,"保存成功,正在为您跳转页面..."); - }else if(stringCfg.getServiceId()!=null){ - int serviceId=stringCfg.getServiceId(); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - long compileId=getCompileId(stringCfg); - stringCfg.setTableName(tableName); -// stringCfg.setCreatorId(stringCfg.getCurrentUser().getId()); -// stringCfg.setCreateTime(new Date()); - stringCfg.setIsValid(Constants.VALID_NO); - stringCfg.setIsAudit(Constants.AUDIT_NOT_YET); - stringCfg.setCompileId(compileId); - if(stringCfg.getCfgId()==null){ - stringCfg.setCreatorId(stringCfg.getCurrentUser().getId()); - stringCfg.setCreateTime(new Date()); - stringCfgService.addStringCfg(stringCfg); - }else{ - stringCfg.setEditorId(stringCfg.getCurrentUser().getId()); - stringCfg.setEditTime(new Date()); - stringCfgService.updateStringCfg(stringCfg); - } - model.addAttribute("serviceId",serviceId); - model.addAttribute("action",stringCfg.getAction()); - addMessage(model,"保存成功,正在为您跳转页面..."); - } - } - }else{ - addMessage(model,"保存失败!"); - logger.error("无法确定IP配置的表名!"); + }catch (Exception e) { + // TODO: handle exception + logger.error("保存失败!",e); + addMessage(model,"保存失败!"); } - return "/cfg/resultPage";//StringEscapeUtils.escapeHtml4("?serviceId="+stringCfg.getServiceId()+"&action="+stringCfg.getAction()+"&cfgName="+cfgName); + return "/cfg/resultPage"; } /** @@ -250,53 +212,50 @@ public class StringCfgController extends BaseController{ public String auditStringCfg(String cfgName,BaseStringCfg stringCfg,Model model) { model.addAttribute("cfgName", cfgName); model.addAttribute("audit", Constants.AUDIT_PAGE); - if(stringCfg==null){ - logger.error("无法审核空的配置!"); - }else if(!StringUtils.isBlank(stringCfg.getTableName())){ - int audit=stringCfgService.getIsAudit(stringCfg); + model.addAttribute("serviceId", stringCfg.getServiceId()); + model.addAttribute("action", stringCfg.getAction()); + try{ + String tableName=stringCfg.getTableName(); + int serviceId=stringCfg.getServiceId(); + String maatTable=null; + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + if(StringUtils.isBlank(tableName)){ + tableName=serviceConfigInfo.getTableName(); + stringCfg.setTableName(tableName); + } + maatTable=serviceConfigInfo.getMaatTable(); + } + + BaseStringCfg bean=stringCfgService.getStringCfgById(stringCfg); + bean.setTableName(tableName); + int audit=bean.getIsAudit().intValue(); if(audit==Constants.AUDIT_YES&&stringCfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ logger.error("审核通过的配置只能取消审核通过!"); }else{ stringCfg.setAuditorId(stringCfg.getCurrentUser().getId()); stringCfg.setAuditTime(new Date()); - + bean.setIsAudit(stringCfg.getIsAudit()); if(stringCfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 stringCfg.setIsValid(Constants.VALID_NO); + bean.setIsValid(Constants.VALID_NO); + bean.setMaatTable(maatTable); }else if(stringCfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 stringCfg.setIsValid(Constants.VALID_YES); + bean.setIsValid(Constants.VALID_YES); } - int result=stringCfgService.auditStringCfg(stringCfg); - model.addAttribute("serviceId", stringCfg.getServiceId()); - model.addAttribute("action", stringCfg.getAction()); - } - - }else if(stringCfg.getServiceId()!=null){ - int serviceId=stringCfg.getServiceId(); - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - String tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - stringCfg.setTableName(tableName); - int audit=stringCfgService.getIsAudit(stringCfg); - if(audit==Constants.AUDIT_YES&&stringCfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ - logger.error("审核通过的配置只能取消审核通过!"); - }else{ - stringCfg.setAuditorId(stringCfg.getCurrentUser().getId()); - stringCfg.setAuditTime(new Date()); - - if(stringCfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 - stringCfg.setIsValid(Constants.VALID_NO); - }else if(stringCfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 - stringCfg.setIsValid(Constants.VALID_YES); - } - int result=stringCfgService.auditStringCfg(stringCfg); - model.addAttribute("serviceId", serviceId); - model.addAttribute("action", stringCfg.getAction()); - } + int result=stringCfgService.auditStringCfg(bean,stringCfg); + if(result!=0){ + addMessage(model,"审核成功!"); + }else{ + addMessage(model,"审核失败!"); } + } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch (Exception e) { + // TODO: handle exception + logger.error("审核失败", e); + addMessage(model,"审核失败!"); } return "redirect:" + adminPath + "/cfg/string/list"; } @@ -316,7 +275,13 @@ public class StringCfgController extends BaseController{ model.addAttribute("action", action); model.addAttribute("cfgType","string"); model.addAttribute("audit", Constants.CFG_PAGE); - if(!StringUtils.isBlank(tableName)){ + try{ + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + } + } int audit=stringCfgService.getIsAudit(tableName,cfgId); //未审核时可删除 if(audit!=Constants.AUDIT_YES){ @@ -332,42 +297,10 @@ public class StringCfgController extends BaseController{ logger.error("通过审核的配置不能删除!"); } - }else if(serviceId!=null){ - ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); - if(serviceConfigInfo!=null){ - tableName=serviceConfigInfo.getTableName(); - if(!StringUtils.isBlank(tableName)){ - BaseStringCfg stringCfg=new BaseStringCfg(); - stringCfg.setCfgId(cfgId); - stringCfg.setTableName(tableName); - int audit=stringCfgService.getIsAudit(stringCfg); - //未审核时可删除 - if(audit!=Constants.AUDIT_YES){ - stringCfg.setEditorId(stringCfg.getCurrentUser().getId()); - stringCfg.setEditTime(new Date()); - stringCfg.setIsValid(Constants.VALID_DEL); - int result=stringCfgService.deleteStringCfg(stringCfg); - addMessage(model,"删除成功,正在为您跳转页面..."); - }else{ - logger.error("通过审核的配置不能删除!"); - } - } - } - }else{ - logger.error("无法确定IP配置的表名!"); + }catch(Exception e){ + logger.error("删除失败",e); + addMessage(model,"删除失败!"); } return "/cfg/resultPage"; } - /** - * - * getCompileId(获取编译ID) - * (这里描述这个方法适用条件 – 可选) - * @return - *long - * @exception - * @since 1.0.0 - */ - protected long getCompileId(BaseCfg cfg){ - return 0; - } } diff --git a/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.java b/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.java index 8d1b2b608..9d052efbb 100644 --- a/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.java @@ -26,4 +26,5 @@ public interface ComplexStringCfgDao extends CrudDao{ public int getIsValid(ComplexkeywordCfg entity); public int getIsAudit(@Param("tableName")String tableName,@Param("cfgId")Long id); public int getIsAudit(ComplexkeywordCfg entity); + public int deleteByCompileId(ComplexkeywordCfg entity); } diff --git a/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.xml index 7267ef454..a9c411c7c 100644 --- a/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/ComplexStringCfgDao.xml @@ -481,4 +481,7 @@ SELECT IS_AUDIT FROM ${tableName} WHERE CFG_ID = #{cfgId,jdbcType=BIGINT} + + update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER}, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER} + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java index b96fe0341..9fb764cb2 100644 --- a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.java @@ -26,4 +26,5 @@ public interface IpCfgDao extends CrudDao{ public int getIsValid(BaseIpCfg entity); public int getIsAudit(@Param("tableName")String tableName,@Param("cfgId")Long id); public int getIsAudit(BaseIpCfg entity); + public int deleteByCompileId(BaseIpCfg entity); } diff --git a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml index 145cdf383..ed3b9c847 100644 --- a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml @@ -583,7 +583,7 @@ editor_id = #{editorId,jdbcType=INTEGER}, - + edit_time = #{editTime,jdbcType=TIMESTAMP}, @@ -639,4 +639,7 @@ SELECT IS_AUDIT FROM ${tableName} WHERE CFG_ID = #{cfgId,jdbcType=BIGINT} + + update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER}, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER} + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.java b/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.java new file mode 100644 index 000000000..0f5fa9c2e --- /dev/null +++ b/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.java @@ -0,0 +1,25 @@ +package com.nis.web.dao.configuration; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.nis.domain.configuration.MultipleSearchCfg; +import com.nis.web.dao.CrudDao; +import com.nis.web.dao.MyBatisDao; + +/** + * 多域配置数据处理类 + * @author dell + * + */ +@MyBatisDao +public interface MultipleCfgDao extends CrudDao{ + public MultipleSearchCfg getById(@Param("tableName")String tableName,@Param("cfgId")Long id) ; + public MultipleSearchCfg get(MultipleSearchCfg entity) ; + public List findList(MultipleSearchCfg entity) ; + public int insert(MultipleSearchCfg entity) ; + public int updateByPrimaryKeySelective(MultipleSearchCfg entity) ; + public int updateValid(MultipleSearchCfg entity) ; + public int audit(MultipleSearchCfg entity) ; +} diff --git a/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.xml new file mode 100644 index 000000000..567b6438e --- /dev/null +++ b/src/main/java/com/nis/web/dao/configuration/MultipleCfgDao.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/configuration/NumCfgDao.java b/src/main/java/com/nis/web/dao/configuration/NumCfgDao.java index 2d79f65b3..c32fee7a0 100644 --- a/src/main/java/com/nis/web/dao/configuration/NumCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/NumCfgDao.java @@ -26,4 +26,5 @@ public interface NumCfgDao extends CrudDao{ public int getIsValid(NumBoundaryCfg entity); public int getIsAudit(@Param("cfgId")Long id); public int getIsAudit(NumBoundaryCfg entity); + public int deleteByCompileId(NumBoundaryCfg entity); } diff --git a/src/main/java/com/nis/web/dao/configuration/NumCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/NumCfgDao.xml index d59d28801..af9902a24 100644 --- a/src/main/java/com/nis/web/dao/configuration/NumCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/NumCfgDao.xml @@ -492,4 +492,7 @@ SELECT IS_AUDIT FROM NUM_BOUNDARY_CFG WHERE CFG_ID = #{cfgId,jdbcType=BIGINT} + + update NUM_BOUNDARY_CFG set is_valid = #{isValid,jdbcType=INTEGER}, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER} + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/configuration/StringCfgDao.java b/src/main/java/com/nis/web/dao/configuration/StringCfgDao.java index 284765c03..489c5914a 100644 --- a/src/main/java/com/nis/web/dao/configuration/StringCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/StringCfgDao.java @@ -26,4 +26,5 @@ public interface StringCfgDao extends CrudDao{ public int getIsValid(BaseStringCfg entity); public int getIsAudit(@Param("tableName")String tableName,@Param("cfgId")Long id); public int getIsAudit(BaseStringCfg entity); + public int deleteByCompileId(BaseStringCfg entity); } diff --git a/src/main/java/com/nis/web/dao/configuration/StringCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/StringCfgDao.xml index a818ea17d..bfe11fdf6 100644 --- a/src/main/java/com/nis/web/dao/configuration/StringCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/StringCfgDao.xml @@ -491,4 +491,7 @@ SELECT IS_AUDIT FROM ${tableName} WHERE CFG_ID = #{cfgId,jdbcType=BIGINT} + + update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER}, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER} + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/BaseService.java b/src/main/java/com/nis/web/service/BaseService.java index 57254769b..a0891b4f3 100644 --- a/src/main/java/com/nis/web/service/BaseService.java +++ b/src/main/java/com/nis/web/service/BaseService.java @@ -143,19 +143,6 @@ public abstract class BaseService { return scopeSql.toString(); } - /** - * - * getTableName(获取Class对应的表名) - * (这里描述这个方法适用条件 – 可选) - * @param clazz - * @return - *String - * @exception - * @since 1.0.0 - */ - public String getTableName(String clazz){ - return Configurations.getStringProperty(clazz, null); - } /** * * getTableName(获取表名对应的Class) diff --git a/src/main/java/com/nis/web/service/CrudService.java b/src/main/java/com/nis/web/service/CrudService.java index 94f4ae68e..9ede322a1 100644 --- a/src/main/java/com/nis/web/service/CrudService.java +++ b/src/main/java/com/nis/web/service/CrudService.java @@ -6,6 +6,7 @@ package com.nis.web.service; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; @@ -20,8 +21,13 @@ 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.NumBoundaryCfg; import com.nis.domain.maat.MaatCfg; import com.nis.domain.maat.ToMaatBean; +import com.nis.domain.maat.ToMaatUnAuditBean; +import com.nis.domain.maat.UnAuditBean; +import com.nis.main.ConvertTool; +import com.nis.util.Constants; import com.nis.web.dao.CrudDao; /** @@ -191,75 +197,132 @@ public abstract class CrudService, T extends BaseEntity> * @param cfg * @return *boolean + * @throws Exception * @exception * @since 1.0.0 */ - public boolean sendToMaatConvertor(AreaIpCfg[] areaCfg,T ... cfg){ + @SuppressWarnings("rawtypes") + public boolean sendToMaatConvertor(int operation,List areaCfg,BaseCfg ... cfg) throws Exception{ if(cfg==null){ throw new RuntimeException("转换出错,配置为空"); } - long compileId=0l; - ToMaatBean toMaatBean=new ToMaatBean(); - MaatCfg maatCfg=new MaatCfg(); - if(cfg[0] instanceof BaseIpCfg){ - maatCfg.setIpCfg((BaseIpCfg[])cfg); - compileId=((BaseIpCfg)cfg[0]).getCompileId(); - }else if(cfg[0] instanceof BaseStringCfg){ - maatCfg.setStrCfg((BaseStringCfg[])cfg); - compileId=((BaseStringCfg)cfg[0]).getCompileId(); - }else if(cfg[0] instanceof ComplexkeywordCfg){ - maatCfg.setComplexStrCfg((ComplexkeywordCfg[])cfg); - compileId=((ComplexkeywordCfg)cfg[0]).getCompileId(); - } - if(areaCfg!=null){ - AreaIpCfg[] cfgArray=new AreaIpCfg[1]; - - } - List serviceCfg=new ArrayList<>(); - serviceCfg.add(maatCfg); - BaseCfg baseCfg=(BaseCfg)cfg[0]; - if(compileId==0l){ - throw new RuntimeException("转换出错,未获取到正确的compileId"); - }else{ - toMaatBean.setCompileId(compileId); - } - if(baseCfg.getAction()==null){ - throw new RuntimeException("转换出错,未获取到正确的action"); - }else{ - toMaatBean.setAction(baseCfg.getAction()); - } - if(baseCfg.getIsAreaEffective()==null){ - throw new RuntimeException("转换出错,未获取到正确的isAreaEffective"); - }else{ - toMaatBean.setIsAreaEffective(baseCfg.getIsAreaEffective()); - } - if(baseCfg.getIsValid()==null){ - throw new RuntimeException("转换出错,未获取到正确的isValid"); - }else{ - toMaatBean.setIsValid(baseCfg.getIsValid()); - } - if(baseCfg.getRequestId()==null){ - throw new RuntimeException("转换出错,未获取到正确的requestId"); - }else{ - toMaatBean.setRequestId(baseCfg.getRequestId()); - } - if(baseCfg.getServiceId()==null){ - throw new RuntimeException("转换出错,未获取到正确的serviceId"); - }else{ - toMaatBean.setServiceId(baseCfg.getServiceId()); - } - toMaatBean.setAreaEffectiveIds(baseCfg.getAreaEffectiveIds()==null?"":baseCfg.getAreaEffectiveIds()); - toMaatBean.setAttribute(baseCfg.getAttribute()==null?"":baseCfg.getAttribute()); - toMaatBean.setClassify(baseCfg.getClassify()==null?"":baseCfg.getClassify()); - toMaatBean.setLable(baseCfg.getLable()==null?"":baseCfg.getLable()); Gson gson=new GsonBuilder().disableHtmlEscaping() .setDateFormat("yyyy-MM-dd HH:mm:ss") /*.setPrettyPrinting().serializeNulls()*/ .excludeFieldsWithoutExposeAnnotation() .create(); - String json=gson.toJson(toMaatBean); - //发送至maat,待完成 - - return false; + if(Constants.AUDIT_NOT_YES==operation){ + ToMaatUnAuditBean toMaatUnAuditBean=new ToMaatUnAuditBean(); + toMaatUnAuditBean.setServiceCfg(new ArrayList()); + for(BaseCfg c:cfg){ + UnAuditBean bean=new UnAuditBean(); + if(c.getCompileId()==null||c.getCompileId()==0){ + throw new RuntimeException("转换出错,未获取到正确的compileId"); + } + if(StringUtils.isBlank(c.getMaatTable())){ + throw new RuntimeException("转换出错,未获取到正确的maatTalbe"); + } + bean.setCompileId(c.getCompileId()); + bean.setMaatTable(c.getMaatTable()); + } + String json=gson.toJson(toMaatUnAuditBean); + logger.info("to maat json:"+json); + //发送至maat,待完成 + return new ConvertTool().setConfigInValid(json); + }else{ + int compileId=0; + ToMaatBean toMaatBean=new ToMaatBean(); + toMaatBean.setServiceCfg(new ArrayList>()); + MaatCfg maatCfg=new MaatCfg(); + for(BaseCfg c:cfg){ + if(c instanceof BaseIpCfg){ + compileId=compileId==0?c.getCompileId():compileId; + if(maatCfg.getIpCfg()==null){ + List list=new ArrayList<>(); + list.add((BaseIpCfg)c); + maatCfg.setIpCfg(list); + }else{ + List list=maatCfg.getIpCfg(); + list.add((BaseIpCfg)c); + } + }else if(c instanceof BaseStringCfg){ + compileId=compileId==0?c.getCompileId():compileId; + if(maatCfg.getStrCfg()==null){ + List list=new ArrayList(); + list.add((BaseStringCfg)c); + maatCfg.setStrCfg(list); + }else{ + List list=maatCfg.getStrCfg(); + list.add((BaseStringCfg)c); + } + }else if(c instanceof ComplexkeywordCfg){ + compileId=compileId==0?c.getCompileId():compileId; + if(maatCfg.getComplexStrCfg()==null){ + List list=new ArrayList(); + list.add((ComplexkeywordCfg)c); + maatCfg.setComplexStrCfg(list); + }else{ + List list=maatCfg.getComplexStrCfg(); + list.add((ComplexkeywordCfg)c); + } + }else if(c instanceof NumBoundaryCfg){ + compileId=compileId==0?c.getCompileId():compileId; + if(maatCfg.getNumCfg()==null){ + List list=new ArrayList(); + list.add((NumBoundaryCfg)c); + maatCfg.setNumCfg(list); + }else{ + List list=maatCfg.getNumCfg(); + list.add((NumBoundaryCfg)c); + } + } + } + if(areaCfg!=null){ + toMaatBean.setAreaCfg(areaCfg); + } + List serviceCfg=new ArrayList<>(); + serviceCfg.add(maatCfg); + toMaatBean.getServiceCfg().add(serviceCfg); + BaseCfg baseCfg=(BaseCfg)cfg[0]; + if(compileId==0){ + throw new RuntimeException("转换出错,未获取到正确的compileId"); + }else{ + toMaatBean.setCompileId(compileId); + } + if(baseCfg.getAction()==null){ + throw new RuntimeException("转换出错,未获取到正确的action"); + }else{ + toMaatBean.setAction(baseCfg.getAction()); + } + if(baseCfg.getIsAreaEffective()==null){ + throw new RuntimeException("转换出错,未获取到正确的isAreaEffective"); + }else{ + toMaatBean.setIsAreaEffective(baseCfg.getIsAreaEffective()); + } + if(baseCfg.getIsValid()==null){ + throw new RuntimeException("转换出错,未获取到正确的isValid"); + }else{ + toMaatBean.setIsValid(baseCfg.getIsValid()); + } + if(baseCfg.getRequestId()==null){ + throw new RuntimeException("转换出错,未获取到正确的requestId"); + }else{ + toMaatBean.setRequestId(baseCfg.getRequestId()); + } + if(baseCfg.getServiceId()==null){ + throw new RuntimeException("转换出错,未获取到正确的serviceId"); + }else{ + toMaatBean.setServiceId(baseCfg.getServiceId()); + } + toMaatBean.setAreaEffectiveIds(baseCfg.getAreaEffectiveIds()==null?"":baseCfg.getAreaEffectiveIds()); + toMaatBean.setAttribute(baseCfg.getAttribute()==null?"":baseCfg.getAttribute()); + toMaatBean.setClassify(baseCfg.getClassify()==null?"":baseCfg.getClassify()); + toMaatBean.setLable(baseCfg.getLable()==null?"":baseCfg.getLable()); + + String json=gson.toJson(toMaatBean); + logger.info("to maat json:"+json); + //发送至maat,待完成 + return new ConvertTool().saveConfig(json); + } } } diff --git a/src/main/java/com/nis/web/service/configuration/ComplexStringCfgService.java b/src/main/java/com/nis/web/service/configuration/ComplexStringCfgService.java index 586292213..4c0e2c6fb 100644 --- a/src/main/java/com/nis/web/service/configuration/ComplexStringCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/ComplexStringCfgService.java @@ -1,11 +1,11 @@ package com.nis.web.service.configuration; -import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.nis.domain.configuration.ComplexkeywordCfg; +import com.nis.util.Constants; import com.nis.web.dao.configuration.ComplexStringCfgDao; import com.nis.web.service.CrudService; @@ -30,17 +30,7 @@ public class ComplexStringCfgService extends CrudService clazz,long id){ - String tableName=getTableName(clazz.getSimpleName()); - if(StringUtils.isBlank(tableName)) - return null; - logger.info("get "+tableName); - return complexStringCfgDao.getById(tableName, id); - } /** * * getStringCfg(根据IP与类名获取IP配置) @@ -144,44 +95,16 @@ public class ComplexStringCfgService extends CrudService { */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int addIpCfg(BaseIpCfg baseIpCfg){ - if(!StringUtils.isBlank(baseIpCfg.getTableName())){ - return ipCfgDao.insert(baseIpCfg); - }else{ - String tableName=getTableName(baseIpCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return 0; - baseIpCfg.setTableName(tableName); - logger.info("save "+tableName); - return ipCfgDao.insert(baseIpCfg); - } - + return ipCfgDao.insert(baseIpCfg); } /** * @@ -55,17 +44,7 @@ public class IpCfgService extends CrudService { */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int updateIpCfg(BaseIpCfg baseIpCfg){ - if(!StringUtils.isBlank(baseIpCfg.getTableName())){ - return ipCfgDao.updateByPrimaryKeySelective(baseIpCfg); - }else{ - String tableName=getTableName(baseIpCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return 0; - baseIpCfg.setTableName(tableName); - logger.info("update "+tableName); - return ipCfgDao.updateByPrimaryKeySelective(baseIpCfg); - } - + return ipCfgDao.updateByPrimaryKeySelective(baseIpCfg); } /** * @@ -74,22 +53,22 @@ public class IpCfgService extends CrudService { * @param baseIpCfg * @return *int + * @throws Exception * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int auditIpCfg(BaseIpCfg baseIpCfg){ - if(!StringUtils.isBlank(baseIpCfg.getTableName())){ - return ipCfgDao.audit(baseIpCfg); + public int auditIpCfg(BaseIpCfg sendCfg,BaseIpCfg baseIpCfg) throws Exception{ + if(Constants.AUDIT_NOT_YES==baseIpCfg.getIsAudit().intValue()|| + Constants.AUDIT_YES==baseIpCfg.getIsAudit().intValue()){//审核通过,取消审核通过需要发到maat + if(sendToMaatConvertor(baseIpCfg.getIsAudit(),null,sendCfg)){ + return ipCfgDao.audit(baseIpCfg); + } }else{ - String tableName=getTableName(baseIpCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return 0; - baseIpCfg.setTableName(tableName); - logger.info("aduit "+tableName); return ipCfgDao.audit(baseIpCfg); } + return 0; } /** * @@ -103,36 +82,8 @@ public class IpCfgService extends CrudService { */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int deleteIpCfg(BaseIpCfg baseIpCfg){ - if(!StringUtils.isBlank(baseIpCfg.getTableName())){ - return ipCfgDao.updateValid(baseIpCfg); - }else{ - String tableName=getTableName(baseIpCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return 0; - baseIpCfg.setTableName(tableName); - logger.info("delete "+tableName); - return ipCfgDao.updateValid(baseIpCfg); - } - + return ipCfgDao.updateValid(baseIpCfg); } - /** - * - * getIpCfg(根据IP与类名获取IP配置) - * (继承BaseIpCfg这个类方可使用) - * @param clazz - * @param id - * @return - *BaseIpCfg - * @exception - * @since 1.0.0 - */ - public BaseIpCfg getIpCfgById(Class clazz,long id){ - String tableName=getTableName(clazz.getSimpleName()); - if(StringUtils.isBlank(tableName)) - return null; - logger.info("get "+tableName); - return ipCfgDao.getById(tableName, id); - } /** * * getIpCfg(根据IP与类名获取IP配置) @@ -145,44 +96,16 @@ public class IpCfgService extends CrudService { * @since 1.0.0 */ public BaseIpCfg getIpCfgById(BaseIpCfg baseIpCfg){ - if(!StringUtils.isBlank(baseIpCfg.getTableName())){ - return ipCfgDao.get(baseIpCfg); - }else{ - String tableName=getTableName(baseIpCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return null; - baseIpCfg.setTableName(tableName); - logger.info("get "+tableName); - return ipCfgDao.get(baseIpCfg); - } - + return ipCfgDao.getById(baseIpCfg.getTableName(), baseIpCfg.getCfgId()); } public Integer getIsValid(BaseIpCfg baseIpCfg){ - if(!StringUtils.isBlank(baseIpCfg.getTableName())){ - return ipCfgDao.getIsValid(baseIpCfg); - }else{ - String tableName=getTableName(baseIpCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return null; - baseIpCfg.setTableName(tableName); - return ipCfgDao.getIsValid(baseIpCfg); - } - + return ipCfgDao.getIsValid(baseIpCfg); } public Integer getIsValid(String tableName, long id){ return ipCfgDao.getIsValid(tableName,id); } public Integer getIsAudit(BaseIpCfg baseIpCfg){ - if(!StringUtils.isBlank(baseIpCfg.getTableName())){ - return ipCfgDao.getIsAudit(baseIpCfg); - }else{ - String tableName=getTableName(baseIpCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return null; - baseIpCfg.setTableName(tableName); - return ipCfgDao.getIsAudit(baseIpCfg); - } - + return ipCfgDao.getIsAudit(baseIpCfg); } public Integer getIsAudit(String tableName, long id){ return ipCfgDao.getIsAudit(tableName,id); diff --git a/src/main/java/com/nis/web/service/configuration/MultipleCfgService.java b/src/main/java/com/nis/web/service/configuration/MultipleCfgService.java new file mode 100644 index 000000000..4780c3806 --- /dev/null +++ b/src/main/java/com/nis/web/service/configuration/MultipleCfgService.java @@ -0,0 +1,168 @@ +package com.nis.web.service.configuration; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.nis.domain.Page; +import com.nis.domain.configuration.BaseIpCfg; +import com.nis.domain.configuration.BaseStringCfg; +import com.nis.domain.configuration.ComplexkeywordCfg; +import com.nis.domain.configuration.MultipleCfg; +import com.nis.domain.configuration.MultipleSearchCfg; +import com.nis.domain.configuration.NumBoundaryCfg; +import com.nis.web.dao.configuration.ComplexStringCfgDao; +import com.nis.web.dao.configuration.IpCfgDao; +import com.nis.web.dao.configuration.MultipleCfgDao; +import com.nis.web.dao.configuration.NumCfgDao; +import com.nis.web.dao.configuration.StringCfgDao; +import com.nis.web.service.CrudService; + +/** + * 多域相关配置事务类 + * @author dell + * + */ +@Service +public class MultipleCfgService extends CrudService { + @Autowired + protected MultipleCfgDao multipleCfgDao; + @Autowired + protected IpCfgDao ipCfgDao; + @Autowired + protected StringCfgDao stringCfgDao; + @Autowired + protected ComplexStringCfgDao complexStringCfgDao; + @Autowired + protected NumCfgDao numCfgDao; + /** + * + * addStringCfg(新增IP类配置) + * (继承ComplexkeywordCfg这个类方可使用) + * @param cfg + * @return + *int + * @exception + * @since 1.0.0 + */ + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public int addCfg(MultipleCfg cfg){ + if(cfg==null) return 0; + if(cfg.getIpCfg()!=null){ + for(BaseIpCfg _cfg:cfg.getIpCfg().values()){ + ipCfgDao.insert(_cfg); + } + } + if(cfg.getStringCfg()!=null){ + for(BaseStringCfg _cfg:cfg.getStringCfg().values()){ + stringCfgDao.insert(_cfg); + } + } + if(cfg.getNumCfg()!=null){ + for(NumBoundaryCfg _cfg:cfg.getNumCfg().values()){ + numCfgDao.insert(_cfg); + } + } + if(cfg.getComplexCfg()!=null){ + for(ComplexkeywordCfg _cfg:cfg.getComplexCfg().values()){ + complexStringCfgDao.insert(_cfg); + } + } + return 1; + } + + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public int updateCfg(MultipleCfg cfg){ + if(cfg==null) return 0; + if(cfg.getIpCfg()!=null){ + for(BaseIpCfg _cfg:cfg.getIpCfg().values()){ + ipCfgDao.updateByPrimaryKeySelective(_cfg); + } + } + if(cfg.getStringCfg()!=null){ + for(BaseStringCfg _cfg:cfg.getStringCfg().values()){ + stringCfgDao.updateByPrimaryKeySelective(_cfg); + } + } + if(cfg.getNumCfg()!=null){ + for(NumBoundaryCfg _cfg:cfg.getNumCfg().values()){ + numCfgDao.updateByPrimaryKeySelective(_cfg); + } + } + if(cfg.getComplexCfg()!=null){ + for(ComplexkeywordCfg _cfg:cfg.getComplexCfg().values()){ + complexStringCfgDao.updateByPrimaryKeySelective(_cfg); + } + } + return 1; + } + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public int deleteCfg(MultipleCfg cfg){ + if(cfg==null) return 0; + if(cfg.getIpCfg()!=null){ + for(BaseIpCfg _cfg:cfg.getIpCfg().values()){ + ipCfgDao.deleteByCompileId(_cfg); + } + } + if(cfg.getStringCfg()!=null){ + for(BaseStringCfg _cfg:cfg.getStringCfg().values()){ + stringCfgDao.deleteByCompileId(_cfg); + } + } + if(cfg.getNumCfg()!=null){ + for(NumBoundaryCfg _cfg:cfg.getNumCfg().values()){ + numCfgDao.deleteByCompileId(_cfg); + } + } + if(cfg.getComplexCfg()!=null){ + for(ComplexkeywordCfg _cfg:cfg.getComplexCfg().values()){ + complexStringCfgDao.deleteByCompileId(_cfg); + } + } + return 1; + } + /** + * + * auditCfg(这里用一句话描述这个方法的作用) + * (这里描述这个方法适用条件 – 可选) + * @param cfg + * @return + *int + * @exception + * @since 1.0.0 + */ + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public int auditCfg(MultipleCfg cfg){ + if(cfg==null) return 0; + if(cfg.getIpCfg()!=null){ + for(BaseIpCfg _cfg:cfg.getIpCfg().values()){ + ipCfgDao.audit(_cfg); + } + } + if(cfg.getStringCfg()!=null){ + for(BaseStringCfg _cfg:cfg.getStringCfg().values()){ + stringCfgDao.audit(_cfg); + } + } + if(cfg.getNumCfg()!=null){ + for(NumBoundaryCfg _cfg:cfg.getNumCfg().values()){ + numCfgDao.audit(_cfg); + } + } + if(cfg.getComplexCfg()!=null){ + for(ComplexkeywordCfg _cfg:cfg.getComplexCfg().values()){ + complexStringCfgDao.audit(_cfg); + } + } + return 1; + } + + /** + * 由于mysql不支持full join,并且考虑mysql的性能问题,这里分别从各个基础表里查询数据再拼接 + */ + @Override + public Page findPage(Page page, MultipleSearchCfg entity) { + return super.findPage(page, entity); + } + +} diff --git a/src/main/java/com/nis/web/service/configuration/NumCfgService.java b/src/main/java/com/nis/web/service/configuration/NumCfgService.java index fbbffc5ca..8afd73a03 100644 --- a/src/main/java/com/nis/web/service/configuration/NumCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/NumCfgService.java @@ -5,6 +5,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.nis.domain.configuration.NumBoundaryCfg; +import com.nis.util.Constants; import com.nis.web.dao.configuration.NumCfgDao; import com.nis.web.service.CrudService; @@ -52,12 +53,21 @@ public class NumCfgService extends CrudService { * @param cfg * @return *int + * @throws Exception * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int auditNumCfg(NumBoundaryCfg cfg){ - return numCfgDao.audit(cfg); + public int auditNumCfg(NumBoundaryCfg sendCfg,NumBoundaryCfg cfg) throws Exception{ + if(Constants.AUDIT_NOT_YES==cfg.getIsAudit().intValue()|| + Constants.AUDIT_YES==cfg.getIsAudit().intValue()){//审核通过,取消审核通过需要发到maat + if(sendToMaatConvertor(cfg.getIsAudit(),null,sendCfg)){ + return numCfgDao.audit(cfg); + } + }else{ + return numCfgDao.audit(cfg); + } + return 0; } /** * @@ -99,7 +109,7 @@ public class NumCfgService extends CrudService { * @since 1.0.0 */ public NumBoundaryCfg getNumCfgById(NumBoundaryCfg cfg){ - return numCfgDao.get(cfg); + return numCfgDao.getById(cfg.getCfgId()); } public Integer getIsValid(NumBoundaryCfg cfg){ return numCfgDao.getIsValid(cfg); diff --git a/src/main/java/com/nis/web/service/configuration/StringCfgService.java b/src/main/java/com/nis/web/service/configuration/StringCfgService.java index 84b1470d1..2ad024846 100644 --- a/src/main/java/com/nis/web/service/configuration/StringCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/StringCfgService.java @@ -1,12 +1,11 @@ package com.nis.web.service.configuration; -import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.nis.domain.configuration.BaseStringCfg; +import com.nis.util.Constants; import com.nis.web.dao.configuration.StringCfgDao; import com.nis.web.service.CrudService; @@ -31,17 +30,7 @@ public class StringCfgService extends CrudService { */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int addStringCfg(BaseStringCfg baseStringCfg){ - if(!StringUtils.isBlank(baseStringCfg.getTableName())){ - return stringCfgDao.insert(baseStringCfg); - }else{ - String tableName=getTableName(baseStringCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return 0; - baseStringCfg.setTableName(tableName); - logger.info("save "+tableName); - return stringCfgDao.insert(baseStringCfg); - } - + return stringCfgDao.insert(baseStringCfg); } /** * @@ -55,17 +44,7 @@ public class StringCfgService extends CrudService { */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int updateStringCfg(BaseStringCfg baseStringCfg){ - if(!StringUtils.isBlank(baseStringCfg.getTableName())){ - return stringCfgDao.updateByPrimaryKeySelective(baseStringCfg); - }else{ - String tableName=getTableName(baseStringCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return 0; - baseStringCfg.setTableName(tableName); - logger.info("update "+tableName); - return stringCfgDao.updateByPrimaryKeySelective(baseStringCfg); - } - + return stringCfgDao.updateByPrimaryKeySelective(baseStringCfg); } /** * @@ -74,22 +53,21 @@ public class StringCfgService extends CrudService { * @param baseStringCfg * @return *int + * @throws Exception * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int auditStringCfg(BaseStringCfg baseStringCfg){ - if(!StringUtils.isBlank(baseStringCfg.getTableName())){ - return stringCfgDao.audit(baseStringCfg); + public int auditStringCfg(BaseStringCfg sendCfg,BaseStringCfg baseStringCfg) throws Exception{ + if(Constants.AUDIT_NOT_YES==baseStringCfg.getIsAudit().intValue()|| + Constants.AUDIT_YES==baseStringCfg.getIsAudit().intValue()){//审核通过,取消审核通过需要发到maat + if(sendToMaatConvertor(baseStringCfg.getIsAudit(),null,sendCfg)){ + return stringCfgDao.audit(baseStringCfg); + } }else{ - String tableName=getTableName(baseStringCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return 0; - baseStringCfg.setTableName(tableName); - logger.info("aduit "+tableName); return stringCfgDao.audit(baseStringCfg); } - + return 0; } /** * @@ -103,36 +81,8 @@ public class StringCfgService extends CrudService { */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int deleteStringCfg(BaseStringCfg baseStringCfg){ - if(!StringUtils.isBlank(baseStringCfg.getTableName())){ - return stringCfgDao.updateValid(baseStringCfg); - }else{ - String tableName=getTableName(baseStringCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return 0; - baseStringCfg.setTableName(tableName); - logger.info("delete "+tableName); - return stringCfgDao.updateValid(baseStringCfg); - } - + return stringCfgDao.updateValid(baseStringCfg); } - /** - * - * getStringCfg(根据IP与类名获取IP配置) - * (继承BaseStringCfg这个类方可使用) - * @param clazz - * @param id - * @return - *BaseStringCfg - * @exception - * @since 1.0.0 - */ - public BaseStringCfg getStringCfgById(Class clazz,long id){ - String tableName=getTableName(clazz.getSimpleName()); - if(StringUtils.isBlank(tableName)) - return null; - logger.info("get "+tableName); - return stringCfgDao.getById(tableName, id); - } /** * * getStringCfg(根据IP与类名获取IP配置) @@ -145,44 +95,16 @@ public class StringCfgService extends CrudService { * @since 1.0.0 */ public BaseStringCfg getStringCfgById(BaseStringCfg baseStringCfg){ - if(!StringUtils.isBlank(baseStringCfg.getTableName())){ - return stringCfgDao.get(baseStringCfg); - }else{ - String tableName=getTableName(baseStringCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return null; - baseStringCfg.setTableName(tableName); - logger.info("get "+tableName); - return stringCfgDao.get(baseStringCfg); - } - + return stringCfgDao.getById(baseStringCfg.getTableName(), baseStringCfg.getCfgId()); } public Integer getIsValid(BaseStringCfg baseStringCfg){ - if(!StringUtils.isBlank(baseStringCfg.getTableName())){ - return stringCfgDao.getIsValid(baseStringCfg); - }else{ - String tableName=getTableName(baseStringCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return null; - baseStringCfg.setTableName(tableName); - return stringCfgDao.getIsValid(baseStringCfg); - } - + return stringCfgDao.getIsValid(baseStringCfg); } public Integer getIsValid(String tableName, long id){ return stringCfgDao.getIsValid(tableName,id); } public Integer getIsAudit(BaseStringCfg baseStringCfg){ - if(!StringUtils.isBlank(baseStringCfg.getTableName())){ - return stringCfgDao.getIsAudit(baseStringCfg); - }else{ - String tableName=getTableName(baseStringCfg.getClass().getSimpleName()); - if(StringUtils.isBlank(tableName)) - return null; - baseStringCfg.setTableName(tableName); - return stringCfgDao.getIsAudit(baseStringCfg); - } - + return stringCfgDao.getIsAudit(baseStringCfg); } public Integer getIsAudit(String tableName, long id){ return stringCfgDao.getIsAudit(tableName,id); diff --git a/src/main/webapp/WEB-INF/views/cfg/resultPage.jsp b/src/main/webapp/WEB-INF/views/cfg/resultPage.jsp index 500ac8ac0..b70d5f596 100644 --- a/src/main/webapp/WEB-INF/views/cfg/resultPage.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/resultPage.jsp @@ -5,7 +5,7 @@ 结果跳转页