分组配置管理GroupName改为可手动输入

This commit is contained in:
zhangwenqing
2019-06-14 17:12:41 +08:00
parent 3aebe7d905
commit d245ef7dc4
33 changed files with 2384 additions and 357 deletions

View File

@@ -73,14 +73,19 @@ public class IpCommGroupCfgService extends BaseService {
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void update(IpCommCfg entity){
// 获取分组ID
Integer serviceGroupId = groupManageService.getServiceGroupId(entity.getGroupName(), Constants.IP_OBJ_GROUP_TYPE);
entity.setGroupId(serviceGroupId);
ipCommGroupCfgDao.update(entity);
// 更新分组状态
List<PolicyGroupInfo> policyGroupInfos = new ArrayList<PolicyGroupInfo>();
if(!entity.getUserRegion1().equals(entity.getGroupId().toString())) {
groupManageService.updateGroupStatus(policyGroupInfos, 5);
policyGroupInfos.addAll(policyGroupInfoDao.findPolicyByServiceGroupInfoList(entity.getUserRegion1()));
policyGroupInfos.addAll(policyGroupInfoDao.findPolicyByServiceGroupInfoList(entity.getUserRegion1())); // old
if(!entity.getUserRegion1().equals(entity.getGroupId()+"")) { // 分组已修改
policyGroupInfos.addAll(policyGroupInfoDao.findPolicyByServiceGroupInfoList(entity.getGroupId()+"")); // new
}
policyGroupInfos.addAll(policyGroupInfoDao.findPolicyByServiceGroupInfoList(entity.getGroupId().toString()));
groupManageService.updateGroupStatus(policyGroupInfos, Constants.IP_OBJ_GROUP_TYPE);
transObjGroupToMaat(policyGroupInfos);
}
@@ -95,12 +100,16 @@ public class IpCommGroupCfgService extends BaseService {
//新增
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveIpCommGroupCfg(CfgIndexInfo entity) {
Date createTime=new Date();
if(CollectionUtils.isNotEmpty(entity.getIpCommGroupCfgList())) {
List<PolicyGroupInfo> policyGroupInfos=policyGroupInfoDao.findPolicyByServiceGroupInfoList(entity.getGroupId().toString());
for (int i = 0; i < entity.getIpCommGroupCfgList().size(); i++) {
BeanUtils.copyProperties(entity, entity.getIpCommGroupCfgList().get(i), new String[]{"cfgId","userregion3"});
// 获取分组ID
Integer serviceGroupId = groupManageService.getServiceGroupId(entity.getGroupName(), Constants.IP_OBJ_GROUP_TYPE);
List<PolicyGroupInfo> policyGroupInfos=policyGroupInfoDao.findPolicyByServiceGroupInfoList(serviceGroupId+"");
for (IpCommCfg cfg : entity.getIpCommGroupCfgList()) {
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId","userregion3"});
Integer regionId = 0;
List<Integer> regionIds = ConfigServiceUtil.getId(3, 1);
if(regionIds!=null && regionIds.size()>0){
@@ -108,21 +117,22 @@ public class IpCommGroupCfgService extends BaseService {
}else {
throw new MaatConvertException("Get region id failed");
}
entity.getIpCommGroupCfgList().get(i).setRegionId(regionId);
entity.getIpCommGroupCfgList().get(i).setRequestId(0);
entity.getIpCommGroupCfgList().get(i).setClassify("0");
entity.getIpCommGroupCfgList().get(i).setAttribute("0");
entity.getIpCommGroupCfgList().get(i).setLable("0");
entity.getIpCommGroupCfgList().get(i).setCreateTime(createTime);
entity.getIpCommGroupCfgList().get(i).setCreatorId(entity.getCurrentUser().getId());
entity.getIpCommGroupCfgList().get(i).setIsValid(Constants.VALID_NO);
entity.getIpCommGroupCfgList().get(i).setIsAudit(Constants.AUDIT_NOT_YET);
entity.getIpCommGroupCfgList().get(i).setGroupId(entity.getGroupId());
ipCommGroupCfgDao.insertForBatch(entity.getIpCommGroupCfgList().get(i));
cfg.setRegionId(regionId);
cfg.setRequestId(0);
cfg.setClassify("0");
cfg.setAttribute("0");
cfg.setLable("0");
cfg.setCreateTime(createTime);
cfg.setCreatorId(entity.getCurrentUser().getId());
cfg.setIsValid(Constants.VALID_NO);
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
cfg.setGroupId(serviceGroupId);
ipCommGroupCfgDao.insertForBatch(cfg);
}
// 更新分组状态
groupManageService.updateGroupStatus(policyGroupInfos, 5);
//TODO 组配置更新时 需检索是否被其它配置引用,若被引用需调用相应服务接口更新配置
transObjGroupToMaat(policyGroupInfos);
}
@@ -150,11 +160,15 @@ public class IpCommGroupCfgService extends BaseService {
String ids = "";
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
for(BaseIpCfg cfg:cfgs) {
if(!ids.contains(cfg.getGroupId()+"")) {
ids += ","+cfg.getGroupId();
}
IpCommCfg ipCommCfg=new IpCommCfg();
BeanUtils.copyProperties(cfg, ipCommCfg);
Integer serviceGroupId = groupManageService.getServiceGroupId(ipCommCfg.getGroupName(), Constants.IP_OBJ_GROUP_TYPE);
if(!ids.contains(serviceGroupId+"")) {
ids += ","+serviceGroupId;
}
ipCommCfg.setGroupId(serviceGroupId);
((IpCommGroupCfgDao) batchSqlSession.getMapper(IpCommGroupCfgDao.class)).insertForBatch(ipCommCfg);
}
@@ -163,7 +177,7 @@ public class IpCommGroupCfgService extends BaseService {
// 更新分组状态
String serviceGroupIds = ids.substring(1);
List<PolicyGroupInfo> policyGroupInfos = policyGroupInfoDao.findPolicyByServiceGroupInfoList(serviceGroupIds);
groupManageService.updateGroupStatus(policyGroupInfos, 5);
groupManageService.updateGroupStatus(policyGroupInfos, Constants.IP_OBJ_GROUP_TYPE);
}finally {
if(batchSqlSession != null){