ExceptionWorkorderLogMapper.xml 2.72 KB
<?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.apple.erp.mapper.ExceptionWorkorderLogMapper">

    <!-- 根据工单ID获取处理日志列表 -->
    <select id="selectWorkorderLogsByWorkorderId" resultType="com.apple.erp.dto.ExceptionWorkorderLogRes">
        SELECT 
            ewl.log_id,
            ewl.workorder_id,
            ewl.workorder_no,
            ewl.handle_user,
            ewl.handle_time,
            ewl.before_status,
            CASE ewl.before_status
                WHEN 1 THEN '待处理'
                WHEN 2 THEN '处理中'
                WHEN 3 THEN '已解决'
                WHEN 4 THEN '已关闭'
                ELSE '未知状态'
            END AS before_status_name,
            ewl.after_status,
            CASE ewl.after_status
                WHEN 1 THEN '待处理'
                WHEN 2 THEN '处理中'
                WHEN 3 THEN '已解决'
                WHEN 4 THEN '已关闭'
                ELSE '未知状态'
            END AS after_status_name,
            ewl.handle_opinion,
            ewl.attach_url,
            ewl.create_by,
            ewl.create_time
        FROM t_exception_workorder_log ewl
        WHERE ewl.workorder_id = #{workorderId} AND ewl.del_flag = '0'
        ORDER BY ewl.handle_time DESC
    </select>

    <!-- 根据工单ID列表批量获取处理日志 -->
    <select id="selectWorkorderLogsByWorkorderIds" resultType="com.apple.erp.dto.ExceptionWorkorderLogRes">
        SELECT 
            ewl.log_id,
            ewl.workorder_id,
            ewl.workorder_no,
            ewl.handle_user,
            ewl.handle_time,
            ewl.before_status,
            CASE ewl.before_status
                WHEN 1 THEN '待处理'
                WHEN 2 THEN '处理中'
                WHEN 3 THEN '已解决'
                WHEN 4 THEN '已关闭'
                ELSE '未知状态'
            END AS before_status_name,
            ewl.after_status,
            CASE ewl.after_status
                WHEN 1 THEN '待处理'
                WHEN 2 THEN '处理中'
                WHEN 3 THEN '已解决'
                WHEN 4 THEN '已关闭'
                ELSE '未知状态'
            END AS after_status_name,
            ewl.handle_opinion,
            ewl.attach_url,
            ewl.create_by,
            ewl.create_time
        FROM t_exception_workorder_log ewl
        WHERE ewl.workorder_id IN
        <foreach collection="workorderIds" item="workorderId" open="(" separator="," close=")">
            #{workorderId}
        </foreach>
        AND ewl.del_flag = '0'
        ORDER BY ewl.workorder_id, ewl.handle_time DESC
    </select>

</mapper>