<?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.crew.mapper.DsCrewEnterCheckMapper">

    <resultMap type="com.ltgk.crew.domain.entity.DsCrewEnterCheck" id="DsCrewEnterCheckMap">
        <result property="id" column="id"/>
        <result property="enterPortId" column="enter_port_id"/>
        <result property="portId" column="port_id"/>
        <result property="portName" column="port_name"/>
        <result property="crewId" column="crew_id"/>
        <result property="crewName" column="crew_name"/>
        <result property="idCard" column="id_card"/>
        <result property="tel" column="tel"/>
        <result property="certificateNumber" column="certificate_number"/>
        <result property="position" column="position"/>
        <result property="address" column="address"/>
        <result property="status" column="status"/>
        <result property="reason" column="reason"/>
        <result property="idCardPic" column="id_card_pic"/>
        <result property="areaCode" column="area_code"/>
        <result property="areaName" column="area_name"/>
        <result property="createBy" column="create_by"/>
        <result property="createAt" column="create_at"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateAt" column="update_at"/>
        <result property="remark" column="remark"/>
        <result property="checkUrl" column="check_url"/>
    </resultMap>
    <insert id="saveBoatBindCrew">
        insert into ds_boat_bind_crew(
        <if test="dsBoatBindCrew.id != null and dsBoatBindCrew.id != 0">id,</if>
        <if test="dsBoatBindCrew.boatName1 != null and dsBoatBindCrew.boatName1 != ''">boat_name1,</if>
        <if test="dsBoatBindCrew.boatName2 != null and dsBoatBindCrew.boatName2 != ''">boat_name2,</if>
        <if test="dsBoatBindCrew.ownerPhone != null and dsBoatBindCrew.ownerPhone != ''">owner_phone,</if>
        <if test="dsBoatBindCrew.crewId != null and dsBoatBindCrew.crewId != ''">crew_id,</if>
        <if test="dsBoatBindCrew.bindTime != null">bind_time,</if>
        <if test="dsBoatBindCrew.crewName != null and dsBoatBindCrew.crewName != ''">crew_name,</if>
        <if test="dsBoatBindCrew.crewIdcard != null and dsBoatBindCrew.crewIdcard != ''">crew_idcard,</if>
        <if test="dsBoatBindCrew.crewPhone != null and dsBoatBindCrew.crewPhone != ''">crew_phone,</if>
        <if test="dsBoatBindCrew.crewPosition != null and dsBoatBindCrew.crewPosition != ''">crew_position,</if>
        <if test="dsBoatBindCrew.crewInsured != null and dsBoatBindCrew.crewInsured != ''">crew_insured,</if>
        <if test="dsBoatBindCrew.ownerUsername != null and dsBoatBindCrew.ownerUsername != ''">owner_username,</if>
        <if test="dsBoatBindCrew.insured != null and dsBoatBindCrew.insured != ''">insured,</if>
        <if test="dsBoatBindCrew.delFlag != null">del_flag,</if>
        <if test="dsBoatBindCrew.createBy != null and dsBoatBindCrew.createBy != ''">create_by,</if>
        <if test="dsBoatBindCrew.createAt != null">create_at,</if>
        <if test="dsBoatBindCrew.updateBy != null and dsBoatBindCrew.updateBy != ''">update_by,</if>
        update_at)
        values (
        <if test="dsBoatBindCrew.id != null and dsBoatBindCrew.id != 0">#{id},</if>
        <if test="dsBoatBindCrew.boatName1 != null and dsBoatBindCrew.boatName1 != ''">#{dsBoatBindCrew.boatName1},</if>
        <if test="dsBoatBindCrew.boatName2 != null and dsBoatBindCrew.boatName2 != ''">#{dsBoatBindCrew.boatName2},</if>
        <if test="dsBoatBindCrew.ownerPhone != null and dsBoatBindCrew.ownerPhone != ''">#{dsBoatBindCrew.ownerPhone},
        </if>
        <if test="dsBoatBindCrew.crewId != null and dsBoatBindCrew.crewId != ''">#{dsBoatBindCrew.crewId},</if>
        <if test="dsBoatBindCrew.bindTime != null">#{dsBoatBindCrew.bindTime},</if>
        <if test="dsBoatBindCrew.crewName != null and dsBoatBindCrew.crewName != ''">#{dsBoatBindCrew.crewName},</if>
        <if test="dsBoatBindCrew.crewIdcard != null and dsBoatBindCrew.crewIdcard != ''">#{dsBoatBindCrew.crewIdcard},
        </if>
        <if test="dsBoatBindCrew.crewPhone != null and dsBoatBindCrew.crewPhone != ''">#{dsBoatBindCrew.crewPhone},</if>
        <if test="dsBoatBindCrew.crewPosition != null and dsBoatBindCrew.crewPosition != ''">
            #{dsBoatBindCrew.crewPosition},
        </if>
        <if test="dsBoatBindCrew.crewInsured != null and dsBoatBindCrew.crewInsured != ''">
            #{dsBoatBindCrew.crewInsured},
        </if>
        <if test="dsBoatBindCrew.ownerUsername != null and dsBoatBindCrew.ownerUsername != ''">
            #{dsBoatBindCrew.ownerUsername},
        </if>
        <if test="dsBoatBindCrew.insured != null and dsBoatBindCrew.insured != ''">#{dsBoatBindCrew.insured},</if>
        <if test="dsBoatBindCrew.delFlag != null">#{dsBoatBindCrew.delFlag},</if>
        <if test="dsBoatBindCrew.createBy != null and dsBoatBindCrew.createBy != ''">#{dsBoatBindCrew.createBy},</if>
        <if test="dsBoatBindCrew.createAt != null">#{dsBoatBindCrew.createAt},</if>
        <if test="dsBoatBindCrew.updateBy != null and dsBoatBindCrew.updateBy != ''">#{dsBoatBindCrew.updateBy},</if>
        sysdate()
        )
    </insert>
    <update id="updateDsEnterPort">
        UPDATE ds_enter_port
        <set>
            <if test="dsEnterPortMap.crewIds != null and dsEnterPortMap.crewIds != ''">
                crew_ids = #{dsEnterPortMap.crewIds}
            </if>
        </set>
        <where>
            <if test="dsEnterPortMap.id != null and dsEnterPortMap.id != ''">
                and id = #{dsEnterPortMap.id}
            </if>
        </where>
    </update>
    <select id="getDsBoatBindCrewByCrewId" resultType="com.ltgk.crew.domain.dto.AddDsCrewCheckAndBindBoatReq">
        select id,
               boat_name1,
               boat_name2,
               owner_phone,
               crew_id,
               bind_time,
               crew_name,
               crew_idcard,
               crew_phone,
               crew_position,
               crew_insured,
               owner_username,
               insured,
               del_flag,
               create_by,
               create_at,
               update_by,
               update_at
        from ds_boat_bind_crew
        where crew_id = #{crewId}
    </select>

    <select id="selectCount" resultType="java.lang.Long">
        select count(id)
        from ds_crew_enter_check
        where enter_time &gt;= #{date}
    </select>
</mapper>

