用户行为日志统计趋势信息改为:

searchBusinessType=2,根据用户名查看IP变化情况;
searchBusinessType=3,根据IP查看用户名变化情况;
This commit is contained in:
zhangdongxu
2018-11-08 10:21:21 +08:00
parent 9c8dd6853c
commit b22d86ec88
3 changed files with 30 additions and 75 deletions

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;
} }
} }