diff --git a/src/main/java/com/nis/web/controller/report/NtcServiceReportController.java b/src/main/java/com/nis/web/controller/report/NtcServiceReportController.java index 5c2846d3b..d452302aa 100644 --- a/src/main/java/com/nis/web/controller/report/NtcServiceReportController.java +++ b/src/main/java/com/nis/web/controller/report/NtcServiceReportController.java @@ -5,10 +5,12 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; @@ -32,17 +34,13 @@ import net.sf.json.JsonConfig; public class NtcServiceReportController extends BaseController { @RequestMapping("/ajaxNtcServiceReport") @ResponseBody - public Map report(@ModelAttribute("bean") SearchReport bean,Model model, HttpServletRequest request, HttpServletResponse response) { - Map datas=new HashMap<>(); + public List> report(@ModelAttribute("bean") SearchReport bean,Model model, HttpServletRequest request, HttpServletResponse response) { + List> datas=new ArrayList>(); List serviceList = DictUtils.getFunctionServiceDictList(bean.getFunctionId()); - if(bean.getAction()!=null){ - for(FunctionServiceDict service:serviceList){ - if(service.getAction().intValue()==bean.getAction().intValue()){ - bean.setSearchService(service.getServiceId().toString()); - } - } + StringBuffer serviceId=new StringBuffer(); + if(StringUtils.isNotBlank(bean.getServices())){ + serviceId.append(bean.getServices()); }else{ - StringBuffer serviceId=new StringBuffer(); for(int i=0;i data=getList(json); + Map dataMap=new HashMap<>(); for(NtcServiceReport report:data){ - if(datas.containsKey(report.getService().toString())){ - datas.put(report.getService().toString(), datas.get(report.getService().toString())+report.getSum().longValue()); + if(dataMap.containsKey(report.getService())){ + dataMap.put(report.getService(), dataMap.get(report.getService())+report.getSum().longValue()); }else{ - datas.put(report.getService().toString(),report.getSum().longValue()); + dataMap.put(report.getService(),report.getSum().longValue()); } } + for(Entry e:dataMap.entrySet()) { + Map _data=new HashMap<>(); + _data.put("service", e.getKey()); + _data.put("sum", e.getValue()); + datas.add(_data); + } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/src/main/webapp/WEB-INF/views/report/list.jsp b/src/main/webapp/WEB-INF/views/report/list.jsp index e393f3941..025b48826 100644 --- a/src/main/webapp/WEB-INF/views/report/list.jsp +++ b/src/main/webapp/WEB-INF/views/report/list.jsp @@ -66,32 +66,7 @@ } } }); - $(".service").each(function(){ - var target=$(this).find("span"); - var action=$(this).data("action"); - $.ajax({ - type:'post', - url:'${ctx}/report/ajaxNtcServiceReport', - data:{ - "action":action, - "functionId":$("#functionId").val(), - "reportType":$('[name="reportType"]').val(), - "reportTime":$('[name="reportTime"]').val() - }, - dataType:'json', - async:true, - success:function(data,textStatus){//处理返回结果 - if(textStatus=="success"){ - target.html(data[action]); - } - }, - complete:function(XMLHttpRequest,status){//超时设置 - if(status=="timeout"){ - target.html(timeout); - } - } - }); - }); + ajaxServiceLogTotal(); $("#export-btn").click(function(){ var te = $(".in table").tableExport({ headings:true, @@ -126,7 +101,54 @@ $("#reportTypeDiv").append(''); } } - +var ajaxServiceLogTotal=function(){ + var services=[]; + var objs=[]; + $(".service").each(function(){ + objs.push($(this)); + services.push($(this).data("service")); + }); + var timeout=$.validator.messages.timeout; + var failed=$.validator.messages.failed; + $.ajax({ + type:'post', + timeout:10000,//超时时间设置,查询接口时间过长超时 + url:'${ctx}/report/ajaxNtcServiceReport', + data:{ + "services":services.join(","), + "functionId":$("#functionId").val(), + "reportType":$('[name="reportType"]').val(), + "reportTime":$('[name="reportTime"]').val() + }, + dataType:'json', + async:true, + success:function(data,textStatus){//处理返回结果 + if(textStatus=="success"){ + for(var i=0;i'); $.ajax({ @@ -193,7 +215,7 @@ function customColumnClick(){ -
btn-primary btn-default">