修改区域地域ip和地域运营商不互斥的bug

去掉cfgIndexInfo中areaIpCfg对象
cont_ip修改功能完成
This commit is contained in:
duandongmei
2018-05-30 17:10:39 +08:00
parent 911b9a6e09
commit d0d9c3eece
9 changed files with 221 additions and 205 deletions

View File

@@ -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<AreaIpCfg> areaCfg=entity.getAreaCfg();
List<AreaBean> 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;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(",");
}
}
entity.setAreaEffectiveIds(areaEffectiveIds.toString());
}else if(Constants.AREA_EFFECTIVE_TYPE_AREA_IP==entity.getAreaType()&&areaCfg!=null&&areaCfg.size()>0){
entity.setAreaEffectiveIds("");
}
}
//新增
if(entity.getCfgId()==null){
entity.setCreatorId(UserUtils.getUser().getId());
@@ -470,7 +499,6 @@ public class AvContentCfgService extends BaseService{
List<Integer> compileIds = new ArrayList<Integer>();
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);