smartor/src/main/resources/mapper/smartor/ServiceSubtaskDetailMapper.xml
@@ -546,4 +546,34 @@
            ivr_liba_target.targetname,
            service_subtask_detail.matchedtext
    </select>
    <select id="selectRepeatDetailIds" resultType="Long">
        SELECT d1.id
        FROM service_subtask_detail d1
        INNER JOIN (
            SELECT sub_id, questiontext,
                   MAX(create_time) AS max_create_time,
                   MAX(id) AS keep_id
            FROM service_subtask_detail
            WHERE del_flag = 0
            GROUP BY sub_id, questiontext
            HAVING COUNT(*) &gt; 1
        ) d2 ON d1.sub_id = d2.sub_id
            AND d1.questiontext = d2.questiontext
            AND (
                d1.create_time &lt; d2.max_create_time
                OR (d1.create_time = d2.max_create_time AND d1.id &lt; d2.keep_id)
            )
        WHERE d1.del_flag = 0
    </select>
    <update id="deleteRepeatDetailByIds">
        UPDATE service_subtask_detail
        SET del_flag = 1
        WHERE del_flag = 0
        AND id IN
        <foreach collection="ids" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
</mapper>