From 3acf9415fce2dd21c0fd5d67805b72a8bde24a81 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期一, 23 十一月 2026 17:12:00 +0800
Subject: [PATCH] 【丽水】妇幼随访发送

---
 smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml |  143 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 142 insertions(+), 1 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml b/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
index 1bac046..24082b1 100644
--- a/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/MchFollowupPlanItemMapper.xml
@@ -18,15 +18,53 @@
         <result property="retryCount" column="retry_count"/>
         <result property="nextRetryTime" column="next_retry_time"/>
         <result property="sendTimeActual" column="send_time_actual"/>
+        <result property="followupDate" column="followup_date"/>
+        <result property="followupUserId" column="followup_user_id"/>
+        <result property="followupUserName" column="followup_user_name"/>
+        <result property="followupSituation" column="followup_situation"/>
+        <result property="followupStatus" column="followup_status"/>
         <result property="resultMsg" column="result_msg"/>
         <result property="providerMsgId" column="provider_msg_id"/>
         <result property="createTime" column="create_time"/>
         <result property="updateTime" column="update_time"/>
     </resultMap>
 
+    <resultMap id="MchFollowupTaskResult" type="com.smartor.domain.MchFollowupTaskVO">
+        <result property="itemId" column="item_id"/>
+        <result property="planId" column="plan_id"/>
+        <result property="taskid" column="taskid"/>
+        <result property="taskType" column="task_type"/>
+        <result property="taskname" column="task_name"/>
+        <result property="archiveType" column="archive_type"/>
+        <result property="archiveTypeName" column="archive_type_name"/>
+        <result property="archiveId" column="archive_id"/>
+        <result property="archiveDetailId" column="archive_detail_id"/>
+        <result property="sourceType" column="source_type"/>
+        <result property="sourceBizNo" column="source_biz_no"/>
+        <result property="patid" column="patid"/>
+        <result property="patname" column="patname"/>
+        <result property="sendname" column="sendname"/>
+        <result property="phone" column="phone"/>
+        <result property="idcardno" column="idcardno"/>
+        <result property="seq" column="seq"/>
+        <result property="outpatientDate" column="outpatient_date"/>
+        <result property="plannedFollowTime" column="planned_follow_time"/>
+        <result property="plannedFollowDate" column="planned_follow_date"/>
+        <result property="followupDate" column="followup_date"/>
+        <result property="followupUserId" column="followup_user_id"/>
+        <result property="followupUserName" column="followup_user_name"/>
+        <result property="followupSituation" column="followup_situation"/>
+        <result property="followupStatus" column="followup_status"/>
+        <result property="sendStatus" column="send_status"/>
+        <result property="sendTimeActual" column="send_time_actual"/>
+        <result property="orgid" column="orgid"/>
+        <result property="campusid" column="campusid"/>
+    </resultMap>
+
     <sql id="selectItemVo">
         select id, plan_id, seq, send_type, send_time, title_name, content, template_id, url,
                send_status, retry_count, next_retry_time, send_time_actual,
+               followup_date, followup_user_id, followup_user_name, followup_situation, followup_status,
                result_msg, provider_msg_id, create_time, update_time
         from mch_followup_plan_item
     </sql>
