<?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="io.renren.modules.app.dao.YhxxDao">

	<!-- 可根据自己的需求，是否要使用 -->
	<resultMap type="io.renren.modules.app.entity.YhxxEntity" id="yhxxMap">
		<result property="yhbm" column="yhbm" />
		<result property="yhmc" column="yhmc" />
		<result property="lxr" column="lxr" />
		<result property="lxdh" column="lxdh" />
		<result property="dz" column="dz" />
		<result property="yhzh" column="yhzh" />
		<result property="gzdbm" column="gzdbm" />
		<result property="hskm" column="hskm" />
		<result property="ztbm" column="ztbm" />
	</resultMap>

	<select id="queryByPage" parameterType="io.renren.modules.app.entity.YhxxEntity"
		resultType="io.renren.modules.app.entity.YhxxEntity">

		select y.yhbm,y.yhmc,y.lxr,y.lxdh,y.dz,y.yhzh,k.kmmc hskm,k.km ztbm from yhxx y,h_km k where y.hskm=k.km

		<if test=" yhbm!=null and yhbm!='' ">
			and yhbm like CONCAT(#{yhbm},"%")
		</if>
		<if test=" yhmc!=null and yhmc!='' ">
			and yhmc like CONCAT(#{yhmc},"%")
		</if>
		<if test=" lxr!=null and lxr!='' ">
			and lxr like CONCAT(#{lxr},"%")
		</if>
		<if test=" lxdh!=null and lxdh!='' ">
			and lxdh like CONCAT(#{lxdh},"%")
		</if>
		<if test=" dz!=null and dz!='' ">
			and dz like CONCAT(#{dz},"%")
		</if>
		<if test=" yhzh!=null and yhzh!='' ">
			and yhzh like CONCAT(#{yhzh},"%")
		</if>
		<if test=" gzdbm!=null and gzdbm!='' ">
			and gzdbm like CONCAT(#{gzdbm},"%")
		</if>
		<if test=" hskm!=null and hskm!='' ">
			and hskm like CONCAT(#{hskm},"%")
		</if>
		<if test=" ztbm!=null and ztbm!='' ">
			and ztbm like CONCAT(#{ztbm},"%")
		</if>
       order by yhbm desc
	</select>

	<select id="selectyhke" resultType="io.renren.modules.app.entity.XlkEntity">
		select km ztbm,kmmc hskm,pydm from h_km where kmlbbm='1'
	</select>
	
	<select id="queryyhbm"  resultType="string">
    SELECT yhbm FROM  yhxx WHERE LENGTH(yhbm)>=8 ORDER BY yhbm  DESC LIMIT 1
    </select>


</mapper>