YyCblrLsMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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.cbgl.mapper.YyCblrLsMapper">
  4. <resultMap id="yyCblrLsMap" type="com.tofly.feesapi.cbgl.entity.YyCblrLs">
  5. <id property="shryxm" column="SHRYXM"/>
  6. <result property="id" column="ID"/>
  7. <result property="yhbh" column="YHBH"/>
  8. <result property="cbkh" column="CBKH"/>
  9. <result property="cbkid" column="CBKID"/>
  10. <result property="ssgs" column="SSGS"/>
  11. <result property="sscbpq" column="SSCBPQ"/>
  12. <result property="sscbb" column="SSCBB"/>
  13. <result property="cwrq" column="CWRQ"/>
  14. <result property="scds" column="SCDS"/>
  15. <result property="bcds" column="BCDS"/>
  16. <result property="jjl" column="JJL"/>
  17. <result property="cbrybm" column="CBRYBM"/>
  18. <result property="cbryxm" column="CBRYXM"/>
  19. <result property="cbrq" column="CBRQ"/>
  20. <result property="lrrybm" column="LRRYBM"/>
  21. <result property="lrryxm" column="LRRYXM"/>
  22. <result property="lrrq" column="LRRQ"/>
  23. <result property="photo" column="PHOTO"/>
  24. <result property="cbbz" column="CBBZ"/>
  25. <result property="shbz" column="SHBZ"/>
  26. <result property="jsbz" column="JSBZ"/>
  27. <result property="cbcs" column="CBCS"/>
  28. <result property="cbxh" column="CBXH"/>
  29. <result property="bz" column="BZ"/>
  30. <result property="cblx" column="CBLX"/>
  31. <result property="cbfs" column="CBFS"/>
  32. <result property="jfzt" column="JFZT"/>
  33. <result property="sl" column="SL"/>
  34. <result property="jbzd" column="JBZD"/>
  35. <result property="xbqd" column="XBQD"/>
  36. <result property="jbbh" column="JBBH"/>
  37. <result property="cbly" column="CBLY"/>
  38. <result property="x" column="X"/>
  39. <result property="y" column="Y"/>
  40. <result property="shry" column="SHRY"/>
  41. <result property="shsj" column="SHSJ"/>
  42. <result property="shsm" column="SHSM"/>
  43. <result property="ssregion" column="SSREGION"/>
  44. <result property="nbzxds" column="NBZXDS"/>
  45. <result property="nbzxcbrq" column="NBZXCBRQ"/>
  46. <result property="sccbrq" column="SCCBRQ"/>
  47. </resultMap>
  48. <select id="cbsltj" resultType="com.tofly.feesapi.cbgl.entity.vo.CbSltjSelect">
  49. <if test="filter.tjlb=='cbry'">
  50. SELECT
  51. cbrybm AS tjlb,
  52. COUNT(1) AS cbhs,
  53. SUM(sl) AS cbsl
  54. FROM
  55. YY_CBLR_LS
  56. WHERE
  57. jfzt = '1'
  58. AND cbbz = '1'
  59. <if test="filter.ssgs!=null">
  60. AND ssgs = #{filter.ssgs}
  61. </if>
  62. <if test="filter.sscbpq!=null">
  63. AND sscbpq = #{filter.sscbpq}
  64. </if>
  65. <if test="filter.sscbb!=null">
  66. <choose>
  67. <when test="filter.sscbb.indexOf(',')!=-1">
  68. AND sscbb in
  69. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  70. close=")">
  71. #{item}
  72. </foreach>
  73. </when>
  74. <otherwise>
  75. AND sscbb=#{filter.sscbb}
  76. </otherwise>
  77. </choose>
  78. </if>
  79. <if test="filter.cwrq!=null">
  80. AND cwrq = #{filter.cwrq}
  81. </if>
  82. GROUP BY
  83. cbrybm
  84. </if>
  85. <if test="filter.tjlb=='ysxz'">
  86. SELECT
  87. a.NAME AS tjlb,
  88. NVL(COUNT(1),0) AS cbhs,
  89. NVL(SUM(sl),0) AS cbsl
  90. FROM bm_yslx a
  91. Left JOIN BM_SJ b ON b.yslx = a.CODE
  92. Left JOIN YH_CBKXX c ON c.sjbm=b.code
  93. Left join YY_CBLR_LS d ON c.CBKID = d.CBKID
  94. WHERE d.jfzt = '1'
  95. AND d.cbbz = '1'
  96. <if test="filter.ssgs!=null">
  97. AND d.ssgs = #{filter.ssgs}
  98. </if>
  99. <if test="filter.sscbpq!=null">
  100. AND d.sscbpq = #{filter.sscbpq}
  101. </if>
  102. <if test="filter.sscbb!=null">
  103. <choose>
  104. <when test="filter.sscbb.indexOf(',')!=-1">
  105. AND d.sscbb in
  106. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  107. close=")">
  108. #{item}
  109. </foreach>
  110. </when>
  111. <otherwise>
  112. AND d.sscbb=#{filter.sscbb}
  113. </otherwise>
  114. </choose>
  115. </if>
  116. <if test="filter.cwrq!=null">
  117. AND d.cwrq = #{filter.cwrq}
  118. </if>
  119. GROUP BY
  120. a.NAME
  121. </if>
  122. <if test="filter.tjlb=='cbb'">
  123. SELECT
  124. b.CBBMC AS tjlb,
  125. NVL(COUNT(1),0) AS cbhs,
  126. NVL(SUM(sl),0) AS cbsl
  127. FROM
  128. YY_CBLR_LS a
  129. LEFT JOIN BM_CBB b ON a.sscbb = b.cbbbm
  130. WHERE
  131. a.jfzt = '1'
  132. AND a.cbbz = '1'
  133. <if test="filter.ssgs!=null">
  134. AND a.ssgs = #{filter.ssgs}
  135. </if>
  136. <if test="filter.sscbpq!=null">
  137. AND a.sscbpq = #{filter.sscbpq}
  138. </if>
  139. <if test="filter.sscbb!=null">
  140. <choose>
  141. <when test="filter.sscbb.indexOf(',')!=-1">
  142. AND a.sscbb in
  143. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  144. close=")">
  145. #{item}
  146. </foreach>
  147. </when>
  148. <otherwise>
  149. AND a.sscbb=#{filter.sscbb}
  150. </otherwise>
  151. </choose>
  152. </if>
  153. <if test="filter.cwrq!=null">
  154. AND a.cwrq = #{filter.cwrq}
  155. </if>
  156. GROUP BY
  157. b.CBBMC
  158. </if>
  159. </select>
  160. <select id="cbltj" resultType="com.tofly.feesapi.cbgl.entity.vo.CbltjSelect">
  161. <if test="filter.tjlb=='cbry'">
  162. SELECT
  163. b.CBY AS tjlb,
  164. COUNT(1) AS ycbs,
  165. SUM(CASE WHEN a.cbbz = '1' THEN 1 ELSE 0 END) AS scbs,
  166. SUM(CASE WHEN a.cbbz = '1' THEN sl ELSE 0 END) AS scsl
  167. FROM
  168. YY_CBLR_LS a
  169. LEFT JOIN BM_CBB b ON a.sscbb = b.cbbbm
  170. WHERE a.jfzt = '1' and a.xycb=1
  171. <if test="filter.ssgs!=null">
  172. AND a.ssgs = #{filter.ssgs}
  173. </if>
  174. <if test="filter.sscbpq!=null">
  175. AND a.sscbpq = #{filter.sscbpq}
  176. </if>
  177. <if test="filter.sscbb!=null">
  178. <choose>
  179. <when test="filter.sscbb.indexOf(',')!=-1">
  180. AND a.sscbb in
  181. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  182. close=")">
  183. #{item}
  184. </foreach>
  185. </when>
  186. <otherwise>
  187. AND a.sscbb=#{filter.sscbb}
  188. </otherwise>
  189. </choose>
  190. </if>
  191. AND a.cwrq = #{filter.cwrq}
  192. GROUP BY
  193. b.CBY
  194. </if>
  195. <if test="filter.tjlb=='cbb'">
  196. SELECT
  197. b.cby as cby,
  198. b.cbbmc AS tjlb,
  199. COUNT(1) AS ycbs,
  200. SUM(CASE WHEN a.cbbz = '1' THEN 1 ELSE 0 END) AS scbs,
  201. SUM(CASE WHEN a.cbbz = '1' THEN sl ELSE 0 END) AS scsl
  202. FROM
  203. YY_CBLR_LS a
  204. LEFT JOIN BM_CBB b ON a.sscbb = b.cbbbm
  205. WHERE a.jfzt = '1' and a.xycb=1
  206. <if test="filter.ssgs!=null">
  207. AND a.ssgs = #{filter.ssgs}
  208. </if>
  209. <if test="filter.sscbpq!=null">
  210. AND a.sscbpq = #{filter.sscbpq}
  211. </if>
  212. <if test="filter.sscbb!=null">
  213. <choose>
  214. <when test="filter.sscbb.indexOf(',')!=-1">
  215. AND a.sscbb in
  216. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  217. close=")">
  218. #{item}
  219. </foreach>
  220. </when>
  221. <otherwise>
  222. AND a.sscbb=#{filter.sscbb}
  223. </otherwise>
  224. </choose>
  225. </if>
  226. AND a.cwrq = #{filter.cwrq}
  227. GROUP BY b.cbbmc,b.cby
  228. order by b.cby asc, b.cbbmc asc
  229. </if>
  230. </select>
  231. <!--抄表异常明细-->
  232. <select id="cbycmx" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCbycmxSelect">
  233. <include refid="mainSql"/>
  234. </select>
  235. <!--抄表异常明细(分页)-->
  236. <select id="cbycmxPage" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCbycmxSelect">
  237. <include refid="mainSql"/>
  238. </select>
  239. <sql id="mainSql">
  240. SELECT
  241. g.mc AS ssgsmc, e.cbpqmc AS sscbpqmc, f.cbbmc AS sscbbmc,
  242. b.yhbh, b.yhxm, b.yhdz, b.bcds, h.name AS cblxmc, b.sl,
  243. NVL(b1.sl, 0) AS scsl1, NVL(b2.sl, 0) AS scsl2, NVL(b3.sl, 0) AS scsl3,
  244. ROUND(NVL(b1.sl, 0) + NVL(b2.sl, 0) + NVL(b3.sl, 0) / 3, 2) AS avgsl
  245. FROM
  246. (
  247. <include refid="subSql"/>
  248. AND a.cwrq = #{filter.cwrq}
  249. ) b
  250. LEFT JOIN
  251. (
  252. <include refid="subSql"/>
  253. AND a.cwrq = #{cwrq1}
  254. ) b1 ON b.cbkid = b1.cbkid
  255. LEFT JOIN
  256. (
  257. <include refid="subSql"/>
  258. AND a.cwrq = #{cwrq2}
  259. ) b2 ON b.cbkid = b2.cbkid
  260. LEFT JOIN
  261. (
  262. <include refid="subSql"/>
  263. AND a.cwrq = #{cwrq3}
  264. ) b3 ON b.cbkid = b3.cbkid
  265. LEFT JOIN
  266. bm_cbpq e on b.sscbpq = e.cbpqbm
  267. LEFT JOIN
  268. bm_cbb f on b.sscbb = f.cbbbm
  269. LEFT JOIN
  270. bm_gs g on b.ssgs = g.bm
  271. LEFT JOIN
  272. bm_cblx h on b.cblx = h.code
  273. WHERE
  274. 1=1
  275. <if test="filter.bfb!=null">
  276. AND ((b.sl = 0 AND ROUND(NVL(b1.sl, 0) + NVL(b2.sl, 0) + NVL(b3.sl, 0) / 3, 2) > 0)
  277. OR (b.sl > 0 AND ROUND((ABS(b.sl - ROUND(NVL(b1.sl, 0) + NVL(b2.sl, 0) + NVL(b3.sl, 0) / 3, 2)) * 100) /
  278. b.sl, 0) > #{filter.bfb}))
  279. </if>
  280. <if test="filter.zjl>0">
  281. AND (b.sl-b1.sl)> #{filter.zjl}
  282. </if>
  283. <if test="filter.flxl!=null">
  284. <if test="filter.flxl">
  285. AND b1.sl=b2.sl AND b2.sl=b3.sl
  286. </if>
  287. </if>
  288. <if test="filter.flw0!=null">
  289. <if test="filter.flw0">
  290. AND b.sl=0
  291. </if>
  292. </if>
  293. <if test="filter.wcb3!=null">
  294. <if test="filter.wcb3">
  295. AND b1.cbbz=0 and b2.cbbz=0 AND b3.cbbz=0
  296. </if>
  297. </if>
  298. </sql>
  299. <sql id="subSql">
  300. SELECT
  301. a.yhbh, a.cblx, a.cbkid, a.cbrybm, a.bcds, a.sl,
  302. d.ssgs, d.sscbpq, d.sscbb, d.yhxm, d.yhdz, a.cbbz
  303. FROM
  304. YY_CBLR_LS a
  305. LEFT JOIN
  306. YH_KHJBXX d ON a.yhbh = d.yhbh WHERE a.jfzt = '1'
  307. <if test="filter.ssgs!=null">
  308. AND a.ssgs = #{filter.ssgs}
  309. </if>
  310. <if test="filter.sscbpq!=null">
  311. AND a.sscbpq = #{filter.sscbpq}
  312. </if>
  313. <if test="filter.sscbb!=null">
  314. <choose>
  315. <when test="filter.sscbb.indexOf(',')!=-1">
  316. AND a.sscbb in
  317. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  318. close=")">
  319. #{item}
  320. </foreach>
  321. </when>
  322. <otherwise>
  323. AND a.sscbb=#{filter.sscbb}
  324. </otherwise>
  325. </choose>
  326. </if>
  327. <if test="filter.cblx!=null">
  328. AND a.cblx = #{filter.cblx}
  329. </if>
  330. <if test="filter.cbrybm!=null">
  331. AND a.cbrybm = #{filter.cbrybm}
  332. </if>
  333. <if test="filter.searchText!=null">
  334. AND (a.yhbh like '%${filter.searchText}%'
  335. OR d.yhxm like '%${filter.searchText}%'
  336. OR d.yhdz like '%${filter.searchText}%')
  337. </if>
  338. <if test="filter.sbzt!=null">
  339. AND a.sbzt = #{filter.sbzt}
  340. </if>
  341. </sql>
  342. </mapper>