From 67d0eef6ef56713345e03afdfd7e5badf4d4ad3d Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 24 十一月 2026 14:13:11 +0800
Subject: [PATCH] fix: 补提交妇幼随访 service_subtask 方案核心文件

---
 smartor/src/main/resources/mapper/smartor/MchFollowupSubtaskMapper.xml |  155 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 155 insertions(+), 0 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/MchFollowupSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/MchFollowupSubtaskMapper.xml
new file mode 100644
index 0000000..ab6e186
--- /dev/null
+++ b/smartor/src/main/resources/mapper/smartor/MchFollowupSubtaskMapper.xml
@@ -0,0 +1,155 @@
+<?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.smartor.mapper.MchFollowupSubtaskMapper">
+
+    <resultMap id="MchSubtaskResult" type="com.ruoyi.task.domain.ServiceSubtask">
+        <id property="id" column="id"/>
+        <result property="taskid" column="taskid"/>
+        <result property="taskName" column="task_name"/>
+        <result property="taskDesc" column="task_desc"/>
+        <result property="sendname" column="sendname"/>
+        <result property="patid" column="patid"/>
+        <result property="phone" column="phone"/>
+        <result property="sfzh" column="sfzh"/>
+        <result property="hospno" column="hospno"/>
+        <result property="visitTime" column="visit_time"/>
+        <result property="sendstate" column="sendstate"/>
+        <result property="orgid" column="orgid"/>
+        <result property="campusid" column="campusid"/>
+        <result property="serviceType" column="service_type"/>
+        <result property="type" column="type"/>
+        <result property="currentPreachform" column="current_preachform"/>
+        <result property="templateid" column="templateid"/>
+        <result property="templatename" column="templatename"/>
+        <result property="isVisitAgain" column="is_visit_again"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="mchArchiveDetailId" column="mch_archive_detail_id"/>
+        <result property="mchNodeSeq" column="mch_node_seq"/>
+        <result property="mchPlanHash" column="mch_plan_hash"/>
+        <result property="mchNodeJson" column="mch_node_json"/>
+    </resultMap>
+
+    <select id="selectCandidates" resultType="com.smartor.domain.MchFollowupArchiveCandidate">
+        select '1' as archiveType, d.archiveid as archiveId, d.id as archiveDetailId
+        from pat_maternity_archive_detail d
+        where d.orgid = #{orgid}
+          and (d.del_flag is null or d.del_flag = '0')
+          and d.followup_status = '1'
+          and d.planned_follow_time is not null
+          and d.followup_period is not null
+          and d.followup_period &lt;&gt; ''
+          and d.archiveid is not null
+          and (d.mch_next_due_time is null or d.mch_next_due_time &lt;= #{dueBefore})
+        union all
+        select '2' as archiveType, d.archiveid as archiveId, d.id as archiveDetailId
+        from pat_child_archive_detail d
+        where d.orgid = #{orgid}
+          and (d.del_flag is null or d.del_flag = '0')
+          and d.followup_status = '1'
+          and d.planned_follow_time is not null
+          and d.followup_period is not null
+          and d.followup_period &lt;&gt; ''
+          and d.archiveid is not null
+          and (d.mch_next_due_time is null or d.mch_next_due_time &lt;= #{dueBefore})
+        limit #{limit}
+    </select>
+
+    <select id="selectMchCursor" resultType="com.smartor.domain.MchFollowupArchiveCursor">
+        <choose>
+            <when test='archiveType == "1"'>
+                select mch_plan_hash as planHash, mch_next_due_time as nextDueTime
+                from pat_maternity_archive_detail
+                where id = #{detailId}
+            </when>
+            <otherwise>
+                select mch_plan_hash as planHash, mch_next_due_time as nextDueTime
+                from pat_child_archive_detail
+                where id = #{detailId}
+            </otherwise>
+        </choose>
+    </select>
+
+    <update id="updateMchCursor">
+        <choose>
+            <when test='archiveType == "1"'>
+                update pat_maternity_archive_detail
+                set mch_plan_hash = #{planHash},
+                    mch_next_due_time = #{nextDueTime}
+                where id = #{detailId}
+            </when>
+            <otherwise>
+                update pat_child_archive_detail
+                set mch_plan_hash = #{planHash},
+                    mch_next_due_time = #{nextDueTime}
+                where id = #{detailId}
+            </otherwise>
+        </choose>
+    </update>
+
+    <select id="selectByArchiveDetailId" resultMap="MchSubtaskResult">
+        select id, taskid, task_name, task_desc, sendname, patid, phone, sfzh, hospno,
+               visit_time, sendstate, orgid, campusid, service_type, type,
+               current_preachform, templateid, templatename, is_visit_again, del_flag,
+               mch_archive_detail_id, mch_node_seq, mch_plan_hash, mch_node_json
+        from service_subtask
+        where mch_archive_detail_id = #{detailId}
+          and (del_flag is null or del_flag = '0')
+        order by mch_node_seq asc, id asc
+    </select>
+
+    <insert id="insertMchSubtask" parameterType="com.ruoyi.task.domain.ServiceSubtask"
+            useGeneratedKeys="true" keyProperty="id">
+        insert into service_subtask
+        (taskid, task_name, task_desc, sendname, patid, phone, sfzh, hospno,
+         visit_time, sendstate, orgid, campusid, service_type, type,
+         current_preachform, templateid, templatename, is_visit_again,
+         create_time, update_time, del_flag,
+         mch_archive_detail_id, mch_node_seq, mch_plan_hash, mch_node_json)
+        values
+        (#{taskid}, #{taskName}, #{taskDesc}, #{sendname}, #{patid}, #{phone}, #{sfzh}, #{hospno},
+         #{visitTime}, #{sendstate}, #{orgid}, #{campusid}, #{serviceType}, #{type},
+         #{currentPreachform}, #{templateid}, #{templatename}, #{isVisitAgain},
+         #{createTime}, #{updateTime}, #{delFlag},
+         #{mchArchiveDetailId}, #{mchNodeSeq}, #{mchPlanHash}, #{mchNodeJson})
+    </insert>
+
+    <update id="cancelPendingByArchiveDetailId">
+        update service_subtask
+        set sendstate = 4,
+            remark = concat(ifnull(remark, ''), ';濡囧辜璁″垝鍙樻洿锛屽彇娑堟湭鍙戦�佷换鍔�'),
+            update_time = #{now}
+        where mch_archive_detail_id = #{detailId}
+          and sendstate = 2
+          and (mch_plan_hash is null or mch_plan_hash &lt;&gt; #{planHash})
+          and (del_flag is null or del_flag = '0')
+    </update>
+
+    <select id="selectNodeJsonById" resultType="java.lang.String">
+        select mch_node_json
+        from service_subtask
+        where id = #{id}
+    </select>
+
+    <update id="claimMchSubtask">
+        update service_subtask
+        set sendstate = 1,
+            update_time = #{now}
+        where id = #{id}
+          and (sendstate = 2
+               or (sendstate = 1 and update_time &lt; date_sub(#{now}, interval 10 minute)))
+    </update>
+
+    <update id="updateMchSendResult">
+        update service_subtask
+        set sendstate = #{sendstate},
+            result = #{result},
+            remark = #{remark},
+            finishtime = #{finishtime},
+            update_time = #{now}
+        where id = #{id}
+          and sendstate = 1
+    </update>
+
+</mapper>

--
Gitblit v1.9.3