Merge branch 'develop' of http://10.0.6.99/gwall/gwall.git into develop

This commit is contained in:
duandongmei
2018-09-28 14:23:39 +08:00
14 changed files with 490 additions and 312 deletions

View File

@@ -0,0 +1,50 @@
package com.nis.domain.maat;
import java.io.Serializable;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class EffectiveRangeCfg implements Serializable{
/**
*
*/
private static final long serialVersionUID = -4503782443649076836L;
@Expose
@SerializedName("tag_sets")
private List<List<AreaIsp>> effectiveRangeList;
public List<List<AreaIsp>> getEffectiveRangeList() {
return effectiveRangeList;
}
public void setEffectiveRangeList(List<List<AreaIsp>> effectiveRangeList) {
this.effectiveRangeList = effectiveRangeList;
}
public static class AreaIsp{
@Expose
private String tag;
@Expose
private List<String> value;
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public List<String> getValue() {
return value;
}
public void setValue(List<String> value) {
this.value = value;
}
@Override
public String toString() {
return "AreaIsp [tag=" + tag + ", value=" + value + "]";
}
}
}

View File

@@ -12,13 +12,14 @@ import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.StringUtils;
import com.nis.web.service.BaseService;
import com.nis.web.service.SpringContextHolder;
import com.nis.web.service.basics.SysDictInfoService;
/**
* @ClassName: MaatCfg.java
@@ -543,8 +544,10 @@ public class MaatCfg implements Serializable {
public void setAreaEffectiveIds(String areaEffectiveIds) {
if(StringUtils.isEmpty(areaEffectiveIds)){
areaEffectiveIds="0";
}else if(areaEffectiveIds.contains(":")){
areaEffectiveIds = areaEffectiveIds.replace(":", "");
}else {
// 组织区域、运营商配置下发格式
SysDictInfoService service = SpringContextHolder.getBean(SysDictInfoService.class);
areaEffectiveIds = service.setEffectiveRange(areaEffectiveIds);
}
this.areaEffectiveIds = areaEffectiveIds;
}

View File

@@ -677,4 +677,8 @@ public final class Constants {
public static final int HTTP_CONNECT_TIMEOUT= Configurations.getIntProperty("http_connect_timeout", 10000);
public static final int HTTP_CONNECT_REQUEST_TIMEOUT = Configurations.getIntProperty("http_connect_request_timeout", 50000);
public static final int HTTP_CONNECT_RETRY_TIMES = Configurations.getIntProperty("http_connect_retry_times", 3);
// 区域/运营商配置下发时tag值
public static final String AREA_TAG=Configurations.getStringProperty("area_tag","location");
public static final String ISP_TAG=Configurations.getStringProperty("isp_tag","isp");
}

View File

@@ -503,4 +503,18 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
}
return str;
}
public static String revertStr(String str,String regex){
String[] split = str.split(regex);
String value = "";
for (int i = split.length-1; i >= 0 ; i--) {
if( i != 0) {
value += split[i]+"/";
}else {
value += split[i];
}
}
return value;
}
}

View File

@@ -678,8 +678,19 @@ public class BaseController {
}else{
// 判断是否是从配置界面过来的日志查询
if(StringUtils.isNotBlank(entry.getIsLogTotalSearch())) {
Calendar time = Calendar.getInstance();
time.add(Calendar.MINUTE, -5);
String searchEndTime = DateUtils.formatDateTime(time.getTime());
params.put("searchFoundEndTime",searchEndTime);
entry.setSearchFoundEndTime(searchEndTime);
time.add(Calendar.MINUTE, -5);
String searchStartTime = DateUtils.formatDateTime(time.getTime());
params.put("searchFoundStartTime", searchStartTime);
entry.setSearchFoundStartTime(searchStartTime);
// 判断startTime是否有值
if(StringUtils.isNotBlank(Constants.LOG_TIME_START)) {
/*if(StringUtils.isNotBlank(Constants.LOG_TIME_START)) {
String endTime = Constants.LOG_TIME_END;
if(StringUtils.isBlank(endTime)) {
endTime = DateUtils.getDateTime();
@@ -717,7 +728,7 @@ public class BaseController {
params.put("searchFoundEndTime",searchEndTime);
entry.setSearchFoundStartTime(searchStartTime);
entry.setSearchFoundEndTime(searchEndTime);
}
}*/
}else {
//设置默认查询当前时间及前五分钟

View File

@@ -120,9 +120,9 @@ public class AsnIpController extends BaseController{
}
@RequestMapping(value="ajaxIsLast",method=RequestMethod.POST)
@ResponseBody
public boolean ajaxIsLast(Model model,@RequestParam(required=true,value="serviceGroupIds")String serviceGroupIds){
if(StringUtils.isNotBlank(serviceGroupIds)) {
return asnIpCfgService.hasLastIp(serviceGroupIds);
public boolean ajaxIsLast(Model model,@RequestParam(required=true,value="serviceGroupIds")String serviceGroupIds,@RequestParam(required=true,value="ids")String ids){
if(StringUtils.isNotBlank(serviceGroupIds)&&StringUtils.isNotBlank(ids)) {
return asnIpCfgService.hasLastIp(serviceGroupIds,ids);
}
return false;
}

View File

@@ -18,5 +18,5 @@ public interface AsnIpCfgDao extends CrudDao<AsnIpCfg>{
public List<AsnIpCfg> findAllList(AsnIpCfg cfg);
public List<ConfigGroupInfo> findPolicyGroupInfosByType(@Param("groupId")Integer groupId);
public List<Integer> findOtherIps(@Param("groupId")Integer groupId,@Param("cfgId")Integer cfgId);
public List<Integer> countValidIPs(@Param("ids")String ids);
public List<Integer> countValidIPs(@Param("groups")String groups,@Param("ids")String ids);
}

View File

@@ -387,7 +387,7 @@
select 1 from asn_ip_cfg where is_valid !=-1 and asn_ip_group in(${ids}) limit 1
</select>
<select id="countValidIPs" resultType="java.lang.Integer" parameterType="java.lang.Integer">
select count(1) from asn_ip_cfg where is_valid !=-1 and asn_ip_group in(${ids}) GROUP BY asn_ip_group;
select count(1) from asn_ip_cfg where is_valid !=-1 and asn_ip_group in(${groups}) and cfg_id not in(${ids}) GROUP BY asn_ip_group;
</select>
</mapper>

View File

@@ -85,9 +85,9 @@ public interface SysDictInfoDao extends CrudDao<SysDictInfo> {
*/
List<SysDictInfo> getDistrictDict(String itemCode);
List<SysDictInfo> getEffectiveArea(String itemCode);
SysDictInfo getDictByItemCode(String itemCode);

View File

@@ -263,4 +263,22 @@
FROM sys_dict_info s
WHERE s.is_valid = 1 AND item_type = 3 AND item_code like concat(#{itemCode,jdbcType=VARCHAR},'%')
</select>
<select id="getEffectiveArea" parameterType="java.lang.String" resultType="com.nis.domain.basics.SysDictInfo">
SELECT
<include refid="sysDictInfoColumns"/>
FROM
sys_dict_info s
WHERE
s.is_valid = 1 AND s.item_code = #{itemCode}
</select>
<select id="getDictByItemCode" resultType="com.nis.domain.basics.SysDictInfo">
select
<include refid="sysDictInfoColumns"/>
from
sys_dict_info s
where
s.is_valid = 1 AND s.item_code = #{itemCode}
</select>
</mapper>

View File

@@ -178,14 +178,17 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
* @param serviceGroupIds
* @return
*/
public boolean hasLastIp(String serviceGroupIds) {
public boolean hasLastIp(String serviceGroupIds,String ids) {
// TODO Auto-generated method stub
for(String groupId:serviceGroupIds.split(",")) {
Long.parseLong(groupId);
}
List<Integer> countList=asnIpCfgDao.countValidIPs(serviceGroupIds);
List<Integer> countList=asnIpCfgDao.countValidIPs(serviceGroupIds,ids);
if(countList.size()==0) {
return true;
}
for(Integer count:countList) {
if(count==1) {
if(count==0) {
return true;
}
}

View File

@@ -1,5 +1,6 @@
package com.nis.web.service.basics;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -11,9 +12,13 @@ import com.google.common.collect.Lists;
import com.nis.domain.Page;
import com.nis.domain.SysUser;
import com.nis.domain.basics.SysDictInfo;
import com.nis.domain.maat.EffectiveRangeCfg;
import com.nis.domain.maat.EffectiveRangeCfg.AreaIsp;
import com.nis.util.ConfigDictUtils;
import com.nis.util.Configurations;
import com.nis.util.Constants;
import com.nis.util.StringUtil;
import com.nis.util.StringUtils;
import com.nis.web.dao.basics.SysDictInfoDao;
import com.nis.web.security.UserUtils;
import com.nis.web.service.BaseService;
@@ -22,7 +27,7 @@ import com.nis.web.service.BaseService;
public class SysDictInfoService extends BaseService{
@Autowired
private SysDictInfoDao sysDictInfoDao;
private SysDictInfoDao sysDictInfoDao;
@@ -217,16 +222,81 @@ public class SysDictInfoService extends BaseService{
return sysDictInfoDao.getDistrictDict(tableName);
}
// 组织区域、运营商配置下发格式
public String setEffectiveRange(String areaEffectiveIds){
EffectiveRangeCfg rangeCfg = new EffectiveRangeCfg();
List<AreaIsp> areaIspList = new ArrayList();
List<String> locaValueList = new ArrayList();
List<String> ispValueList = new ArrayList();
for (String areaEffectiveId : StringUtils.split(areaEffectiveIds, ",")) {
String area = "";
// 区域和运营商
if(areaEffectiveId.contains(":")) {
int index = areaEffectiveId.indexOf(":");
String areaCode = areaEffectiveId.substring(0, index);
String ispCode = areaEffectiveId.substring(index+1);
// 查询该区域信息及其所有父节点信息
List<SysDictInfo> list = sysDictInfoDao.getEffectiveArea(areaCode);
for (SysDictInfo sysDictInfo : list) {
area += sysDictInfo.getItemValue();
while(sysDictInfo.getParent().getSysDictId() != 0) {
sysDictInfo = sysDictInfoDao.getDictById(sysDictInfo.getParent().getSysDictId());
area += "/"+sysDictInfo.getItemValue();
}
}
String areaItemValue = StringUtils.revertStr(area, "/");
if(!locaValueList.contains(areaItemValue)) {
locaValueList.add(areaItemValue);
}
// 查询运营商信息
SysDictInfo isp = sysDictInfoDao.getDictByItemCode(ispCode);
if(!ispValueList.contains(isp.getItemValue())) {
ispValueList.add(isp.getItemValue());
}
}else {
// 区域或运营商
SysDictInfo dict = sysDictInfoDao.getDictByItemCode(areaEffectiveId);
if(dict.getItemType() == 1) {
// 查询所有父节点区域信息
area += dict.getItemValue();
while(dict.getParent().getSysDictId() != 0) {
dict = sysDictInfoDao.getDictById(dict.getParent().getSysDictId());
area += "/"+dict.getItemValue();
}
String areaItemValue = StringUtils.revertStr(area, "/");
if(!locaValueList.contains(areaItemValue)) {
locaValueList.add(areaItemValue);
}
}else {
if(!ispValueList.contains(dict.getItemValue())) {
ispValueList.add(dict.getItemValue());
}
}
}
}
if(locaValueList.size() > 0) {
AreaIsp area = new AreaIsp();
area.setTag(Constants.AREA_TAG);
area.setValue(locaValueList);
areaIspList.add(area);
}
if(ispValueList.size() > 0) {
AreaIsp isp = new AreaIsp();
isp.setTag(Constants.ISP_TAG);
isp.setValue(ispValueList);
areaIspList.add(isp);
}
List<List<AreaIsp>> effectiveRangeList = new ArrayList();
effectiveRangeList.add(areaIspList);
rangeCfg.setEffectiveRangeList(effectiveRangeList);
return gsonToJson(rangeCfg);
}
}

View File

@@ -522,3 +522,5 @@ groupReuseSources=groupReuseSources
log_time_range=3600000
log_time_start=2018-08-01 00:00:00
log_time_end=2018-10-01 00:00:00
area_tag=location
isp_tag=isp

View File

@@ -50,17 +50,20 @@ function del(url){
top.$.jBox.tip("<spring:message code='has_prohibit_delete'/>", "<spring:message code='info'/>");
return;
}else{
var serviceGroupIds=[],canDel=true;
var serviceGroupIds=[],ids=[],canDel=true;
$(checkboxes).filter(":checked").each(function(){
if($(this).attr("serviceGroupId")){
serviceGroupIds.push($(this).attr("serviceGroupId"));
if($(this).attr("serviceGroupId")&&$(this).attr("isValid")){
if($(this).attr("isValid")==1){//下发过的组的ip才需要判断是否是组内最后一个IP
serviceGroupIds.push($(this).attr("serviceGroupId"));
}
ids.push($(this).attr("id"));
}
})
if(serviceGroupIds.length>0){
$.ajax({
type:'post',
url:'${ctx}/basics/asn/ajaxIsLast',
data:{"serviceGroupIds":serviceGroupIds.join(',')},
data:{"serviceGroupIds":serviceGroupIds.join(','),"ids":ids.join(',')},
async:false,
success:function(data,textStatus){//处理返回结果
if(data){