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

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

	</select>

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

	</select>

	<select id="selectlz" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select
		z.dhbm,z.dhmc,z.zmj,z.zje,z.jkbz,z.hwjg,x.dlwz,z.jsbz from
		zhxx
		z,xm x
		where z.xmbm=x.xmbm and
		z.xmbm=#{id}

	</select>

	<select id="queryByPage" parameterType="io.renren.modules.app.entity.ZhxxEntity"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select z.dhbm,z.dhmc,z.zmj,z.zje,s.value
		hwjg,x.dlwz,z.jsbz,z.jkbz from
		zhxx z,xm x,sys_dict s where
		z.xmbm=x.xmbm and z.hwjg=s.id and
		z.sfdz='0' and
		z.xmbm=#{xmbm}

	</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="queryByPageC" parameterType="io.renren.modules.app.entity.YwpzDyEntity"
		resultType="io.renren.modules.app.entity.YwpzDyEntity">
		select
		d.djbh,d.djrq,d.dwmc,x.xmmc,d.mj,d.je,d.fwdz,d.bz,d.czyxm,d.czrq from
		ywpz_dy d,xm x where d.xmbm=x.xmbm and d.djlx='0' and d.kjqj=#{kjqj}
		<if test=" xmbm!=null and xmbm!='' ">
			and d.xmbm like CONCAT(#{xmbm},"%")
		</if>
		<if test=" dwbm!=null and dwbm!='' ">
			and d.dwbm like CONCAT(#{dwbm},"%")
		</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.XlkEntity">
		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='0'

	</select>

</mapper>