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

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

	</select>

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

	</select>

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

	</select>

	<select id="selectfw" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select fwbm,cczh,xm,mphm from fwxx
		where dhbm=#{bm} and sfsc='0'

	</select>

	<select id="selectfwxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select
		s.dwmc,s.dwbm,f.fwbm,f.xm,f.mj,f.fwje,f.grjjl,f.bz,f.jsbz,f.dz
		from fwxx
		f,sfdw
		s,zhxx z,xm
		x
		where f.dhbm=z.dhbm and z.xmbm=x.xmbm and
		x.dwbm=s.dwbm
		and fwbm=#{id}

	</select>

	<insert id="insertbc" parameterType="io.renren.modules.app.entity.YwpzDyEntity">
		insert into
		ywpz_dy(djbh,djlx,djrq,dwbm,dwmc,xmbm,fwdz,fwbm,cbwdbm,gzdbm,je,mj,czybm,czyxm,bz,kjqj,czrq)
		values(#{djbh},#{djlx},#{djrq},#{dwbm},#{dwmc},#{xmbm},#{fwdz},#{fwbm},#{cbwdbm},#{gzdbm},#{je},#{mj},#{czybm},#{czyxm},#{bz},#{kjqj},#{czrq})
	</insert>

	<select id="queryByPage" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzDyEntity">
		select
		distinct
		d.djbh,d.dwmc,d.fwbm,d.djrq,f.xm,f.mphm,f.cczh,d.mj,d.je,d.fwdz,d.bz,z.dhmc,x.xmmc,q.xqmc
		from ywpz_dy d,fwxx f,zhxx z,xqxx q,xm x where d.fwbm=f.fwbm and
		f.dhbm=z.dhbm and z.xmbm=x.xmbm and x.xqbm=q.xqbm and d.djlx='1' and d.kjqj=#{kjqj}
		<if test=" dwbm!=null and dwbm!='' ">
			and d.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 d.djbh like CONCAT(#{djbh},"%")
		</if>
		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and d.djrq between #{beginrq} and #{endrq}
		</if>
		order by d.czrq desc

	</select>

	<delete id="deletedy" parameterType="io.renren.modules.app.entity.YwpzDyEntity">
		delete from ywpz_dy where
		djbh=#{djbh}
	</delete>
	<select id="queryByCount" parameterType="java.lang.String"
		resultType="java.lang.String">
		select max(substr(djbh,11,4)) from ywpz_dy where
		substr(czrq,1,7)=substr(#{date},1,7) and djlx='1'

	</select>

</mapper>