社交应用功能,增加批量处理功能按钮。

This commit is contained in:
zhangwei
2018-04-08 17:19:43 +08:00
parent 40ff67f6f2
commit 75cab20b25
4 changed files with 338 additions and 260 deletions

View File

@@ -267,230 +267,248 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
* @since 1.0.0
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int auditAppCfg(AppIdCfg entity) throws Exception{
boolean sendFlag = false;
AppIdCfg appCfg = appCfgDao.getById(entity.getCfgId());
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(appCfg.getCompileId());
List<AppStringCfg> strList = new ArrayList();
List<AppComplexKeywordCfg> complexList = new ArrayList();
List<SpecificServiceHostCfg> hostList =new ArrayList();
List<BaseIpCfg> areaList = new ArrayList();
ConfigGroupInfo group = null;
Gson gson=new GsonBuilder().disableHtmlEscaping()
.excludeFieldsWithoutExposeAnnotation()
.create();
//配置审核状态即将改变后的状态
if(Constants.AUDIT_NOT_YES==entity.getIsAudit().intValue()||
Constants.AUDIT_YES==entity.getIsAudit().intValue()){//审核通过,取消审核通过需要发到maat
public int auditAppCfg(String[] cfgIds,Integer auditState) throws Exception{
for(String id:cfgIds){
boolean sendFlag = false;
AppIdCfg appCfg = appCfgDao.getById(Long.parseLong(id));
if(Constants.AUDIT_YES==entity.getIsAudit().intValue()){//审核通过
if(StringUtil.isEmpty(featuresTableList)){
SpecificServiceCfg protocol = specificServiceCfgDao.getBySpecServiceId(appCfg.getAppId().intValue());
group = specificServiceCfgDao.getConfigGroupInfoByGroupId(protocol.getGroupId());
//featuresTableList为空的时候该service只有特定服务IP一个配置表
ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId());
if(group==null){
throw new RuntimeException("配置审核失败未获取社交应用服务器IP所属分组信息");
}else{
if(group.getIsIssued()==0){
//如果分组信息尚未下发则下发IP
group.setGroupId(protocol.getGroupId());
group.setIsIssued(1);
SpecificServiceHostCfg hostCfg = new SpecificServiceHostCfg();
hostCfg.setSpecServiceId(protocol.getSpecServiceId());
hostList = specificServiceHostCfgDao.findSpecHostList(hostCfg);
for(SpecificServiceHostCfg host:hostList){
SpecificServiceCfg specServiceCfg = specificServiceCfgDao.getBySpecServiceId(host.getSpecServiceId());
host.setProtocolId(0);
host.setGroupId(specServiceCfg.getGroupId());
if(StringUtil.isEmpty(serviceCfg)){
host.setMaatTable("DF_PROTOCOL_APP");
}else{
host.setMaatTable(serviceCfg.getMaatTable());
}
}
//给需要修改的配置字段赋值
appCfg.setIsAudit(auditState);
appCfg.setAuditorId(appCfg.getCurrentUser().getId());
appCfg.setAuditTime(new Date());
if(auditState==Constants.AUDIT_NOT_YES){//取消审核通过设置有效标志为0
appCfg.setIsValid(Constants.VALID_NO);
}else if(auditState==Constants.AUDIT_YES){//审核通过设置有效标志为1
appCfg.setIsValid(Constants.VALID_YES);
}
if(appCfg.getCompileId()==0){
logger.error("转换出错,未获取到正确的compileId");
break;
}
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(appCfg.getCompileId());
List<AppStringCfg> strList = new ArrayList();
List<AppComplexKeywordCfg> complexList = new ArrayList();
List<SpecificServiceHostCfg> hostList =new ArrayList();
List<BaseIpCfg> areaList = new ArrayList();
ConfigGroupInfo group = null;
Gson gson=new GsonBuilder().disableHtmlEscaping()
.excludeFieldsWithoutExposeAnnotation()
.create();
//配置审核状态即将改变后的状态
if(Constants.AUDIT_NOT_YES==auditState||
Constants.AUDIT_YES==auditState){//审核通过,取消审核通过需要发到maat
if(Constants.AUDIT_YES==auditState){//审核通过
if(StringUtil.isEmpty(featuresTableList)){
SpecificServiceCfg protocol = specificServiceCfgDao.getBySpecServiceId(appCfg.getAppId().intValue());
group = specificServiceCfgDao.getConfigGroupInfoByGroupId(protocol.getGroupId());
//featuresTableList为空的时候该service只有特定服务IP一个配置表
ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId());
if(group==null){
throw new RuntimeException("配置审核失败未获取社交应用服务器IP所属分组信息");
}else{
SpecificServiceHostCfg host = new SpecificServiceHostCfg();
host.setGroupId(protocol.getGroupId());
hostList.add(host);
if(group.getIsIssued()==0){
//如果分组信息尚未下发则下发IP
group.setGroupId(protocol.getGroupId());
group.setIsIssued(1);
SpecificServiceHostCfg hostCfg = new SpecificServiceHostCfg();
hostCfg.setSpecServiceId(protocol.getSpecServiceId());
hostList = specificServiceHostCfgDao.findSpecHostList(hostCfg);
for(SpecificServiceHostCfg host:hostList){
SpecificServiceCfg specServiceCfg = specificServiceCfgDao.getBySpecServiceId(host.getSpecServiceId());
host.setProtocolId(0);
host.setGroupId(specServiceCfg.getGroupId());
if(StringUtil.isEmpty(serviceCfg)){
host.setMaatTable("DF_PROTOCOL_APP");
}else{
host.setMaatTable(serviceCfg.getMaatTable());
}
}
}else{
SpecificServiceHostCfg host = new SpecificServiceHostCfg();
host.setGroupId(protocol.getGroupId());
hostList.add(host);
}
}
}
//生效区域列表信息
if(appCfg.getIsAreaEffective()==1){
if(StringUtil.isEmpty(appCfg.getAreaEffectiveIds())){
BaseIpCfg ipCfg = new BaseIpCfg();
ipCfg.setCompileId(appCfg.getCompileId());
ipCfg.setTableName("area_ip_cfg");
areaList = ipCfgDao.findList(ipCfg);
//生效区域列表信息
if(appCfg.getIsAreaEffective()==1){
if(StringUtil.isEmpty(appCfg.getAreaEffectiveIds())){
BaseIpCfg ipCfg = new BaseIpCfg();
ipCfg.setCompileId(appCfg.getCompileId());
ipCfg.setTableName("area_ip_cfg");
areaList = ipCfgDao.findList(ipCfg);
}
}
}
}else{
for(AppFeaturesIndex featuresCfg:featuresTableList){
if(featuresCfg.getFeaturesTableType()==2){
List<AppStringCfg> list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppStringCfg cfg:list){
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
cfg.setMaatTable(c.getMaatTable());
}else{
for(AppFeaturesIndex featuresCfg:featuresTableList){
if(featuresCfg.getFeaturesTableType()==2){
List<AppStringCfg> list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppStringCfg cfg:list){
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
cfg.setMaatTable(c.getMaatTable());
}
}
}
cfg.setCompileId(featuresCfg.getFeaturesCompileId());
strList.add(cfg);
}
}
if(featuresCfg.getFeaturesTableType()==4){
List<AppComplexKeywordCfg> list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppComplexKeywordCfg cfg:list){
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
cfg.setMaatTable(c.getMaatTable());
}
}
}
cfg.setCompileId(featuresCfg.getFeaturesCompileId());
complexList.add(cfg);
}
cfg.setCompileId(featuresCfg.getFeaturesCompileId());
strList.add(cfg);
}
}
if(featuresCfg.getFeaturesTableType()==4){
List<AppComplexKeywordCfg> list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppComplexKeywordCfg cfg:list){
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
cfg.setMaatTable(c.getMaatTable());
}
AppMaatCfg maatCfg = new AppMaatCfg();
if(StringUtil.isEmpty(featuresTableList)){
maatCfg.setIpCfg(hostList);
maatCfg.setAreaCfg(areaList);
if(appCfg.getCompileId()==0){
throw new RuntimeException("转换出错,未获取到正确的compileId");
}else{
maatCfg.setCompileId(appCfg.getCompileId());
}
}else{//特征配置
maatCfg.setStrCfg(strList);
maatCfg.setComplexStrCfg(complexList);
}
if(appCfg.getAction()==null){
throw new RuntimeException("转换出错,未获取到正确的action");
}else{
maatCfg.setAction(appCfg.getAction());
}
if(appCfg.getIsAreaEffective()==null){
throw new RuntimeException("转换出错,未获取到正确的isAreaEffective");
}else{
maatCfg.setIsAreaEffective(appCfg.getIsAreaEffective());
}
if(appCfg.getIsValid()==null){
throw new RuntimeException("转换出错,未获取到正确的isValid");
}else{
maatCfg.setIsValid(appCfg.getIsValid());
}
if(appCfg.getRequestId()==null){
throw new RuntimeException("转换出错,未获取到正确的requestId");
}else{
maatCfg.setRequestId(appCfg.getRequestId());
}
if(appCfg.getServiceId()==null){
throw new RuntimeException("转换出错,未获取到正确的serviceId");
}else{
maatCfg.setServiceId(appCfg.getServiceId());
}
maatCfg.setSpecificServiceId(appCfg.getAppId());
maatCfg.setAreaEffectiveIds(appCfg.getAreaEffectiveIds()==null?"":appCfg.getAreaEffectiveIds());
maatCfg.setAttribute(appCfg.getAttribute()==null?"":appCfg.getAttribute());
maatCfg.setClassify(appCfg.getClassify()==null?"":appCfg.getClassify());
maatCfg.setLable(appCfg.getLable()==null?"":appCfg.getLable());
String json=gson.toJson(maatCfg);
//下发maat
// new ConvertTool().saveAppConfig(json);
sendFlag = true;
}else{//取消审核通过
AppMaatCfg maatCfg = new AppMaatCfg();
if(StringUtil.isEmpty(featuresTableList)){
ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId());
maatCfg.setMaatTable(serviceCfg.getMaatTable());
if(appCfg.getCompileId()==0){
throw new RuntimeException("转换出错,未获取到正确的compileId");
}else{
maatCfg.setCompileId(appCfg.getCompileId());
}
}else{//特征配置
for(AppFeaturesIndex featuresCfg:featuresTableList){
if(featuresCfg.getFeaturesTableType()==2){
List<AppStringCfg> list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppStringCfg cfg:list){
AppStringCfg strCfg = new AppStringCfg();
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
strCfg.setMaatTable(c.getMaatTable());
}
}
}
strCfg.setCompileId(featuresCfg.getFeaturesCompileId());
strList.add(strCfg);
}
cfg.setCompileId(featuresCfg.getFeaturesCompileId());
complexList.add(cfg);
}
}
}
}
AppMaatCfg maatCfg = new AppMaatCfg();
if(StringUtil.isEmpty(featuresTableList)){
maatCfg.setIpCfg(hostList);
maatCfg.setAreaCfg(areaList);
if(appCfg.getCompileId()==0){
throw new RuntimeException("转换出错,未获取到正确的compileId");
}else{
maatCfg.setCompileId(appCfg.getCompileId());
}
}else{//特征配置
maatCfg.setStrCfg(strList);
maatCfg.setComplexStrCfg(complexList);
}
if(appCfg.getAction()==null){
throw new RuntimeException("转换出错,未获取到正确的action");
}else{
maatCfg.setAction(appCfg.getAction());
}
if(appCfg.getIsAreaEffective()==null){
throw new RuntimeException("转换出错,未获取到正确的isAreaEffective");
}else{
maatCfg.setIsAreaEffective(appCfg.getIsAreaEffective());
}
if(appCfg.getIsValid()==null){
throw new RuntimeException("转换出错,未获取到正确的isValid");
}else{
maatCfg.setIsValid(appCfg.getIsValid());
}
if(appCfg.getRequestId()==null){
throw new RuntimeException("转换出错,未获取到正确的requestId");
}else{
maatCfg.setRequestId(appCfg.getRequestId());
}
if(appCfg.getServiceId()==null){
throw new RuntimeException("转换出错,未获取到正确的serviceId");
}else{
maatCfg.setServiceId(appCfg.getServiceId());
}
maatCfg.setSpecificServiceId(appCfg.getAppId());
maatCfg.setAreaEffectiveIds(appCfg.getAreaEffectiveIds()==null?"":appCfg.getAreaEffectiveIds());
maatCfg.setAttribute(appCfg.getAttribute()==null?"":appCfg.getAttribute());
maatCfg.setClassify(appCfg.getClassify()==null?"":appCfg.getClassify());
maatCfg.setLable(appCfg.getLable()==null?"":appCfg.getLable());
String json=gson.toJson(maatCfg);
//下发maat
// new ConvertTool().saveAppConfig(json);
sendFlag = true;
}else{//取消审核通过
AppMaatCfg maatCfg = new AppMaatCfg();
if(StringUtil.isEmpty(featuresTableList)){
ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId());
maatCfg.setMaatTable(serviceCfg.getMaatTable());
if(appCfg.getCompileId()==0){
throw new RuntimeException("转换出错,未获取到正确的compileId");
}else{
maatCfg.setCompileId(appCfg.getCompileId());
}
}else{//特征配置
for(AppFeaturesIndex featuresCfg:featuresTableList){
if(featuresCfg.getFeaturesTableType()==2){
List<AppStringCfg> list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppStringCfg cfg:list){
AppStringCfg strCfg = new AppStringCfg();
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
strCfg.setMaatTable(c.getMaatTable());
if(featuresCfg.getFeaturesTableType()==4){
List<AppComplexKeywordCfg> list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppComplexKeywordCfg cfg:list){
AppComplexKeywordCfg complexCfg = new AppComplexKeywordCfg();
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
complexCfg.setMaatTable(c.getMaatTable());
}
}
}
complexCfg.setCompileId(featuresCfg.getFeaturesCompileId());
complexList.add(complexCfg);
}
strCfg.setCompileId(featuresCfg.getFeaturesCompileId());
strList.add(strCfg);
}
}
if(featuresCfg.getFeaturesTableType()==4){
List<AppComplexKeywordCfg> list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
for(AppComplexKeywordCfg cfg:list){
AppComplexKeywordCfg complexCfg = new AppComplexKeywordCfg();
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
if(!StringUtil.isEmpty(cList)){
for(ServiceConfigInfo c:cList){
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
complexCfg.setMaatTable(c.getMaatTable());
}
}
}
complexCfg.setCompileId(featuresCfg.getFeaturesCompileId());
complexList.add(complexCfg);
}
}
maatCfg.setStrCfg(strList);
maatCfg.setComplexStrCfg(complexList);
}
maatCfg.setStrCfg(strList);
maatCfg.setComplexStrCfg(complexList);
String json=gson.toJson(maatCfg);
//下发maat
// new ConvertTool().saveAppConfig(json);
sendFlag = true;
}
String json=gson.toJson(maatCfg);
//下发maat
// new ConvertTool().saveAppConfig(json);
}else{
sendFlag = true;
}
}else{
sendFlag = false;
}
if(sendFlag){
//修改appId配置审核下发状态
appCfgDao.audit(entity);
//修改特定服务IP分组下发状态
specificServiceCfgDao.updateConfigGroupInfobyGroupId(group);
//修改特征表配置审核下发状态
for(AppFeaturesIndex cfg:featuresTableList){
appCfgDao.auditFeaturesTable(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(), entity.getIsValid(),
entity.getIsAudit(), entity.getAuditorId(), entity.getAuditTime());
if(sendFlag){
//修改appId配置审核下发状态
appCfgDao.audit(appCfg);
//修改特定服务IP分组下发状态
specificServiceCfgDao.updateConfigGroupInfobyGroupId(group);
//修改特征表配置审核下发状态
for(AppFeaturesIndex cfg:featuresTableList){
appCfgDao.auditFeaturesTable(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(), appCfg.getIsValid(),
appCfg.getIsAudit(), appCfg.getAuditorId(), appCfg.getAuditTime());
}
}else{
return 0;
}
return 1;
}else{
return 0;
}
return 1;
}
/**
*
@@ -503,22 +521,27 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
* @since 1.0.0
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int deleteAppCfg(AppIdCfg entity){
Integer status = appCfgDao.updateValid(entity);
if(status==1){
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(entity.getCompileId());
for(AppFeaturesIndex cfg:featuresTableList){
status = appCfgDao.updateFeaturesTableValid(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(),
entity.getIsValid(), entity.getEditorId(), entity.getEditTime());
if(status==0){
return 0;
public int deleteAppCfg(String[] cfgIds){
for(String id : cfgIds){
AppIdCfg entity = appCfgDao.getById(Long.parseLong(id));
entity.setEditorId(entity.getCurrentUser().getId());
entity.setEditTime(new Date());
entity.setIsValid(Constants.VALID_DEL);
Integer status = appCfgDao.updateValid(entity);
if(status==1){
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(entity.getCompileId());
for(AppFeaturesIndex cfg:featuresTableList){
status = appCfgDao.updateFeaturesTableValid(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(),
entity.getIsValid(), entity.getEditorId(), entity.getEditTime());
if(status==0){
return 0;
}
}
}else{
return 0;
}
return status;
}else{
return status;
}
// return appCfgDao.updateValid(cfg);
return 1;
}
/**
*