From 7f5d27f90aa59379e82deb41923ea10c47edc818 Mon Sep 17 00:00:00 2001 From: wangxin Date: Mon, 27 Aug 2018 15:26:32 +0800 Subject: [PATCH] =?UTF-8?q?(1)=E4=BF=AE=E5=A4=8D=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=80=BB=E9=87=8F=E6=9F=A5=E8=AF=A2=E5=9B=9E?= =?UTF-8?q?=E6=98=BE0=E7=9A=84bug=20(2)=E8=B0=83=E6=95=B4=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E6=97=A5=E5=BF=97=E6=80=BB=E9=87=8F=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E6=94=B9=E4=B8=BA=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=EF=BC=8C=E5=87=8F=E5=B0=91=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=B5=AA=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/NtcServiceReportController.java | 31 ++++---- src/main/webapp/WEB-INF/views/report/list.jsp | 78 ++++++++++++------- 2 files changed, 68 insertions(+), 41 deletions(-) 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">