提交标签报表页面第一版

This commit is contained in:
wangxin
2018-07-09 17:36:13 +08:00
parent 5ed876e38d
commit 3b60b81c72
10 changed files with 357 additions and 47 deletions

View File

@@ -0,0 +1,28 @@
/**
*@Title: NtcServiceReportLog.java
*@Package com.nis.domain.log
*@Description TODO
*@author dell
*@date 2018年7月9日 上午8:57:01
*@version 版本号
*/
package com.nis.domain.log;
/**
* @ClassName: NtcServiceReportLog.java
* @Description: TODO
* @author (dell)
* @date 2018年7月9日 上午8:57:01
* @version V1.0
*/
public class NtcServiceReportLog extends BaseReportLog<NtcServiceReportLog> {
/**
* @Fields serialVersionUID:TODO用一句话描述这个变量表示什么
*
* @since 1.0.0
*/
private static final long serialVersionUID = 5574384523786886920L;
}

View File

@@ -0,0 +1,43 @@
/**
*@Title: NtcServiceReportLog.java
*@Package com.nis.domain.log
*@Description TODO
*@author dell
*@date 2018年7月9日 上午8:57:01
*@version 版本号
*/
package com.nis.domain.log;
/**
* @ClassName: NtcServiceReportLog.java
* @Description: TODO
* @author (dell)
* @date 2018年7月9日 上午8:57:01
* @version V1.0
*/
public class NtcTagReportLog extends BaseReportLog<NtcTagReportLog> {
/**
* @Fields serialVersionUID:TODO用一句话描述这个变量表示什么
*
* @since 1.0.0
*/
private static final long serialVersionUID = 2245672277797057001L;
private Integer tag;
/**
* tag
* @return tag
*/
public Integer getTag() {
return tag;
}
/**
* @param tag the tag to set
*/
public void setTag(Integer tag) {
this.tag = tag;
}
}

View File

