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

	<!-- 可根据自己的需求，是否要使用 -->
	<resultMap type="io.renren.modules.app.entity.HPzEntity" id="hPzMap">
		<result property="gzdbm" column="gzdbm" />
		<result property="kjqj" column="kjqj" />
		<result property="pzh" column="pzh" />
		<result property="flxh" column="flxh" />
		<result property="pzrq" column="pzrq" />
		<result property="fjzs" column="fjzs" />
		<result property="zymc" column="zymc" />
		<result property="km" column="km" />
		<result property="jfje" column="jfje" />
		<result property="dfje" column="dfje" />
		<result property="sfsh" column="sfsh" />
		<result property="sfjz" column="sfjz" />
		<result property="lrfs" column="lrfs" />
		<result property="ywlx" column="ywlx" />
		<result property="ywbh" column="ywbh" />
		<result property="zdrbm" column="zdrbm" />
		<result property="zdsj" column="zdsj" />
		<result property="shrbm" column="shrbm" />
		<result property="shsj" column="shsj" />
		<result property="jzrbm" column="jzrbm" />
		<result property="jzsj" column="jzsj" />
		<result property="ztbm" column="ztbm" />
		<result property="pztype" column="pztype" />
		<result property="zdrmc" column="zdrmc" />
		<result property="shrmc" column="shrmc" />
		<result property="jzrmc" column="jzrmc" />
		<result property="pjrq" column="pjrq" />
	</resultMap>

	<select id="queryByPageDWPZ" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">

		select distinct y.djbh,y.djrq,s.dwmc,y.je,y.bank_code
		bankCode,h.yhmc,y.jsfs,j.billname,y.czyxm,y.zph,y.kjqj
		from ywpz
		y,sfdw
		s,yhxx
		h,h_jsfs j where
		y.dwbm=s.dwbm and
		y.bank_code=h.yhbm and
		y.jsfs=j.billcode and y.shzt='1' and y.djlx='01' and y.pzh is NULL

		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		<!-- and y.kjqj=#{kjqj} -->
		order by y.djrq desc
	</select>

	<select id="selectyjmxdhbm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">

		select dhbm from yjmx where djbh=#{id}

	</select>

	<select id="selectywpzmxdhbm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">

		select dhbm from ywpzmx where djbh=#{id}

	</select>

	<select id="selectxmmcbydhbm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">

		select x.xmmc,x.xmbm from zhxx z,xm x where z.xmbm=x.xmbm
		and
		z.dhbm=#{id}

	</select>

	<select id="selectkfskm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XmEntity">

		select kfskm from xm where xmbm=#{id}

	</select>

	<select id="selectbymc" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.HKmEntity">

		select * from h_km where kmmc=#{id} and ztbm='0001'

	</select>

	<select id="selectbymc2" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.HKmEntity">
		select * from h_km where kmmc=#{id} and ztbm='0002'
	</select>

	<select id="selectbymc22" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.HKmEntity">
		select * from h_km where kmmc=#{id} and ztbm='0003'
	</select>

	<select id="selectbymc1" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.HKmEntity">

		select * from h_km where km=#{id} and ztbm='0001'

	</select>

	<select id="selecthoprator" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.HPzEntity">

		select account,ztbm from h_operator where name=#{name}

	</select>

	<select id="selectsysuser" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.HPzEntity">

		select user_id id from sys_user where username=#{id}

	</select>

	<select id="selectzt" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.HPzEntity">

		select sfzt from h_zt where ztbm=#{id}

	</select>

	<select id="selectmaxpzh" parameterType="java.lang.String"
		resultType="java.lang.String">

		select max(pzh) from h_pz where kjqj=#{date}

	</select>

	<insert id="inserthpzjf" parameterType="io.renren.modules.app.entity.HPzEntity">
		insert into
		h_pz(gzdbm,kjqj,pzh,flxh,pzrq,fjzs,zymc,km,jfje,dfje,sfsh,sfjz,lrfs,ywlx,ywbh,zdrbm,zdsj,pztype,zdrmc,ztbm)
		values(#{gzdbm},#{kjqj},#{pzh},#{flxh},#{pzrq},#{fjzs},#{zymc},#{km},#{jfje},#{dfje},#{sfsh},#{sfjz},#{lrfs},#{ywlx},#{ywbh},#{zdrbm},#{zdsj},#{pztype},#{zdrmc},#{ztbm})
	</insert>

	<update id="updateywpzpzh" parameterType="io.renren.modules.app.entity.HPzEntity">
		update ywpz set
		pzh=#{pzh} where djbh=#{djbh}
	</update>

	<update id="updateywpzpzhnull" parameterType="java.lang.String">
		update ywpz set
		pzh=null where djbh=#{id}
	</update>

	<select id="queryByPageGRPZ" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">

		select distinct
		y.djbh,y.djrq,y.djlx,y.kjqj,f.xm,f.mphm,f.sfzh,y.je,y.bank_code
		bankCode,h.yhmc,y.jsfs,j.billname,y.czyxm,y.zph,y.djbm,q.xqbm,q.xqmc,x.xmmc
		from ywpz
		y,ywpzmx
		m,fwxx f,zhxx z,xm x,xqxx q,yhxx
		h,h_jsfs j where
		y.djbh=m.djbh
		and m.fwbm=f.fwbm and f.dhbm=z.dhbm and z.xmbm=x.xmbm and
		x.xqbm=q.xqbm and
		y.bank_code=h.yhbm and
		y.jsfs=j.billcode and
		y.shzt='1' and (y.djlx='03' or y.djlx='05')
		and y.pzh is NULL

		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		<if test=" xqbm!=null and xqbm!='' ">
			and q.xqbm like CONCAT(#{xqbm},"%")
		</if>
		<if test=" xqmc!=null and xqmc!='' ">
			and q.xqmc like CONCAT(#{xqmc},"%")
		</if>
		<if test=" jsfs!=null and jsfs!='' ">
			and y.jsfs like CONCAT(#{jsfs},"%")
		</if>
		<!-- and y.kjqj=#{kjqj} -->
		order by y.djrq desc
	</select>

	<select id="queryByPageTKPZ" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">

		select distinct
		y.djbh,y.djrq,y.djlx,y.kjqj,f.xm,f.mphm,f.sfzh,y.je,y.bank_code
		bankCode,h.yhmc,y.jsfs,j.billname,y.czyxm,y.zph,y.djbm,q.xqbm,q.xqmc,x.xmmc
		from ywpz
		y,ywpzmx
		m,fwxx f,zhxx z,xm x,xqxx q,yhxx
		h,h_jsfs j where
		y.djbh=m.djbh
		and m.fwbm=f.fwbm and f.dhbm=z.dhbm and z.xmbm=x.xmbm and
		x.xqbm=q.xqbm and
		y.bank_code=h.yhbm and
		y.jsfs=j.billcode and
		y.shzt='1' and (y.djlx='13')
		and y.pzh is NULL

		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		<if test=" xqbm!=null and xqbm!='' ">
			and q.xqbm like CONCAT(#{xqbm},"%")
		</if>
		<if test=" xqmc!=null and xqmc!='' ">
			and q.xqmc like CONCAT(#{xqmc},"%")
		</if>
		<if test=" jsfs!=null and jsfs!='' ">
			and y.jsfs like CONCAT(#{jsfs},"%")
		</if>
		<!-- and y.kjqj=#{kjqj} -->
		order by y.djrq desc
	</select>

	<select id="queryByPageGGSYFTPZ" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">

		select distinct y.djbh,y.djrq,y.je,y.bank_code
		bankCode,h.yhmc,y.jsfs,j.billname,y.czyxm,y.zph
		from ywpz
		y,ywpzmx
		m,yhxx
		h,h_jsfs j where y.djbh=m.djbh and
		y.bank_code=h.yhbm and
		y.jsfs=j.billcode and y.djlx='04' and y.pzh is NULL

		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		and y.kjqj=#{kjqj}
		order by y.djrq desc
	</select>

	<select id="queryByPagePZCX" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select pztype,pzh,fjzs,flxh,zymc,km,gzdbm,ztbm,jfje,dfje,(case
		ywlx
		when '30'
		then
		'单位交款分配' when '31' then '现金' when '32' then '电汇凭证'
		when
		'33' then
		'转帐支票' when '34' then '信汇凭证' when '35' then '借方凭证' when
		'36'
		then '进帐单'
		when '37' then '税单' when '01' then '开发商缴交' when '03' then
		'业主(个人)缴交'
		when
		'04' then '公共收益分摊'
		else '' END)
		ywlx,zdrmc,zdsj,shrmc,shsj,sfsh,jzrmc,jzsj,kjqj,pzrq from h_pz where
		1=1
		<if test=" pzh!=0 ">
			and pzh=#{pzh}
		</if>
		<if
			test=" beginkjrq!=null and beginkjrq!='' and endkjrq!=null and endkjrq!='' ">
			and kjqj between #{beginkjrq} and #{endkjrq}
		</if>
		<if
			test=" beginjzrq!=null and beginjzrq!='' and endjzrq!=null and endjzrq!='' ">
			and jzsj between #{beginjzrq} and #{endjzrq}
		</if>
		<if test=" beginpzrq!=null and beginpzrq!='' and endpzrq!=null and endpzrq!='' ">
			and pzrq between #{beginpzrq} and #{endpzrq}
		</if>
		<if test=" zymc!=null and zymc!='' ">
			and zymc like CONCAT("%",#{zymc},"%")
		</if>
		<if test=" km!=null and km!='' ">
			and km like CONCAT(#{km},"%")
		</if>
		<if test=" je!=null and je!='' ">
			and (jfje=#{je} or dfje=#{je})
		</if>
		<if test=" sfjz!=null and sfjz!='' ">
			and sfjz like CONCAT(#{sfjz},"%")
		</if>
		order by kjqj,pzh,flxh
	</select>

	<select id="queryByPagePZCXHJ" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select sum(jfje) sumjf,sum(dfje) sumdf from h_pz where
		1=1
		<if test=" pzh!=0 ">
			and pzh=#{pzh}
		</if>
		<if
			test=" beginkjrq!=null and beginkjrq!='' and endkjrq!=null and endkjrq!='' ">
			and kjqj between #{beginkjrq} and #{endkjrq}
		</if>
		<if
			test=" beginjzrq!=null and beginjzrq!='' and endjzrq!=null and endjzrq!='' ">
			and jzsj between #{beginjzrq} and #{endjzrq}
		</if>
		<if test=" zymc!=null and zymc!='' ">
			and zymc like CONCAT("%",#{zymc},"%")
		</if>
		<if test=" km!=null and km!='' ">
			and km like CONCAT(#{km},"%")
		</if>
		<if test=" je!=null and je!='' ">
			and jfje=#{je} or dfje=#{je}
		</if>
		<if test=" sfjz!=null and sfjz!='' ">
			and sfjz like CONCAT(#{sfjz},"%")
		</if>
		order by kjqj,pzh
	</select>

	<delete id="deletePZ" parameterType="io.renren.modules.app.entity.HPzEntity">
		delete from h_pz where
		kjqj=#{kjqj} and pztype=#{pztype} and pzh=#{pzh} and
		gzdbm=#{gzdbm} and
		ztbm=#{ztbm}
	</delete>

	<select id="selectkm3" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select p.km,k.kmmc,p.jfje,p.dfje from h_pz p,h_km k where p.km=k.km
		and p.ztbm=k.ztbm
		<if
			test=" beginkjrq!=null and beginkjrq!='' and endkjrq!=null and endkjrq!='' ">
			and p.kjqj between #{beginkjrq} and #{endkjrq}
		</if>
		<if
			test=" beginjzrq!=null and beginjzrq!='' and endjzrq!=null and endjzrq!='' ">
			and p.jzsj between #{beginjzrq} and #{endjzrq}
		</if>
		<if
			test=" beginpzh!=null and beginpzh!='' and endpzh!=null and endpzh!='' ">
			and p.pzh between #{beginpzh} and #{endpzh}
		</if>
		<if test=" sfjz!=null and sfjz!='' ">
			and p.sfjz like CONCAT(#{sfjz},"%")
		</if>
		<if test=" pztype!=null and pztype!='' ">
			and p.pztype like CONCAT(#{pztype},"%")
		</if>
	</select>

	<select id="queryByPagePZSH" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select
		ztbm,pztype,kjqj,pzrq,zdrmc,shrmc,zdsj,sfsh,jzrmc,pzh,sum(jfje)
		jfje,sum(dfje)
		dfje from h_pz where kjqj=#{kjqj} and sfsh='0' GROUP BY
		pzh ORDER BY
		pzh
	</select>

	<select id="selectPZSHXQ" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select * from h_pz where kjqj=#{kjqj} and pzh=#{pzh}
	</select>

	<select id="selectPZSHXQj" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select * from h_pz where kjqj=#{kjqj} and pzh=#{pzh} and
		jfje!=0 order by flxh
	</select>

	<select id="selectPZSHXQd" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select * from h_pz where kjqj=#{kjqj} and pzh=#{pzh} and
		dfje!=0 order by flxh
	</select>

	<select id="selectPZSHXQj2" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select * from h_pz where kjqj=#{kjqj} and pzh=#{pzh} and
		jfje!=0 and flxh=#{flxh}
	</select>

	<select id="selectPZSHXQd2" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select * from h_pz where kjqj=#{kjqj} and pzh=#{pzh} and
		dfje!=0 and flxh=#{flxh}
	</select>

	<update id="updatePZSH" parameterType="io.renren.modules.app.entity.HPzEntity">
		update h_pz set
		sfsh=#{sfsh},shrbm=#{shrbm},shrmc=#{shrmc},shsj=#{shsj}
		where
		kjqj=#{kjqj} and pzh=#{pzh} and ztbm=#{ztbm} and
		pztype=#{pztype}
	</update>

	<select id="queryByPagePZJZ" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select
		pzh,ztbm,pztype,kjqj,pzrq,zdrmc,shrmc,sfsh,shsj,jzrmc,sfjz,jzsj from
		h_pz where kjqj=#{kjqj} and sfsh='1' GROUP BY pzh ORDER BY shsj desc
	</select>

	<select id="queryByPagePZWJZ" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select
		pzh,ztbm,pztype,kjqj,pzrq,zdrmc,shrmc,sfsh,shsj,jzrmc,sfjz,jzsj from
		h_pz where kjqj=#{kjqj} and sfsh='1' and sfjz='0' GROUP BY pzh ORDER
		BY pzh
	</select>

	<select id="queryByPagePZYJZ" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select
		pzh,ztbm,pztype,kjqj,pzrq,zdrmc,shrmc,sfsh,shsj,jzrmc,sfjz,jzsj from
		h_pz where kjqj=#{kjqj} and sfsh='1' and sfjz='1' GROUP BY pzh ORDER
		BY pzh
	</select>

	<update id="updatePZJZ" parameterType="io.renren.modules.app.entity.HPzEntity">
		update h_pz set
		sfjz=#{sfjz},jzrbm=#{jzrbm},jzrmc=#{jzrmc},jzsj=#{jzsj}
		where
		kjqj=#{kjqj} and pzh=#{pzh} and ztbm=#{ztbm} and
		pztype=#{pztype}
	</update>

	<select id="selectmaxzybm" resultType="java.lang.String">
		select max(zybm+0) from
		h_zy
	</select>

	<insert id="insertzy" parameterType="io.renren.modules.app.entity.HZyEntity">
		insert into
		h_zy(zybm,zymc,ztbm)values(#{zybm},#{zymc},#{ztbm})
	</insert>

	<select id="selectyzkm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">

		select fwbm from ywpzmx where djbh=#{id}

	</select>

	<select id="selectyzkm2" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">

		select yzkm from fwxx where fwbm=#{id}

	</select>

	<select id="selectkm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.HKmEntity">

		select * from h_km where km=#{id}

	</select>

	<select id="selectpz" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select pztype,pzh,fjzs,flxh,zymc,km,gzdbm,ztbm,kjqj,jfje,dfje,(case
		ywlx
		when '30'
		then
		'单位交款分配' when '31' then '现金' when '32' then '电汇凭证'
		when
		'33' then
		'转帐支票' when '34' then '信汇凭证' when '35' then '借方凭证' when
		'36'
		then '进帐单'
		when '37' then '税单' when '01' then '开发商缴交' when '03'
		then
		'业主(个人)缴交'
		when
		'04' then '公共收益分摊'
		else '' END)
		ywlx,ywbh,zdrmc,zdsj,shrmc,shsj,sfsh,jzrmc,jzsj,kjqj,pzrq from h_pz
		where
		1=1
		<if test=" pzh!=null and pzh !='' ">
			and pzh=#{pzh}
		</if>
		and kjqj=#{kjqj}
		order by pzrq desc
	</select>

	<select id="queryByPagePZCZ" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select y.djbh,y.djrq,y.djlx,s.dwmc,s.dwbm,h.yhmc,y.je,y.bz,y.pzzt from
		ywpz y,sfdw s,yhxx h
		where y.dwbm=s.dwbm and y.
		bank_code=h.yhbm
		and
		y.djlx=#{djlx}
		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		order by y.djrq desc
	</select>

	<select id="queryByPagePZCZ2" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select y.djbh,y.djrq,y.djlx,s.dwmc,s.dwbm,y.je,y.bz,y.pzzt from
		ywpz
		y,sfdw s
		where y.dwbm=s.dwbm
		and
		y.djlx='02'
		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		order by y.djrq desc
	</select>

	<select id="queryByPagePZCZ3" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select y.djbh,y.djrq,y.djlx,h.yhmc,y.je,y.bz,y.pzzt from
		ywpz y,yhxx h
		where y.
		bank_code=h.yhbm
		and
		y.djlx='05'
		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		order by y.djrq desc
	</select>

	<select id="selectdw" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select dwbm,dwmc from sfdw where dwbm=#{id}
	</select>

	<select id="selectdwzck" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select zckje from sfdw where dwbm=#{id}
	</select>

	<select id="selectpzh" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select kjqj,pztype,pzh,ztbm from h_pz where pztype='记账' and
		kjqj=#{kjqj} GROUP BY pztype,pzh ORDER BY pztype,pzh
	</select>

	<select id="selectywdj" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select * from ywpz where kjqj=#{kjqj} and pzh=#{pzh}
	</select>

	<update id="updatedjpzh" parameterType="io.renren.modules.app.entity.HPzEntity">
		update ywpz set
		pzh=#{newpzh} where djbh=#{djbh}
	</update>

	<update id="updatepzpzh" parameterType="io.renren.modules.app.entity.HPzEntity">
		update h_pz set
		pzh=#{newpzh} where pzh=#{pzh} and pztype='记账' and
		ztbm=#{ztbm} and
		kjqj=#{kjqj}
	</update>

	<select id="selectzy" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.HZyEntity">
		select * from h_zy where zymc=#{id}
	</select>

	<select id="selectyspz" resultType="io.renren.modules.app.entity.HPzEntity">
		select
		DATE_FORMAT(STR_TO_DATE(a.jzsj,'%m/%d/%Y'),'%Y-%m-%d') AS
		jzsj,a.ztbm,a.pztype,a.kjqj,a.pzh,a.flxh from h_pz a
		where
		LENGTH(a.jzsj) >15
	</select>

	<update id="updaterqgs" parameterType="io.renren.modules.app.entity.HPzEntity">
		update h_pz set jzsj =
		#{jzsj} where ztbm =#{ztbm} and
		pztype=#{pztype} and kjqj = #{kjqj} and
		pzh = #{pzh} and flxh=#{flxh}
	</update>

	<select id="queryByPageZQPZSC" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">

		select DISTINCT
		y.djbh,y.djrq,y.djlx,s.dwmc,q.xqmc,x.xmmc,y.je,y.bank_code
		bankCode,h.yhmc,y.jsfs,y.kjqj,j.billname,y.czyxm,y.zph,z.wxbw from
		ywpz y,sfdw
		s,yhxx
		h,h_jsfs j,xqxx q,xm x,sqwxzq z where
		y.dwbm=s.dwbm
		and
		y.bank_code=h.yhbm and
		y.jsfs=j.billcode and y.sqdbh=z.sqdbh and
		y.xgbm=x.xmbm and x.xqbm=q.xqbm and y.djlx='21' and y.pzh is NULL
		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		order by y.djrq desc
	</select>

	<select id="queryByPageZQPZSC2" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">

		select DISTINCT
		y.djbh,y.djrq,y.djlx,s.dwmc,q.xqmc,x.xmmc,y.je,y.bank_code
		bankCode,h.yhmc,y.jsfs,y.kjqj,j.billname,y.czyxm,y.zph,z.wxbw from
		ywpz y,sfdw
		s,yhxx
		h,h_jsfs j,xqxx q,xm x,sqwxzq z where
		y.dwbm=s.dwbm
		and
		y.bank_code=h.yhbm and
		y.jsfs=j.billcode and y.sqdbh=z.sqdbh and
		y.xgbm=x.xmbm and x.xqbm=q.xqbm and y.djlx='22' and y.pzh is NULL
		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		order by y.djrq desc
	</select>

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

	<select id="selectkmmm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.HKmEntity">
		select km,kmmc from h_km where kmmc=(select xmmc from xm
		where xmbm=(select xmbm from zhxx where dhbm=#{id}))
	</select>

	<select id="selectwxjl" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.WxjlbEntity">
		select fybm from wxjlb where sqdbh=(select sqdbh from
		sqwxzq where jsdbh=#{id})
	</select>

	<select id="selectwxxm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.WxxmxxEntity">
		select wxxmmc from wxxmxx where wxxmbm=#{id}
	</select>

	<select id="selectxqmc" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XqxxEntity">
		select xqmc from xqxx where xqbm=(select xqbm from xm where
		xmbm=(select xmbm from zhxx where dhbm=#{id}))
	</select>

	<update id="updatepz" parameterType="io.renren.modules.app.entity.HPzEntity">
		update h_pz set
		pzrq=#{pzrq},fjzs=#{fjzs},zymc=#{zymc},km=#{km},jfje=#{jfje},dfje=#{dfje}
		where kjqj=#{kjqj} and pztype=#{pztype} and pzh=#{pzh} and
		flxh=#{flxh} and ztbm=#{ztbm}
	</update>

	<select id="selectjzsr" parameterType="io.renren.modules.app.entity.YwpzmxEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select sum(h_pz.jfje) jfje,sum(h_pz.dfje) dfje,h_pz.km
		from
		h_pz,h_km
		where h_km.km = h_pz.km and
		h_km.ztbm = h_pz.ztbm AND
		h_pz.ZTBM = '0001' AND
		h_pz.KJQJ = #{kjqj} and
		h_km.kmlbbm = '10'
		group
		by h_pz.km
	</select>

	<select id="selectjzzc" parameterType="io.renren.modules.app.entity.YwpzmxEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select sum(h_pz.jfje) jfje,sum(h_pz.dfje) dfje,h_pz.km
		from
		h_pz,h_km
		where h_km.km = h_pz.km and
		h_km.ztbm = h_pz.ztbm AND
		h_pz.ZTBM = '0001' AND
		h_pz.KJQJ = #{kjqj} and
		h_km.kmlbbm = '9'
		group by
		h_pz.km
	</select>

	<select id="selectytlx" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="Integer">
		SELECT count(*) from h_ytlxb where kjqj =#{kjqj} and
		ztbm='0001'
	</select>

	<select id="selectjxrq" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.HYtlxbEntity">
		select MAX(JXRQ) jxrq from h_ytlxb where ztbm='0001'
	</select>

	<select id="selectytxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.HYtlxbEntity">
		select (case
		when ISNULL(sum(-lx)) then 0 else sum(-lx) END)
		lx,(case
		when ISNULL(sum(-dqlx)) then 0 else sum(-dqlx) END)
		dqlx,(case
		when ISNULL(sum(-hqlx)) then 0 else sum(-hqlx) END)
		hqlx,(case
		when
		ISNULL(sum(-dqjs)) then 0 else sum(-dqjs) END)
		dqjs,(case
		when
		ISNULL(sum(-hqjs)) then 0 else sum(-hqjs) END)
		hqjs
		from h_ytlxb where
		JXND =#{id} AND ZTBM ='0001' AND GZDBM='0001'
	</select>

	<select id="selectxtcs" resultType="io.renren.modules.app.entity.XtcsEntity">
		select * from xtcs where 1=1
	</select>

	<insert id="insertytlxb" parameterType="io.renren.modules.app.entity.HYtlxbEntity">
		insert into
		h_ytlxb(pzh,kjqj,jxnd,jxrq,dqll,hqll,lx,dqlx,hqlx,dqjs,hqjs,gzdbm,ztbm)
		values(#{pzh},#{kjqj},#{jxnd},#{jxrq},#{dqll},#{hqll},#{lx},#{dqlx},#{hqlx},#{dqjs},#{hqjs},'0001','0001')
	</insert>

	<select id="queryByPageYTLX" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.HYtlxbEntity">
		select * from h_ytlxb where 1=1
		<if test=" jxnd!=null and jxnd!='' ">
			and jxnd=#{jxnd}
		</if>
	</select>

	<select id="selectpzzsfjhz" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select pzh,fjzs from h_pz where 1=1
		<if
			test=" beginkjrq!=null and beginkjrq!='' and endkjrq!=null and endkjrq!='' ">
			and kjqj between #{beginkjrq} and #{endkjrq}
		</if>
		GROUP BY pzh
	</select>

	<select id="selectfjhz" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select pzh,flxh,fjzs from h_pz where 1=1
		<if
			test=" beginkjrq!=null and beginkjrq!='' and endkjrq!=null and endkjrq!='' ">
			and kjqj between #{beginkjrq} and #{endkjrq}
		</if>
	</select>

	<select id="selectmaxflxh" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="Integer">
		select MAX(flxh+1) flxh from h_pz where kjqj=#{kjqj} and
		pzh=#{pzh}
	</select>

	<select id="selectonefl" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select * from h_pz where kjqj=#{kjqj} and pzh=#{pzh} and
		flxh=#{flxh}
	</select>

	<update id="updatefzhsmxdw" parameterType="io.renren.modules.app.entity.HPzEntity">
		update fzhsmx set
		cwkjqj=#{kjqj},pzh=#{pzh} where djbh=#{djbh}
	</update>

	<select id="selectfzhsmxdj" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select djbh from fzhsmx where djbh=#{id}
	</select>

	<update id="updatefzhsmxdj" parameterType="java.lang.String">
		update fzhsmx set
		cwkjqj='',pzh='' where djbh=#{id}
	</update>

	<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="selectkjqjpzhgs" parameterType="java.lang.String"
		resultType="java.lang.String">
		SELECT pzh FROM h_pz where kjqj=#{id} GROUP BY pzh
	</select>

	<select id="selectMINpzh" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="Integer">
		select MIN(pzh) from h_pz where kjqj=#{kjqj} and
		ztbm=#{ztbm}
	</select>

	<select id="selectMINpzh2" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="java.lang.String">
		select MIN(pzh) from h_pz where kjqj=#{kjqj} and
		ztbm=#{ztbm}
	</select>

	<select id="selectallpzh" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="java.lang.String">
		select pzh from h_pz where kjqj=#{kjqj} and ztbm=#{ztbm}
		GROUP BY pzh
	</select>

	<select id="selectkjqjpzhsfcz" parameterType="io.renren.modules.app.entity.HPzEntity"
		resultType="Integer">
		select count(1) from h_pz where kjqj=#{kjqj} and
		ztbm=#{ztbm}
	</select>

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

	<select id="selectszbypz" parameterType="String"
		resultType="io.renren.modules.app.entity.HPzEntity">
		select kjqj,km,jfje,dfje from h_pz where SUBSTR(kjqj FROM 1
		FOR 4)=SUBSTR(#{kjqj} FROM 1 FOR 4)
	</select>

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

	<select id="selectkmyexxxx" parameterType="String"
		resultType="io.renren.modules.app.entity.HKmyeEntity">
		select * from h_kmye where kjqj=#{kjqj}
	</select>

	<select id="selectpzkm" parameterType="io.renren.modules.app.entity.HPzEntity" resultType="io.renren.modules.app.entity.HPzEntity">
		select sum(dfje) dfje,sum(jfje) jfje from h_pz where kjqj=#{kjqj} and km=#{km}
	</select>
	
	<select id="selectkmye" parameterType="io.renren.modules.app.entity.HKmyeEntity" resultType="io.renren.modules.app.entity.HKmyeEntity">
		select * from h_kmye where kjqj=#{kjqj} and hskmdm=#{hskmdm}
	</select>
	
	<update id="updatekmye" parameterType="io.renren.modules.app.entity.HKmyeEntity">
	update h_kmye 
	<trim prefix="SET" suffixOverrides=",">
	<if test="dfje != null">dfje=dfje+#{dfje},</if>
	<if test="ljdfje != null">ljdfje=#{ljdfje},</if>
	<if test="jfje != null">jfje=jfje+#{jfje},</if>
	<if test="ljjfje != null">ljjfje=#{ljjfje},</if>
	<if test="qmjz != null">qmjz=#{qmjz},</if>
	</trim>
	where kjqj=#{kjqj} and hskmdm=#{hskmdm}
	</update>
	
	<select id="YJQQMJZ" parameterType="io.renren.modules.app.entity.HKmyeEntity" resultType="io.renren.modules.app.entity.HKmyeEntity">
		select IFNULL(qmjz,'0') qmjz,hskmdm from h_kmye where kjqj=#{kjqj} and hskmdm in('400101','400102','5001','5101')
	</select>
	
	<update id="updatekmyeqmjehtjf" parameterType="io.renren.modules.app.entity.HKmyeEntity">
	update h_kmye 
	<trim prefix="SET" suffixOverrides=",">
	<if test="jfje != null">jfje=jfje-#{jfje},</if>
	qmjz=null
	</trim>
	 where ztbm=#{ztbm} and kjqj=#{kjqj} and hskmdm=#{hskmdm}
	</update>
	
	<update id="updatekmyeqmjehtdf" parameterType="io.renren.modules.app.entity.HKmyeEntity">
	update h_kmye 
	<trim prefix="SET" suffixOverrides=",">
	<if test="dfje != null">dfje=dfje-#{dfje},</if>
	qmjz=null
	</trim>
	 where ztbm=#{ztbm} and kjqj=#{kjqj} and hskmdm=#{hskmdm}
	</update>
	
	<select id="selectpzfse" parameterType="String" resultType="io.renren.modules.app.entity.HPzEntity">
		select * from h_pz where SUBSTR(kjqj FROM 1 FOR 4)=#{id} and km in('4001','4201','4301','5001','5101','400101','400102','4101','4102','4901','5901','3101')
	</select>

</mapper>