From aaf8dd5afba4f8ece59ba5c332e4a4acc60cc690 Mon Sep 17 00:00:00 2001 From: wangxin Date: Sun, 8 Apr 2018 16:15:06 +0800 Subject: [PATCH] =?UTF-8?q?=EF=BC=881=EF=BC=89IP=E7=B1=BB=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=A2=9E=E5=8A=A0=E5=8C=BA=E5=9F=9FGK=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20=EF=BC=882=EF=BC=89=E4=BF=AE=E5=A4=8D=E7=BC=96?= =?UTF-8?q?=E8=AF=91ID=E7=9A=84=E9=87=8D=E5=A4=8D=E8=8E=B7=E5=8F=96BUG=20?= =?UTF-8?q?=EF=BC=883=EF=BC=89=E7=9B=91=E6=B5=8B=E7=B1=BB=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=9B=AE=E5=89=8D=E4=B8=8D=E6=8F=90=E4=BE=9B=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E7=AE=A1=E6=8E=A7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nis/domain/configuration/AreaBean.java | 49 ++ .../nis/domain/configuration/AreaIpCfg.java | 20 + .../com/nis/domain/configuration/BaseCfg.java | 59 +++ .../nis/domain/configuration/BaseIpCfg.java | 9 + src/main/java/com/nis/util/Constants.java | 10 + .../ComplexStringCfgController.java | 10 +- .../configuration/IpCfgController.java | 226 +++++++-- .../configuration/NumCfgController.java | 10 +- .../configuration/StringCfgController.java | 10 +- .../web/dao/configuration/AreaIpCfgDao.java | 30 ++ .../web/dao/configuration/AreaIpCfgDao.xml | 92 ++++ .../nis/web/dao/configuration/IpCfgDao.xml | 5 +- .../java/com/nis/web/service/CrudService.java | 67 ++- .../service/configuration/IpCfgService.java | 25 +- .../webapp/WEB-INF/include/form/areaInfo.jsp | 432 ++++++++++++++++++ .../webapp/WEB-INF/include/form/ipInfo.jsp | 20 +- .../WEB-INF/include/form/stringInfo.jsp | 6 +- .../WEB-INF/views/cfg/complexCfgForm.jsp | 3 + .../webapp/WEB-INF/views/cfg/ipCfgForm.jsp | 153 +++++-- .../WEB-INF/views/cfg/stringCfgForm.jsp | 4 + 20 files changed, 1133 insertions(+), 107 deletions(-) create mode 100644 src/main/java/com/nis/domain/configuration/AreaBean.java create mode 100644 src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java create mode 100644 src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.xml create mode 100644 src/main/webapp/WEB-INF/include/form/areaInfo.jsp diff --git a/src/main/java/com/nis/domain/configuration/AreaBean.java b/src/main/java/com/nis/domain/configuration/AreaBean.java new file mode 100644 index 000000000..92a982f38 --- /dev/null +++ b/src/main/java/com/nis/domain/configuration/AreaBean.java @@ -0,0 +1,49 @@ +/** + *@Title: AreaBean.java + *@Package com.nis.domain.configuration + *@Description TODO + *@author dell + *@date 2018年4月8日 上午10:06:11 + *@version 版本号 + */ +package com.nis.domain.configuration; + +/** + * @ClassName: AreaBean.java + * @Description: TODO + * @author (dell) + * @date 2018年4月8日 上午10:06:11 + * @version V1.0 + */ +public class AreaBean { + private String area; + private String isp; + /** + * area + * @return area + */ + + public String getArea() { + return area; + } + /** + * @param area the area to set + */ + public void setArea(String area) { + this.area = area; + } + /** + * isp + * @return isp + */ + + public String getIsp() { + return isp; + } + /** + * @param isp the isp to set + */ + public void setIsp(String isp) { + this.isp = isp; + } +} diff --git a/src/main/java/com/nis/domain/configuration/AreaIpCfg.java b/src/main/java/com/nis/domain/configuration/AreaIpCfg.java index 6e62ddca4..84bc8b004 100644 --- a/src/main/java/com/nis/domain/configuration/AreaIpCfg.java +++ b/src/main/java/com/nis/domain/configuration/AreaIpCfg.java @@ -16,6 +16,8 @@ package com.nis.domain.configuration; * @version V1.0 */ public class AreaIpCfg extends BaseIpCfg { + private static final String tableName="area_ip_cfg"; + private static final String maatTable="DF_IP_RANGE"; /** * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) * @@ -53,5 +55,23 @@ public class AreaIpCfg extends BaseIpCfg { this.isAreaEffective=0; this.areaEffectiveIds=null; } + + /** + * tablename + * @return tablename + */ + + public static String getTablename() { + return tableName; + } + + /** + * maattable + * @return maattable + */ + + public static String getMaattable() { + return maatTable; + } } diff --git a/src/main/java/com/nis/domain/configuration/BaseCfg.java b/src/main/java/com/nis/domain/configuration/BaseCfg.java index 5701759c2..916d02428 100644 --- a/src/main/java/com/nis/domain/configuration/BaseCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseCfg.java @@ -9,6 +9,7 @@ package com.nis.domain.configuration; import java.util.Date; +import java.util.List; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; @@ -22,6 +23,9 @@ import com.nis.domain.BaseEntity; * @version V1.0 */ public class BaseCfg extends BaseEntity implements Cloneable{ + protected Integer areaType; + protected List areaIsp; + protected List areaCfg; protected String showName;//表在界面上展示的名称 protected String seltype;//选中类型,页面搜索用 protected String tableName; @@ -672,5 +676,60 @@ public class BaseCfg extends BaseEntity implements Cloneable{ // TODO Auto-generated method stub return super.clone(); } + /** + * areaCfg + * @return areaCfg + */ + public List getAreaCfg() { + return areaCfg; + } + /** + * @param areaCfg the areaCfg to set + */ + public void setAreaCfg(List areaCfg) { + this.areaCfg = areaCfg; + } + /** + * showName + * @return showName + */ + + public String getShowName() { + return showName; + } + /** + * @param showName the showName to set + */ + public void setShowName(String showName) { + this.showName = showName; + } + /** + * areaIsp + * @return areaIsp + */ + + public List getAreaIsp() { + return areaIsp; + } + /** + * @param areaIsp the areaIsp to set + */ + public void setAreaIsp(List areaIsp) { + this.areaIsp = areaIsp; + } + /** + * areaType + * @return areaType + */ + + public Integer getAreaType() { + return areaType; + } + /** + * @param areaType the areaType to set + */ + public void setAreaType(Integer areaType) { + this.areaType = areaType; + } } diff --git a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java index dea1199df..ce2cb2758 100644 --- a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java @@ -25,6 +25,15 @@ public class BaseIpCfg extends BaseCfg { * @since 1.0.0 */ private static final long serialVersionUID = -1939538118388300002L; + + /** + * 创建一个新的实例 BaseIpCfg. + * + */ + public BaseIpCfg() { + super(); + // TODO Auto-generated constructor stub + } /** * ip类型 */ diff --git a/src/main/java/com/nis/util/Constants.java b/src/main/java/com/nis/util/Constants.java index c9994e0e5..c0cba54fa 100644 --- a/src/main/java/com/nis/util/Constants.java +++ b/src/main/java/com/nis/util/Constants.java @@ -5,6 +5,16 @@ import java.util.Date; import com.google.gson.GsonBuilder; public final class Constants { + /** + * 区域GK类型 + */ + public static final int AREA_EFFECTIVE_TYPE_AREA_ISP = 1; + public static final int AREA_EFFECTIVE_TYPE_AREA_IP = 0; + /** + * 是否区域GK + */ + public static final int IS_AREA_EFFECTIVE_YES = 1; + public static final int IS_AREA_EFFECTIVE_NO = 0; /** * 字典表地域运营商 */ 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 18b647137..a519a8a8d 100644 --- a/src/main/java/com/nis/web/controller/configuration/ComplexStringCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/ComplexStringCfgController.java @@ -89,6 +89,10 @@ public class ComplexStringCfgController extends BaseController{ cfg.setTableName(tableName); cfg.initDefaultValue(); cfg.setAction(action); + //监测缺省不需要区域管控 + if(action==Constants.ACTION_DJ){ + cfg.setIsAreaEffective(0); + } cfg.setServiceId(serviceId); model.addAttribute("_cfg", cfg); model.addAttribute("tableName", tableName); @@ -171,10 +175,12 @@ public class ComplexStringCfgController extends BaseController{ cfg.setTableName(tableName); } } - int compileId = new ConvertTool().getCompileId(); + if(cfg.getCompileId()==null){ + int compileId = new ConvertTool().getCompileId().intValue(); + cfg.setCompileId(compileId); + } 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()); 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 45bb1c374..bf1a87026 100644 --- a/src/main/java/com/nis/web/controller/configuration/IpCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/IpCfgController.java @@ -1,5 +1,6 @@ package com.nis.web.controller.configuration; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -12,14 +13,16 @@ 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.servlet.mvc.support.RedirectAttributes; import com.nis.domain.Page; import com.nis.domain.ServiceConfigInfo; import com.nis.domain.basics.ServiceDictInfo; +import com.nis.domain.basics.SysDictInfo; +import com.nis.domain.configuration.AreaBean; +import com.nis.domain.configuration.AreaIpCfg; import com.nis.domain.configuration.BaseIpCfg; import com.nis.domain.configuration.RequestInfo; +import com.nis.exceptions.ServiceException; import com.nis.main.ConvertTool; import com.nis.util.Constants; import com.nis.web.controller.BaseController; @@ -124,6 +127,10 @@ public class IpCfgController extends BaseController{ ipcfg.setTableName(tableName); ipcfg.initDefaultValue(); ipcfg.setAction(action); + //监测缺省不需要区域管控 + if(action==Constants.ACTION_DJ){ + ipcfg.setIsAreaEffective(0); + } ipcfg.setServiceId(serviceId); model.addAttribute("_cfg", ipcfg); model.addAttribute("tableName", tableName); @@ -135,6 +142,18 @@ public class IpCfgController extends BaseController{ model.addAttribute("xzs", xzs); List lables=serviceDictInfoService.findLableDict(); model.addAttribute("lables", lables); + List itTypeList=new ArrayList(); + itTypeList.add(Constants.ITEM_TYPE_AREA); + List areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null); + model.addAttribute("areas", areas); + itTypeList.clear(); + itTypeList.add(Constants.ITEM_TYPE_ISP); + List isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null); + model.addAttribute("isps", isps); + //初始化一个默认的地域ip给界面 + AreaIpCfg areaIpCfg=new AreaIpCfg(); + areaIpCfg.initDefaultValue(); + model.addAttribute("_areaCfg", areaIpCfg); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { // TODO Auto-generated catch block logger.error("打开新增IP窗口失败",e); @@ -172,6 +191,12 @@ public class IpCfgController extends BaseController{ model.addAttribute("serviceId", serviceId); model.addAttribute("action", action); model.addAttribute("audit",Constants.CFG_PAGE); + if(StringUtils.isBlank(tableName)){ + ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); + if(serviceConfigInfo!=null){ + tableName=serviceConfigInfo.getTableName(); + } + } if(!StringUtils.isBlank(tableName)){ logger.info("table name is "+tableName); BaseIpCfg searchBean=new BaseIpCfg(); @@ -180,6 +205,37 @@ public class IpCfgController extends BaseController{ BaseIpCfg ipCfg=ipCfgService.getIpCfgById(searchBean); model.addAttribute("_cfg", ipCfg); model.addAttribute("tableName", tableName); + int compileId=ipCfg.getCompileId(); + //查询配置对应的地域ip + List areaCfgs=ipCfgService.getAreaCfgByCompileId(compileId); + model.addAttribute("areaCfgs", areaCfgs); + StringBuffer areaCfgIds=new StringBuffer(); + for(AreaIpCfg areaCfg:areaCfgs){ + areaCfgIds.append(areaCfg.getCfgId()+","); + } + //update时判断是否有删除地域ip + model.addAttribute("areaCfgIds", areaCfgIds.toString()); + //初始化一个默认的地域ip给界面 + AreaIpCfg areaIpCfg=new AreaIpCfg(); + areaIpCfg.initDefaultValue(); + model.addAttribute("_areaCfg", areaIpCfg); + //从区域生效ID中获取区域与运营商 + String areaEffectiveIds=ipCfg.getAreaEffectiveIds(); + List areaIspList=new ArrayList(); + if(StringUtils.isNotBlank(areaEffectiveIds)){ + String[] areaIsps=areaEffectiveIds.split(","); + for(String areaIsp:areaIsps){ + AreaBean area=new AreaBean(); + if(areaIsp.contains(":")){ + area.setArea(areaIsp.split(":")[0]); + area.setIsp(areaIsp.split(":")[1]); + }else{ + area.setArea(areaIsp); + } + areaIspList.add(area); + } + } + model.addAttribute("_areaIsps", areaIspList); List requestInfos=requestInfoService.getAllRequestInfo(); model.addAttribute("requestInfos", requestInfos); List fls=serviceDictInfoService.findAllFlDict(); @@ -188,29 +244,14 @@ public class IpCfgController 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); - BaseIpCfg searchBean=new BaseIpCfg(); - searchBean.setCfgId(cfgId); - searchBean.setTableName(tableName); - BaseIpCfg ipCfg=ipCfgService.getIpCfgById(searchBean); - model.addAttribute("_cfg", ipCfg); - model.addAttribute("tableName", tableName); - 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); - - } - } + List itTypeList=new ArrayList(); + itTypeList.add(Constants.ITEM_TYPE_AREA); + List areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null); + model.addAttribute("areas", areas); + itTypeList.clear(); + itTypeList.add(Constants.ITEM_TYPE_ISP); + List isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null); + model.addAttribute("isps", isps); }else{ logger.error("未获取到正确的表名"); } @@ -228,7 +269,7 @@ public class IpCfgController extends BaseController{ * @since 1.0.0 */ @RequestMapping(value = {"saveOrUpdateCfg"}) - public String saveOrUpdateIpCfg(String cfgName,Model model, BaseIpCfg ipCfg) { + public String saveOrUpdateIpCfg(String cfgName,Model model, BaseIpCfg ipCfg,String areaCfgIds) { model.addAttribute("cfgName",cfgName); model.addAttribute("cfgType", "ip"); model.addAttribute("audit", Constants.CFG_PAGE); @@ -238,6 +279,38 @@ public class IpCfgController extends BaseController{ logger.info("saveOrUpdateIpCfg loaded"); try{ String tableName=ipCfg.getTableName(); + List areaCfg=ipCfg.getAreaCfg(); + List areaIsps=ipCfg.getAreaIsp(); + if(Constants.IS_AREA_EFFECTIVE_NO==ipCfg.getIsAreaEffective()){ + ipCfg.setAreaEffectiveIds(""); + ipCfg.setAreaType(null); + }else if(Constants.IS_AREA_EFFECTIVE_YES==ipCfg.getIsAreaEffective()){ + if(Constants.AREA_EFFECTIVE_TYPE_AREA_ISP==ipCfg.getAreaType()&&areaIsps!=null&&areaIsps.size()>0){ + StringBuffer areaEffectiveIds=new StringBuffer(); + for(int i=0;i0){ + ipCfg.setAreaEffectiveIds(""); + }else{ + logger.error("区域管控,但是地域+ISP以及地域IP全部为空!"); + addMessage(model,"save_failed"); + return "/cfg/resultPage"; + } + } int serviceId=ipCfg.getServiceId(); if(StringUtils.isBlank(tableName)){ ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); @@ -246,23 +319,98 @@ public class IpCfgController extends BaseController{ ipCfg.setTableName(tableName); } } - int compileId=new ConvertTool().getCompileId().intValue(); + if(ipCfg.getCompileId()==null){ + int compileId=new ConvertTool().getCompileId().intValue(); + ipCfg.setCompileId(compileId); + } + Date date=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()); - ipCfgService.addIpCfg(ipCfg); + ipCfg.setCreateTime(date); + if(Constants.IS_AREA_EFFECTIVE_YES==ipCfg.getIsAreaEffective()&&areaCfg!=null){ + for(AreaIpCfg area:areaCfg){ + area.setTableName(AreaIpCfg.getTablename()); + area.setServiceId(serviceId); + area.setCompileId(ipCfg.getCompileId()); + area.setAction(ipCfg.getAction()); + area.setIsValid(Constants.VALID_NO); + area.setIsAudit(Constants.AUDIT_NOT_YET); + area.setRequestId(ipCfg.getRequestId()); + area.setClassify(ipCfg.getClassify()); + area.setAttribute(ipCfg.getAttribute()); + area.setLable(ipCfg.getLable()); + area.setCreatorId(ipCfg.getCurrentUser().getId()); + area.setCreateTime(date); + } + } + ipCfgService.addIpCfg(ipCfg,areaCfg); }else{ ipCfg.setEditorId(ipCfg.getCurrentUser().getId()); ipCfg.setEditTime(new Date()); - ipCfgService.updateIpCfg(ipCfg); + List updateAreaCfg=new ArrayList<>(); + List deleteAreaCfg=new ArrayList<>(); + List addAreaCfg=new ArrayList<>(); + String[] cfgIds=null; + if(!StringUtils.isBlank(areaCfgIds)){ + cfgIds=areaCfgIds.split(","); + } + if(Constants.IS_AREA_EFFECTIVE_YES==ipCfg.getIsAreaEffective()&&areaCfg!=null){ + for(AreaIpCfg area:areaCfg){ + area.setTableName(AreaIpCfg.getTablename()); + area.setServiceId(serviceId); + area.setCompileId(ipCfg.getCompileId()); + area.setAction(ipCfg.getAction()); + area.setIsValid(Constants.VALID_NO); + area.setIsAudit(Constants.AUDIT_NOT_YET); + area.setRequestId(ipCfg.getRequestId()); + area.setClassify(ipCfg.getClassify()); + area.setAttribute(ipCfg.getAttribute()); + area.setLable(ipCfg.getLable()); + if(area.getCfgId()==null){ + area.setCreatorId(ipCfg.getCurrentUser().getId()); + area.setCreateTime(date); + addAreaCfg.add(area); + }else if(cfgIds!=null){ + area.setEditorId(ipCfg.getCurrentUser().getId()); + area.setEditTime(date); + boolean contains=false; + for(String cfgId:cfgIds){ + if(!StringUtils.isBlank(cfgId)&&area.getCfgId().longValue()==Long.parseLong(cfgId)){ + contains=true; + break; + } + } + if(contains){ + updateAreaCfg.add(area); + }else{ + deleteAreaCfg.add(area); + } + } + } + }else{ + if(cfgIds!=null){ + for(String cfgId:cfgIds){ + if(!StringUtils.isBlank(cfgId)){ + AreaIpCfg area=new AreaIpCfg(); + area.setTableName(AreaIpCfg.getTablename()); + area.setIsValid(Constants.VALID_DEL); + area.setCfgId(Long.parseLong(cfgId)); + area.setEditorId(ipCfg.getCurrentUser().getId()); + area.setEditTime(date); + deleteAreaCfg.add(area); + + } + } + } + } + ipCfgService.updateIpCfg(ipCfg,addAreaCfg,updateAreaCfg,deleteAreaCfg); } - addMessage(model,"保存成功,正在为您跳转页面..."); + addMessage(model,"save_success"); }catch(Exception e){ logger.error("保存失败",e); - addMessage(model,"保存失败!"); + addMessage(model,"save_failed"); } return "/cfg/resultPage"; } @@ -314,15 +462,15 @@ public class IpCfgController extends BaseController{ } int result=ipCfgService.auditIpCfg(bean,ipCfg); if(result!=0){ - addMessage(model,"审核成功!"); + addMessage(model,"audit_success"); }else{ - addMessage(model, "审核失败"); + addMessage(model, "audit_failed"); } } }catch(Exception e){ logger.error("审核失败", e); - addMessage(model, "审核失败"); + addMessage(model, "audit_failed"); } return "/cfg/resultPage"; } @@ -361,14 +509,14 @@ public class IpCfgController extends BaseController{ ipCfg.setIsValid(Constants.VALID_DEL); int result=ipCfgService.deleteIpCfg(ipCfg); model.addAttribute("tableName", tableName); - addMessage(model,"删除成功,正在为您跳转页面..."); + addMessage(model,"delete_success"); }else{ logger.error("通过审核的配置不能删除!"); - addMessage(model,"删除失败!"); + addMessage(model,"delete_failed"); } }catch(Exception e){ logger.error("删除失败", e); - addMessage(model,"删除失败!"); + addMessage(model,"delete_failed"); } return "/cfg/resultPage"; } 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 52e509a12..18d57062e 100644 --- a/src/main/java/com/nis/web/controller/configuration/NumCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/NumCfgController.java @@ -73,6 +73,10 @@ public class NumCfgController extends BaseController{ NumBoundaryCfg cfg=new NumBoundaryCfg(); cfg.initDefaultValue(); cfg.setAction(action); + //监测缺省不需要区域管控 + if(action==Constants.ACTION_DJ){ + cfg.setIsAreaEffective(0); + } cfg.setServiceId(serviceId); model.addAttribute("_cfg", cfg); List requestInfos=requestInfoService.getValidRequestInfo(); @@ -139,10 +143,12 @@ public class NumCfgController extends BaseController{ int serviceId=cfg.getServiceId(); ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId); if(serviceConfigInfo!=null){ - int compileId=new ConvertTool().getCompileId(); + if(cfg.getCompileId()==null){ + int compileId=new ConvertTool().getCompileId(); + cfg.setCompileId(compileId); + } 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()); 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 6b7a5d4a1..c6905b36d 100644 --- a/src/main/java/com/nis/web/controller/configuration/StringCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/StringCfgController.java @@ -90,6 +90,10 @@ public class StringCfgController extends BaseController{ stringcfg.setTableName(tableName); stringcfg.initDefaultValue(); stringcfg.setAction(action); + //监测缺省不需要区域管控 + if(action==Constants.ACTION_DJ){ + stringcfg.setIsAreaEffective(0); + } stringcfg.setServiceId(serviceId); model.addAttribute("_cfg", stringcfg); model.addAttribute("tableName", tableName); @@ -176,10 +180,12 @@ public class StringCfgController extends BaseController{ stringCfg.setTableName(tableName); } } - int compileId=new ConvertTool().getCompileId(); + if(stringCfg.getCompileId()==null){ + int compileId=new ConvertTool().getCompileId(); + stringCfg.setCompileId(compileId); + } 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()); diff --git a/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java b/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java new file mode 100644 index 000000000..117d36d35 --- /dev/null +++ b/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java @@ -0,0 +1,30 @@ +package com.nis.web.dao.configuration; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.nis.domain.configuration.AreaIpCfg; +import com.nis.web.dao.CrudDao; +import com.nis.web.dao.MyBatisDao; + +/** + * IP相关配置数据处理类 + * @author dell + * + */ +@MyBatisDao +public interface AreaIpCfgDao extends CrudDao{ + public AreaIpCfg getById(@Param("cfgId")Long id) ; + public List findList(AreaIpCfg entity) ; + public List getByCompileId(@Param("compileId") int compileId) ; + public int insert(AreaIpCfg entity) ; + public int updateByPrimaryKeySelective(AreaIpCfg entity) ; + public int updateValid(AreaIpCfg entity) ; + public int audit(AreaIpCfg entity) ; + public int getIsValid(@Param("cfgId")Long id); + public int getIsValid(AreaIpCfg entity); + public int getIsAudit(@Param("cfgId")Long id); + public int getIsAudit(AreaIpCfg entity); + public int deleteByCompileId(AreaIpCfg entity); +} diff --git a/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.xml new file mode 100644 index 000000000..d25e9b549 --- /dev/null +++ b/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CFG_ID, CFG_DESC, IP_TYPE, SRC_IP, SRC_IP_MASK, SRC_PORT, + SRC_PORT_MASK ,DST_IP ,DST_IP_MASK, DST_PORT, DST_PORT_MASK, + DIRECTION,PROTOCOL,PROTOCOL_ID,ACTION,IS_VALID,IS_AUDIT, + CREATOR_ID,CREATE_TIME,EDITOR_ID,EDIT_TIME,AUDITOR_ID,AUDIT_TIME, + SERVICE_ID,REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,CLASSIFY, + ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS + + + \ No newline at end of file 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 7e18c1397..36ca8bba7 100644 --- a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml @@ -527,7 +527,7 @@ lable = #{lable,jdbcType=VARCHAR}, - + area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR} @@ -553,6 +553,9 @@ 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 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} diff --git a/src/main/java/com/nis/web/service/CrudService.java b/src/main/java/com/nis/web/service/CrudService.java index 6e23be1d5..1bc6fb700 100644 --- a/src/main/java/com/nis/web/service/CrudService.java +++ b/src/main/java/com/nis/web/service/CrudService.java @@ -29,6 +29,7 @@ import com.nis.domain.maat.UnAuditBean; import com.nis.main.ConvertTool; import com.nis.util.Constants; import com.nis.web.dao.CrudDao; +import com.nis.web.dao.configuration.IpCfgDao; /** * Service基类 @@ -124,6 +125,25 @@ public abstract class CrudService, T extends BaseEntity> batchSqlSession.commit(); // }catch (Exception e){ // batchSqlSession.rollback(); +// throw e; + }finally { + if(batchSqlSession != null){ + batchSqlSession.close(); + } + } + } + public void saveIpBatch(List areaIpCfgs) { + SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); + SqlSession batchSqlSession = null; + try{ + batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); + for(int index = 0; index < areaIpCfgs.size();index++){ + BaseIpCfg t = areaIpCfgs.get(index); + ((CrudDao) batchSqlSession.getMapper(IpCfgDao.class)).insert(t); + } + batchSqlSession.commit(); +// }catch (Exception e){ +// batchSqlSession.rollback(); // throw e; }finally { if(batchSqlSession != null){ @@ -135,7 +155,7 @@ public abstract class CrudService, T extends BaseEntity> * * updateBatch(批量更新全部数据) * (这里描述这个方法适用条件 – 可选) - * @param data 数据集合 + * @param areaCfg 数据集合 * @param mClass 传入的dao.xml里的mapper * @author wx * @since 1.0.0 @@ -143,12 +163,32 @@ public abstract class CrudService, T extends BaseEntity> @SuppressWarnings("unchecked") public void updateBatch(List data,@SuppressWarnings("rawtypes") Class mClass) { SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); + SqlSession batchSqlSession = null; + try{ + batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); + for(int index = 0; index < data.size();index++){ + T t = data.get(index); + ((CrudDao) batchSqlSession.getMapper(mClass)).update(t); + } + batchSqlSession.commit(); +// }catch (Exception e){ +// batchSqlSession.rollback(); +// throw e; + }finally { + if(batchSqlSession != null){ + batchSqlSession.close(); + } + } + } + @SuppressWarnings("unchecked") + public void updateIpBatch(List areaCfg) { + SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); SqlSession batchSqlSession = null; try{ batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); - for(int index = 0; index < data.size();index++){ - T t = data.get(index); - ((CrudDao) batchSqlSession.getMapper(mClass)).update(t); + for(int index = 0; index < areaCfg.size();index++){ + BaseIpCfg t = areaCfg.get(index); + ((CrudDao) batchSqlSession.getMapper(IpCfgDao.class)).update(t); } batchSqlSession.commit(); // }catch (Exception e){ @@ -183,6 +223,25 @@ public abstract class CrudService, T extends BaseEntity> batchSqlSession.commit(); // }catch (Exception e){ // batchSqlSession.rollback(); +// throw e; + }finally { + if(batchSqlSession != null){ + batchSqlSession.close(); + } + } + } + public void deleteIpBatch(List data) { + SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); + SqlSession batchSqlSession = null; + try{ + batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); + for(int index = 0; index < data.size();index++){ + BaseIpCfg t = data.get(index); + ((CrudDao) batchSqlSession.getMapper(IpCfgDao.class)).delete(t); + } + batchSqlSession.commit(); +// }catch (Exception e){ +// batchSqlSession.rollback(); // throw e; }finally { if(batchSqlSession != null){ diff --git a/src/main/java/com/nis/web/service/configuration/IpCfgService.java b/src/main/java/com/nis/web/service/configuration/IpCfgService.java index bb73a2d7b..b06a3b31c 100644 --- a/src/main/java/com/nis/web/service/configuration/IpCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/IpCfgService.java @@ -1,11 +1,15 @@ package com.nis.web.service.configuration; +import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.nis.domain.configuration.AreaIpCfg; import com.nis.domain.configuration.BaseIpCfg; import com.nis.util.Constants; +import com.nis.web.dao.configuration.AreaIpCfgDao; import com.nis.web.dao.configuration.IpCfgDao; import com.nis.web.service.CrudService; @@ -18,6 +22,8 @@ import com.nis.web.service.CrudService; public class IpCfgService extends CrudService { @Autowired protected IpCfgDao ipCfgDao; + @Autowired + protected AreaIpCfgDao areaIpCfgDao; /** * * addIpCfg(新增IP类配置) @@ -29,7 +35,10 @@ public class IpCfgService extends CrudService { * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int addIpCfg(BaseIpCfg baseIpCfg){ + public int addIpCfg(BaseIpCfg baseIpCfg,List areaIpCfgs){ + if(areaIpCfgs!=null&&areaIpCfgs.size()>0){ + this.saveIpBatch(areaIpCfgs); + } return ipCfgDao.insert(baseIpCfg); } /** @@ -43,7 +52,16 @@ public class IpCfgService extends CrudService { * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int updateIpCfg(BaseIpCfg baseIpCfg){ + public int updateIpCfg(BaseIpCfg baseIpCfg,List addAreaCfg,List updateAreaCfg,List deleteAreaCfgs){ + if(addAreaCfg!=null&&addAreaCfg.size()>0){ + this.saveIpBatch(addAreaCfg); + } + if(updateAreaCfg!=null&&updateAreaCfg.size()>0){ + this.updateIpBatch(updateAreaCfg); + } + if(deleteAreaCfgs!=null&&deleteAreaCfgs.size()>0){ + this.deleteIpBatch(deleteAreaCfgs); + } return ipCfgDao.updateByPrimaryKeySelective(baseIpCfg); } /** @@ -110,4 +128,7 @@ public class IpCfgService extends CrudService { public Integer getIsAudit(String tableName, long id){ return ipCfgDao.getIsAudit(tableName,id); } + public List getAreaCfgByCompileId(int compileId){ + return areaIpCfgDao.getByCompileId(compileId); + } } diff --git a/src/main/webapp/WEB-INF/include/form/areaInfo.jsp b/src/main/webapp/WEB-INF/include/form/areaInfo.jsp new file mode 100644 index 000000000..3c5005f79 --- /dev/null +++ b/src/main/webapp/WEB-INF/include/form/areaInfo.jsp @@ -0,0 +1,432 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + + diff --git a/src/main/webapp/WEB-INF/include/form/ipInfo.jsp b/src/main/webapp/WEB-INF/include/form/ipInfo.jsp index 15a1164a2..1d3e18adc 100644 --- a/src/main/webapp/WEB-INF/include/form/ipInfo.jsp +++ b/src/main/webapp/WEB-INF/include/form/ipInfo.jsp @@ -185,24 +185,34 @@ - <%-- --%> + + +
-
-
- + diff --git a/src/main/webapp/WEB-INF/include/form/stringInfo.jsp b/src/main/webapp/WEB-INF/include/form/stringInfo.jsp index 651fa435a..b811e59f9 100644 --- a/src/main/webapp/WEB-INF/include/form/stringInfo.jsp +++ b/src/main/webapp/WEB-INF/include/form/stringInfo.jsp @@ -86,14 +86,18 @@ - <%-- --%> + + +
diff --git a/src/main/webapp/WEB-INF/views/cfg/complexCfgForm.jsp b/src/main/webapp/WEB-INF/views/cfg/complexCfgForm.jsp index 10860cc04..f69e17730 100644 --- a/src/main/webapp/WEB-INF/views/cfg/complexCfgForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/complexCfgForm.jsp @@ -91,6 +91,9 @@ $(function(){ + + + diff --git a/src/main/webapp/WEB-INF/views/cfg/ipCfgForm.jsp b/src/main/webapp/WEB-INF/views/cfg/ipCfgForm.jsp index dff2b7e1f..8c04ba916 100644 --- a/src/main/webapp/WEB-INF/views/cfg/ipCfgForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/ipCfgForm.jsp @@ -6,6 +6,50 @@ @@ -210,6 +263,9 @@ $(function(){ + + + @@ -217,14 +273,13 @@ $(function(){ + <%@include file="/WEB-INF/include/form/areaInfo.jsp" %> <%@include file="/WEB-INF/include/form/basicInfo.jsp" %> - -
diff --git a/src/main/webapp/WEB-INF/views/cfg/stringCfgForm.jsp b/src/main/webapp/WEB-INF/views/cfg/stringCfgForm.jsp index ee70af6ea..e95d24a2b 100644 --- a/src/main/webapp/WEB-INF/views/cfg/stringCfgForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/stringCfgForm.jsp @@ -100,6 +100,9 @@ $(function(){ + + + @@ -107,6 +110,7 @@ $(function(){ + <%@include file="/WEB-INF/include/form/areaInfo.jsp" %> <%@include file="/WEB-INF/include/form/basicInfo.jsp" %>