报表调整,注释掉测试数据,返回接口真正的数据

This commit is contained in:
wangxin
2018-07-17 11:30:45 +08:00
parent 9400b7e089
commit 5666a93160
10 changed files with 478 additions and 254 deletions

View File

@@ -9,7 +9,12 @@
package com.nis.domain.report; package com.nis.domain.report;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.URI; import java.net.URI;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.ws.rs.client.Client; import javax.ws.rs.client.Client;
@@ -20,6 +25,14 @@ import javax.ws.rs.core.UriBuilder;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.RestfulResult; import com.nis.domain.RestfulResult;
import com.nis.domain.log.SearchReport; import com.nis.domain.log.SearchReport;
@@ -66,7 +79,7 @@ public class ReportResult<T extends BaseReport> extends RestfulResult{
public void setData(Page<T> data) { public void setData(Page<T> data) {
this.data = data; this.data = data;
} }
public ReportResult<T> getReport(String reportUrl, SearchReport searchCondition) throws MaatConvertException, UnsupportedEncodingException{ public String getReport(String reportUrl, SearchReport searchCondition) throws MaatConvertException, UnsupportedEncodingException{
// if(StringUtils.isBlank(searchCondition.getSearchService())){ // if(StringUtils.isBlank(searchCondition.getSearchService())){
// throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>"); // throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
// } // }
@@ -74,7 +87,9 @@ public class ReportResult<T extends BaseReport> extends RestfulResult{
ReportResult<T> bean = null; ReportResult<T> bean = null;
UriBuilder builder=UriBuilder.fromPath(reportUrl); UriBuilder builder=UriBuilder.fromPath(reportUrl);
builder.queryParam("searchBusinessType",searchCondition.getSearchBusinessType()); builder.queryParam("searchBusinessType",searchCondition.getSearchBusinessType());
builder.queryParam("searchService",searchCondition.getSearchService()); if(StringUtils.isNotBlank(searchCondition.getSearchService())) {
builder.queryParam("searchService",searchCondition.getSearchService());
}
if(searchCondition.getSearchCondition()!=null){ if(searchCondition.getSearchCondition()!=null){
for(Entry<String, Object> e:searchCondition.getSearchCondition().entrySet()){ for(Entry<String, Object> e:searchCondition.getSearchCondition().entrySet()){
builder.queryParam(e.getKey(),e.getValue()); builder.queryParam(e.getKey(),e.getValue());
@@ -108,12 +123,10 @@ public class ReportResult<T extends BaseReport> extends RestfulResult{
Response response= header.get(); Response response= header.get();
if( response.getStatus() == 200){ if( response.getStatus() == 200){
result= response.readEntity(String.class); result= response.readEntity(String.class);
Gson gson=Constants.gsonbuilder.create();
bean = gson.fromJson(result, new TypeToken<ReportResult<T>>(){
private static final long serialVersionUID = 7963055764864141968L;}.getType());
}else{ }else{
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class)); throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
} }
return bean; return result;
} }
} }

View File

@@ -355,6 +355,9 @@ public final class Constants {
public static final String NTC_SERVICE_REPORT=Configurations.getStringProperty("ntcServiceReport","ntcServiceReport"); public static final String NTC_SERVICE_REPORT=Configurations.getStringProperty("ntcServiceReport","ntcServiceReport");
public static final String NTC_TAG_REPORT=Configurations.getStringProperty("ntcTagReport","ntcTagReport"); public static final String NTC_TAG_REPORT=Configurations.getStringProperty("ntcTagReport","ntcTagReport");
public static final String NTC_PZ_REPORT=Configurations.getStringProperty("ntcPzReport","ntcPzReport"); public static final String NTC_PZ_REPORT=Configurations.getStringProperty("ntcPzReport","ntcPzReport");
public static final String NTC_NTC_SRCIP_REPORT=Configurations.getStringProperty("ntcSrcipDomesticReport","ntcSrcipDomesticReport");
public static final String NTC_NTC_DESTIP_REPORT=Configurations.getStringProperty("ntcDestipCountryReport","ntcDestipCountryReport");
public static final String NTC_NTC_LWHH_REPORT=Configurations.getStringProperty("ntcLwhhReport","ntcLwhhReport");
public static final String NTC_IP_LOG = Configurations.getStringProperty("ntcIpLog",""); public static final String NTC_IP_LOG = Configurations.getStringProperty("ntcIpLog","");
public static final String NTC_HTTP_LOG = Configurations.getStringProperty("ntcHttpLog",""); public static final String NTC_HTTP_LOG = Configurations.getStringProperty("ntcHttpLog","");
public static final String NTC_DNS_LOG = Configurations.getStringProperty("ntcDnsLog",""); public static final String NTC_DNS_LOG = Configurations.getStringProperty("ntcDnsLog","");

View File

@@ -3,12 +3,10 @@ package com.nis.web.controller.report;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -18,11 +16,12 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.log.SearchReport; import com.nis.domain.log.SearchReport;
import com.nis.domain.report.NtcTagReport; import com.nis.domain.report.NtcDestIpReport;
import com.nis.domain.report.ReportResult; import com.nis.domain.report.ReportResult;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.DictUtils; import com.nis.util.DictUtils;
@@ -67,22 +66,75 @@ public class NtcDestIpReportController extends BaseController {
} }
List<String> titles=this.getDateTitiles(bean); List<String> titles=this.getDateTitiles(bean);
model.addAttribute("titles", titles); model.addAttribute("titles", titles);
try {
HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合 ReportResult<NtcDestIpReport> result=new ReportResult<>();
List<Long> line= new ArrayList<Long>(); StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_NTC_DESTIP_REPORT);
long total=0l; Gson gson=Constants.gsonbuilder.create();
for(String title:titles){ String json=result.getReport(url.toString(), bean);
line.add(10000l); result = gson.fromJson(json, new TypeToken<ReportResult<NtcDestIpReport>>() {
total+=10000l; }.getType());
Page<NtcDestIpReport> page=result.getData();
List<NtcDestIpReport> list=page.getList();
HashMap<String,Long> trimData=new HashMap<>();//数据累加去重
SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
for(NtcDestIpReport report:list){
String trimStr="";
if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
trimStr=report.getDestCountry().trim()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,13);
}else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
trimStr=report.getDestCountry().trim()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,10);
}else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
trimStr=report.getDestCountry().trim()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,7);
}
if(trimData.containsKey(trimStr)){
trimData.put(trimStr, trimData.get(trimStr)+report.getSum().longValue());
}else{
trimData.put(trimStr, report.getSum().longValue());
}
}
HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
for(Entry<String, Long> counrty:trimData.entrySet()){
String[] keyArr=counrty.getKey().split(Constants.REPORT_TRIM_CONNECTOR);
List<Long> line= new ArrayList<Long>();
long total=0;
for(String title:titles){
if(trimData.containsKey(keyArr[0]+Constants.REPORT_TRIM_CONNECTOR+title)){
line.add(trimData.get(keyArr[0]+Constants.REPORT_TRIM_CONNECTOR+title));
total+=trimData.get(keyArr[0]+Constants.REPORT_TRIM_CONNECTOR+title).longValue();
}else{
line.add(0l);
}
}
List<Long> _line= new ArrayList<Long>();
_line.add(total);
_line.addAll(line);
showData.put(keyArr[0], _line);
}
model.addAttribute("datas", showData);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
} }
List<Long> _line= new ArrayList<Long>(); // HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
_line.add(total); // List<Long> line= new ArrayList<Long>();
_line.addAll(line); // long total=0l;
for (int i = 0; i < 40; i++) { // for(String title:titles){
showData.put("巴西"+i, _line); // line.add(10000l);
} // total+=10000l;
// }
model.addAttribute("datas", showData); // List<Long> _line= new ArrayList<Long>();
// _line.add(total);
// _line.addAll(line);
// for (int i = 0; i < 40; i++) {
// showData.put("巴西"+i, _line);
// }
//
// model.addAttribute("datas", showData);
return "/report/destIp"; return "/report/destIp";
} }
} }

