(1)IP类配置增加区域GK逻辑

(2)修复编译ID的重复获取BUG
(3)监测类配置目前不提供区域管控逻辑
This commit is contained in:
wangxin
2018-04-08 16:15:06 +08:00
parent 1f6bbc20ce
commit aaf8dd5afb
20 changed files with 1133 additions and 107 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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<T> extends BaseEntity<T> implements Cloneable{
protected Integer areaType;
protected List<AreaBean> areaIsp;
protected List<AreaIpCfg> areaCfg;
protected String showName;//表在界面上展示的名称
protected String seltype;//选中类型,页面搜索用
protected String tableName;
@@ -672,5 +676,60 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
// TODO Auto-generated method stub
return super.clone();
}
/**
* areaCfg
* @return areaCfg
*/
public List<AreaIpCfg> getAreaCfg() {
return areaCfg;
}
/**
* @param areaCfg the areaCfg to set
*/
public void setAreaCfg(List<AreaIpCfg> 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<AreaBean> getAreaIsp() {
return areaIsp;
}
/**
* @param areaIsp the areaIsp to set
*/
public void setAreaIsp(List<AreaBean> 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;
}
}

View File

@@ -25,6 +25,15 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
* @since 1.0.0
*/
private static final long serialVersionUID = -1939538118388300002L;
/**
* 创建一个新的实例 BaseIpCfg.
*
*/
public BaseIpCfg() {
super();
// TODO Auto-generated constructor stub
}
/**
* ip类型
*/

View File

@@ -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;
/**
* 字典表地域运营商
*/

View File

@@ -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());

View File

@@ -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<ServiceDictInfo> lables=serviceDictInfoService.findLableDict();
model.addAttribute("lables", lables);
List<Integer> itTypeList=new ArrayList<Integer>();
itTypeList.add(Constants.ITEM_TYPE_AREA);
List<SysDictInfo> areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
model.addAttribute("areas", areas);
itTypeList.clear();
itTypeList.add(Constants.ITEM_TYPE_ISP);
List<SysDictInfo> 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<AreaIpCfg> 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<AreaBean> areaIspList=new ArrayList<AreaBean>();
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<RequestInfo> requestInfos=requestInfoService.getAllRequestInfo();
model.addAttribute("requestInfos", requestInfos);
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
@@ -188,29 +244,14 @@ public class IpCfgController extends BaseController{
model.addAttribute("xzs", xzs);
List<ServiceDictInfo> 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<RequestInfo> requestInfos=requestInfoService.getAllRequestInfo();
model.addAttribute("requestInfos", requestInfos);
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
model.addAttribute("fls", fls);
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
model.addAttribute("xzs", xzs);
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
model.addAttribute("lables", lables);
}
}
List<Integer> itTypeList=new ArrayList<Integer>();
itTypeList.add(Constants.ITEM_TYPE_AREA);
List<SysDictInfo> areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
model.addAttribute("areas", areas);
itTypeList.clear();
itTypeList.add(Constants.ITEM_TYPE_ISP);
List<SysDictInfo> 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<AreaIpCfg> areaCfg=ipCfg.getAreaCfg();
List<AreaBean> 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;i<areaIsps.size();i++){
if(StringUtils.isNotBlank(areaIsps.get(i).getIsp())){
areaEffectiveIds.append(areaIsps.get(i).getArea()+":"+areaIsps.get(i).getIsp());
}else{
areaEffectiveIds.append(areaIsps.get(i).getArea());
}
if(i!=areaIsps.size()-1){
areaEffectiveIds.append(",");
}
}
if(StringUtils.isBlank(areaEffectiveIds.toString())){
logger.error("区域管控,且按照地域运营商管控,但是地域运营商为空!");
addMessage(model,"save_failed");
return "/cfg/resultPage";
}
ipCfg.setAreaEffectiveIds(areaEffectiveIds.toString());
}else if(Constants.AREA_EFFECTIVE_TYPE_AREA_IP==ipCfg.getAreaType()&&areaCfg!=null&&areaCfg.size()>0){
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<AreaIpCfg> updateAreaCfg=new ArrayList<>();
List<AreaIpCfg> deleteAreaCfg=new ArrayList<>();
List<AreaIpCfg> 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";
}

View File

@@ -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<RequestInfo> 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());

View File

@@ -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());

View File

@@ -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<AreaIpCfg>{
public AreaIpCfg getById(@Param("cfgId")Long id) ;
public List<AreaIpCfg> findList(AreaIpCfg entity) ;
public List<AreaIpCfg> 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);
}

View File