@@ -36,10 +74,13 @@
         insert into mch_followup_plan_item
         (plan_id, seq, send_type, send_time, title_name, content, template_id, url,
          send_status, retry_count, next_retry_time, send_time_actual,
+         followup_date, followup_user_id, followup_user_name, followup_situation, followup_status,
          result_msg, provider_msg_id, create_time, update_time)
         values
         (#{planId}, #{seq}, #{sendType}, #{sendTime}, #{titleName}, #{content}, #{templateId}, #{url},
          #{sendStatus}, #{retryCount}, #{nextRetryTime}, #{sendTimeActual},
+         #{followupDate}, #{followupUserId}, #{followupUserName}, #{followupSituation},
+         COALESCE(#{followupStatus,jdbcType=CHAR}, '0'),
          #{resultMsg}, #{providerMsgId}, #{createTime}, #{updateTime})
     </insert>
 
@@ -56,6 +97,11 @@
             <if test="retryCount != null">retry_count = #{retryCount},</if>
             <if test="nextRetryTime != null">next_retry_time = #{nextRetryTime},</if>
             <if test="sendTimeActual != null">send_time_actual = #{sendTimeActual},</if>
+            <if test="followupDate != null">followup_date = #{followupDate},</if>
+            <if test="followupUserId != null">followup_user_id = #{followupUserId},</if>
+            <if test="followupUserName != null">followup_user_name = #{followupUserName},</if>
+            <if test="followupSituation != null">followup_situation = #{followupSituation},</if>
+            <if test="followupStatus != null">followup_status = #{followupStatus},</if>
             <if test="resultMsg != null">result_msg = #{resultMsg},</if>
             <if test="providerMsgId != null">provider_msg_id = #{providerMsgId},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
@@ -75,6 +121,17 @@
         where id = #{id}
     </update>
 
+    <update id="updateFollowupResult" parameterType="com.smartor.domain.MchFollowupPlanItem">
+        update mch_followup_plan_item
+        set followup_date = #{followupDate,jdbcType=TIMESTAMP},
+            followup_user_id = #{followupUserId,jdbcType=VARCHAR},
+            followup_user_name = #{followupUserName,jdbcType=VARCHAR},
+            followup_situation = #{followupSituation,jdbcType=VARCHAR},
+            followup_status = #{followupStatus,jdbcType=CHAR},
+            update_time = #{updateTime,jdbcType=TIMESTAMP}
+        where id = #{id}
+    </update>
+
     <select id="selectMchFollowupPlanItemById" resultMap="MchFollowupPlanItemResult">
         <include refid="selectItemVo"/>
         where id = #{id}
@@ -89,7 +146,9 @@
     <select id="selectDueItems" resultMap="MchFollowupPlanItemResult">
         select i.id, i.plan_id, i.seq, i.send_type, i.send_time, i.title_name, i.content,
                i.template_id, i.url, i.send_status, i.retry_count, i.next_retry_time,
-               i.send_time_actual, i.result_msg, i.provider_msg_id, i.create_time, i.update_time
+               i.send_time_actual, i.followup_date, i.followup_user_id, i.followup_user_name,
+               i.followup_situation, i.followup_status,
+               i.result_msg, i.provider_msg_id, i.create_time, i.update_time
         from mch_followup_plan_item i
         inner join mch_followup_plan p on p.id = i.plan_id
         where p.orgid = #{orgid}
@@ -125,4 +184,86 @@
           and send_status in ('0', '1')
     </select>
 
+    <select id="selectTaskList" parameterType="com.smartor.domain.MchFollowupTaskQuery"
+            resultMap="MchFollowupTaskResult">
+        select
+            i.id as item_id,
+            i.plan_id as plan_id,
+            cast(null as signed) as taskid,
+            'MCH' as task_type,
+            case
+                when p.archive_type = '1' and m.archive_type = '1' then '鏃╁瓡鍏崇埍闅忚'
+                when p.archive_type = '1' and m.archive_type = '2' then '鍥寸粷缁忔湡MHI闅忚'
+                when p.archive_type = '2' and c.archive_type = '1' then '钀ュ吇鎬х柧鐥呴殢璁�'
+                when p.archive_type = '2' and c.archive_type = '2' then '瀛︿範鍥伴毦闅忚'
+                when p.archive_type = '2' and c.archive_type = '3' then '楂樺嵄鍎夸笓妗堥殢璁�'
+                when p.archive_type = '1' then '濡囦繚闅忚'
+                when p.archive_type = '2' then '鍎夸繚闅忚'
+                else '濡囧辜闅忚'
+            end as task_name,
+            p.archive_type as archive_type,
+            case
+                when p.archive_type = '1' and m.archive_type = '1' then '鏃╁瓡鍏崇埍'
+                when p.archive_type = '1' and m.archive_type = '2' then '鍥寸粷缁忔湡MHI'
+                when p.archive_type = '2' and c.archive_type = '1' then '钀ュ吇鎬х柧鐥�'
+                when p.archive_type = '2' and c.archive_type = '2' then '瀛︿範鍥伴毦'
+                when p.archive_type = '2' and c.archive_type = '3' then '楂樺嵄鍎夸笓妗�'
+                when p.archive_type = '1' then '濡囦繚'
+                when p.archive_type = '2' then '鍎夸繚'
+                else '濡囧辜'
+            end as archive_type_name,
+            p.archive_id as archive_id,
+            p.archive_detail_id as archive_detail_id,
+            p.source_type as source_type,
+            p.source_biz_no as source_biz_no,
+            p.patid as patid,
+            p.patname as patname,
+            p.patname as sendname,
+            p.phone as phone,
+            p.idcardno as idcardno,
+            i.seq as seq,
+            o.admitdate as outpatient_date,
+            p.planned_follow_time as planned_follow_time,
+            i.send_time as planned_follow_date,
+            i.followup_date as followup_date,
+            i.followup_user_id as followup_user_id,
+            i.followup_user_name as followup_user_name,
+            i.followup_situation as followup_situation,
+            i.followup_status as followup_status,
+            i.send_status as send_status,
+            i.send_time_actual as send_time_actual,
+            p.orgid as orgid,
+            p.campusid as campusid
+        from mch_followup_plan_item i
+        inner join mch_followup_plan p on p.id = i.plan_id
+        left join pat_maternity_archive_detail m
+            on p.archive_type = '1' and m.id = p.archive_detail_id
+        left join pat_child_archive_detail c
+            on p.archive_type = '2' and c.id = p.archive_detail_id
+        left join pat_med_outhosp o
+            on p.source_type = '1'
+           and o.orgid = p.orgid
+           and o.outhospno = p.source_biz_no
+        where p.orgid = #{orgid}
+          and p.plan_status &lt;&gt; '1'
+          and i.send_status &lt;&gt; '5'
+          <if test="campusid != null and campusid != ''">and p.campusid = #{campusid}</if>
+          <if test="planId != null">and p.id = #{planId}</if>
+          <if test="itemId != null">and i.id = #{itemId}</if>
+          <if test="archiveType != null and archiveType != ''">and p.archive_type = #{archiveType}</if>
+          <if test="sourceType != null and sourceType != ''">and p.source_type = #{sourceType}</if>
+          <if test="sendStatus != null and sendStatus != ''">and i.send_status = #{sendStatus}</if>
+          <if test="followupStatus != null and followupStatus != ''">and i.followup_status = #{followupStatus}</if>
+          <if test="patid != null">and p.patid = #{patid}</if>
+          <if test="keyword != null and keyword != ''">
+              and (p.patname like concat('%', #{keyword}, '%')
+                   or p.phone like concat('%', #{keyword}, '%')
+                   or p.idcardno like concat('%', #{keyword}, '%')
+                   or p.source_biz_no like concat('%', #{keyword}, '%'))
+          </if>
+          <if test="beginDate != null">and i.send_time &gt;= #{beginDate}</if>
+          <if test="endDate != null">and i.send_time &lt;= #{endDate}</if>
+        order by i.send_time asc, i.seq asc, i.id asc
+    </select>
+
 </mapper>

--
Gitblit v1.9.3