|
@@ -0,0 +1,190 @@
|
|
|
|
|
+<?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="externalId" column="external_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" />
|
|
|
|
|
+ </resultMap>
|
|
|
|
|
+
|
|
|
|
|
+ <resultMap type="com.fs.qw.vo.SopCompanyUserTaskVo" id="SopCompanyUserTaskVoResult">
|
|
|
|
|
+ <!-- 主键可 -->
|
|
|
|
|
+ <result property="id" column="id" />
|
|
|
|
|
+ <!-- fs_sop_company_user_task 表字段 -->
|
|
|
|
|
+ <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="name" column="name" /> <!-- qwec.name -->
|
|
|
|
|
+ <result property="doctorName" column="doctor_name" /> <!-- fd.doctor_name -->
|
|
|
|
|
+ <result property="avatar" column="avatar" />
|
|
|
|
|
+ <result property="phone" column="phone" />
|
|
|
|
|
+ </resultMap>
|
|
|
|
|
+
|
|
|
|
|
+ <sql id="selectFsSopCompanyUserTaskVo">
|
|
|
|
|
+ select id, external_id, doctor_id, user_id, status, create_time, update_time, remark from fs_sop_company_user_task
|
|
|
|
|
+ </sql>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectFsSopCompanyUserTaskVoList" parameterType="com.fs.qw.dto.SopCompanyUserTaskDto" resultMap="SopCompanyUserTaskVoResult">
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ sct.id,
|
|
|
|
|
+ sct.user_id,
|
|
|
|
|
+ qwec.name,
|
|
|
|
|
+ qwec.avatar,
|
|
|
|
|
+ fu.phone,
|
|
|
|
|
+ sct.doctor_id,
|
|
|
|
|
+ fd.doctor_name,
|
|
|
|
|
+ sct.STATUS,
|
|
|
|
|
+ sct.create_time,
|
|
|
|
|
+ sct.update_time,
|
|
|
|
|
+ sct.external_id,
|
|
|
|
|
+ sct.remark
|
|
|
|
|
+ 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.user_id = qwec.id
|
|
|
|
|
+ LEFT JOIN fs_user fu ON qwec.fs_user_id = fu.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="status != null "> and sct.status = #{status}</if>
|
|
|
|
|
+ <if test="qwUserId != null "> and qwec.qw_user_id = #{qwUserId}</if>
|
|
|
|
|
+ <if test="name != null "> and qwec.name like concat('%', #{name}, '%')</if>
|
|
|
|
|
+ <if test="doctorName != null "> and fd.doctor_name like concat('%', #{doctorName}, '%')</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 id DESC
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectFsSopCompanyUserTaskVoById" parameterType="Long" resultMap="SopCompanyUserTaskVoResult">
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ sct.id,
|
|
|
|
|
+ sct.user_id,
|
|
|
|
|
+ qwec.name,
|
|
|
|
|
+ qwec.avatar,
|
|
|
|
|
+ fu.phone,
|
|
|
|
|
+ sct.doctor_id,
|
|
|
|
|
+ fd.doctor_name,
|
|
|
|
|
+ sct.STATUS,
|
|
|
|
|
+ sct.create_time,
|
|
|
|
|
+ sct.update_time,
|
|
|
|
|
+ sct.external_id,
|
|
|
|
|
+ sct.remark
|
|
|
|
|
+ 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.user_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="externalId != null">external_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>
|
|
|
|
|
+ </trim>
|
|
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
+ <if test="externalId != null">#{externalId},</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>
|
|
|
|
|
+ </trim>
|
|
|
|
|
+ </insert>
|
|
|
|
|
+
|
|
|
|
|
+ <update id="updateFsSopCompanyUserTask" parameterType="FsSopCompanyUserTask">
|
|
|
|
|
+ update fs_sop_company_user_task
|
|
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
+ <if test="externalId != null">external_id = #{externalId},</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>
|
|
|
|
|
+ </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>
|