123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?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="com.unis.transaction.server.dao.TyJyccKhxxDao">
-
- <select id="selectKhxxTj" resultType="com.unis.transaction.server.entity.tradeplan.TyBmkhxxtj">
- select * from (
- select cc.apcc as cc,
- max(cc.ccbh) as ccbh,
- max(cc.wtfmc) as wtdw,
- max(hw.pzmc) as pzmc,
- max(hw.pzbm) as pzbm,
- max(wt.lsxzbm) as lsxzbm,
- kh.khmc as hymc,
- max(kh.jyqbzj) as jyqbzj,
- wt.jyrq as jyrq,
- (select wm_concat(ht.htbh) from ty_jyht ht where ht.apcc = cc.apcc
- and ((ht.jylx = '0' and ht.cmmc = kh.khmc) or (ht.jylx = '1' and ht.sgmc = kh.khmc))) as hth,
- (select count(*) from ty_jyht ht where ht.apcc = cc.apcc
- and ((ht.jylx = '0' and ht.cmmc = kh.khmc) or (ht.jylx = '1' and ht.sgmc = kh.khmc))) as cjqk
- from ty_jycc_khxx kh
- left join ty_jycc cc on kh.wtbh = cc.wtbm
- left join ty_jycrkwt wt on wt.wtbm = cc.wtbm
- left join ty_jycrkwt_hw hw on hw.wtbm = cc.wtbm
- <where>
- <if test="cc != null and cc != ''">
- and cc.apcc like '%' || #{cc} || '%'
- </if>
- <if test="wtdw != null and wtdw != ''">
- and cc.wtfmc like '%' || #{wtdw} || '%'
- </if>
- <if test="pzbm != null and pzbm != ''">
- and hw.pzbm = #{pzbm}
- </if>
- <if test="lsxzbm != null and lsxzbm != ''">
- and wt.lsxzbm = #{lsxzbm}
- </if>
- <if test="hymc != null and hymc != ''">
- and kh.khmc like '%' || #{hymc} || '%'
- </if>
- <if test="jyrqStart != null and jyrqStart != ''">
- and to_date(wt.jyrq, 'yyyy-MM-dd') >= to_date(#{jyrqStart}, 'yyyy-MM-dd')
- </if>
- <if test="jyrqEnd != null and jyrqEnd != ''">
- and to_date(wt.jyrq, 'yyyy-MM-dd') <= to_date(#{jyrqEnd}, 'yyyy-MM-dd')
- </if>
- </where>
- group by cc, hymc, jyrq, hth, cjqk order by wt.jyrq desc,cc.apcc desc) as sub
- <where>
- <if test="cjqk==0">
- and sub.cjqk=0
- </if>
- <if test="cjqk==1">
- and sub.cjqk>0
- </if>
- </where>
- </select>
- <select id="exportKhxxTj" resultType="com.unis.transaction.server.entity.tradeplan.TyBmkhxxtj">
- select * from (
- select cc.apcc as cc,
- max(cc.ccbh) as ccbh,
- max(cc.wtfmc) as wtdw,
- max(hw.pzmc) as pzmc,
- max(hw.pzbm) as pzbm,
- max(wt.lsxzbm) as lsxzbm,
- kh.khmc as hymc,
- max(kh.jyqbzj) as jyqbzj,
- wt.jyrq as jyrq,
- (select wm_concat(ht.htbh) from ty_jyht ht where ht.apcc = cc.apcc
- and ((ht.jylx = '0' and ht.cmmc = kh.khmc) or (ht.jylx = '1' and ht.sgmc = kh.khmc))) as hth,
- (select count(*) from ty_jyht ht where ht.apcc = cc.apcc
- and ((ht.jylx = '0' and ht.cmmc = kh.khmc) or (ht.jylx = '1' and ht.sgmc = kh.khmc))) as cjqk
- from ty_jycc_khxx kh
- left join ty_jycc cc on kh.wtbh = cc.wtbm
- left join ty_jycrkwt wt on wt.wtbm = cc.wtbm
- left join ty_jycrkwt_hw hw on hw.wtbm = cc.wtbm
- <where>
- <if test="cc != null and cc != ''">
- and cc.apcc like '%' || #{cc} || '%'
- </if>
- <if test="wtdw != null and wtdw != ''">
- and cc.wtfmc like '%' || #{wtdw} || '%'
- </if>
- <if test="pzbm != null and pzbm != ''">
- and hw.pzbm = #{pzbm}
- </if>
- <if test="lsxzbm != null and lsxzbm != ''">
- and wt.lsxzbm = #{lsxzbm}
- </if>
- <if test="hymc != null and hymc != ''">
- and kh.khmc like '%' || #{hymc} || '%'
- </if>
- <if test="jyrqStart != null and jyrqStart != ''">
- and to_date(wt.jyrq, 'yyyy-MM-dd') >= to_date(#{jyrqStart}, 'yyyy-MM-dd')
- </if>
- <if test="jyrqEnd != null and jyrqEnd != ''">
- and to_date(wt.jyrq, 'yyyy-MM-dd') <= to_date(#{jyrqEnd}, 'yyyy-MM-dd')
- </if>
- </where>
- group by cc, hymc, jyrq, hth, cjqk order by wt.jyrq desc,cc.apcc desc) as sub
- <where>
- <if test="cjqk==0">
- and sub.cjqk=0
- </if>
- <if test="cjqk==1">
- and sub.cjqk>0
- </if>
- </where>
- </select>
- </mapper>
|