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

	<select id="selectxm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select xmmc,xmbm from xm
		where
		dwbm=#{bm}

	</select>

	<select id="selectzh" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select dhmc,dhbm from zhxx
		where xmbm=#{bm}

	</select>

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

	</select>

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

	</select>

	<select id="selectfwbm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		<!-- select fwbm,mphm,xm,mj,fwje,grjjl,jsbz from fwxx where dhbm=#{bm} 
			and sfjq='0' -->

		select DISTINCT t.*,m.je from (SELECT
		fwbm,
		mphm,
		xm,
		mj,
		fwje,
		grjjl,
		jsbz
		FROM
		fwxx
		where dhbm = #{bm}
		AND sfjq = '0')t
		LEFT JOIN ywpzmx m ON t.fwbm
		= m.fwbm
		AND ((SUBSTR(m.djbh FROM 5 FOR 2) = '03') or (SUBSTR(m.djbh
		FROM 1 FOR 2)
		= '03')) and m.dhbm =#{bm}

	</select>

	<select id="selectfwxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select fwbm,mphm,xm,cczh,sfzh,mj,fwje,grjjl,fpbh,jsbz from
		fwxx
		where
		fwbm=#{bm}

	</select>
	<update id="updatefwxxsfyj" parameterType="java.lang.String">
		update fwxx set
		sfyj='1' where fwbm=#{id}
	</update>
	<select id="selectywpzmx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select fwbm from ywpzmx where djbh=#{id}
	</select>
	<update id="updatefwxxsfyj2" parameterType="java.lang.String">
		update fwxx set
		sfyj='0' where fwbm=#{id}
	</update>

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

	</select>

	<insert id="insertgr" 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,czrq,djbm)
		values(#{djbh},#{djlx},#{djrq},#{dwbm},#{cbwdbm},#{bankCode},#{gzdbm},#{zph},#{je},#{czybm},#{czyxm},
		#{bz},#{pzz},#{pzh},#{flsh},#{jsfs},#{kjqj},#{syxm},#{dhbm},#{fpfs},#{pzzt},#{xgbm},#{jkfx},#{shrbm},#{shrxm},#{czrq},#{djbm})
	</insert>

	<insert id="insertgrmx" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into ywpzmx(
		djbh,dhbm,fwbm,bjje,je,jdf
		) values(
		#{djbh},#{dhbm},#{fwbm},#{je},#{je},'0'
		)
	</insert>

	<select id="queryByPage" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select
		distinct
		y.djbh,y.dwbm,y.djrq,y.kjqj,y.bank_code
		bankCode,y.jsfs,m.fwbm,f.cczh,f.mphm,f.dhbm,f.mj,f.fwje,f.grjjl,f.jsbz,y.zph,y.djbm,s.dwmc,q.xqmc,x.xmmc,
		z.dhmc,f.xm,f.sfzh,h.billname,a.yhmc,y.je,f.dz,y.czyxm,(case
		y.shzt
		when '1' then '已复核' when '0' then '未复核' else '' END)
		shzt,y.bz,y.shrxm,y.shrq
		from
		ywpzmx m,ywpz y,fwxx f,xqxx q,xm x,zhxx
		z,h_jsfs h,yhxx a,sfdw s
		where
		m.djbh=y.djbh and
		m.fwbm=f.fwbm and
		m.dhbm=z.dhbm and
		z.xmbm=x.xmbm and
		x.xqbm=q.xqbm and y.bank_code=a.yhbm
		and
		y.jsfs=h.billcode and y.dwbm=s.dwbm and y.djlx='03'

		<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=" xqbm!=null and xqbm!='' ">
			and q.xqbm like CONCAT(#{xqbm},"%")
		</if>
		<if test=" zph!=null and zph!='' ">
			and y.zph like CONCAT("%",#{zph},"%")
		</if>
		<if test=" xmbm!=null and xmbm!='' ">
			and x.xmbm like CONCAT(#{xmbm},"%")
		</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=" shzt!=null and shzt!='' ">
			and y.shzt like CONCAT(#{shzt},"%")
		</if>
		<if test=" xm!=null and xm!='' ">
			and f.xm like CONCAT(#{xm},"%")
		</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 -->
		order by y.djrq,djbh desc
	</select>

	<delete id="deletemx" parameterType="java.lang.String">
		delete from ywpzmx where
		djbh=#{id}
	</delete>

	<delete id="deleteywpz" parameterType="java.lang.String">
		delete from ywpz where
		djbh=#{id}
	</delete>
	<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='03'

	</select>

	<update id="updatefwxx" parameterType="io.renren.modules.app.entity.FwxxEntity">
		update fwxx set
		xm=#{xm},grjjl=#{grjjl},jsbz=#{jsbz},mj=#{mj},lxdh=#{sjh} where
		fwbm=#{fwbm}
	</update>

	<update id="updatefwxxbjym" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update fwxx set
		xm=#{xm},grjjl=#{grjjl},jsbz=#{jsbz},mj=#{mj},fwje=#{fwje} where
		fwbm=#{fwbm}
	</update>

	<update id="updatefwxx222" parameterType="io.renren.modules.app.entity.FwxxEntity">
		update fwxx set
		xm=#{xm},grjjl=#{grjjl},jsbz=#{jsbz},fwje=#{fwje},lxdh=#{sjh} where
		fwbm=#{fwbm}
	</update>

	<select id="selectfwxxmph" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select fwbm,mphm from fwxx where fwbm=#{fwbm}
	</select>

	<select id="selectxmmc" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select xmmc from xm where xmbm=(select xmbm from zhxx where
		dhbm=#{id})
	</select>

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

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

	<select id="selectdwbmbyxmmc" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="java.lang.String">
		select dwmc from sfdw where dwbm=(select dwbm from xm where
		xmbm=(select
		xmbm from xm where xmmc=#{xmmc}))
	</select>

	<select id="selectxmbmbyxmmc" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="java.lang.String">
		select xmbm from xm where xmmc=#{xmmc}
	</select>

	<select id="selectdhbmbyxmmc" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="java.lang.String">
		select dhbm from zhxx where xmbm=(select xmbm from xm where
		xmmc=#{xmmc})
		and dhmc=#{dhmc}
	</select>

	<select id="selectdwwwwbmbyxmmc" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="java.lang.String">
		select dwbm from xm where xmbm=(select xmbm from xm where
		xmmc=#{xmmc})
	</select>

	<select id="selectfwbmbyxmmjdh" parameterType="io.renren.modules.app.entity.FwxxEntity"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select fwbm,sfyj from fwxx where dhbm=#{dhbm} and xm like
		CONCAT(#{xm},"%")
		and mj=#{mj}
	</select>

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

	<select id="selectfwbylz" parameterType="java.lang.String"
		resultType="java.lang.String">
		select xm from fwxx where dhbm=#{id}
	</select>

	<insert id="insertywpldrjl" parameterType="java.lang.String">
		insert into
		ywpldrdjjlb (djbh,cratetime) values(#{id},now())
	</insert>

	<select id="selectgryjpldr" resultType="io.renren.modules.app.entity.GryjpldrtempEntity">
		select * from
		gryjpldr_temp where 1=1
	</select>

	<select id="selectxmxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XmEntity">
		select xmbm,dwbm,xqbm from xm where xmmc like
		CONCAT(#{id},"%")
	</select>

	<select id="selectdhbmbyxmdc" parameterType="io.renren.modules.app.entity.ZhxxEntity"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select dhbm from zhxx where xmbm=#{xmbm} and dhmc like
		CONCAT(#{dhmc},"%")
	</select>

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

	<update id="updategrpldrsfcz" parameterType="io.renren.modules.app.entity.GryjpldrtempEntity">
		update gryjpldr_temp
		set fwsfcz='1',fwbm=#{fwbm} where djrq=#{djrq} and
		yzxm=#{yzxm} and
		xxdz=#{xxdz}
	</update>

	<update id="updategrpldrxmsfcz" parameterType="io.renren.modules.app.entity.GryjpldrtempEntity">
		update
		gryjpldr_temp set xmsfcz='0' where djrq=#{djrq} and yzxm=#{yzxm} and
		xxdz=#{xxdz}
	</update>

	<select id="selectfwbmbydmmph" parameterType="io.renren.modules.app.entity.FwxxEntity"
		resultType="java.lang.String">
		select fwbm from fwxx where dhbm=#{dhbm} and mphm like
		CONCAT("%",#{mphm})
	</select>

	<select id="selectgryjpldryjfw" resultType="io.renren.modules.app.entity.GryjpldrtempEntity">
		select * from
		gryjpldr_temp_copy where fwsfcz='1'
	</select>

	<select id="selectdhdw" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select dhbm,dwbm from zhxx where dhbm=(select dhbm from
		fwxx where fwbm=#{id})
	</select>

	<select id="selectgryjpl" resultType="io.renren.modules.app.entity.GryjpldrtempEntity">
		select * from
		gryjpldr_temp_copy where 1=1
	</select>

	<select id="selectxmbyxmbm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XmEntity">
		select xmbm from xm where xmmc=#{id}
	</select>

	<select id="selectdhbmbyxm" 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>

	<select id="selectfwbm2" parameterType="io.renren.modules.app.entity.FwxxEntity"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select fwbm from fwxx where dhbm=#{dhbm} and mphm=#{mphm}
	</select>

	<update id="updategrplcopy" parameterType="io.renren.modules.app.entity.GryjpldrtempEntity">
		update
		gryjpldr_temp_copy set fwsfcz=#{fwsfcz},fwbm=#{fwbm} where
		djrq=#{djrq} and yzxm=#{yzxm} and xxdz=#{xxdz}
	</update>

	<select id="selectloudiaode7562" resultType="io.renren.modules.app.entity.GryjpldrtempEntity">
		select * from
		gryjpldr_temp_7562 where 1=1
	</select>

	<select id="selectloudiaode7383" resultType="io.renren.modules.app.entity.GryjpldrtempEntity">
		select * from
		gryjpldr_temp_7383 where 1=1
	</select>

	<update id="updategr7562" parameterType="io.renren.modules.app.entity.GryjpldrtempEntity">
		update
		gryjpldr_temp_7562 set sfy='1' where djrq=#{djrq} and yzxm=#{yzxm}
		and
		xxdz=#{xxdz}
	</update>

	<select id="selectlsj" resultType="io.renren.modules.app.entity.YwpzmxEntity">
		select djbh,fwbm from ywpzmx
		where SUBSTR(djbh FROM 5 FOR 2)='03' and SUBSTR(djbh FROM 1 FOR
		4)='0001'
	</select>

	<select id="selectxsj" resultType="io.renren.modules.app.entity.YwpzmxEntity">
		select djbh,fwbm from ywpzmx
		where SUBSTR(djbh FROM 1 FOR 2)='03' and SUBSTR(djbh FROM 1 FOR
		2)='03'
	</select>

	<select id="selectfwcfj" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select
		s.dwmc,q.xqmc,x.xmmc,z.dhmc,f.fwbm,f.mphm,f.lc,f.hx,f.fwxz,f.ssdj,f.mj,f.fwje,f.gfrq,f.zjk,f.xm,f.sfzh,f.lxdh,f.grjjl,
		f.jsbz,f.dz
		from fwxx f,zhxx z,xm x,xqxx q,sfdw s where
		f.dhbm=z.dhbm
		and
		z.xmbm=x.xmbm and x.xqbm=q.xqbm and x.dwbm=s.dwbm and f.fwbm=#{id}
	</select>

	<insert id="insertcfjk" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		beiyong(dwmc,xqmc,xmmc,dhmc,mphm,lc,xm,ssdj,mj,fwje,sfzh,lxdh,grjjl,jsbz,dz)
		values(#{dwmc},#{xqmc},#{xmmc},#{dhmc},#{mphm},#{lc},#{xm},#{ssdj},#{mj},#{fwje},#{sfzh},#{lxdh},#{grjjl},#{jsbz},#{dz})
	</insert>

	<select id="SELECTXMDYKM" resultType="io.renren.modules.app.entity.HPzEntity">
		select x.xmmc xmmc,k.km km
		from xm x,h_km k where x.kfskm=k.km
	</select>

	<select id="selectkkkk" parameterType="java.lang.String"
		resultType="java.lang.String">
		select kmmc from h_km where km=SUBSTR(#{id} FROM 1 FOR 6)
	</select>

	<insert id="insertbeiyong2" parameterType="io.renren.modules.app.entity.HPzEntity">
		insert into
		beiyong2(xmmc,kmmc) values(#{xmmc},#{kmmc})
	</insert>

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

	<select id="selectfwkyzkm" resultType="io.renren.modules.app.entity.FwxxEntity">
		select fwbm from fwxx
		where yzkm=''
	</select>

	<select id="selectfwkfskm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select CONCAT(SUBSTR(x.kfskm FROM 1 FOR 6),'002') yzkm from
		fwxx f,zhxx z,xm x where f.dhbm=z.dhbm and z.xmbm=x.xmbm and
		fwbm=#{id}
	</select>

	<update id="updatefwdeyzkm" parameterType="io.renren.modules.app.entity.FwxxEntity">
		update fwxx set
		yzkm=#{yzkm} where fwbm=#{fwbm}
	</update>

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

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

	<update id="updategrywpzmx" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update ywpzmx set
		bjje=#{je},je=#{je}
		where djbh=#{djbh}
	</update>

	<select id="selectfwsfjq" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzmxEntity">
		select sum(je) je from ywpzmx where (SUBSTR(djbh FROM 5 FOR
		2)='03' || SUBSTR(djbh FROM 1 FOR 2)='03') and fwbm=#{id}
	</select>

	<update id="updatefwsfjq" parameterType="java.lang.String">
		update fwxx set sfjq='1'
		where fwbm=#{id}
	</update>

	<update id="updatefwsfjq0" parameterType="java.lang.String">
		update fwxx set
		sfjq='0' where fwbm=#{id}
	</update>

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

	<select id="selectallfwxx" resultType="io.renren.modules.app.entity.FwxxEntity">
		select * from fwxx where
		1=1
	</select>

	<select id="selectxtpldr" resultType="io.renren.modules.app.entity.YwpzEntity">
		select * from ywpz where
		djlx='03' and czyxm ='系统'
	</select>

	<select id="selectywpzmxbydj" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzmxEntity">
		select * from ywpzmx where djbh=#{id}
	</select>

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

	<update id="updatefwxxgrdq" parameterType="io.renren.modules.app.entity.FwxxEntity">
		update fwxx set
		grje=#{grje},dqye=#{dqye} where fwbm=#{fwbm}
	</update>

	<update id="updatezhxxgrdq" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		gryjje=#{gryjje},dqye=#{dqye} where dhbm=#{dhbm}
	</update>

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

	<update id="updateywpzmxbjjeje" parameterType="io.renren.modules.app.entity.YwpzmxEntity">
		update ywpzmx set
		bjje=#{bjje},je=#{je} where djbh=#{djbh}
	</update>

	<select id="selectdw01" resultType="io.renren.modules.app.entity.YwpzEntity">
		select djbh from ywpz where
		djlx='01'
	</select>

	<select id="selectdw01djxx" resultType="io.renren.modules.app.entity.YwpzEntity">
		select DISTINCT
		y.djbh,y.pzh,y.djlx,y.djrq,y.kjqj,y.je,z.xmbm,s.dwmc from ywpz
		y,yjmx
		m,zhxx z,sfdw s where y.djbh=m.djbh and m.dhbm=z.dhbm and
		y.dwbm=s.dwbm and y.djbh=#{id}
	</select>

	<insert id="insertfzhsmxdw01" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		fzhsmx(gjkjqj,djbh,djlx,djrq,xmbm,dffse,zymc,cwkjqj,pzh)values(#{kjqj},#{djbh},#{djlx},#{djrq},#{xmbm},#{je},#{dwmc},#{kjqj},#{pzh})
	</insert>

	<insert id="insertfzhsmx1dw01" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		fzhsmx(gjkjqj,djbh,djlx,djrq,xmbm,dffse,zymc)values(#{kjqj},#{djbh},#{djlx},#{djrq},#{xmbm},#{je},#{dwmc})
	</insert>

	<select id="queryByPageFZHSMX" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select DISTINCT gjkjqj,djbh,(case
		djlx
		when '01' then '单位预交' when '03'
		then
		'个人预交' when '05' then
		'个人预交' when '13' then '业主退款' when '21' then
		'首次拨付分摊' when '22' then
		'余额拨付分摊' when '10' then
		'年度结息' else '' END)
		djlx,djrq,jffse,dffse,zymc,cwkjqj,pzh,zqlx from fzhsmx
		where 1=1
		<if test=" kjqj!=null and kjqj!='' ">
			and gjkjqj=#{kjqj}
		</if>
		<if test=" djlx!=null and djlx!='' ">
			and (djlx=#{djlx}
		</if>
		<!-- <if test=" djlx2!=null and djlx2!='' ">
			and (djlx='01' or djlx='03')
		</if> -->
		<!-- <if test=" djlx3!=null and djlx3!='' ">
			and (djlx='21' or djlx='22')
		</if> -->
		<if test=" zqlx!=null and zqlx!='' ">
			or zqlx=#{zqlx})
		</if>
		<if test=" mhlook!=null and mhlook!='' ">
			and zymc like CONCAT("%",#{mhlook},"%") or jffse like
			CONCAT(#{mhlook},"%") or dffse like CONCAT(#{mhlook},"%") or
			djbh like
			CONCAT("%",#{mhlook},"%")
		</if>
		<!-- <if test=" je!=null and je!='' "> and jffse=#{je} or dffse=#{je} </if> 
			<if test=" djbh!=null and djbh!='' "> and djbh like CONCAT("%",#{djbh},"%") 
			</if> -->
			order by djrq
	</select>

	<select id="queryByPageFZHSYE" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select x.xmmc,f.xmbm,(case
		f.djlx
		when '01' then '单位预交' when '03' then
		'个人预交' when '13' then '业主退款' when '21' then '首次拨付分摊' when '22' then
		'余额拨付分摊' when '10' then
		'年度结息' else '' END)
		djlx,s.dwmc,f.qcye,f.jffse,f.dffse,f.qmye,f.zqlx from
		fzhsye f ,xm
		x,sfdw s where f.xmbm=x.xmbm and x.dwbm=s.dwbm
		<if test=" kjqj!=null and kjqj!='' ">
			and gjkjqj=#{kjqj}
		</if>
		<if test=" djlx!=null and djlx!='' ">
			and djlx=#{djlx}
		</if>
		<if test=" djlx2!=null and djlx2!='' ">
			and (djlx='01' or djlx='03')
		</if>
		<if test=" djlx3!=null and djlx3!='' ">
			and (djlx='21' or djlx='22')
		</if>
		<if test=" xmmc!=null and xmmc!='' ">
			and xmmc like CONCAT("%",#{xmmc},"%")
		</if>

		<if test=" zqlx!=null and zqlx!='' ">
			and zqlx=#{zqlx}
		</if>

	</select>

	<select id="listywb" resultType="java.lang.String">
		select djbh from ywpz where
		djlx='01'
	</select>

	<select id="listfzmxb" resultType="java.lang.String">
		select djbh from fzhsmx where
		djlx ='01'
	</select>

	<select id="selectzyxqmc" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select DISTINCT q.xqmc from yjmx y,zhxx z,xm x,xqxx q where
		y.dhbm=z.dhbm and z.xmbm=x.xmbm and q.xqbm=x.xqbm and djbh=#{id}
	</select>

	<select id="selectzyxmmc" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select DISTINCT x.xmmc from yjmx y,zhxx z,xm x where
		y.dhbm=z.dhbm and z.xmbm=x.xmbm and djbh=#{id}
	</select>

	<select id="selectzydhmc" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select z.dhmc from yjmx y,zhxx z where y.dhbm=z.dhbm and
		djbh=#{id}
	</select>

	<select id="selectxmbydj" parameterType="java.lang.String"
		resultType="java.util.Map">
		select xm,mphm from fwxx where fwbm=(select fwbm from
		ywpzmx where djbh=#{id})
	</select>

	<select id="selectxcbydj" parameterType="java.lang.String"
		resultType="java.lang.String">
		select xmmc from xm where xmbm=(select xmbm from zhxx where
		dhbm=(select dhbm from ywpzmx where djbh=#{id}))
	</select>

	<select id="selectqcbydj" parameterType="java.lang.String"
		resultType="java.lang.String">
		select xqmc from xqxx where xqbm=(select xqbm from xm where
		xmbm=(select xmbm from zhxx where dhbm=(select dhbm from ywpzmx where
		djbh=#{id})))
	</select>

	<select id="selectqqqq" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select DISTINCT
		y.kjqj,y.djbh,y.djlx,y.djrq,z.xmbm,0,y.je,CONCAT(q.xqmc,'_',x.xmmc,'_',f.mphm,'_',f.xm)
		dwmc,(case when (ISNULL(y.pzh)=1 || (LENGTH(trim(y.pzh))=0)) then null
		else y.kjqj end)cwkjqj,y.pzh from ywpz
		y,ywpzmx m,zhxx z,fwxx f,xm
		x,xqxx q where y.djbh=m.djbh and m.dhbm=z.dhbm and
		m.fwbm=f.fwbm and
		z.xmbm=x.xmbm and x.xqbm=q.xqbm and y.djlx='03' and y.kjqj=#{id}
	</select>

	<!-- <insert id="insertqqqq" parameterType="io.renren.modules.app.entity.YwpzEntity"> 
		insert into fzhsmx(gjkjqj,djbh,djlx,djrq,xmbm,dffse,zymc,cwkjqj,pzh)values(#{kjqj},#{djbh},#{djlx},#{djrq},#{xmbm},#{je},#{dwmc},#{cwkjqj},#{pzh}) 
		</insert> -->

	<insert id="insertqqqq">
		insert into fzhsmx
		(
		gjkjqj,djbh,djlx,djrq,xmbm,dffse,zymc,cwkjqj,pzh
		)
		values
		<foreach item="item" index="index" collection="list"
			separator=",">
			(
			#{item.kjqj},
			#{item.djbh},
			#{item.djlx},
			#{item.djrq},
			#{item.xmbm},
			#{item.je},
			#{item.dwmc},
			#{item.cwkjqj},
			#{item.pzh}
			)
		</foreach>
	</insert>

	<select id="selectqqqqww" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select * from fzhsye_copy where djlx in ('01','03') and
		gjkjqj BETWEEN '2019-01' and '2021-01'
	</select>

	<insert id="insertqqqqww">
		insert into fzhsye
		(
		gjkjqj,xmbm,djlx,qcye,jffse,dffse,qmye
		)
		values
		<foreach item="item" index="index" collection="list"
			separator=",">
			(
			#{item.gjkjqj},
			#{item.xmbm},
			#{item.djlx},
			#{item.qcye},
			#{item.jffse},
			#{item.dffse},
			#{item.qmye}
			)
		</foreach>
	</insert>

	<select id="selectghandcw" resultType="io.renren.modules.app.entity.YwpzEntity">
		select * from gjandcw
	</select>

	<select id="selectypz" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select djbh,djrq,je,kjqj,pzh from ywpz where kjqj=#{kjqj}
		and pzh=#{pzh}
	</select>

	<select id="selectcpz" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="Double">
		select dfje from h_pz where kjqj=#{kjqj} and pzh=#{pzh}
	</select>

	<insert id="inserttemp" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into tempgjcw
		(djbh,djrq,je,kjqj,pzh) values
		(#{djbh},#{djrq},#{je},#{kjqj},#{pzh})
	</insert>

	<select id="selectxmbm" resultType="HashMap">
		select xmmc,xmbm from xm
	</select>

	<select id="QUERYDW" parameterType="String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		SELECT
		x.xmbm xmbm,
		sum(m.je) je
		FROM
		ywpz y,
		yjmx m,
		zhxx z,
		xm x
		WHERE
		y.djbh = m.djbh
		AND m.dhbm = z.dhbm
		AND z.xmbm = x.xmbm
		AND djlx IN
		('01')
		AND y.kjqj BETWEEN '2005-01'
		AND #{kjqj}
		AND y.pzh is not null
		GROUP BY
		x.xmbm
	</select>

	<select id="QUERYGR" parameterType="String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		SELECT
		x.xmbm xmbm,
		sum(m.je) je
		FROM
		ywpz y,
		ywpzmx m,
		zhxx z,
		xm x
		WHERE
		y.djbh = m.djbh
		AND m.dhbm = z.dhbm
		AND z.xmbm = x.xmbm
		AND djlx
		IN ('03', '05')
		AND y.kjqj BETWEEN '2005-01'
		AND #{kjqj}
		AND y.pzh is not null
		GROUP BY
		x.xmbm
	</select>

	<select id="QUERYSY" parameterType="String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		<!-- SELECT
		xgbm xmbm,
		sum(je) je
		FROM
		ywpz
		WHERE
		djlx IN ('21', '22')
		AND kjqj BETWEEN '2005-01'
		AND #{kjqj}
		AND pzh IS NOT NULL
		GROUP BY
		xgbm -->
		SELECT
		sum(m.dwje) dwje,
		sum(m.grje) grje,
		y.xgbm xmbm
		FROM
		ywpz y,
		ywpzmx m
		WHERE
		y.djbh = m.djbh
		AND y.djlx IN ('21', '22')
		AND y.kjqj BETWEEN '2005-01'
		AND #{kjqj}
		AND y.pzh is not null
		GROUP BY
		y.xgbm
	</select>

	<select id="QUERYTK" parameterType="String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		SELECT
		x.xmbm xmbm,
		sum(m.bjje) je
		FROM
		ywpz y,
		ywpzmx m,
		zhxx z,
		xm x
		WHERE
		y.djbh = m.djbh
		AND m.dhbm = z.dhbm
		AND z.xmbm = x.xmbm
		AND djlx
		IN ('13')
		AND y.kjqj BETWEEN '2005-01'
		AND #{kjqj}
		AND y.pzh is not null
		GROUP BY
		x.xmbm
	</select>

	<select id="QUERYDWDY" parameterType="String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		SELECT
		x.xmbm xmbm,
		sum(m.je) je
		FROM
		ywpz y,
		yjmx m,
		zhxx z,
		xm x
		WHERE
		y.djbh = m.djbh
		AND m.dhbm = z.dhbm
		AND z.xmbm = x.xmbm
		AND djlx IN
		('01')
		AND y.kjqj=#{kjqj}
		AND y.pzh is not null
		GROUP BY
		x.xmbm
	</select>

	<select id="QUERYGRDY" parameterType="String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		SELECT
		x.xmbm xmbm,
		sum(m.je) je
		FROM
		ywpz y,
		ywpzmx m,
		zhxx z,
		xm x
		WHERE
		y.djbh = m.djbh
		AND m.dhbm = z.dhbm
		AND z.xmbm = x.xmbm
		AND djlx
		IN ('03', '05')
		AND y.kjqj=#{kjqj}
		AND y.pzh is not null
		GROUP BY
		x.xmbm
	</select>

	<select id="QUERYSYDY" parameterType="String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		SELECT
		xgbm xmbm,
		sum(je) je
		FROM
		ywpz
		WHERE
		djlx IN ('21', '22')
		AND y.kjqj=#{kjqj}
		AND y.pzh is not null
		GROUP BY
		xgbm
	</select>

	<select id="QUERYSYDY2" parameterType="String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		SELECT
		sum(m.dwje) dwje,
		sum(m.grje) grje,
		y.xgbm xmbm
		FROM
		ywpz y,
		ywpzmx m
		WHERE
		y.djbh = m.djbh
		AND y.djlx IN ('21', '22')
		AND y.kjqj=#{kjqj}
		AND y.pzh is not null
		GROUP BY
		y.xgbm
	</select>

	<select id="QUERYTKDY" parameterType="String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		SELECT
		x.xmbm xmbm,
		sum(m.bjje) je
		FROM
		ywpz y,
		ywpzmx m,
		zhxx z,
		xm x
		WHERE
		y.djbh = m.djbh
		AND m.dhbm = z.dhbm
		AND z.xmbm = x.xmbm
		AND djlx
		IN ('13')
		AND y.kjqj=#{kjqj}
		AND y.pzh is not null
		GROUP BY
		x.xmbm
	</select>

</mapper>