<?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.xinelu.manage.mapper.nursestation.NurseStationMapper">

    <resultMap type="NurseStation" id="NurseStationResult">
        <result property="id" column="id"/>
        <result property="areaCode" column="area_code"/>
        <result property="userId" column="user_id"/>
        <result property="nurseStationCode" column="nurse_station_code"/>
        <result property="nurseStationName" column="nurse_station_name"/>
        <result property="nurseStationType" column="nurse_station_type"/>
        <result property="agencyIntroduce" column="agency_introduce"/>
        <result property="nurseStationDescription" column="nurse_station_description"/>
        <result property="longitude" column="longitude"/>
        <result property="latitude" column="latitude"/>
        <result property="phone" column="phone"/>
        <result property="address" column="address"/>
        <result property="dutyPerson" column="duty_person"/>
        <result property="dutyPhone" column="duty_phone"/>
        <result property="stationPictureUrl" column="station_picture_url"/>
        <result property="stationIntroducePictureUrl" column="station_introduce_picture_url"/>
        <result property="sort" column="sort"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="nurseGrade" column="nurse_grade"/>
        <result property="openingHoursDescribe" column="opening_hours_describe"/>
        <result property="morningOpenStartTime" column="morning_open_start_time"/>
        <result property="morningOpenEndTime" column="morning_open_end_time"/>
        <result property="afternoonOpenStartTime" column="afternoon_open_start_time"/>
        <result property="afternoonOpenEndTime" column="afternoon_open_end_time"/>
        <result property="stationWechatCodeUrl" column="station_wechat_code_url"/>
    </resultMap>


    <resultMap type="com.xinelu.manage.vo.nursestation.NurseStationAndAreaVO" id="NurseStationResultInFo">
        <result property="id" column="id"/>
        <result property="areaCode" column="area_code"/>
        <result property="userId" column="user_id"/>
        <result property="nurseStationCode" column="nurse_station_code"/>
        <result property="nurseStationName" column="nurse_station_name"/>
        <result property="nurseStationType" column="nurse_station_type"/>
        <result property="agencyIntroduce" column="agency_introduce"/>
        <result property="nurseStationDescription" column="nurse_station_description"/>
        <result property="longitude" column="longitude"/>
        <result property="latitude" column="latitude"/>
        <result property="phone" column="phone"/>
        <result property="address" column="address"/>
        <result property="dutyPerson" column="duty_person"/>
        <result property="dutyPhone" column="duty_phone"/>
        <result property="stationPictureUrl" column="station_picture_url"/>
        <result property="stationIntroducePictureUrl" column="station_introduce_picture_url"/>
        <result property="sort" column="sort"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="nurseGrade" column="nurse_grade"/>
        <result property="openingHoursDescribe" column="opening_hours_describe"/>
        <result property="morningOpenStartTime" column="morning_open_start_time"/>
        <result property="morningOpenEndTime" column="morning_open_end_time"/>
        <result property="afternoonOpenStartTime" column="afternoon_open_start_time"/>
        <result property="afternoonOpenEndTime" column="afternoon_open_end_time"/>
        <collection property="nurseStationLabel" javaType="java.util.List" resultMap="NurseStationLabelInfo"/>
        <collection property="nurseClassifyInfoList" javaType="java.util.List" resultMap="NurseClassifyInfoResult"/>
    </resultMap>

    <resultMap type="com.xinelu.manage.vo.nursestation.NurseStationLabelVO" id="NurseStationLabelInfo">
        <result property="id" column="id"/>
        <result property="nurseStationId" column="nurse_station_id"/>
        <result property="userId" column="user_id"/>
        <result property="labelCode" column="label_code"/>
        <result property="labelDescription" column="label_description"/>
        <result property="labelSort" column="labelSort"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <resultMap type="NurseClassifyInfo" id="NurseClassifyInfoResult">
        <result property="id" column="nurseClassifyId"/>
        <result property="parentId" column="parent_id"/>
        <result property="classifyCode" column="classify_code"/>
        <result property="classifyName" column="classify_name"/>
        <result property="classifyLevel" column="classify_level"/>
        <result property="classifyType" column="classify_type"/>
        <result property="classifyPictureUrl" column="classify_picture_url"/>
        <result property="classifySort" column="classify_sort"/>
    </resultMap>

    <sql id="selectNurseStationVo">
        select id,
               area_code,
               user_id,
               nurse_station_code,
               nurse_station_name,
               nurse_station_type,
               agency_introduce,
               nurse_station_description,
               longitude,
               latitude,
               phone,
               address,
               duty_person,
               duty_phone,
               station_picture_url,
               station_introduce_picture_url,
               sort,
               create_by,
               create_time,
               update_by,
               update_time,
               nurse_grade,
               opening_hours_describe,
               morning_open_start_time,
               morning_open_end_time,
               afternoon_open_start_time,
               afternoon_open_end_time,
               station_wechat_code_url
        from nurse_station
    </sql>

    <select id="selectNurseStationList" parameterType="com.xinelu.manage.vo.nursestation.NurseStationVO"
            resultType="com.xinelu.manage.vo.nursestation.NurseStationVO">
        <include refid="selectNurseStationVo"/>
        <where>
            <if test="areaCode != null ">
                and area_code = #{areaCode}
            </if>
            <if test="id != null ">
                and id = #{id}
            </if>
            <if test="userId != null ">
                and user_id = #{userId}
            </if>
            <if test="nurseStationCode != null  and nurseStationCode != ''">
                and nurse_station_code like concat('%', #{nurseStationCode}, '%')
            </if>
            <if test="nurseStationName != null  and nurseStationName != ''">
                and nurse_station_name like concat('%', #{nurseStationName}, '%')
            </if>
            <if test="nurseStationType != null  and nurseStationType != ''">
                and find_in_set(#{nurseStationType},nurse_station_type)
            </if>
            <if test="agencyIntroduce != null  and agencyIntroduce != ''">
                and agency_introduce = #{agencyIntroduce}
            </if>
            <if test="nurseStationDescription != null  and nurseStationDescription != ''">
                and nurse_station_description = #{nurseStationDescription}
            </if>
            <if test="longitude != null  and longitude != ''">
                and longitude = #{longitude}
            </if>
            <if test="latitude != null  and latitude != ''">
                and latitude = #{latitude}
            </if>
            <if test="phone != null  and phone != ''">
                and phone = #{phone}
            </if>
            <if test="address != null  and address != ''">
                and address = #{address}
            </if>
            <if test="dutyPerson != null  and dutyPerson != ''">
                and duty_person = #{dutyPerson}
            </if>
            <if test="dutyPhone != null  and dutyPhone != ''">
                and duty_phone = #{dutyPhone}
            </if>
            <if test="stationPictureUrl != null  and stationPictureUrl != ''">
                and station_picture_url = #{stationPictureUrl}
            </if>
            <if test="stationIntroducePictureUrl != null  and stationIntroducePictureUrl != ''">
                and station_introduce_picture_url = #{stationIntroducePictureUrl}
            </if>
            <if test="sort != null ">
                and sort = #{sort}
            </if>
            <if test="nurseGrade != null ">
                and nurse_grade = #{nurseGrade}
            </if>
            <if test="openingHoursDescribe != null  and openingHoursDescribe != ''">
                and opening_hours_describe = #{openingHoursDescribe}
            </if>
            <if test="morningOpenStartTime != null ">
                and morning_open_start_time = #{morningOpenStartTime}
            </if>
            <if test="morningOpenEndTime != null ">
                and morning_open_end_time = #{morningOpenEndTime}
            </if>
            <if test="afternoonOpenStartTime != null ">
                and afternoon_open_start_time = #{afternoonOpenStartTime}
            </if>
            <if test="afternoonOpenEndTime != null ">
                and afternoon_open_end_time = #{afternoonOpenEndTime}
            </if>
        </where>
        order by create_time desc
    </select>

    <select id="selectNurseStationListByUser" parameterType="NurseStation"
            resultType="com.xinelu.manage.vo.nursestation.NurseStationByUserVO">
        <include refid="selectNurseStationVo"/>
        <where>
            <if test="areaCode != null ">
                and area_code = #{areaCode}
            </if>
            <if test="userId != null ">
                and user_id = #{userId}
            </if>
            <if test="nurseStationCode != null  and nurseStationCode != ''">
                and nurse_station_code = #{nurseStationCode}
            </if>
            <if test="nurseStationName != null  and nurseStationName != ''">
                and nurse_station_name like concat('%', #{nurseStationName}, '%')
            </if>
            <if test="nurseStationType != null  and nurseStationType != ''">
                and nurse_station_type = #{nurseStationType}
            </if>
            <if test="agencyIntroduce != null  and agencyIntroduce != ''">
                and agency_introduce = #{agencyIntroduce}
            </if>
            <if test="nurseStationDescription != null  and nurseStationDescription != ''">
                and nurse_station_description = #{nurseStationDescription}
            </if>
            <if test="longitude != null  and longitude != ''">
                and longitude = #{longitude}
            </if>
            <if test="latitude != null  and latitude != ''">
                and latitude = #{latitude}
            </if>
            <if test="phone != null  and phone != ''">
                and phone = #{phone}
            </if>
            <if test="address != null  and address != ''">
                and address = #{address}
            </if>
            <if test="dutyPerson != null  and dutyPerson != ''">
                and duty_person = #{dutyPerson}
            </if>
            <if test="dutyPhone != null  and dutyPhone != ''">
                and duty_phone = #{dutyPhone}
            </if>
            <if test="stationPictureUrl != null  and stationPictureUrl != ''">
                and station_picture_url = #{stationPictureUrl}
            </if>
            <if test="sort != null ">
                and sort = #{sort}
            </if>
        </where>
    </select>

    <select id="selectNurseStationById" parameterType="Long"
            resultMap="NurseStationResultInFo">
        SELECT ns.id,
               ns.area_code,
               ns.user_id,
               ns.nurse_station_code,
               ns.nurse_station_name,
               ns.nurse_station_type,
               ns.agency_introduce,
               ns.nurse_station_description,
               ns.longitude,
               ns.latitude,
               ns.phone,
               ns.address,
               ns.duty_person,
               ns.duty_phone,
               ns.station_picture_url,
               ns.station_introduce_picture_url,
               ns.sort,
               ns.create_by,
               ns.create_time,
               ns.update_by,
               ns.update_time,
               ns.nurse_grade,
               ns.opening_hours_describe,
               ns.morning_open_start_time,
               ns.morning_open_end_time,
               ns.afternoon_open_start_time,
               ns.afternoon_open_end_time,
               nsl.nurse_station_id,
               nsl.user_id,
               nsl.label_code,
               nsl.label_description,
               nsl.sort labelSort,
               nsl.create_by,
               nsl.create_time,
               nsl.update_by,
               nsl.update_time,
               nci.id   nurseClassifyId,
               nci.classify_code,
               nci.classify_name,
               nci.classify_type
        FROM nurse_station ns
                 LEFT JOIN nurse_station_label nsl ON nsl.nurse_station_id = ns.id
                 LEFT JOIN nurse_station_classify_relation nscr ON nscr.nurse_station_id = ns.id
                 LEFT JOIN nurse_classify_info nci ON nci.id = nscr.nurse_classify_id
        where ns.id = #{id}
    </select>

    <insert id="insertNurseStation" parameterType="NurseStation" useGeneratedKeys="true"
            keyProperty="id">
        insert into nurse_station
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaCode != null">area_code,
            </if>
            <if test="userId != null">user_id,
            </if>
            <if test="nurseStationCode != null">nurse_station_code,
            </if>
            <if test="nurseStationName != null">nurse_station_name,
            </if>
            <if test="nurseStationType != null">nurse_station_type,
            </if>
            <if test="agencyIntroduce != null">agency_introduce,
            </if>
            <if test="nurseStationDescription != null">nurse_station_description,
            </if>
            <if test="longitude != null">longitude,
            </if>
            <if test="latitude != null">latitude,
            </if>
            <if test="phone != null">phone,
            </if>
            <if test="address != null">address,
            </if>
            <if test="dutyPerson != null">duty_person,
            </if>
            <if test="dutyPhone != null">duty_phone,
            </if>
            <if test="stationPictureUrl != null">station_picture_url,
            </if>
            <if test="stationIntroducePictureUrl != null">station_introduce_picture_url,
            </if>
            <if test="sort != null">sort,
            </if>
            <if test="createBy != null">create_by,
            </if>
            <if test="createTime != null">create_time,
            </if>
            <if test="updateBy != null">update_by,
            </if>
            <if test="updateTime != null">update_time,
            </if>
            <if test="nurseGrade != null">nurse_grade,
            </if>
            <if test="openingHoursDescribe != null">opening_hours_describe,
            </if>
            <if test="morningOpenStartTime != null">morning_open_start_time,
            </if>
            <if test="morningOpenEndTime != null">morning_open_end_time,
            </if>
            <if test="afternoonOpenStartTime != null">afternoon_open_start_time,
            </if>
            <if test="afternoonOpenEndTime != null">afternoon_open_end_time,
            </if>
            <if test="stationWechatCodeUrl != null">station_wechat_code_url,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="areaCode != null">#{areaCode},
            </if>
            <if test="userId != null">#{userId},
            </if>
            <if test="nurseStationCode != null">#{nurseStationCode},
            </if>
            <if test="nurseStationName != null">#{nurseStationName},
            </if>
            <if test="nurseStationType != null">#{nurseStationType},
            </if>
            <if test="agencyIntroduce != null">#{agencyIntroduce},
            </if>
            <if test="nurseStationDescription != null">#{nurseStationDescription},
            </if>
            <if test="longitude != null">#{longitude},
            </if>
            <if test="latitude != null">#{latitude},
            </if>
            <if test="phone != null">#{phone},
            </if>
            <if test="address != null">#{address},
            </if>
            <if test="dutyPerson != null">#{dutyPerson},
            </if>
            <if test="dutyPhone != null">#{dutyPhone},
            </if>
            <if test="stationPictureUrl != null">#{stationPictureUrl},
            </if>
            <if test="stationIntroducePictureUrl != null">#{stationIntroducePictureUrl},
            </if>
            <if test="sort != null">#{sort},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
            <if test="nurseGrade != null">#{nurseGrade},
            </if>
            <if test="openingHoursDescribe != null">#{openingHoursDescribe},
            </if>
            <if test="morningOpenStartTime != null">#{morningOpenStartTime},
            </if>
            <if test="morningOpenEndTime != null">#{morningOpenEndTime},
            </if>
            <if test="afternoonOpenStartTime != null">#{afternoonOpenStartTime},
            </if>
            <if test="afternoonOpenEndTime != null">#{afternoonOpenEndTime},
            </if>
            <if test="stationWechatCodeUrl != null">#{stationWechatCodeUrl},
            </if>
        </trim>
    </insert>

    <update id="updateNurseStation" parameterType="NurseStation">
        update nurse_station
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaCode != null">area_code =
                #{areaCode},
            </if>
            <if test="userId != null">user_id =
                #{userId},
            </if>
            <if test="nurseStationCode != null">nurse_station_code =
                #{nurseStationCode},
            </if>
            <if test="nurseStationName != null">nurse_station_name =
                #{nurseStationName},
            </if>
            <if test="nurseStationType != null">nurse_station_type =
                #{nurseStationType},
            </if>
            <if test="agencyIntroduce != null">agency_introduce =
                #{agencyIntroduce},
            </if>
            <if test="nurseStationDescription != null">nurse_station_description =
                #{nurseStationDescription},
            </if>
            <if test="longitude != null">longitude =
                #{longitude},
            </if>
            <if test="latitude != null">latitude =
                #{latitude},
            </if>
            <if test="phone != null">phone =
                #{phone},
            </if>
            <if test="address != null">address =
                #{address},
            </if>
            <if test="dutyPerson != null">duty_person =
                #{dutyPerson},
            </if>
            <if test="dutyPhone != null">duty_phone =
                #{dutyPhone},
            </if>
            <if test="stationPictureUrl != null">station_picture_url =
                #{stationPictureUrl},
            </if>
            <if test="stationIntroducePictureUrl != null">station_introduce_picture_url =
                #{stationIntroducePictureUrl},
            </if>
            <if test="sort != null">sort =
                #{sort},
            </if>
            <if test="createBy != null">create_by =
                #{createBy},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
            <if test="updateBy != null">update_by =
                #{updateBy},
            </if>
            <if test="updateTime != null">update_time =
                #{updateTime},
            </if>
            <if test="nurseGrade != null">nurse_grade =
                #{nurseGrade},
            </if>
            <if test="openingHoursDescribe != null">opening_hours_describe =
                #{openingHoursDescribe},
            </if>
            <if test="morningOpenStartTime != null">morning_open_start_time =
                #{morningOpenStartTime},
            </if>
            <if test="morningOpenEndTime != null">morning_open_end_time =
                #{morningOpenEndTime},
            </if>
            <if test="afternoonOpenStartTime != null">afternoon_open_start_time =
                #{afternoonOpenStartTime},
            </if>
            <if test="afternoonOpenEndTime != null">afternoon_open_end_time =
                #{afternoonOpenEndTime},
            </if>
            <if test="stationWechatCodeUrl != null">station_wechat_code_url =
                #{stationWechatCodeUrl},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteNurseStationById" parameterType="Long">
        delete
        from nurse_station
        where id = #{id}
    </delete>

    <delete id="deleteNurseStationByIds" parameterType="String">
        delete from nurse_station where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <delete id="deleteNurseStationLabelByIds" parameterType="String">
        delete from nurse_station_label where nurse_station_id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <update id="updateNurseStationByHead" parameterType="NurseStation">
        update nurse_station
        set station_picture_url = #{stationPictureUrl}
        where nurse_station_code = #{nurseStationCode}
    </update>

    <update id="updateNurseStationIntroduceByHead" parameterType="NurseStation">
        update nurse_station
        set station_introduce_picture_url = #{stationIntroducePictureUrl}
        where nurse_station_code = #{nurseStationCode}
    </update>

    <select id="selectNurseStationListByNames" parameterType="String"
            resultMap="NurseStationResult">
        <include refid="selectNurseStationVo"/>
        <where>
            <if test="nurseStationIdList != null and nurseStationIdList.size() > 0">
                and nurse_station_name in
                <foreach item="nurseStationName" collection="nurseStationIdList" open="(" separator="," close=")">
                    #{nurseStationName}
                </foreach>
            </if>
        </where>
    </select>

    <select id="selectNurseStationListByIds" resultType="com.xinelu.manage.vo.nursestation.NurseStationByUserVO">
        <include refid="selectNurseStationVo"/>
        <where>
            <if test="nurseStationIdList != null and nurseStationIdList.size() > 0">
                and id in
                <foreach item="nurseStationId" collection="nurseStationIdList" open="(" separator="," close=")">
                    #{nurseStationId}
                </foreach>
            </if>
            <if test="nurseStationCode != null  and nurseStationCode != ''">
                and nurse_station_code = #{nurseStationCode}
            </if>
            <if test="nurseStationName != null  and nurseStationName != ''">
                and nurse_station_name like concat('%', #{nurseStationName}, '%')
            </if>
        </where>
    </select>

    <select id="getNurseStationCode" parameterType="NurseStation" resultType="NurseStation">
        select id,
        area_code,
        user_id,
        nurse_station_code,
        nurse_station_name,
        nurse_station_type,
        agency_introduce,
        nurse_station_description,
        longitude,
        latitude,
        phone,
        address,
        duty_person,
        duty_phone,
        station_picture_url,
        station_introduce_picture_url,
        sort,
        create_by,
        create_time,
        update_by,
        update_time
        from nurse_station
        <where>
            <if test="nurseStationCode != null  and nurseStationCode != ''">
                and nurse_station_code = #{nurseStationCode}
            </if>
        </where>
    </select>


    <insert id="insertNurseStationImportList" parameterType="java.util.List">
        insert into nurse_station(
        area_code,
        user_id,
        nurse_station_code,
        nurse_station_name,
        nurse_station_type,
        agency_introduce,
        nurse_station_description,
        longitude,
        latitude,
        phone,
        address,
        duty_person,
        duty_phone,
        station_picture_url,
        station_introduce_picture_url,
        sort,
        create_by,
        create_time,
        update_by,
        update_time
        ) values
        <foreach item="NurseStation" index="index" collection="list" separator=",">
            (
            #{NurseStation.areaCode},
            #{NurseStation.userId},
            #{NurseStation.nurseStationCode},
            #{NurseStation.nurseStationName},
            #{NurseStation.nurseStationType},
            #{NurseStation.agencyIntroduce},
            #{NurseStation.nurseStationDescription},
            #{NurseStation.longitude},
            #{NurseStation.latitude},
            #{NurseStation.phone},
            #{NurseStation.address},
            #{NurseStation.dutyPerson},
            #{NurseStation.dutyPhone},
            #{NurseStation.stationPictureUrl},
            #{NurseStation.stationIntroducePictureUrl},
            #{NurseStation.sort},
            #{NurseStation.createBy},
            #{NurseStation.createTime},
            #{NurseStation.updateBy},
            #{NurseStation.updateTime}
            )
        </foreach>
    </insert>

    <select id="getNurseItemCode" parameterType="NurseStationItem" resultType="NurseStationItem">
        select id,
        nurse_station_id,
        nurse_type_id,
        user_id,
        item_picture_url,
        nurse_item_code,
        nurse_item_name,
        nurse_item_content,
        advance_appoint_duration,
        sort,
        create_by,
        create_time,
        update_by,
        update_time
        from nurse_station_item
        <where>
            <if test="nurseItemCode != null  and nurseItemCode != ''">
                and nurse_item_code = #{nurseItemCode}
            </if>
        </where>
    </select>

    <update id="updateNurseStationItemByHead" parameterType="NurseStationItem">
        update nurse_station_item
        set item_picture_url = #{itemPictureUrl}
        where nurse_item_code = #{nurseItemCode}
    </update>

    <select id="getNurseStationName" resultType="int">
        SELECT
        COUNT( 1 )
        FROM
        nurse_station
        <where>
            <if test="areaCode != null ">
                and area_code = #{areaCode}
            </if>
            <if test="nurseStationName != null  and nurseStationName != ''">
                and nurse_station_name = #{nurseStationName}
            </if>
        </where>
    </select>

    <select id="getSysDictNurseTypeCode" resultType="com.xinelu.manage.vo.nursestation.NurseStationVO">
        SELECT sdt.dict_name,
               sdd.dict_label nurseTypeName,
               sdd.dict_value nurseTypeCode
        FROM sys_dict_type sdt
                 LEFT JOIN sys_dict_data sdd ON sdd.dict_type = sdt.dict_type
        WHERE sdt.dict_type = 'nurse_type_code'
    </select>

    <select id="selectNurseStationLabelByIds" resultType="int">
        SELECT COUNT(1) from nurse_station_label where nurse_station_id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

    <select id="getNurseStationType" parameterType="NurseType"
            resultType="NurseType">
        SELECT
        nt.nurse_type_name,
        nt.nurse_type_code
        FROM
        nurse_type nt
        <where>
            <if test="nurseTypeCodeList != null  and nurseTypeCodeList.size()>0 ">
                and nt.nurse_type_code in
                <foreach item="nurseTypeCode" collection="nurseTypeCodeList" open="(" separator="," close=")">
                    #{nurseTypeCode}
                </foreach>
            </if>
        </where>
    </select>

    <select id="selectStationLabelByStationId" parameterType="Long"
            resultType="NurseStationLabel">
        select id,
        nurse_station_id,
        user_id,
        label_code,
        label_description,
        sort,
        create_by,
        create_time,
        update_by,
        update_time
        from nurse_station_label
        where
        <if test="nurseStationId != null ">
            nurse_station_id = #{nurseStationId}
        </if>
    </select>


    <select id="getNurseStationByUserId" parameterType="com.xinelu.manage.vo.nursestation.NurseStationSysUserVO"
            resultType="com.xinelu.manage.vo.nursestation.NurseStationSysUserVO">
        SELECT
        su.user_id,
        su.nurse_station_ids
        FROM
        sys_user su
        <where>
            <if test="userId != null ">
                and su.user_id = #{userId}
            </if>
        </where>
        order by su.create_time desc
    </select>

    <select id="getNurseStationIds" parameterType="com.xinelu.manage.vo.nursestation.NurseStationSysUserVO"
            resultType="com.xinelu.manage.vo.nursestation.NurseStationSysUserVO">
        SELECT
        ns.id nurseStationId,
        ns.nurse_station_name,
        ns.agency_introduce,
        ns.station_picture_url,
        ns.station_introduce_picture_url
        FROM
        nurse_station ns
        <where>
            <if test="nurseStationIdsList != null  and nurseStationIdsList.size()>0 ">
                and ns.id in
                <foreach item="nurseStationIds" collection="nurseStationIdsList" open="(" separator="," close=")">
                    #{nurseStationIds}
                </foreach>
            </if>
        </where>
        order by ns.create_time desc
    </select>

    <select id="getAllNurseStationInfo" resultType="com.xinelu.manage.dto.nursestation.NurseStationImportDTO">
        select nurse_station_name, phone, address, duty_person, duty_phone, agency_introduce FROM nurse_station
        <where>
            <if test="nurseStationNameList != null and nurseStationNameList.size() > 0">
                and nurse_station_name in
                <foreach item="nurseStationName" collection="nurseStationNameList" open="(" separator="," close=")">
                    #{nurseStationName}
                </foreach>
            </if>
        </where>
    </select>

    <select id="getNurseStationCount" resultType="int">
        SELECT count( 1 ) nurseStationCount FROM nurse_station
        <where>
            <if test="idList != null and idList.size() > 0">
                and id in
                <foreach item="id" collection="idList" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
    </select>

    <select id="getNurseStationById" parameterType="long" resultType="nurseStation">
        <include refid="selectNurseStationVo"/>
        where id = #{stationId}
    </select>

    <update id="updateStationWeChatCodeUrl">
        update nurse_station
        set station_wechat_code_url = #{stationWeChatCodeUrl},
            update_time             = now()
        where id = #{stationId}
    </update>
</mapper>
