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

	<select id="selectwygs" resultType="io.renren.modules.app.entity.XlkEntity">
		select wygsbm,wygsmc from
		wygsxx
		where 1=1

	</select>


	<select id="selectxq" resultType="io.renren.modules.app.entity.XlkEntity">
		select xqbm,xqmc from xqxx
		where 1=1

	</select>
	
	<select id="selecthzy" resultType="io.renren.modules.app.entity.XlkEntity">
		select zybm,zymc from h_zy where 1=1

	</select>

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

	</select>

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

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

	</select>
	
	 <select id="selectkm" resultType="io.renren.modules.app.entity.XlkEntity">
    select km,kmmc,pydm,kmsx,jbh,djkm from h_km where 1=1 and ztbm='0001'
    <if test=" _pt!=null and _pt!=''">
			and km like '%${_pt}%' or kmmc like '%${_pt}%'
	</if>
    </select>
    
    <select id="selectkm2" resultType="io.renren.modules.app.entity.XlkEntity">
    select km,kmmc,pydm,kmsx,jbh,djkm from h_km where 1=1 and ztbm='0002'
    <if test=" _pt!=null and _pt!=''">
			and km like '%${_pt}%' or kmmc like '%${_pt}%'
	</if>
    </select>
    
    <select id="selectkm22" resultType="io.renren.modules.app.entity.XlkEntity">
    select km,kmmc,pydm,kmsx,jbh,djkm from h_km where 1=1 and ztbm='0003'
    <if test=" _pt!=null and _pt!=''">
			and km like '%${_pt}%' or kmmc like '%${_pt}%'
	</if>
    </select>
    
    <select id="selectkm3" resultType="io.renren.modules.app.entity.XlkEntity">
    select km,kmmc,pydm,kmsx,jbh,djkm,ztbm from h_km where 1=1
    <if test=" _pt!=null and _pt!=''">
			and km like '%${_pt}%' or kmmc like '%${_pt}%'
	</if>
    </select>
    
    <select id="selectkmmc" resultType="io.renren.modules.app.entity.XlkEntity">
    select kmmc from h_km where km=#{id}
    </select>

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

	<select id="selectsyxm" resultType="io.renren.modules.app.entity.XlkEntity">
		select id lx,value zdmc from
		sys_dict
		where
		type='11'
	</select>

	<select id="queryByPage" parameterType="io.renren.modules.app.entity.ZhxxEntity"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select fwbm,cczh,mphm,xm,sfzh,mj,fwje from fwxx
		where
		dhbm=#{dhbm}
	</select>

	<select id="selectftdj" resultType="io.renren.modules.app.entity.XlkEntity">
		select y.djbh,y.djrq,d.zdmc
		from
		ywpz y,zdxx d
		where y.syxm=d.lx and y.pzzt='1'
	</select>

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

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

	<select id="selectdj" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select
		y.djbh,y.djrq,q.xqmc,x.xmmc,z.dhmc,a.yhmc,h.billname,y.zph,d.zdmc,y.je
		syze,y.fpfs,y.bz,w.wygsmc,s.dwmc
		from ywpz y,xqxx
		q,xm x,zhxx z,yhxx
		a,h_jsfs h,zdxx
		d,wygsxx w,sfdw s where
		y.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.syxm=d.lx and y.wygsid=w.id and x.dwbm=s.dwbm and
		y.djbh=#{id}
	</select>

	<select id="selectdjfw" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select
		m.djbh,f.fwbm,f.cczh,f.mphm,f.xm,f.sfzh,f.mj,f.fwje,m.bjje ftje from ywpzmx
		m,fwxx f where m.fwbm=f.fwbm and m.djbh=#{id}
	</select>

	<delete id="deleteywpzmx" 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="selectywpzmxcount" parameterType="java.lang.String"
		resultType="java.lang.Integer">
		select count(0) from ywpzmx where djbh=#{id}
	</select>

	<delete id="deletemxfw" parameterType="io.renren.modules.app.entity.DhbmyjEntity">
		delete from ywpzmx where
		djbh=#{djbh} and fwbm=#{fwbm}
	</delete>

	<select id="selectshengyumx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.DhbmyjEntity">
		select fwbm,djbh,bjje,je from ywpzmx where djbh=#{id}
	</select>

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

	<select id="selectftmj" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.DhbmyjEntity">
		select m.djbh,m.fwbm,m.bjje,m.je,f.mj from ywpzmx m,fwxx f
		where
		m.fwbm=f.fwbm and m.djbh=#{id}
	</select>

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

	<update id="updatefwxx" parameterType="io.renren.modules.app.entity.FwxxEntity">
		update fwxx set
		ggsy=#{ggsy},dqye=#{dqye} where fwbm=#{fwbm}
	</update>
	<select id="selectfwxxggsy" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select * from fwxx where fwbm=#{id}
	</select>
	<select id="selectzhxxggsy" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select * from zhxx where dhbm=#{id}
	</select>
	<update id="updatezhxx" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		ggsy=#{ggsy},dqye=#{dqye} where dhbm=#{dhbm}
	</update>

	<select id="queryByPageC" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select
		distinct y.djbh,y.djrq,q.xqmc,x.xmmc,z.dhmc,z.dhbm,a.yhmc,h.billname,y.zph,d.value zdmc,y.je
		syze,y.fpfs,y.czyxm,w.wygsmc,s.dwmc
		from ywpz y,xqxx
		q,xm x,zhxx z,yhxx
		a,h_jsfs h,sys_dict
		d,wygsxx w,sfdw s where
		y.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.syxm=d.id and y.wygsid=w.wygsbm and x.dwbm=s.dwbm and y.djlx='04'
		and
		y.pzzt='1' and y.kjqj=#{kjqj}
		<if test=" dhbm!=null and dhbm!='' ">
			and z.dhbm like CONCAT(#{dhbm},"%")
		</if>
		<if test=" xmbm!=null and xmbm!='' ">
			and x.xmbm like CONCAT(#{xmbm},"%")
		</if>
		<if test=" xqbm!=null and xqbm!='' ">
			and q.xqbm like CONCAT(#{xqbm},"%")
		</if>
		<if test=" djbh!=null and djbh!='' ">
			and y.djbh like CONCAT(#{djbh},"%")
		</if>
		<if test=" wygsid!=null and wygsid!='' ">
			and y.wygsid like CONCAT(#{wygsbm},"%")
		</if>
		<if test=" syxm!=null and syxm!='' ">
			and y.syxm like CONCAT(#{lx},"%")
		</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

	</select>
	
	<select id="selectywpzmxbydjbh" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select fwbm,bjje from ywpzmx where djbh=#{id}
	</select>
	
	<select id="queryByCount" parameterType="java.lang.String"
		resultType="java.lang.String">
		select max(substr(djbh,17,4)) from ywpz where
		substr(shrq,1,7)=substr(#{date},1,7) and djlx='04'

	</select>
	
	<select id="selectdwbm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select s.dwbm from zhxx z,xm x,sfdw s where z.xmbm=x.xmbm and x.dwbm=s.dwbm and z.dhbm=#{id}
	</select>

</mapper>