YhCbkxxMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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.bjgl.mapper.YhCbkxxMapper">
  4. <!--查询用户水表档案 -->
  5. <select id="SelectYhcbkxx" resultType="com.tofly.feesapi.bjgl.entity.YhCbkxx2">
  6. select * from yh_cbkxx where 1=1
  7. <if test="yhbh!=null and yhbh!=''">
  8. and yhbh=#{yhbh}
  9. </if>
  10. <if test="cbkh!=null and cbkh!=''">
  11. and cbkh=#{cbkh}
  12. </if>
  13. </select>
  14. <!--自定义获取用户是否存在 -->
  15. <select id="selectExistYhbh" resultType="int">
  16. SELECT COUNT(0) sl
  17. FROM yh_cbkxx
  18. WHERE yhbh = #{yhbh}
  19. and cbkh#{cbkh}
  20. </select>
  21. <!--查询用户档案连表查询信息-->
  22. <select id="getYhdaSbdaPage" resultType="com.tofly.feesapi.bjgl.entity.YhDaCbkxxSelect">
  23. select a.yhbh,a.yhxm,a.yhdz,a.lxdh,a.ssgs,a.sscbpq,a.sscbb,b.sblb,b.sbsccj,b.sbbh,b.sblc,b.sbxh,b.sbkj,b.bjwz
  24. from yh_khjbxx a,yh_cbkxx b where a.yhbh=b.yhbh
  25. <!--模糊查询 -->
  26. <if test="searchText!=null">
  27. AND ( a.yhbh like '%${searchText}%'
  28. OR a.yhxm like '%${searchText}%'
  29. OR a.yhdz like '%${searchText}%'
  30. OR a.lxdh like '%${searchText}%')
  31. </if>
  32. <if test="ssgs!=null and ssgs!=''">
  33. and a.ssgs=#{ssgs}
  34. </if>
  35. <if test="sscbpq!=null and sscbpq!=''">
  36. and a.sscbpq=#{sscbpq}
  37. </if>
  38. <if test="sscbb!=null and sscbb!=''">
  39. and a.sscbb=#{sscbb}
  40. </if>
  41. <if test="startDate!=null and endDate!=null">
  42. and a.jdrq between #{startDate} and #{endDate}
  43. </if>
  44. </select>
  45. <!--换表查看用户、水表档案 -->
  46. <select id="SelectYhdaSbda" resultType="com.tofly.feesapi.bjgl.entity.YhDaCbkxxSelect">
  47. select a.yhbh,a.yhxm,a.yhdz,a.lxdh,a.ssgs,a.sscbpq,a.sscbb,b.sblb,b.sbsccj,b.sbbh,b.sblc,b.sbxh,b.sbkj,b.bjwz,
  48. b.sbazfs,b.sbyt
  49. from yh_khjbxx a,yh_cbkxx b where a.yhbh=b.yhbh
  50. <if test="yhbh!=null and yhbh!=''">
  51. and a.yhbh=#{yhbh}
  52. </if>
  53. <if test="cbkh!=null and cbkh!=''">
  54. and b.cbkh=#{cbkh}
  55. </if>
  56. </select>
  57. <select id="getList" resultType="com.tofly.feesapi.bjgl.entity.vo.YhCbkxxSelect">
  58. SELECT yhbh,
  59. cbkh,
  60. cbkid,
  61. c.name AS sblbmc,
  62. d.name AS sbsccjmc,
  63. sbccrq,
  64. e.name AS sbxhmc,
  65. f.ccname AS sbkjmc,
  66. sbbh,
  67. b.name sjmc,
  68. jfzt
  69. FROM yh_cbkxx a
  70. LEFT JOIN bm_sj b ON a.sjbm = b.code
  71. LEFT JOIN bm_sblb c ON a.sblb = c.code
  72. LEFT JOIN bm_sbsccj d ON a.sbsccj = d.code
  73. LEFT JOIN bm_sbxh e ON a.sbxh = e.code
  74. LEFT JOIN (SELECT * FROM sys_child_code WHERE pcid = '12') f ON a.sbkj = f.cccode
  75. WHERE a.yhbh = #{yhbh}
  76. </select>
  77. <!--自定义水表档案分页查询 -->
  78. <select id="getPage" resultType="com.tofly.feesapi.bjgl.entity.vo.YhCbkxxSelect2">
  79. SELECT a.yhbh, a.cbkh,a.cbkid, c.yhxm, c.yhdz, a.ybdjbz, a.wsfbz, a.sjbm,a.slbl, a.sjbm1, a.slbl1, a.sjbm2, a.slbl2,
  80. a.sjbm3, a.slbl3,
  81. a.cbxh, a.sbbh, a.fmzt, f.cbbmc AS sscbbmc, g.cbpqmc AS sscbpqmc, c.lxdh, d.name AS sblbmc,
  82. cc.ccname as sbztmc
  83. FROM yh_cbkxx a
  84. LEFT JOIN yh_khjbxx c ON a.yhbh = c.yhbh
  85. LEFT JOIN bm_sblb d ON a.sblb = d.code
  86. LEFT JOIN bm_cbb f ON c.sscbb = f.cbbbm
  87. LEFT JOIN bm_cbpq g ON c.sscbpq = g.cbpqbm
  88. LEFT JOIN bm_sj b ON a.sjbm = b.code
  89. LEFT JOIN sys_child_code cc on a.sbzt=cc.cccode and cc.pcid='34'
  90. WHERE 1=1
  91. <!--模糊查询 -->
  92. <if test="filter.searchText!=null">
  93. AND (c.yhbh like '%${filter.searchText}%'
  94. OR c.yhxm like '%${filter.searchText}%'
  95. OR c.yhdz like '%${filter.searchText}%'
  96. OR c.lxdh like '%${filter.searchText}%')
  97. </if>
  98. <!--所属公司-->
  99. <if test="filter.ssgs!=null">
  100. AND c.ssgs=#{filter.ssgs}
  101. </if>
  102. <!--所属片区-->
  103. <if test="filter.sscbpq!=null">
  104. AND c.sscbpq=#{filter.sscbpq}
  105. </if>
  106. <!--所属抄表本-->
  107. <if test="filter.sscbb!=null">
  108. <choose>
  109. <when test="filter.sscbb.indexOf(',')!=-1">
  110. AND c.sscbb in
  111. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  112. close=")">
  113. #{item}
  114. </foreach>
  115. </when>
  116. <otherwise>
  117. AND c.sscbb=#{filter.sscbb}
  118. </otherwise>
  119. </choose>
  120. </if>
  121. <if test="filter.cby!=null">
  122. AND f.cby=#{filter.cby}
  123. </if>
  124. <if test="filter.qyfzr!=null">
  125. AND f.qyfzr=#{filter.qyfzr}
  126. </if>
  127. <!-- 用户状态-->
  128. <if test="filter.yhzt!=null">
  129. AND c.yhzt=#{filter.yhzt}
  130. </if>
  131. <!-- 垃圾费标志-->
  132. <if test="filter.ljfbz!=null">
  133. AND a.ljfbz=#{filter.ljfbz}
  134. </if>
  135. <!--建档日期-->
  136. <if test="filter.jdrqStart!=null and filter.jdrqEnd!=null">
  137. AND TRUNC(c.jdrq) BETWEEN #{filter.jdrqStart} AND
  138. #{filter.jdrqEnd}
  139. </if>
  140. <!-- 用户姓名-->
  141. <if test="filter.yhxm!=null">
  142. AND c.yhxm=#{filter.yhxm}
  143. </if>
  144. <!-- 用户编号-->
  145. <if test="filter.yhbh!=null">
  146. AND c.yhbh=#{filter.yhbh}
  147. </if>
  148. <!-- 用户地址-->
  149. <if test="filter.yhdz!=null">
  150. AND c.yhdz=#{filter.yhdz}
  151. </if>
  152. <!-- 联系电话-->
  153. <if test="filter.lxdh!=null">
  154. AND c.lxdh=#{filter.lxdh}
  155. </if>
  156. <!-- 是否分配抄表本(册)-->
  157. <if test="filter.sffpcbb!=null">
  158. <if test="filter.sffpcbb">
  159. AND c.sscbb >' '
  160. </if>
  161. <if test="!filter.sffpcbb">
  162. AND c.sscbb IS NULL
  163. </if>
  164. </if>
  165. <!-- 抄表序号-->
  166. <if test="filter.cbxh!=null">
  167. AND a.cbxh=#{filter.cbxh}
  168. </if>
  169. <!-- 是否分配抄表序号-->
  170. <if test="filter.sffpcbxh!=null">
  171. <if test="filter.sffpcbxh">
  172. AND (a.cbxh IS NOT NULL AND a.cbxh > 0)
  173. </if>
  174. <if test="!filter.sffpcbxh">
  175. AND (a.cbxh IS NULL OR a.cbxh = 0)
  176. </if>
  177. </if>
  178. <if test="sblbs!=null and sblbs.size()>0">
  179. AND a.sblb IN
  180. <foreach collection="sblbs" item="sblb" index="index" open="(" close=")" separator=",">
  181. #{sblb}
  182. </foreach>
  183. </if>
  184. <if test="filter.sjbm!=null">
  185. AND a.sjbm=#{filter.sjbm}
  186. </if>
  187. </select>
  188. <select id="getMaxCbxh" resultType="Integer">
  189. SELECT NVL(MAX(cbxh),0) AS cbxh FROM yh_cbkxx WHERE yhbh IN
  190. (select yhbh from yh_khjbxx where sscbb=${sscbb})
  191. <!-- <foreach collection="yhbhs" item="yhbh" index="index" open="(" close=")" separator=",">-->
  192. <!-- #{yhbh}-->
  193. <!-- </foreach>-->
  194. </select>
  195. <select id="getNextCbxh" resultType="Integer">
  196. SELECT NVL(MAX(cbxh),0) AS cbxh FROM yh_cbkxx WHERE yhbh IN
  197. (select yhbh from yh_khjbxx where sscbb=${sscbb}) and cbxh = ${cbxh}
  198. <!-- <foreach collection="yhbhs" item="yhbh" index="index" open="(" close=")" separator=",">-->
  199. <!-- #{yhbh}-->
  200. <!-- </foreach>-->
  201. </select>
  202. <select id="getCbkxxSbbh" resultType="Integer">
  203. SELECT count(*)
  204. FROM yh_cbkxx
  205. WHERE yhbh = ${yhbh}
  206. and sbbh = ${ssbh}
  207. </select>
  208. <select id="getUp" resultType="com.tofly.feesapi.bjgl.entity.YhCbkxx">
  209. SELECT c.sscbb,
  210. a.*
  211. FROM yh_cbkxx a
  212. LEFT JOIN yh_khjbxx c ON
  213. a.yhbh = c.yhbh
  214. WHERE c.sscbb = #{sscbb}
  215. AND ${cbxh} > a.cbxh
  216. AND a.cbxh > 0
  217. AND ROWNUM = 1
  218. ORDER BY a.cbxh
  219. </select>
  220. <select id="getDown" resultType="com.tofly.feesapi.bjgl.entity.YhCbkxx">
  221. SELECT c.sscbb,
  222. a.*
  223. FROM yh_cbkxx a
  224. LEFT JOIN yh_khjbxx c ON
  225. a.yhbh = c.yhbh
  226. WHERE c.sscbb = #{sscbb}
  227. AND a.cbxh > ${cbxh}
  228. AND a.cbxh > 0
  229. AND ROWNUM = 1
  230. ORDER BY a.cbxh
  231. </select>
  232. <select id="lockTable">
  233. LOCK
  234. TABLE yh_cbkxx IN SHARE MODE NOWAIT
  235. </select>
  236. <select id="getBySbsccj" resultType="com.tofly.feesapi.bjgl.entity.dto.YhCbkxxSync">
  237. SELECT a.sbbh,
  238. b.yhbh,
  239. b.yhxm,
  240. b.yhdz,
  241. b.lxdh
  242. FROM yh_cbkxx a
  243. LEFT JOIN yh_khjbxx b ON
  244. a.yhbh = b.yhbh
  245. WHERE a.sbsccj = #{sbsccj}
  246. </select>
  247. <select id="sblbtj" resultType="com.tofly.feesapi.bjgl.entity.vo.YhCbkxxSelectSbfl">
  248. select yslx.name yhxz,
  249. sbsccj.name sbcj,
  250. sbxh.name sbxh,
  251. sblb.name sblb,
  252. a.sbkj,a.sbsl
  253. from (
  254. select sbkj,sbxh,sbsccj,yslx,sblb,sum(1) sbsl
  255. from yh_cbkxx
  256. <where>
  257. <if test="ysxz!=null">
  258. AND yslx = #{ysxz}
  259. </if>
  260. <if test="sbkj!=null">
  261. AND sbkj = #{sbkj}
  262. </if>
  263. </where>
  264. GROUP BY sbkj,
  265. sbxh,
  266. sbsccj,
  267. yslx,
  268. sblb
  269. ) A
  270. left join bm_yslx yslx on yslx.code = a.yslx
  271. left join bm_sbsccj sbsccj on sbsccj.code = a.sbsccj
  272. left join bm_sbxh sbxh on sbxh.code = a.sbxh
  273. left join bm_sblb sblb on sblb.code=a.sblb
  274. </select>
  275. <update id="updatecbxh">
  276. UPDATE YH_CBKXX b SET cbxh=(select cbxh from yy_cblr a where a.cbkid=b.cbkid)
  277. <where>
  278. and b.cbkid in
  279. <foreach collection="cbkids" item="cbkid" index="index" open="(" close=")" separator=",">
  280. #{cbkid}
  281. </foreach>
  282. </where>
  283. </update>
  284. </mapper>