<?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.DsCrewOutCheckMapper">

    <resultMap type="com.ltgk.crew.domain.entity.DsCrewOutCheck" id="DsCrewOutCheckMap">
        <result property="id" column="id"/>
        <result property="outPortId" column="out_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="outPortName" column="out_port_name"/>
        <result property="checkUrl" column="check_url"/>
    </resultMap>
    <update id="updateDsOutPort">
        UPDATE ds_out_port
        <set>
            <if test="dsOutPortMap.crewIds != null and dsOutPortMap.crewIds != ''">
                crew_ids = #{dsOutPortMap.crewIds}
            </if>
        </set>
        <where>
            <if test="dsOutPortMap.id != null and dsOutPortMap.id != ''">
                and id = #{dsOutPortMap.id}
            </if>
        </where>
    </update>

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

    <select id="selectCrewGoSea" resultType="com.ltgk.crew.domain.vo.CrewGoSeaVo">
        select date_format(out_time, '%Y-%m-%d') as date,
               count(id)                         as count
        from ds_crew_out_check
        where create_at &gt;= #{startTime}
          and create_at &lt;= #{endTime}
        group by date
        ORDER BY date ASC
    </select>
</mapper>

