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

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

		select
		distinct
		y.djbh,y.djrq,m.fwbm,s.dwmc,q.xqmc,x.xmmc,z.dhmc,f.lc,f.mphm,
		c.value
		fwxz,f.fwje,f.mj,y.je,f.ssdj,f.jsbz,f.xm,f.gfrq,f.grjjl,(case
		y.shzt
		when '1' then '已复核' when '0' then '未复核' else '' END)
		shzt,y.shrxm,y.shrq
		from ywpzmx m,xm
		x,zhxx z,fwxx f,ywpz y,sfdw s,xqxx
		q,sys_dict c where
		m.dhbm=z.dhbm and
		z.xmbm=x.xmbm and
		m.fwbm=f.fwbm and
		m.djbh=y.djbh and
		y.dwbm=s.dwbm and
		x.xqbm=q.xqbm and f.fwxz=c.id and
		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=" xmbm!=null and xmbm!='' ">
			and x.xmbm like CONCAT(#{xmbm},"%")
		</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>
		and y.djrq between #{beginrq}
		and #{endrq} order by y.djrq,djbh desc



	</select>

	<select id="selectgrwxfh" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XzdyFwxxSdEntity">
		select f.fwbm fwbm,x.xmmc xmmc,z.dhmc dhmc,f.lc lc,f.mphm
		mphm,f.fwxz
		fwxz,f.fwje fwje,f.jjze jjze,f.xm xm,f.gfrq gfrq,f.spzt
		spzt from xm
		x,zhxx z,fwxx f where
		x.xmbm=z.xmbm and z.dhbm=f.dhbm and
		fwbm=#{fwbm}
	</select>

	<select id="selectfwzt" parameterType="java.lang.String"
		resultType="java.lang.String">
		select shzt from ywpz where djbh=#{id}
	</select>

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

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

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

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

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

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

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

	</select>

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

	</select>
	<select id="selectzhxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select * from zhxx where dhbm=#{dhbm}
	</select>
	<update id="updatezhxx" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set gryjje=#{gryjje},dqye=#{dqye} where dhbm=#{dhbm}
	</update>

	<select id="selectdjrqbydjbh" parameterType="java.lang.String"
		resultType="java.lang.String">
		select djrq from ywpz where djbh=#{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,CONCAT(q.xqmc,'_',x.xmmc,'_',f.mphm,'_',f.xm) xm 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.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},#{xm})
	</insert>
	
	<delete id="deletefzhsdj" parameterType="java.lang.String" >
		delete from fzhsmx where djbh=#{id}
	</delete>
	
	<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='03'
	</select>
	
	<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>
	
	<select id="selectfffff" parameterType="java.lang.String" resultType="io.renren.modules.app.entity.YwpzEntity">
		select z.xmbm,y.je dffse from ywpzmx 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>

</mapper>