<?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="org.sky.scientific.mapper.YsRyrgfyMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="ResultVoMap" type="org.sky.scientific.pojo.vo.YsRyrgfyVO">
        <result column="id" property="id"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="XM_ID" property="xmId"/>
        <result column="technician_id" property="technicianId"/>
        <result column="unicode" property="unicode"/>
        <result column="ZZSC" property="zzsc"/>
        <result column="PJRGFY" property="pjrgfy"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>

    <delete id="physicalDeleteByIds">
        DELETE FROM kd_ys_ryrgfy
        WHERE id IN
        <foreach item="id" collection="list" separator="," close=")" open="(" index="">
            #{id}
        </foreach>
    </delete>

    <select id="selectYsRyrgfyPage" resultMap="ResultVoMap">
        select
            fy.*,
            t.unicode unicode,t.name as 'technician.name',t.number as 'technician.number',t.id_card as 'technician.id_card', t.nature as 'technician.nature'
        from kd_ys_ryrgfy fy
        LEFT JOIN kd_technician t on fy.technician_id = t.id
        WHERE fy.XM_ID = #{ysRyrgfy.xmId}

    </select>

    <select id="countByUnicodeAndYearMonth" resultType="java.lang.Long">
        SELECT count(*)
        from kd_ys_ryrgfy r
        left  join kd_technician t on t.id = r.technician_id
        where t.unicode = #{unicode} and t.year_and_month <![CDATA[>=]]>  #{yearAndMonth}
    </select>

</mapper>
