<?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.MxzDao">
	<select id="mxzSelect_2" parameterType="io.renren.modules.app.entity.MxzEntity" resultType="io.renren.modules.app.entity.MxzEntity">
	select pzrq,pztype,pzh,zymc,jfje,dfje,ifnull(qcye,'0') qcye,ss ,#{kmsx} kmsx,#{hskmdm} hskmdm,#{qskjqj} qskjqj, #{zzkjqj} zzkjqj,kjqj from (
      select concat(#{qskjqj},'-01') pzrq,'' pztype,0 pzh,'期初余额' zymc, 0 jfje,0 dfje ,sum(qcye) qcye,'0' ss,#{kmsx} kmsx, ifnull(kjqj,#{qskjqj}) kjqj from h_kmye
        where kjqj = #{qskjqj}  and ztbm=#{ztbm} and hskmdm like '${hskmdm}%'
      union all
      select pzrq,pztype,pzh ,zymc,jfje,dfje,0 qcye,'1' ss ,#{kmsx} kmsx, kjqj from h_pz where kjqj &gt;= #{qskjqj} and kjqj &lt;= #{zzkjqj}
      and (ztbm=#{ztbm}) and (km like '${hskmdm}%') and (sfjz ='1')
      ) b order by ss,kjqj,pzrq,pztype,pzh
	</select>

    <select id="mxzSelect_1" parameterType="io.renren.modules.app.entity.MxzEntity" resultType="io.renren.modules.app.entity.MxzEntity">
   select pzrq,pztype,pzh,zymc,jfje,dfje,ifnull(qcye,'0') qcye,ss ,#{kmsx} kmsx,#{hskmdm} hskmdm,#{qskjqj} qskjqj,#{zzkjqj} zzkjqj,kjqj from (
      select concat(#{qskjqj},'-01') pzrq,'' pztype,0 pzh,'期初余额' zymc, 0 jfje,0 dfje ,sum(qcye) qcye,'0' ss,#{kmsx} kmsx, ifnull(kjqj,#{qskjqj}) kjqj from h_kmye
        where kjqj = #{qskjqj}  and ztbm=#{ztbm} and hskmdm like '${hskmdm}%'
      union all
      select pzrq,pztype,pzh ,zymc,jfje,dfje,0 qcye,'1' ss ,#{kmsx} kmsx, kjqj from h_pz where kjqj &gt;= #{qskjqj} and kjqj &lt;= #{zzkjqj}
      and (ztbm=#{ztbm}) and (km like '${hskmdm}%')
      ) b order by ss,kjqj,pzrq,pztype,pzh
    </select>
    
    <select id="select_pz" parameterType="io.renren.modules.app.entity.HPzEntity2" resultType="io.renren.modules.app.entity.HPzEntity2">
    	select * from h_pz where kjqj=#{kjqj} and pzh=#{pzh} order by flxh
    </select>
    
    <select id="select_kmmc" resultType="String">
    	select trim(kmmc)  kmmc from h_km where km=substr(trim(#{kmdm}),1,#{len}) and ztbm=#{ztbm}
    </select>
    
    <select id="select_kmjb2" resultType="String">
    	select substr(#{kmjb},#{len3},1) from dual
    </select>
    
    <select id="select_kmjb" resultType="String">
    	select kmjb from h_zt where ztbm = #{ztbm}
    </select>
</mapper>