<?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.ZhxxDao">

    <!-- 幢号查询 -->
    <select id="queryByPage" parameterType="io.renren.modules.app.entity.ZhxxEntity" resultType="io.renren.modules.app.entity.ZhxxEntity">
    SELECT t4.xqmc,t5.dwmc,t6.gwhmc,a.*,(select count(*) from dyxx where dyxx.dhbm = a.dhbm) zhcon FROM (
    SELECT  t.gwhbm,t1.dwbm,t1.xqbm,t1.xmbm,t1.xmmc,t.dhbm,t.dhmc,t2.wygsbm,t2.wygsmc,t.hwjg ,t.hwlx,t.zh,t.drs,t.lcs,t.hs,t.jsbz,t.jkbz,t.grjjl,t.zje,t.zmj,t.rfmj,t.sfrf,t.jkmj,t.sfjk,t.zgrq,t.nx,t.yzkm,t.sfdt,t.sfgf
    FROM zhxx t 
    LEFT JOIN xm t1 ON t.xmbm=t1.xmbm
    LEFT JOIN wygsxx t2 ON t.wygsbm=t2.wygsbm) a 
    LEFT JOIN xqxx t4 ON a.xqbm = t4.xqbm
    LEFT JOIN sfdw t5 ON a.dwbm = t5.dwbm 
    LEFT JOIN gwhxx t6 ON a.gwhbm = t6.gwhbm
    WHERE 1=1 
    <if test=" xmbm!=null and xmbm!='' ">
    and a.XMBM=#{xmbm}
    </if>
    <if test=" dhmc!=null and dhmc !='' ">
    and a.dhmc  like CONCAT("%",#{dhmc},"%") 
    </if>
    order by DHBM desc
    </select>
    
    <select id="querydhbm"  resultType="string">
    SELECT dhbm FROM  zhxx WHERE LENGTH(dhbm)>=8 ORDER BY dhbm  DESC LIMIT 1
    </select>
    
    <select id="gwh"  resultType="io.renren.modules.app.entity.WtTyEntity">
    SELECT gwhbm,gwhmc FROM gwhxx
    </select>
    
    <select id="wygs"  resultType="io.renren.modules.app.entity.WtTyEntity">
    SELECT wygsbm,wygsmc FROM wygsxx
    </select>
    
    <select id="fwjg"  resultType="io.renren.modules.app.entity.WtTyEntity">
     SELECT id as hwjg,VALUE as hwjgmc FROM  sys_dict   WHERE TYPE = '02' 
    </select>
    
     <select id="fwlx"  resultType="io.renren.modules.app.entity.WtTyEntity">
     SELECT id as hwlx,VALUE as hwlxmc FROM  sys_dict   WHERE TYPE = '01' 
    </select>
    
    <select id="kfdw"  resultType="io.renren.modules.app.entity.WtTyEntity">
     select a.dwbm,b.dwmc from XM a
     left join sfdw b on a.dwbm = b.dwbm where 1=1
     <if test=" xmbm !=null and xmbm !='' ">
     AND  a.xmbm= #{xmbm}
	 </if>
    </select>
    
    <select id="dwjcl"  parameterType="java.util.Map"  resultType="io.renren.modules.app.entity.WtTyEntity">
     SELECT bm,mc,dwjjl ftbz FROM JKBZ WHERE 1=1 
     <if test=" fwyt !=null and fwyt !='' ">
     AND  FWYT = #{fwyt}
	 </if>
	 <if test=" jsbz !=null and jsbz !='' ">
     AND JSBZ = #{jsbz}
	 </if>
     ORDER BY BM 
     </select>
    
    <select id="yzhskm"  resultType="io.renren.modules.app.entity.WtTyEntity">
      select KM,KMMC from H_KM where KMLBBM='3' order by km
    </select>
    
    <select id="selectkm" parameterType="java.lang.String"  resultType="io.renren.modules.app.entity.WtTyEntity">
      select km,kmmc from h_km where kmmc=#{id}
    </select>
    
    <select id="selectzhxx" parameterType="java.lang.String"  resultType="io.renren.modules.app.entity.ZhxxEntity">
     select dhmc from zhxx where xmbm=#{id}
    </select>

    <select id="selectDhbmList" resultType="io.renren.modules.app.entity.ZhxxEntity">
        select xmbm,dhmc,dhbm from zhxx
        where xmbm = #{xmbm}
          and dhmc in
        <foreach collection="dhmcList" item="item" index="index" separator="," open=" (" close=")">
            #{item}
        </foreach>
    </select>

    <update id="updatezhxxyjje" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		yjje=#{yjje} where dhbm=#{dhbm}
	</update>
    
    
    
    
</mapper>