配置取消审核通过逻辑完善

This commit is contained in:
zhangwei
2018-05-29 15:37:48 +08:00
parent 11e70875c8
commit aa341445f2
5 changed files with 89 additions and 53 deletions

View File

@@ -76,6 +76,8 @@ public class MaatCfg implements Serializable {
@SerializedName("opTime")
private Date auditTime;
@Expose
private Integer isValid;
@Expose
private List<GroupCfg> groupRelationList;
@Expose
private List<StringCfg> strRegionList;
@@ -630,6 +632,12 @@ public class MaatCfg implements Serializable {
public void setAreaIpRegionList(List<IpCfg> areaIpRegionList) {
this.areaIpRegionList = areaIpRegionList;
}
public Integer getIsValid() {
return isValid;
}
public void setIsValid(Integer isValid) {
this.isValid = isValid;
}
public void initDefaultValue() {
this.doLog=2;
this.doBlackList=1;

View File

@@ -43,6 +43,8 @@ public class ToMaatBean implements Serializable{
@SerializedName("opTime")
private Date auditTime;
@Expose
private Integer opAction;
@Expose
private List<MaatCfg> configCompileList;
public String getVersion() {
@@ -76,6 +78,14 @@ public class ToMaatBean implements Serializable{
public void setConfigCompileList(List<MaatCfg> configCompileList) {
this.configCompileList = configCompileList;
}
public Integer getOpAction() {
return opAction;
}
public void setOpAction(Integer opAction) {
this.opAction = opAction;
}
public static void main(String[] args) {
}

View File

@@ -252,7 +252,7 @@ public class ConfigServiceUtil {
WebTarget wt = ClientUtil.getWebTarger(url);
//获取响应结果
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
Response response= header.put(Entity.entity(params, MediaType.APPLICATION_JSON));
Response response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
if( response.getStatus() == 200){
result= response.readEntity(String.class);
JSONObject resObject = JSONObject.fromObject(result);

View File

@@ -292,5 +292,9 @@ public final class Constants {
public static final String VOIP_IP_REGION = Configurations.getStringProperty("voip_ip","av_voip_ip");
public static final String VOIP_ACCOUNT_REGION = Configurations.getStringProperty("voip_account","av_voip_account");
public static final String MAAT_VERSION = Configurations.getStringProperty("maat_version","1.0");
public static final Integer INSERT_ACTION = Configurations.getIntProperty("insert_action",1);
public static final Integer UPDATE_ACTION = Configurations.getIntProperty("update_action",2);
public static final Integer DELETE_ACTION = Configurations.getIntProperty("delete_action",3);
}

View File

@@ -6,6 +6,7 @@ import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -287,6 +288,17 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
//修改数据库审核状态信息
entity.setTableName(CfgIndexInfo.getTablename());
websiteCfgDao.auditCfg(entity);
ToMaatBean maatBean = new ToMaatBean();
MaatCfg maatCfg = new MaatCfg();
List<MaatCfg> configCompileList = new ArrayList();
List<GroupCfg> groupRelationList = new ArrayList();
List<IpCfg> ipRegionList = new ArrayList();
List<StringCfg> strRegionList = new ArrayList();
List<NumBoundaryCfg> numRegionList = new ArrayList();
List<DigestCfg> digestRegionList = new ArrayList();
List<IpCfg> areaIpRegionList = new ArrayList();
//查询子配置并修改审核状态
entity = this.getHttpCfg(entity.getCfgId());
if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){
@@ -294,24 +306,47 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(IpPortCfg.getTablename());
websiteCfgDao.auditCfg(cfg);
if(isAudit==1){
Map<String,List> map = cfgConvert(ipRegionList,entity.getIpPortList(),1,entity,groupRelationList);
groupRelationList=map.get("groupList");
ipRegionList=map.get("dstList");
if(map.get("numRegionList")!=null){
numRegionList.addAll(map.get("numRegionList"));
}
}
}
if(entity.getHttpUrlList()!=null && entity.getHttpUrlList().size()>0){
HttpUrlCfg cfg = new HttpUrlCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(HttpUrlCfg.getTablename());
websiteCfgDao.auditCfg(cfg);
if(isAudit==1){
Map<String,List> map = cfgConvert(strRegionList,entity.getHttpUrlList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
}
if(entity.getHttpReqHdrList()!=null && entity.getHttpReqHdrList().size()>0){
HttpReqHeadCfg cfg = new HttpReqHeadCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(HttpReqHeadCfg.getTablename());
websiteCfgDao.auditCfg(cfg);
if(isAudit==1){
Map<String,List> map = cfgConvert(strRegionList,entity.getHttpReqHdrList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
}
if(entity.getHttpResHdrList()!=null && entity.getHttpResHdrList().size()>0){
HttpResHeadCfg cfg = new HttpResHeadCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(HttpResHeadCfg.getTablename());
websiteCfgDao.auditCfg(cfg);
if(isAudit==1){
Map<String,List> map = cfgConvert(strRegionList,entity.getHttpResHdrList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
}
if((entity.getHttpReqBodyList()!=null && entity.getHttpReqBodyList().size()>0) ||
(entity.getHttpResBodyList()!=null && entity.getHttpResBodyList().size()>0)){
@@ -319,6 +354,18 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(HttpBodyCfg.getTablename());
websiteCfgDao.auditCfg(cfg);
if(isAudit==1){
if(entity.getHttpReqBodyList()!=null && entity.getHttpReqBodyList().size()>0){
Map<String,List> map = cfgConvert(strRegionList,entity.getHttpReqBodyList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
if(entity.getHttpResBodyList()!=null && entity.getHttpResBodyList().size()>0){
Map<String,List> map = cfgConvert(strRegionList,entity.getHttpResBodyList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
}
}
//保存区域IP信息
if(entity.getAreaCfg()!=null && entity.getAreaCfg().size()>0){
@@ -326,61 +373,17 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(AreaIpCfg.getTablename());
websiteCfgDao.auditCfg(cfg);
}
ToMaatBean maatBean = new ToMaatBean();
MaatCfg maatCfg = new MaatCfg();
//构造提交综合服务参数格式,一条配置提交一次综合服务
if(isAudit==1){
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
List<MaatCfg> configCompileList = new ArrayList();
List<GroupCfg> groupRelationList = new ArrayList();
List<IpCfg> ipRegionList = new ArrayList();
List<StringCfg> strRegionList = new ArrayList();
List<NumBoundaryCfg> numRegionList = new ArrayList();
List<DigestCfg> digestRegionList = new ArrayList();
List<IpCfg> areaIpRegionList = new ArrayList();
if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){
Map<String,List> map = cfgConvert(ipRegionList,entity.getIpPortList(),1,entity,groupRelationList);
groupRelationList=map.get("groupList");
ipRegionList=map.get("dstList");
if(map.get("numRegionList")!=null){
numRegionList.addAll(map.get("numRegionList"));
}
}
if(entity.getHttpUrlList()!=null && entity.getHttpUrlList().size()>0){
Map<String,List> map = cfgConvert(strRegionList,entity.getHttpUrlList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
if(entity.getHttpReqHdrList()!=null && entity.getHttpReqHdrList().size()>0){
Map<String,List> map = cfgConvert(strRegionList,entity.getHttpReqHdrList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
if(entity.getHttpResHdrList()!=null && entity.getHttpResHdrList().size()>0){
Map<String,List> map = cfgConvert(strRegionList,entity.getHttpResHdrList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
if(entity.getHttpReqBodyList()!=null && entity.getHttpReqBodyList().size()>0){
Map<String,List> map = cfgConvert(strRegionList,entity.getHttpReqBodyList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
if(entity.getHttpResBodyList()!=null && entity.getHttpResBodyList().size()>0){
Map<String,List> map = cfgConvert(strRegionList,entity.getHttpResBodyList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
//保存区域IP信息
if(entity.getAreaCfg()!=null && entity.getAreaCfg().size()>0){
if(isAudit==1){
Map<String,List> map = cfgConvert(areaIpRegionList,entity.getAreaCfg(),1,entity,groupRelationList);
groupRelationList=map.get("groupList");
areaIpRegionList=map.get("dstList");
}
}
//构造提交综合服务参数格式,一条配置提交一次综合服务
if(isAudit==1){
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
maatCfg.setAction(entity.getAction());
maatCfg.setAuditTime(entity.getAuditTime());
maatCfg.setIpRegionList(ipRegionList);
@@ -390,11 +393,13 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
maatCfg.setGroupRelationList(groupRelationList);
maatCfg.setGroupNum(groupRelationList.size());
maatCfg.setAreaIpRegionList(areaIpRegionList);
maatCfg.setIsValid(entity.getIsValid());
configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("http配置下发配置参数"+json);
@@ -403,11 +408,20 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
logger.info("http配置下发响应信息"+result.getMsg());
}else if(isAudit==3){
maatCfg.setCompileId(entity.getCompileId());
maatCfg.setServiceId(entity.getServiceId());
maatCfg.setIsValid(0);//无效
configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.UPDATE_ACTION);
//调用服务接口取消配置
String json=gsonToJson(maatBean);
logger.info("http配置下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json,2);
ToMaatResult result = ConfigServiceUtil.put(json,1);
logger.info("http配置取消配置响应信息"+result.getMsg());
}
}