新增用户流量报表、license流量报表实现
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
package fun.asgc.neutrino.proxy.server.dal;
|
||||
|
||||
import fun.asgc.neutrino.proxy.server.controller.req.LicenseFlowReportReq;
|
||||
import fun.asgc.neutrino.proxy.server.controller.req.UserFlowReportReq;
|
||||
import fun.asgc.neutrino.proxy.server.controller.res.LicenseFlowReportRes;
|
||||
import fun.asgc.neutrino.proxy.server.controller.res.UserFlowReportRes;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/3/19
|
||||
*/
|
||||
@Mapper
|
||||
public interface ReportMapper {
|
||||
|
||||
/**
|
||||
* 基于用户维度的流量报表
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
List<UserFlowReportRes> userFlowReportList(@Param("req") UserFlowReportReq req);
|
||||
|
||||
/**
|
||||
* 基于license维度的流量报表
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
List<LicenseFlowReportRes> licenseFLowReportList(@Param("req")LicenseFlowReportReq req);
|
||||
}
|
||||
+16
-73
@@ -1,16 +1,23 @@
|
||||
package fun.asgc.neutrino.proxy.server.service;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.google.common.collect.Lists;
|
||||
import fun.asgc.neutrino.proxy.server.base.page.PageInfo;
|
||||
import fun.asgc.neutrino.proxy.server.base.page.PageQuery;
|
||||
import fun.asgc.neutrino.proxy.server.controller.req.LicenseFlowReportReq;
|
||||
import fun.asgc.neutrino.proxy.server.controller.req.UserFlowReportReq;
|
||||
import fun.asgc.neutrino.proxy.server.controller.res.JobLogListRes;
|
||||
import fun.asgc.neutrino.proxy.server.controller.res.LicenseFlowReportRes;
|
||||
import fun.asgc.neutrino.proxy.server.controller.res.UserFlowReportRes;
|
||||
import fun.asgc.neutrino.proxy.server.dal.ReportMapper;
|
||||
import fun.asgc.neutrino.proxy.server.util.FormatUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import ma.glasnost.orika.MapperFacade;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,6 +28,10 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ReportService {
|
||||
@Inject
|
||||
private MapperFacade mapperFacade;
|
||||
@Db
|
||||
private ReportMapper reportMapper;
|
||||
|
||||
/**
|
||||
* 用户流量报表分页
|
||||
@@ -29,44 +40,10 @@ public class ReportService {
|
||||
* @return
|
||||
*/
|
||||
public PageInfo<UserFlowReportRes> userFlowReportPage(PageQuery pageQuery, UserFlowReportReq req) {
|
||||
// TODO
|
||||
List<UserFlowReportRes> all = Lists.newArrayList(
|
||||
new UserFlowReportRes().setUserId(1).setUserName("用户1").setUpFlowBytes(100L).setDownFlowBytes(200L),
|
||||
new UserFlowReportRes().setUserId(2).setUserName("用户2").setUpFlowBytes(400L).setDownFlowBytes(600L),
|
||||
new UserFlowReportRes().setUserId(3).setUserName("用户3").setUpFlowBytes(800L).setDownFlowBytes(1200L),
|
||||
new UserFlowReportRes().setUserId(4).setUserName("用户4").setUpFlowBytes(120L).setDownFlowBytes(1600L),
|
||||
new UserFlowReportRes().setUserId(5).setUserName("用户5").setUpFlowBytes(1600L).setDownFlowBytes(2000L),
|
||||
new UserFlowReportRes().setUserId(6).setUserName("用户6").setUpFlowBytes(2200L).setDownFlowBytes(2500L),
|
||||
new UserFlowReportRes().setUserId(7).setUserName("用户7").setUpFlowBytes(2800L).setDownFlowBytes(3200L),
|
||||
new UserFlowReportRes().setUserId(8).setUserName("用户8").setUpFlowBytes(41000L).setDownFlowBytes(52000L),
|
||||
new UserFlowReportRes().setUserId(9).setUserName("用户9").setUpFlowBytes(310000L).setDownFlowBytes(420000L),
|
||||
new UserFlowReportRes().setUserId(10).setUserName("用户10").setUpFlowBytes(51000L).setDownFlowBytes(620000L),
|
||||
new UserFlowReportRes().setUserId(11).setUserName("用户11").setUpFlowBytes(310000L).setDownFlowBytes(20000L),
|
||||
new UserFlowReportRes().setUserId(12).setUserName("用户12").setUpFlowBytes(23100L).setDownFlowBytes(245200L),
|
||||
new UserFlowReportRes().setUserId(13).setUserName("用户13").setUpFlowBytes(98100L).setDownFlowBytes(65200L),
|
||||
new UserFlowReportRes().setUserId(14).setUserName("用户14").setUpFlowBytes(234100L).setDownFlowBytes(7809200L),
|
||||
new UserFlowReportRes().setUserId(15).setUserName("用户15").setUpFlowBytes(23100L).setDownFlowBytes(4200L),
|
||||
new UserFlowReportRes().setUserId(16).setUserName("用户16").setUpFlowBytes(21003100L).setDownFlowBytes(4099200L),
|
||||
new UserFlowReportRes().setUserId(17).setUserName("用户17").setUpFlowBytes(23100L).setDownFlowBytes(4200L),
|
||||
new UserFlowReportRes().setUserId(18).setUserName("用户18").setUpFlowBytes(10023100L).setDownFlowBytes(20004200L),
|
||||
new UserFlowReportRes().setUserId(19).setUserName("用户19").setUpFlowBytes(300023100L).setDownFlowBytes(40004200L),
|
||||
new UserFlowReportRes().setUserId(20).setUserName("用户20").setUpFlowBytes(5000023100L).setDownFlowBytes(600004200L),
|
||||
new UserFlowReportRes().setUserId(21).setUserName("用户21").setUpFlowBytes(700023100L).setDownFlowBytes(80094200L),
|
||||
new UserFlowReportRes().setUserId(22).setUserName("用户22").setUpFlowBytes(40000023100L).setDownFlowBytes(6000004200L),
|
||||
new UserFlowReportRes().setUserId(23).setUserName("用户23").setUpFlowBytes(300000023100L).setDownFlowBytes(40000004200L),
|
||||
new UserFlowReportRes().setUserId(24).setUserName("用户24").setUpFlowBytes(300998723100L).setDownFlowBytes(2099877664200L),
|
||||
new UserFlowReportRes().setUserId(25).setUserName("用户25").setUpFlowBytes(50987668623100L).setDownFlowBytes(30987657864200L)
|
||||
);
|
||||
List<UserFlowReportRes> list = null;
|
||||
if (pageQuery.getCurrent() == 1) {
|
||||
list = all.subList(0, 10);
|
||||
} else if (pageQuery.getCurrent() == 2){
|
||||
list = all.subList(10, 20);
|
||||
} else {
|
||||
list = all.subList(20, all.size());
|
||||
}
|
||||
Page<UserFlowReportRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<UserFlowReportRes> list = reportMapper.userFlowReportList(req);
|
||||
fillUserFlowReport(list);
|
||||
return PageInfo.of(list, 25L, pageQuery.getCurrent(), pageQuery.getSize());
|
||||
return PageInfo.of(list, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,42 +53,8 @@ public class ReportService {
|
||||
* @return
|
||||
*/
|
||||
public PageInfo<LicenseFlowReportRes> licenseFlowReportPage(PageQuery pageQuery, LicenseFlowReportReq req) {
|
||||
// TODO
|
||||
List<LicenseFlowReportRes> all = Lists.newArrayList(
|
||||
new LicenseFlowReportRes().setUserId(1).setUserName("用户1").setLicenseName("license1").setUpFlowBytes(100L).setDownFlowBytes(200L),
|
||||
new LicenseFlowReportRes().setUserId(2).setUserName("用户2").setLicenseName("license1").setUpFlowBytes(400L).setDownFlowBytes(600L),
|
||||
new LicenseFlowReportRes().setUserId(3).setUserName("用户3").setLicenseName("license1").setUpFlowBytes(800L).setDownFlowBytes(1200L),
|
||||
new LicenseFlowReportRes().setUserId(4).setUserName("用户4").setLicenseName("license1").setUpFlowBytes(120L).setDownFlowBytes(1600L),
|
||||
new LicenseFlowReportRes().setUserId(5).setUserName("用户5").setLicenseName("license1").setUpFlowBytes(1600L).setDownFlowBytes(2000L),
|
||||
new LicenseFlowReportRes().setUserId(6).setUserName("用户6").setLicenseName("license1").setUpFlowBytes(2200L).setDownFlowBytes(2500L),
|
||||
new LicenseFlowReportRes().setUserId(7).setUserName("用户7").setLicenseName("license1").setUpFlowBytes(2800L).setDownFlowBytes(3200L),
|
||||
new LicenseFlowReportRes().setUserId(8).setUserName("用户8").setLicenseName("license1").setUpFlowBytes(41000L).setDownFlowBytes(52000L),
|
||||
new LicenseFlowReportRes().setUserId(9).setUserName("用户9").setLicenseName("license1").setUpFlowBytes(310000L).setDownFlowBytes(420000L),
|
||||
new LicenseFlowReportRes().setUserId(10).setUserName("用户10").setLicenseName("license1").setUpFlowBytes(51000L).setDownFlowBytes(620000L),
|
||||
new LicenseFlowReportRes().setUserId(11).setUserName("用户11").setLicenseName("license1").setUpFlowBytes(310000L).setDownFlowBytes(20000L),
|
||||
new LicenseFlowReportRes().setUserId(12).setUserName("用户12").setLicenseName("license1").setUpFlowBytes(23100L).setDownFlowBytes(245200L),
|
||||
new LicenseFlowReportRes().setUserId(13).setUserName("用户13").setLicenseName("license1").setUpFlowBytes(98100L).setDownFlowBytes(65200L),
|
||||
new LicenseFlowReportRes().setUserId(14).setUserName("用户14").setLicenseName("license1").setUpFlowBytes(234100L).setDownFlowBytes(7809200L),
|
||||
new LicenseFlowReportRes().setUserId(15).setUserName("用户15").setLicenseName("license1").setUpFlowBytes(23100L).setDownFlowBytes(4200L),
|
||||
new LicenseFlowReportRes().setUserId(16).setUserName("用户16").setLicenseName("license1").setUpFlowBytes(21003100L).setDownFlowBytes(4099200L),
|
||||
new LicenseFlowReportRes().setUserId(17).setUserName("用户17").setLicenseName("license1").setUpFlowBytes(23100L).setDownFlowBytes(4200L),
|
||||
new LicenseFlowReportRes().setUserId(18).setUserName("用户18").setLicenseName("license1").setUpFlowBytes(10023100L).setDownFlowBytes(20004200L),
|
||||
new LicenseFlowReportRes().setUserId(19).setUserName("用户19").setLicenseName("license1").setUpFlowBytes(300023100L).setDownFlowBytes(40004200L),
|
||||
new LicenseFlowReportRes().setUserId(20).setUserName("用户20").setLicenseName("license1").setUpFlowBytes(5000023100L).setDownFlowBytes(600004200L),
|
||||
new LicenseFlowReportRes().setUserId(21).setUserName("用户21").setLicenseName("license1").setUpFlowBytes(700023100L).setDownFlowBytes(80094200L),
|
||||
new LicenseFlowReportRes().setUserId(22).setUserName("用户22").setLicenseName("license1").setUpFlowBytes(40000023100L).setDownFlowBytes(6000004200L),
|
||||
new LicenseFlowReportRes().setUserId(23).setUserName("用户23").setLicenseName("license1").setUpFlowBytes(300000023100L).setDownFlowBytes(40000004200L),
|
||||
new LicenseFlowReportRes().setUserId(24).setUserName("用户24").setLicenseName("license1").setUpFlowBytes(300998723100L).setDownFlowBytes(2099877664200L),
|
||||
new LicenseFlowReportRes().setUserId(25).setUserName("用户25").setLicenseName("license1").setUpFlowBytes(50987668623100L).setDownFlowBytes(30987657864200L)
|
||||
);
|
||||
List<LicenseFlowReportRes> list = null;
|
||||
if (pageQuery.getCurrent() == 1) {
|
||||
list = all.subList(0, 10);
|
||||
} else if (pageQuery.getCurrent() == 2){
|
||||
list = all.subList(10, 20);
|
||||
} else {
|
||||
list = all.subList(20, all.size());
|
||||
}
|
||||
Page<LicenseFlowReportRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<LicenseFlowReportRes> list = reportMapper.licenseFLowReportList(req);
|
||||
fillLicenseFlowReport(list);
|
||||
return PageInfo.of(list, 25L, pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class FormatUtil {
|
||||
res *= 1024;
|
||||
}
|
||||
|
||||
return trimZero(String.format("%.2f", res)) + " " + SIZE_UNINTS[index];
|
||||
return trimZero(String.format("%.2f", res)) + SIZE_UNINTS[index];
|
||||
}
|
||||
|
||||
private static String trimZero(String s) {
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="fun.asgc.neutrino.proxy.server.dal.ReportMapper">
|
||||
|
||||
<select id="userFlowReportList" resultType="fun.asgc.neutrino.proxy.server.controller.res.UserFlowReportRes">
|
||||
SELECT
|
||||
u.id AS 'userId',
|
||||
u.name AS 'userName',
|
||||
SUM(frm.write_bytes + frd.write_bytes + frm2.write_bytes) AS 'upFlowBytes',
|
||||
SUM(frm.read_bytes + frd.read_bytes + frm2.read_bytes) AS 'downFlowBytes',
|
||||
SUM(frm.write_bytes) monthWriteBytes,
|
||||
SUM(frm.read_bytes) monthReadBytes,
|
||||
SUM(frd.write_bytes) dayWriteBytes,
|
||||
SUM(frd.read_bytes) dayReadBytes,
|
||||
SUM(frm2.write_bytes) minuteWriteBytes,
|
||||
SUM(frm2.read_bytes) minuteReadBytes
|
||||
FROM `user` u
|
||||
LEFT JOIN (SELECT user_id,sum(write_bytes) write_bytes,sum(read_bytes) read_bytes from flow_report_month GROUP BY user_id) frm ON u.id = frm.user_id
|
||||
LEFT JOIN (SELECT user_id,sum(write_bytes) write_bytes,sum(read_bytes) read_bytes from flow_report_day
|
||||
WHERE date >= STR_TO_DATE(CONCAT(YEAR(CURDATE()), '-', month(CURDATE()), '-', '01'), '%Y-%m-%d') AND date <= STR_TO_DATE(CONCAT(YEAR(CURDATE()), '-', month(CURDATE()), '-', day(CURDATE())), '%Y-%m-%d')
|
||||
GROUP BY user_id) frd ON u.id = frd.user_id
|
||||
LEFT JOIN (SELECT user_id,sum(write_bytes) write_bytes,sum(read_bytes) read_bytes from flow_report_minute
|
||||
WHERE date >= STR_TO_DATE(CONCAT(YEAR(CURDATE()), '-', month(CURDATE()), '-', day(CURDATE())), '%Y-%m-%d') AND date <= STR_TO_DATE(CONCAT(YEAR(CURDATE()),'-',MONTH(CURDATE()),'-',DAY(CURDATE()), ' ',HOUR(CURTIME()),':',MINUTE(CURTIME())), "%Y-%m-%d %H:%i")
|
||||
GROUP BY user_id) frm2 ON u.id = frm2.user_id
|
||||
<where>
|
||||
<if test="req.userId != null">
|
||||
AND u.id = #{req.userId}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY u.id
|
||||
</select>
|
||||
|
||||
<select id="licenseFLowReportList" resultType="fun.asgc.neutrino.proxy.server.controller.res.LicenseFlowReportRes">
|
||||
SELECT
|
||||
l.id AS 'licenseId',
|
||||
l.name AS 'licenseName',
|
||||
u.id AS 'userId',
|
||||
u.name AS 'userName',
|
||||
SUM(frm.write_bytes + frd.write_bytes + frm2.write_bytes) AS 'upFlowBytes',
|
||||
SUM(frm.read_bytes + frd.read_bytes + frm2.read_bytes) AS 'downFlowBytes',
|
||||
SUM(frm.write_bytes) monthWriteBytes,
|
||||
SUM(frm.read_bytes) monthReadBytes,
|
||||
SUM(frd.write_bytes) dayWriteBytes,
|
||||
SUM(frd.read_bytes) dayReadBytes,
|
||||
SUM(frm2.write_bytes) minuteWriteBytes,
|
||||
SUM(frm2.read_bytes) minuteReadBytes
|
||||
FROM `license` l
|
||||
LEFT JOIN `user` u ON l.user_id = u.id
|
||||
LEFT JOIN (SELECT license_id,sum(write_bytes) write_bytes,sum(read_bytes) read_bytes from flow_report_month GROUP BY license_id) frm ON l.id = frm.license_id
|
||||
LEFT JOIN (SELECT license_id,sum(write_bytes) write_bytes,sum(read_bytes) read_bytes from flow_report_day
|
||||
WHERE date >= STR_TO_DATE(CONCAT(YEAR(CURDATE()), '-', month(CURDATE()), '-', '01'), '%Y-%m-%d') AND date <= STR_TO_DATE(CONCAT(YEAR(CURDATE()), '-', month(CURDATE()), '-', day(CURDATE())), '%Y-%m-%d')
|
||||
GROUP BY license_id) frd ON l.id = frd.license_id
|
||||
LEFT JOIN (SELECT license_id,sum(write_bytes) write_bytes,sum(read_bytes) read_bytes from flow_report_minute
|
||||
WHERE date >= STR_TO_DATE(CONCAT(YEAR(CURDATE()), '-', month(CURDATE()), '-', day(CURDATE())), '%Y-%m-%d') AND date <= STR_TO_DATE(CONCAT(YEAR(CURDATE()),'-',MONTH(CURDATE()),'-',DAY(CURDATE()), ' ',HOUR(CURTIME()),':',MINUTE(CURTIME())), "%Y-%m-%d %H:%i")
|
||||
GROUP BY license_id)frm2 ON l.id = frm2.license_id
|
||||
<where>
|
||||
<if test="req.userId != null">
|
||||
AND u.id = #{req.userId}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY l.id
|
||||
</select>
|
||||
</mapper>
|
||||
+4
-6
@@ -1,10 +1,8 @@
|
||||
# 功能点
|
||||
- 用户流量报表
|
||||
- 弹框展示月度明细
|
||||
- 弹框展示今日流量明细
|
||||
- License流量报表
|
||||
- 弹框展示月度明细
|
||||
- 弹框展示今日流量明细
|
||||
- [x] 用户流量报表
|
||||
- [ ] 兼容sqlite
|
||||
- [x] License流量报表
|
||||
- [ ] 兼容sqlite
|
||||
- 首页图表📈
|
||||
- 1、License在线数
|
||||
- 2、端口映射在线数
|
||||
|
||||
Reference in New Issue
Block a user