@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.nis.web.dao.configuration.AreaIpCfgDao" >
<resultMap id="BaseIpMap" type="com.nis.domain.configuration.AreaIpCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="ip_type" property="ipType" jdbcType="INTEGER" />
<result column="src_ip" property="srcIp" jdbcType="VARCHAR" />
<result column="src_ip_mask" property="srcIpMask" jdbcType="VARCHAR" />
<result column="src_port" property="srcPort" jdbcType="VARCHAR" />
<result column="src_port_mask" property="srcPortMask" jdbcType="VARCHAR" />
<result column="dst_ip" property="dstIp" jdbcType="VARCHAR" />
<result column="dst_ip_mask" property="dstIpMask" jdbcType="VARCHAR" />
<result column="dst_port" property="dstPort" jdbcType="VARCHAR" />
<result column="dst_port_mask" property="dstPortMask" jdbcType="VARCHAR" />
<result column="direction" property="direction" jdbcType="INTEGER" />
<result column="protocol" property="protocol" jdbcType="INTEGER" />
<result column="protocol_id" property="protocolId" jdbcType="INTEGER" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="BaseIpMapWithUser" type="com.nis.domain.configuration.AreaIpCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="ip_type" property="ipType" jdbcType="INTEGER" />
<result column="src_ip" property="srcIp" jdbcType="VARCHAR" />
<result column="src_ip_mask" property="srcIpMask" jdbcType="VARCHAR" />
<result column="src_port" property="srcPort" jdbcType="VARCHAR" />
<result column="src_port_mask" property="srcPortMask" jdbcType="VARCHAR" />
<result column="dst_ip" property="dstIp" jdbcType="VARCHAR" />
<result column="dst_ip_mask" property="dstIpMask" jdbcType="VARCHAR" />
<result column="dst_port" property="dstPort" jdbcType="VARCHAR" />
<result column="dst_port_mask" property="dstPortMask" jdbcType="VARCHAR" />
<result column="direction" property="direction" jdbcType="INTEGER" />
<result column="protocol" property="protocol" jdbcType="INTEGER" />
<result column="protocol_id" property="protocolId" jdbcType="INTEGER" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="creator_name" property="creatorName" jdbcType="VARCHAR" />
<result column="auditor_name" property="auditorName" jdbcType="VARCHAR" />
<result column="editor_name" property="editorName" jdbcType="VARCHAR" />
</resultMap>
<sql id="AreaIpCfg_Column_List_with_id" >
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
</sql>
<select id="getByCompileId" resultMap="BaseIpMap" >
SELECT
<include refid="AreaIpCfg_Column_List_with_id" />
FROM area_ip_cfg
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="compileId != null">
AND COMPILE_ID=#{compileId,jdbcType=INTEGER}
</if>
AND IS_VALID!=-1
</trim>
</select>
</mapper>

View File

@@ -527,7 +527,7 @@
<if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR},
</if>
<if test="areaEffectiveIds != null and areaEffectiveIds != ''" >
<if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}
</if>
</trim>
@@ -553,6 +553,9 @@
SELECT IS_AUDIT FROM ${tableName}
WHERE CFG_ID = #{cfgId,jdbcType=BIGINT}
</select>
<update id="delete" parameterType="com.nis.domain.configuration.BaseIpCfg" >
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>
<update id="deleteByCompileId" parameterType="com.nis.domain.configuration.BaseIpCfg" >
update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER}, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER}
</update>

View File

@@ -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<D extends CrudDao<T>, T extends BaseEntity<T>>
batchSqlSession.commit();
// }catch (Exception e){
// batchSqlSession.rollback();
// throw e;
}finally {
if(batchSqlSession != null){
batchSqlSession.close();
}
}
}
public void saveIpBatch(List<AreaIpCfg> 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<BaseIpCfg>) 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<D extends CrudDao<T>, T extends BaseEntity<T>>
*
* updateBatch(批量更新全部数据)
* (这里描述这个方法适用条件 可选)
* @param data 数据集合
* @param areaCfg 数据集合
* @param mClass 传入的dao.xml里的mapper
* @author wx
* @since 1.0.0
@@ -143,12 +163,32 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
@SuppressWarnings("unchecked")
public void updateBatch(List<T> 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<T>) 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<AreaIpCfg> 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<T>) batchSqlSession.getMapper(mClass)).update(t);
for(int index = 0; index < areaCfg.size();index++){
BaseIpCfg t = areaCfg.get(index);
((CrudDao<BaseIpCfg>) batchSqlSession.getMapper(IpCfgDao.class)).update(t);
}
batchSqlSession.commit();
// }catch (Exception e){
@@ -183,6 +223,25 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
batchSqlSession.commit();
// }catch (Exception e){
// batchSqlSession.rollback();
// throw e;
}finally {
if(batchSqlSession != null){
batchSqlSession.close();
}
}
}
public void deleteIpBatch(List<AreaIpCfg> 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<BaseIpCfg>) batchSqlSession.getMapper(IpCfgDao.class)).delete(t);
}
batchSqlSession.commit();
// }catch (Exception e){
// batchSqlSession.rollback();
// throw e;
}finally {
if(batchSqlSession != null){

View File

@@ -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<IpCfgDao,BaseIpCfg> {
@Autowired
protected IpCfgDao ipCfgDao;
@Autowired
protected AreaIpCfgDao areaIpCfgDao;
/**
*
* addIpCfg(新增IP类配置)
@@ -29,7 +35,10 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
* @since 1.0.0
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int addIpCfg(BaseIpCfg baseIpCfg){
public int addIpCfg(BaseIpCfg baseIpCfg,List<AreaIpCfg> areaIpCfgs){
if(areaIpCfgs!=null&&areaIpCfgs.size()>0){
this.saveIpBatch(areaIpCfgs);
}
return ipCfgDao.insert(baseIpCfg);
}
/**
@@ -43,7 +52,16 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
* @since 1.0.0
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int updateIpCfg(BaseIpCfg baseIpCfg){
public int updateIpCfg(BaseIpCfg baseIpCfg,List<AreaIpCfg> addAreaCfg,List<AreaIpCfg> updateAreaCfg,List<AreaIpCfg> 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<IpCfgDao,BaseIpCfg> {
public Integer getIsAudit(String tableName, long id){
return ipCfgDao.getIsAudit(tableName,id);
}
public List<AreaIpCfg> getAreaCfgByCompileId(int compileId){
return areaIpCfgDao.getByCompileId(compileId);
}
}