@@ -8,6 +8,8 @@
*/ */
package com.nis.domain.log; package com.nis.domain.log;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.ws.rs.client.Invocation.Builder; import javax.ws.rs.client.Invocation.Builder;
@@ -62,13 +64,13 @@ public class ReportResultLog<T extends BaseReportLog> extends RestfulResult{
public void setData(Page<T> data) { public void setData(Page<T> data) {
this.data = data; this.data = data;
} }
public ReportResultLog<T> getReport(String reportUrl,SearchReport searchCondition) throws MaatConvertException{ public ReportResultLog<T> 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\"/>");
} // }
String result = null; String result = null;
ReportResultLog<T> bean = null; ReportResultLog<T> bean = null;
StringBuffer url=new StringBuffer(reportUrl+"?"); StringBuffer url=new StringBuffer(reportUrl);
url.append("searchBusinessType=").append(searchCondition.getSearchBusinessType()) url.append("searchBusinessType=").append(searchCondition.getSearchBusinessType())
.append("&searchService=").append(searchCondition.getSearchService()); .append("&searchService=").append(searchCondition.getSearchService());
if(searchCondition.getSearchCondition()!=null){ if(searchCondition.getSearchCondition()!=null){
@@ -95,7 +97,7 @@ public class ReportResultLog<T extends BaseReportLog> extends RestfulResult{
url.append("&fields=").append(searchCondition.getFields()); url.append("&fields=").append(searchCondition.getFields());
} }
//创建连接 //创建连接
WebTarget wt = ClientUtil.getWebTarger(url.toString()); WebTarget wt = ClientUtil.getWebTarger(URLEncoder.encode(url.toString(),"UTF-8"));
Builder header = wt.request(MediaType.APPLICATION_JSON); Builder header = wt.request(MediaType.APPLICATION_JSON);
Response response= header.get(); Response response= header.get();
if( response.getStatus() == 200){ if( response.getStatus() == 200){

View File

@@ -7,6 +7,16 @@ import java.util.Map;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
public final class Constants { public final class Constants {
/**
* 报表去重连接符
*/
public static final String REPORT_TRIM_CONNECTOR="_;_";
/**
* 报表类型
*/
public static final int REPORT_TYPE_HOUR=1;
public static final int REPORT_TYPE_DAY=2;
public static final int REPORT_TYPE_MONTH=3;
/** /**
* 配置审核下发的类型 maat类型 * 配置审核下发的类型 maat类型
*/ */

View File

@@ -0,0 +1,42 @@
package com.nis.web.controller.report;
import java.io.UnsupportedEncodingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import com.nis.domain.Page;
import com.nis.domain.log.NtcServiceReportLog;
import com.nis.domain.log.ReportResultLog;
import com.nis.domain.log.SearchReport;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants;
import com.nis.web.controller.BaseController;
@Controller
@RequestMapping("${adminPath}/report")
public class NtcServiceReportController extends BaseController {
@RequestMapping("/ntcLabelReport")
public String list(@ModelAttribute("bean") SearchReport bean,Model model, HttpServletRequest request, HttpServletResponse response) {
initReportCondition(model, bean);
ReportResultLog<NtcServiceReportLog> result=new ReportResultLog<>();
StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_SERVICE_REPORT+"?");
try {
result=result.getReport(url.toString(), bean);
} catch (MaatConvertException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Page<NtcServiceReportLog> page=result.getData();
model.addAttribute("page", page);
return "/report/list";
}
}

View File

@@ -0,0 +1,159 @@
package com.nis.web.controller.report;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.log.NtcTagReportLog;
import com.nis.domain.log.ReportResultLog;
import com.nis.domain.log.SearchReport;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.web.controller.BaseController;
@Controller
@RequestMapping("${adminPath}/report")
public class NtcTagReportController extends BaseController {
@RequestMapping("/ajaxNtcTagReport")
public String list(@ModelAttribute("bean") SearchReport bean,Model model, HttpServletRequest request, HttpServletResponse response) {
initReportCondition(model, bean);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(bean.getFunctionId());
List<ServiceDictInfo> labels=serviceDictInfoService.findAllLableDict();
model.addAttribute("labels", labels);
if(bean.getAction()!=null){
for(FunctionServiceDict service:serviceList){
if(service.getAction().intValue()==bean.getAction().intValue()){
bean.setSearchService(service.getServiceId().toString());
}
}
}else{
StringBuffer serviceId=new StringBuffer();
for(int i=0;i<serviceList.size();i++){
if(i==0){
serviceId.append(serviceList.get(i).getServiceId().toString());
}else{
serviceId.append(","+serviceList.get(i).getServiceId().toString());
}
}
bean.setSearchService(serviceId.toString());
}
bean.setSearchBusinessType("1");
ReportResultLog<NtcTagReportLog> result=new ReportResultLog<>();
StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_SERVICE_REPORT+"?");
bean.setPageSize(-1);
bean.setFields("tag,sum,reportTime");
String format=Constants.SEARCH_DATEFORMAT;
SimpleDateFormat sdf=new SimpleDateFormat(format);
Date date=new Date();
bean.setSearchReportEndTime(sdf.format(date));
Calendar cal=Calendar.getInstance();
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
cal.set(Calendar.HOUR_OF_DAY, 0);
}else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.DAY_OF_MONTH, 1);
}else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.MONTH, 0);
}
logger.info("search start time "+sdf.format(cal.getTime()));
logger.info("search end time "+sdf.format(date));
bean.setSearchReportStartTime(sdf.format(cal.getTime()));
List<String> titles=new ArrayList<String>();
while(cal.getTime().getTime()<date.getTime()){//构造标题
//报表时间单位加一
if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
titles.add(sdf.format(cal.getTime()).substring(0,13));
cal.add(Calendar.HOUR_OF_DAY, 1);
}else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
titles.add(sdf.format(cal.getTime()).substring(0,10));
cal.add(Calendar.DAY_OF_MONTH, 1);
}else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
titles.add(sdf.format(cal.getTime()).substring(0,7));
cal.add(Calendar.MONTH, 1);
}
}
model.addAttribute("titles", titles);
// try {
// result=result.getReport(url.toString(), bean);
// Page<NtcTagReportLog> page=result.getData();
// List<NtcTagReportLog> list=page.getList();
// HashMap<String,Long> trimData=new HashMap<>();//数据累加去重
// for(NtcTagReportLog report:list){
// String trimStr="";
// if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
// trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+
// sdf.format(cal.getTime()).substring(0,13);
//
// }else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
// trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+
// sdf.format(cal.getTime()).substring(0,10);
//
// }else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
// trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+
// sdf.format(cal.getTime()).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 HashMap<>();//构造数据展示集合
// for(ServiceDictInfo label:lables){
// List<Long> line= new ArrayList<Long>();
// 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();
// }
HashMap<String,List<Long>> showData=new HashMap<>();//构造数据展示集合
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";
}
}

