voip 区域信息增加,voipAccount修改为字符串类型配置

区域信息单选切换移至common.js
This commit is contained in:
duandongmei
2018-05-29 18:31:43 +08:00
parent 3ff6acb8c8
commit 787510e168
18 changed files with 1586 additions and 308 deletions

View File

@@ -15,25 +15,24 @@ import org.springframework.transaction.annotation.Transactional;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.nis.domain.Page;
import com.nis.domain.configuration.AreaBean;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.AvContIpCfg;
import com.nis.domain.configuration.AvFileSampleCfg;
import com.nis.domain.configuration.AvSignSampleCfg;
import com.nis.domain.configuration.AvVoipAccountCfg;
import com.nis.domain.configuration.AvVoipIpCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.maat.ToMaatResult;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.FileUtils;
import com.nis.util.Constants;
import com.nis.util.StringUtil;
import com.nis.web.dao.FunctionRegionDictDao;
import com.nis.web.dao.FunctionServiceDictDao;
import com.nis.web.dao.configuration.AvCfgDao;
import com.nis.util.StringUtils;
import com.nis.web.dao.configuration.AreaIpCfgDao;
import com.nis.web.dao.configuration.AvContentCfgDao;
import com.nis.web.security.UserUtils;
import com.nis.web.service.BaseService;
import com.nis.web.service.CrudService;
import net.sf.json.JSONObject;
/**
@@ -45,6 +44,8 @@ import net.sf.json.JSONObject;
public class AvContentCfgService extends BaseService{
@Autowired
protected AvContentCfgDao avContentCfgDao;
@Autowired
protected AreaIpCfgDao areaIpCfgDao;
/**
* 查询分页数据
@@ -100,8 +101,33 @@ public class AvContentCfgService extends BaseService{
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdateAvVoip(CfgIndexInfo entity,String voipIpIds,String voipAccountIds){
public void saveOrUpdateAvVoip(CfgIndexInfo entity,String voipIpIds,String voipAccountIds,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());
@@ -111,7 +137,7 @@ public class AvContentCfgService extends BaseService{
//调用服务接口获取compileId
List<Integer> compileIds = new ArrayList<Integer>();
try {
//TODO 后期修改为动态获取
//TODO
//compileIds = ConfigServiceUtil.getId(1,1);
compileIds.add((int)Math.floor(Math.random()*1000000+1));
} catch (Exception e) {
@@ -135,12 +161,18 @@ public class AvContentCfgService extends BaseService{
avContentCfgDao.insertAvVoipAccount(entity);
}
}
//保存区域IP信息
if(entity.getAreaCfg()!=null&&entity.getAreaCfg().size()>0){
for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) {
entity.setAreaIpCfg(areaIpCfg);
areaIpCfgDao.saveAreaIpCfgFromCfgIndexInfo(entity);
}
}
//保存cfgIndexInfo
avContentCfgDao.insertCfgIndexInfo(entity);
}else{
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
}
//修改
}else{
Date editTime=new Date();
@@ -149,6 +181,7 @@ public class AvContentCfgService extends BaseService{
voipIpIds=!StringUtil.isEmpty(voipIpIds)? voipIpIds+",":"";
voipAccountIds=!StringUtil.isEmpty(voipAccountIds)? voipAccountIds+",":"";
areaCfgIds=!StringUtil.isEmpty(areaCfgIds)? ","+areaCfgIds:"";
//判断voip信息为新增还是修改清楚voipIpIds修改的voipId记录剩下即为需要删除的voipId
if(!StringUtil.isEmpty(entity.getVoipIps())){
@@ -192,6 +225,26 @@ public class AvContentCfgService extends BaseService{
}
}
}
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);
entity.setAreaIpCfg(areaIpCfg);
areaIpCfgDao.updateAreaIpCfgFromCfgIndexInfo(entity);
}else{
//新增
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
entity.setAreaIpCfg(areaIpCfg);
areaIpCfgDao.saveAreaIpCfgFromCfgIndexInfo(entity);
}
}
}
//delete 真是删除voipAccount信息
if(!StringUtil.isEmpty(voipAccountIds.replaceAll(",", ""))){
voipAccountIds=voipAccountIds.substring(1,voipAccountIds.length());
@@ -215,6 +268,18 @@ public class AvContentCfgService extends BaseService{
avContentCfgDao.deleteAvVoipIp(cfg);
}
}
//delete 真是删除areaIpCfg信息
if(!StringUtil.isEmpty(areaCfgIds.replaceAll(",", ""))){
areaCfgIds=areaCfgIds.substring(1,areaCfgIds.length());
for (String cfgId : areaCfgIds.split(",")) {
CfgIndexInfo cfg=new CfgIndexInfo();
AreaIpCfg areaIpCfg=new AreaIpCfg();
areaIpCfg.setCfgId(Long.parseLong(cfgId));
cfg.setAreaIpCfg(areaIpCfg);
areaIpCfgDao.deleteAreaIpCfgByCfgId(cfg);
}
}
//修改
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
@@ -241,6 +306,7 @@ public class AvContentCfgService extends BaseService{
avContentCfgDao.updateAvVoipIp(entity);
avContentCfgDao.updateAvVoipAccount(entity);
avContentCfgDao.updateCfgIndexInfo(entity);
areaIpCfgDao.updateAreaIpCfgFromCfgIndexInfo(entity);
}
}
/**
@@ -256,6 +322,7 @@ public class AvContentCfgService extends BaseService{
List<CfgIndexInfo> list = new ArrayList();
List<AvVoipIpCfg> voipIpList = new ArrayList();
List<AvVoipAccountCfg> voipAccountList = new ArrayList();
List<AreaIpCfg> areaIpCfgList = new ArrayList();
Map<String, Object> childMap=new HashMap<>();
CfgIndexInfo searchCfg=new CfgIndexInfo();
Date auditTime=new Date();
@@ -268,12 +335,15 @@ public class AvContentCfgService extends BaseService{
entity.setAuditTime(auditTime);
voipIpList=avContentCfgDao.findVoipIpCfgList(entity);
voipAccountList=avContentCfgDao.findVoipAccountCfgList(entity);
areaIpCfgList=areaIpCfgDao.findAreaIpCfgList(entity);
avContentCfgDao.updateAvVoipIp(entity);
avContentCfgDao.updateAvVoipAccount(entity);
avContentCfgDao.updateCfgIndexInfo(entity);
childMap.put("voipIp", voipIpList);
childMap.put("voipAccount", voipAccountList);
areaIpCfgDao.updateAreaIpCfgFromCfgIndexInfo(entity);
childMap.put("voipIps", voipIpList);
childMap.put("voipAccounts", voipAccountList);
childMap.put("areaIpCfgs", areaIpCfgList);
list.add(entity);
}
/*if(isAudit==1){
@@ -305,4 +375,66 @@ public class AvContentCfgService extends BaseService{
}*/
}
/**
* contIp查询分页数据
* @param page 分页对象
* @param entity
* @return
*/
public Page<AvContIpCfg> findContIpPage(Page page, AvContIpCfg entity) {
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r"));
entity.setPage(page);
List<AvContIpCfg> list=avContentCfgDao.findContIpList(entity);
page.setList(list);
return page;
}
/**
* contUp根据id查询contIpCfg信息
* @param entity
* @return
*/
public AvContIpCfg getContIpCfgById(AvContIpCfg entity) {
return avContentCfgDao.findVoipIpCfgById(entity);
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdateAvContIp(AvContIpCfg entity){
Date createTime=new Date();
//新增
if(entity.getCfgId()==null){
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
entity.setIsValid(0);
entity.setIsAudit(0);
//调用服务接口获取compileId
List<Integer> compileIds = new ArrayList<Integer>();
try {
//TODO
//compileIds = ConfigServiceUtil.getId(1,1);
compileIds.add((int)Math.floor(Math.random()*1000000+1));
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
if(compileIds != null && compileIds.size() >0 && compileIds.get(0) != 0){
entity.setCompileId(compileIds.get(0));
//保存cfgIndexInfo
avContentCfgDao.insertAvContIp(entity);
}else{
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
}
//修改
}else{
Date editTime=new Date();
entity.setIsValid(0);
entity.setIsAudit(0);
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
avContentCfgDao.updateAvContIp(entity);
}
}
}