| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- <?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.qingjian.module.call.mapper.CallRecordMapper">
- <!-- 定义结果映射:表字段 → 实体类属性(假设实体类属性与表字段名一致) -->
- <resultMap id="CallRecordResultMap" type="com.qingjian.common.model.call.entity.CallRecord">
- <id column="id" property="id"/>
- <result column="fileId" property="fileId"/>
- <result column="sheetId" property="sheetId"/>
- <result column="personName" property="personName"/>
- <result column="personPhone" property="personPhone"/>
- <result column="personPhoneArea" property="personPhoneArea"/>
- <result column="personCertNo" property="personCertNo"/>
- <result column="personRegionId" property="personRegionId"/>
- <result column="personCellId" property="personCellId"/>
- <result column="personStationName" property="personStationName"/>
- <result column="personStationLongitude" property="personStationLongitude"/>
- <result column="personStationLatitude" property="personStationLatitude"/>
- <result column="callDateTime" property="callDateTime"/>
- <result column="duration" property="duration"/>
- <result column="callDirection" property="callDirection"/>
- <result column="callType" property="callType"/>
- <result column="otherName" property="otherName"/>
- <result column="otherPhone" property="otherPhone"/>
- <result column="otherPhoneArea" property="otherPhoneArea"/>
- <result column="otherCertNo" property="otherCertNo"/>
- <result column="remark" property="remark"/>
- <result column="operatorId" property="operatorId"/>
- <result column="callLocal" property="callLocal"/>
- </resultMap>
- <!-- 全字段动态条件查询:所有字段均可作为查询条件,空值自动忽略 -->
- <select id="selectCallRecordPage" resultMap="CallRecordResultMap">
- SELECT
- id,
- fileId,
- sheetId,
- personName,
- personPhone,
- personPhoneArea,
- personCertNo,
- personRegionId,
- personCellId,
- personStationName,
- personStationLongitude,
- personStationLatitude,
- callDateTime,
- duration,
- callDirection,
- callType,
- otherName,
- otherPhone,
- otherPhoneArea,
- otherCertNo,
- remark,
- operatorId,
- callLocal
- FROM ${query.tableName}
- <where>
- <if test="query.ids != null and query.ids.size>0">
- AND id in
- <foreach item="id" collection="query.ids" separator="," open="(" close=")">
- #{id}
- </foreach>
- </if>
- <if test="query.id != null">
- AND id = #{query.id}
- </if>
- <if test="query.fileId != null">
- AND fileId = #{query.fileId}
- </if>
- <if test="query.sheetId != null">
- AND sheetId = #{query.sheetId}
- </if>
- <if test="query.personName != null and query.personName != ''">
- AND personName = #{query.personName}
- </if>
- <if test="query.personPhones != null and query.personPhones.size>0">
- AND personPhone in
- <foreach item="phone" collection="query.personPhones" separator="," open="(" close=")">
- #{phone}
- </foreach>
- </if>
- <if test="query.personPhoneArea != null and query.personPhoneArea != ''">
- AND personPhoneArea = #{query.personPhoneArea}
- </if>
- <if test="query.personCertNo != null and query.personCertNo != ''">
- AND personCertNo = #{query.personCertNo}
- </if>
- <if test="query.personRegionId != null and query.personRegionId != ''">
- AND personRegionId = #{query.personRegionId}
- </if>
- <if test="query.personCellId != null and query.personCellId != ''">
- AND personCellId = #{query.personCellId}
- </if>
- <if test="query.startDate != null">
- AND callDate >= #{query.startDate}
- </if>
- <if test="query.endDate != null">
- AND callDate <= #{query.endDate}
- </if>
- <if test="query.startTime != null">
- AND (
- (#{query.startTime} < #{query.endTime} AND callTime BETWEEN #{query.startTime} AND
- #{query.endTime})
- OR
- (#{query.startTime} > #{query.endTime} AND (callTime >= #{query.startTime} OR callTime
- < #{query.endTime}))
- )
- </if>
- <choose>
- <when test="query.symbol != 'ge'">
- <if test="query.duration != null">
- AND duration >= #{query.duration}
- </if>
- </when>
- <otherwise>
- <if test="query.duration != null">
- AND duration <= #{query.duration}
- </if>
- </otherwise>
- </choose>
- <if test="query.callDirection != null and query.callDirection != ''">
- AND callDirection = #{query.callDirection}
- </if>
- <if test="query.callType != null and query.callType != ''">
- AND callType = #{query.callType}
- </if>
- <if test="query.otherName != null and query.otherName != ''">
- <choose>
- <when test="query.otherName == '未知对手'">
- and otherName IS NULL
- </when>
- <otherwise>
- and otherName = #{query.otherName}
- </otherwise>
- </choose>
- </if>
- <if test="query.otherPhones != null and query.otherPhones.size>0">
- AND otherPhone in
- <foreach item="phone" collection="query.otherPhones" separator="," open="(" close=")">
- #{phone}
- </foreach>
- </if>
- <if test="query.operatorId != null and query.operatorId != ''">
- AND operatorId LIKE CONCAT('%', #{query.operatorId}, '%')
- </if>
- </where>
- <if test="query.orderKey != null and query.orderKey != ''">
- order by ${query.orderKey} ${query.sort}
- </if>
- </select>
- <select id="statCall" resultType="com.qingjian.common.model.person.dto.CallDataProfileStatDTO">
- SELECT
- COUNT(*) AS callCount,
- COUNT(distinct otherPhone) as otherCount,
- COUNT() FILTER (callDirection = '主叫') AS outCount,
- COUNT() FILTER (callDirection = '被叫') AS inCount,
- MIN(callDate) AS callDateStart,
- MAX(callDate) AS callDateEnd
- FROM ${tableName}
- WHERE personName = #{personName}
- </select>
- <select id="callOftenTop10" resultType="com.qingjian.common.model.person.dto.CallOftenTop10DTO">
- SELECT COALESCE(otherPhone, '未知卡号') as otherPhone,
- COUNT(*) AS callCount
- FROM ${query.tableName}
- WHERE personName = #{query.personName}
- <if test="query.startDate != null">
- and callDate >= #{query.startDate}
- </if>
- <if test="query.endDate != null">
- and callDate <= #{query.endDate}
- </if>
- GROUP BY COALESCE(otherPhone, '未知卡号')
- ORDER BY callCount, otherPhone DESC
- </select>
- <select id="callStatStation" resultType="com.qingjian.common.model.person.dto.CallStatStationDTO">
- SELECT count(*) as callCount,
- personRegionId,
- personCellId,
- any_value(personStationName) as personStationName,
- any_value(personStationLongitude) as personStationLongitude,
- any_value(personStationLatitude) as personStationLatitude
- FROM ${tableName}
- WHERE personName = #{personName}
- GROUP BY personRegionId, personCellId
- ORDER BY callCount DESC
- LIMIT ${limit}
- </select>
- <select id="getCallRecordSummary" resultType="com.qingjian.common.model.person.dto.CallRecordSummaryDTO">
- select personPhone,
- otherName,
- otherPhone,
- count(*) as callCount,
- from ${query.tableName}
- where personName = #{query.personName}
- <if test="query.otherName != null and query.otherName != ''">
- <choose>
- <when test="query.otherName == '未知对手'">
- and otherName IS NULL
- </when>
- <otherwise>
- and otherName = #{query.otherName}
- </otherwise>
- </choose>
- </if>
- <if test="query.otherPhone != null">
- and otherPhone = #{query.otherPhone}
- </if>
- <if test="query.startDate != null">
- AND callDate >= #{query.startDate}
- </if>
- <if test="query.endDate != null">
- AND callDate <= #{query.endDate}
- </if>
- group by personPhone, otherName, otherPhone
- <choose>
- <when test="query.orderKey != null and query.orderKey != ''">
- order by ${query.orderKey} ${query.sort}
- </when>
- <otherwise>
- order by callCount desc
- </otherwise>
- </choose>
- </select>
- <select id="callGraphDetail" resultType="com.qingjian.common.model.call.entity.CallRecord">
- select * from (
- select *
- from ${query.tableName}
- where
- callDirection = '主叫'
- <if test="query.personPhone!=null">
- and personPhone = #{query.personPhone}
- </if>
- <if test="query.otherPhone!=null">
- and otherPhone = #{query.otherPhone}
- </if>
- union all
- select *
- from ${query.tableName}
- where
- callDirection != '主叫'
- <if test="query.personPhone!=null">
- and personPhone = #{query.otherPhone}
- </if>
- <if test="query.otherPhone!=null">
- and otherPhone = #{query.personPhone}
- </if>
- ) as temmp_msg_data
- <where>
- <if test="query.startDate != null">
- AND callDate >= #{query.startDate}
- </if>
- <if test="query.endDate != null">
- AND callDate <= #{query.endDate}
- </if>
- </where>
- <if test="query.orderKey != null and query.orderKey != ''">
- order by ${query.orderKey} ${query.sort}
- </if>
- </select>
- </mapper>
|