| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <?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.qw.mapper.FsSopCompanyUserTaskMapper">
-
- <resultMap type="FsSopCompanyUserTask" id="FsSopCompanyUserTaskResult">
- <result property="id" column="id" />
- <result property="packageId" column="package_id" />
- <result property="orderCode" column="order_code" />
- <result property="companyUserId" column="company_user_id" />
- <result property="doctorId" column="doctor_id" />
- <result property="userId" column="user_id" />
- <result property="status" column="status" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- <result property="remark" column="remark" />
- <result property="type" column="type" />
- <result property="qwExternalContactId" column="qw_external_contact_id" />
- </resultMap>
- <resultMap type="com.fs.qw.vo.SopCompanyUserTaskVo" id="SopCompanyUserTaskVoResult">
- <!-- 主键可 -->
- <result property="id" column="id" />
- <!-- fs_sop_company_user_task 表字段 -->
- <result property="packageId" column="package_id" />
- <result property="orderCode" column="order_code" />
- <result property="companyUserId" column="company_user_id" />
- <result property="doctorId" column="doctor_id" />
- <result property="userId" column="user_id" />
- <result property="status" column="status" />
- <result property="remark" column="remark" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- <result property="type" column="type" />
- <result property="qwExternalContactId" column="qw_external_contact_id" />
- <!-- 关联表字段 -->
- <result property="name" column="name" /> <!-- qwec.name -->
- <result property="doctorName" column="doctor_name" /> <!-- fd.doctor_name -->
- <result property="avatar" column="avatar" />
- <result property="phone" column="phone" />
- <result property="packageName" column="package_name" />
- <result property="companyUserName" column="nick_name" />
- </resultMap>
- <sql id="selectFsSopCompanyUserTaskVo">
- select id, package_id,order_code,company_user_id, doctor_id, user_id, status, create_time, update_time, remark,type,qw_external_contact_id from fs_sop_company_user_task
- </sql>
- <select id="selectFsSopCompanyUserTaskVoList" parameterType="com.fs.qw.dto.SopCompanyUserTaskDto" resultMap="SopCompanyUserTaskVoResult">
- SELECT
- sct.id,
- sct.user_id,
- sct.package_id,
- sct.order_code,
- sct.company_user_id,
- qwec.name,
- qwec.avatar,
- fu.phone,
- sct.doctor_id,
- fd.doctor_name,
- sct.STATUS,
- sct.create_time,
- sct.update_time,
- sct.remark,
- sct.type,
- cu.nick_name,
- sct.qw_external_contact_id
- FROM
- fs_sop_company_user_task sct
- LEFT JOIN fs_doctor fd ON sct.doctor_id = fd.doctor_id
- LEFT JOIN qw_external_contact qwec ON sct.qw_external_contact_id = qwec.id
- LEFT JOIN fs_user fu ON qwec.fs_user_id = fu.user_id
- LEFT JOIN company_user cu ON cu.user_id = sct.company_user_id
- <where>
- <if test="id != null "> and sct.id = #{id}</if>
- <if test="doctorId != null "> and sct.doctor_id = #{doctorId}</if>
- <if test="userId != null "> and sct.user_id = #{userId}</if>
- <if test="packageId != null "> and sct.package_id = #{packageId}</if>
- <if test="orderCode != null "> and sct.order_code = #{orderCode}</if>
- <if test="type != null "> and sct.type = #{type}</if>
- <if test="companyUserId != null "> and sct.company_user_id = #{companyUserId}</if>
- <if test="status != null "> and sct.status = #{status}</if>
- <if test="qwUserId != null "> and qwec.qw_user_id = #{qwUserId}</if>
- <if test="name != null and name !='' "> and qwec.name like concat('%', #{name}, '%')</if>
- <if test="doctorName != null and doctorName != ''"> and fd.doctor_name like concat('%', #{doctorName}, '%')</if>
- <if test="companyUserName != null and companyUserName !=''"> and cu.nick_name like concat('%', #{companyUserName}, '%')</if>
- <if test="beginTime != null and beginTime != ''">
- and sct.create_time >= str_to_date(#{beginTime}, '%Y-%m-%d %H:%i:%s')
- </if>
- <if test="endTime != null and endTime != ''">
- and sct.create_time <= str_to_date(#{endTime}, '%Y-%m-%d %H:%i:%s')
- </if>
- </where>
- ORDER BY sct.id DESC
- </select>
-
- <select id="selectFsSopCompanyUserTaskVoById" parameterType="Long" resultMap="SopCompanyUserTaskVoResult">
- SELECT
- sct.id,
- sct.user_id,
- sct.package_id,
- sct.order_code,
- sct.company_user_id,
- qwec.name,
- qwec.avatar,
- fu.phone,
- sct.doctor_id,
- fd.doctor_name,
- sct.STATUS,
- sct.create_time,
- sct.update_time,
- sct.remark,
- sct.type,
- sct.qw_external_contact_id
- FROM
- fs_sop_company_user_task sct
- LEFT JOIN fs_doctor fd ON sct.doctor_id = fd.doctor_id
- LEFT JOIN qw_external_contact qwec ON sct.qw_external_contact_id = qwec.id
- LEFT JOIN fs_user fu ON qwec.fs_user_id = fu.user_id
- where sct.id = #{id}
- </select>
- <!-- 统计指定时间段内已处理/待处理数量 -->
- <select id="selectAllTimeRangeStats" resultType="map">
- SELECT
- -- 今日
- SUM(CASE WHEN DATE(create_time) = CURDATE() AND status = 1 THEN 1 ELSE 0 END) AS day_processed,
- SUM(CASE WHEN DATE(create_time) = CURDATE() AND status = 0 THEN 1 ELSE 0 END) AS day_pending,
- -- 本周(周一到今天)
- SUM(CASE
- WHEN create_time >= DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY)
- AND create_time < CURDATE() + INTERVAL 1 DAY
- AND status = 1
- THEN 1 ELSE 0 END) AS week_processed,
- SUM(CASE
- WHEN create_time >= DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY)
- AND create_time < CURDATE() + INTERVAL 1 DAY
- AND status = 0
- THEN 1 ELSE 0 END) AS week_pending,
- -- 本月
- SUM(CASE WHEN YEAR(create_time) = YEAR(CURDATE())
- AND MONTH(create_time) = MONTH(CURDATE())
- AND status = 1
- THEN 1 ELSE 0 END) AS month_processed,
- SUM(CASE WHEN YEAR(create_time) = YEAR(CURDATE())
- AND MONTH(create_time) = MONTH(CURDATE())
- AND status = 0
- THEN 1 ELSE 0 END) AS month_pending
- FROM fs_sop_company_user_task
- WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <!-- 只查最近1个月数据,减少扫描量 -->
- </select>
- <!-- 最近7天每日任务量(含今天) -->
- <select id="getTaskCountLast7Days" resultType="map">
- SELECT
- DATE_FORMAT(create_time, '%m-%d') AS date,
- COUNT(*) AS total
- FROM fs_sop_company_user_task
- WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
- AND create_time < CURDATE() + INTERVAL 1 DAY
- GROUP BY DATE(create_time)
- ORDER BY DATE(create_time) ASC
- </select>
- <insert id="insertFsSopCompanyUserTask" parameterType="FsSopCompanyUserTask" useGeneratedKeys="true" keyProperty="id">
- insert into fs_sop_company_user_task
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="packageId != null">package_id,</if>
- <if test="orderCode != null">order_code,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="doctorId != null">doctor_id,</if>
- <if test="userId != null">user_id,</if>
- <if test="status != null">status,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="remark != null">remark,</if>
- <if test="type != null">type,</if>
- <if test="qwExternalContactId != null">qw_external_contact_id,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="packageId != null">#{packageId},</if>
- <if test="orderCode != null">#{orderCode},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="doctorId != null">#{doctorId},</if>
- <if test="userId != null">#{userId},</if>
- <if test="status != null">#{status},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="remark != null">#{remark},</if>
- <if test="type != null">#{type},</if>
- <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
- </trim>
- </insert>
- <update id="updateFsSopCompanyUserTask" parameterType="FsSopCompanyUserTask">
- update fs_sop_company_user_task
- <trim prefix="SET" suffixOverrides=",">
- <if test="packageId != null">package_id = #{packageId},</if>
- <if test="orderCode != null">order_code = #{orderCode},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="doctorId != null">doctor_id = #{doctorId},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="status != null">status = #{status},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="type != null">type = #{type},</if>
- <if test="qwExternalContactId != null">qw_external_contact_id=#{qwExternalContactId},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteFsSopCompanyUserTaskById" parameterType="Long">
- delete from fs_sop_company_user_task where id = #{id}
- </delete>
- <delete id="deleteFsSopCompanyUserTaskByIds" parameterType="String">
- delete from fs_sop_company_user_task where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|