调整日志配置总量查询,整页配置只查询一次,减小资源浪费
This commit is contained in:
@@ -25,21 +25,14 @@ public class NtcPzReport extends BaseReport<NtcPzReport>{
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = 7079305499220977782L;
|
||||
private Long configId;
|
||||
private Long cfgId;
|
||||
private Date statTime;
|
||||
/**
|
||||
* configId
|
||||
* @return configId
|
||||
*/
|
||||
|
||||
public Long getConfigId() {
|
||||
return configId;
|
||||
public Long getCfgId() {
|
||||
return cfgId;
|
||||
}
|
||||
/**
|
||||
* @param configId the configId to set
|
||||
*/
|
||||
public void setConfigId(Long configId) {
|
||||
this.configId = configId;
|
||||
public void setCfgId(Long cfgId) {
|
||||
this.cfgId = cfgId;
|
||||
}
|
||||
/**
|
||||
* statTime
|
||||
|
||||
@@ -50,30 +50,46 @@ import net.sf.json.JsonConfig;
|
||||
public class NtcPzReportController extends BaseController{
|
||||
@RequestMapping(value="ajaxGetLogTotal",method=RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Map<String, Object> ajaxGetLogTotal(Model model,long endTime,int action,Integer functionId,Integer compileId){
|
||||
Map<String, Object> data=new HashMap<String, Object>();
|
||||
public List<Map<String, Object>> ajaxGetLogTotal(Model model,long endTime,String actions,Integer functionId,String compileIds){
|
||||
List<Map<String, Object>> dataList=new ArrayList<>();
|
||||
SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
|
||||
int interval=Constants.LOG_TIME_RANGE;
|
||||
Date endDate=new Date(endTime);
|
||||
Date startDate=new Date(endTime-interval);
|
||||
int serviceId=0;
|
||||
String serviceIdsStr="";
|
||||
StringBuffer serviceIds=new StringBuffer();
|
||||
List<FunctionServiceDict> serviceList=DictUtils.getFunctionServiceDictList(functionId.intValue());
|
||||
for(FunctionServiceDict service:serviceList){
|
||||
if(service.getAction().intValue()==action){
|
||||
serviceId=service.getServiceId().intValue();
|
||||
break;
|
||||
for(String action:actions.split(",")) {
|
||||
for(FunctionServiceDict service:serviceList){
|
||||
if(service.getAction().intValue()==Integer.parseInt(action)){
|
||||
serviceIds.append(service.getServiceId().intValue());
|
||||
serviceIds.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
data.put("compileId", compileId.intValue());
|
||||
String json=ConfigServiceUtil.getReport(Constants.BUSINESSTYPE_CONFIG, String.valueOf(compileId), String.valueOf(serviceId), sdf.format(startDate), sdf.format(endDate));
|
||||
if(serviceIds.toString().endsWith(",")) {
|
||||
serviceIdsStr=serviceIds.toString().substring(0,serviceIds.toString().lastIndexOf(","));
|
||||
}
|
||||
String json=ConfigServiceUtil.getReport(Constants.BUSINESSTYPE_CONFIG, compileIds, serviceIdsStr, sdf.format(startDate), sdf.format(endDate));
|
||||
List<NtcPzReport> list=getList(json);
|
||||
if(list!=null&&list.size()>0){
|
||||
data.put("sum",list.get(0).getSum().longValue());
|
||||
String[] idArr=compileIds.split(",");
|
||||
if(list!=null&&(list.size()>0)){
|
||||
for(NtcPzReport report:list) {
|
||||
Map<String, Object> data=new HashMap<String, Object>();
|
||||
data.put("compileId", report.getCfgId().longValue());
|
||||
data.put("sum",report.getSum().longValue());
|
||||
dataList.add(data);
|
||||
}
|
||||
}else {
|
||||
data.put("sum", 0);
|
||||
for(String id:idArr) {
|
||||
Map<String, Object> data=new HashMap<String, Object>();
|
||||
data.put("compileId", id);
|
||||
data.put("sum",0);
|
||||
dataList.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
return dataList;
|
||||
}
|
||||
@RequestMapping("/ntcPzReport")
|
||||
public String list(@ModelAttribute("bean") SearchReport bean,Model model, HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
@@ -336,28 +336,8 @@ $(function(){
|
||||
$("input[name$='exprType']:checked").each(function(){
|
||||
setDefaultMatchMethod(this);
|
||||
});
|
||||
/*
|
||||
*配置展示日志总数,审核通过才会调用接口查询日志总量
|
||||
必须放在是否审核一列之后
|
||||
并且是否审核一列的span标签需配置data-audit="xxxx"属性
|
||||
xxxx可用值为created,approved,unapproved,cancel
|
||||
td需要配置属性有,functionId,compileId,action
|
||||
*/
|
||||
$("td[compileId]").each(function(){
|
||||
var audit=$(this).attr("audit");
|
||||
if(audit == 1){
|
||||
var data={};
|
||||
data.date=new Date();
|
||||
data.compileId=$(this).attr("compileId");
|
||||
data.action=$(this).attr("action");
|
||||
data.functionId=$(this).attr("functionId");
|
||||
data.audit=$(this).attr("audit");
|
||||
data.obj=$(this)
|
||||
GetLogTotal(data);
|
||||
}else{
|
||||
$(this).html("0");
|
||||
}
|
||||
});
|
||||
//获取配置日志总数
|
||||
getTotalLog();
|
||||
$(".action").on("change", function() {
|
||||
$("#serviceId").val($(this).attr("serviceId"));
|
||||
$("#protocolId").val($(this).attr("protocolId"));
|
||||
@@ -1116,32 +1096,77 @@ var viewAreaInfo=function(path,areaEffectiveIds,compileId){
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
var GetLogTotal=function(data){
|
||||
var getTotalLog=function(){
|
||||
/*
|
||||
td需要配置属性有,audit,functionId,compileId,action
|
||||
*/
|
||||
var data={};
|
||||
data.date=new Date();
|
||||
data.compileIds=[];
|
||||
data.actions=[];
|
||||
data.objs=[];
|
||||
$("td[compileId]").each(function(){
|
||||
var audit=$(this).attr("audit");
|
||||
var compileId=$(this).attr("compileId");
|
||||
var action=$(this).attr("action");
|
||||
var functionId=$(this).attr("functionId");
|
||||
if(audit&&compileId&&action&&functionId){
|
||||
if(audit == 1){
|
||||
var has=false;
|
||||
for(var i=0;i<data.actions.length;i++){
|
||||
if(data.actions[i]==$(this).attr("action")){
|
||||
has=true;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
data.actions.push($(this).attr("action"));
|
||||
}
|
||||
data.compileIds.push($(this).attr("compileId"));
|
||||
data.functionId=$(this).attr("functionId");
|
||||
data.objs.push($(this));
|
||||
}else{
|
||||
$(this).html("0");
|
||||
}
|
||||
}
|
||||
});
|
||||
if(data.compileIds.length>0){
|
||||
GetLogTotal(data);
|
||||
}
|
||||
|
||||
}
|
||||
var GetLogTotal=function(_data){
|
||||
var pathName=window.document.location.pathname.substring(0,window.document.location.pathname.indexOf("/nis")+4);
|
||||
var timeStamp=0;
|
||||
if(data.date){
|
||||
timeStamp=data.date.valueOf();
|
||||
if(_data.date){
|
||||
timeStamp=_data.date.valueOf();
|
||||
}else{
|
||||
timeStamp=(new Date()).valueOf();
|
||||
}
|
||||
var totalTr=$(data.obj);
|
||||
var totalTrs=$(_data.objs);
|
||||
var timeout=$.validator.messages.timeout;
|
||||
var request=$.ajax({
|
||||
type:'post',
|
||||
timeout:10000,//超时时间设置,查询接口时间过长超时
|
||||
url:pathName+'/report/ajaxGetLogTotal',
|
||||
data:{"endTime":timeStamp,"action":data.action,"functionId":data.functionId,"compileId":data.compileId},
|
||||
data:{"endTime":timeStamp,"actions":_data.actions.join(','),"functionId":_data.functionId,"compileIds":_data.compileIds.join(',')},
|
||||
dataType:'json',
|
||||
async:true,
|
||||
success:function(data,textStatus){//处理返回结果
|
||||
if(textStatus=="success"){
|
||||
totalTr.html(data.sum);
|
||||
totalTrs.each(function(){
|
||||
for(var i=0;i<data.length;i++){
|
||||
if($(this).attr("compileId")==data[i].compileId){
|
||||
$(this).html(data[i].sum);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
complete:function(XMLHttpRequest,status){//超时设置
|
||||
if(status=="timeout"){
|
||||
totalTr.html(timeout);
|
||||
totalTrs.each(function(){
|
||||
$(this).html(timeout);
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user