TyJycckhxxMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.unis.transaction.server.dao.TyJyccKhxxDao">
  4. <select id="selectKhxxTj" resultType="com.unis.transaction.server.entity.tradeplan.TyBmkhxxtj">
  5. select * from (
  6. select cc.apcc as cc,
  7. max(cc.ccbh) as ccbh,
  8. max(cc.wtfmc) as wtdw,
  9. max(hw.pzmc) as pzmc,
  10. max(hw.pzbm) as pzbm,
  11. max(wt.lsxzbm) as lsxzbm,
  12. kh.khmc as hymc,
  13. max(kh.jyqbzj) as jyqbzj,
  14. wt.jyrq as jyrq,
  15. (select wm_concat(ht.htbh) from ty_jyht ht where ht.apcc = cc.apcc
  16. and ((ht.jylx = '0' and ht.cmmc = kh.khmc) or (ht.jylx = '1' and ht.sgmc = kh.khmc))) as hth,
  17. (select count(*) from ty_jyht ht where ht.apcc = cc.apcc
  18. and ((ht.jylx = '0' and ht.cmmc = kh.khmc) or (ht.jylx = '1' and ht.sgmc = kh.khmc))) as cjqk
  19. from ty_jycc_khxx kh
  20. left join ty_jycc cc on kh.wtbh = cc.wtbm
  21. left join ty_jycrkwt wt on wt.wtbm = cc.wtbm
  22. left join ty_jycrkwt_hw hw on hw.wtbm = cc.wtbm
  23. <where>
  24. <if test="cc != null and cc != ''">
  25. and cc.apcc like '%' || #{cc} || '%'
  26. </if>
  27. <if test="wtdw != null and wtdw != ''">
  28. and cc.wtfmc like '%' || #{wtdw} || '%'
  29. </if>
  30. <if test="pzbm != null and pzbm != ''">
  31. and hw.pzbm = #{pzbm}
  32. </if>
  33. <if test="lsxzbm != null and lsxzbm != ''">
  34. and wt.lsxzbm = #{lsxzbm}
  35. </if>
  36. <if test="hymc != null and hymc != ''">
  37. and kh.khmc like '%' || #{hymc} || '%'
  38. </if>
  39. <if test="jyrqStart != null and jyrqStart != ''">
  40. and to_date(wt.jyrq, 'yyyy-MM-dd') &gt;= to_date(#{jyrqStart}, 'yyyy-MM-dd')
  41. </if>
  42. <if test="jyrqEnd != null and jyrqEnd != ''">
  43. and to_date(wt.jyrq, 'yyyy-MM-dd') &lt;= to_date(#{jyrqEnd}, 'yyyy-MM-dd')
  44. </if>
  45. </where>
  46. group by cc, hymc, jyrq, hth, cjqk order by wt.jyrq desc,cc.apcc desc) as sub
  47. <where>
  48. <if test="cjqk==0">
  49. and sub.cjqk=0
  50. </if>
  51. <if test="cjqk==1">
  52. and sub.cjqk&gt;0
  53. </if>
  54. </where>
  55. </select>
  56. <select id="exportKhxxTj" resultType="com.unis.transaction.server.entity.tradeplan.TyBmkhxxtj">
  57. select * from (
  58. select cc.apcc as cc,
  59. max(cc.ccbh) as ccbh,
  60. max(cc.wtfmc) as wtdw,
  61. max(hw.pzmc) as pzmc,
  62. max(hw.pzbm) as pzbm,
  63. max(wt.lsxzbm) as lsxzbm,
  64. kh.khmc as hymc,
  65. max(kh.jyqbzj) as jyqbzj,
  66. wt.jyrq as jyrq,
  67. (select wm_concat(ht.htbh) from ty_jyht ht where ht.apcc = cc.apcc
  68. and ((ht.jylx = '0' and ht.cmmc = kh.khmc) or (ht.jylx = '1' and ht.sgmc = kh.khmc))) as hth,
  69. (select count(*) from ty_jyht ht where ht.apcc = cc.apcc
  70. and ((ht.jylx = '0' and ht.cmmc = kh.khmc) or (ht.jylx = '1' and ht.sgmc = kh.khmc))) as cjqk
  71. from ty_jycc_khxx kh
  72. left join ty_jycc cc on kh.wtbh = cc.wtbm
  73. left join ty_jycrkwt wt on wt.wtbm = cc.wtbm
  74. left join ty_jycrkwt_hw hw on hw.wtbm = cc.wtbm
  75. <where>
  76. <if test="cc != null and cc != ''">
  77. and cc.apcc like '%' || #{cc} || '%'
  78. </if>
  79. <if test="wtdw != null and wtdw != ''">
  80. and cc.wtfmc like '%' || #{wtdw} || '%'
  81. </if>
  82. <if test="pzbm != null and pzbm != ''">
  83. and hw.pzbm = #{pzbm}
  84. </if>
  85. <if test="lsxzbm != null and lsxzbm != ''">
  86. and wt.lsxzbm = #{lsxzbm}
  87. </if>
  88. <if test="hymc != null and hymc != ''">
  89. and kh.khmc like '%' || #{hymc} || '%'
  90. </if>
  91. <if test="jyrqStart != null and jyrqStart != ''">
  92. and to_date(wt.jyrq, 'yyyy-MM-dd') &gt;= to_date(#{jyrqStart}, 'yyyy-MM-dd')
  93. </if>
  94. <if test="jyrqEnd != null and jyrqEnd != ''">
  95. and to_date(wt.jyrq, 'yyyy-MM-dd') &lt;= to_date(#{jyrqEnd}, 'yyyy-MM-dd')
  96. </if>
  97. </where>
  98. group by cc, hymc, jyrq, hth, cjqk order by wt.jyrq desc,cc.apcc desc) as sub
  99. <where>
  100. <if test="cjqk==0">
  101. and sub.cjqk=0
  102. </if>
  103. <if test="cjqk==1">
  104. and sub.cjqk&gt;0
  105. </if>
  106. </where>
  107. </select>
  108. </mapper>