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



	<select id="queryByPagelb" parameterType="io.renren.modules.app.entity.ZhxxEntity"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select distinct z.dhbm,z.dhmc,z.zmj,z.zje,z.yjje,c.value hwjg,z.dwze
		yjyjje,z.jsbz,z.jkbz,x.dlwz from zhxx
		z,xm x,sys_dict c where z.xmbm=x.xmbm and
		z.sffp='0' and z.sfdz='1' and z.hwjg=c.id
		<if test=" xmbm!=null and xmbm!='' ">
			and z.xmbm like CONCAT(#{xmbm},"%")
		</if>

	</select>

	<insert id="insertfp" 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,shrq)
		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},#{shrq})
	</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>

	<insert id="insertywpz" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		insert into
		ywpz(djbh,djrq,dhbm,dwbm,bz)
		values(#{djbh},#{djrq},#{dhbm},#{dwbm},#{bz})
	</insert>

	<select id="queryByPage" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select
		distinct y.djbh,y.djrq,s.dwmc,s.dwbm,q.xqmc,x.xmmc,y.je,y.shrq,y.czybm,y.czyxm,y.bz
		from ywpz y,yjmx m,sfdw s,xqxx q,xm x,zhxx z
		where y.djbh=m.djbh and
		m.dhbm=z.dhbm and z.xmbm=x.xmbm and x.xqbm=q.xqbm
		and y.dwbm=s.dwbm and
		z.sffp='1' and y.djlx='02'
		<if test=" dwbm!=null and dwbm!='' ">
			and y.dwbm like CONCAT(#{dwbm},"%")
		</if>
		<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=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		<if test=" beginshrq!=null and beginshrq!='' and endshrq!=null and endshrq!='' ">
			and y.shrq between #{beginshrq} and #{endshrq}
		</if>
		order by y.djbh desc
	</select>

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

	</select>

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

	</select>
	<select id="selectkm" resultType="io.renren.modules.app.entity.XlkEntity">
    select km,kmmc,pydm,kmsx from h_km where 1=1
    </select>
    
    <select id="selectkmmc" resultType="io.renren.modules.app.entity.XlkEntity">
    select kmmc from h_km where km=#{id}
    </select>

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

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

	</select>

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

	</select>

	<!-- <select id="selectwxjjyj" parameterType="java.lang.String" resultType="io.renren.modules.app.entity.YwpzEntity"> 
		select * from wxjjyj where yjdhbm=#{id} </select> -->

	<update id="updatefpje" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update zhxx set
		dwyjje=#{je},sffp='1',dwze=0 where dhbm=#{dhbm}
	</update>

	<!-- <update id="updateyjyjje" parameterType="java.lang.String"> update 
		wxjjyj set yjyjje='0' where yjbm=#{dhbm} </update> -->

	<update id="updatefp" parameterType="java.lang.String">
		update zhxx set
		dwyjje='0',sffp='0' where dhbm=#{id}
	</update>

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

	<select id="selectdj" parameterType="java.util.Map"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select
		distinct y.djbh,y.fpfs,s.dwmc,y.djrq,x.xmmc,y.je,y.bz,y.czybm,y.czyxm,y.shrq from ywpz
		y,yjmx
		m,sfdw s,xm x,zhxx z where
		y.djbh=m.djbh and m.dhbm=z.dhbm and
		z.xmbm=x.xmbm and y.dwbm=s.dwbm and y.djbh=#{djbh}
	</select>

	<select id="selectyjmx" parameterType="java.util.Map"
		resultType="io.renren.modules.app.entity.DhbmyjEntity">
		select distinct m.dhbm,z.dhmc,s.value
		hwjg,z.zmj,z.zje,z.jsbz,z.jkbz,m.je,x.dlwz from yjmx m,zhxx z,xm
		x,sys_dict s where m.dhbm=z.dhbm
		and z.xmbm=x.xmbm and z.hwjg=s.id
		and
		m.djbh=#{djbh}
	</select>

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

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

	<update id="updatezhxx" parameterType="java.lang.String">
		update zhxx set
		dwyjje='0',sffp='0' where dhbm=#{id}
	</update>

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

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

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

	<delete id="deleteywpzmx" parameterType="java.lang.String">
		delete from ywpzmx where djbh=#{id}
	</delete>
	
	<select id="selectdwxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.SfdwEntity">
		select * from sfdw
		where dwbm=#{id}
	</select>
	<update id="updatedwzckje" parameterType="io.renren.modules.app.entity.SfdwEntity">
	update sfdw set zckje=#{zckje} where dwbm=#{dwbm}
	</update>
	
	<select id="selectywpz" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select * from ywpz
		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(djrq,1,7)=substr(#{date},1,7) and djlx='02'

	</select>
	
	<select id="selectdqye" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select * from zhxx where dhbm=#{id}
	</select>
	
	<update id="updatezhxxdqye" parameterType="io.renren.modules.app.entity.ZhxxEntity">
	   update zhxx set dqye=#{dqye} where dhbm=#{dhbm}
	</update>
	
	<select id="selectfwxxdqye" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select * from fwxx where fwbm=#{id}
	</select>
	
	<update id="updatefwxxdqye" parameterType="io.renren.modules.app.entity.FwxxEntity">
	   update fwxx set dqye=#{dqye} where fwbm=#{fwbm}
	</update>
	
	<select id="selectsfyfw" parameterType="java.lang.String"
		resultType="Integer">
		select count(*) from fwxx where dhbm=#{id}

	</select>
	
	<update id="updatezhxxdwze" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		dwze=#{dwyjje} where dhbm=#{dhbm}
	</update>

</mapper>