From 0a714b1322803be821890cee7c40c1706eb24c79 Mon Sep 17 00:00:00 2001
From: yys <47@gamerwa.com>
Date: Wed, 22 Apr 2026 17:40:59 +0800
Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=9B=A2=E9=98=9F=E7=BB=9F?=
=?UTF-8?q?=E8=AE=A1=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
admin-ui/src/views/ai/data/index.vue | 126 +++++++++++++++++-
.../src/views/ai/groupchargeorder/index.vue | 11 +-
admin-ui/src/views/ai/user/index.vue | 69 ++++------
.../src/views/subteam/chargeOrder/index.vue | 3 +-
admin-ui/src/views/subteam/overview/index.vue | 2 +-
admin-ui/src/views/subteam/user/index.vue | 7 +-
.../AiVideoReportDataController.java | 26 +++-
.../subteam/SubteamOverviewController.java | 5 +-
.../com/ruoyi/common/constant/RedisKey.java | 2 +
.../common/core/domain/entity/AiUser.java | 4 +-
.../ruoyi/ai/domain/AiVideoReportData.java | 17 ++-
.../request/GroupReportDataRequest.java | 6 +
.../vo/TeamDailyConsumeAggregateVO.java | 25 ++++
.../ai/mapper/AiVideoReportDataMapper.java | 17 ++-
.../ai/service/IAiVideoReportDataService.java | 7 +
.../impl/AiVideoReportDataServiceImpl.java | 47 +++++--
.../impl/SubteamOverviewServiceImpl.java | 12 +-
.../mapper/ai/AiVideoReportDataMapper.xml | 101 +++++++++-----
18 files changed, 369 insertions(+), 118 deletions(-)
create mode 100644 web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/vo/TeamDailyConsumeAggregateVO.java
diff --git a/admin-ui/src/views/ai/data/index.vue b/admin-ui/src/views/ai/data/index.vue
index 6b8b6be..8695bb9 100644
--- a/admin-ui/src/views/ai/data/index.vue
+++ b/admin-ui/src/views/ai/data/index.vue
@@ -32,12 +32,46 @@
搜索
重置
+ 导出
+
-
-
-
+
+
+
+ 汇总:加载中…
+
+
+
+ 汇总:—
+
+
+
+ 汇总:
+ 总计
+ {{ summaryState.totalStr }}
+ 条记录,实际充值积分
+ {{ summaryState.recharge }}
+ 分
+ ,消耗积分
+ {{ summaryState.score }}
+ 分
+ ,实际订单数量(成功)
+ {{ summaryState.orders }}
+ 单
+ ,三方消耗tokens数量
+ {{ summaryState.tokens }}
+ 。
+
+
@@ -90,6 +124,7 @@ export default {
showSearch: true,
total: 0,
dataList: [],
+ aggregate: null,
deptOptions: [],
dateRange: [],
queryParams: {
@@ -107,9 +142,30 @@ export default {
this.syncDateRangeToQuery()
this.getList()
},
+ computed: {
+ summaryState() {
+ if (this.loading) {
+ return { mode: "loading" }
+ }
+ const a = this.aggregate
+ if (!a) {
+ return { mode: "empty" }
+ }
+ const fmt = (v) => this.formatWesternNumberValue(v)
+ const n = a.totalRows != null ? Number(a.totalRows) : 0
+ const totalStr = Number.isNaN(n) ? "0" : n.toLocaleString("en-US")
+ return {
+ mode: "ok",
+ totalStr,
+ recharge: fmt(a.sumRechargeScore),
+ score: fmt(a.sumScore),
+ orders: fmt(a.sumOrderCount),
+ tokens: fmt(a.sumUseTokens)
+ }
+ }
+ },
methods: {
- /** null/空 显示 0;数字按 en-US 千分位(如 99,999,999) */
- formatWesternNumber(row, column, cellValue) {
+ formatWesternNumberValue(cellValue) {
if (cellValue === null || cellValue === undefined || cellValue === "") {
return (0).toLocaleString("en-US")
}
@@ -119,6 +175,10 @@ export default {
}
return n.toLocaleString("en-US")
},
+ /** null/空 显示 0;数字按 en-US 千分位(如 99,999,999) */
+ formatWesternNumber(row, column, cellValue) {
+ return this.formatWesternNumberValue(cellValue)
+ },
buildLastMonthDateRange() {
const end = new Date()
const start = new Date(end.getTime())
@@ -160,8 +220,10 @@ export default {
this.loading = true
listData(this.queryParams)
.then(response => {
- this.dataList = response.rows
- this.total = response.total
+ this.dataList = response.rows || []
+ this.total = response.total != null ? response.total : 0
+ this.aggregate =
+ response.param && response.param.aggregate != null ? response.param.aggregate : null
})
.finally(() => {
this.loading = false
@@ -177,7 +239,57 @@ export default {
this.queryParams.pageNum = 1
this.syncDateRangeToQuery()
this.getList()
+ },
+ handleExport() {
+ this.syncDateRangeToQuery()
+ this.download(
+ "ai/data/export",
+ {
+ startDate: this.queryParams.startDate,
+ endDate: this.queryParams.endDate,
+ deptId: this.queryParams.deptId
+ },
+ `team_consume_${new Date().getTime()}.xlsx`
+ )
}
}
}
+
+
diff --git a/admin-ui/src/views/ai/groupchargeorder/index.vue b/admin-ui/src/views/ai/groupchargeorder/index.vue
index fed8f2a..4113c31 100644
--- a/admin-ui/src/views/ai/groupchargeorder/index.vue
+++ b/admin-ui/src/views/ai/groupchargeorder/index.vue
@@ -19,7 +19,12 @@
-
+
@@ -151,6 +156,10 @@ export default {
amount: [{ required: true, message: "请填写积分", trigger: "blur" }],
status: [{ required: true, message: "请选择状态", trigger: "change" }]
},
+ orderTypeQueryOptions: [
+ { label: "充值", value: 0 },
+ { label: "退款", value: 1 }
+ ],
orderTypeOptions: [
{ label: "充值", value: 0 },
{ label: "退款", value: 1 },
diff --git a/admin-ui/src/views/ai/user/index.vue b/admin-ui/src/views/ai/user/index.vue
index e0d1755..d5d61fd 100644
--- a/admin-ui/src/views/ai/user/index.vue
+++ b/admin-ui/src/views/ai/user/index.vue
@@ -8,19 +8,12 @@
v-show="showSearch"
label-width="68px"
>
-
-
-
@@ -29,19 +22,12 @@
v-model="queryParams.username"
placeholder="请输入用户账号"
clearable
+ style="width: 150px"
@keyup.enter.native="handleQuery"
/>
-
-
-
-
-
+
+
-
+
搜索
重置
-
-
-
-
-
新增
-
-
删除
-
-
导出
-
-
-
+
+
+
-
-
+
+
-
+
-
+
- {{ parseTime(scope.row.loginTime, '{y}-{m}-{d}') }}
+ {{ parseTime(scope.row.loginTime, '{y}-{m}-{d} {h}:{i}:{s}') }}
-
分配部门
+ >分配团队
-
-
+
+
-
+
@@ -297,6 +273,9 @@
@close="cancelDeptScore"
>
+
+ {{ deptScoreForm.deptName || "—" }}
+
{{ deptScoreForm.username }}
@@ -392,6 +371,7 @@ export default {
deptScoreForm: {
userId: null,
username: "",
+ deptName: "",
amount: undefined,
remark: ""
},
@@ -526,13 +506,14 @@ export default {
},
openDeptScoreDialog(row, mode) {
if (!row.deptId) {
- this.$modal.msgWarning("请先分配归属部门后再操作积分");
+ this.$modal.msgWarning("请先分配归属团队后再操作积分");
return;
}
this.deptScoreMode = mode;
this.deptScoreForm = {
userId: row.id,
username: row.username || row.userId || "",
+ deptName: row.deptName || "",
amount: undefined,
remark: ""
};
@@ -569,7 +550,7 @@ export default {
},
cancelDeptScore() {
this.deptScoreOpen = false;
- this.deptScoreForm = { userId: null, username: "", amount: undefined, remark: "" };
+ this.deptScoreForm = { userId: null, username: "", deptName: "", amount: undefined, remark: "" };
},
// updateBalance(row) {
// this.reset();
diff --git a/admin-ui/src/views/subteam/chargeOrder/index.vue b/admin-ui/src/views/subteam/chargeOrder/index.vue
index ab74f5a..de285ac 100644
--- a/admin-ui/src/views/subteam/chargeOrder/index.vue
+++ b/admin-ui/src/views/subteam/chargeOrder/index.vue
@@ -3,7 +3,8 @@
-
+
+
diff --git a/admin-ui/src/views/subteam/overview/index.vue b/admin-ui/src/views/subteam/overview/index.vue
index f7edde9..02e9925 100644
--- a/admin-ui/src/views/subteam/overview/index.vue
+++ b/admin-ui/src/views/subteam/overview/index.vue
@@ -13,7 +13,7 @@
团队名称
{{ info.deptName }}
- 积分余额(部门)
{{ info.balance }}
+ 团队剩余积分
{{ info.balance }}
diff --git a/admin-ui/src/views/subteam/user/index.vue b/admin-ui/src/views/subteam/user/index.vue
index 58742b2..56238b3 100644
--- a/admin-ui/src/views/subteam/user/index.vue
+++ b/admin-ui/src/views/subteam/user/index.vue
@@ -109,6 +109,9 @@
@close="cancelDeptScore"
>
+
+ {{ deptScoreForm.deptName || '—' }}
+
{{ deptScoreForm.username }}
@@ -169,6 +172,7 @@ export default {
deptScoreForm: {
userId: null,
username: '',
+ deptName: '',
amount: undefined,
remark: ''
},
@@ -270,6 +274,7 @@ export default {
this.deptScoreForm = {
userId: row.id,
username: row.username || row.userId || '',
+ deptName: row.deptName || '',
amount: undefined,
remark: ''
}
@@ -306,7 +311,7 @@ export default {
},
cancelDeptScore() {
this.deptScoreOpen = false
- this.deptScoreForm = { userId: null, username: '', amount: undefined, remark: '' }
+ this.deptScoreForm = { userId: null, username: '', deptName: '', amount: undefined, remark: '' }
}
}
}
diff --git a/web-api/ruoyi-admin/src/main/java/com/ruoyi/ai/controller/AiVideoReportDataController.java b/web-api/ruoyi-admin/src/main/java/com/ruoyi/ai/controller/AiVideoReportDataController.java
index 3e4d1bc..1ab9f6a 100644
--- a/web-api/ruoyi-admin/src/main/java/com/ruoyi/ai/controller/AiVideoReportDataController.java
+++ b/web-api/ruoyi-admin/src/main/java/com/ruoyi/ai/controller/AiVideoReportDataController.java
@@ -1,10 +1,13 @@
package com.ruoyi.ai.controller;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import com.ruoyi.ai.domain.request.GroupReportDataRequest;
+import com.ruoyi.ai.domain.vo.TeamDailyConsumeAggregateVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@@ -12,10 +15,10 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
@@ -44,8 +47,17 @@ public class AiVideoReportDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('ai:data:list')")
@GetMapping("/list")
public TableDataInfo list(@Valid @ModelAttribute GroupReportDataRequest query) {
- List list = aiVideoReportDataService.selectTeamDailyConsumeList(query);
- return getDataTable(list);
+ TeamDailyConsumeAggregateVO aggregate = aiVideoReportDataService.selectTeamDailyConsumeAggregate(query);
+ List list = aiVideoReportDataService.selectTeamDailyConsumeListPaged(query);
+ TableDataInfo rsp = new TableDataInfo();
+ rsp.setCode(HttpStatus.SUCCESS);
+ rsp.setMsg("查询成功");
+ rsp.setRows(list);
+ rsp.setTotal(aggregate.getTotalRows());
+ Map param = new HashMap<>(2);
+ param.put("aggregate", aggregate);
+ rsp.setParam(param);
+ return rsp;
}
/**
@@ -54,9 +66,13 @@ public class AiVideoReportDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('ai:data:export')")
@Log(title = "AI视频生成统计数据,作为其他统计报的数据源", businessType = BusinessType.EXPORT)
@PostMapping("/export")
- public void export(HttpServletResponse response, @Valid @RequestBody GroupReportDataRequest query) {
+ public void export(HttpServletResponse response, GroupReportDataRequest query) {
+ if (query != null) {
+ query.setPageNum(null);
+ query.setPageSize(null);
+ }
List list = aiVideoReportDataService.selectTeamDailyConsumeList(query);
- ExcelUtil util = new ExcelUtil(AiVideoReportData.class);
+ ExcelUtil util = new ExcelUtil<>(AiVideoReportData.class);
util.exportExcel(response, list, "AI视频生成统计数据,作为其他统计报的数据源数据");
}
diff --git a/web-api/ruoyi-admin/src/main/java/com/ruoyi/web/controller/subteam/SubteamOverviewController.java b/web-api/ruoyi-admin/src/main/java/com/ruoyi/web/controller/subteam/SubteamOverviewController.java
index bfbec20..6095229 100644
--- a/web-api/ruoyi-admin/src/main/java/com/ruoyi/web/controller/subteam/SubteamOverviewController.java
+++ b/web-api/ruoyi-admin/src/main/java/com/ruoyi/web/controller/subteam/SubteamOverviewController.java
@@ -19,8 +19,7 @@ public class SubteamOverviewController extends BaseController {
@PreAuthorize("@ss.hasPermi('subteam:overview:view')")
@GetMapping
- public AjaxResult overview() {
- SubteamOverviewVO vo = subteamOverviewService.loadOverview();
- return success(vo);
+ public AjaxResult overview() {
+ return success(subteamOverviewService.loadOverview());
}
}
diff --git a/web-api/ruoyi-common/src/main/java/com/ruoyi/common/constant/RedisKey.java b/web-api/ruoyi-common/src/main/java/com/ruoyi/common/constant/RedisKey.java
index a9ab047..8df6b3b 100644
--- a/web-api/ruoyi-common/src/main/java/com/ruoyi/common/constant/RedisKey.java
+++ b/web-api/ruoyi-common/src/main/java/com/ruoyi/common/constant/RedisKey.java
@@ -12,4 +12,6 @@ public final class RedisKey {
* Spring Cache 名:部门近七日汇总({@code @Cacheable} 与 TTL 配置须同名)
*/
public static final String CACHE_DEPT_SUMMARY = "dept_summary";
+
+ public static final String VIDEO_METRICS = "video_metrics";
}
diff --git a/web-api/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/AiUser.java b/web-api/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/AiUser.java
index 6e473a3..5bf3bf3 100644
--- a/web-api/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/AiUser.java
+++ b/web-api/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/AiUser.java
@@ -85,8 +85,8 @@ public class AiUser extends BaseEntity {
private String paymentUrl;
/** 登录时间 */
- @JsonFormat(pattern = "yyyy-MM-dd")
- @Excel(name = "登录时间", width = 30, dateFormat = "yyyy-MM-dd")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @Excel(name = "登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date loginTime;
/** 余额 */
diff --git a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/AiVideoReportData.java b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/AiVideoReportData.java
index 0ef31b1..f898425 100644
--- a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/AiVideoReportData.java
+++ b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/AiVideoReportData.java
@@ -26,43 +26,46 @@ public class AiVideoReportData implements Serializable {
/** 主键 */
@TableId(type = IdType.AUTO)
- @Excel(name = "主键")
+ @Excel(name = "主键", type = Excel.Type.IMPORT)
private Long id;
/** 统计时间,到小时(库表注释:'%Y-%m-%d %H';业务写入常用 yyyyMMddHH) */
- @Excel(name = "统计时间(到小时)")
+ @Excel(name = "日期", sort = 1)
private String dateKey;
/** 部门ID */
- @Excel(name = "部门ID")
+ @Excel(name = "团队ID", sort = 2)
private Long deptId;
/** 消耗积分,按任务创建时间统计 */
- @Excel(name = "消耗积分")
+ @Excel(name = "消耗积分", sort = 5)
private BigDecimal score;
/** 实际充值积分(充值 - 退款) */
- @Excel(name = "实际充值积分")
+ @Excel(name = "实际充值积分(充值-退款)", sort = 4)
private BigDecimal rechargeScore;
/** 实际订单数,仅统计生成成功的任务 */
- @Excel(name = "订单数")
+ @Excel(name = "实际订单数量(成功)", sort = 6)
private Long orderCount;
/** 三方消耗 tokens,按任务创建时间统计 */
- @Excel(name = "消耗tokens")
+ @Excel(name = "三方消耗tokens数量", sort = 7)
private Long useTokens;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @Excel(name = "创建时间", type = Excel.Type.IMPORT)
private Date createTime;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @Excel(name = "更新时间", type = Excel.Type.IMPORT)
private Date updateTime;
/** 团队名称(查询结果展示,非表字段) */
@TableField(exist = false)
+ @Excel(name = "团队名称", sort = 3)
private String deptName;
/** 查询日期 yyyyMMdd(非表字段,子团队单日统计等仍可用) */
diff --git a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/request/GroupReportDataRequest.java b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/request/GroupReportDataRequest.java
index 6c69a1f..7eeda2f 100644
--- a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/request/GroupReportDataRequest.java
+++ b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/request/GroupReportDataRequest.java
@@ -19,4 +19,10 @@ public class GroupReportDataRequest implements Serializable {
/** 二级团队部门 ID,可选;为空表示不限团队 */
private Long deptId;
+
+ /** 列表分页:页码,从 1 开始;导出不传 */
+ private Integer pageNum;
+
+ /** 列表分页:每页条数;导出不传 */
+ private Integer pageSize;
}
diff --git a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/vo/TeamDailyConsumeAggregateVO.java b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/vo/TeamDailyConsumeAggregateVO.java
new file mode 100644
index 0000000..7ea4ba2
--- /dev/null
+++ b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/domain/vo/TeamDailyConsumeAggregateVO.java
@@ -0,0 +1,25 @@
+package com.ruoyi.ai.domain.vo;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import lombok.Data;
+
+/**
+ * 团队每日消耗统计:分组总行数与明细列全量合计(与列表筛选条件一致)。
+ */
+@Data
+public class TeamDailyConsumeAggregateVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** 按日+团队聚合后的行数(与分页 total 一致) */
+ private long totalRows;
+
+ private BigDecimal sumRechargeScore;
+
+ private BigDecimal sumScore;
+
+ private Long sumOrderCount;
+
+ private Long sumUseTokens;
+}
diff --git a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/mapper/AiVideoReportDataMapper.java b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/mapper/AiVideoReportDataMapper.java
index d87f50d..81d02bd 100644
--- a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/mapper/AiVideoReportDataMapper.java
+++ b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/mapper/AiVideoReportDataMapper.java
@@ -1,12 +1,12 @@
package com.ruoyi.ai.mapper;
import java.util.List;
-import java.math.BigDecimal;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.ai.domain.AiOrder;
import com.ruoyi.ai.domain.AiVideoReportData;
import com.ruoyi.ai.domain.request.GroupReportDataRequest;
+import com.ruoyi.ai.domain.vo.TeamDailyConsumeAggregateVO;
import com.ruoyi.system.domain.subteam.SubteamVideoMetrics;
import org.apache.ibatis.annotations.Param;
@@ -24,6 +24,21 @@ public interface AiVideoReportDataMapper extends BaseMapper {
*/
List selectTeamDailyConsumeList(GroupReportDataRequest query);
+ /**
+ * 与列表相同筛选下的分组行数 + 四列合计(一条 SQL)。
+ */
+ TeamDailyConsumeAggregateVO selectTeamDailyConsumeAggregate(GroupReportDataRequest query);
+
+ /**
+ * 按日+团队聚合后的分页列表(一条 SQL,LIMIT/OFFSET)。
+ * 参数须为标量:全局 {@code pagehelper.supportMethodsArguments=true} 时,若传入含 pageNum/pageSize 的请求对象,PageHelper 会再次追加 LIMIT。
+ */
+ List selectTeamDailyConsumeListPaged(@Param("startDate") String startDate,
+ @Param("endDate") String endDate,
+ @Param("deptId") Long deptId,
+ @Param("offset") int offset,
+ @Param("limit") int limit);
+
/**
* 按团队部门、日期聚合(团队后台消耗统计)
*/
diff --git a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/IAiVideoReportDataService.java b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/IAiVideoReportDataService.java
index 88575cc..d82bd02 100644
--- a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/IAiVideoReportDataService.java
+++ b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/IAiVideoReportDataService.java
@@ -10,6 +10,7 @@ import com.ruoyi.ai.domain.AiVideoReportData;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.ai.domain.request.GroupReportDataRequest;
+import com.ruoyi.ai.domain.vo.TeamDailyConsumeAggregateVO;
/**
* AI视频生成统计数据,作为其他统计报的数据源Service接口
@@ -32,6 +33,12 @@ public interface IAiVideoReportDataService {
*/
List selectTeamDailyConsumeList(GroupReportDataRequest query);
+ /** 分组总行数 + 四列合计(与列表筛选一致)。 */
+ TeamDailyConsumeAggregateVO selectTeamDailyConsumeAggregate(GroupReportDataRequest query);
+
+ /** 团队每日消耗分页列表(依赖 query 中的 pageNum/pageSize,Service 内写入 offset)。 */
+ List selectTeamDailyConsumeListPaged(GroupReportDataRequest query);
+
/**
* 团队每日消耗(按部门 ID,团队后台)
*/
diff --git a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/impl/AiVideoReportDataServiceImpl.java b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/impl/AiVideoReportDataServiceImpl.java
index a5ad0a0..7286e36 100644
--- a/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/impl/AiVideoReportDataServiceImpl.java
+++ b/web-api/ruoyi-system/src/main/java/com/ruoyi/ai/service/impl/AiVideoReportDataServiceImpl.java
@@ -1,20 +1,13 @@
package com.ruoyi.ai.service.impl;
import java.math.BigDecimal;
-import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import java.time.format.DateTimeFormatter;
-import java.util.Date;
import java.util.List;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.ai.domain.AiChargeRefundOrder;
import com.ruoyi.ai.domain.AiOrder;
import com.ruoyi.ai.domain.request.GroupReportDataRequest;
-import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.ai.domain.vo.TeamDailyConsumeAggregateVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ai.mapper.AiVideoReportDataMapper;
@@ -49,6 +42,44 @@ public class AiVideoReportDataServiceImpl implements IAiVideoReportDataService {
return aiVideoReportDataMapper.selectTeamDailyConsumeList(query);
}
+ @Override
+ public TeamDailyConsumeAggregateVO selectTeamDailyConsumeAggregate(GroupReportDataRequest query) {
+ TeamDailyConsumeAggregateVO vo = aiVideoReportDataMapper.selectTeamDailyConsumeAggregate(query);
+ if (vo == null) {
+ vo = new TeamDailyConsumeAggregateVO();
+ vo.setTotalRows(0L);
+ vo.setSumRechargeScore(BigDecimal.ZERO);
+ vo.setSumScore(BigDecimal.ZERO);
+ vo.setSumOrderCount(0L);
+ vo.setSumUseTokens(0L);
+ } else {
+ if (vo.getSumRechargeScore() == null) {
+ vo.setSumRechargeScore(BigDecimal.ZERO);
+ }
+ if (vo.getSumScore() == null) {
+ vo.setSumScore(BigDecimal.ZERO);
+ }
+ if (vo.getSumOrderCount() == null) {
+ vo.setSumOrderCount(0L);
+ }
+ if (vo.getSumUseTokens() == null) {
+ vo.setSumUseTokens(0L);
+ }
+ }
+ return vo;
+ }
+
+ @Override
+ public List selectTeamDailyConsumeListPaged(GroupReportDataRequest query) {
+ int pageNum = query.getPageNum() == null || query.getPageNum() < 1 ? 1 : query.getPageNum();
+ int pageSize = query.getPageSize() == null || query.getPageSize() < 1 ? 10 : query.getPageSize();
+ query.setPageNum(pageNum);
+ query.setPageSize(pageSize);
+ int offset = (pageNum - 1) * pageSize;
+ return aiVideoReportDataMapper.selectTeamDailyConsumeListPaged(
+ query.getStartDate(), query.getEndDate(), query.getDeptId(), offset, pageSize);
+ }
+
@Override
public List selectTeamDailyConsumeByDeptId(String statDate, Long deptId) {
return aiVideoReportDataMapper.selectTeamDailyConsumeByDeptId(statDate, deptId);
diff --git a/web-api/ruoyi-system/src/main/java/com/ruoyi/system/service/subteam/impl/SubteamOverviewServiceImpl.java b/web-api/ruoyi-system/src/main/java/com/ruoyi/system/service/subteam/impl/SubteamOverviewServiceImpl.java
index 0edd0c6..c574541 100644
--- a/web-api/ruoyi-system/src/main/java/com/ruoyi/system/service/subteam/impl/SubteamOverviewServiceImpl.java
+++ b/web-api/ruoyi-system/src/main/java/com/ruoyi/system/service/subteam/impl/SubteamOverviewServiceImpl.java
@@ -4,6 +4,8 @@ import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;
+
+import com.ruoyi.common.constant.RedisKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ai.mapper.AiVideoReportDataMapper;
@@ -21,6 +23,8 @@ public class SubteamOverviewServiceImpl implements ISubteamOverviewService {
private static final int METRICS_CACHE_MINUTES = 5;
+ private static final DateTimeFormatter VIDEO_METRICS_DAY = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+
@Autowired
private ISubteamScopeService subteamScopeService;
@@ -48,12 +52,12 @@ public class SubteamOverviewServiceImpl implements ISubteamOverviewService {
LocalDate end = LocalDate.now();
LocalDate start = end.minusDays(6);
- String startDay = start.format(DateTimeFormatter.BASIC_ISO_DATE);
- String endDay = end.format(DateTimeFormatter.BASIC_ISO_DATE);
- String cacheKey = "subteam:videoMetrics:" + deptId + ":" + startDay + ":" + endDay;
+ String startDate = start.format(VIDEO_METRICS_DAY);
+ String endDate = end.format(VIDEO_METRICS_DAY);
+ String cacheKey = RedisKey.VIDEO_METRICS + ":" + deptId + ":" + startDate + ":" + endDate;
SubteamVideoMetrics metrics = redisCache.getCacheObject(cacheKey);
if (metrics == null) {
- metrics = aiVideoReportDataMapper.selectDeptVideoMetricsBetween(deptId, startDay, endDay);
+ metrics = aiVideoReportDataMapper.selectDeptVideoMetricsBetween(deptId, startDate, endDate);
if (metrics == null) {
metrics = new SubteamVideoMetrics();
}
diff --git a/web-api/ruoyi-system/src/main/resources/mapper/ai/AiVideoReportDataMapper.xml b/web-api/ruoyi-system/src/main/resources/mapper/ai/AiVideoReportDataMapper.xml
index 54240fd..22a0a46 100644
--- a/web-api/ruoyi-system/src/main/resources/mapper/ai/AiVideoReportDataMapper.xml
+++ b/web-api/ruoyi-system/src/main/resources/mapper/ai/AiVideoReportDataMapper.xml
@@ -26,10 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
-