<?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.boman.web.core.mapper.ToQianshanPersonnerMapper">

    <resultMap type="com.boman.web.core.domain.ToQianshanPersonner" id="ToQianshanPersonnerResult">
        <result property="id" column="id"/>
        <result property="hiAdress" column="hi_adress"/>
        <result property="riskLv" column="risk_lv"/>
        <result property="address" column="address"/>
        <result property="qu" column="QU"/>
        <result property="sex" column="sex"/>
        <result property="hiName" column="hi_name"/>
        <result property="hiDestinationStreet" column="hi_destination_street"/>
        <result property="fxdjLy" column="FXDJ_LY"/>
        <result property="hiDestinationRc" column="hi_destination_rc"/>
        <result property="hiPhone" column="hi_phone"/>
        <result property="hiDate" column="hi_date"/>
        <result property="hiIcd" column="hi_icd"/>
        <result property="shi" column="SHI"/>
        <result property="sheng" column="SHENG"/>
        <result property="hiDestinationArea" column="hi_destination_area"/>
        <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>

    <insert id="insertToQianshanPersonner">
        insert into to_qianshan_personner
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="hiAdress != null">hi_adress,</if>
            <if test="riskLv != null">risk_lv,</if>
            <if test="address != null">address,</if>
            <if test="qu != null">QU,</if>
            <if test="sex != null">sex,</if>
            <if test="hiName != null">hi_name,</if>
            <if test="hiDestinationStreet != null">hi_destination_street,</if>
            <if test="fxdjLy != null">FXDJ_LY,</if>
            <if test="hiDestinationRc != null">hi_destination_rc,</if>
            <if test="hiIcd != null">hi_icd,</if>
            <if test="hiPhone != null">hi_phone,</if>
            <if test="hiDate != null">hi_date,</if>
            <if test="shi != null">SHI,</if>
            <if test="sheng != null">SHENG,</if>
            <if test="hiDestinationArea != null">hi_destination_area,</if>
            create_time
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="hiAdress != null">#{hiAdress},</if>
            <if test="riskLv != null">#{riskLv},</if>
            <if test="address != null">#{address},</if>
            <if test="qu != null">#{qu},</if>
            <if test="sex != null">#{sex},</if>
            <if test="hiName != null">#{hiName},</if>
            <if test="hiDestinationStreet != null">#{hiDestinationStreet},</if>
            <if test="fxdjLy != null">#{fxdjLy},</if>
            <if test="hiDestinationRc != null">#{hiDestinationRc},</if>
            <if test="hiIcd != null">#{hiIcd},</if>
            <if test="hiPhone != null">#{hiPhone},</if>
            <if test="hiDate != null">#{hiDate},</if>
            <if test="shi != null">#{shi},</if>
            <if test="sheng != null">#{sheng},</if>
            <if test="hiDestinationArea != null">#{hiDestinationArea},</if>
            sysdate()
        </trim>
    </insert>
    <select id="toQianshanList" resultType="java.util.Map">
        select hi_adress,risk_lv,address,QU,sex,hi_name,hi_destination_street,FXDJ_LY,hi_destination_rc,hi_phone,hi_date,hi_icd as SFZ_ID,SHI,SHENG,hi_destination_area
        from to_qianshan_personner
        <where>
            1=1
            <if test="startTime != null  and startTime != '' and endTime != null  and endTime != ''">
            and DATE_FORMAT(hi_date,'%Y-%m-%d %H:%i:%s') &gt;= DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s')
            and DATE_FORMAT(hi_date,'%Y-%m-%d %H:%i:%s') &lt;= DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s')
            </if>
            <if test="hiIcd != null  and hiIcd != ''">and hi_icd = #{hiIcd}</if>
            <if test="hiName != null  and hiName != ''">and hi_name like concat(#{hiName}, '%')</if>
            <if test="hiDestinationRc != null  and hiDestinationRc != ''">and hi_destination_rc like concat('%', #{hiDestinationRc}, '%')</if>
        </where>
        ORDER BY hi_date DESC

    </select>
    <select id="getNewInfo" resultMap="ToQianshanPersonnerResult">
        select hi_adress,risk_lv,address,QU,sex,hi_name,hi_destination_street,FXDJ_LY,hi_destination_rc,hi_phone,hi_date,hi_icd ,SHI,SHENG,hi_destination_area
        from to_qianshan_personner order by hi_date desc limit 1;
    </select>


</mapper>