feat: 生成视频时记录统计表数据
This commit is contained in:
parent
690bc43a55
commit
1a7205564d
|
|
@ -1,9 +1,11 @@
|
|||
package com.ruoyi.ai.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.ai.domain.AiOrder;
|
||||
import com.ruoyi.ai.domain.AiVideoReportData;
|
||||
import com.ruoyi.common.core.dto.DeptSummaryDTO;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* 视频报表数据 Mapper
|
||||
|
|
@ -12,4 +14,6 @@ public interface AiVideoReportDataMapper extends BaseMapper<AiVideoReportData> {
|
|||
@Select("SELECT SUM(order_count) as order_count,SUM(score) as score FROM ai_video_report_data " +
|
||||
" where dept_id=#{deptId} and date_key>=#{startHour} and date_key<=#{endHour}")
|
||||
DeptSummaryDTO selectOneDeptSummaryData(Long deptId, String startHour, String endHour);
|
||||
|
||||
void addNewOrderReportData(AiOrder aiOrder);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.ruoyi.ai.domain.AiManager;
|
||||
import com.ruoyi.ai.domain.AiOrder;
|
||||
import com.ruoyi.ai.domain.AiStatistics;
|
||||
import com.ruoyi.ai.domain.AiVideoReportData;
|
||||
import com.ruoyi.ai.mapper.AiOrderMapper;
|
||||
import com.ruoyi.ai.mapper.AiVideoReportDataMapper;
|
||||
import com.ruoyi.ai.service.*;
|
||||
import com.ruoyi.common.constant.BalanceChangerConstants;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
|
|
@ -46,6 +48,8 @@ public class AiOrderServiceImpl implements IAiOrderService {
|
|||
|
||||
@Autowired
|
||||
private AiOrderMapper aiOrderMapper;
|
||||
@Autowired
|
||||
private AiVideoReportDataMapper aiVideoReportDataMapper;
|
||||
|
||||
@Autowired
|
||||
private IAiManagerService aiManagerService;
|
||||
|
|
@ -249,6 +253,9 @@ public class AiOrderServiceImpl implements IAiOrderService {
|
|||
aiStatistics.setGenerateCount(1L);
|
||||
// 新增生成数量
|
||||
aiStatisticsService.saveOrUpdateData(aiStatistics);
|
||||
|
||||
// 统计数据
|
||||
aiVideoReportDataMapper.addNewOrderReportData(aiOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
<?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="com.ruoyi.ai.mapper.AiVideoReportDataMapper">
|
||||
|
||||
<!--
|
||||
按订单 create_time 聚合到小时(yyyy-MM-dd HH)+ dept_id + user_id 维表。
|
||||
不存在则插入,存在则累加 score、order_count、use_tokens(单条语句,InnoDB 原子)。
|
||||
-->
|
||||
<insert id="addNewOrderReportData">
|
||||
INSERT INTO ai_video_report_data (date_key, dept_id, user_id, score, order_count, use_tokens)
|
||||
VALUES (
|
||||
DATE_FORMAT(#{createTime}, '%Y-%m-%d %H'),
|
||||
#{deptId},
|
||||
#{userId},
|
||||
IFNULL(#{amount}, 0),
|
||||
1,
|
||||
IFNULL(#{totalUsage}, 0)
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
score = score + VALUES(score),
|
||||
order_count = order_count + VALUES(order_count),
|
||||
use_tokens = use_tokens + VALUES(use_tokens)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue