多域配置审核调整,多个maat_table进行分割
This commit is contained in:
@@ -21,7 +21,7 @@ import com.nis.domain.BaseEntity;
|
||||
* @date 2018年2月5日 上午11:15:14
|
||||
* @version V1.0
|
||||
*/
|
||||
public class BaseCfg<T> extends BaseEntity<T> {
|
||||
public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
|
||||
protected String showName;//表在界面上展示的名称
|
||||
protected String seltype;//选中类型,页面搜索用
|
||||
protected String tableName;
|
||||
@@ -664,4 +664,13 @@ public class BaseCfg<T> extends BaseEntity<T> {
|
||||
public void setCompileId(Integer compileId) {
|
||||
this.compileId = compileId;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
// TODO Auto-generated method stub
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -850,6 +850,8 @@ public class MultipleCfgController extends BaseController{
|
||||
BaseIpCfg resultIpCfg=ipCfgService.get(searchIpCfg);
|
||||
searchIpCfg.setAuditorId(searchIpCfg.getCurrentUser().getId());
|
||||
searchIpCfg.setAuditTime(date);
|
||||
searchIpCfg.setCfgId(resultIpCfg.getCfgId());
|
||||
searchIpCfg.setIsAudit(audit);
|
||||
if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0
|
||||
searchIpCfg.setIsValid(Constants.VALID_NO);
|
||||
if(resultIpCfg!=null){
|
||||
@@ -892,6 +894,8 @@ public class MultipleCfgController extends BaseController{
|
||||
BaseStringCfg resultStringCfg=stringCfgService.get(searchStringCfg);
|
||||
searchStringCfg.setAuditorId(searchStringCfg.getCurrentUser().getId());
|
||||
searchStringCfg.setAuditTime(date);
|
||||
searchStringCfg.setCfgId(resultStringCfg.getCfgId());
|
||||
searchStringCfg.setIsAudit(audit);
|
||||
if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0
|
||||
searchStringCfg.setIsValid(Constants.VALID_NO);
|
||||
if(resultStringCfg!=null){
|
||||
@@ -932,6 +936,8 @@ public class MultipleCfgController extends BaseController{
|
||||
NumBoundaryCfg resultNumCfg=numCfgService.get(searchNumCfg);
|
||||
searchNumCfg.setAuditorId(searchNumCfg.getCurrentUser().getId());
|
||||
searchNumCfg.setAuditTime(date);
|
||||
searchNumCfg.setCfgId(resultNumCfg.getCfgId());
|
||||
searchNumCfg.setIsAudit(audit);
|
||||
if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0
|
||||
searchNumCfg.setIsValid(Constants.VALID_NO);
|
||||
if(resultNumCfg!=null){
|
||||
@@ -972,6 +978,8 @@ public class MultipleCfgController extends BaseController{
|
||||
ComplexkeywordCfg resultComplexCfg=complexStringCfgService.get(searchComplexCfg);
|
||||
searchComplexCfg.setAuditorId(searchComplexCfg.getCurrentUser().getId());
|
||||
searchComplexCfg.setAuditTime(date);
|
||||
searchComplexCfg.setCfgId(resultComplexCfg.getCfgId());
|
||||
searchComplexCfg.setIsAudit(audit);
|
||||
if(audit==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0
|
||||
searchComplexCfg.setIsValid(Constants.VALID_NO);
|
||||
if(resultComplexCfg!=null){
|
||||
@@ -1007,8 +1015,8 @@ public class MultipleCfgController extends BaseController{
|
||||
}
|
||||
}
|
||||
}
|
||||
int result=multipleCfgService.auditCfg(resultCfg,searchCfg);
|
||||
if(result==0){
|
||||
boolean result=multipleCfgService.auditCfg(resultCfg,searchCfg);
|
||||
if(!result){
|
||||
addMessage(model,"审核失败");
|
||||
}else{
|
||||
addMessage(model,"审核成功,正在为您跳转页面...");
|
||||
|
||||
@@ -214,16 +214,28 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
ToMaatUnAuditBean toMaatUnAuditBean=new ToMaatUnAuditBean();
|
||||
toMaatUnAuditBean.setServiceCfg(new ArrayList<UnAuditBean>());
|
||||
for(BaseCfg c:cfg){
|
||||
UnAuditBean bean=new UnAuditBean();
|
||||
|
||||
if(c.getCompileId()==null||c.getCompileId()==0){
|
||||
throw new RuntimeException("转换出错,未获取到正确的compileId");
|
||||
}
|
||||
if(StringUtils.isBlank(c.getMaatTable())){
|
||||
throw new RuntimeException("转换出错,未获取到正确的maatTalbe");
|
||||
}
|
||||
bean.setCompileId(c.getCompileId());
|
||||
bean.setMaatTable(c.getMaatTable());
|
||||
toMaatUnAuditBean.getServiceCfg().add(bean);
|
||||
//针对含有多个maatTable的表
|
||||
if(c.getMaatTable().contains(",")){
|
||||
for(String maatTable:c.getMaatTable().split(",")){
|
||||
UnAuditBean bean=new UnAuditBean();
|
||||
bean.setCompileId(c.getCompileId());
|
||||
bean.setMaatTable(maatTable);
|
||||
toMaatUnAuditBean.getServiceCfg().add(bean);
|
||||
}
|
||||
}else{
|
||||
UnAuditBean bean=new UnAuditBean();
|
||||
bean.setCompileId(c.getCompileId());
|
||||
bean.setMaatTable(c.getMaatTable());
|
||||
toMaatUnAuditBean.getServiceCfg().add(bean);
|
||||
}
|
||||
|
||||
}
|
||||
String json=gson.toJson(toMaatUnAuditBean);
|
||||
logger.info("to maat json:"+json);
|
||||
@@ -237,34 +249,104 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
|
||||
for(BaseCfg c:cfg){
|
||||
if(c instanceof BaseIpCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
if(maatCfg.getIpCfg()==null){
|
||||
List<BaseIpCfg> list=new ArrayList<>();
|
||||
list.add((BaseIpCfg)c);
|
||||
maatCfg.setIpCfg(list);
|
||||
int protocolId= ((BaseIpCfg) c).getProtocolId().intValue();
|
||||
String maatTable=c.getMaatTable();
|
||||
if(maatTable.contains(",")){
|
||||
if(protocolId!=0){
|
||||
for(String _maatTable:maatTable.split(",")){
|
||||
if(_maatTable.toLowerCase().indexOf("ip")>-1){
|
||||
BaseIpCfg ipCfg=(BaseIpCfg)c.clone();
|
||||
ipCfg.setMaatTable(_maatTable);
|
||||
if(maatCfg.getIpCfg()==null){
|
||||
List<BaseIpCfg> list=new ArrayList<>();
|
||||
list.add(ipCfg);
|
||||
maatCfg.setIpCfg(list);
|
||||
}else{
|
||||
List<BaseIpCfg> list=maatCfg.getIpCfg();
|
||||
list.add(ipCfg);
|
||||
}
|
||||
}else{
|
||||
NumBoundaryCfg numCfg=new NumBoundaryCfg();
|
||||
numCfg.initDefaultValue();
|
||||
numCfg.setLowBounadry((long)protocolId);
|
||||
numCfg.setUpBoundary((long)protocolId);
|
||||
numCfg.setMaatTable(_maatTable);
|
||||
if(maatCfg.getNumCfg()==null){
|
||||
List<NumBoundaryCfg> numlist=new ArrayList<>();
|
||||
numlist.add(numCfg);
|
||||
maatCfg.setNumCfg(numlist);
|
||||
}else{
|
||||
List<NumBoundaryCfg> numlist=maatCfg.getNumCfg();
|
||||
numlist.add(numCfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
throw new RuntimeException("protocolId等于0,却对应两个maat_table "+maatTable);
|
||||
}
|
||||
}else{
|
||||
List<BaseIpCfg> list=maatCfg.getIpCfg();
|
||||
list.add((BaseIpCfg)c);
|
||||
if(maatCfg.getIpCfg()==null){
|
||||
List<BaseIpCfg> list=new ArrayList<>();
|
||||
list.add((BaseIpCfg)c);
|
||||
maatCfg.setIpCfg(list);
|
||||
}else{
|
||||
List<BaseIpCfg> list=maatCfg.getIpCfg();
|
||||
list.add((BaseIpCfg)c);
|
||||
}
|
||||
}
|
||||
}else if(c instanceof BaseStringCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
if(maatCfg.getStrCfg()==null){
|
||||
List<BaseStringCfg> list=new ArrayList<BaseStringCfg>();
|
||||
list.add((BaseStringCfg)c);
|
||||
maatCfg.setStrCfg(list);
|
||||
String maatTable=c.getMaatTable();
|
||||
if(maatTable.contains(",")){
|
||||
for(String _maatTable:maatTable.split(",")){
|
||||
BaseStringCfg strCfg=(BaseStringCfg)c.clone();
|
||||
strCfg.setMaatTable(_maatTable);
|
||||
if(maatCfg.getStrCfg()==null){
|
||||
List<BaseStringCfg> list=new ArrayList<BaseStringCfg>();
|
||||
list.add(strCfg);
|
||||
maatCfg.setStrCfg(list);
|
||||
}else{
|
||||
List<BaseStringCfg> list=maatCfg.getStrCfg();
|
||||
list.add(strCfg);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
List<BaseStringCfg> list=maatCfg.getStrCfg();
|
||||
list.add((BaseStringCfg)c);
|
||||
if(maatCfg.getStrCfg()==null){
|
||||
List<BaseStringCfg> list=new ArrayList<BaseStringCfg>();
|
||||
list.add((BaseStringCfg)c);
|
||||
maatCfg.setStrCfg(list);
|
||||
}else{
|
||||
List<BaseStringCfg> list=maatCfg.getStrCfg();
|
||||
list.add((BaseStringCfg)c);
|
||||
}
|
||||
}
|
||||
}else if(c instanceof ComplexkeywordCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
if(maatCfg.getComplexStrCfg()==null){
|
||||
List<ComplexkeywordCfg> list=new ArrayList<ComplexkeywordCfg>();
|
||||
list.add((ComplexkeywordCfg)c);
|
||||
maatCfg.setComplexStrCfg(list);
|
||||
String maatTable=c.getMaatTable();
|
||||
if(maatTable.contains(",")){
|
||||
for(String _maatTable:maatTable.split(",")){
|
||||
ComplexkeywordCfg complexCfg=(ComplexkeywordCfg)c.clone();
|
||||
complexCfg.setMaatTable(_maatTable);
|
||||
if(maatCfg.getComplexStrCfg()==null){
|
||||
List<ComplexkeywordCfg> list=new ArrayList<ComplexkeywordCfg>();
|
||||
list.add(complexCfg);
|
||||
maatCfg.setComplexStrCfg(list);
|
||||
}else{
|
||||
List<ComplexkeywordCfg> list=maatCfg.getComplexStrCfg();
|
||||
list.add(complexCfg);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
List<ComplexkeywordCfg> list=maatCfg.getComplexStrCfg();
|
||||
list.add((ComplexkeywordCfg)c);
|
||||
if(maatCfg.getComplexStrCfg()==null){
|
||||
List<ComplexkeywordCfg> list=new ArrayList<ComplexkeywordCfg>();
|
||||
list.add((ComplexkeywordCfg)c);
|
||||
maatCfg.setComplexStrCfg(list);
|
||||
}else{
|
||||
List<ComplexkeywordCfg> list=maatCfg.getComplexStrCfg();
|
||||
list.add((ComplexkeywordCfg)c);
|
||||
}
|
||||
}
|
||||
|
||||
}else if(c instanceof NumBoundaryCfg){
|
||||
compileId=compileId==0?c.getCompileId():compileId;
|
||||
if(maatCfg.getNumCfg()==null){
|
||||
|
||||
@@ -143,8 +143,22 @@ public class MultipleCfgService extends CrudService<MultipleCfgDao,MultipleSearc
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public int auditCfg(MultipleCfg sendCfg,MultipleCfg cfg) throws Exception{
|
||||
if(cfg==null) return 0;
|
||||
public boolean auditCfg(MultipleCfg sendCfg,MultipleCfg cfg) throws Exception{
|
||||
int should=0;
|
||||
if(cfg.getComplexCfg()!=null){
|
||||
should+=cfg.getComplexCfg().size();
|
||||
}
|
||||
if(cfg.getStringCfg()!=null){
|
||||
should+=cfg.getStringCfg().size();
|
||||
}
|
||||
if(cfg.getNumCfg()!=null){
|
||||
should+=cfg.getNumCfg().size();
|
||||
}
|
||||
if(cfg.getIpCfg()!=null){
|
||||
should+=cfg.getIpCfg().size();
|
||||
}
|
||||
int result=0;
|
||||
if(cfg==null) return false;
|
||||
if(Constants.AUDIT_YES==cfg.getIsAudit()||Constants.AUDIT_NOT_YES==cfg.getIsAudit()){
|
||||
List<BaseCfg> cfgs=new ArrayList<BaseCfg>();
|
||||
if(sendCfg.getIpCfg()!=null){
|
||||
@@ -172,52 +186,51 @@ public class MultipleCfgService extends CrudService<MultipleCfgDao,MultipleSearc
|
||||
if(this.sendToMaatConvertor(cfg.getIsAudit(), null, cfgArray)){
|
||||
if(cfg.getIpCfg()!=null){
|
||||
for(BaseIpCfg _cfg:cfg.getIpCfg().values()){
|
||||
ipCfgDao.audit(_cfg);
|
||||
result+=ipCfgDao.audit(_cfg);
|
||||
}
|
||||
}
|
||||
if(cfg.getStringCfg()!=null){
|
||||
for(BaseStringCfg _cfg:cfg.getStringCfg().values()){
|
||||
stringCfgDao.audit(_cfg);
|
||||
result+=stringCfgDao.audit(_cfg);
|
||||
}
|
||||
}
|
||||
if(cfg.getNumCfg()!=null){
|
||||
for(NumBoundaryCfg _cfg:cfg.getNumCfg().values()){
|
||||
numCfgDao.audit(_cfg);
|
||||
result+=numCfgDao.audit(_cfg);
|
||||
}
|
||||
}
|
||||
if(cfg.getComplexCfg()!=null){
|
||||
for(ComplexkeywordCfg _cfg:cfg.getComplexCfg().values()){
|
||||
complexStringCfgDao.audit(_cfg);
|
||||
result+=complexStringCfgDao.audit(_cfg);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return 0;
|
||||
result=0;
|
||||
}
|
||||
|
||||
}else{
|
||||
if(cfg.getIpCfg()!=null){
|
||||
for(BaseIpCfg _cfg:cfg.getIpCfg().values()){
|
||||
ipCfgDao.audit(_cfg);
|
||||
result+=ipCfgDao.audit(_cfg);
|
||||
}
|
||||
}
|
||||
if(cfg.getStringCfg()!=null){
|
||||
for(BaseStringCfg _cfg:cfg.getStringCfg().values()){
|
||||
stringCfgDao.audit(_cfg);
|
||||
result+=stringCfgDao.audit(_cfg);
|
||||
}
|
||||
}
|
||||
if(cfg.getNumCfg()!=null){
|
||||
for(NumBoundaryCfg _cfg:cfg.getNumCfg().values()){
|
||||
numCfgDao.audit(_cfg);
|
||||
result+=numCfgDao.audit(_cfg);
|
||||
}
|
||||
}
|
||||
if(cfg.getComplexCfg()!=null){
|
||||
for(ComplexkeywordCfg _cfg:cfg.getComplexCfg().values()){
|
||||
complexStringCfgDao.audit(_cfg);
|
||||
result+=complexStringCfgDao.audit(_cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return should==result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user