<?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.qmth.sop.business.mapper.TBSopPlanDateLogMapper">

    <select id="findSopPlanDateLog" resultType="com.qmth.sop.business.bean.dto.TBSopPlanDateLogDto">
        select *,tffa.status as status,tffa.update_time as flowUpdateTime from t_b_sop_plan_date_log tbspdl
               left join t_b_sop_info tbsi on tbsi.id = tbspdl.sop_id
               left join t_f_custom_flow_entity tfcfe on tfcfe.code = tbsi.sop_no
               left join t_b_service tbs on tbs.id = tbsi.service_id
               left join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id
        <where> 1 = 1
                and tbsi.status = 'START'
            <if test="serviceId != null and serviceId != ''">
                and tbs.id = #{serviceId}
            </if>
        </where>
            order by tbspdl.sop_id,tbspdl.create_time
    </select>
</mapper>
