diff --git a/src/main/java/com/nis/domain/basics/CommonGroupInfo.java b/src/main/java/com/nis/domain/basics/CommonGroupInfo.java new file mode 100644 index 000000000..f4dc3d72d --- /dev/null +++ b/src/main/java/com/nis/domain/basics/CommonGroupInfo.java @@ -0,0 +1,74 @@ +package com.nis.domain.basics; + +import java.io.Serializable; +import java.util.Date; + +import com.nis.domain.configuration.BaseCfg; +import com.nis.util.excel.ExcelField; + +/** + * 公共分组实体 + */ +public class CommonGroupInfo extends BaseCfg implements Serializable{ + /** + * + */ + private static final long serialVersionUID = 7931466570918016654L; + + private Integer groupId; + + @ExcelField(title="group_name",sort=1) + private String groupName; + + @ExcelField(title="group_type",dictType="GROUP_TYPE",sort=2) + private Integer groupType; + + private Integer serviceGroupId; + + @ExcelField(title="desc",sort=4) + private String description; + + public Integer getServiceGroupId() { + return serviceGroupId; + } + public void setServiceGroupId(Integer serviceGroupId) { + this.serviceGroupId = serviceGroupId; + } + public Integer getGroupId() { + return groupId; + } + public void setGroupId(Integer groupId) { + this.groupId = groupId; + } + public String getGroupName() { + return groupName; + } + public void setGroupName(String groupName) { + this.groupName = groupName; + } + public Date getCreateTime() { + return createTime; + } + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + public Date getEditTime() { + return editTime; + } + public void setEditTime(Date editTime) { + this.editTime = editTime; + } + public Integer getGroupType() { + return groupType; + } + public void setGroupType(Integer groupType) { + this.groupType = groupType; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/src/main/java/com/nis/domain/basics/IpCommCfg.java b/src/main/java/com/nis/domain/basics/IpCommCfg.java new file mode 100644 index 000000000..5ef21dceb --- /dev/null +++ b/src/main/java/com/nis/domain/basics/IpCommCfg.java @@ -0,0 +1,315 @@ +package com.nis.domain.basics; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import com.nis.domain.configuration.BaseCfg; +import com.nis.util.excel.ExcelField; + +public class IpCommCfg extends BaseCfg { + + + /** + * + */ + private static final long serialVersionUID = 4218856118489784060L; + + /** + * 创建一个新的实例 BaseIpCfg. + * + */ + public IpCommCfg() { + super(); + // TODO Auto-generated constructor stub + } + private String indexTable="ip_comm_cfg"; + /** + * ip类型 + */ + @Expose + @SerializedName("ipType") + @ExcelField(title="ip_type",dictType="IP_TYPE",sort=50) + protected Integer ipType; + @ExcelField(title="src_ip_pattern",dictType="IP_PATTERN",sort=51) + protected Integer srcIpPattern; + @ExcelField(title="client_ip",sort=52) + protected String srcIpAddress; + @ExcelField(title="dest_ip_pattern",dictType="IP_PATTERN",sort=53) + protected Integer destIpPattern; + @ExcelField(title="server_ip",sort=54) + protected String destIpAddress; + @ExcelField(title="src_port_pattern",dictType="PORT_PATTERN",sort=54) + protected Integer srcPortPattern; + @ExcelField(title="dest_port_pattern",dictType="PORT_PATTERN",sort=54) + protected Integer destPortPattern; + @ExcelField(title="client_port",sort=55) + protected String srcPort; + @ExcelField(title="server_port",sort=56) + protected String destPort; + protected Integer dnsStrategyId; + @ExcelField(title="ir_type",dictType="IR_TYPE",sort=57) + protected Integer irType; + @ExcelField(title="group_name",sort=58) + protected String groupName; + // @ExcelField(title="log_total",sort=42) + private Long totalLogs; + private Integer regionId; + private Integer groupId; + + public Integer getRegionId() { + return regionId; + } + public void setRegionId(Integer regionId) { + this.regionId = regionId; + } + public Integer getGroupId() { + return groupId; + } + public void setGroupId(Integer groupId) { + this.groupId = groupId; + } + public Long getTotalLogs() { + return totalLogs; + } + public void setTotalLogs(Long totalLogs) { + this.totalLogs = totalLogs; + } + /** + * irType + * @return irType + */ + + public Integer getIrType() { + return irType; + } + /** + * @param irType the irType to set + */ + public void setIrType(Integer irType) { + this.irType = irType; + } + /** + * groupName + * @return groupName + */ + + public String getGroupName() { + return groupName; + } + /** + * @param groupName the groupName to set + */ + public void setGroupName(String groupName) { + this.groupName = groupName; + } + /** + * 方向 + */ + @Expose + @SerializedName("direction") + @ExcelField(title="direction",dictType="DIRECTION",sort=58) + protected Integer direction ; + /** + * 协议 + */ + @Expose + @SerializedName("protocol") + @ExcelField(title="protocol",dictType="PROTOCOL",sort=59) + protected Integer protocol ; + /** + * 协议ID + */ + @Expose + @SerializedName("protocolId") + protected Integer protocolId ; + /** + * 限速比例 + */ + protected String ratelimit ; + + /** + * ratelimit + * @return ratelimit + */ + + public String getRatelimit() { + return ratelimit; + } + /** + * @param ratelimit the ratelimit to set + */ + public void setRatelimit(String ratelimit) { + this.ratelimit = ratelimit; + } + /** + * ipType + * @return ipType + */ + + public Integer getIpType() { + return ipType; + } + /** + * @param ipType the ipType to set + */ + public void setIpType(Integer ipType) { + this.ipType = ipType; + } + + /** + * direction + * @return direction + */ + + public Integer getDirection() { + return direction; + } + /** + * @param direction the direction to set + */ + public void setDirection(Integer direction) { + this.direction = direction; + } + /** + * protocol + * @return protocol + */ + + public Integer getProtocol() { + return protocol; + } + /** + * @param protocol the protocol to set + */ + public void setProtocol(Integer protocol) { + this.protocol = protocol; + } + /** + * protocolId + * @return protocolId + */ + + public Integer getProtocolId() { + return protocolId; + } + /** + * @param protocolId the protocolId to set + */ + public void setProtocolId(Integer protocolId) { + this.protocolId = protocolId; + } + + + public Integer getSrcIpPattern() { + return srcIpPattern; + } + public void setSrcIpPattern(Integer srcIpPattern) { + this.srcIpPattern = srcIpPattern; + } + public Integer getDestIpPattern() { + return destIpPattern; + } + public void setDestIpPattern(Integer destIpPattern) { + this.destIpPattern = destIpPattern; + } + public Integer getSrcPortPattern() { + return srcPortPattern; + } + public void setSrcPortPattern(Integer srcPortPattern) { + this.srcPortPattern = srcPortPattern; + } + public Integer getDestPortPattern() { + return destPortPattern; + } + public void setDestPortPattern(Integer destPortPattern) { + this.destPortPattern = destPortPattern; + } + /** + * srcIpAddress + * @return srcIpAddress + */ + + public String getSrcIpAddress() { + return srcIpAddress; + } + /** + * @param srcIpAddress the srcIpAddress to set + */ + public void setSrcIpAddress(String srcIpAddress) { + this.srcIpAddress = srcIpAddress; + } + /** + * destIpAddress + * @return destIpAddress + */ + + public String getDestIpAddress() { + return destIpAddress; + } + /** + * @param destIpAddress the destIpAddress to set + */ + public void setDestIpAddress(String destIpAddress) { + this.destIpAddress = destIpAddress; + } + /** + * srcPort + * @return srcPort + */ + + public String getSrcPort() { + return srcPort; + } + /** + * @param srcPort the srcPort to set + */ + public void setSrcPort(String srcPort) { + this.srcPort = srcPort; + } + /** + * destPort + * @return destPort + */ + + public String getDestPort() { + return destPort; + } + /** + * @param destPort the destPort to set + */ + public void setDestPort(String destPort) { + this.destPort = destPort; + } + + /** + * dnsStrategyId + * @return dnsStrategyId + */ + + public Integer getDnsStrategyId() { + return dnsStrategyId; + } + /** + * @param dnsStrategyId the dnsStrategyId to set + */ + public void setDnsStrategyId(Integer dnsStrategyId) { + this.dnsStrategyId = dnsStrategyId; + } + @Override + public void initDefaultValue(){ + super.initDefaultValue(); + this.direction = 0; + } + + public String getIndexTable() { + return indexTable; + } + public void setIndexTable(String indexTable) { + this.indexTable = indexTable; + } + public Integer getIndex() { + return index; + } + public void setIndex(Integer index) { + this.index = index; + } +} \ No newline at end of file diff --git a/src/main/java/com/nis/domain/configuration/BaseCfg.java b/src/main/java/com/nis/domain/configuration/BaseCfg.java index d9faba9cf..438ec6778 100644 --- a/src/main/java/com/nis/domain/configuration/BaseCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseCfg.java @@ -78,6 +78,14 @@ public class BaseCfg extends BaseEntity implements Cloneable{ protected ScheduleCfg schedule; private String commonGroupIds; //公共组织id(考虑一个compile存在多个asn组织的情况) + protected Integer groupType; //url组以及dns组相关功能使用 + protected Integer udFlag; //url组以及dns组相关功能使用 过滤数据库数据标记 + public Integer getGroupType() { + return groupType; + } + public void setGroupType(Integer groupType) { + this.groupType = groupType; + } public String getCommonGroupIds() { return commonGroupIds; } @@ -85,8 +93,12 @@ public class BaseCfg extends BaseEntity implements Cloneable{ public void setCommonGroupIds(String commonGroupIds) { this.commonGroupIds = commonGroupIds; } - - + public Integer getUdFlag() { + return udFlag; + } + public void setUdFlag(Integer udFlag) { + this.udFlag = udFlag; + } public String getExType() { return exType; diff --git a/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java b/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java index 78f45ea8d..f2b0e701e 100644 --- a/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java +++ b/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java @@ -14,7 +14,9 @@ import java.util.Map; import com.google.gson.annotations.Expose; import com.nis.domain.basics.AsnGroupInfo; import com.nis.domain.basics.AsnIpCfg; +import com.nis.domain.basics.IpCommCfg; import com.nis.domain.basics.IpReuseIpCfg; +import com.nis.domain.basics.UrlCommCfg; import com.nis.util.Constants; import com.nis.util.excel.ExcelField; @@ -88,8 +90,8 @@ public class CfgIndexInfo extends BaseCfg { private List asnKeywords; @ExcelField(title="log_total",sort=42) private Long totalLogs; - - + private List urlCommGroupList; + private List ipCommGroupCfgList; /*private CachePolicyUserRegion cachePolicyUserRegion;//缓存策略用户自定义域参数 public static class CachePolicyUserRegion{ @@ -101,6 +103,12 @@ public class CfgIndexInfo extends BaseCfg { public String getOrganization() { return organization; } + public List getIpCommGroupCfgList() { + return ipCommGroupCfgList; + } + public void setIpCommGroupCfgList(List ipCommGroupCfgList) { + this.ipCommGroupCfgList = ipCommGroupCfgList; + } public List getAsnKeywords() { return asnKeywords; } @@ -411,4 +419,11 @@ public class CfgIndexInfo extends BaseCfg { public void setTotalLogs(Long totalLogs) { this.totalLogs = totalLogs; } + public List getUrlCommGroupList() { + return urlCommGroupList; + } + public void setUrlCommGroupList(List urlCommGroupList) { + this.urlCommGroupList = urlCommGroupList; + } + } diff --git a/src/main/java/com/nis/domain/configuration/template/IpCommCfgTemplate.java b/src/main/java/com/nis/domain/configuration/template/IpCommCfgTemplate.java new file mode 100644 index 000000000..35296ca4e --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/template/IpCommCfgTemplate.java @@ -0,0 +1,47 @@ +package com.nis.domain.configuration.template; + +import com.nis.util.excel.ExcelField; + +public class IpCommCfgTemplate extends IpAllTemplate{ + @ExcelField(title="ip_group",align=2,sort=10) + private Integer groupId; + + public Integer getGroupId() { + return groupId; + } + + public void setGroupId(Integer groupId) { + this.groupId = groupId; + } + + /* @Override + public String getSrcIpAddress() { + // TODO Auto-generated method stub + return super.getSrcIpAddress(); + } + + @Override + public String getSrcPort() { + // TODO Auto-generated method stub + return super.getSrcPort(); + } + + @Override + public String getDestPort() { + // TODO Auto-generated method stub + return super.getDestPort(); + } + + @Override + public Integer getProtocol() { + // TODO Auto-generated method stub + return super.getProtocol(); + } + + @Override + public Integer getDirection() { + // TODO Auto-generated method stub + return super.getDirection(); + }*/ + +} \ No newline at end of file diff --git a/src/main/java/com/nis/web/controller/BaseController.java b/src/main/java/com/nis/web/controller/BaseController.java index b15431683..ae44e75d4 100644 --- a/src/main/java/com/nis/web/controller/BaseController.java +++ b/src/main/java/com/nis/web/controller/BaseController.java @@ -162,6 +162,7 @@ import com.nis.web.service.SystemService; import com.nis.web.service.UserService; import com.nis.web.service.basics.AsnGroupInfoService; import com.nis.web.service.basics.AsnIpCfgService; +import com.nis.web.service.basics.CommonGroupManageService; import com.nis.web.service.basics.InnerProtectionListService; import com.nis.web.service.basics.IpReuseIpCfgService; import com.nis.web.service.basics.PolicyGroupInfoService; @@ -358,6 +359,9 @@ public class BaseController { @Autowired protected ManipulatPolicyService manipulatPolicyService; + @Autowired + protected CommonGroupManageService commonGroupManageService; + /** * 管理基础路径 */ diff --git a/src/main/java/com/nis/web/controller/basics/CommonGroupManageController.java b/src/main/java/com/nis/web/controller/basics/CommonGroupManageController.java new file mode 100644 index 000000000..ea66d9a20 --- /dev/null +++ b/src/main/java/com/nis/web/controller/basics/CommonGroupManageController.java @@ -0,0 +1,159 @@ +package com.nis.web.controller.basics; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.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 org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.nis.domain.Page; +import com.nis.domain.basics.CommonGroupInfo; +import com.nis.domain.basics.PolicyGroupInfo; +import com.nis.util.Constants; +import com.nis.util.LogUtils; +import com.nis.util.StringUtil; +import com.nis.web.controller.BaseController; +import com.nis.web.service.basics.CommonGroupManageService; +/** + * 公共组管理 + */ +@Controller +@RequestMapping(value = "${adminPath}/basics/commonGroup") +public class CommonGroupManageController extends BaseController { + + @Autowired + private CommonGroupManageService commonGroupManageService; + + @RequestMapping(value = {"list", ""}) + public String policyGroupList(CommonGroupInfo cfg, Model model, HttpServletRequest request, HttpServletResponse response) { + if(cfg == null)cfg=new CommonGroupInfo(); + Page pageCondition = new Page(request, response,"r"); + Page page = commonGroupManageService.findCommonGroupInfoList(pageCondition,cfg); + + model.addAttribute("cfg", cfg); + model.addAttribute("page", page); + return "/basics/commonGroupList"; + } + + @RequestMapping(value={"/form"}) + public String form(Integer groupType,String ids,Model model,String doAction,RedirectAttributes redirectAttributes) { + CommonGroupInfo groupInfo = new CommonGroupInfo(); + if(!StringUtil.isEmpty(ids)){ + groupInfo = commonGroupManageService.getById(Integer.parseInt(ids)); + } + //groupInfo.setGroupType(groupType); + model.addAttribute("_cfg", groupInfo); + return "/basics/commonGroupForm"; + } + + @RequestMapping(value = "saveOrUpdate") + public String saveOrUpdate(CommonGroupInfo cfg, Model model, RedirectAttributes redirectAttributes, + String itType,Integer groupType,HttpServletRequest request) { + + try { + commonGroupManageService.saveOrUpdate(cfg); + addMessage(redirectAttributes,"success","save_success"); + } catch (Exception e) { + logger.error("新增失败",e); + addMessage(redirectAttributes,"error","save_failed"); + LogUtils.saveLog(request, null, e, null); + } + + return "redirect:" + adminPath + "/basics/commonGroup/list"; + + + } + + @RequestMapping(value={"delete"}) + public String delete(RedirectAttributes redirectAttributes, Integer groupType,String ids,int isValid,HttpServletRequest request) { + try { + commonGroupManageService.deldete(ids,isValid); + addMessage(redirectAttributes,"success","delete_success"); + } catch (Exception e) { + logger.error("删除失败",e); + addMessage(redirectAttributes,"error","delete_failed"); + LogUtils.saveLog(request, null, e, null); + } + return "redirect:" + adminPath + "/basics/commonGroup/list"; + } + + @ResponseBody + @RequestMapping(value="ajaxCheckGroupUse") + public boolean ajaxCheckGroupUse(@RequestParam("groupIds")String groupIds){ + return commonGroupManageService.checkIsIssued(groupIds); + } + + //Group配置导出 + @RequestMapping(value = "exportGroup") + public void exportGroup(Model model,HttpServletRequest request,HttpServletResponse response, + @ModelAttribute("cfg")CommonGroupInfo entity,String ids,RedirectAttributes redirectAttributes){ + try { + //export data info + entity.setMenuNameCode("common_group_manage"); + List titleList=new ArrayList(); + Map> classMap=new HashMap>(); + Map dataMap=new HashMap(); + Map noExportMap=new HashMap(); + List list = new ArrayList(); + if (!StringUtil.isEmpty(ids)) { + list = commonGroupManageService.findGroupInfoList(ids); + } else { + Page pageInfo=new Page(request, response,"r"); + pageInfo.setPageNo(1); + pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE); + Page page = commonGroupManageService.findCommonGroupInfoList(pageInfo,entity); + list=page.getList(); + } + + titleList.add(entity.getMenuNameCode()); + classMap.put(entity.getMenuNameCode(), CommonGroupInfo.class); + String cfgIndexInfoNoExport=",config_describe,cfg_id,block_type,do_log,action,valid_identifier,is_audit" + + ",auditor,audit_time,letter,whether_area_block,classification,attribute,label" + +",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,"; + // 时间过滤 + if (entity.getSearch_create_time_start() == null ) { + cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport; + } + if (entity.getSearch_edit_time_start() == null) { + cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport; + } + + if (!StringUtil.isEmpty(entity.gethColumns())) { + cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport; + } + noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport); + dataMap.put(entity.getMenuNameCode(), list); + String timeRange = initTimeMap(entity); + noExportMap.put("timeRange", timeRange); + + if ("csv".equals(entity.getExType())) { + this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList, + classMap, dataMap, noExportMap); + } else { + this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList, + classMap, dataMap, noExportMap); + } + } catch (Exception e) { + logger.error("Group export failed",e); + addMessage(redirectAttributes,"error","export_failed"); + LogUtils.saveLog(request, null, e, null); + } + //return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId(); + } + +} diff --git a/src/main/java/com/nis/web/controller/basics/IpCommGroupController.java b/src/main/java/com/nis/web/controller/basics/IpCommGroupController.java new file mode 100644 index 000000000..43aa1d9b5 --- /dev/null +++ b/src/main/java/com/nis/web/controller/basics/IpCommGroupController.java @@ -0,0 +1,479 @@ +package com.nis.web.controller.basics; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.BlockingQueue; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.jets3t.service.ServiceException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.beust.jcommander.internal.Lists; +import com.nis.domain.FunctionRegionDict; +import com.nis.domain.FunctionServiceDict; +import com.nis.domain.Page; +import com.nis.domain.basics.CommonGroupInfo; +import com.nis.domain.basics.IpCommCfg; +import com.nis.domain.basics.PolicyGroupInfo; +import com.nis.domain.configuration.BaseIpCfg; +import com.nis.domain.configuration.CfgIndexInfo; +import com.nis.domain.configuration.IpPortCfg; +import com.nis.domain.configuration.template.IpCommCfgTemplate; +import com.nis.domain.specific.ConfigGroupInfo; +import com.nis.exceptions.MaatConvertException; +import com.nis.util.Constants; +import com.nis.util.DictUtils; +import com.nis.util.StringUtil; +import com.nis.util.excel.ImportBigExcel; +import com.nis.web.controller.BaseController; +import com.nis.web.security.UserUtils; +import com.nis.web.service.basics.IpCommGroupCfgService; + +@Controller +@RequestMapping(value = "${adminPath}/basics/ip") +public class IpCommGroupController extends BaseController { + + @Autowired + private IpCommGroupCfgService ipCommGroupCfgService; + + @RequestMapping(value = { "/list" }) + public String list(Model model, @ModelAttribute("cfg") IpCommCfg entity, HttpServletRequest request, HttpServletResponse response) { + Page page = ipCommGroupCfgService.findPage(new Page(request, response, "r"),entity); + List regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId()); + List serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId()); + List policyGroupInfos=commonGroupManageService.findCommonGroupInfosByType(5); + + model.addAttribute("page", page); + model.addAttribute("regionList", regionList); + model.addAttribute("serviceList", serviceList); + model.addAttribute("policyGroupInfos", policyGroupInfos); + + return "/basics/ipCommonGroupCfgList"; + } + + @RequestMapping(value = { "/addForm" }) + public String addForm(Model model, @ModelAttribute("cfg") CfgIndexInfo cfg, RedirectAttributes redirectAttributes, + HttpServletRequest request, HttpServletResponse response) { + // IP Group Tyep为5 + cfg.setGroupType(5); + initFormCondition(model, cfg); + + List groupInfos=commonGroupManageService.findCommonGroupInfosByType(5); + model.addAttribute("policyGroupInfos", groupInfos); + model.addAttribute("_cfg", cfg); + return "/basics/ipCommGroupFormAdd"; + } + + @RequestMapping(value = { "/save" }) + @RequiresPermissions(value = { "ip:common:config" }) + public String save(Model model, @ModelAttribute("cfg") CfgIndexInfo cfg, RedirectAttributes redirectAttributes, + HttpServletRequest request, HttpServletResponse response) { + try { + ipCommGroupCfgService.saveIpCommGroupCfg(cfg); + } catch (Exception e) { + logger.error("信息保存失败", e); + if (e instanceof MaatConvertException) { + addMessage(redirectAttributes, "error", e.getMessage()); + } else { + addMessage(redirectAttributes, "error", "save_failed"); + } + } + + return "redirect:" + adminPath + "/basics/ip/list?functionId=" + cfg.getFunctionId(); + } + + @RequestMapping(value = { "/updateForm" }) + public String updateForm(Model model, @ModelAttribute("cfg") IpCommCfg cfg, RedirectAttributes redirectAttributes, String ids, + HttpServletRequest request, HttpServletResponse response) { + cfg = ipCommGroupCfgService.get(Long.parseLong(ids)); + // initUpdateFormCondition(model, cfg); + cfg.setGroupType(5); + initUpdateFormCondition(model, cfg); + List groupInfos=commonGroupManageService.findCommonGroupInfosByType(5); + model.addAttribute("policyGroupInfos", groupInfos); + model.addAttribute("_cfg", cfg); + return "/basics/ipCommGroupFormUpdate"; + } + + @RequestMapping(value = { "/update" }) + @RequiresPermissions(value = { "ip:common:config" }) + public String update(Model model, HttpServletRequest request, HttpServletResponse response, + @ModelAttribute("cfg") IpCommCfg cfg, RedirectAttributes redirectAttributes) { + try { + ipCommGroupCfgService.update(cfg); + addMessage(redirectAttributes, "success", "save_success"); + } catch (Exception e) { + logger.error("信息保存失败", e); + addMessage(redirectAttributes, "error", "save_failed"); + } + + return "redirect:" + adminPath + "/basics/ip/list?functionId=" + cfg.getFunctionId(); + } + +// @RequestMapping(value = { "/audit" }) +// @RequiresPermissions(value = { "ip:common:config" }) +// public String audit(Model model, @ModelAttribute("cfg") IpCommCfg cfg, Integer isAudit, Integer isValid, +// String ids, Integer functionId, HttpServletRequest request, HttpServletResponse response, +// RedirectAttributes redirectAttributes) { +// // 选中配置审核 +// if (!StringUtil.isEmpty(ids)) { +// List ipGroupCfgs = ipCommGroupCfgService.getByIds(ids); +// List temp = Lists.newArrayList(); +// try { +// ipCommGroupCfgService.audit(ipGroupCfgs, isAudit, isValid); +// } catch (Exception e) { +// logger.error("审核失败", e); +// addMessage(redirectAttributes, "error", "audit_failed"); +// } finally { +// temp.clear(); +// } +// return "redirect:" + adminPath + "/basics/ip/list?functionId=" + cfg.getFunctionId(); +// } else {// 全部审核 +// // 条件下所有配置审核 +// Page searchPage = new Page(request, response, "a"); +// Page auditPage = new Page(request, response, "a"); +// BeanUtils.copyProperties(searchPage, auditPage); +// +// try { +// auditAll(auditPage, isValid, cfg); +// addMessage(redirectAttributes, "success", "audit_success"); +// } catch (Exception e) { +// logger.error("配置下发失败:", e); +// if (e instanceof MaatConvertException) { +// addMessage(redirectAttributes, "error", "request_service_failed"); +// } else { +// addMessage(redirectAttributes, "error", "audit_failed"); +// } +// +// } +// +// return list(model, request, response, cfg); +// } +// } + + @RequestMapping(value = { "/delete" }) + @RequiresPermissions(value = { "ip:common:config" }) + public String delete(Integer isValid, String ids, Integer functionId, RedirectAttributes redirectAttributes) { + try { + ipCommGroupCfgService.delete(ids); + addMessage(redirectAttributes, "success", "delete_success"); + } catch (Exception e) { + logger.error("Delete failed", e); + if (e instanceof MaatConvertException) { + addMessage(redirectAttributes, "error", e.getMessage()); + } else { + addMessage(redirectAttributes, "error", "delete_failed"); + } + } + + return "redirect:" + adminPath + "/basics/ip/list?functionId=" + functionId; + } + + // ipComm配置导出 + @RequestMapping(value = "/exportIpComm") + public void exportIpCommonCfg(Model model, HttpServletRequest request, HttpServletResponse response, + @ModelAttribute("cfg") IpCommCfg entity, String ids, RedirectAttributes redirectAttributes) { + try { + // export data info + List titleList = new ArrayList(); + Map> classMap = new HashMap>(); + Map dataMap = new HashMap(); + Map noExportMap = new HashMap(); + List list = new ArrayList(); + if (!StringUtil.isEmpty(ids)) { + list = ipCommGroupCfgService.findByPage(ids); + } else { + Page pageInfo = new Page(request, response, "r"); + pageInfo.setPageNo(1); + pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE); + Page page = ipCommGroupCfgService.findPage(pageInfo, entity); + list = page.getList(); + } + // + titleList.add(entity.getMenuNameCode()); + classMap.put(entity.getMenuNameCode(), IpPortCfg.class); + String cfgIndexInfoNoExport = ",block_type,do_log,action" + + ",letter,whether_area_block,classification,attribute,label" + + ",userregion1,userregion2,userregion3,userregion4,userregion5,src_ip_pattern,client_ip,src_port_pattern,client_port,dest_ip_pattern,dest_port_pattern,dest_port,"; + // 时间过滤 + if (entity.getSearch_create_time_start() == null) { + cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport; + } + if (entity.getSearch_edit_time_start() == null) { + cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport; + } + if (entity.getSearch_audit_time_start() == null) { + cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport; + } + if (!StringUtil.isEmpty(entity.gethColumns())) { + cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport; + } + + noExportMap.put(entity.getMenuNameCode(), cfgIndexInfoNoExport); + dataMap.put(entity.getMenuNameCode(), list); + String timeRange = initTimeMap(entity); + noExportMap.put("timeRange", timeRange); + + if ("csv".equals(entity.getExType())) { + this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList, + classMap, dataMap, noExportMap); + } else { + this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList, + classMap, dataMap, noExportMap); + } + } catch (Exception e) { + logger.error("IpCommGroupCfg export failed", e); + addMessage(redirectAttributes, "error", "export_failed"); + } + // return "redirect:" + adminPath + // +"/ntc/iplist/list?functionId="+entity.getFunctionId(); + } + + /** + * 批量审核 + * + * @param isAudit + * @param isValid + * @param ids + * @param functionId + * @param redirectAttributes + * @return + */ +// @Override +// public void auditAll(Page page, Integer auditType, Object entity) throws Exception { +// long start = System.currentTimeMillis(); +// page.setOrderBy(""); +// page.setPageSize(Constants.MAAT_JSON_SEND_SIZE); +// page.setPageNo(1); +// page.setLastPage(false); +// // 携带审核状态信息的BaseCfg +// BaseCfg auditBatchCfg = new BaseCfg(); +// // 携带审核条件的BaseCfg +// IpCommCfg searchIpCommGroupCfg = new IpCommCfg(); +// BeanUtils.copyProperties(entity, auditBatchCfg); +// BeanUtils.copyProperties(entity, searchIpCommGroupCfg); +// +// auditType = (Integer) Reflections.invokeGetter(entity, "isAudit"); +// +// // 全部审核通过,只查询当前条件下的所有未审核的配置 -批量审核通过/不通过 +// if (auditType.equals(1) || auditType.equals(2)) { +// +// searchIpCommGroupCfg.setIsValid(0); +// searchIpCommGroupCfg.setIsAudit(0); +// +// if (auditType.equals(1)) { +// auditBatchCfg.setIsAudit(1); +// auditBatchCfg.setIsValid(1); +// } else { +// auditBatchCfg.setIsAudit(2); +// auditBatchCfg.setIsValid(0); +// } +// auditBatchCfg.setAuditTime(new Date()); +// auditBatchCfg.setAuditorId(UserUtils.getUser().getId()); +// } else { +// // 全部取消通过,只查询当前条件下的所有审核通过的配置 +// searchIpCommGroupCfg.setIsValid(1); +// searchIpCommGroupCfg.setIsAudit(1); +// +// auditBatchCfg.setIsAudit(3); +// auditBatchCfg.setIsValid(0); +// auditBatchCfg.setAuditTime(new Date()); +// auditBatchCfg.setAuditorId(UserUtils.getUser().getId()); +// } +// +// ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil(); +// Integer functionId = 0; +// if (auditBatchCfg != null && !StringUtil.isEmpty(auditBatchCfg.getFunctionId())) { +// functionId = auditBatchCfg.getFunctionId(); +// } +// List> serviceList = serviceTemplate.getServiceListByFunctionId(functionId); +// for (Map service : serviceList) { +// String tableNameXml = service.get("tableName").toString(); // 获取业务主配置表 +// String serviceTypeXml = service.get("serviceType").toString(); // 业务类型 1maat 2callback +// String classNameXml = service.get("className").toString(); // 主配置Java类 +// String serviceIdXml = service.get("id").toString(); // service字典表 service_id字段 +// auditBatchCfg.setServiceId(Integer.valueOf(serviceIdXml)); +// auditBatchCfg.setTableName(tableNameXml); +// searchIpCommGroupCfg.setServiceId(Integer.valueOf(serviceIdXml)); +// searchIpCommGroupCfg.setTableName(tableNameXml); +// +// if ("1".equals(serviceTypeXml)) {// maat类配置 +// // 存放域配置类型 及 对应表名 +// List> cfgList = (List>) service.get("cfgList"); +// List> userRegionList = (List>) service.get("userRegionList"); +// int cfgType = Integer.parseInt(service.get("cfgType").toString()); +// if (auditBatchCfg.getIsAudit() == 1) { +// boolean hasData = true; +// +// while (hasData) { +// page.setPageNo(1); +// page.setLastPage(false); +// List list = ipCommGroupCfgService.findPage(page, searchIpCommGroupCfg).getList(); +// if(CollectionUtils.isNotEmpty(list)){ +// Map groupIdMap=new HashMap(); +// // 配置生效处理 +// if(auditBatchCfg.getIsAudit().equals(1)) { +// hasData=commonPolicyService.auditReuseCommonConfigData(page, auditBatchCfg,groupIdMap,hasData); +// Map groupIpMap=new HashMap(); +// if(CollectionUtils.isNotEmpty(list)) { +// for (IpCommCfg obj : (List)list) { +// BaseCfg baseCfg=(BaseCfg)obj; +// if(!StringUtil.isEmpty(obj.getGroupId())) { +// groupIdMap.get(obj.getGroupId()).add(baseCfg); +// }else { +// List newList=new ArrayList<>(); +// newList.add(baseCfg); +// groupIdMap.put(obj.getGroupId(),newList); +// } +// } +// } +// +// } +// if(hasData) { +// page.setPageNo(1); +// page.setLastPage(false); +// } +// }else{ +// hasData = false; +// } +// } +// } +// } else { +// throw new RuntimeException("wrong service type " + serviceTypeXml); +// } +// } +// +// // 批量审核通过时,如果没有携带isValid检索条件,返回界面需要将isValid置为null +// if (!StringUtil.isEmpty(entity)) { +// BaseCfg base = (BaseCfg) entity; +// if (!StringUtil.isEmpty(base.getSeltype()) && base.getSeltype().equals("isValid")) { +// base.setIsValid(null); +// BeanUtils.copyProperties(base, entity); +// } +// } +// long end = System.currentTimeMillis(); +// logger.warn("配置批量生效/失效耗时:" + (end - start)); +// } + @RequestMapping(value = "import", method=RequestMethod.POST) + public String importIp(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes, + @RequestParam("files") MultipartFile[] files, Integer serviceDictId ,Integer requestId ,String attribute ,String classify + ,String regionDictIds ,String importPath) { + logger.warn("import start..."); + long start=System.currentTimeMillis(); + ImportBigExcel ei=null; + try { + FunctionServiceDict serviceDict = DictUtils.getFunctionServiceDict(serviceDictId); + StringBuffer errTip=new StringBuffer(); + BlockingQueue ipPortCfgs =null; + //List cfgIndexInfos = new ArrayList(); + for (int i = 0; i < files.length; i++) { + MultipartFile file = files[i]; + ei = new ImportBigExcel(file, 0, 1); + FunctionRegionDict regionDict = DictUtils.getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i])); + //加载模板 + loadTemplate(ei,regionDict, serviceDict); + //------------------------------------check format start---------------------------- + if (regionDict.getRegionType().equals(1)) {// IP + BlockingQueue list = ei.getDataList(IpCommCfgTemplate.class ); + ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null, list); + } + //删除文件 + if(ei.getUploadFile()!=null&&ei.getUploadFile().exists()) { + ei.getUploadFile().delete(); + } + //------------------------------------check format end---------------------------- + Date date = new Date(); + String isSend = request.getParameter("isSend")==null?"":request.getParameter("isSend"); + + if (regionDict.getRegionType().equals(1)) {// IP + List _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE); + while(!ipPortCfgs.isEmpty()) { + ipPortCfgs.drainTo(_ipPortCfgs, Constants.MAAT_JSON_SEND_SIZE); + + int ind=0; + for (BaseIpCfg cfg : _ipPortCfgs) { + cfg.setAction(serviceDict==null?null:serviceDict.getAction()); + cfg.setCfgRegionCode(regionDict.getConfigRegionCode()); + cfg.setCfgType(regionDict.getConfigRegionValue()); + cfg.setCreateTime(date); + cfg.setCreatorId(UserUtils.getUser().getId()); + //cfg.setDoLog(2); + cfg.setCompileId(0); + cfg.setFunctionId(regionDict.getFunctionId()); + if(isSend.equals("1")) { + cfg.setIsAudit(Constants.AUDIT_YES); + cfg.setIsValid(Constants.VALID_YES); + cfg.setAuditorId(UserUtils.getUser().getId()); + cfg.setAuditTime(date); + }else { + cfg.setIsAudit(Constants.AUDIT_NOT_YET); + cfg.setIsValid(Constants.VALID_NO); + } + cfg.setIsAreaEffective(0); + cfg.setLable("0"); + cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId); + cfg.setAttribute(attribute); + cfg.setClassify(classify); + cfg.setServiceId(serviceDict==null?null:serviceDict.getServiceId()); + cfg.setTableName("ip_comm_cfg"); + ind++; + } + ipCommGroupCfgService.saveAndSend(regionDict, serviceDict, _ipPortCfgs,isSend.equals("1")); + _ipPortCfgs.clear(); + } + + } + } + if(errTip.toString().length()>0) { + addMessage(redirectAttributes,"error", errTip.toString()); + } + } catch (Exception e) { + if(ei!=null) { + if(ei.getUploadFile().exists()) { + ei.getUploadFile().delete(); + } + } + if(e instanceof MaatConvertException) { + addMessage(redirectAttributes,"error", "request_service_failed"); + }else if(e instanceof ServiceException) { + addMessage(redirectAttributes,"error", e.getMessage()); + }else if(e instanceof IndexOutOfBoundsException){ + addMessage(redirectAttributes,"error", "template_error"); + }else { + addMessage(redirectAttributes,"error", "import_failed"); + } + logger.error("import failed", e); + } + long end=System.currentTimeMillis(); + logger.warn("import finish,cost:"+(end-start)); + return "redirect:" + adminPath+ importPath; + } + @RequestMapping(value="ajaxGetGroups",method=RequestMethod.POST) + @ResponseBody + public Map ajaxGetGroups(Model model,@RequestParam(required=true,value="groupIds")String groupIds){ + Map groupIdList=new HashMap(); + if(StringUtils.isNotBlank(groupIds)) { + List list=policyGroupInfoService.findPolicyByGroupInfoList(groupIds); + for(PolicyGroupInfo p:list) { + groupIdList.put(p.getGroupId(), p.getGroupName()); + } + } + return groupIdList; + } +} \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/basics/CommonGroupManageDao.java b/src/main/java/com/nis/web/dao/basics/CommonGroupManageDao.java new file mode 100644 index 000000000..e89510da6 --- /dev/null +++ b/src/main/java/com/nis/web/dao/basics/CommonGroupManageDao.java @@ -0,0 +1,35 @@ +package com.nis.web.dao.basics; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.nis.domain.basics.CommonGroupInfo; +import com.nis.domain.basics.PolicyGroupInfo; +import com.nis.web.dao.CrudDao; +import com.nis.web.dao.MyBatisDao; + +@MyBatisDao +public interface CommonGroupManageDao extends CrudDao { + List findCommonGroupInfoList(CommonGroupInfo commonGroupInfo); + + CommonGroupInfo getById(int id); + + List findCommonGroupInfosByType(int groupType); + + List findGroupInfoList(@Param("ids")String ids); + + /*List findPolicyGroupInfos(); + List findHasIPPolicyGroupInfosByType(int groupType); + List findPolicyGroupInfosHasIpRegionByType(int groupType); + List findNatPolicyGroups(); + + PolicyGroupInfo getInfoByAsnNo(PolicyGroupInfo policyGroupInfo); + List getHasAreaPolicyGroups(int groupType); + int insertBatch(List list); + + Integer getGroupIdByGroupName(String groupName); + PolicyGroupInfo getGroupInfo(PolicyGroupInfo policyGroupInfo); + + */ +} \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/basics/CommonGroupManageDao.xml b/src/main/java/com/nis/web/dao/basics/CommonGroupManageDao.xml new file mode 100644 index 000000000..deef9bbfd --- /dev/null +++ b/src/main/java/com/nis/web/dao/basics/CommonGroupManageDao.xml @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + r.group_id,r.group_name,r.group_type,r.is_valid,r.create_time,r.edit_time, + r.creator_id,r.editor_id,r.service_group_id,r.description + + + + + + + + + INSERT INTO policy_group_info( + IS_VALID, + CREATOR_ID, + CREATE_TIME, + GROUP_NAME, + GROUP_TYPE, + SERVICE_GROUP_ID, + DESCRIPTION + )values ( + 1, + #{creatorId,jdbcType=INTEGER}, + #{createTime,jdbcType=TIMESTAMP}, + #{groupName,jdbcType=VARCHAR}, + #{groupType,jdbcType=INTEGER}, + #{serviceGroupId,jdbcType=INTEGER}, + #{description,jdbcType=VARCHAR} + ) + + + INSERT INTO policy_group_info( + IS_VALID, + CREATOR_ID, + CREATE_TIME, + GROUP_NAME, + GROUP_TYPE, + SERVICE_GROUP_ID, + DESCRIPTION + )values + + ( + 1, + #{info.creatorId,jdbcType=INTEGER}, + #{info.createTime,jdbcType=TIMESTAMP}, + #{info.groupName,jdbcType=VARCHAR}, + #{info.groupType,jdbcType=INTEGER}, + #{info.serviceGroupId,jdbcType=INTEGER}, + #{info.description,jdbcType=VARCHAR} + ) + + + + + UPDATE policy_group_info + + + + group_name = #{groupName,jdbcType=VARCHAR}, + + + group_type = #{groupType,jdbcType=INTEGER}, + + + description = #{description,jdbcType=VARCHAR}, + + + is_valid = #{isValid,jdbcType=INTEGER}, + + + editor_id = #{editorId,jdbcType=INTEGER}, + + + edit_time = #{editTime,jdbcType=TIMESTAMP}, + + + + + + and group_id = #{groupId,jdbcType=INTEGER} + + + and service_group_id = #{serviceGroupId,jdbcType=INTEGER} + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/basics/IpCommGroupCfgDao.java b/src/main/java/com/nis/web/dao/basics/IpCommGroupCfgDao.java new file mode 100644 index 000000000..fcedaefbd --- /dev/null +++ b/src/main/java/com/nis/web/dao/basics/IpCommGroupCfgDao.java @@ -0,0 +1,31 @@ +package com.nis.web.dao.basics; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.nis.domain.basics.IpCommCfg; +import com.nis.domain.basics.Varibles; +import com.nis.web.dao.CrudDao; +import com.nis.web.dao.MyBatisDao; +@MyBatisDao +public interface IpCommGroupCfgDao extends CrudDao{ + public List findPage(IpCommCfg cfg); + public List findByPage(@Param("ids")String ids); + public void delete(@Param("ids")String ids); + public void updateIssued(IpCommCfg cfg); + public List getByIds(@Param("ids")String ids); + public List findAllList(IpCommCfg cfg); + public List findOtherIps(@Param("groupId")Integer groupId,@Param("cfgId")Integer cfgId); + public List countValidIPs(@Param("groups")String groups,@Param("ids")String ids); + public int insertBatch(List list); + public Varibles getVaribles(@Param("name")String name); + public void ajaxDeleteAsnIp(@Param("ids")String ids); + public IpCommCfg getOne(IpCommCfg cfg); + public List findAllIpCommGroupCfgList(); + public void insertIpCommGroupCfg(IpCommCfg ipPortCfg); + public int getGroupIdCount(int groupId); + + // 校验分组是否被引用 + public List getCfgInfoByGroupIds(@Param("ids")String ids); +} diff --git a/src/main/java/com/nis/web/dao/basics/IpCommGroupCfgDao.xml b/src/main/java/com/nis/web/dao/basics/IpCommGroupCfgDao.xml new file mode 100644 index 000000000..d66e03e25 --- /dev/null +++ b/src/main/java/com/nis/web/dao/basics/IpCommGroupCfgDao.xml @@ -0,0 +1,526 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + r.cfg_id,r.cfg_desc,r.cfg_type,r.cfg_region_code,r.ip_type,r.src_ip_pattern,r.src_ip_address,r.dest_ip_pattern,r.dest_ip_address, + r.src_port_pattern,r.src_port,r.dest_port_pattern,r.dest_port + ,r.protocol,r.protocol_id,r.direction,r.action + ,r.is_valid,r.is_audit,r.creator_id,r.create_time,r.editor_id + ,r.edit_time,r.auditor_id,r.audit_time,r.service_id,r.request_id, + r.is_area_effective,r.classify,r.attribute,r.lable + ,r.area_effective_ids,r.function_id,r.user_region1 + ,r.user_region2,r.user_region3,r.user_region4,r.user_region5,r.compile_id,r.region_id,r.group_id + + + + + + + + + + + + + SELECT LAST_INSERT_ID() + + insert into ip_comm_cfg ( + CFG_DESC, + ACTION, + IS_VALID, + IS_AUDIT, + CREATOR_ID, + CREATE_TIME, + EDITOR_ID, + EDIT_TIME, + AUDITOR_ID, + AUDIT_TIME, + SERVICE_ID, + REQUEST_ID, + REGION_ID, + GROUP_ID, + COMPILE_ID, + IS_AREA_EFFECTIVE, + CLASSIFY, + ATTRIBUTE, + LABLE, + AREA_EFFECTIVE_IDS, + FUNCTION_ID, + IP_TYPE, + SRC_IP_ADDRESS, + SRC_IP_PATTERN, + DEST_IP_PATTERN, + SRC_PORT_PATTERN, + DEST_PORT_PATTERN, + SRC_PORT, + PROTOCOL, + PROTOCOL_ID, + DIRECTION, + DEST_PORT, + DEST_IP_ADDRESS, + CFG_TYPE, + CFG_REGION_CODE, + USER_REGION1, + USER_REGION2, + USER_REGION3, + USER_REGION4, + USER_REGION5, + )values ( + #{cfgDesc,jdbcType=VARCHAR}, + #{action,jdbcType=INTEGER}, + #{isValid,jdbcType=INTEGER}, + #{isAudit,jdbcType=INTEGER}, + #{creatorId,jdbcType=INTEGER}, + #{createTime,jdbcType=TIMESTAMP}, + #{editorId,jdbcType=INTEGER}, + #{editTime,jdbcType=TIMESTAMP}, + #{auditorId,jdbcType=INTEGER}, + #{auditTime,jdbcType=TIMESTAMP}, + #{serviceId,jdbcType=INTEGER}, + #{requestId,jdbcType=INTEGER}, + #{regionId,jdbcType=INTEGER}, + #{groupId,jdbcType=INTEGER}, + #{compileId,jdbcType=INTEGER}, + #{isAreaEffective,jdbcType=INTEGER}, + #{classify,jdbcType=VARCHAR}, + #{attribute,jdbcType=VARCHAR}, + #{lable,jdbcType=VARCHAR}, + #{areaEffectiveIds,jdbcType=VARCHAR}, + #{functionId,jdbcType=INTEGER}, + #{ipType,jdbcType=INTEGER}, + #{srcIpAddress,jdbcType=VARCHAR}, + #{srcIpPattern,jdbcType=INTEGER},#{destIpPattern,jdbcType=INTEGER}, + #{srcPortPattern,jdbcType=INTEGER},#{destPortPattern,jdbcType=INTEGER}, + #{srcPort,jdbcType=VARCHAR}, + #{protocol,jdbcType=INTEGER}, + #{protocolId,jdbcType=INTEGER}, + #{direction,jdbcType=INTEGER}, + #{destPort,jdbcType=VARCHAR}, + #{destIpAddress,jdbcType=VARCHAR}, + #{cfgType,jdbcType=VARCHAR}, + #{cfgRegionCode,jdbcType=INTEGER}, + #{userRegion1,jdbcType=VARCHAR}, + #{userRegion2,jdbcType=VARCHAR}, + #{userRegion3,jdbcType=VARCHAR}, + #{userRegion4,jdbcType=VARCHAR}, + #{userRegion5,jdbcType=VARCHAR} + ) + + + insert into ip_comm_cfg ( + CFG_DESC, + ACTION, + IS_VALID, + IS_AUDIT, + CREATOR_ID, + CREATE_TIME, + EDITOR_ID, + EDIT_TIME, + AUDITOR_ID, + AUDIT_TIME, + SERVICE_ID, + REQUEST_ID, + REGION_ID, + GROUP_ID, + COMPILE_ID, + IS_AREA_EFFECTIVE, + CLASSIFY, + ATTRIBUTE, + LABLE, + AREA_EFFECTIVE_IDS, + FUNCTION_ID, + IP_TYPE, + SRC_IP_ADDRESS, + SRC_IP_PATTERN, + DEST_IP_PATTERN, + SRC_PORT_PATTERN, + DEST_PORT_PATTERN, + SRC_PORT, + PROTOCOL, + PROTOCOL_ID, + DIRECTION, + DEST_PORT, + DEST_IP_ADDRESS, + CFG_TYPE, + CFG_REGION_CODE, + USER_REGION1, + USER_REGION2, + USER_REGION3, + USER_REGION4, + USER_REGION5 + )values ( + #{cfgDesc,jdbcType=VARCHAR}, + #{action,jdbcType=INTEGER}, + #{isValid,jdbcType=INTEGER}, + #{isAudit,jdbcType=INTEGER}, + #{creatorId,jdbcType=INTEGER}, + #{createTime,jdbcType=TIMESTAMP}, + #{editorId,jdbcType=INTEGER}, + #{editTime,jdbcType=TIMESTAMP}, + #{auditorId,jdbcType=INTEGER}, + #{auditTime,jdbcType=TIMESTAMP}, + #{serviceId,jdbcType=INTEGER}, + #{requestId,jdbcType=INTEGER}, + #{regionId,jdbcType=INTEGER}, + #{groupId,jdbcType=INTEGER}, + #{compileId,jdbcType=INTEGER}, + #{isAreaEffective,jdbcType=INTEGER}, + #{classify,jdbcType=VARCHAR}, + #{attribute,jdbcType=VARCHAR}, + #{lable,jdbcType=VARCHAR}, + #{areaEffectiveIds,jdbcType=VARCHAR}, + #{functionId,jdbcType=INTEGER}, + #{ipType,jdbcType=INTEGER}, + #{srcIpAddress,jdbcType=VARCHAR}, + #{srcIpPattern,jdbcType=INTEGER},#{destIpPattern,jdbcType=INTEGER}, + #{srcPortPattern,jdbcType=INTEGER},#{destPortPattern,jdbcType=INTEGER}, + #{srcPort,jdbcType=VARCHAR}, + #{protocol,jdbcType=INTEGER}, + #{protocolId,jdbcType=INTEGER}, + #{direction,jdbcType=INTEGER}, + #{destPort,jdbcType=VARCHAR}, + #{destIpAddress,jdbcType=VARCHAR}, + #{cfgType,jdbcType=VARCHAR}, + #{cfgRegionCode,jdbcType=INTEGER}, + #{userRegion1,jdbcType=VARCHAR}, + #{userRegion2,jdbcType=VARCHAR}, + #{userRegion3,jdbcType=VARCHAR}, + #{userRegion4,jdbcType=VARCHAR}, + #{userRegion5,jdbcType=VARCHAR} + ) + + + update ip_comm_cfg + + + + CFG_DESC = #{cfgDesc,jdbcType=VARCHAR}, + + + ACTION = #{action,jdbcType=INTEGER}, + + + IS_VALID = #{isValid,jdbcType=INTEGER}, + + + IS_AUDIT = #{isAudit,jdbcType=INTEGER}, + + + EDITOR_ID = #{editorId,jdbcType=INTEGER}, + + + EDIT_TIME = #{editTime,jdbcType=TIMESTAMP}, + + + AUDITOR_ID = #{auditorId,jdbcType=INTEGER}, + + + AUDIT_TIME = #{auditTime,jdbcType=TIMESTAMP}, + + + REGION_ID = #{regionId,jdbcType=TIMESTAMP}, + + + REQUEST_ID = #{requestId,jdbcType=INTEGER}, + + + IS_AREA_EFFECTIVE = #{isAreaEffective,jdbcType=INTEGER}, + + + CLASSIFY = #{classify,jdbcType=VARCHAR}, + + + ATTRIBUTE = #{attribute,jdbcType=VARCHAR}, + + + LABLE = #{lable,jdbcType=VARCHAR}, + + + AREA_EFFECTIVE_IDS = #{areaEffectiveIds,jdbcType=VARCHAR}, + + + FUNCTION_ID = #{functionId,jdbcType=INTEGER}, + + + SERVICE_ID = #{serviceId,jdbcType=INTEGER}, + + + IP_TYPE = #{ipType,jdbcType=INTEGER}, + + + SRC_IP_ADDRESS = #{srcIpAddress,jdbcType=VARCHAR}, + + + SRC_IP_PATTERN = #{srcIpPattern,jdbcType=INTEGER}, + + + DEST_IP_PATTERN =#{destIpPattern,jdbcType=INTEGER}, + + + SRC_PORT_PATTERN = #{srcPortPattern,jdbcType=INTEGER}, + + + DEST_PORT_PATTERN = #{destPortPattern,jdbcType=INTEGER}, + + + SRC_PORT = #{srcPort,jdbcType=VARCHAR}, + + + PROTOCOL = #{protocol,jdbcType=INTEGER}, + + + PROTOCOL_ID = #{protocolId,jdbcType=INTEGER}, + + + DIRECTION = #{direction,jdbcType=INTEGER}, + + + DEST_PORT = #{destPort,jdbcType=VARCHAR}, + + + DEST_IP_ADDRESS = #{destIpAddress,jdbcType=VARCHAR}, + + + CFG_TYPE = #{cfgType,jdbcType=VARCHAR}, + + + CFG_REGION_CODE = #{cfgRegionCode,jdbcType=INTEGER}, + + + USER_REGION1 = #{userRegion1,jdbcType=VARCHAR}, + + + USER_REGION2 = #{userRegion2,jdbcType=VARCHAR}, + + + USER_REGION3 = #{userRegion3,jdbcType=VARCHAR}, + + + USER_REGION4 = #{userRegion4,jdbcType=VARCHAR}, + + + USER_REGION5 = #{userRegion5,jdbcType=VARCHAR}, + + + GROUP_ID = #{groupId,jdbcType=INTEGER}, + + + REGION_ID = #{regionId,jdbcType=INTEGER}, + + + + + and cfg_id = #{cfgId,jdbcType=INTEGER} + + + + + delete from ip_comm_cfg where cfg_id in (${ids}) + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/basics/CommonGroupManageService.java b/src/main/java/com/nis/web/service/basics/CommonGroupManageService.java new file mode 100644 index 000000000..b252298c7 --- /dev/null +++ b/src/main/java/com/nis/web/service/basics/CommonGroupManageService.java @@ -0,0 +1,235 @@ +package com.nis.web.service.basics; + +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +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.basics.CommonGroupInfo; +import com.nis.domain.basics.IpCommCfg; +import com.nis.domain.basics.PolicyGroupInfo; +import com.nis.domain.basics.UrlCommCfg; +import com.nis.domain.specific.ConfigGroupInfo; +import com.nis.exceptions.MaatConvertException; +import com.nis.util.ConfigServiceUtil; +import com.nis.util.StringUtil; +import com.nis.web.dao.basics.AsnIpCfgDao; +import com.nis.web.dao.basics.CommonGroupManageDao; +import com.nis.web.dao.basics.IpCommGroupCfgDao; +import com.nis.web.dao.basics.UrlCommGroupDao; +import com.nis.web.dao.specific.ConfigGroupInfoDao; +import com.nis.web.security.UserUtils; +import com.nis.web.service.BaseService; +import com.nis.web.service.SpringContextHolder; + +@Service +public class CommonGroupManageService extends BaseService{ + + @Autowired + private CommonGroupManageDao commonGroupManageDao; + + @Autowired + private ConfigGroupInfoDao configGroupInfoDao; + + @Autowired + private IpCommGroupCfgDao ipCommGroupCfgDao; + + @Autowired + private UrlCommGroupDao urlCommGroupDao; + + @Autowired + private AsnIpCfgDao asnIpCfgDao; + + public Page findCommonGroupInfoList(Page page, CommonGroupInfo entity) { + entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r")); + entity.setPage(page); + List list=commonGroupManageDao.findCommonGroupInfoList(entity); + page.setList(list); + return page; + } + + public CommonGroupInfo getById(int id) { + CommonGroupInfo groupInfo=commonGroupManageDao.getById(id); + return groupInfo; + } + + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void saveOrUpdate(CommonGroupInfo entity) throws MaatConvertException{ + entity.setIsValid(1); + //新增 + if(entity.getGroupId()==null){ + Date createTime=new Date(); + entity.setCreatorId(UserUtils.getUser().getId()); + entity.setCreateTime(createTime); + //asn类型从综合服务获取groupId 非ASN组 不对config_group_info表添加数据 + /*if(4==entity.getGroupType().intValue()) { + int serviceGroupId=0; + List groupIds= ConfigServiceUtil.getId(2,1); + if(groupIds.size()>0) { + serviceGroupId=groupIds.get(0).intValue(); + }else { + throw new MaatConvertException("Get asn group id failed"); + } + entity.setServiceGroupId(serviceGroupId); + //新增协议分组 + ConfigGroupInfo group = configGroupInfoDao.getConfigGroupInfoByGroupId(serviceGroupId); + if(group==null){ + group = new ConfigGroupInfo(); + group.setGroupId(serviceGroupId); + group.setGroupName(entity.getGroupName()); + group.setIsIssued(0); + group.setGroupType(entity.getGroupType()); + group.setAsnId(entity.getAsnNo()); + configGroupInfoDao.insertConfigGroupInfo(group); +// if(group.getGroupType().intValue()==4) { +// AsnCacheUtils.put(entity.getAsnNo(), group); +// } + + } + }*/ + commonGroupManageDao.insert(entity); + //修改 + }else{ + Date editTime=new Date(); + entity.setEditorId(UserUtils.getUser().getId()); + entity.setEditTime(editTime); + commonGroupManageDao.update(entity); + } + } + + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void deldete(String ids, int isValid){ + //TODO 公共组删除时需检索是否有被对应公共组配置引用,被引用的公共组无法删除 + IpCommGroupCfgService ipGroupCfgService = SpringContextHolder.getBean(IpCommGroupCfgService.class); + + CommonGroupInfo entity=new CommonGroupInfo(); + Date editTime=new Date(); + entity.setEditorId(UserUtils.getUser().getId()); + entity.setEditTime(editTime); + entity.setIsValid(isValid); + if(!StringUtil.isEmpty(ids)){ + for (String id : ids.split(",")) { + if(!StringUtil.isEmpty(id)){ + entity.setGroupId(Integer.parseInt(id)); + commonGroupManageDao.update(entity); + } + } + } + } + + // 查询指定类型的分组信息 + public List findCommonGroupInfosByType(int type) { + List list=commonGroupManageDao.findCommonGroupInfosByType(type); + return list; + } + + public List findGroupInfoList(String ids) { + List list=commonGroupManageDao.findGroupInfoList(ids); + return list; + } + + /** + * 删除时校验分组是否被引用,未被引用可删除 + * @param groupIds + * @return false未被引用 / true已被引用 + */ + public boolean checkIsIssued(String groupIds) { + // 组织格式 + Map> map = new HashMap>(); + for(String str : groupIds.split(",")) { + Integer id = Integer.valueOf(str.substring(0, str.indexOf("_"))); + Integer type = Integer.valueOf(str.substring(str.indexOf("_")+1)); + if(map.containsKey(type)) { + Set set = map.get(type); + set.add(id); + map.put(type, set); + }else { + Set set = new HashSet(); + set.add(id); + map.put(type, set); + } + } + + // 根据类型去相应配置查询,若存在被引用的则限制操作 + Set keySet = map.keySet(); + for (Integer type : keySet) { + Set set = map.get(type); + String str = set.toString(); + String ids = str.substring(1, str.indexOf("]")); + if(type == 5) { + List list = ipCommGroupCfgDao.getCfgInfoByGroupIds(ids); + if(list.size() > 0) { + return true; + } + }else if(type == 7) { + List list = urlCommGroupDao.getCfgInfoByGroupIds(ids); + if(list.size() > 0) { + return true; + } + } + } + return false; + } + + /* + public List findPolicyGroupInfos() { + List list=commonGroupManageDao.findPolicyGroupInfos(); + return list; + } + public List findNatPolicyGroups() { + List list=commonGroupManageDao.findNatPolicyGroups(); + return list; + } + public List findPolicyGroupInfosByType(int type) { + List list=commonGroupManageDao.findPolicyGroupInfosByType(type); + return list; + } + public List findHasIpPolicyGroupInfosByType(int type) { + List list=commonGroupManageDao.findHasIPPolicyGroupInfosByType(type); + return list; + } + public List findPolicyGroupInfosHasIpRegionByType(int type) { + List list=commonGroupManageDao.findPolicyGroupInfosByType(type); + return list; + } + + public boolean checkIps(String groupIds) { + for(String groupId:groupIds.split(",")) { + Integer.parseInt(groupId); + } + List hasIpList=asnIpCfgDao.hasGroupIds(groupIds); + if(hasIpList!=null&&hasIpList.size()>0) { + return true; + } + return false; + } + + public PolicyGroupInfo getInfoByAsnNo(PolicyGroupInfo policyGroupInfo){ + return commonGroupManageDao.getInfoByAsnNo(policyGroupInfo); + } + + *//** + * IP复用配置表单-获取拥有区域信息的策略分组 + * @param groupType + * @return + *//* + public List getHasAreaPolicyGroups(int groupType) { + return commonGroupManageDao.getHasAreaPolicyGroups(groupType); + } + + public Integer getGroupIdByGroupName(String groupName){ + return commonGroupManageDao.getGroupIdByGroupName(groupName); + } + + public PolicyGroupInfo getGroupInfo(PolicyGroupInfo policyGroupInfo){ + return commonGroupManageDao.getGroupInfo(policyGroupInfo); + }*/ + +} diff --git a/src/main/java/com/nis/web/service/basics/IpCommGroupCfgService.java b/src/main/java/com/nis/web/service/basics/IpCommGroupCfgService.java new file mode 100644 index 000000000..951af5a1e --- /dev/null +++ b/src/main/java/com/nis/web/service/basics/IpCommGroupCfgService.java @@ -0,0 +1,253 @@ +package com.nis.web.service.basics; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.beust.jcommander.internal.Maps; +import com.beust.jcommander.internal.Sets; +import com.google.common.collect.Lists; +import com.nis.domain.FunctionRegionDict; +import com.nis.domain.FunctionServiceDict; +import com.nis.domain.Page; +import com.nis.domain.basics.AsnGroupInfo; +import com.nis.domain.basics.AsnIpCfg; +import com.nis.domain.basics.IpCommCfg; +import com.nis.domain.configuration.BaseIpCfg; +import com.nis.domain.configuration.CfgIndexInfo; +import com.nis.domain.maat.GroupReuseAddBean; +import com.nis.domain.maat.GroupReuseCfg; +import com.nis.domain.maat.MaatCfg; +import com.nis.domain.maat.ToMaatBean; +import com.nis.domain.maat.ToMaatResult; +import com.nis.domain.maat.MaatCfg.DigestCfg; +import com.nis.domain.maat.MaatCfg.GroupCfg; +import com.nis.domain.maat.MaatCfg.IpCfg; +import com.nis.domain.maat.MaatCfg.NumBoundaryCfg; +import com.nis.domain.maat.MaatCfg.StringCfg; +import com.nis.util.ConfigServiceUtil; +import com.nis.util.Constants; +import com.nis.util.StringUtil; +import com.nis.web.dao.basics.AsnGroupInfoDao; +import com.nis.web.dao.basics.AsnIpCfgDao; +import com.nis.web.dao.basics.IpCommGroupCfgDao; +import com.nis.web.dao.basics.PolicyGroupInfoDao; +import com.nis.web.security.UserUtils; +import com.nis.web.service.BaseService; +import com.nis.web.service.SpringContextHolder; +@Service +public class IpCommGroupCfgService extends BaseService { + @Autowired + private IpCommGroupCfgDao ipCommGroupCfgDao; + @Autowired + private PolicyGroupInfoDao policyGroupInfoDao; + /** + * @param page + * @param entity + * @return + */ + public Page findPage(Page page, IpCommCfg entity) { + entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r")); + entity.setPage(page); + List list=ipCommGroupCfgDao.findPage(entity); + page.setList(list); + return page; + } + + public List findByPage(String ids) { + List list=ipCommGroupCfgDao.findByPage(ids); + return list; + } + + public IpCommCfg get(Long id ) { + return ipCommGroupCfgDao.get(id); + } + + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void save(List entitys) { + logger.warn("Start to save IP,size:"+entitys.size()); + long start=System.currentTimeMillis(); + for(IpCommCfg ipCfg:entitys) { + ipCommGroupCfgDao.insert(ipCfg); + } + long end=System.currentTimeMillis(); + logger.warn("Save IP finish,cost:"+(end-start)); + } + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void update(IpCommCfg entity){ + ipCommGroupCfgDao.update(entity); + } + + + public List getByIds(String ids) { + if(ids==null) { + throw new RuntimeException("ids is null!"); + } + return ipCommGroupCfgDao.getByIds(ids); + } + + //新增 + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void saveIpCommGroupCfg(CfgIndexInfo entity) { + //TODO 组配置更新时 需检索是否被其它配置引用,若被引用需调用相应服务接口更新配置 + + Date createTime=new Date(); + if(CollectionUtils.isNotEmpty(entity.getIpCommGroupCfgList())) { + for (int i = 0; i < entity.getIpCommGroupCfgList().size(); i++) { + BeanUtils.copyProperties(entity, entity.getIpCommGroupCfgList().get(i), new String[]{"cfgId","userregion3"}); + entity.getIpCommGroupCfgList().get(i).setRequestId(0); + entity.getIpCommGroupCfgList().get(i).setClassify("0"); + entity.getIpCommGroupCfgList().get(i).setAttribute("0"); + entity.getIpCommGroupCfgList().get(i).setLable("0"); + entity.getIpCommGroupCfgList().get(i).setCreateTime(createTime); + entity.getIpCommGroupCfgList().get(i).setCreatorId(entity.getCurrentUser().getId()); + entity.getIpCommGroupCfgList().get(i).setIsValid(Constants.VALID_NO); + entity.getIpCommGroupCfgList().get(i).setIsAudit(Constants.AUDIT_NOT_YET); + entity.getIpCommGroupCfgList().get(i).setGroupId(Integer.parseInt(entity.getUserRegion3())); + ipCommGroupCfgDao.insertForBatch(entity.getIpCommGroupCfgList().get(i)); + } + } + } + + + + // @Transactional(readOnly=false,rollbackFor=RuntimeException.class) +// public void audit(List ipCommGroupCfgs, Integer isAudit, Integer isValid) { +// // TODO Auto-generated method stub +// Set groupIds=Sets.newHashSet(); +// if(!StringUtil.isEmpty(ipCommGroupCfgs)){ +// for(IpCommCfg cfg:ipCommGroupCfgs) { +// cfg.setIsValid(isValid); +// cfg.setIsAudit(isAudit); +// cfg.setAuditorId(UserUtils.getUser().getId()); +// cfg.setAuditTime(new Date()); +// groupIds.add(cfg.getGroupId()); +// ipCommGroupCfgDao.update(cfg); +// } +// } +// //查询有效的Ip配置个数 +// for(Integer groupId:groupIds) { +// Integer groupCount=ipCommGroupCfgDao.getGroupIdCount(groupId); +// if(groupCount>0){//udFlag 设置为1 +// policyGroupInfoDao.updateUdFlag(groupId, 1,5); +// }else{//udFlag 设置为0 +// policyGroupInfoDao.updateUdFlag(groupId, 0,5); +// } +// } +// //下发配置时改变公共组udFlag标识 +// send2Maat(ipCommGroupCfgs,isValid); +// } +// public void send2Maat(List ipCommGroupCfgs,int isValid) { +// GroupReuseAddBean maatBean = new GroupReuseAddBean(); +// List groupReuseList=new ArrayList<>(); +// GroupReuseCfg groupReuseCfg=new GroupReuseCfg(); +// List ipRegionList = groupReuseCfgAddRemoveConvert(ipCommGroupCfgs,isValid,null); +// List strRegionList = new ArrayList<>(); +// List numRegionList = new ArrayList<>(); +// groupReuseCfg.setIpRegionList(ipRegionList); +// groupReuseCfg.setStrRegionList(strRegionList); +// groupReuseCfg.setNumRegionList(numRegionList); +// groupReuseList.add(groupReuseCfg); +// maatBean.setGroupReuseCfgList(groupReuseList); +// maatBean.setAuditTime(new Date()); +// maatBean.setCreatorName(UserUtils.getUser().getName()); +// maatBean.setVersion(Constants.MAAT_VERSION); +// logger.warn("IP Common Region Send To Maat start"); +// long start=System.currentTimeMillis(); +// if(isValid==Constants.VALID_YES) { +// maatBean.setOpAction(Constants.INSERT_ACTION); +// //调用服务接口下发配置数据 +// String json=gsonToJson(maatBean); +// if(ipCommGroupCfgs.size()<=100) { +// logger.info("ip 公共组域新增配置下发配置参数:"+json); +// }else { +// logger.info("ip 公共组域新增配置下发region条数:"+ipCommGroupCfgs.size()); +// } +// //调用服务接口下发配置 +// ToMaatResult result =ConfigServiceUtil.postGroupReuseSources(json); +// logger.info("ip 公共组域新增配置响应信息:"+result.getMsg()); +// }else { +// maatBean.setOpAction(Constants.UPDATE_ACTION); +// //调用服务接口下发配置数据 +// String json=gsonToJson(maatBean); +// if(ipCommGroupCfgs.size()<=100) { +// logger.info("ip 公共组域删除配置下发配置参数:"+json); +// }else { +// logger.info("ip 公共组域删除配置下发region条数:"+ipCommGroupCfgs.size()); +// +// } +// //调用服务接口下发配置 +// ToMaatResult result = ConfigServiceUtil.put(json,3); +// logger.info("asn ip复用域删除配置响应信息:"+result.getMsg()); +// } +// long end=System.currentTimeMillis(); +// logger.warn("IP Common Region Send To Maat finish,cost:"+(end-start)); +// } + public void delete(String ids) { + // TODO 公共组配置删除时 需检索是否被其它业务配置引用,没被引用可删除 + + if(ids==null) { + throw new RuntimeException("ids is null!"); + } + ipCommGroupCfgDao.delete(ids); + } + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void saveAndSend(FunctionRegionDict regionDict, FunctionServiceDict serviceDict, List cfgs,boolean send) { + logger.warn("Start to save IP,size:"+cfgs.size()); + long start=System.currentTimeMillis(); + SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); + SqlSession batchSqlSession = null; + //需要通过新增域接口新增的ip集合 + Map groupCount=Maps.newHashMap(); + List ipCommCfgs=new ArrayList(cfgs.size()); + try{ + batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); + + for(BaseIpCfg cfg:cfgs) { + IpCommCfg ipCommCfg=new IpCommCfg(); + BeanUtils.copyProperties(cfg, ipCommCfg); + ipCommCfgs.add(ipCommCfg); + ((IpCommGroupCfgDao) batchSqlSession.getMapper(IpCommGroupCfgDao.class)).insertForBatch(ipCommCfg); +// if(send) { +// if(groupCount.containsKey(ipCommCfg.getGroupId())) { +// groupCount.put(ipCommCfg.getGroupId(), groupCount.get(ipCommCfg.getGroupId())+1); +// }else { +// groupCount.put(ipCommCfg.getGroupId(), 1); +// } +// } + + } +// if(send) { +// if(groupCount.size()>0) { +// for(Entry groupId:groupCount.entrySet()) { +// policyGroupInfoDao.updateUdFlag(groupId.getKey(), 1,5); +// } +// +// this.send2Maat(ipCommCfgs, Constants.VALID_YES); +// } +// } + batchSqlSession.commit(); + }finally { + if(batchSqlSession != null){ + batchSqlSession.close(); + } + } + long end=System.currentTimeMillis(); + logger.warn("Save IP finish,cost:"+(end-start)); + cfgs.clear(); + cfgs=null; + } + +} \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/basics/commonGroupForm.jsp b/src/main/webapp/WEB-INF/views/basics/commonGroupForm.jsp new file mode 100644 index 000000000..0337d7b26 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/basics/commonGroupForm.jsp @@ -0,0 +1,126 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +<spring:message code="${cfgName}"></spring:message> + + + + +
+ +

+ +

+ +
+
+
+
+
+ + + +
+
+
+ + + + <%-- --%> +
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/basics/commonGroupList.jsp b/src/main/webapp/WEB-INF/views/basics/commonGroupList.jsp new file mode 100644 index 000000000..404de9502 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/basics/commonGroupList.jsp @@ -0,0 +1,324 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +<spring:message code="${cfgName}"></spring:message> + + + + +
+ + +

+ +

+ +
+
+
+
+ + + + + + + + +
+ <%--
+ + +
--%> + +
+ +
+
+ + + + <%-- + + --%> + + +
+ + + +
+
+
+ + + +
+
+ <%-- --%> + + + + + <%-- --%> + <%-- --%> + +
+ + +
+ + href="javascript:;"> + + +
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ +
+
+ +
+ + + + + + + <%-- + + --%> + <%-- + + --%> + + + + + + + + + + + + + + <%-- + + --%> + <%-- + + --%> + + + + + + + + +
+ + ${fns:abbr(cfg.groupName,20)} + + + <%-- + + + + + + + + + + + --%> + + + + <%-- + + + + + + + + + + + --%> + ${cfg.asnNo} + + + ${ipTypeC.itemValue } + + + ${fns:abbr(cfg.description,20)}${cfg.creatorName }${cfg.editorName }
+
${page}
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/basics/ipCommGroupFormAdd.jsp b/src/main/webapp/WEB-INF/views/basics/ipCommGroupFormAdd.jsp new file mode 100644 index 000000000..927a5109c --- /dev/null +++ b/src/main/webapp/WEB-INF/views/basics/ipCommGroupFormAdd.jsp @@ -0,0 +1,366 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + + <spring:message code="ip_group_configuration"></spring:message> + + + + +
+ +

+ +

+ +
+
+
+
+
+ + +
+
+
+ +
+ + + + + + + + + + + + + + + + + +
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+

+ + +

+ +
+
+
+
+
+
+ + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/basics/ipCommGroupFormUpdate.jsp b/src/main/webapp/WEB-INF/views/basics/ipCommGroupFormUpdate.jsp new file mode 100644 index 000000000..dc0082de0 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/basics/ipCommGroupFormUpdate.jsp @@ -0,0 +1,323 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + + <spring:message code="ip_group_configuration"></spring:message> + + + + +
+ +

+ +

+ +
+
+
+
+
+ + +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ <%-- --%> + +
+
+
+
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+ <%-- <%@include file="/WEB-INF/include/form/basicInfo.jsp" %> --%> +
+
+
+
+
+
+ + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/basics/ipCommonGroupCfgList.jsp b/src/main/webapp/WEB-INF/views/basics/ipCommonGroupCfgList.jsp new file mode 100644 index 000000000..19654320c --- /dev/null +++ b/src/main/webapp/WEB-INF/views/basics/ipCommonGroupCfgList.jsp @@ -0,0 +1,361 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + + <spring:message code="ip_group_configuration"></spring:message> + + + + +
+ + +

+ +

+ +
+
+
+
+ + + + + + + + + + + +
+ <%--
+ + + + + + + + +
--%> + +
+
+
+ + + + <%-- --%> + +
+ + +
+ + + + + +
+
+
+
+ + + + + + +
+
+ + + +
+
+ + + + + +
+ + +
+ + <%-- +
+ + +
+
--%> + href="javascript:;"> + + +
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ + <%--
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
--%> +
+ + +
+ + +
+
+ +
+ + + + + <%-- --%> + <%-- --%> + + <%-- --%> + + + + + <%-- --%> + <%-- --%> + + + + + + <%-- + --%> + <%-- --%> + + + + + + + <%-- --%> + + + + + <%-- --%> + + <%-- --%> + <%-- --%> + + + + + + <%-- + --%> + + + + +
${cfg.compileId }${cfg.cfgDesc }${cfg.groupId} + + + + ${fns:abbr(cfg.destIpAddress, 42)}${cfg.destPort } + + + + + + + + + + + +
+ + + + ${cfg.creatorName }${cfg.editorName }${cfg.auditorName }
+
${page}
+
+
+
+
+
+ + +<%@include file="/WEB-INF/include/excel/importModal.jsp" %> + + \ No newline at end of file