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

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

		select
		distinct
		y.djbh,s.dwmc,y.djrq,a.yhmc,y.je,y.czyxm,h.billname,y.zph,y.bz,(case
		y.shzt when '1' then '已复核' when '0' then '未复核' else '' END)
		shzt,y.shrxm,y.shrq
		from ywpz y,sfdw s,h_jsfs h,yhxx a,yjmx m,zhxx
		z,xqxx q,xm x
		where
		y.dwbm=s.dwbm and
		y.bank_code=a.yhbm and
		y.jsfs=h.billcode and djlx='01' and y.djbh=m.djbh and m.dhbm=z.dhbm
		and z.xmbm=x.xmbm and x.xqbm=q.xqbm
		<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=" bz!=null and bz!='' ">
			and y.bz like CONCAT(#{bz},"%")
		</if>
		<if test=" jsfs!=null and jsfs!='' ">
			and y.jsfs like CONCAT(#{jsfs},"%")
		</if>
		<if test=" dhbm!=null and dhbm!='' ">
			and m.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=" 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 -->
		order by y.djrq,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.zph,y.bz,y.shzt
		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,x.xmmc,z.dhmc,z.zmj,z.yjje,z.zje,m.je,z.dwze
		yjyjje,z.gryjje,s.value hwjg,(case
		z.jsbz when '1' then '按金额' when '0'
		then '按面积' when '2' then '按造价' else '' END)
		jsbz,z.jkbz from yjmx
		m,zhxx z,xm x,sys_dict
		s where
		m.dhbm=z.dhbm and z.hwjg=s.id and z.xmbm=x.xmbm and
		m.djbh=#{id}
	</select>

	<select id="selectfhzt" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select * from ywpz where djbh=#{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="updatezhxx" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		dwze=#{dwze} where dhbm=#{dhbm}
	</update>

	<update id="updatezhsfdz" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		sfdz='1'
		where dhbm=#{dhbm}
	</update>
	<update id="updatezhsfdz2" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		sfdz='0'
		where dhbm=#{dhbm}
	</update>


	<update id="updatefhzt" parameterType="io.renren.modules.app.entity.DhbmyjEntity">
		update ywpz set
		shzt='1',shrbm=#{shrbm},shrxm=#{shrxm},shrq=#{shrq} where
		djbh=#{djbh}
	</update>

	<update id="updateqxsh" parameterType="java.lang.String">
		update ywpz set
		shzt='0',shrbm='',shrxm='',shrq=''
		where djbh=#{id}
	</update>

	<!-- <select id="selectwxjjyj" parameterType="java.lang.String" resultType="io.renren.modules.app.entity.YwpzEntity"> 
		select yjbm,yjdhbm,yjsjje,yjqjje,yjyjje,yjrq,jkfx from wxjjyj where yjdhbm=#{id} 
		</select> -->

	<!-- <update id="updatewxjjyj" parameterType="io.renren.modules.app.entity.YwpzEntity"> 
		update wxjjyj set yjyjje=#{yjyjje} where yjbm=#{yjbm} </update> <insert id="insertwxjjyj" 
		parameterType="io.renren.modules.app.entity.YwpzEntity"> insert into wxjjyj(yjbm,yjdhbm,yjyjje)values(#{yjbm},#{yjdhbm},#{yjyjje}) 
		</insert> -->

	<select id="selectfwbydh" parameterType="java.lang.String"
		resultType="Double">
		select sum(grje) from fwxx where dhbm=#{dhbm}
	</select>

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

	<select id="selectmhdw" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select s.dwmc,s.dwbm from sfdw s where 1=1
		<if test=" _mhdwz!=null and _mhdwz!=''">
			and s.dwmc like '%${_mhdwz}%' or s.dwbm like '%${_mhdwz}%'
		</if>
	</select>

	<select id="selectxlkxq" resultType="io.renren.modules.app.entity.XlkEntity">
		select x.xqmc,x.xqbm from xqxx x where 1=1
		<if test=" _pt!=null and _pt!=''">
			and x.xqmc like '%${_pt}%' or x.xqbm like '%${_pt}%'
		</if>
	</select>

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

	<select id="selectyhxx" resultType="io.renren.modules.app.entity.XlkEntity">
		select yhmc,yhbm from yhxx
		where 1=1
	</select>
	<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="selectyjmxyw" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select dhbm from yjmx where djbh=#{id}
	</select>

	<select id="selecthskm" resultType="io.renren.modules.app.entity.XlkEntity">
		select km,kmmc,pydm from h_km
		where kmlbbm='1'
	</select>

	<select id="selectyjyjje" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select yjyjje,yjbm from wxjjyj where yjdhbm=#{id}

	</select>

	<insert id="insertwxjjyj" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		insert into
		wxjjyj(yjbm,yjdhbm,yjyjje)values(#{yjbm},#{yjdhbm},#{yjyjje})
	</insert>

	<update id="updatewxjjyj" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update wxjjyj set
		yjyjje=#{yjyjje} where yjbh=#{yjbm}
	</update>

	<select id="selectmxje" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select je,dhbm from yjmx where djbh=#{id}
	</select>



	<select id="selectlistglb" resultType="io.renren.modules.app.entity.ZhxxEntity">
		select yjdhbm,yjyjje from wxjjyj
	</select>

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

	<update id="updateld" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set dwze = #{yjyjje} where dhbm = #{yjdhbm}
	</update>

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

	<select id="selectyjfwxx" resultType="io.renren.modules.app.entity.FwxxEntity">
		select * from ywpzmx where SUBSTRING(djbh FROM 5 FOR 2)='03'
	</select>

	<select id="selectfw" resultType="io.renren.modules.app.entity.FwxxEntity">
		select * from fwxx where fwbm=#{id}
	</select>
	<update id="updatefwsfyj" parameterType="java.lang.String">
		update fwxx set sfyj='1' where fwbm=#{id}
	</update>

	<select id="selectsqrq" resultType="io.renren.modules.app.entity.SqwxzqEntity">
		select DATE_FORMAT(STR_TO_DATE(a.sqrq,'%m/%d/%Y'),'%Y-%m-%d') AS
		sqrq,a.sqdbh from sqwxzq a where LENGTH(a.sqrq) >15
	</select>

	<update id="updatesqrq" parameterType="io.renren.modules.app.entity.SqwxzqEntity">
		update sqwxzq set sqrq = #{sqrq} where sqdbh=#{sqdbh}
	</update>

	<select id="selectxm" resultType="io.renren.modules.app.entity.XmEntity">
		select * from xm where xmbm &lt;'000100192'
	</select>

	<select id="selectkmbyxq" resultType="io.renren.modules.app.entity.HKmEntity">
		select * from h_km where kmmc=(select xqmc from xqxx where xqbm=#{id})
	</select>

	<update id="updatexmkfskm" parameterType="io.renren.modules.app.entity.XmEntity">
		update xm set kfskm =#{kfskm} where xmbm=#{xmbm}
	</update>

	<select id="selectsqje" resultType="io.renren.modules.app.entity.SqwxzqEntity">
		select sqje,sqdbh from sqwxzq where sfsh='1'
	</select>

	<update id="updatespje" parameterType="io.renren.modules.app.entity.SqwxzqEntity">
		update sqwxzq set spje = #{sqje} where sqdbh=#{sqdbh}
	</update>

	<select id="selectywpzdjrq" resultType="io.renren.modules.app.entity.YwpzEntity">
		select djbh,SUBSTR(djrq FROM 1 FOR 11) djrq from ywpz where LENGTH(djrq)>11
	</select>

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

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

	<select id="selectfzhsdj" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select DISTINCT y.djbh,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="insertfzhsmx" 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="deletefzhsdj" parameterType="java.lang.String" >
		delete from fzhsmx where djbh=#{id}
	</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="selectkjqjbydjbh" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select * from fzhsye where gjkjqj=(select kjqj from ywpz where djbh=#{id}) and djlx='01'
	</select>
	
	<select id="selectfffff" parameterType="java.lang.String" resultType="io.renren.modules.app.entity.YwpzEntity">
		select z.xmbm,y.je dffse from yjmx y,zhxx z where y.dhbm=z.dhbm and y.djbh=#{id}
	</select>
	
	<select id="selectqcye" parameterType="io.renren.modules.app.entity.YwpzEntity" resultType="io.renren.modules.app.entity.YwpzEntity">
		select qcye,dffse,qmye from fzhsye where gjkjqj=#{gjkjqj} and djlx=#{djlx} and xmbm=#{xmbm}
	</select>
	
	<update id="updatefzhsye" parameterType="io.renren.modules.app.entity.YwpzEntity" >
		update fzhsye set dffse=#{dffse},qmye=#{qmye} where gjkjqj=#{gjkjqj} and xmbm=#{xmbm} and djlx=#{djlx}
	</update>
	
	<update id="updatefzhsye111" parameterType="io.renren.modules.app.entity.YwpzEntity" >
		update fzhsye set qcye=#{qcye},dffse=#{dffse},qmye=#{qmye} where gjkjqj=#{gjkjqj} and xmbm=#{xmbm} and djlx=#{djlx}
	</update>
	
	<select id="selectfzhsye" parameterType="java.lang.String" resultType="io.renren.modules.app.entity.YwpzEntity">
		select * from fzhsye where gjkjqj=#{id} and (djlx='01' or djlx='03')
	</select>
	
	<insert id="insertfzhsye" parameterType="io.renren.modules.app.entity.YwpzEntity">
	insert into fzhsye(gjkjqj,xmbm,djlx,qcye,jffse,dffse,qmye)values(#{gjkjqj},#{xmbm},#{djlx},#{qcye},#{jffse},#{dffse},#{qmye})
	</insert>
	
	<select id="ywkjqj" parameterType="java.lang.String" resultType="java.lang.String">
		select kjqj from ywpz where djbh=#{id}
	</select>
	
	<select id="selectmaxkjqj" resultType="string">
		select MAX(gjkjqj) from fzhsye
	</select>
	
	<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>

</mapper>