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



	<select id="queryByPage" parameterType="io.renren.modules.app.entity.ZhxxEntity"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select z.dhbm,z.hs,z.dhmc,z.zmj,z.zje,z.dwze
		yjyjje,z.gryjje,s.value
		hwjg,z.jsbz,z.jkbz,z.sfdz,z.sffp,z.yjje
		from
		zhxx z,sys_dict s where
		z.hwjg=s.id
		<if test=" dwbm!=null and dwbm!='' ">
			and z.dwbm like CONCAT(#{dwbm},"%")
		</if>
		<if test=" xmbm!=null and xmbm!='' ">
			and z.xmbm like CONCAT(#{xmbm},"%")
		</if>
		<if test=" sfdz!=null and sfdz!='' ">
			and z.sfdz like CONCAT(#{sfdz},"%")
		</if>
		<if test=" sffp!=null and sffp!='' ">
			and z.sffp like CONCAT(#{sffp},"%")
		</if>

	</select>

	<update id="updatezhxx" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		dhmc=#{dhmc},zmj=#{zmj},zje=#{zje},hwjg=#{hwjg},jsbz=#{jsbz},jkbz=#{jkbz}
		where dhbm=#{dhbm}
	</update>

	<select id="selectdw" resultType="io.renren.modules.app.entity.XlkEntity">
		select dwmc,dwbm from sfdw
		where 1=1

	</select>

	<select id="selectyh" resultType="io.renren.modules.app.entity.XlkEntity">
		select yhmc,yhbm from yhxx
		where 1=1

	</select>

	<select id="selectjsfs" resultType="io.renren.modules.app.entity.XlkEntity">
		select billname,billcode from
		h_jsfs
		where 1=1

	</select>

	<insert id="insertyj" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		ywpz(djbh,djlx,djrq,dwbm,cbwdbm,bank_code,gzdbm,zph,je,czybm,czyxm,bz,pzz,pzh,flsh,jsfs,kjqj,syxm,dhbm,fpfs,pzzt,xgbm,jkfx,shrbm,shrxm)
		values(#{djbh},#{djlx},#{djrq},#{dwbm},#{cbwdbm},#{bankCode},#{gzdbm},#{zph},#{je},#{czybm},#{czyxm},#{bz},#{pzz},#{pzh},#{flsh},#{jsfs},#{kjqj},#{syxm},#{dhbm},#{fpfs},'1',#{xgbm},#{jkfx},#{shrbm},#{shrxm})
	</insert>

	<insert id="insertyjmx" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		yjmx(yjmxbm,djbh,dhbm,je,djrq,jkfx)
		values(#{yjmxbm},#{djbh},#{dhbm},#{je},#{djrq},#{jkfx})
	</insert>

	<select id="selectfwbydh" parameterType="java.lang.String"
		resultType="Double">
		select sum(grje) from fwxx where dhbm=#{dhbm}
	</select>
	<!-- 新页面 -->
	<select id="queryByPageC" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select
		distinct
		y.djbh,s.dwmc,s.dwbm,x.xmmc,q.xqmc,s.dz,y.djrq,a.yhmc,y.je,y.czyxm,h.billname,y.zph,y.bz,y.shzt
		from ywpz y,yjmx m,zhxx z,xm x,sfdw s,h_jsfs h,yhxx a,xqxx q
		where
		y.dwbm=s.dwbm and
		y.bank_code=a.yhbm and y.jsfs=h.billcode and
		y.djbh=m.djbh and m.dhbm=z.dhbm and z.xmbm=x.xmbm and x.xqbm=q.xqbm
		and y.djlx='01'
		<if test=" djbh!=null and djbh!='' ">
			and y.djbh like CONCAT(#{djbh},"%")
		</if>
		<if test=" dwbm!=null and dwbm!='' ">
			and y.dwbm like CONCAT(#{dwbm},"%")
		</if>
		<if test=" bankCode!=null and bankCode!='' ">
			and y.bank_code like CONCAT(#{bankCode},"%")
		</if>
		<if test=" jsfs!=null and jsfs!='' ">
			and y.jsfs like CONCAT(#{jsfs},"%")
		</if>
		<if test=" dhbm!=null and dhbm!='' ">
			and y.dhbm like CONCAT(#{dhbm},"%")
		</if>
		<if test=" xmbm!=null and xmbm!='' ">
			and x.xmbm like CONCAT(#{xmbm},"%")
		</if>
		<if test=" shzt!=null and shzt!='' ">
			and y.shzt like CONCAT(#{shzt},"%")
		</if>
		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		<!-- order by y.djbh desc -->
		GROUP BY y.djbh
		order by y.djrq,y.djbh desc
	</select>

	<select id="selectck" parameterType="java.util.Map"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select
		y.djbh,s.dwmc,a.yhmc,y.je,y.czyxm,h.billname,y.djrq,y.zph,y.bz,y.shzt,y.shrxm,y.shrq,y.jsfs,y.bank_code
		bankCode
		from
		ywpz y,sfdw
		s,yhxx a,h_jsfs h where
		y.dwbm=s.dwbm and
		y.bank_code=a.yhbm
		and y.jsfs=h.billcode and
		y.djbh=#{djbh}
	</select>

	<select id="selectyjmx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.DhbmyjEntity">
		select DISTINCT m.dhbm,z.dhmc,z.zmj,z.zje,m.je,z.dwze
		yjyjje,z.gryjje,s.value hwjg,z.jsbz,z.jkbz,z.yjje from yjmx
		m,zhxx z
		,sys_dict
		s where
		m.dhbm=z.dhbm and z.hwjg=s.id and m.djbh=#{id}
	</select>

	<delete id="deletedj" parameterType="java.lang.String">
		delete from ywpz where
		djbh=#{id}
	</delete>
	<delete id="deletedjmx" parameterType="java.lang.String">
		delete from yjmx where
		djbh=#{id}
	</delete>
	<select id="selectsyscode" parameterType="java.lang.String"
		resultType="java.lang.String">
		select id from sys_dict where value=#{id} and type='02'
	</select>

	<select id="queryByCount" parameterType="java.lang.String"
		resultType="java.lang.String">
		select max(substr(djbh,17,4)) from ywpz where
		substr(djrq,1,7)=substr(#{date},1,7) and djlx='01'

	</select>

	<select id="selectyw" parameterType="java.lang.String"
		resultType="java.lang.String">
		select shzt from ywpz where dwbm=#{id} and djlx='01'
	</select>

	<select id="selectdj01" resultType="io.renren.modules.app.entity.YwpzEntity">
		select shzt,dwbm from ywpz
		where djlx='01'
	</select>

	<select id="selectdwjjl" parameterType="io.renren.modules.app.entity.JkbzEntity"
		resultType="io.renren.modules.app.entity.JkbzEntity">
		select (case
		jsbz when '1' then '按金额' when '0' then '按面积'
		else '' END)
		jsbz,dwjjl,grjjl,(case
		fwyt when '1' then '非住宅' when '0' then
		'住宅' else
		'' END)
		fwyt,bm 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>
	</select>

	<select id="selectzhmjh" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select sum(zmj) zmj from zhxx where dhbm in(select dhbm
		from yjmx where djbh=#{id})
	</select>

	<select id="selectdhmjjkbz" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select zmj,jkbz from zhxx where dhbm=#{id}
	</select>

	<update id="updateywpzdjrq" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update ywpz set
		djrq=#{djrq} where djbh=#{djbh}
	</update>

	<update id="updateyjmxdjrq" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update yjmx set
		djrq=#{djrq} where djbh=#{djbh}
	</update>

	<select id="selectallfw" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select * from fwxx where dhbm=#{id}
	</select>

	<select id="selectzhxx" resultType="io.renren.modules.app.entity.ZhxxEntity">
		select * from zhxx where 1=1
	</select>

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

	<select id="selectxlrdhbm" resultType="io.renren.modules.app.entity.ZhxxEntity">
		select dhbm from fwxx
		where LENGTH(fwbm)=7 GROUP BY dhbm
	</select>

	<select id="selectfwallbydh" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select * from fwxx where dhbm=#{id}
	</select>

	<select id="selectzhxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select * from zhxx where dhbm=#{id}
	</select>

	<update id="updatedwxqxg" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update ywpz set
		djrq=#{djrq},bank_code=#{bankCode},jsfs=#{jsfs},zph=#{zph} where
		djbh=#{djbh}
	</update>

	<select id="selecttest" resultType="io.renren.modules.app.entity.ZhxxEntity">
		<!-- select xmmc,dhmc,yijiao yjyjje,shijiao yjsjje from test -->
		select x.xmbm,t.dhmc,t.xmmc from test t,xm x where t.xmmc=x.xmmc
	</select>

	<select id="selectdhbmbytest" parameterType="io.renren.modules.app.entity.ZhxxEntity"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select dhbm from zhxx where xmbm=#{xmbm} and dhmc=#{dhmc}
	</select>

	<update id="updatedhbmtest" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update test set
		dhbm=#{dhbm} where xmmc=#{xmmc} and dhmc=#{dhmc}
	</update>

	<select id="selectdwdhyj" resultType="io.renren.modules.app.entity.YwpzEntity">
		select m.djbh,m.dhbm,m.je,t.shijiao yjsjje from test t,yjmx m where t.dhbm=m.dhbm  and SUBSTR(m.djbh FROM 1 FOR 2)='01'
	</select>
	
	<select id="selectywpzdwbm" parameterType="java.lang.String" resultType="io.renren.modules.app.entity.YwpzEntity">
		select dwbm from ywpz where djbh=#{id}
	</select>
	
	<select id="selectsfdwzck" parameterType="java.lang.String" resultType="io.renren.modules.app.entity.YwpzEntity">
		select dwbm,zckje from sfdw where dwbm=#{id}
	</select>
	
	<update id="updatedwzck" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update sfdw set zckje=#{zckje} where dwbm=#{dwbm}
	</update>
	
	<update id="updatezhxxdwze" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set dwze=#{dwze} where dhbm=#{dhbm}
	</update>
	
	<update id="updateywpzje" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update ywpz set je=#{yjsjje} where djbh=#{djbh}
	</update>
	
	<update id="updateyjmxje" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update yjmx set je=#{yjsjje} where djbh=#{djbh}
	</update>
	
	<select id="selectfwyjhs" parameterType="String" resultType="int">
		select count(*) from fwxx where dhbm=#{id} and sfyj='1'
	</select>
	
	<select id="selectxmmcbydhbm" parameterType="String" resultType="String">
		select xmmc from xm where xmbm=(select xmbm from zhxx where dhbm=#{id})
	</select>

</mapper>