ZnbCsjsLogMapper.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.tofly.feesapi.sfgl.mapper.ZnbCsjsLogMapper">
  4. <!--自定义智能表档案分页查询 -->
  5. <select id="getPage" resultType="com.tofly.feesapi.sfgl.entity.vo.ZnbCsjsSelect">
  6. select a.yhbh, a.yhxm, a.yhdz,a.lxdh,
  7. b.sbbh,l.cwrq,l.yysl,l.cbkid,
  8. f.cbbmc as sscbbmc,
  9. g.cbpqmc as sscbpqmc
  10. from yh_khjbxx a
  11. left join yh_cbkxx b on a.yhbh = b.yhbh and b.jfzt='1'
  12. left join (select yhbh,cbkid,cwrq,sum(nvl(yssl,0))yysl from znb_csjs_log
  13. group by cwrq,cbkid,yhbh) l on a.yhbh=l.yhbh
  14. left join bm_cbb f on a.sscbb = f.cbbbm
  15. left join bm_cbpq g on a.sscbpq = g.cbpqbm
  16. WHERE 1=1 and b.sblb in ('2','3')
  17. <!--模糊查询 -->
  18. <if test="filter.searchText!=null">
  19. AND (a.yhbh like '%${filter.searchText}%'
  20. OR a.yhxm like '%${filter.searchText}%'
  21. OR a.yhdz like '%${filter.searchText}%'
  22. OR a.lxdh like '%${filter.searchText}%')
  23. </if>
  24. <!--所属公司-->
  25. <if test="filter.ssgs!=null">
  26. AND a.ssgs=#{filter.ssgs}
  27. </if>
  28. <!--所属片区-->
  29. <if test="filter.sscbpq!=null">
  30. AND a.sscbpq=#{filter.sscbpq}
  31. </if>
  32. <!--所属抄表本-->
  33. <if test="filter.sscbb!=null">
  34. <choose>
  35. <when test="filter.sscbb.indexOf(',')!=-1">
  36. AND a.sscbb in
  37. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  38. close=")">
  39. #{item}
  40. </foreach>
  41. </when>
  42. <otherwise>
  43. AND a.sscbb=#{filter.sscbb}
  44. </otherwise>
  45. </choose>
  46. </if>
  47. <if test="filter.cwrq!=null">
  48. AND l.cwrq=#{filter.cwrq}
  49. </if>
  50. </select>
  51. <select id="getYhysmxList" resultType="com.tofly.feesapi.sfgl.entity.ZnbCsjsLog">
  52. <include refid="querySql"/>
  53. </select>
  54. <sql id="querySql">
  55. SELECT
  56. a.*,
  57. c.sccj, c.czsj, c.cl_clsj ,case c.jsbz when '1' then '已结算' ELSE '未知' END jsbz,
  58. row_number() over (partition by a.cbkid, a.cwrq, to_char(jsrq,'yyyy-mm-dd') order by jsrq desc) AS rn
  59. FROM
  60. znb_csjs_log a
  61. LEFT JOIN
  62. yh_cbkxx b ON a.cbkid = b.cbkid
  63. LEFT JOIN
  64. znb_cb_log c ON a.qflsbh = c.id
  65. WHERE
  66. 1=1
  67. <if test="filter.cwrq != null and filter.cwrq != ''">
  68. AND a.cwrq=#{filter.cwrq}
  69. </if>
  70. <if test="filter.yhbh != null and filter.yhbh != ''">
  71. AND a.yhbh=#{filter.yhbh}
  72. </if>
  73. <if test="filter.cbkid != null and filter.cbkid != ''">
  74. AND a.cbkid=#{filter.cbkid}
  75. </if>
  76. <if test="filter.startDate!=null and filter.endDate!=null">
  77. AND (a.jsrq BETWEEN #{filter.startDate} AND #{filter.endDate})
  78. </if>
  79. <if test="filter.sscbpq != null and filter.sscbpq != ''">
  80. AND a.sscbpq=#{filter.sscbpq}
  81. </if>
  82. <if test="filter.sscbb != null and filter.sscbb != ''">
  83. AND (a.sscbb=#{filter.sscbb})
  84. </if>
  85. <if test="filter.sbsccj != null and filter.sbsccj != ''">
  86. AND (a.sbsccj=#{filter.sbsccj})
  87. </if>
  88. <if test="filter.sl != null and filter.sl != ''">
  89. AND (a.sl>=#{filter.sl})
  90. </if>
  91. <if test="filter.searchText != null and filter.searchText != ''">
  92. AND (a.yhbh like '%${filter.searchText}%' OR a.yhxm like '%${filter.searchText}%')
  93. </if>
  94. </sql>
  95. </mapper>