View File

@@ -3,12 +3,10 @@ package com.nis.web.controller.report;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -18,11 +16,12 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.log.SearchReport; import com.nis.domain.log.SearchReport;
import com.nis.domain.report.NtcTagReport; import com.nis.domain.report.NtcEntranceReport;
import com.nis.domain.report.ReportResult; import com.nis.domain.report.ReportResult;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.DictUtils; import com.nis.util.DictUtils;
@@ -67,22 +66,75 @@ public class NtcEntranceReportController extends BaseController {
} }
List<String> titles=this.getDateTitiles(bean); List<String> titles=this.getDateTitiles(bean);
model.addAttribute("titles", titles); model.addAttribute("titles", titles);
try {
HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合 ReportResult<NtcEntranceReport> result=new ReportResult<>();
List<Long> line= new ArrayList<Long>(); StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_NTC_DESTIP_REPORT);
long total=0l; Gson gson=Constants.gsonbuilder.create();
for(String title:titles){ String json=result.getReport(url.toString(), bean);
line.add(10000l); result = gson.fromJson(json, new TypeToken<ReportResult<NtcEntranceReport>>() {
total+=10000l; }.getType());
Page<NtcEntranceReport> page=result.getData();
List<NtcEntranceReport> list=page.getList();
HashMap<String,Long> trimData=new HashMap<>();//数据累加去重
SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
for(NtcEntranceReport report:list){
String trimStr="";
if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
trimStr=report.getEntranceId().intValue()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,13);
}else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
trimStr=report.getEntranceId().intValue()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,10);
}else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
trimStr=report.getEntranceId().intValue()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,7);
}
if(trimData.containsKey(trimStr)){
trimData.put(trimStr, trimData.get(trimStr)+report.getSum().longValue());
}else{
trimData.put(trimStr, report.getSum().longValue());
}
}
HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
for(Entry<String, Long> counrty:trimData.entrySet()){
String[] keyArr=counrty.getKey().split(Constants.REPORT_TRIM_CONNECTOR);
List<Long> line= new ArrayList<Long>();
long total=0;
for(String title:titles){
if(trimData.containsKey(keyArr[0]+Constants.REPORT_TRIM_CONNECTOR+title)){
line.add(trimData.get(keyArr[0]+Constants.REPORT_TRIM_CONNECTOR+title));
total+=trimData.get(keyArr[0]+Constants.REPORT_TRIM_CONNECTOR+title).longValue();
}else{
line.add(0l);
}
}
List<Long> _line= new ArrayList<Long>();
_line.add(total);
_line.addAll(line);
showData.put(keyArr[0], _line);
}
model.addAttribute("datas", showData);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
} }
List<Long> _line= new ArrayList<Long>(); // HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
_line.add(total); // List<Long> line= new ArrayList<Long>();
_line.addAll(line); // long total=0l;
for (int i = 0; i < 40; i++) { // for(String title:titles){
showData.put(""+i, _line); // line.add(10000l);
} // total+=10000l;
// }
model.addAttribute("datas", showData); // List<Long> _line= new ArrayList<Long>();
// _line.add(total);
// _line.addAll(line);
// for (int i = 0; i < 40; i++) {
// showData.put(""+i, _line);
// }
//
// model.addAttribute("datas", showData);
return "/report/entranceId"; return "/report/entranceId";
} }
} }