View File

@@ -310,7 +310,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
maatCfg.initDefaultValue(); maatCfg.initDefaultValue();
BeanUtils.copyProperties(cfg, maatCfg); BeanUtils.copyProperties(cfg, maatCfg);
if(cfg.getIsAudit()==1){ if(cfg.getIsAudit()==Constants.AUDIT_YES){
maatBean.setOpAction(Constants.INSERT_ACTION); maatBean.setOpAction(Constants.INSERT_ACTION);
Map<String,List> map = cfgConvert(ipRegionList,beans,1,cfg,groupRelationList); Map<String,List> map = cfgConvert(ipRegionList,beans,1,cfg,groupRelationList);
groupRelationList=map.get("groupList"); groupRelationList=map.get("groupList");
@@ -343,10 +343,10 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
logger.error("IP白名单配置下发失败",e); logger.error("IP白名单配置下发失败",e);
throw e; throw e;
} }
}else if(cfg.getIsAudit()==3){ }else if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){
maatCfg.setCompileId(cfg.getCompileId()); maatCfg.setCompileId(cfg.getCompileId());
maatCfg.setServiceId(cfg.getServiceId()); maatCfg.setServiceId(cfg.getServiceId());
maatCfg.setIsValid(0);//无效 maatCfg.setIsValid(Constants.VALID_NO);//无效
configCompileList.add(maatCfg); configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList); maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(cfg.getAuditTime()); maatBean.setAuditTime(cfg.getAuditTime());

View File

