|
|
@@ -1,9 +1,9 @@
|
|
|
<?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">
|
|
|
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.fs.his.mapper.FsSopDoctorTaskMapper">
|
|
|
-
|
|
|
+
|
|
|
<resultMap type="FsSopDoctorTask" id="FsSopDoctorTaskResult">
|
|
|
<result property="id" column="id" />
|
|
|
<result property="companyUserId" column="company_user_id" />
|
|
|
@@ -21,6 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<result property="doctorMemberSalesId" column="doctor_member_sales_id" />
|
|
|
<result property="handlePersonType" column="handle_person_type" />
|
|
|
<result property="version" column="version" />
|
|
|
+ <result property="taskType" column="task_type" />
|
|
|
</resultMap>
|
|
|
|
|
|
<resultMap type="com.fs.his.vo.SopDoctorTaskVo" id="SopDoctorTaskVoResult">
|
|
|
@@ -42,6 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<result property="sendDays" column="send_days" />
|
|
|
<result property="handlePersonType" column="handle_person_type" />
|
|
|
<result property="version" column="version" />
|
|
|
+ <result property="taskType" column="task_type" />
|
|
|
<!-- 关联表字段 -->
|
|
|
<result property="name" column="name" /> <!-- qwec.name -->
|
|
|
<result property="companyUserName" column="company_user_name" /> <!-- cp.nick_name -->
|
|
|
@@ -52,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectFsSopDoctorTaskVo">
|
|
|
- select id, company_user_id,doctor_id, user_id, status, create_time, update_time, remark, package_id, order_code, type,qw_external_contact_id,handle_type,doctor_member_sales_id,send_days,handle_person_type,version from fs_sop_doctor_task
|
|
|
+ select id, company_user_id, doctor_id, user_id, status, create_time, update_time, remark, package_id, order_code, type, qw_external_contact_id, handle_type, doctor_member_sales_id, send_days, handle_person_type, version, task_type from fs_sop_doctor_task
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectFsSopDoctorTaskVoList" parameterType="com.fs.his.dto.SopDoctorTaskDto" resultMap="SopDoctorTaskVoResult">
|
|
|
@@ -75,7 +77,64 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
sdt.handle_type,
|
|
|
sdt.send_days,
|
|
|
sdt.version,
|
|
|
- sdt.handle_person_type
|
|
|
+ sdt.handle_person_type,
|
|
|
+ sdt.task_type
|
|
|
+ FROM
|
|
|
+ fs_sop_doctor_task sdt
|
|
|
+ LEFT JOIN company_user cp ON sdt.company_user_id = cp.user_id
|
|
|
+ LEFT JOIN qw_external_contact qwec ON sdt.qw_external_contact_id = qwec.id
|
|
|
+ LEFT JOIN fs_user fu ON qwec.fs_user_id = fu.user_id
|
|
|
+ LEFT JOIN fs_doctor fd ON sdt.doctor_id = fd.doctor_id
|
|
|
+ <where>
|
|
|
+ <if test="id != null "> and sdt.id = #{id}</if>
|
|
|
+ <if test="doctorId != null "> and sdt.doctor_id = #{doctorId}</if>
|
|
|
+ <if test="userId != null "> and sdt.user_id = #{userId}</if>
|
|
|
+ <if test="packageId != null "> and sdt.package_id = #{packageId}</if>
|
|
|
+ <if test="orderCode != null "> and sdt.order_code = #{orderCode}</if>
|
|
|
+ <if test="companyUserId != null "> and sdt.company_user_id = #{companyUserId}</if>
|
|
|
+ <if test="status != null "> and sdt.status = #{status}</if>
|
|
|
+ <if test="handleType != null "> and sdt.handle_type = #{handleType}</if>
|
|
|
+ <if test="doctorMemberSalesId != null "> and sdt.doctor_member_sales_id = #{doctorMemberSalesId}</if>
|
|
|
+ <if test="type != null "> and sdt.type = #{type}</if>
|
|
|
+ <if test="version != null "> and sdt.version = #{version}</if>
|
|
|
+ <if test="handlePersonType != null "> and sdt.handle_person_type = #{handlePersonType}</if>
|
|
|
+ <if test="taskType != null "> and sdt.task_type = #{taskType}</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="companyUserName != null and companyUserName !='' "> and cp.nick_name like concat('%', #{companyUserName}, '%')</if>
|
|
|
+ <if test="doctorName != null and doctorName !='' "> and fd.doctor_name like concat('%', #{doctorName}, '%')</if>
|
|
|
+ <if test="beginTime != null and beginTime != ''">
|
|
|
+ and sdt.create_time >= str_to_date(#{beginTime}, '%Y-%m-%d %H:%i:%s')
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ and sdt.create_time <= str_to_date(#{endTime}, '%Y-%m-%d %H:%i:%s')
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ ORDER BY sdt.id DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectSopDoctorTaskVoProcessRecordList" parameterType="com.fs.his.dto.SopDoctorTaskDto" resultMap="SopDoctorTaskVoResult">
|
|
|
+ SELECT
|
|
|
+ sdt.id,
|
|
|
+ sdt.user_id,
|
|
|
+ qwec.name,
|
|
|
+ qwec.avatar,
|
|
|
+ fu.phone,
|
|
|
+ cp.nick_name as company_user_name,
|
|
|
+ cp.user_id as company_user_id,
|
|
|
+ sdt.status,
|
|
|
+ sdt.order_code,
|
|
|
+ sdt.create_time,
|
|
|
+ sdt.update_time,
|
|
|
+ sdt.remark,
|
|
|
+ sdt.type,
|
|
|
+ fd.doctor_name,
|
|
|
+ sdt.qw_external_contact_id,
|
|
|
+ sdt.handle_type,
|
|
|
+ sdt.send_days,
|
|
|
+ sdt.version,
|
|
|
+ sdt.handle_person_type,
|
|
|
+ sdt.task_type
|
|
|
FROM
|
|
|
fs_sop_doctor_task sdt
|
|
|
LEFT JOIN company_user cp ON sdt.company_user_id = cp.user_id
|
|
|
@@ -83,6 +142,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user fu ON qwec.fs_user_id = fu.user_id
|
|
|
LEFT JOIN fs_doctor fd ON sdt.doctor_id = fd.doctor_id
|
|
|
<where>
|
|
|
+ sdt.handle_type IN (1,2,3)
|
|
|
<if test="id != null "> and sdt.id = #{id}</if>
|
|
|
<if test="doctorId != null "> and sdt.doctor_id = #{doctorId}</if>
|
|
|
<if test="userId != null "> and sdt.user_id = #{userId}</if>
|
|
|
@@ -95,6 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="type != null "> and sdt.type = #{type}</if>
|
|
|
<if test="version != null "> and sdt.version = #{version}</if>
|
|
|
<if test="handlePersonType != null "> and sdt.handle_person_type = #{handlePersonType}</if>
|
|
|
+ <if test="taskType != null "> and sdt.task_type = #{taskType}</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="companyUserName != null and companyUserName !='' "> and cp.nick_name like concat('%', #{companyUserName}, '%')</if>
|
|
|
@@ -108,7 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</where>
|
|
|
ORDER BY sdt.id DESC
|
|
|
</select>
|
|
|
-
|
|
|
+
|
|
|
<select id="selectFsSopDoctorTaskVoById" parameterType="Long" resultMap="SopDoctorTaskVoResult">
|
|
|
SELECT
|
|
|
sdt.id,
|
|
|
@@ -129,7 +190,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
sdt.doctor_member_sales_id,
|
|
|
sdt.send_days,
|
|
|
sdt.version,
|
|
|
- sdt.handle_person_type
|
|
|
+ sdt.handle_person_type,
|
|
|
+ sdt.task_type
|
|
|
FROM
|
|
|
fs_sop_doctor_task sdt
|
|
|
LEFT JOIN company_user cp ON sdt.company_user_id = cp.user_id
|
|
|
@@ -137,7 +199,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user fu ON qwec.fs_user_id = fu.user_id
|
|
|
where sdt.id = #{id}
|
|
|
</select>
|
|
|
-
|
|
|
+
|
|
|
<insert id="insertFsSopDoctorTask" parameterType="FsSopDoctorTask" useGeneratedKeys="true" keyProperty="id">
|
|
|
insert into fs_sop_doctor_task
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
@@ -157,7 +219,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="sendDays != null">send_days,</if>
|
|
|
<if test="handlePersonType != null">handle_person_type,</if>
|
|
|
<if test="version != null">version,</if>
|
|
|
- </trim>
|
|
|
+ <if test="taskType != null">task_type,</if>
|
|
|
+ </trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="companyUserId != null">#{companyUserId},</if>
|
|
|
<if test="doctorId != null">#{doctorId},</if>
|
|
|
@@ -175,7 +238,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="sendDays != null">#{sendDays},</if>
|
|
|
<if test="handlePersonType != null">#{handlePersonType},</if>
|
|
|
<if test="version != null">#{version},</if>
|
|
|
- </trim>
|
|
|
+ <if test="taskType != null">#{taskType},</if>
|
|
|
+ </trim>
|
|
|
</insert>
|
|
|
|
|
|
<update id="updateFsSopDoctorTask" parameterType="FsSopDoctorTask">
|
|
|
@@ -195,6 +259,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="qwExternalContactId != null">qw_external_contact_id=#{qwExternalContactId},</if>
|
|
|
<if test="sendDays != null">send_days=#{sendDays},</if>
|
|
|
<if test="handlePersonType != null">handle_person_type=#{handlePersonType},</if>
|
|
|
+ <if test="taskType != null">task_type = #{taskType},</if>
|
|
|
version = version + 1,
|
|
|
</trim>
|
|
|
where id = #{id} AND version = #{version}
|
|
|
@@ -205,7 +270,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</delete>
|
|
|
|
|
|
<delete id="deleteFsSopDoctorTaskByIds" parameterType="String">
|
|
|
- delete from fs_sop_doctor_task where id in
|
|
|
+ delete from fs_sop_doctor_task where id in
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
#{id}
|
|
|
</foreach>
|
|
|
@@ -213,11 +278,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
<select id="selectFsSopDoctorTaskList" parameterType="FsSopDoctorTask" resultType="FsSopDoctorTask">
|
|
|
SELECT * FROM fs_sop_doctor_task
|
|
|
- WHERE doctor_member_sales_id = #{doctorMemberSalesId}
|
|
|
- <if test="status != null "> and status = #{status} </if>
|
|
|
+ <where>
|
|
|
+ <if test="doctorId != null">
|
|
|
+ AND doctor_id = #{doctorId}
|
|
|
+ </if>
|
|
|
+ <if test="companyUserId != null">
|
|
|
+ AND company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ <if test="doctorMemberSalesId != null">
|
|
|
+ AND doctor_member_sales_id = #{doctorMemberSalesId}
|
|
|
+ </if>
|
|
|
+ <if test="handlePersonType != null">
|
|
|
+ AND handle_person_type = #{handlePersonType}
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ AND status = #{status}
|
|
|
+ </if>
|
|
|
+ <if test="taskType != null">
|
|
|
+ AND task_type = #{taskType}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
ORDER BY id DESC
|
|
|
</select>
|
|
|
<select id="selectFsSopDoctorTaskById" resultType="com.fs.his.domain.FsSopDoctorTask">
|
|
|
SELECT * FROM fs_sop_doctor_task WHERE id = #{id}
|
|
|
</select>
|
|
|
+
|
|
|
+ <!-- 获取医生待处理的任务总数 -->
|
|
|
+ <select id="selectUnprocessedDoctorTaskCount" parameterType="Long" resultType="Long">
|
|
|
+ SELECT COUNT(*)
|
|
|
+ FROM fs_sop_doctor_task
|
|
|
+ WHERE doctor_member_sales_id = #{memberSalesId}
|
|
|
+ AND status = 0
|
|
|
+ AND handle_person_type = 1
|
|
|
+ AND (
|
|
|
+ task_type = 1
|
|
|
+ OR (task_type = 3 AND handle_person_type = 1)
|
|
|
+ )
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 获取销售待处理的任务总数 -->
|
|
|
+ <select id="selectUnprocessedSalesTaskCount" parameterType="Long" resultType="Long">
|
|
|
+ SELECT COUNT(*)
|
|
|
+ FROM fs_sop_doctor_task
|
|
|
+ WHERE doctor_member_sales_id = #{memberSalesId}
|
|
|
+ AND status = 0
|
|
|
+ AND handle_person_type = 2
|
|
|
+ AND (
|
|
|
+ task_type = 1
|
|
|
+ OR (task_type = 3 AND handle_person_type = 2)
|
|
|
+ )
|
|
|
+ </select>
|
|
|
</mapper>
|