View File

@@ -3,8 +3,6 @@ package com.nis.web.controller.report;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -17,9 +15,10 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.configuration.RequestInfo; import com.nis.domain.configuration.RequestInfo;
import com.nis.domain.log.SearchReport; import com.nis.domain.log.SearchReport;
import com.nis.domain.report.NtcLwhhReport; import com.nis.domain.report.NtcLwhhReport;
@@ -54,8 +53,6 @@ public class NtcLwhhReportController extends BaseController {
bean.setSearchService(serviceId.toString()); bean.setSearchService(serviceId.toString());
} }
bean.setSearchBusinessType("1"); bean.setSearchBusinessType("1");
ReportResult<NtcLwhhReport> result=new ReportResult<>();
StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_SERVICE_REPORT+"?");
bean.setPageSize(-1); bean.setPageSize(-1);
bean.setFields("lwhh,sum,reportTime"); bean.setFields("lwhh,sum,reportTime");
try { try {
@@ -66,67 +63,73 @@ public class NtcLwhhReportController extends BaseController {
} }
List<String> titles=this.getDateTitiles(bean); List<String> titles=this.getDateTitiles(bean);
model.addAttribute("titles", titles); model.addAttribute("titles", titles);
// try { try {
// result=result.getReport(url.toString(), bean); ReportResult<NtcLwhhReport> result=new ReportResult<>();
// Page<NtcLwhhReportLog> page=result.getData(); StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_NTC_LWHH_REPORT);
// List<NtcLwhhReportLog> list=page.getList(); Gson gson=Constants.gsonbuilder.create();
// HashMap<String,Long> trimData=new HashMap<>();//数据累加去重 String json=result.getReport(url.toString(), bean);
// for(NtcLwhhReportLog report:list){ result = gson.fromJson(json, new TypeToken<ReportResult<NtcLwhhReport>>() {
// String trimStr=""; }.getType());
// if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){ Page<NtcLwhhReport> page=result.getData();
// trimStr=report.getLwhh().intValue()+Constants.REPORT_TRIM_CONNECTOR+ List<NtcLwhhReport> list=page.getList();
// sdf.format(cal.getTime()).substring(0,13); HashMap<String,Long> trimData=new HashMap<>();//数据累加去重
// SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
// }else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){ for(NtcLwhhReport report:list){
// trimStr=report.getLwhh().intValue()+Constants.REPORT_TRIM_CONNECTOR+ String trimStr="";
// sdf.format(cal.getTime()).substring(0,10); if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
// trimStr=report.getLwhh().intValue()+Constants.REPORT_TRIM_CONNECTOR+
// }else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){ sdf.format(report.getReportTime()).substring(0,13);
// trimStr=report.getLwhh().intValue()+Constants.REPORT_TRIM_CONNECTOR+
// sdf.format(cal.getTime()).substring(0,7); }else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
// } trimStr=report.getLwhh().intValue()+Constants.REPORT_TRIM_CONNECTOR+
// if(trimData.containsKey(trimStr)){ sdf.format(report.getReportTime()).substring(0,10);
// trimData.put(trimStr, trimData.get(trimStr)+report.getSum().longValue());
// }else{ }else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
// trimData.put(trimStr, report.getSum().longValue()); trimStr=report.getLwhh().intValue()+Constants.REPORT_TRIM_CONNECTOR+
// } sdf.format(report.getReportTime()).substring(0,7);
// } }
// HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合 if(trimData.containsKey(trimStr)){
// for(RequestInfo requestInfo:requestInfos){ trimData.put(trimStr, trimData.get(trimStr)+report.getSum().longValue());
// List<Long> line= new ArrayList<Long>(); }else{
// long total=0; trimData.put(trimStr, report.getSum().longValue());
// for(String title:titles){ }
// if(trimData.containsKey(requestInfo.getId().longValue()+Constants.REPORT_TRIM_CONNECTOR+title)){
// line.add(trimData.get(requestInfo.getId().longValue()+Constants.REPORT_TRIM_CONNECTOR+title));
// total+=trimData.get(requestInfo.getId().longValue()+Constants.REPORT_TRIM_CONNECTOR+title).longValue();
// }else{
// line.add(0l);
// }
// }
// List<Long> _line= new ArrayList<Long>();
// _line.add(total);
// _line.addAll(line);
// showData.put(requestInfo.getId().toString(), _line);
// }
// model.addAttribute("datas", showData);
// } catch (Exception e) {
// // TODO: handle exception
// e.printStackTrace();
// }
HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
for(RequestInfo requestInfo:requestInfos){
List<Long> line= new ArrayList<Long>();
long total=0l;
for(String title:titles){
line.add(10000l);
total+=10000l;
} }
List<Long> _line= new ArrayList<Long>(); HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
_line.add(total); for(RequestInfo requestInfo:requestInfos){
_line.addAll(line); List<Long> line= new ArrayList<Long>();
showData.put(requestInfo.getId().toString(), _line); long total=0;
for(String title:titles){
if(trimData.containsKey(requestInfo.getId().longValue()+Constants.REPORT_TRIM_CONNECTOR+title)){
line.add(trimData.get(requestInfo.getId().longValue()+Constants.REPORT_TRIM_CONNECTOR+title));
total+=trimData.get(requestInfo.getId().longValue()+Constants.REPORT_TRIM_CONNECTOR+title).longValue();
}else{
line.add(0l);
}
}
List<Long> _line= new ArrayList<Long>();
_line.add(total);
_line.addAll(line);
showData.put(requestInfo.getId().toString(), _line);
}
model.addAttribute("datas", showData);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
} }
model.addAttribute("datas", showData); // HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
// for(RequestInfo requestInfo:requestInfos){
// List<Long> line= new ArrayList<Long>();
// long total=0l;
// for(String title:titles){
// line.add(10000l);
// total+=10000l;
// }
// List<Long> _line= new ArrayList<Long>();
// _line.add(total);
// _line.addAll(line);
// showData.put(requestInfo.getId().toString(), _line);
// }
// model.addAttribute("datas", showData);
return "/report/lwhh"; return "/report/lwhh";
} }
} }

