Merge branch 'Release-1.3' into develop

This commit is contained in:
doufenghu
2018-11-09 14:52:28 +08:00
4 changed files with 37 additions and 79 deletions

View File

@@ -1,10 +1,13 @@
package com.nis.domain.restful; package com.nis.domain.restful;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.nis.util.JsonDateSerializer;
import com.wordnik.swagger.annotations.ApiModelProperty; import com.wordnik.swagger.annotations.ApiModelProperty;
public class NtcRadiusReport implements Serializable{ public class NtcRadiusReport implements Serializable{
@@ -21,7 +24,7 @@ public class NtcRadiusReport implements Serializable{
protected Long num; protected Long num;
@JsonInclude(value = Include.NON_NULL) @JsonInclude(value = Include.NON_NULL)
@ApiModelProperty(value = "统计时间", required = true) @ApiModelProperty(value = "统计时间", required = true)
protected String reportTime; protected Date reportTime;
/** /**
* 业务类型1:用户名和接口IP列表 2:根据用户统计IP变化趋势 3IP根据统计用户变化趋势 * 业务类型1:用户名和接口IP列表 2:根据用户统计IP变化趋势 3IP根据统计用户变化趋势
@@ -59,12 +62,12 @@ public class NtcRadiusReport implements Serializable{
public void setNum(Long num) { public void setNum(Long num) {
this.num = num; this.num = num;
} }
@JsonSerialize(using = JsonDateSerializer.class)
public String getReportTime() { public Date getReportTime() {
return reportTime; return reportTime;
} }
public void setReportTime(String reportTime) { public void setReportTime(Date reportTime) {
this.reportTime = reportTime; this.reportTime = reportTime;
} }

View File

@@ -369,7 +369,6 @@ public class SingleDimensionReport extends BaseRestController {
ntcReportService.checkNtcRadiusReportCondition(saveLogThread, start, ntcRadiusReport); ntcReportService.checkNtcRadiusReportCondition(saveLogThread, start, ntcRadiusReport);
setGroupType(ntcRadiusReport);
dataList= ntcReportService.findNtcRadiusReport(ntcRadiusReport); dataList= ntcReportService.findNtcRadiusReport(ntcRadiusReport);
} catch (Exception e) { } catch (Exception e) {
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause()); saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
@@ -421,25 +420,4 @@ public class SingleDimensionReport extends BaseRestController {
entity.setSearchReportEndTime(map.get("endTime")); entity.setSearchReportEndTime(map.get("endTime"));
} }
} }
/**
* @Description:
* @author(zdx)
* @date 2018年10月31日 下午2:43:13
* @param ntcRadiusReport
* @throws Exception
*/
public void setGroupType(NtcRadiusReport ntcRadiusReport) throws Exception {
String groupType ="hour";
if (!(StringUtil.isEmpty(ntcRadiusReport.getSearchReportStartTime())&&StringUtil.isEmpty(ntcRadiusReport.getSearchReportEndTime()))) {
Long times = DateUtil.convertStringToTimestamp(ntcRadiusReport.getSearchReportEndTime(), DateUtil.YYYY_MM_DD_HH24_MM_SS)-DateUtil.convertStringToTimestamp(ntcRadiusReport.getSearchReportStartTime(), DateUtil.YYYY_MM_DD_HH24_MM_SS);
if (times>24*60*60L&&times<=30*24*60*60L) {
groupType ="day";
}else if(times>30*24*60*60L){
groupType ="month";
}
}
ntcRadiusReport.setGroupType(groupType);
}
} }

View File

@@ -645,20 +645,7 @@
<select id="findNtcRadiusReport" parameterType="com.nis.domain.restful.NtcRadiusReport" <select id="findNtcRadiusReport" parameterType="com.nis.domain.restful.NtcRadiusReport"
resultMap="NtcRadiusReportMap"> resultMap="NtcRadiusReportMap">
SELECT SELECT
nas_ip, *
account,
<choose>
<when test="groupType!= null and groupType!='' and groupType == 'day'">
DATE_FORMAT(REPORT_TIME, '%Y-%m-%d')
</when>
<when test="groupType!= null and groupType!='' and groupType == 'month'">
DATE_FORMAT(REPORT_TIME, '%Y-%m')
</when>
<otherwise>
DATE_FORMAT(REPORT_TIME, '%Y-%m-%d %H')
</otherwise>
</choose>
REPORT_TIME,sum(num) num
FROM ntc_radius_report FROM ntc_radius_report
<where> <where>
<if test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 2 and searchAccount != null and searchAccount !=''"> <if test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 2 and searchAccount != null and searchAccount !=''">
@@ -676,41 +663,7 @@
</otherwise> </otherwise>
</choose> </choose>
</where> </where>
GROUP BY
<if test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 2">
<![CDATA[account,nas_ip]]>
</if>
<if test="searchBusinessType !=null and searchBusinessType != '' and searchBusinessType == 3 ">
<![CDATA[nas_ip,account]]>
</if>
,
<choose>
<when test="groupType!= null and groupType!='' and groupType == 'day'">
DATE_FORMAT(REPORT_TIME, '%Y-%m-%d')
</when>
<when test="groupType!= null and groupType!='' and groupType == 'month'">
DATE_FORMAT(REPORT_TIME, '%Y-%m')
</when>
<otherwise>
DATE_FORMAT(REPORT_TIME, '%Y-%m-%d %H')
</otherwise>
</choose>
ORDER BY ORDER BY
<choose> REPORT_TIME ASC
<when test="groupType!= null and groupType!='' and groupType == 'day'">
DATE_FORMAT(REPORT_TIME, '%Y-%m-%d')
</when>
<when test="groupType!= null and groupType!='' and groupType == 'month'">
DATE_FORMAT(REPORT_TIME, '%Y-%m')
</when>
<otherwise>
DATE_FORMAT(REPORT_TIME, '%Y-%m-%d %H')
</otherwise>
</choose>
ASC
</select> </select>
</mapper> </mapper>

View File

@@ -1,5 +1,7 @@
package com.nis.web.service.restful; package com.nis.web.service.restful;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -108,7 +110,6 @@ public class NtcReportService extends BaseLogService {
public List findNtcRadiusReport(NtcRadiusReport entity) throws Exception { public List findNtcRadiusReport(NtcRadiusReport entity) throws Exception {
List resultList = null; List resultList = null;
if ("1".equals(entity.getSearchBusinessType())) { if ("1".equals(entity.getSearchBusinessType())) {
resultList = new ArrayList<Map>(); resultList = new ArrayList<Map>();
Map<String, List<NtcRadiusReport>> restMap = new HashMap<String, List<NtcRadiusReport>>(); Map<String, List<NtcRadiusReport>> restMap = new HashMap<String, List<NtcRadiusReport>>();
@@ -118,10 +119,33 @@ public class NtcReportService extends BaseLogService {
restMap.put("nasIpList", nasIpList); restMap.put("nasIpList", nasIpList);
resultList.add(restMap); resultList.add(restMap);
}else{ }else{
resultList = dao.findNtcRadiusReport(entity); resultList = new ArrayList<NtcRadiusReport>();
List<NtcRadiusReport> list = dao.findNtcRadiusReport(entity);
String regionName = "nasIp";
if ("3".equals(entity.getSearchBusinessType())) {
regionName="account";
}
PropertyDescriptor pd= new PropertyDescriptor(regionName, NtcRadiusReport.class);
Method method = pd.getReadMethod();
NtcRadiusReport temp = null;
Object tempVal =null;
for (int i = 0; i < list.size(); i++) {
if (i>0) {
NtcRadiusReport obj = list.get(i);
Object objVal = method.invoke(obj);
if (objVal!=null && tempVal!=null && !objVal.toString().equals(tempVal.toString())) {
temp = obj;
tempVal = method.invoke(temp);
resultList.add(obj);
}
}else{
temp = list.get(i);
tempVal = method.invoke(temp);
resultList.add(list.get(i));
}
}
} }
return resultList; return resultList;
} }
} }