提交实时报表服务公共类以及公共调用方法
This commit is contained in:
87
src/main/java/com/nis/domain/log/BaseReportLog.java
Normal file
87
src/main/java/com/nis/domain/log/BaseReportLog.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
*@Title: BaseReportLog.java
|
||||
*@Package com.nis.domain.log
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2018年7月5日 上午11:12:48
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.domain.log;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.ws.rs.client.Invocation.Builder;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.nis.domain.BaseEntity;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.util.httpclient.ClientUtil;
|
||||
|
||||
/**
|
||||
* @ClassName: BaseReportLog.java
|
||||
* @Description: 报表接口返回的公共字段
|
||||
* @author (wx)
|
||||
* @date 2018年7月5日 上午11:12:48
|
||||
* @version V1.0
|
||||
*/
|
||||
public class BaseReportLog<T> extends BaseEntity<T> {
|
||||
/**
|
||||
* @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么)
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = -6190203013788730697L;
|
||||
protected Long sum;
|
||||
protected Integer service;
|
||||
protected Date reportTime;
|
||||
/**
|
||||
* sum
|
||||
* @return sum
|
||||
*/
|
||||
|
||||
public Long getSum() {
|
||||
return sum;
|
||||
}
|
||||
/**
|
||||
* @param sum the sum to set
|
||||
*/
|
||||
public void setSum(Long sum) {
|
||||
this.sum = sum;
|
||||
}
|
||||
/**
|
||||
* service
|
||||
* @return service
|
||||
*/
|
||||
|
||||
public Integer getService() {
|
||||
return service;
|
||||
}
|
||||
/**
|
||||
* @param service the service to set
|
||||
*/
|
||||
public void setService(Integer service) {
|
||||
this.service = service;
|
||||
}
|
||||
/**
|
||||
* reportTime
|
||||
* @return reportTime
|
||||
*/
|
||||
|
||||
public Date getReportTime() {
|
||||
return reportTime;
|
||||
}
|
||||
/**
|
||||
* @param reportTime the reportTime to set
|
||||
*/
|
||||
public void setReportTime(Date reportTime) {
|
||||
this.reportTime = reportTime;
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,6 @@ package com.nis.domain.log;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.nis.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* @ClassName: ReportLog.java
|
||||
* @Description: TODO
|
||||
@@ -19,7 +17,7 @@ import com.nis.domain.BaseEntity;
|
||||
* @date 2018年6月13日 下午2:21:04
|
||||
* @version V1.0
|
||||
*/
|
||||
public class ReportLog extends BaseEntity<ReportLog>{
|
||||
public class ReportLog extends BaseReportLog<ReportLog>{
|
||||
/**
|
||||
* @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么)
|
||||
*
|
||||
|
||||
@@ -8,12 +8,21 @@
|
||||
*/
|
||||
package com.nis.domain.log;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.nis.domain.BaseEntity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.client.Invocation.Builder;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.RestfulResult;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.util.httpclient.ClientUtil;
|
||||
|
||||
/**
|
||||
* @ClassName: ReportResultLog.java
|
||||
@@ -22,9 +31,9 @@ import com.nis.domain.RestfulResult;
|
||||
* @date 2018年6月11日 下午2:04:09
|
||||
* @version V1.0
|
||||
*/
|
||||
public class ReportResultLog extends RestfulResult{
|
||||
public class ReportResultLog<T extends BaseReportLog> extends RestfulResult{
|
||||
private Integer logSource;
|
||||
private Page<ReportLog> data;
|
||||
private Page<T> data;
|
||||
/**
|
||||
* logSource
|
||||
* @return logSource
|
||||
@@ -44,14 +53,47 @@ public class ReportResultLog extends RestfulResult{
|
||||
* @return data
|
||||
*/
|
||||
|
||||
public Page<ReportLog> getData() {
|
||||
public Page<T> getData() {
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* @param data the data to set
|
||||
*/
|
||||
public void setData(Page<ReportLog> data) {
|
||||
public void setData(Page<T> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ReportResultLog<T> getReport(String reportUrl,SearchReport searchCondition) throws MaatConvertException{
|
||||
if(StringUtils.isBlank(searchCondition.getSearchService())){
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
String result = null;
|
||||
ReportResultLog<T> bean = null;
|
||||
StringBuffer url=new StringBuffer(reportUrl+"?");
|
||||
url.append("searchBusinessType=").append(searchCondition.getSearchBusinessType())
|
||||
.append("&searchService=").append(searchCondition.getSearchService());
|
||||
if(searchCondition.getSearchCondition()!=null){
|
||||
for(Entry<String, Object> e:searchCondition.getSearchCondition().entrySet()){
|
||||
url.append("&").append(e.getKey()).append("=").append((String)e.getValue());
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(searchCondition.getSearchReportStartTime())){
|
||||
url.append("&searchReportStartTime=").append(searchCondition.getSearchReportStartTime());
|
||||
}
|
||||
if(StringUtils.isNotBlank(searchCondition.getSearchReportEndTime())){
|
||||
url.append("&searchReportEndTime=").append(searchCondition.getSearchReportEndTime());
|
||||
}
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url.toString());
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON);
|
||||
Response response= header.get();
|
||||
if( response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
Gson gson=Constants.gsonbuilder.create();
|
||||
bean = gson.fromJson(result, new TypeToken<ReportResultLog<T>>(){
|
||||
private static final long serialVersionUID = 7963055764864141968L;}.getType());
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
121
src/main/java/com/nis/domain/log/SearchReport.java
Normal file
121
src/main/java/com/nis/domain/log/SearchReport.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
*@Title: SearchReport.java
|
||||
*@Package com.nis.domain.log
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2018年7月5日 下午12:30:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.domain.log;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @ClassName: SearchReport.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2018年7月5日 下午12:30:44
|
||||
* @version V1.0
|
||||
*/
|
||||
public class SearchReport {
|
||||
private String searchBusinessType;
|
||||
private String searchReportStartTime;
|
||||
private String searchReportEndTime;
|
||||
private String searchService;
|
||||
private HashMap<String,Object> searchCondition;
|
||||
public static final String searchConditionSplitor=",";
|
||||
public int searchConditionLimit;
|
||||
/**
|
||||
* searchBusinessType
|
||||
* @return searchBusinessType
|
||||
*/
|
||||
|
||||
public String getSearchBusinessType() {
|
||||
return searchBusinessType;
|
||||
}
|
||||
/**
|
||||
* @param searchBusinessType the searchBusinessType to set
|
||||
*/
|
||||
public void setSearchBusinessType(String searchBusinessType) {
|
||||
this.searchBusinessType = searchBusinessType;
|
||||
}
|
||||
/**
|
||||
* searchReportStartTime
|
||||
* @return searchReportStartTime
|
||||
*/
|
||||
|
||||
public String getSearchReportStartTime() {
|
||||
return searchReportStartTime;
|
||||
}
|
||||
/**
|
||||
* @param searchReportStartTime the searchReportStartTime to set
|
||||
*/
|
||||
public void setSearchReportStartTime(String searchReportStartTime) {
|
||||
this.searchReportStartTime = searchReportStartTime;
|
||||
}
|
||||
/**
|
||||
* searchReportEndTime
|
||||
* @return searchReportEndTime
|
||||
*/
|
||||
|
||||
public String getSearchReportEndTime() {
|
||||
return searchReportEndTime;
|
||||
}
|
||||
/**
|
||||
* @param searchReportEndTime the searchReportEndTime to set
|
||||
*/
|
||||
public void setSearchReportEndTime(String searchReportEndTime) {
|
||||
this.searchReportEndTime = searchReportEndTime;
|
||||
}
|
||||
/**
|
||||
* searchService
|
||||
* @return searchService
|
||||
*/
|
||||
|
||||
public String getSearchService() {
|
||||
return searchService;
|
||||
}
|
||||
/**
|
||||
* @param searchService the searchService to set
|
||||
*/
|
||||
public void setSearchService(String searchService) {
|
||||
this.searchService = searchService;
|
||||
}
|
||||
/**
|
||||
* searchCondition
|
||||
* @return searchCondition
|
||||
*/
|
||||
|
||||
public HashMap<String, Object> getSearchCondition() {
|
||||
return searchCondition;
|
||||
}
|
||||
/**
|
||||
* @param searchCondition the searchCondition to set
|
||||
*/
|
||||
public void setSearchCondition(HashMap<String, Object> searchCondition) {
|
||||
this.searchCondition = searchCondition;
|
||||
}
|
||||
/**
|
||||
* searchConditionLimit
|
||||
* @return searchConditionLimit
|
||||
*/
|
||||
|
||||
public int getSearchConditionLimit() {
|
||||
return searchConditionLimit;
|
||||
}
|
||||
/**
|
||||
* @param searchConditionLimit the searchConditionLimit to set
|
||||
*/
|
||||
public void setSearchConditionLimit(int searchConditionLimit) {
|
||||
this.searchConditionLimit = searchConditionLimit;
|
||||
}
|
||||
/**
|
||||
* searchconditionsplitor
|
||||
* @return searchconditionsplitor
|
||||
*/
|
||||
|
||||
public static String getSearchconditionsplitor() {
|
||||
return searchConditionSplitor;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +1,31 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.client.Invocation.Builder;
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.Invocation.Builder;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
import net.sf.json.JsonConfig;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
||||
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.nis.domain.log.ReportLog;
|
||||
import com.nis.domain.log.ReportResultLog;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.domain.maat.ToMaatResult.ResponseData;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.httpclient.ClientUtil;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
import net.sf.json.JsonConfig;
|
||||
|
||||
public class ConfigServiceUtil {
|
||||
private static Logger logger = LoggerFactory.getLogger(ConfigServiceUtil.class);
|
||||
/*public static class MapTypeAdapter extends TypeAdapter<Object> {
|
||||
@@ -310,12 +309,12 @@ public class ConfigServiceUtil {
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static ReportResultLog getReport(int type,String ids,String serviceIds,String searchReportStartTime,String searchReportEndTime) throws MaatConvertException{
|
||||
public static ReportResultLog<ReportLog> getReport(int type,String ids,String serviceIds,String searchReportStartTime,String searchReportEndTime) throws MaatConvertException{
|
||||
if(StringUtils.isBlank(ids)||StringUtils.isBlank(serviceIds)){
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
String result = null;
|
||||
ReportResultLog bean = null;
|
||||
ReportResultLog<ReportLog> bean = null;
|
||||
StringBuffer url=new StringBuffer(Constants.SERVICE_URL+Constants.NTC_PZ_REPORT+"?");
|
||||
url.append("searchBusinessType=").append(type)
|
||||
.append("&searchService=").append(serviceIds).append("&searchCfgId=").append(ids);
|
||||
@@ -331,8 +330,9 @@ public class ConfigServiceUtil {
|
||||
Response response= header.get();
|
||||
if( response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ReportResultLog) JSONObject.toBean(resObject,ReportResultLog.class);
|
||||
Gson gson=Constants.gsonbuilder.create();
|
||||
bean = gson.fromJson(result, new TypeToken<ReportResultLog<ReportLog>>(){
|
||||
private static final long serialVersionUID = 7963055764864141968L;}.getType());
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user