@@ -27,6 +27,7 @@
<mapping path="/nis/ntc/other/ajax*" exclue="true"/> <mapping path="/nis/ntc/other/ajax*" exclue="true"/>
<mapping path="/nis/proxy/control/httpRedirect/ajax*" exclue="true"/> <mapping path="/nis/proxy/control/httpRedirect/ajax*" exclue="true"/>
<mapping path="/nis/app/ajax*" exclue="true"/> <mapping path="/nis/app/ajax*" exclue="true"/>
<mapping path="/nis/report/ajax*" exclue="true"/>
<!-- 对同一路径,启用多个装饰器 --> <!-- 对同一路径,启用多个装饰器 -->
<mapping> <mapping>
<path>/articles/*</path> <path>/articles/*</path>

View File

@@ -4,39 +4,29 @@
$(function(){ $(function(){
}); });
</script> </script>
<div id="label" class="tab-pane fade in active"> <table id="tagTable" class="table table-striped table-bordered table-condensed text-nowrap">
<table id="contentTable1" class="table table-striped table-bordered table-condensed text-nowrap"> <thead>
<thead> <tr>
<tr> <th><spring:message code="label"/></th>
<th>标签</th> <th><spring:message code="log_total"/></th>
<th>总量</th> <c:forEach items="${titles}" var="title">
<th>0点</th> <th>${title}</th>
<th>1点</th> </c:forEach>
<th>2点</th> </tr>
<th>3点</th> </thead>
<th>4点</th> <tbody>
<th>5点</th> <c:forEach items="${datas}" var="data">
<th>6点</th> <tr>
<th>7点</th> <td>
<th>8点</th> <c:forEach items="${labels}" var="label">
<th>9点</th> <c:if test="${label.serviceDictId==data.key}">${label.itemValue}</c:if>
<th>10点</th> </c:forEach>
<th>11点</th> </td>
<th>12点</th> <c:forEach items="${data.value}" var="cloumn" varStatus="status">
<th>14点</th> <td>${cloumn}</td>
<th>15点</th> </c:forEach>
<th>16点</th> </tr>
<th>17点</th> </c:forEach>
<th>18点</th> </tbody>
<th>19点</th> </table>
<th>20点</th> <div class="page">${page}</div>
<th>21点</th>
<th>22点</th>
<th>23点</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="page">${page}</div>
</div>

View File

@@ -17,6 +17,21 @@
$(".Wdate").attr("value",''); $(".Wdate").attr("value",'');
$("#searchForm")[0].reset(); $("#searchForm")[0].reset();
}); });
if(!"${bean.reportBusinessType}"){
$.ajax({
type:'post',
async:false,
url:'${ctx}/report/ajaxNtcTagReport',
data:{
"action":$('select[name="action"]').val(),
"reportType":$('input[name="reportType"]:checked').val()
},
dataType:"html",
success:function(data){
$("#label").html(data);
}
});
}
$("input[name='reportType']").each(function(){ $("input[name='reportType']").each(function(){
var type='${bean.reportType}'; var type='${bean.reportType}';
if(type && type==$(this).val()){ if(type && type==$(this).val()){
@@ -25,8 +40,29 @@
}) })
$("a[data-toggle='tab']").on("click",function(){ $("a[data-toggle='tab']").on("click",function(){
$("#reportBusinessType").val($(this).data("bussiness")); $("#reportBusinessType").val($(this).data("bussiness"));
if(!$(this).parent("li").hasClass("active")){
var action=$('select[name="action"]').val();
var reportBusinessType=$("#reportBusinessType").val();
var reportType=$('input[name="reportType"]:checked').val();
if($(this).data("bussiness")=="label_report"){
$.ajax({
type:'post',
async:false,
url:'${ctx}/report/ajaxNtcTagReport',
data:{
"action":action,
"reportType":reportType
},
dataType:"html",
success:function(data){
$("#label").html(data);
}
});
}
}
}); });
}); });
</script> </script>
</head> </head>
<body> <body>
@@ -117,7 +153,6 @@
<sys:message content="${message}"/> <sys:message content="${message}"/>
<br> <br>
<ul class="nav nav-tabs nav-justified"> <ul class="nav nav-tabs nav-justified">
<!-- <li><a data-toggle="tab" href="#serviceType">业务类型</a></li> -->
<li <li
<c:if test="${bean.reportBusinessType eq 'label_report' or bean.reportBusinessType ==null}"> <c:if test="${bean.reportBusinessType eq 'label_report' or bean.reportBusinessType ==null}">
class="active" class="active"
@@ -150,7 +185,7 @@
><a data-bussiness="isp_report" data-toggle="tab" href="#entranceId"><spring:message code="isp_report"/></a></li> ><a data-bussiness="isp_report" data-toggle="tab" href="#entranceId"><spring:message code="isp_report"/></a></li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<%@include file="/WEB-INF/views/report/label.jsp" %> <div id="label" class="tab-pane fade in active"></div>
<%@include file="/WEB-INF/views/report/attrType.jsp" %> <%@include file="/WEB-INF/views/report/attrType.jsp" %>
<%@include file="/WEB-INF/views/report/lwhh.jsp" %> <%@include file="/WEB-INF/views/report/lwhh.jsp" %>
<%@include file="/WEB-INF/views/report/srcIp.jsp" %> <%@include file="/WEB-INF/views/report/srcIp.jsp" %>