<?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.ZhxxSelectDao">
	<select id="selectZhxx" parameterType="io.renren.modules.app.entity.ZhxxSelectEntity" resultType="io.renren.modules.app.entity.ZhxxSelectEntity">
		   select t1.*,
      case when t1.sffp='是' then t1.dwyjje else t1.dwze end dwje
      from
       (select zhxx.dhbm,   
             zhxx.dhmc,
             zhxx.yjje,
             zhxx.jsbz,    
             sfdw.dwmc,
             xm.xmmc,      
             hwlx.value hwlx,  
             hwjg.value hwjg,
             zhxx.zh,      
             zhxx.hs,    
             zhxx.lcs,    
             zhxx.drs,     
             case when zhxx.sfdt='1' then '有电梯' else '无电梯' end sfdt,   
             case when zhxx.sfgf='1' then '公有住房' elSe '商品房' end sfgf,   
             <!-- date_format(str_to_date(zhxx.zgrq,'%m/%d/%Y %H:%i:%s'),'%Y-%m-%d') zgrq, -->
             zhxx.zgrq,
             zhxx.nx,      
             zhxx.zje,     
             zhxx.zmj,   
             zhxx.dwyjje,
             zhxx.gryjje, 
             zhxx.zqje,   
             zhxx.jkbz, 
             zhxx.grjjl,
             case when zhxx.sffp='1' then '是' else '否' end sffp,    
             zhxx.ggsy,   
             zhxx.ljlx,    
             zhxx.xhje,   
             zhxx.xhjx,zhxx.dwze
        from zhxx,
             sys_dict hwlx,
             sys_dict hwjg,
             sfdw,
             xm
       where sfdw.dwbm = zhxx.dwbm
             and xm.xmbm = zhxx.xmbm
             and hwlx.id = zhxx.hwlx
             
             and hwjg.id = zhxx.hwjg
             AND ((zhxx.Wygsbm like '%${wygsbm}%') or (zhxx.Wygsbm is null))
             AND ((zhxx.Gwhbm like '%${gwhbm}%') or (zhxx.Gwhbm is null))
             AND ((zhxx.XMBM like '%${xmbm}%') or (zhxx.XMBM is null))) t1
        order by t1.dhbm
	</select>

    <select id="selectdhgryj" parameterType="io.renren.modules.app.entity.ZhxxSelectEntity" resultType="Double">
      select IFNULL(sum(je),0) yjje from ywpzmx where  ((SUBSTR(djbh FROM 5 FOR 2) in('03','05')) or SUBSTR(djbh FROM 1 FOR 2) in('03','05')) and dhbm=#{dhbm}
    </select>
    
    <select id="selectdhgryj2" parameterType="io.renren.modules.app.entity.ZhxxSelectEntity" resultType="Double">
    select IFNULL(sum(bjje),0) yjyjje from ywpzmx where ((SUBSTR(djbh FROM 5 FOR 2) in('13')) or SUBSTR(djbh FROM 1 FOR 2) in('13')) and dhbm=#{dhbm}
    </select>

</mapper>