View File

@@ -24,6 +24,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.basics.ServiceDictInfo; import com.nis.domain.basics.ServiceDictInfo;
@@ -97,12 +99,15 @@ public class NtcPzReportController extends BaseController{
bean.setSearchService(serviceId.toString()); bean.setSearchService(serviceId.toString());
} }
ReportResult<NtcPzReport> result=new ReportResult<>(); ReportResult<NtcPzReport> result=new ReportResult<>();
StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_PZ_REPORT+"?"); StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_PZ_REPORT);
List<String> titles=this.getDateTitiles(bean); List<String> titles=this.getDateTitiles(bean);
model.addAttribute("titles", titles); model.addAttribute("titles", titles);
try { try {
result=result.getReport(url.toString(), bean); Gson gson=Constants.gsonbuilder.create();
String json=result.getReport(url.toString(), bean);
result = gson.fromJson(json, new TypeToken<ReportResult<NtcPzReport>>() {
}.getType());
Page<NtcPzReport> page=result.getData(); Page<NtcPzReport> page=result.getData();
List<NtcPzReport> list=page.getList(); List<NtcPzReport> list=page.getList();
model.addAttribute("datas", list); model.addAttribute("datas", list);

View File

@@ -1,6 +1,5 @@
package com.nis.web.controller.report; package com.nis.web.controller.report;
import java.io.UnsupportedEncodingException;
import java.text.ParseException; import java.text.ParseException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -15,12 +14,13 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.log.SearchReport; import com.nis.domain.log.SearchReport;
import com.nis.domain.report.NtcServiceReport; import com.nis.domain.report.NtcServiceReport;
import com.nis.domain.report.ReportResult; import com.nis.domain.report.ReportResult;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.DictUtils; import com.nis.util.DictUtils;
import com.nis.web.controller.BaseController; import com.nis.web.controller.BaseController;
@@ -31,7 +31,7 @@ public class NtcServiceReportController extends BaseController {
@RequestMapping("/ajaxNtcServiceReport") @RequestMapping("/ajaxNtcServiceReport")
@ResponseBody @ResponseBody
public Map<String, Long> report(@ModelAttribute("bean") SearchReport bean,Model model, HttpServletRequest request, HttpServletResponse response) { public Map<String, Long> report(@ModelAttribute("bean") SearchReport bean,Model model, HttpServletRequest request, HttpServletResponse response) {
Map<String, Long> data=new HashMap<>(); Map<String, Long> datas=new HashMap<>();
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(bean.getFunctionId()); List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(bean.getFunctionId());
if(bean.getAction()!=null){ if(bean.getAction()!=null){
for(FunctionServiceDict service:serviceList){ for(FunctionServiceDict service:serviceList){
@@ -59,25 +59,28 @@ public class NtcServiceReportController extends BaseController {
e1.printStackTrace(); e1.printStackTrace();
} }
ReportResult<NtcServiceReport> result=new ReportResult<>(); ReportResult<NtcServiceReport> result=new ReportResult<>();
StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_SERVICE_REPORT+"?"); StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_SERVICE_REPORT);
// try { try {
// result=result.getReport(url.toString(), bean); Gson gson=Constants.gsonbuilder.create();
// Page<NtcServiceReport> page=result.getData(); String json=result.getReport(url.toString(), bean);
// List<NtcServiceReport> data=page.getList(); result = gson.fromJson(json, new TypeToken<ReportResult<NtcServiceReport>>() {
// for(NtcServiceReport report:data){ }.getType());
// if(datas.containsKey(report.getService().toString())){ Page<NtcServiceReport> page=result.getData();
// data.put(report.getService().toString(), datas.get(report.getService().toString())+report.getSum().longValue()); List<NtcServiceReport> data=page.getList();
// }else{ for(NtcServiceReport report:data){
// data.put(report.getService().toString(),report.getSum().longValue()); if(datas.containsKey(report.getService().toString())){
// } datas.put(report.getService().toString(), datas.get(report.getService().toString())+report.getSum().longValue());
// } }else{
// } catch (Exception e) { datas.put(report.getService().toString(),report.getSum().longValue());
// // TODO Auto-generated catch block }
// e.printStackTrace(); }
// } } catch (Exception e) {
if(bean.getAction()!=null){ // TODO Auto-generated catch block
data.put(bean.getAction().toString(), 66666666l); e.printStackTrace();
} }
return data; // if(bean.getAction()!=null){
// data.put(bean.getAction().toString(), 66666666l);
// }
return datas;
} }
} }

View File

@@ -3,8 +3,6 @@ package com.nis.web.controller.report;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -12,15 +10,15 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.log.SearchReport; import com.nis.domain.log.SearchReport;
import com.nis.domain.report.NtcSrcipDomesticReport; import com.nis.domain.report.NtcSrcipDomesticReport;
import com.nis.domain.report.ReportResult; import com.nis.domain.report.ReportResult;
@@ -53,8 +51,6 @@ public class NtcSrcipDomesticReportController extends BaseController {
} }
bean.setSearchBusinessType("1"); bean.setSearchBusinessType("1");
ReportResult<NtcSrcipDomesticReport> result=new ReportResult<>();
StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_SERVICE_REPORT+"?");
bean.setPageSize(-1); bean.setPageSize(-1);
bean.setFields("srcProvince,srcCity,sum,reportTime"); bean.setFields("srcProvince,srcCity,sum,reportTime");
try { try {
@@ -95,44 +91,84 @@ public class NtcSrcipDomesticReportController extends BaseController {
// } // }
// HashMap<String,List<Long>> showData=new HashMap<>();//构造数据展示集合 // HashMap<String,List<Long>> showData=new HashMap<>();//构造数据展示集合
// //
// for(String key:trimData.keySet()){
// List<Long> line= new ArrayList<Long>();
// long total=0;
// String[] keyArr=key.split(Constants.REPORT_TRIM_CONNECTOR);
// String location=keyArr[0]+Constants.REPORT_TRIM_CONNECTOR+keyArr[1];
// for(String title:titles){
// if(trimData.containsKey(location+Constants.REPORT_TRIM_CONNECTOR+title)){
// line.add(trimData.get(location+Constants.REPORT_TRIM_CONNECTOR+title));
// total+=trimData.get(location+Constants.REPORT_TRIM_CONNECTOR+title).longValue();
// }else{
// line.add(0l);
// }
// }
// List<Long> _line= new ArrayList<Long>();
// _line.add(total);
// _line.addAll(line);
// showData.put(location, _line);
// }
// model.addAttribute("datas", showData);
// } catch (Exception e) { // } catch (Exception e) {
// // TODO: handle exception // // TODO: handle exception
// e.printStackTrace(); // e.printStackTrace();
// } // }
HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合 try {
long total=0; ReportResult<NtcSrcipDomesticReport> result=new ReportResult<>();
List<Long> line= new ArrayList<Long>(); StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_NTC_SRCIP_REPORT);
for(String title:titles){ Gson gson=Constants.gsonbuilder.create();
line.add(10000l); String json=result.getReport(url.toString(), bean);
total+=10000l; result = gson.fromJson(json, new TypeToken<ReportResult<NtcSrcipDomesticReport>>() {
}.getType());
Page<NtcSrcipDomesticReport> page=result.getData();
List<NtcSrcipDomesticReport> list=page.getList();
HashMap<String,Long> trimData=new HashMap<>();//数据累加去重
SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
for(NtcSrcipDomesticReport report:list){
String trimStr="";
if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
trimStr=report.getSrcProvince().trim()+Constants.REPORT_TRIM_CONNECTOR+
report.getSrcCity().trim()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,13);
}else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
trimStr=report.getSrcProvince().trim()+Constants.REPORT_TRIM_CONNECTOR+
report.getSrcCity().trim()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,10);
}else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
trimStr=report.getSrcProvince().trim()+Constants.REPORT_TRIM_CONNECTOR+
report.getSrcCity().trim()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,7);
}
if(trimData.containsKey(trimStr)){
trimData.put(trimStr, trimData.get(trimStr)+report.getSum().longValue());
}else{
trimData.put(trimStr, report.getSum().longValue());
}
}
HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
for(String key:trimData.keySet()){
List<Long> line= new ArrayList<Long>();
long total=0;
String[] keyArr=key.split(Constants.REPORT_TRIM_CONNECTOR);
String location=keyArr[0]+Constants.REPORT_TRIM_CONNECTOR+keyArr[1];
for(String title:titles){
if(trimData.containsKey(location+Constants.REPORT_TRIM_CONNECTOR+title)){
line.add(trimData.get(location+Constants.REPORT_TRIM_CONNECTOR+title));
total+=trimData.get(location+Constants.REPORT_TRIM_CONNECTOR+title).longValue();
}else{
line.add(0l);
}
}
List<Long> _line= new ArrayList<Long>();
_line.add(total);
_line.addAll(line);
showData.put(location, _line);
}
model.addAttribute("splitor", Constants.REPORT_TRIM_CONNECTOR);
model.addAttribute("datas", showData);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
} }
List<Long> _line= new ArrayList<Long>(); // HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
_line.add(total); // long total=0;
_line.addAll(line); // List<Long> line= new ArrayList<Long>();
for(int i=0;i<1000;i++){ // for(String title:titles){
showData.put("河北"+Constants.REPORT_TRIM_CONNECTOR+"廊坊"+i, _line); // line.add(10000l);
} // total+=10000l;
model.addAttribute("splitor", Constants.REPORT_TRIM_CONNECTOR); // }
model.addAttribute("datas", showData); // List<Long> _line= new ArrayList<Long>();
// _line.add(total);
// _line.addAll(line);
// for(int i=0;i<1000;i++){
// showData.put("河北"+Constants.REPORT_TRIM_CONNECTOR+"廊坊"+i, _line);
// }
// model.addAttribute("splitor", Constants.REPORT_TRIM_CONNECTOR);
// model.addAttribute("datas", showData);
return "/report/srcIp"; return "/report/srcIp";
} }
} }

