update pat_maternity_archive_detail
set mch_plan_hash = #{planHash},
mch_next_due_time = #{nextDueTime}
where id = #{detailId}
update pat_child_archive_detail
set mch_plan_hash = #{planHash},
mch_next_due_time = #{nextDueTime}
where id = #{detailId}
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})
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 <> #{planHash})
and (del_flag is null or del_flag = '0')
update service_subtask
set sendstate = 1,
update_time = #{now}
where id = #{id}
and (sendstate = 2
or (sendstate = 1 and update_time < date_sub(#{now}, interval 10 minute)))
update service_subtask
set sendstate = #{sendstate},
result = #{result},
remark = #{remark},
finishtime = #{finishtime},
update_time = #{now}
where id = #{id}
and sendstate = 1