diff --git a/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java b/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java index 341fdc732..2adcdbd10 100644 --- a/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java +++ b/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java @@ -27,7 +27,6 @@ public class CfgIndexInfo extends BaseCfg { private static final String tableName="cfg_index_info"; private List voipAccounts;//Add表单使用 private List voipIps; //Add表单使用 - private AreaIpCfg areaIpCfg; private AvVoipAccountCfg voipAccount;//Search使用 private AvVoipIpCfg voipIp;//Search使用 private IpPortCfg ipPort; @@ -143,11 +142,5 @@ public class CfgIndexInfo extends BaseCfg { public static String getTablename() { return tableName; } - public AreaIpCfg getAreaIpCfg() { - return areaIpCfg; - } - public void setAreaIpCfg(AreaIpCfg areaIpCfg) { - this.areaIpCfg = areaIpCfg; - } } diff --git a/src/main/java/com/nis/web/controller/configuration/ntc/AvContentController.java b/src/main/java/com/nis/web/controller/configuration/ntc/AvContentController.java index 1e638a916..00fe378f4 100644 --- a/src/main/java/com/nis/web/controller/configuration/ntc/AvContentController.java +++ b/src/main/java/com/nis/web/controller/configuration/ntc/AvContentController.java @@ -141,9 +141,12 @@ public class AvContentController extends BaseController { @RequestMapping(value = {"/contentIpForm"}) public String contIpForm(Model model,HttpServletRequest request,HttpServletResponse response,String ids,@ModelAttribute("cfg")AvContIpCfg cfg){ if(!StringUtil.isEmpty(ids)){ + cfg.setCfgId(Long.parseLong(ids)); cfg = avContentCfgService.getContIpCfgById(cfg); + initUpdateFormCondition(model, cfg); + }else{ + initFormCondition(model,cfg); } - initFormCondition(model,cfg); model.addAttribute("_cfg", cfg); return "/cfg/av/contIp/contIpForm"; } @@ -151,9 +154,10 @@ public class AvContentController extends BaseController { //保存voip信息 @RequestMapping(value = {"/saveContIp"}) public String saveContIp(Model model,HttpServletRequest request,HttpServletResponse response, - @ModelAttribute("cfg")AvContIpCfg cfg){ + @ModelAttribute("cfg")AvContIpCfg cfg, + @ModelAttribute("areaCfgIds")String areaCfgIds){ try{ - avContentCfgService.saveOrUpdateAvContIp(cfg); + avContentCfgService.saveOrUpdateAvContIp(cfg,areaCfgIds); addMessage(model,"save_success"); }catch(Exception e){ logger.error("信息保存失败",e); diff --git a/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java b/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java index 079a170d9..d5158c4e1 100644 --- a/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.java @@ -17,10 +17,9 @@ import com.nis.web.dao.MyBatisDao; @MyBatisDao public interface AreaIpCfgDao extends CrudDao{ public List getByCompileId(@Param("compileId") int compileId) ; - public List findAreaIpCfgList(CfgIndexInfo entity); public void saveAreaIpCfg(AreaIpCfg entity); - public void saveAreaIpCfgFromCfgIndexInfo(CfgIndexInfo entity); - public void updateAreaIpCfgFromCfgIndexInfo(CfgIndexInfo entity); + public void updateAreaIpCfg(AreaIpCfg entity); + public void updateAreaIpCfgValid(AreaIpCfg entity); public void deleteAreaIpCfg(AreaIpCfg entity); - public void deleteAreaIpCfgByCfgId(CfgIndexInfo entity); + public void deleteAreaIpCfgByCfgId(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 index cb8404011..59e94a196 100644 --- a/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/AreaIpCfgDao.xml @@ -52,26 +52,6 @@ AND IS_VALID!=-1 - - - @@ -141,76 +121,9 @@ #{cfgRegionCode,jdbcType=INTEGER} ) - - - insert into area_ip_cfg ( - CFG_DESC, - 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, - function_id, - ip_type, - src_ip_address, - ip_pattern, - port_pattern, - src_port, - protocol, - protocol_id, - direction, - dest_port, - dest_ip_address, - cfg_type, - cfg_region_code - )values ( - #{cfgDesc,jdbcType=VARCHAR}, - #{action,jdbcType=INTEGER}, - 0, - 0, - #{creatorId,jdbcType=INTEGER}, - #{createTime,jdbcType=TIMESTAMP}, - #{editorId,jdbcType=INTEGER}, - #{editTime,jdbcType=TIMESTAMP}, - #{auditorId,jdbcType=INTEGER}, - #{auditTime,jdbcType=TIMESTAMP}, - #{serviceId,jdbcType=INTEGER}, - #{requestId,jdbcType=INTEGER}, - #{compileId,jdbcType=INTEGER}, - #{isAreaEffective,jdbcType=INTEGER}, - #{classify,jdbcType=VARCHAR}, - #{attribute,jdbcType=VARCHAR}, - #{lable,jdbcType=VARCHAR}, - #{areaEffectiveIds,jdbcType=VARCHAR}, - #{functionId,jdbcType=INTEGER}, - #{areaIpCfg.ipType,jdbcType=INTEGER}, - #{areaIpCfg.srcIpAddress,jdbcType=VARCHAR}, - #{areaIpCfg.ipPattern,jdbcType=INTEGER}, - #{areaIpCfg.portPattern,jdbcType=INTEGER}, - #{areaIpCfg.srcPort,jdbcType=VARCHAR}, - #{areaIpCfg.protocol,jdbcType=INTEGER}, - #{areaIpCfg.protocolId,jdbcType=INTEGER}, - #{areaIpCfg.direction,jdbcType=INTEGER}, - #{areaIpCfg.destPort,jdbcType=VARCHAR}, - #{areaIpCfg.destIpAddress,jdbcType=VARCHAR}, - #{areaIpCfg.cfgType,jdbcType=VARCHAR}, - #{areaIpCfg.cfgRegionCode,jdbcType=INTEGER} - ) - + - + update area_ip_cfg @@ -265,47 +178,47 @@ service_id = #{serviceId,jdbcType=INTEGER}, - - ip_type = #{areaIpCfg.ipType,jdbcType=INTEGER}, + + ip_type = #{ipType,jdbcType=INTEGER}, - - src_ip_address = #{areaIpCfg.srcIpAddress,jdbcType=VARCHAR}, + + src_ip_address = #{srcIpAddress,jdbcType=VARCHAR}, - - ip_pattern = #{areaIpCfg.ipPattern,jdbcType=INTEGER}, + + ip_pattern = #{ipPattern,jdbcType=INTEGER}, - - port_pattern = #{areaIpCfg.portPattern,jdbcType=INTEGER}, + + port_pattern = #{portPattern,jdbcType=INTEGER}, - - src_port = #{areaIpCfg.srcPort,jdbcType=VARCHAR}, + + src_port = #{srcPort,jdbcType=VARCHAR}, - - protocol = #{areaIpCfg.protocol,jdbcType=INTEGER}, + + protocol = #{protocol,jdbcType=INTEGER}, - - protocol_id = #{areaIpCfg.protocolId,jdbcType=INTEGER}, + + protocol_id = #{protocolId,jdbcType=INTEGER}, - - direction = #{areaIpCfg.direction,jdbcType=INTEGER}, + + direction = #{direction,jdbcType=INTEGER}, - - dest_port = #{areaIpCfg.destPort,jdbcType=VARCHAR}, + + dest_port = #{destPort,jdbcType=VARCHAR}, - - dest_ip_address = #{areaIpCfg.destIpAddress,jdbcType=VARCHAR}, + + dest_ip_address = #{destIpAddress,jdbcType=VARCHAR}, - - cfg_type = #{areaIpCfg.cfgType,jdbcType=VARCHAR}, + + cfg_type = #{cfgType,jdbcType=VARCHAR}, - - cfg_region_code = #{areaIpCfg.cfgRegionCode,jdbcType=INTEGER}, + + cfg_region_code = #{cfgRegionCode,jdbcType=INTEGER}, - - and cfg_id = #{areaIpCfg.cfgId,jdbcType=INTEGER} + + and cfg_id = #{cfgId,jdbcType=INTEGER} and compile_id = #{compileId,jdbcType=INTEGER} @@ -319,20 +232,23 @@ delete from area_ip_cfg where compile_id=#{compileId} and function_id=#{functionId} + + update area_ip_cfg set is_valid = #{isValid,jdbcType=INTEGER}, + editor_id = #{editorId,jdbcType=INTEGER} , + edit_time = #{editTime,jdbcType=TIMESTAMP} + + + AND cfg_id = #{cfgId,jdbcType=BIGINT} + + + AND compile_id = #{compileId,jdbcType=INTEGER} + + and function_id=#{functionId,jdbcType=INTEGER} + + - delete from area_ip_cfg - - - and cfg_id = #{areaIpCfg.cfgId,jdbcType=INTEGER} - - - and compile_id = #{compileId,jdbcType=INTEGER} - - - and function_id = #{functionId,jdbcType=INTEGER} - - + delete from area_ip_cfg where cfg_id = #{cfgId,jdbcType=INTEGER} \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/configuration/AvContentCfgDao.java b/src/main/java/com/nis/web/dao/configuration/AvContentCfgDao.java index 36179a6e4..f918f19d7 100644 --- a/src/main/java/com/nis/web/dao/configuration/AvContentCfgDao.java +++ b/src/main/java/com/nis/web/dao/configuration/AvContentCfgDao.java @@ -31,7 +31,7 @@ public interface AvContentCfgDao { public void updateAvVoipAccount(CfgIndexInfo entity); public void deleteAvVoipIp(CfgIndexInfo entity); public void deleteAvVoipAccount(CfgIndexInfo entity); - public AvContIpCfg findVoipIpCfgById(AvContIpCfg entity) ; + public AvContIpCfg findContIpCfgById(AvContIpCfg entity) ; public void insertAvContIp(AvContIpCfg entity); public void updateAvContIp(AvContIpCfg entity); } diff --git a/src/main/java/com/nis/web/service/configuration/AvContentCfgService.java b/src/main/java/com/nis/web/service/configuration/AvContentCfgService.java index 8d6ab4c2e..737114318 100644 --- a/src/main/java/com/nis/web/service/configuration/AvContentCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/AvContentCfgService.java @@ -177,8 +177,8 @@ public class AvContentCfgService extends BaseService{ //保存区域IP信息 if(entity.getAreaCfg()!=null&&entity.getAreaCfg().size()>0){ for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) { - entity.setAreaIpCfg(areaIpCfg); - areaIpCfgDao.saveAreaIpCfgFromCfgIndexInfo(entity); + BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(areaIpCfg); } } //保存cfgIndexInfo @@ -237,7 +237,7 @@ public class AvContentCfgService extends BaseService{ avContentCfgDao.insertAvVoipAccount(entity); } } - } + } if(!StringUtil.isEmpty(entity.getAreaCfg())){ for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) { if(!StringUtil.isEmpty(areaIpCfg.getCfgId())){ @@ -247,14 +247,14 @@ public class AvContentCfgService extends BaseService{ //修改 entity.setEditorId(UserUtils.getUser().getId()); entity.setEditTime(editTime); - entity.setAreaIpCfg(areaIpCfg); - areaIpCfgDao.updateAreaIpCfgFromCfgIndexInfo(entity); + BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode","cfgType","cfgId"}); + areaIpCfgDao.updateAreaIpCfg(areaIpCfg); }else{ //新增 entity.setCreatorId(UserUtils.getUser().getId()); entity.setCreateTime(createTime); - entity.setAreaIpCfg(areaIpCfg); - areaIpCfgDao.saveAreaIpCfgFromCfgIndexInfo(entity); + BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(areaIpCfg); } } } @@ -288,8 +288,7 @@ public class AvContentCfgService extends BaseService{ CfgIndexInfo cfg=new CfgIndexInfo(); AreaIpCfg areaIpCfg=new AreaIpCfg(); areaIpCfg.setCfgId(Long.parseLong(cfgId)); - cfg.setAreaIpCfg(areaIpCfg); - areaIpCfgDao.deleteAreaIpCfgByCfgId(cfg); + areaIpCfgDao.deleteAreaIpCfgByCfgId(areaIpCfg); } } @@ -319,7 +318,9 @@ public class AvContentCfgService extends BaseService{ avContentCfgDao.updateAvVoipIp(entity); avContentCfgDao.updateAvVoipAccount(entity); avContentCfgDao.updateCfgIndexInfo(entity); - areaIpCfgDao.updateAreaIpCfgFromCfgIndexInfo(entity); + AreaIpCfg areaIpCfg=new AreaIpCfg(); + BeanUtils.copyProperties(entity, areaIpCfg); + areaIpCfgDao.updateAreaIpCfgValid(areaIpCfg); } } /** @@ -351,11 +352,13 @@ public class AvContentCfgService extends BaseService{ avContentCfgDao.updateAvVoipIp(entity); avContentCfgDao.updateAvVoipAccount(entity); avContentCfgDao.updateCfgIndexInfo(entity); - areaIpCfgDao.updateAreaIpCfgFromCfgIndexInfo(entity); + AreaIpCfg areaIpCfg=new AreaIpCfg(); + BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode","cfgType","cfgId"}); + areaIpCfgDao.updateAreaIpCfg(areaIpCfg); voipIpList=avContentCfgDao.findVoipIpCfgList(entity); voipAccountList=avContentCfgDao.findVoipAccountCfgList(entity); - areaIpCfgList=areaIpCfgDao.findAreaIpCfgList(entity); + areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId()); ToMaatBean maatBean = new ToMaatBean(); MaatCfg maatCfg = new MaatCfg(); @@ -455,11 +458,37 @@ public class AvContentCfgService extends BaseService{ * @return */ public AvContIpCfg getContIpCfgById(AvContIpCfg entity) { - return avContentCfgDao.findVoipIpCfgById(entity); + return avContentCfgDao.findContIpCfgById(entity); } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveOrUpdateAvContIp(AvContIpCfg entity){ + public void saveOrUpdateAvContIp(AvContIpCfg entity,String areaCfgIds){ Date createTime=new Date(); + + //区域IPsetAreaEffectiveIds设置 + List areaCfg=entity.getAreaCfg(); + List areaIsps=entity.getAreaIsp(); + if(Constants.IS_AREA_EFFECTIVE_NO==entity.getIsAreaEffective()){ + entity.setAreaEffectiveIds(""); + entity.setAreaType(null); + }else if(Constants.IS_AREA_EFFECTIVE_YES==entity.getIsAreaEffective()){ + if(Constants.AREA_EFFECTIVE_TYPE_AREA_ISP==entity.getAreaType()&&areaIsps!=null&&areaIsps.size()>0){ + StringBuffer areaEffectiveIds=new StringBuffer(); + for(int i=0;i0){ + entity.setAreaEffectiveIds(""); + } + } + //新增 if(entity.getCfgId()==null){ entity.setCreatorId(UserUtils.getUser().getId()); @@ -470,7 +499,6 @@ public class AvContentCfgService extends BaseService{ List compileIds = new ArrayList(); try { compileIds = ConfigServiceUtil.getId(1,1); - //compileIds.add((int)Math.floor(Math.random()*1000000+1)); } catch (Exception e) { e.printStackTrace(); logger.info("获取编译ID出错"); @@ -478,6 +506,15 @@ public class AvContentCfgService extends BaseService{ } if(compileIds != null && compileIds.size() >0 && compileIds.get(0) != 0){ entity.setCompileId(compileIds.get(0)); + + //保存区域IP信息 + if(entity.getAreaCfg()!=null&&entity.getAreaCfg().size()>0){ + for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) { + BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(areaIpCfg); + } + } + //保存cfgIndexInfo avContentCfgDao.insertAvContIp(entity); }else{ @@ -489,6 +526,39 @@ public class AvContentCfgService extends BaseService{ Date editTime=new Date(); entity.setIsValid(0); entity.setIsAudit(0); + + areaCfgIds=!StringUtil.isEmpty(areaCfgIds)? ","+areaCfgIds:""; + + if(!StringUtil.isEmpty(entity.getAreaCfg())){ + for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) { + if(!StringUtil.isEmpty(areaIpCfg.getCfgId())){ + if(areaCfgIds.contains(","+areaIpCfg.getCfgId()+",")){ + areaCfgIds=areaCfgIds.replace(areaIpCfg.getCfgId()+",", ""); + } + //修改 + entity.setEditorId(UserUtils.getUser().getId()); + entity.setEditTime(editTime); + BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode","cfgType","cfgId"}); + areaIpCfgDao.updateAreaIpCfg(areaIpCfg); + }else{ + //新增 + entity.setCreatorId(UserUtils.getUser().getId()); + entity.setCreateTime(createTime); + BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(areaIpCfg); + } + } + } + //delete 真是删除areaIpCfg信息 + if(!StringUtil.isEmpty(areaCfgIds.replaceAll(",", ""))){ + areaCfgIds=areaCfgIds.substring(1,areaCfgIds.length()); + for (String cfgId : areaCfgIds.split(",")) { + AreaIpCfg areaIpCfg=new AreaIpCfg(); + areaIpCfg.setCfgId(Long.parseLong(cfgId)); + areaIpCfgDao.deleteAreaIpCfgByCfgId(areaIpCfg); + } + } + entity.setEditorId(UserUtils.getUser().getId()); entity.setEditTime(editTime); avContentCfgDao.updateAvContIp(entity); diff --git a/src/main/webapp/WEB-INF/views/cfg/av/contIp/contIpForm.jsp b/src/main/webapp/WEB-INF/views/cfg/av/contIp/contIpForm.jsp index 44dd49d2e..03bb68f24 100644 --- a/src/main/webapp/WEB-INF/views/cfg/av/contIp/contIpForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/av/contIp/contIpForm.jsp @@ -5,40 +5,6 @@ <spring:message code="${cfgName}"></spring:message>