View File

@@ -3,8 +3,6 @@ package com.nis.web.controller.report;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -17,7 +15,10 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.basics.ServiceDictInfo; import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.log.SearchReport; import com.nis.domain.log.SearchReport;
import com.nis.domain.report.NtcTagReport; import com.nis.domain.report.NtcTagReport;
@@ -52,8 +53,7 @@ public class NtcTagReportController extends BaseController {
bean.setSearchService(serviceId.toString()); bean.setSearchService(serviceId.toString());
} }
bean.setSearchBusinessType("1"); bean.setSearchBusinessType("1");
ReportResult<NtcTagReport> result=new ReportResult<>();
StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_SERVICE_REPORT+"?");
bean.setPageSize(-1); bean.setPageSize(-1);
bean.setFields("tag,sum,reportTime"); bean.setFields("tag,sum,reportTime");
try { try {
@@ -64,67 +64,73 @@ public class NtcTagReportController extends BaseController {
} }
List<String> titles=this.getDateTitiles(bean); List<String> titles=this.getDateTitiles(bean);
model.addAttribute("titles", titles); model.addAttribute("titles", titles);
// try { try {
// result=result.getReport(url.toString(), bean); ReportResult<NtcTagReport> result=new ReportResult<>();
// Page<NtcTagReportLog> page=result.getData(); StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_TAG_REPORT);
// List<NtcTagReportLog> list=page.getList(); Gson gson=Constants.gsonbuilder.create();
// HashMap<String,Long> trimData=new HashMap<>();//数据累加去重 String json=result.getReport(url.toString(), bean);
// for(NtcTagReportLog report:list){ result = gson.fromJson(json, new TypeToken<ReportResult<NtcTagReport>>() {
// String trimStr=""; }.getType());
// if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){ Page<NtcTagReport> page=result.getData();
// trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+ List<NtcTagReport> list=page.getList();
// sdf.format(cal.getTime()).substring(0,13); HashMap<String,Long> trimData=new HashMap<>();//数据累加去重
// SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
// }else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){ for(NtcTagReport report:list){
// trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+ String trimStr="";
// sdf.format(cal.getTime()).substring(0,10); if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
// trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+
// }else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){ sdf.format(report.getReportTime()).substring(0,13);
// trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+
// sdf.format(cal.getTime()).substring(0,7); }else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
// } trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+
// if(trimData.containsKey(trimStr)){ sdf.format(report.getReportTime()).substring(0,10);
// trimData.put(trimStr, trimData.get(trimStr)+report.getSum().longValue());
// }else{ }else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
// trimData.put(trimStr, report.getSum().longValue()); trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+
// } sdf.format(report.getReportTime()).substring(0,7);
// } }
// HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合 if(trimData.containsKey(trimStr)){
// for(ServiceDictInfo label:lables){ trimData.put(trimStr, trimData.get(trimStr)+report.getSum().longValue());
// List<Long> line= new ArrayList<Long>(); }else{
// long total=0; trimData.put(trimStr, report.getSum().longValue());
// for(String title:titles){ }
// if(trimData.containsKey(label.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title)){
// line.add(trimData.get(label.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title));
// total+=trimData.get(label.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title).longValue();
// }else{
// line.add(0l);
// }
// }
// List<Long> _line= new ArrayList<Long>();
// _line.add(total);
// _line.addAll(line);
// showData.put(label.getServiceDictId().toString(), _line);
// }
// model.addAttribute("datas", showData);
// } catch (Exception e) {
// // TODO: handle exception
// e.printStackTrace();
// }
HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
for(ServiceDictInfo label:labels){
List<Long> line= new ArrayList<Long>();
long total=0l;
for(String title:titles){
line.add(10000l);
total+=10000l;
} }
List<Long> _line= new ArrayList<Long>(); HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
_line.add(total); for(ServiceDictInfo label:labels){
_line.addAll(line); List<Long> line= new ArrayList<Long>();
showData.put(label.getServiceDictId().toString(), _line); long total=0;
for(String title:titles){
if(trimData.containsKey(label.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title)){
line.add(trimData.get(label.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title));
total+=trimData.get(label.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title).longValue();
}else{
line.add(0l);
}
}
List<Long> _line= new ArrayList<Long>();
_line.add(total);
_line.addAll(line);
showData.put(label.getServiceDictId().toString(), _line);
}
model.addAttribute("datas", showData);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
} }
model.addAttribute("datas", showData); // HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
// for(ServiceDictInfo label:labels){
// List<Long> line= new ArrayList<Long>();
// long total=0l;
// for(String title:titles){
// line.add(10000l);
// total+=10000l;
// }
// List<Long> _line= new ArrayList<Long>();
// _line.add(total);
// _line.addAll(line);
// showData.put(label.getServiceDictId().toString(), _line);
// }
// model.addAttribute("datas", showData);
return "/report/label"; return "/report/label";
} }
} }

