| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <?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.fs.fastGpt.mapper.FastgptEventLogTotalMapper">
-
- <resultMap type="FastgptEventLogTotal" id="FastgptEventLogTotalResult">
- <result property="id" column="id" />
- <result property="roleId" column="role_id" />
- <result property="count" column="count" />
- <result property="type" column="type" />
- <result property="companyId" column="company_id" />
- <result property="companyUserId" column="company_user_id" />
- <result property="qwUserId" column="qw_user_id" />
- <result property="statTime" column="stat_time" />
- </resultMap>
- <sql id="selectFastgptEventLogTotalVo">
- select id, role_id, `count`, `type`, company_id, company_user_id, qw_user_id, stat_time from fastgpt_event_log_total
- </sql>
- <select id="selectFastgptEventLogTotalList" parameterType="FastgptEventLogTotal" resultMap="FastgptEventLogTotalResult">
- <include refid="selectFastgptEventLogTotalVo"/>
- <where>
- <if test="roleId != null "> and role_id = #{roleId}</if>
- <if test="count != null "> and `count` = #{count}</if>
- <if test="type != null "> and `type` = #{type}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
- <if test="beginTime != null and endTime != null"> <![CDATA[and DATE_FORMAT(create_time, '%Y-%m-%d') >= #{beginTime}
- and DATE_FORMAT(create_time, '%Y-%m-%d') <= #{endTime} ]]></if>
- </where>
- </select>
-
- <select id="selectFastgptEventLogTotalById" parameterType="Long" resultMap="FastgptEventLogTotalResult">
- <include refid="selectFastgptEventLogTotalVo"/>
- where id = #{id}
- </select>
- <select id="selectFastgptEventLogTotalInfoList" resultType="com.fs.fastGpt.domain.FastgptEventLogTotal">
- SELECT role_id roleId,company_id companyId,company_user_id companyUserId,qw_user_id qwUserId,event_name eventName,`type`,
- DATE_FORMAT(create_time,'%Y-%m-%d') as statTime,sum(count) count,count(distinct sender_id) senderCount from fastgpt_event_log
- <where>
- <if test="roleId != null "> and role_id = #{roleId}</if>
- <if test="roleId == null "> and role_id is not null</if>
- <if test="createTime != null "> and DATE_FORMAT(create_time,'%Y-%m-%d') = DATE_FORMAT(#{createTime},'%Y-%m-%d')</if>
- <if test="beginTime != null and endTime != null"> <![CDATA[and DATE_FORMAT(create_time,'%Y-%m-%d') > DATE_FORMAT(#{beginTime},'%Y-%m-%d')
- and DATE_FORMAT(create_time,'%Y-%m-%d') <= DATE_FORMAT(#{endTime},'%Y-%m-%d') ]]></if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="companyUserId == null "> and company_user_id is not null</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="qwUserId == null "> and qw_user_id is not null</if>
- <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
- </where>
- group by role_id,company_id,company_user_id,qw_user_id,event_name,`type`,DATE_FORMAT(create_time,'%Y-%m-%d')
- order by `type`
- </select>
- <select id="selectFastgptEventLogTotalVoInfoList" resultType="com.fs.fastGpt.domain.FastgptEventLogTotal">
- SELECT
- role_id roleId,type,
- sum(count) AS count,stat_time statTime
- FROM fastgpt_event_log_total
- <where>
- <if test="roleId != null "> and role_id = #{roleId}</if>
- <if test="count != null "> and `count` = #{count}</if>
- <if test="type != null "> and `type` = #{type}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="qwUserIds != null">
- and qw_user_id in
- <foreach collection="qwUserIds.split(',')" item="qwUserId" open="(" close=")" separator=",">
- #{qwUserId}
- </foreach>
- </if>
- <if test="roleIds != null">
- and role_id in
- <foreach collection="roleIds" item="roleId" open="(" close=")" separator=",">
- #{roleId}
- </foreach>
- </if>
- <if test="beginTime != null and endTime != null"> <![CDATA[and DATE_FORMAT(stat_time, '%Y-%m-%d') >= #{beginTime}
- and DATE_FORMAT(stat_time, '%Y-%m-%d') <= #{endTime} ]]></if>
- </where>
- GROUP BY role_id,stat_time,type WITH ROLLUP
- HAVING role_id is not null and type is not null
- </select>
- <select id="selectFastgptEventTokenLogTotalList" resultType="com.fs.fastGpt.domain.FastGptEventTokenLog">
- SELECT role_id roleId,company_id companyId,company_user_id companyUserId,qw_user_id qwUserId,
- DATE_FORMAT(create_time, '%Y-%m-%d') as statTime,sum(token_count) tokenCount from fastgpt_event_token_log
- where token_type = 0
- <if test="roleId != null "> and role_id = #{roleId}</if>
- <if test="roleId == null "> and role_id is not null</if>
- <if test="createTime != null "> and DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT(#{createTime})</if>
- <if test="beginTime != null and endTime != null"> <![CDATA[and DATE_FORMAT(create_time, '%Y-%m-%d') > DATE_FORMAT(#{beginTime}, '%Y-%m-%d')
- and DATE_FORMAT(create_time, '%Y-%m-%d') <= DATE_FORMAT(#{endTime}, '%Y-%m-%d') ]]></if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="companyUserId == null "> and company_user_id is not null</if>
- <if test="qwUserId == null "> and qw_user_id is not null</if>
- <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
- group by role_id,company_id,company_user_id,qw_user_id,DATE_FORMAT(create_time, '%Y-%m-%d')
- </select>
- <select id="selectFastgptEventTokenLogTotalByRoleIdAndType" resultMap="FastgptEventLogTotalResult">
- <include refid="selectFastgptEventLogTotalVo"/>
- where `type` = 11
- <if test="roleId != null "> and role_id = #{roleId}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
- <if test="statTime != null "> and stat_time = #{statTime}</if>
- </select>
- <select id="selectFastgptEventLogTotalByRoleIdAndType" resultMap="FastgptEventLogTotalResult">
- <include refid="selectFastgptEventLogTotalVo"/>
- <where>
- <if test="roleId != null "> and role_id = #{roleId}</if>
- <if test="type != null "> and `type` = #{type}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
- <if test="statTime != null "> and stat_time = #{statTime}</if>
- </where>
- </select>
- <select id="selectFastgptEventLogTotalListByStatTime"
- resultType="com.fs.fastGpt.vo.FastgptEventLogTotalVo">
- SELECT fe.stat_time statTime,c.company_id companyId,c.company_name companyName,sum(`count`) `count`
- FROM `fastgpt_event_log_total` fe left join company c on fe.company_id = c.company_id
- where fe.stat_time like concat(#{dateTime},'%')
- GROUP BY fe.company_id
- order by fe.company_id
- </select>
- <insert id="insertFastgptEventLogTotal" parameterType="FastgptEventLogTotal" useGeneratedKeys="true" keyProperty="id">
- insert into fastgpt_event_log_total
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="roleId != null">role_id,</if>
- <if test="count != null">`count`,</if>
- <if test="type != null">`type`,</if>
- <if test="companyId != null">company_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="qwUserId != null">qw_user_id,</if>
- <if test="statTime != null">stat_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="roleId != null">#{roleId},</if>
- <if test="count != null">#{count},</if>
- <if test="type != null">#{type},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="qwUserId != null">#{qwUserId},</if>
- <if test="statTime != null">#{statTime},</if>
- </trim>
- </insert>
- <insert id="insertFastgptEventLogTotalBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO fastgpt_event_log_total
- (role_id, `count`, `type`, company_id, company_user_id, qw_user_id, stat_time)
- VALUES
- <foreach collection="list" item="item" separator=",">
- (
- #{item.roleId},
- #{item.count},
- #{item.type},
- #{item.companyId},
- #{item.companyUserId},
- #{item.qwUserId},
- #{item.statTime}
- )
- </foreach>
- </insert>
- <update id="updateFastgptEventLogTotal" parameterType="FastgptEventLogTotal">
- update fastgpt_event_log_total
- <trim prefix="SET" suffixOverrides=",">
- <if test="roleId != null">role_id = #{roleId},</if>
- <if test="count != null">`count` = #{count},</if>
- <if test="type != null">`type` = #{type},</if>
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
- <if test="statTime != null">stat_time = #{statTime},</if>
- </trim>
- where id = #{id}
- </update>
- <update id="updateFastgptEventLogTotalBatch" parameterType="java.util.List">
- <foreach collection="list" item="item" separator=";">
- UPDATE fastgpt_event_log_total
- <set>
- <if test="item.roleId != null">role_id = #{item.roleId},</if>
- <if test="item.count != null">`count` = #{item.count},</if>
- <if test="item.type != null">`type` = #{item.type},</if>
- <if test="item.companyId != null">company_id = #{item.companyId},</if>
- <if test="item.companyUserId != null">company_user_id = #{item.companyUserId},</if>
- <if test="item.qwUserId != null">qw_user_id = #{item.qwUserId},</if>
- <if test="item.statTime != null">stat_time = #{item.statTime},</if>
- </set>
- WHERE id = #{item.id}
- </foreach>
- </update>
- <delete id="deleteFastgptEventLogTotalById" parameterType="Long">
- delete from fastgpt_event_log_total where id = #{id}
- </delete>
- <delete id="deleteFastgptEventLogTotalByIds" parameterType="String">
- delete from fastgpt_event_log_total where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|