<?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.cool.store.mapper.AcceptanceInfoMapper">
    <resultMap id="BaseResultMap" type="com.cool.store.entity.AcceptanceInfoDO">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
        <result column="actual_entry_time" jdbcType="TIMESTAMP" property="actualEntryTime"/>
        <result column="planned_completion_time" jdbcType="TIMESTAMP" property="plannedCompletionTime"/>
        <result column="planned_start_time" jdbcType="TIMESTAMP" property="plannedStartTime"/>
        <result column="decoration_planned_completion_time" jdbcType="TIMESTAMP"
                property="decorationPlannedCompletionTime"/>
        <result column="decoration_planned_start_time" jdbcType="TIMESTAMP" property="decorationPlannedStartTime"/>
        <result column="construction_completion_time" jdbcType="TIMESTAMP" property="constructionCompletionTime"/>
        <result column="engineering_acceptance_signatures" jdbcType="VARCHAR"
                property="engineeringAcceptanceSignatures"/>
        <result column="operations_acceptance_signatures" jdbcType="VARCHAR" property="operationsAcceptanceSignatures"/>
        <result column="partner_acceptance_signatures" jdbcType="VARCHAR" property="partnerAcceptanceSignatures"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="deleted" jdbcType="BIT" property="deleted"/>
        <result column="plan_acceptance_time" jdbcType="TIMESTAMP" property="planAcceptanceTime"/>
        <result column="actual_acceptance_time" jdbcType="TIMESTAMP" property="actualAcceptanceTime"/>
        <result column="booking_user" jdbcType="VARCHAR" property="bookingUser"/>
        <result column="plan_exit_time" jdbcType="TIMESTAMP" property="planExitTime"/>
    </resultMap>
    <sql id="baseColumn">
        id
        ,shop_id,actual_entry_time,planned_completion_time,planned_start_time,decoration_planned_completion_time,
           decoration_planned_start_time,construction_completion_time,engineering_acceptance_signatures,
           operations_acceptance_signatures,partner_acceptance_signatures,
           create_time,update_time,deleted,plan_acceptance_time,actual_acceptance_time,booking_user,plan_exit_time
    </sql>
    <update id="updateByShopIDSelective">
        update xfsg_acceptance_info
        <set>
            <if test="actualEntryTime != null">
                actual_entry_time = #{actualEntryTime} ,
            </if>
            <if test="plannedCompletionTime != null">
                planned_completion_time = #{plannedCompletionTime} ,
            </if>
            <if test="plannedStartTime != null">
                planned_start_time = #{plannedStartTime} ,
            </if>
            <if test="decorationPlannedCompletionTime != null">
                decoration_planned_completion_time = #{decorationPlannedCompletionTime} ,
            </if>
            <if test="decorationPlannedStartTime != null">
                decoration_planned_start_time = #{decorationPlannedStartTime} ,
            </if>
            <if test="constructionCompletionTime != null">
                construction_completion_time = #{constructionCompletionTime} ,
            </if>
            <if test="engineeringAcceptanceSignatures != null">
                engineering_acceptance_signatures = #{engineeringAcceptanceSignatures} ,
            </if>
            <if test="operationsAcceptanceSignatures != null">
                operations_acceptance_signatures = #{operationsAcceptanceSignatures} ,
            </if>
            <if test="partnerAcceptanceSignatures != null">
                partner_acceptance_signatures = #{partnerAcceptanceSignatures} ,
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime} ,
            </if>
            <if test="deleted != null">
                deleted = #{deleted} ,
            </if>
            <if test="planAcceptanceTime !=null ">
                plan_acceptance_time  =#{planAcceptanceTime},
            </if>
            <if test="actualAcceptanceTime !=null ">
                actual_acceptance_time  =#{actualAcceptanceTime},
            </if>
            <if test="bookingUser !=null ">
                booking_user  =#{bookingUser},
            </if>
            <if test="planExitTime !=null">
                plan_exit_time =#{planExitTime}
            </if>
        </set>
        where shop_id = #{shopId}
    </update>
    <select id="selectShopIdListBySignatures" resultType="com.cool.store.entity.AcceptanceInfoDO">
        select
           a.shop_id as shopId ,a.actual_entry_time as actualEntry_time,a.plan_exit_time as planExitTime, a.decoration_planned_completion_time as decorationPlannedCompletionTime,
           a.plan_acceptance_time as planAcceptanceTime
        from xfsg_acceptance_info a
        left join  xfsg_shop_stage_info b on a.shop_id = b.shop_id
        where b.shop_sub_stage=#{subStage} and b.shop_sub_stage_status = #{status}
          and a.deleted = 0 and a.actual_entry_time is not null
    </select>
    <select id="selectByShopId" resultType="com.cool.store.entity.AcceptanceInfoDO">
        select
        <include refid="baseColumn"/>
        from xfsg_acceptance_info
        where shop_id = #{shopId} and deleted = 0
    </select>
    <select id="selectByEntryTimeNull" resultType="com.cool.store.entity.AcceptanceInfoDO">
        select
        <include refid="baseColumn"/>
        from xfsg_acceptance_info
        where actual_entry_time is null
    </select>
    <select id="selectByShopIds" resultType="com.cool.store.entity.AcceptanceInfoDO">
        select
        <include refid="baseColumn"/>
        from xfsg_acceptance_info
        where deleted = 0
        <if test="shopIds != null and shopIds.size()>0">
            and shop_id in
            <foreach collection="shopIds" item="shopId" open="(" separator="," close=")">
                #{shopId}
            </foreach>
        </if>
    </select>
    <select id="selectListNotNullEntryTime" resultType="com.cool.store.entity.AcceptanceInfoDO">
        select *
        from xfsg_acceptance_info
        where actual_entry_time is not null
    </select>

</mapper>