<?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="org.jeecg.modules.fbsBasedate.mapper.FbsTechnologicalProcessMapper">
    <select id="findByPage" resultType="org.jeecg.modules.fbsBasedate.entity.FbsTechnologicalProcess">
        SELECT
            i.cinvname as cinvCName,
            ftp.*
        FROM
            fbs_technological_process ftp
            LEFT JOIN inventory i ON ftp.NAME = i.cInvCode
            ${ew.customSqlSegment}
    </select>

    <select id="getExport" resultType="org.jeecg.modules.fbsBasedate.entity.FbsTechnologicalProcess">
        SELECT
        ftp.*,
        i.cInvCName as cinvCName,
        ftpi.name as itemName,
        ftpi.standard_working_hours
        FROM fbs_technological_process ftp
        LEFT JOIN inventory i ON ftp.NAME = i.cInvCode
        LEFT JOIN fbs_technological_process_item ftpi ON ftp.id=ftpi.fbs_technological_process_id
        where
        ftp.del_flag='0' AND ftpi.del_flag='0'
        <if test="fbsTechnologicalProcess.name!=null and fbsTechnologicalProcess.name!=''">
            AND ftp.name =#{fbsTechnologicalProcess.name}
        </if>
        <if test="fbsTechnologicalProcess.cinvCName!=null and fbsTechnologicalProcess.cinvCName!=''">
            AND i.cInvCName LIKE "%" #{fbsTechnologicalProcess.cinvCName} "%"
        </if>
        order by ftp.create_time desc,ftpi.sort asc
    </select>
</mapper>