View File

@@ -3,9 +3,6 @@ package com.nis.web.controller.report;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -18,11 +15,13 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.basics.ServiceDictInfo; import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.log.SearchReport; import com.nis.domain.log.SearchReport;
import com.nis.domain.report.NtcTagReport; import com.nis.domain.report.NtcAttrTypeReport;
import com.nis.domain.report.ReportResult; import com.nis.domain.report.ReportResult;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.DictUtils; import com.nis.util.DictUtils;
@@ -67,21 +66,73 @@ public class NtcXzReportController extends BaseController {
} }
List<String> titles=this.getDateTitiles(bean); List<String> titles=this.getDateTitiles(bean);
model.addAttribute("titles", titles); model.addAttribute("titles", titles);
try {
HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合 ReportResult<NtcAttrTypeReport> result=new ReportResult<>();
for(ServiceDictInfo xz:xzs){ StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_TAG_REPORT);
List<Long> line= new ArrayList<Long>(); Gson gson=Constants.gsonbuilder.create();
long total=0l; String json=result.getReport(url.toString(), bean);
for(String title:titles){ result = gson.fromJson(json, new TypeToken<ReportResult<NtcAttrTypeReport>>() {
line.add(10000l); }.getType());
total+=10000l; Page<NtcAttrTypeReport> page=result.getData();
List<NtcAttrTypeReport> list=page.getList();
HashMap<String,Long> trimData=new HashMap<>();//数据累加去重
SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
for(NtcAttrTypeReport report:list){
String trimStr="";
if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
trimStr=report.getAttrType().intValue()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,13);
}else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
trimStr=report.getAttrType().intValue()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,10);
}else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
trimStr=report.getAttrType().intValue()+Constants.REPORT_TRIM_CONNECTOR+
sdf.format(report.getReportTime()).substring(0,7);
}
if(trimData.containsKey(trimStr)){
trimData.put(trimStr, trimData.get(trimStr)+report.getSum().longValue());
}else{
trimData.put(trimStr, report.getSum().longValue());
}
} }
List<Long> _line= new ArrayList<Long>(); HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
_line.add(total); for(ServiceDictInfo xz:xzs){
_line.addAll(line); List<Long> line= new ArrayList<Long>();
showData.put(xz.getServiceDictId().toString(), _line); long total=0;
for(String title:titles){
if(trimData.containsKey(xz.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title)){
line.add(trimData.get(xz.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title));
total+=trimData.get(xz.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title).longValue();
}else{
line.add(0l);
}
}
List<Long> _line= new ArrayList<Long>();
_line.add(total);
_line.addAll(line);
showData.put(xz.getServiceDictId().toString(), _line);
}
model.addAttribute("datas", showData);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
} }
model.addAttribute("datas", showData); // HashMap<String,List<Long>> showData=new LinkedHashMap<>();//构造数据展示集合
// for(ServiceDictInfo xz:xzs){
// List<Long> line= new ArrayList<Long>();
// long total=0l;
// for(String title:titles){
// line.add(10000l);
// total+=10000l;
// }
// List<Long> _line= new ArrayList<Long>();
// _line.add(total);
// _line.addAll(line);
// showData.put(xz.getServiceDictId().toString(), _line);
// }
// model.addAttribute("datas", showData);
return "/report/attrType"; return "/report/attrType";
} }
} }