123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- <?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.slibra.business.mapper.TCallRecordMapper">
- <resultMap type="TCallRecord" id="TCallRecordResult">
- <result property="id" column="id" />
- <result property="sessionId" column="session_id" />
- <result property="type" column="type" />
- <result property="userId" column="user_id" />
- <result property="userName" column="user_name" />
- <result property="serviceCategory" column="service_category" />
- <result property="timeBegin" column="time_begin" />
- <result property="timeEnd" column="time_end" />
- <result property="times" column="times" />
- <result property="category" column="category" />
- <result property="status" column="status" />
- <result property="phone" column="phone" />
- <result property="bussinessType" column="bussiness_type" />
- <result property="url" column="url" />
- <result property="remark" column="remark" />
- <result property="hasParsed" column="has_parsed" />
- <result property="parsedVoiceContent" column="parsed_voice_content" />
- <result property="delFlag" column="del_flag" />
- <result property="revision" column="revision" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="transferUserId" column="transfer_user_id" />
- <result property="transferUserName" column="transfer_user_name" />
- </resultMap>
- <sql id="selectTCallRecordVo">
- select id, session_id, type, user_id, user_name, service_category, time_begin, time_end, times, category, status, phone, bussiness_type, url, remark, has_parsed, parsed_voice_content, del_flag, revision, create_by, create_time, update_by, update_time, transfer_user_id, transfer_user_name from t_call_record
- </sql>
- <select id="selectTCallRecordById" parameterType="Long" resultMap="TCallRecordResult">
- <include refid="selectTCallRecordVo"/>
- where id = #{id} and del_flag = 0
- </select>
- <insert id="insertTCallRecord" parameterType="TCallRecord" useGeneratedKeys="true" keyProperty="id">
- insert into t_call_record
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="sessionId != null">session_id,</if>
- <if test="type != null">type,</if>
- <if test="userId != null">user_id,</if>
- <if test="userName != null">user_name,</if>
- <if test="serviceCategory != null">service_category,</if>
- <if test="timeBegin != null">time_begin,</if>
- <if test="timeEnd != null">time_end,</if>
- <if test="times != null">times,</if>
- <if test="category != null">category,</if>
- <if test="status != null">status,</if>
- <if test="phone != null">phone,</if>
- <if test="bussinessType != null">bussiness_type,</if>
- <if test="url != null">url,</if>
- <if test="remark != null">remark,</if>
- <if test="hasParsed != null">has_parsed,</if>
- <if test="parsedVoiceContent != null">parsed_voice_content,</if>
- <if test="delFlag != null">del_flag,</if>
- <if test="revision != null">revision,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="sessionId != null">#{sessionId},</if>
- <if test="type != null">#{type},</if>
- <if test="userId != null">#{userId},</if>
- <if test="userName != null">#{userName},</if>
- <if test="serviceCategory != null">#{serviceCategory},</if>
- <if test="timeBegin != null">#{timeBegin},</if>
- <if test="timeEnd != null">#{timeEnd},</if>
- <if test="times != null">#{times},</if>
- <if test="category != null">#{category},</if>
- <if test="status != null">#{status},</if>
- <if test="phone != null">#{phone},</if>
- <if test="bussinessType != null">#{bussinessType},</if>
- <if test="url != null">#{url},</if>
- <if test="remark != null">#{remark},</if>
- <if test="hasParsed != null">#{hasParsed},</if>
- <if test="parsedVoiceContent != null">#{parsedVoiceContent},</if>
- <if test="delFlag != null">#{delFlag},</if>
- <if test="revision != null">#{revision},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- </trim>
- </insert>
- <update id="updateTCallRecord" parameterType="TCallRecord">
- update t_call_record
- <trim prefix="SET" suffixOverrides=",">
- <if test="sessionId != null">session_id = #{sessionId},</if>
- <if test="type != null">type = #{type},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="userName != null">user_name = #{userName},</if>
- <if test="serviceCategory != null">service_category = #{serviceCategory},</if>
- <if test="timeBegin != null">time_begin = #{timeBegin},</if>
- <if test="timeEnd != null">time_end = #{timeEnd},</if>
- <if test="times != null">times = #{times},</if>
- <if test="category != null">category = #{category},</if>
- <if test="status != null">status = #{status},</if>
- <if test="phone != null">phone = #{phone},</if>
- <if test="bussinessType != null">bussiness_type = #{bussinessType},</if>
- <if test="url != null">url = #{url},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="hasParsed != null">has_parsed = #{hasParsed},</if>
- <if test="parsedVoiceContent != null">parsed_voice_content = #{parsedVoiceContent},</if>
- <if test="delFlag != null">del_flag = #{delFlag},</if>
- <if test="revision != null">revision = #{revision},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- </trim>
- ,revision = revision + 1
- where id = #{id}
- </update>
- <delete id="deleteTCallRecordById" parameterType="Long">
- update t_call_record set del_flag = 2,revision = revision + 1 where del_flag = 0 and id = #{id}
- </delete>
- <delete id="deleteTCallRecordByIds" parameterType="String">
- update t_call_record set del_flag = 2,revision = revision + 1 where del_flag = 0 and id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <!-- 2024年11月12日09:51:10 下面是新增或者调整的,不允许覆盖 -->
- <select id="selectTCallRecordList" parameterType="TCallRecord" resultMap="TCallRecordResult">
- <include refid="selectTCallRecordVo"/>
- <where>
- 1 = 1
- <if test="sessionId != null and sessionId != ''"> and session_id = #{sessionId}</if>
- <if test="type != null "> and type = #{type}</if>
- <if test="userId != null "> and (user_id = #{userId} or transfer_user_id = #{userId})</if>
- <if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
- <if test="serviceCategory != null "> and service_category = #{serviceCategory}</if>
- <if test="timeBegin != null "> and time_begin >= #{timeBegin}</if>
- <if test="timeEnd != null "> and time_end <= #{timeEnd}</if>
- <if test="times != null and times != ''"> and times = #{times}</if>
- <if test="category != null "> and category = #{category}</if>
- <if test="status != null "> and status = #{status}</if>
- <if test="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
- <if test="bussinessType != null and bussinessType != ''"> and bussiness_type = #{bussinessType}</if>
- <if test="hasParsed != null "> and has_parsed = #{hasParsed}</if>
- <if test="parsedVoiceContent != null and parsedVoiceContent != ''"> and parsed_voice_content = #{parsedVoiceContent}</if>
- <if test="revision != null "> and revision = #{revision}</if>
- <if test="timeBeginReq != null and timeBeginReq != ''"> and DATE_FORMAT(time_begin, '%Y-%m-%d') >= #{timeBeginReq}</if>
- <if test="timeEndReq != null and timeEndReq != ''"> and DATE_FORMAT(time_begin, '%Y-%m-%d') <= #{timeEndReq}</if>
- </where>
- and del_flag = 0 order by id desc
- </select>
- <select id="getBusinessTypeBySessionId" resultType="string">
- SELECT
- intent
- FROM
- botrecords
- WHERE
- `session` = #{sessionId}
- LIMIT 1
- </select>
- <select id="getContentsBySessionId" resultType="string">
- SELECT
- contents
- FROM
- botrecords
- WHERE
- `session` = #{sessionId}
- LIMIT 1
- </select>
- <select id="getAgentList" resultType="com.slibra.business.res.UserTypeResp">
- <!-- SELECT DISTINCT
- user_id id,
- user_name `name`
- FROM
- t_call_record
- WHERE user_id is not null -->
- <!-- SELECT DISTINCT
- user_id id,
- user_name `name`,
- CASE
- service_category
- WHEN 0 THEN
- 0 ELSE 1
- END serviceCategory
- FROM
- t_call_record
- WHERE
- user_id IS NOT NULL -->
- SELECT
- user_id id,
- user_name `name`,
- type
- FROM
- t_zuoxi_record
- WHERE
- del_flag = 0
- </select>
- <select id="getCallCountsByPhone" resultType="int">
- SELECT
- COUNT(*)
- FROM
- t_call_record
- WHERE
- phone = #{phone}
- </select>
- <select id="selectHistoriesByPhone" resultMap="TCallRecordResult">
- <include refid="selectTCallRecordVo"/>
- where phone = #{phone} and del_flag = 0 and id != #{id}
- </select>
- <select id="getTotalByType" resultType="int">
- SELECT
- COUNT(*)
- FROM
- t_call_record
- WHERE
- 1 = 1 AND del_flag = 0
- <if test="type != null "> and type = #{type}</if>
- </select>
- <select id="getTotalByIsAi" resultType="int">
- SELECT
- COUNT(*)
- FROM
- t_call_record
- WHERE
- 1 = 1 and type = 1 AND del_flag = 0
- <if test="businessType == 1 "> and (bussiness_type != '不体验AI服务' or bussiness_type is NULL or bussiness_type = '') and category = 0</if>
- <if test="businessType == 0 "> and bussiness_type = '不体验AI服务' and category = 0</if>
- <if test="businessType == 2 "> and category = 1</if>
- </select>
- <select id="getSpecialCount" resultType="int">
- SELECT
- COUNT(*)
- FROM
- t_call_record
- WHERE
- 1 = 1 and phone = '12345' AND del_flag = 0
- </select>
- <select id="getTransferCount" resultType="int">
- SELECT
- COUNT(*)
- FROM
- t_call_record
- WHERE
- 1 = 1 and service_category = 2 AND del_flag = 0
- <if test="userId != null "> and user_id = #{userId} </if>
- <if test="date != null "> and DATE_FORMAT(create_time, '%Y-%m-%d') = #{date} </if>
- </select>
- <select id="getPersonCountByState" resultType="int">
- SELECT
- COUNT(*)
- FROM
- c_agent_monitor
- WHERE
- 1 = 1
- and check_state = 0
- <if test="state != null "> and service_state = #{state}</if>
- </select>
- <select id="getPersonCountRecordIsRobot" resultType="int">
- SELECT
- COUNT(*)
- FROM
- t_call_record
- WHERE
- 1 = 1
- AND del_flag = 0
- <if test="type == 0 "> and service_category = 0</if>
- <if test="type == 1 "> and service_category != 0 </if>
- </select>
- <select id="getPersonCountByType" resultType="int">
- SELECT
- COUNT(*)
- FROM
- t_call_record
- WHERE
- 1 = 1
- AND del_flag = 0
- and service_category = 0
- <if test="type == 0 "> and (user_id is null or user_id = '') </if>
- <if test="type == 1 "> and user_id is not null and user_id != ''</if>
- </select>
- <select id="getPersonTotalRecordIsRobot" resultType="long">
- SELECT
- IFNULL(SUM(times),0)
- FROM
- t_call_record
- WHERE
- 1 = 1
- AND del_flag = 0
- <if test="type == 0 "> and service_category = 0</if>
- <if test="type == 1 "> and service_category != 0 </if>
- <if test="userId != null "> and user_id = #{userId} </if>
- </select>
- <select id="selectAllUsersByType" resultType="com.slibra.business.res.CallUserCountInfo">
- SELECT DISTINCT
- user_id userId,
- user_name userName
- FROM
- t_call_record
- WHERE
- 1 = 1
- AND del_flag = 0
- AND user_id IS NOT NULL
- AND user_id != ''
- <if test="type == 0 "> and service_category = 0</if>
- <if test="type == 1 "> and service_category != 0 </if>
- </select>
- <select id="selectAllPersonUserIds" resultType="com.slibra.business.res.CallUserCountInfo">
- SELECT DISTINCT
- user_id userId
- FROM
- t_call_record
- WHERE
- 1 = 1
- AND del_flag = 0
- AND user_id IS NOT NULL
- AND user_id != ''
- and service_category = 0
- </select>
- <select id="getStatusByUserId" resultType="java.lang.Integer">
- SELECT
- service_state
- FROM
- c_agent_monitor
- WHERE
- out_id = (
- SELECT
- out_id
- FROM
- c_agent
- WHERE
- user_id = #{userId} AND is_delete = 0 LIMIT 1)
- </select>
- <select id="getCountByTypeAndDate" resultType="int">
- SELECT
- COUNT(*)
- FROM
- t_call_record
- WHERE
- 1 = 1
- AND del_flag = 0
- AND category = #{category}
- AND user_id = #{userId}
- <if test="date != null "> and DATE_FORMAT(create_time, '%Y-%m-%d') = #{date} </if>
- </select>
- </mapper>
|