<?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.ltgk.catches.mapper.TcFishLimitEarlyMapper">
    <resultMap id="BaseResultMap" type="com.ltgk.catches.domain.entity.TcFishLimitEarly">
        <!--@mbg.generated-->
        <!--@Table tc_fish_limit_early-->
        <id column="id" jdbcType="VARCHAR" property="id"/>
        <result column="early_type" jdbcType="VARCHAR" property="earlyType"/>
        <result column="log_date" jdbcType="DATE" property="logDate"/>
        <result column="boat_id" jdbcType="VARCHAR" property="boatId"/>
        <result column="aquatic_dict_id" jdbcType="BIGINT" property="aquaticDictId"/>
        <result column="boat_name" jdbcType="VARCHAR" property="boatName"/>
        <result column="fish_limit" jdbcType="BIGINT" property="fishLimit"/>
        <result column="set_id" jdbcType="VARCHAR" property="setId"/>
        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
        <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
        <result column="create_at" jdbcType="TIMESTAMP" property="createAt"/>
        <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
        <result column="update_at" jdbcType="TIMESTAMP" property="updateAt"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="handle_result" jdbcType="VARCHAR" property="handleResult"/>
        <result column="rationale" jdbcType="VARCHAR" property="rationale"/>
        <result column="be_handle" jdbcType="INTEGER" property="beHandle"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, early_type, log_date, boat_id, aquatic_dict_id, boat_name, fish_limit, set_id,
        del_flag, create_by, create_at, update_by, update_at, remark
    </sql>

    <select id="list" resultType="com.ltgk.catches.domain.vo.FishLimitEarlyVo">
        select te.id,te.boat_id as boatId,te.boat_name as boatName,t.holder_name as holderName,
        t.holder_phone as holderPhone,t.holder_address as holderAddress,
        t.area_code as areaCode,t.area_name as areaName, t.boat_code as boatCode,
        t.main_power as mainPower,t.boat_type as boatType,f.fishing_code as fishingCode,
        f.main_work_type as mainWorkType,f.certificate_type as certificateType,te.early_type as earlyType,
        te.log_date as logDate,te.fish_limit as fishLimit,te.set_id as setId,te.aquatic_dict_id as aquaticDictId,
        d.dict_name as aquaticName,
        te.handle_person as handlePerson,te.handle_phone as handlePhone,te.handle_date as handleDate,te.handle_desc as
        handleDesc,
        te.handle_result AS handleResult, te.rationale AS rationale, te.be_handle AS beHandle, te.early_weight AS earlyWeight
        from tc_fish_limit_early as te
        left join ds_boat_data as t on te.boat_id = t.boat_id
        left join ds_boat_fishing as f on te.boat_id = f.boat_id
        left join tp_aquatic_dict as d on te.aquatic_dict_id = d.id
        where te.del_flag = 0
        <if test="earlyType != null and earlyType != ''">
            and te.early_type = #{earlyType}
        </if>
        <if test="boatId != null and boatId != ''">
            and te.boat_id = #{boatId}
        </if>
        <if test="boatName != null and boatName != ''">
            and te.boat_name like concat('%',#{boatName},'%')
        </if>
        <if test="aquaticDictId != null and aquaticDictId != ''">
            and te.aquatic_dict_id = #{aquaticDictId}
        </if>
        <if test="startDate != null and startDate != ''">
            and te.log_date &gt;= #{startDate}
        </if>
        <if test="endDate != null and endDate != ''">
            and te.log_date &lt;= #{endDate}
        </if>
        order by te.log_date desc
    </select>
</mapper>