YSP样例配置增加有效配置规则量限制验证,如果达到规则量限制,则不允许提交。
Signed-off-by: zhangwei <zhangwei2@iie.ac.cn>
This commit is contained in:
@@ -4,6 +4,7 @@ package com.nis.web.controller.configuration.statistics;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -11,20 +12,27 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mchange.v1.util.MapUtils;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SysArea;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.util.CacheUtils;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.service.BaseService;
|
||||
import com.nis.web.service.CommonService;
|
||||
@@ -76,4 +84,33 @@ public class ConfigureStatisticsController extends BaseController{
|
||||
model.addAttribute("configStatisticTime", configureStatisticsService.getConfigStatisticTime());
|
||||
return "/index";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据业务ID查询当前业务配置是否可继续新增,如果达到规则限制量则不允许新增。
|
||||
* @param serviceId
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/getEffectiveCfgNum")
|
||||
public Map getEffectiveCfgNum(Integer serviceId, HttpServletResponse response) {
|
||||
Map map= new HashMap();
|
||||
Integer cfgNum = configureStatisticsService.getEffectiveCfgNum(serviceId);
|
||||
String dictValue = DictUtils.getDictLabel("SERVICE_RULE_LIMIT", serviceId+"","default").trim();
|
||||
Integer ruleLimit = 0;
|
||||
if(!"default".equals(dictValue)){
|
||||
ruleLimit = Integer.parseInt(dictValue);
|
||||
}
|
||||
if(ruleLimit==0){
|
||||
map.put("status", 1);//如果为0说明没有限制
|
||||
}else if(cfgNum<ruleLimit){
|
||||
map.put("status", 1);//当前配置量小于限制
|
||||
}else{
|
||||
map.put("status", 0);//当前配置量大于或等于限制,则不允许添加
|
||||
map.put("msg", String.format(this.getMsgProp().getProperty("ruleLimitTip"),ruleLimit));
|
||||
}
|
||||
map.put("cfgNum", cfgNum);
|
||||
map.put("ruleLimit", ruleLimit);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,5 @@ public interface ConfigureStatisticsDao {
|
||||
public List<Object[]> getConfigStatisticTime();
|
||||
public List<Object[]> getRequestStatisticTime();
|
||||
public List<Object[]> getRequestStateStatistics(@Param("requestList")List<RequestInfo> requestList,@Param("serviceList")List<FunctionServiceDict> serviceList) ;
|
||||
public Integer getEffectiveCfgNum(@Param("serviceId")Integer serviceId);
|
||||
}
|
||||
|
||||
@@ -45,4 +45,7 @@
|
||||
from request_num_statistics c
|
||||
group by request_id)
|
||||
</select> -->
|
||||
<select id="getEffectiveCfgNum" resultType="Integer">
|
||||
select count(distinct c.compile_id) from cfg_num_statistics c where c.service_id=#{serviceId} and c.cfg_state=1;
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -38,4 +38,7 @@ public class ConfigureStatisticsService extends CrudService<NumCfgDao,NumBoundar
|
||||
List<Object[]> dataList=configureStatisticsDao.getRequestStateStatistics(requestList,serviceList);
|
||||
return dataList;
|
||||
}
|
||||
public Integer getEffectiveCfgNum(Integer serviceId){
|
||||
return configureStatisticsDao.getEffectiveCfgNum(serviceId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1294,3 +1294,4 @@ query=Query
|
||||
cfg_operation_log=Configuration Operation Log
|
||||
function_name=Operation Module
|
||||
config_service_statistics=Config Statistics
|
||||
ruleLimitTip=The number of effective rules has reached the limit(%s).
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -153,8 +153,15 @@ $(function(){
|
||||
}
|
||||
}
|
||||
loading('onloading...');
|
||||
//如果是新增配置,则校验是否配置量已达上限
|
||||
var flag = true;
|
||||
if($("input[name='cfgId']").val()==""){
|
||||
var serviceId = $("#serviceId").val();
|
||||
flag = validateEffectiveRuleLimit("${ctx}",serviceId);
|
||||
}
|
||||
if(flag){
|
||||
form.submit();
|
||||
|
||||
}
|
||||
},
|
||||
errorContainer: "#messageBox",
|
||||
errorPlacement: function(error,element){
|
||||
|
||||
@@ -1586,7 +1586,28 @@ var setHexCaseSenstive=function(){
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
var validateEffectiveRuleLimit=function(path,serviceId){
|
||||
var flag = true;
|
||||
$.ajax({
|
||||
url: path+"/configure/statistics/getEffectiveCfgNum",
|
||||
type: "POST",
|
||||
data:{"serviceId":serviceId},
|
||||
async: false, //表单提交前验证是否可提交,所以此参数必须为false
|
||||
success: function(data) {
|
||||
if(data.status==0){
|
||||
top.$.jBox.closeTip();
|
||||
alertx(data.msg);
|
||||
flag=false;
|
||||
}
|
||||
},
|
||||
error:function(jqXHR, textStatus, errorThrown){
|
||||
top.$.jBox.closeTip();
|
||||
alertx(errorThrown);
|
||||
flag=false;
|
||||
}
|
||||
});
|
||||
return flag;
|
||||
}
|
||||
function heightDiv(type){
|
||||
var hei=document.documentElement.clientHeight;
|
||||
hei=hei-91;
|
||||
|
||||
Reference in New Issue
Block a user