<?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.unis.purchaseAndSalesSupervision.modular.storageTaskSupervise.mapper.StorageTaskSuperviseMapper">
    <select id="getPageList" parameterType="string" resultType="com.unis.purchaseAndSalesSupervision.modular.storageTaskSupervise.entity.StorageTaskSupervise">
        SELECT
            tvo.id id,
            tvo.org_id orgId,
            tvo.org_name orgName,
            tvo.cfbh,
            tvo.cfmc,
            '通风' zylx,
            tfkssj startTime,
            tfjssj endTime,
            tfrq workTime
        FROM
            t_ventilation_operation tvo
        <where>
            <if test="orgName != null and orgName != ''">
                tvo.org_name LIKE CONCAT("%",#{orgName},"%")
            </if>
        </where>
        UNION ALL
            SELECT
                tft.id,
                tft.org_id orgId,
                tft.org_name orgName,
                tft.storehouse_code cfbh,
                tft.storehouse_name cfmc,
                '熏蒸' zylx,
                tft.start_time startTime,
                tft.end_time endTime,
                tft.start_time workTime
            FROM
                t_fumigation_task tft
        <where>
            <if test="orgName != null and orgName != ''">
                tft.org_name LIKE CONCAT("%",#{orgName},"%")
            </if>
        </where>
    </select>
    <select id="getByIdTF" parameterType="string" resultType="com.unis.purchaseAndSalesSupervision.modular.storageTaskSupervise.entity.StorageVentilationOperation">
        SELECT
            tvo.*, be.enumname tfmdName,
            be1.enumname tflxName,
            be2.enumname fdxsName,
            be3.enumname fwszfsName,
            be4.enumname sffsName
        FROM
            t_ventilation_operation tvo
        LEFT JOIN basic_enum be ON tvo.tfmd = be.enumId
        LEFT JOIN basic_enum be1 ON tvo.tflx = be1.enumId
        LEFT JOIN basic_enum be2 ON tvo.fdxs = be2.enumId
        LEFT JOIN basic_enum be3 ON tvo.fwszfs = be3.enumId
        LEFT JOIN basic_enum be4 ON tvo.sffs = be4.enumId
        WHERE
            tvo.id = #{id}
    </select>
    <select id="getByIdXZ" parameterType="string" resultType="com.unis.purchaseAndSalesSupervision.modular.storageTaskSupervise.entity.StorageFumigationTask">
        SELECT
            *
        FROM
            t_fumigation_task
        WHERE
            id = #{id}
    </select>
</mapper>