YyCblrMapper.xml 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373
  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.YyCblrMapper">
  4. <sql id="querySql">
  5. SELECT
  6. a.yhbh, a.cbkh, a.cbkid, e.sbbh,e.sblc, d.yhxm, d.yhdz,d.lxdh, a.scds, a.bcds, a.jjl, a.sl AS sjsl,
  7. b.name AS cbfsmc, a.cbbz, a.shbz, a.jsbz, a.cblx, c.name AS cblxmc, a.jbzd, a.xbqd, a.jbbh, a.cbrq,
  8. a.lrrq, a.photo, a.bz, a.cbrybm, a.cbryxm, a.cbxh, a.cwrq,a.sscbb, f.ccname as sbzt,e.fmzt,
  9. g.qyfzr as qyfzrbm,g.qyfzrxm,a.lrrybm, a.lrryxm, e.cbpl
  10. <if test="filter.cxly!=null and filter.cxly=='app'">
  11. ,(select LISTAGG(cwrq||'-'||ysje,'|') WITHIN GROUP (ORDER BY cwrq) from yy_qfmx where sfbz=0 and
  12. yy_qfmx.yhbh=a.yhbh) qfje,
  13. (SELECT nvl(sum(nvl(syje, 0)), 0) FROM yy_zjzh WHERE yy_zjzh.yhbh = a.yhbh ) ycje
  14. </if>
  15. FROM yy_cblr a
  16. LEFT JOIN bm_cbfs b on a.cbfs = b.code
  17. LEFT JOIN bm_cblx c on a.cblx = c.code
  18. LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
  19. LEFT JOIN yh_cbkxx e on a.yhbh = e.yhbh and a.cbkh=e.cbkh
  20. LEFT JOIN sys_child_code f on a.sbzt=f.cccode and f.pcid='34'
  21. LEFT JOIN bm_cbb g on a.sscbb = g.cbbbm
  22. <include refid="querySqlWhere"></include>
  23. </sql>
  24. <sql id="querySqlWhere">
  25. <if test="filter.cwrq!=null and filter.cwrq!=''">
  26. LEFT JOIN (
  27. SELECT yhbh,cbkid, sl FROM YY_CBLR_LS
  28. WHERE cwrq = #{filter.cwrq}
  29. <!--所属公司-->
  30. <if test="filter.ssgs != null and filter.ssgs != ''">
  31. AND ssgs=#{filter.ssgs}
  32. </if>
  33. <!--所属片区-->
  34. <if test="filter.sscbpq != null and filter.sscbpq != ''">
  35. AND sscbpq=#{filter.sscbpq}
  36. </if>
  37. <!--所属抄表本-->
  38. <if test="filter.sscbb != null and filter.sscbb != ''">
  39. <choose>
  40. <when test="filter.sscbb.indexOf(',')!=-1">
  41. AND sscbb in
  42. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  43. close=")">
  44. #{item}
  45. </foreach>
  46. </when>
  47. <otherwise>
  48. AND sscbb=#{filter.sscbb}
  49. </otherwise>
  50. </choose>
  51. </if>
  52. <if test="filter.userId!= null">
  53. AND sscbb in (select cbbbm from yh_sjqx where user_id=#{filter.userId})
  54. </if>
  55. ) ls ON a.cbkid=ls.cbkid
  56. </if>
  57. WHERE 1=1 AND e.jfzt='1'
  58. <!--模糊查询 -->
  59. <if test="filter.searchText!=null">
  60. AND ( a.yhbh like '%${filter.searchText}%'
  61. OR d.yhxm like '%${filter.searchText}%'
  62. OR d.yhdz like '%${filter.searchText}%'
  63. OR d.lxdh like '${filter.searchText}%'
  64. )
  65. </if>
  66. <!--所属公司-->
  67. <if test="filter.ssgs != null and filter.ssgs != ''">
  68. AND a.ssgs = #{filter.ssgs}
  69. </if>
  70. <!--所属片区-->
  71. <if test="filter.sscbpq != null and filter.sscbpq != ''">
  72. AND a.sscbpq=#{filter.sscbpq}
  73. </if>
  74. <!--所属抄表本-->
  75. <if test="filter.sscbb != null and filter.sscbb != ''">
  76. <choose>
  77. <when test="filter.sscbb.indexOf(',')!=-1">
  78. AND a.sscbb in
  79. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  80. close=")">
  81. #{item}
  82. </foreach>
  83. </when>
  84. <otherwise>
  85. AND a.sscbb=#{filter.sscbb}
  86. </otherwise>
  87. </choose>
  88. </if>
  89. <!-- 抄表方式-->
  90. <if test="filter.cbfs!=null">
  91. AND a.cbfs=#{filter.cbfs}
  92. </if>
  93. <!-- 用水性质(水价编码)-->
  94. <if test="filter.ysxz!=null">
  95. AND (
  96. e.sjbm in (select code from bm_sj where yslx=#{filter.ysxz})
  97. OR e.sjbm1 in (select code from bm_sj where yslx=#{filter.ysxz})
  98. OR e.sjbm2 in (select code from bm_sj where yslx=#{filter.ysxz})
  99. OR e.sjbm3 in (select code from bm_sj where yslx=#{filter.ysxz})
  100. )
  101. </if>
  102. <!-- 水表口径编码-->
  103. <if test="filter.sbkj!=null">
  104. AND e.sbkj = #{filter.sbkj}
  105. </if>
  106. <!-- 抄表人员编码-->
  107. <if test="filter.cbrybm!=null">
  108. AND a.cbrybm = #{filter.cbrybm}
  109. </if>
  110. <!-- 财务日期-->
  111. <if test="filter.cwrq!=null">
  112. AND a.cwrq = #{filter.cwrq}
  113. </if>
  114. <!-- 抄表标志-->
  115. <if test="filter.cbbz!=null">
  116. AND nvl(a.cbbz,0) = #{filter.cbbz}
  117. </if>
  118. <!-- 审核标志-->
  119. <if test="filter.shbz!=null">
  120. AND nvl(a.shbz,0) = #{filter.shbz}
  121. </if>
  122. <!-- 计算标志-->
  123. <if test="filter.jsbz!=null">
  124. AND nvl(a.jsbz,0) = #{filter.jsbz}
  125. </if>
  126. <!-- 录入日期-->
  127. <if test="filter.lrrqStart!=null and filter.lrrqEnd!=null">
  128. AND a.lrrq BETWEEN #{filter.lrrqStart} AND
  129. #{filter.lrrqEnd}
  130. </if>
  131. <!--抄表序号-->
  132. <if test="filter.cbxh !=null and filter.cbxh != ''">
  133. AND a.cbxh=#{filter.cbxh}
  134. </if>
  135. <!--用户编号-->
  136. <if test="filter.yhbh != null and filter.yhbh != ''">
  137. AND a.yhbh = #{filter.yhbh}
  138. </if>
  139. <if test="filter.sfssfb!=null">
  140. <if test="filter.sfssfb==1">
  141. AND not exists (select 1 from yh_bjfl_fb fb left join yh_bjfl_zb zb on
  142. fb.zb_id=zb.id where <![CDATA[ fb.zb_id<>fb.id ]]> and zb.isdisabled='1' and
  143. (fb.yhbh||fb.cbkh)=a.cbkid)
  144. </if>
  145. <if test="filter.sfssfb==0">
  146. AND exists (select 1 from yh_bjfl_fb fb left join yh_bjfl_zb zb on
  147. fb.zb_id=zb.id where <![CDATA[ fb.zb_id<>fb.id ]]> and zb.isdisabled='1' and
  148. (fb.yhbh||fb.cbkh)=a.cbkid)
  149. </if>
  150. </if>
  151. <if test="filter.qyfzr!=null">
  152. AND a.sscbb in(select cbbbm from bm_cbb where qyfzr=#{filter.qyfzr})
  153. </if>
  154. <if test="filter.cwrqStart!=null and filter.cwrqEnd!=null">
  155. AND a.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
  156. </if>
  157. <if test="filter.yhbhStart!=null">
  158. <![CDATA[ AND a.yhbh>=#{filter.yhbhStart} ]]>
  159. </if>
  160. <if test="filter.yhbhEnd!=null">
  161. <![CDATA[ AND a.yhbh<=#{filter.yhbhEnd} ]]>
  162. </if>
  163. <if test="filter.sbzt!=null">
  164. AND a.sbzt=#{filter.sbzt}
  165. </if>
  166. <if test="filter.sblb!=null">
  167. AND e.sblb=#{filter.sblb}
  168. </if>
  169. <if test="filter.cbly!=null">
  170. AND a.cbly=#{filter.cbly}
  171. </if>
  172. <if test="filter.kssl!=null and filter.jssl!=null">
  173. AND a.sl BETWEEN #{filter.kssl} AND #{filter.jssl}
  174. </if>
  175. <if test="filter.bfb!=null">
  176. AND ( ls.sl != 0 AND a.sl != 0 AND
  177. ((a.sl>=ls.sl AND round((a.sl-ls.sl)/ls.sl*100,2)>=#{filter.bfb})
  178. or (ls.sl>=a.sl AND round((ls.sl-a.sl)/a.sl*100,2)>=#{filter.bfb}))
  179. )
  180. </if>
  181. <if test="filter.userId != null">
  182. AND a.sscbb in (select cbbbm from yh_sjqx where user_id=#{filter.userId})
  183. </if>
  184. <if test="filter.dxh != null">
  185. AND d.dxh = #{dxh}
  186. </if>
  187. </sql>
  188. <!--查询抄表录入历史-->
  189. <sql id="querySql1">
  190. SELECT
  191. a.yhbh, a.cbkh, a.cbkid, e.sbbh,e.sblc, d.yhxm, d.yhdz,d.lxdh, a.scds, a.bcds, a.jjl, a.sl AS sjsl,
  192. b.name AS cbfsmc, a.cbbz, a.shbz, a.jsbz, a.cblx, c.name AS cblxmc, a.jbzd, a.xbqd, a.jbbh, a.cbrq,
  193. a.lrrq, a.photo, a.bz, a.cbrybm, a.cbryxm, a.cbxh, a.cwrq,a.sscbb, f.ccname as sbzt,e.fmzt,
  194. a.qyfzrbm,a.qyfzrxm,a.lrrybm, a.lrryxm,e.cbpl cbpl
  195. FROM yy_cblr_ls a
  196. LEFT JOIN bm_cbfs b on a.cbfs = b.code
  197. LEFT JOIN bm_cblx c on a.cblx = c.code
  198. LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
  199. LEFT JOIN yh_cbkxx e on a.yhbh = e.yhbh and a.cbkh=e.cbkh
  200. LEFT JOIN sys_child_code f on a.sbzt=f.cccode and pcid='34'
  201. <include refid="querySqlWhere2"></include>
  202. </sql>
  203. <sql id="querySqlWhere2">
  204. WHERE 1=1
  205. <!--模糊查询 -->
  206. <if test="filter.searchText!=null">
  207. AND ( a.yhbh like '%${filter.searchText}%'
  208. OR d.yhxm like '%${filter.searchText}%'
  209. OR d.yhdz like '%${filter.searchText}%' )
  210. </if>
  211. <!--所属公司-->
  212. <if test="filter.ssgs!=null">
  213. AND d.ssgs=#{filter.ssgs}
  214. </if>
  215. <!--所属片区-->
  216. <if test="filter.sscbpq!=null">
  217. AND d.sscbpq=#{filter.sscbpq}
  218. </if>
  219. <!--所属抄表本-->
  220. <if test="filter.sscbb!=null">
  221. <choose>
  222. <when test="filter.sscbb.indexOf(',')!=-1">
  223. AND d.sscbb in
  224. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  225. close=")">
  226. #{item}
  227. </foreach>
  228. </when>
  229. <otherwise>
  230. AND d.sscbb=#{filter.sscbb}
  231. </otherwise>
  232. </choose>
  233. </if>
  234. <!-- 抄表方式-->
  235. <if test="filter.cbfs!=null">
  236. AND a.cbfs=#{filter.cbfs}
  237. </if>
  238. <!-- 用水性质(水价编码)-->
  239. <if test="filter.ysxz!=null">
  240. AND (e.sjbm in (select code from bm_sj where yslx=#{filter.ysxz})
  241. OR e.sjbm1 in (select code from bm_sj where yslx=#{filter.ysxz})
  242. OR e.sjbm2 in (select code from bm_sj where yslx=#{filter.ysxz})
  243. OR e.sjbm3 in (select code from bm_sj where yslx=#{filter.ysxz})
  244. )
  245. </if>
  246. <!-- 水表口径编码-->
  247. <if test="filter.sbkj!=null">
  248. AND e.sbkj=#{filter.sbkj}
  249. </if>
  250. <!-- 抄表人员编码-->
  251. <if test="filter.cbrybm != null and filter.cbrybm != ''">
  252. AND a.cbrybm=#{filter.cbrybm}
  253. </if>
  254. <!-- 财务日期-->
  255. <if test="filter.cwrq != null and filter.cwrq != ''">
  256. AND a.cwrq=#{filter.cwrq}
  257. </if>
  258. <!-- 抄表标志-->
  259. <if test="filter.cbbz!=null">
  260. AND nvl(a.cbbz,0)=#{filter.cbbz}
  261. </if>
  262. <!-- 审核标志-->
  263. <if test="filter.shbz!=null">
  264. AND nvl(a.shbz,0)=#{filter.shbz}
  265. </if>
  266. <!-- 计算标志-->
  267. <if test="filter.jsbz!=null">
  268. AND nvl(a.jsbz,0)=#{filter.jsbz}
  269. </if>
  270. <!-- 录入日期-->
  271. <if test="filter.lrrqStart!=null and filter.lrrqEnd!=null">
  272. AND a.lrrq BETWEEN #{filter.lrrqStart} AND #{filter.lrrqEnd}
  273. </if>
  274. <!--抄表序号-->
  275. <if test="filter.cbxh!=null">
  276. AND a.cbxh=#{filter.cbxh}
  277. </if>
  278. <!--用户编号-->
  279. <if test="filter.yhbh!=null">
  280. AND a.yhbh=#{filter.yhbh}
  281. </if>
  282. <if test="filter.qyfzr!=null">
  283. AND a.sscbb in(select cbbbm from bm_cbb where qyfzr=#{filter.qyfzr})
  284. </if>
  285. <if test="filter.cwrqStart!=null and filter.cwrqEnd!=null">
  286. AND a.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
  287. </if>
  288. <if test="filter.yhbhStart!=null">
  289. <![CDATA[ AND a.yhbh>=#{filter.yhbhStart} ]]>
  290. </if>
  291. <if test="filter.yhbhEnd!=null">
  292. <![CDATA[ AND a.yhbh<=#{filter.yhbhEnd} ]]>
  293. </if>
  294. <if test="filter.sbzt!=null">
  295. AND a.sbzt=#{filter.sbzt}
  296. </if>
  297. <if test="filter.sblb!=null">
  298. AND e.sbzt=#{filter.sblb}
  299. </if>
  300. <if test="filter.cbly!=null">
  301. AND a.cbly=#{filter.cbly}
  302. </if>
  303. <if test="filter.userId != null">
  304. AND a.sscbb in (select cbbbm from yh_sjqx where user_id=#{filter.userId})
  305. </if>
  306. <if test="filter.dxh != null">
  307. AND d.dxh = #{filter.dxh}
  308. </if>
  309. <if test="filter.cblx!=null">
  310. AND a.cblx=#{filter.cblx}
  311. </if>
  312. </sql>
  313. <sql id="querySqldqorls">
  314. SELECT a.yhbh,
  315. a.cbkh,
  316. a.cbkid,
  317. a.scds,
  318. a.bcds,
  319. a.jjl,
  320. a.sl AS sjsl,
  321. a.cbfs,
  322. a.cbbz,
  323. a.shbz,
  324. a.jsbz,
  325. a.cblx,
  326. a.jbzd,
  327. a.xbqd,
  328. a.jbbh,
  329. a.cbrq,
  330. a.lrrq,
  331. a.photo,
  332. a.bz,
  333. a.cbrybm,
  334. a.cbryxm,
  335. a.cbxh,
  336. a.cwrq,
  337. a.sscbb,
  338. a.sbzt,
  339. a.lrrybm,
  340. a.lrryxm,
  341. a.cbcs,
  342. -- 动态决定连接哪个表
  343. CASE WHEN a.table_source = 'current' THEN e.sbbh ELSE ls_e.sbbh END AS sbbh,
  344. CASE WHEN a.table_source = 'current' THEN e.sblc ELSE ls_e.sblc END AS sblc,
  345. CASE WHEN a.table_source = 'current' THEN e.fmzt ELSE ls_e.fmzt END AS fmzt,
  346. d.yhxm,
  347. d.yhdz,
  348. d.lxdh,
  349. b.name AS cbfsmc,
  350. c.name AS cblxmc,
  351. f.ccname AS sbztmc,
  352. g.qyfzr AS qyfzrbm,
  353. g.qyfzrxm,
  354. a.table_source
  355. FROM ( -- 合并当前表和历史表
  356. SELECT 'current' as table_source,
  357. yhbh,
  358. cbkh,
  359. cbkid,
  360. scds,
  361. bcds,
  362. jjl,
  363. sl,
  364. cbfs,
  365. cbbz,
  366. shbz,
  367. jsbz,
  368. cblx,
  369. jbzd,
  370. xbqd,
  371. jbbh,
  372. cbrq,
  373. lrrq,
  374. photo,
  375. bz,
  376. cbrybm,
  377. cbryxm,
  378. cbxh,
  379. cwrq,
  380. sscbb,
  381. sbzt,
  382. lrrybm,
  383. lrryxm,
  384. cbcs
  385. FROM yy_cblr
  386. UNION ALL
  387. SELECT 'history' as table_source,
  388. yhbh,
  389. cbkh,
  390. cbkid,
  391. scds,
  392. bcds,
  393. jjl,
  394. sl,
  395. cbfs,
  396. cbbz,
  397. shbz,
  398. jsbz,
  399. cblx,
  400. jbzd,
  401. xbqd,
  402. jbbh,
  403. cbrq,
  404. lrrq,
  405. photo,
  406. bz,
  407. cbrybm,
  408. cbryxm,
  409. cbxh,
  410. cwrq,
  411. sscbb,
  412. sbzt,
  413. lrrybm,
  414. lrryxm,
  415. cbcs
  416. FROM yy_cblr_ls) a
  417. LEFT JOIN bm_cbfs b ON a.cbfs = b.code
  418. LEFT JOIN bm_cblx c ON a.cblx = c.code
  419. LEFT JOIN yh_khjbxx d ON a.yhbh = d.yhbh
  420. -- 根据数据来源动态连接不同的表
  421. LEFT JOIN yh_cbkxx e ON a.cbkid = e.cbkid AND a.table_source = 'current'
  422. LEFT JOIN yh_cbkxx ls_e ON a.yhbh = ls_e.yhbh AND a.cbkh = ls_e.cbkh AND a.table_source = 'history'
  423. LEFT JOIN sys_child_code f ON a.sbzt = f.cccode AND f.pcid = '34'
  424. LEFT JOIN bm_cbb g ON d.sscbb = g.cbbbm
  425. </sql>
  426. <select id="getPage" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
  427. <include refid="querySql"/>
  428. </select>
  429. <select id="getPage2" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
  430. <include refid="querySqldqorls"></include>
  431. <include refid="querySqlWhere2"></include>
  432. </select>
  433. <select id="getList" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
  434. <include refid="querySqldqorls"></include>
  435. <include refid="querySqlWhere2"></include>
  436. <if test="filter.orders!=null and !filter.orders.isEmpty()">
  437. order by
  438. <foreach item="item" index="index" collection="filter.orders" separator=",">
  439. ${item.column} ${item.asc? 'asc':'desc'}
  440. </foreach>
  441. </if>
  442. </select>
  443. <select id="getCbjlByYhbhs" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
  444. SELECT * FROM (
  445. SELECT
  446. a.yhbh, a.cbkh, a.cbkid, e.sbbh,e.sblc, d.yhxm, d.yhdz,d.lxdh, a.scds, a.bcds, a.jjl, a.sl AS sjsl,
  447. b.name AS cbfsmc, a.cbbz, a.shbz, a.jsbz, a.cblx, c.name AS cblxmc, a.jbzd, a.xbqd, a.jbbh, a.cbrq,
  448. a.lrrq, a.photo, a.bz, a.cbrybm, a.cbryxm, a.cbxh, a.cwrq,a.sscbb, f.ccname as sbzt,e.fmzt,
  449. g.qyfzr as qyfzrbm,g.qyfzrxm,a.lrrybm, a.lrryxm
  450. FROM yy_cblr a
  451. LEFT JOIN bm_cbfs b on a.cbfs = b.code
  452. LEFT JOIN bm_cblx c on a.cblx = c.code
  453. LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
  454. LEFT JOIN yh_cbkxx e on a.yhbh = e.yhbh and a.cbkh=e.cbkh
  455. LEFT JOIN sys_child_code f on a.sbzt=f.cccode and f.pcid='34'
  456. LEFT JOIN bm_cbb g on a.sscbb = g.cbbbm
  457. WHERE 1=1
  458. <if test="filter.ssgs!=null">
  459. AND a.ssgs = #{filter.ssgs}
  460. </if>
  461. <if test="filter.sscbpq!=null">
  462. AND a.sscbpq=#{filter.sscbpq}
  463. </if>
  464. <if test="filter.sscbb!=null">
  465. <choose>
  466. <when test="filter.sscbb.indexOf(',')!=-1">
  467. AND a.sscbb in
  468. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  469. close=")">
  470. #{item}
  471. </foreach>
  472. </when>
  473. <otherwise>
  474. AND a.sscbb=#{filter.sscbb}
  475. </otherwise>
  476. </choose>
  477. </if>
  478. <if test="filter.searchText!=null">
  479. AND ( a.yhbh like '%${filter.searchText}%'
  480. OR d.yhxm like '%${filter.searchText}%'
  481. OR d.yhdz like '%${filter.searchText}%'
  482. OR d.lxdh like '${filter.searchText}%'
  483. )
  484. </if>
  485. <if test="filter.cwrqStart!=null and filter.cwrqEnd!=null">
  486. AND a.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
  487. </if>
  488. <if test="filter.yhbhs != null and filter.yhbhs.size() > 0">
  489. AND a.yhbh IN
  490. <foreach collection="filter.yhbhs" open="(" separator="," item="yhbh" close=")">
  491. #{yhbh}
  492. </foreach>
  493. </if>
  494. UNION ALL
  495. SELECT
  496. a.yhbh, a.cbkh, a.cbkid, e.sbbh,e.sblc, d.yhxm, d.yhdz,d.lxdh, a.scds, a.bcds, a.jjl, a.sl AS sjsl,
  497. b.name AS cbfsmc, a.cbbz, a.shbz, a.jsbz, a.cblx, c.name AS cblxmc, a.jbzd, a.xbqd, a.jbbh, a.cbrq,
  498. a.lrrq, a.photo, a.bz, a.cbrybm, a.cbryxm, a.cbxh, a.cwrq,a.sscbb, f.ccname as sbzt,e.fmzt,
  499. a.qyfzrbm,a.qyfzrxm,a.lrrybm, a.lrryxm
  500. FROM yy_cblr_ls a
  501. LEFT JOIN bm_cbfs b on a.cbfs = b.code
  502. LEFT JOIN bm_cblx c on a.cblx = c.code
  503. LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
  504. LEFT JOIN yh_cbkxx e on a.yhbh = e.yhbh and a.cbkh=e.cbkh
  505. LEFT JOIN sys_child_code f on a.sbzt=f.cccode and pcid='34'
  506. WHERE 1=1
  507. <if test="filter.searchText!=null">
  508. AND ( a.yhbh like '%${filter.searchText}%'
  509. OR d.yhxm like '%${filter.searchText}%'
  510. OR d.yhdz like '%${filter.searchText}%' )
  511. </if>
  512. <if test="filter.ssgs!=null">
  513. AND d.ssgs=#{filter.ssgs}
  514. </if>
  515. <if test="filter.sscbpq!=null">
  516. AND d.sscbpq=#{filter.sscbpq}
  517. </if>
  518. <if test="filter.sscbb!=null">
  519. <choose>
  520. <when test="filter.sscbb.indexOf(',')!=-1">
  521. AND d.sscbb in
  522. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  523. close=")">
  524. #{item}
  525. </foreach>
  526. </when>
  527. <otherwise>
  528. AND d.sscbb=#{filter.sscbb}
  529. </otherwise>
  530. </choose>
  531. </if>
  532. <if test="filter.cwrqStart!=null and filter.cwrqEnd!=null">
  533. AND a.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
  534. </if>
  535. <if test="filter.yhbhs != null and filter.yhbhs.size() > 0">
  536. AND a.yhbh IN
  537. <foreach collection="filter.yhbhs" open="(" separator="," item="yhbh" close=")">
  538. #{yhbh}
  539. </foreach>
  540. </if>
  541. )
  542. </select>
  543. <select id="lycbglfy" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
  544. SELECT
  545. a.yhbh, a.cbkh, a.cbkid, e.sbbh,e.sblc, d.yhxm, d.yhdz,d.lxdh,
  546. a.scds, a.bcds, a.jjl, a.sl AS sjsl, a.xycb,
  547. b.name AS cbfsmc, a.cbbz, a.shbz, a.jsbz, a.cblx, c.name AS cblxmc, a.jbzd, a.xbqd, a.jbbh, a.cbrq,
  548. a.lrrq, a.photo, a.bz, a.cbrybm, a.cbryxm, a.cbxh, a.cwrq,a.sscbb,
  549. f.ccname as sbzt,
  550. e.fmzt, e.cbpl,
  551. g.qyfzr as qyfzrbm, g.qyfzrxm, a.lrrybm, a.lrryxm
  552. FROM yy_cblr a
  553. LEFT JOIN bm_cbfs b ON a.cbfs = b.code
  554. LEFT JOIN bm_cblx c ON a.cblx = c.code
  555. LEFT JOIN yh_khjbxx d ON a.yhbh = d.yhbh
  556. LEFT JOIN yh_cbkxx e ON a.yhbh = e.yhbh and a.cbkh=e.cbkh
  557. LEFT JOIN sys_child_code f ON a.sbzt=f.cccode and f.pcid='34'
  558. LEFT JOIN bm_cbb g ON a.sscbb = g.cbbbm
  559. WHERE 1=1 AND e.jfzt='1'
  560. <!--所属公司-->
  561. <if test="filter.ssgs!=null">
  562. AND a.ssgs = #{filter.ssgs}
  563. </if>
  564. <!--所属片区-->
  565. <if test="filter.sscbpq!=null">
  566. AND a.sscbpq = #{filter.sscbpq}
  567. </if>
  568. <if test="filter.sscbb != null and filter.sscbb != ''">
  569. <choose>
  570. <when test="filter.sscbb.indexOf(',') != -1">
  571. AND a.sscbb in
  572. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  573. close=")">
  574. #{item}
  575. </foreach>
  576. </when>
  577. <otherwise>
  578. AND a.sscbb = #{filter.sscbb}
  579. </otherwise>
  580. </choose>
  581. </if>
  582. <if test="filter.cwrq!= null and filter.cwrq != ''">
  583. AND a.cwrq = #{filter.cwrq}
  584. </if>
  585. <if test="filter.cbrybm != null and filter.cbrybm != ''">
  586. AND a.cbrybm = #{filter.cbrybm}
  587. </if>
  588. <if test="filter.cbbz != null">
  589. AND nvl(a.cbbz, 0)=#{filter.cbbz}
  590. </if>
  591. <if test="filter.shbz != null">
  592. AND nvl(a.shbz, 0) = #{filter.shbz}
  593. </if>
  594. <if test="filter.searchText!=null">
  595. AND ( a.yhbh like '%${filter.searchText}%'
  596. OR d.yhxm like '%${filter.searchText}%'
  597. OR d.yhdz like '%${filter.searchText}%'
  598. OR d.lxdh like '${filter.searchText}%'
  599. )
  600. </if>
  601. <if test="filter.userId != null">
  602. AND a.sscbb in (select cbbbm from yh_sjqx where user_id=#{filter.userId})
  603. </if>
  604. <if test="filter.dxh != null">
  605. AND d.dxh = #{dxh}
  606. </if>
  607. </select>
  608. <select id="getViewById" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrView">
  609. SELECT a.yhbh,
  610. a.cwrq,
  611. a.cbkh,
  612. b.sbbh,
  613. d.yhxm,
  614. d.lxdh,
  615. d.yhdz,
  616. b.sblc,
  617. a.cbfs,
  618. a.cblx,
  619. a.scds,
  620. a.bcds,
  621. a.jjl,
  622. a.bcds - a.scds AS sjsl,
  623. a.bz,
  624. a.photo,
  625. f.ccname as sbzt
  626. FROM yy_cblr a
  627. LEFT JOIN yh_cbkxx b on a.yhbh = b.yhbh and a.cbkh = b.cbkh
  628. LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
  629. LEFT JOIN sys_child_code f on a.sbzt = f.cccode and pcid = '34'
  630. WHERE a.yhbh = #{yhbh}
  631. and a.cbkh = #{cbkh}
  632. </select>
  633. <select id="cbsltj" resultType="com.tofly.feesapi.cbgl.entity.vo.CbSltjSelect">
  634. <if test="filter.tjlb=='cbry'">
  635. SELECT
  636. cbryxm AS tjlb,
  637. NVL(COUNT(1), 0) AS cbhs,
  638. NVL(SUM(sl), 0) AS cbsl FROM
  639. YY_CBLR
  640. WHERE jfzt = '1' AND cbbz = '1'
  641. <if test="filter.ssgs != null and filter.ssgs!= ''">
  642. AND ssgs = #{filter.ssgs}
  643. </if>
  644. <if test="filter.sscbpq != null and filter.sscbpq != ''">
  645. AND sscbpq = #{filter.sscbpq}
  646. </if>
  647. <if test="filter.sscbb != null and filter.sscbb != ''">
  648. AND sscbb = #{filter.sscbb}
  649. </if>
  650. GROUP BY
  651. cbryxm
  652. </if>
  653. <if test="filter.tjlb=='ysxz'">
  654. SELECT
  655. a.NAME AS tjlb,
  656. NVL(COUNT(1),0) AS cbhs,
  657. NVL(SUM(sl),0) AS cbsl
  658. FROM bm_yslx a
  659. Left JOIN BM_SJ b ON b.yslx = a.CODE
  660. Left JOIN YH_CBKXX c ON c.sjbm=b.code
  661. Left join YY_CBLR d ON c.CBKID = d.CBKID
  662. WHERE d.jfzt = '1'
  663. AND d.cbbz = '1'
  664. <if test="filter.ssgs!=null">
  665. AND d.ssgs = #{filter.ssgs}
  666. </if>
  667. <if test="filter.sscbpq!=null">
  668. AND d.sscbpq = #{filter.sscbpq}
  669. </if>
  670. <if test="filter.sscbb!=null">
  671. <choose>
  672. <when test="filter.sscbb.indexOf(',')!=-1">
  673. AND d.sscbb in
  674. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  675. close=")">
  676. #{item}
  677. </foreach>
  678. </when>
  679. <otherwise>
  680. AND d.sscbb=#{filter.sscbb}
  681. </otherwise>
  682. </choose>
  683. </if>
  684. GROUP BY
  685. a.NAME
  686. </if>
  687. <if test="filter.tjlb=='cbb'">
  688. SELECT
  689. b.CBBMC AS tjlb,
  690. NVL(COUNT(1),0) AS cbhs,
  691. NVL(SUM(sl),0) AS cbsl
  692. FROM
  693. YY_CBLR a
  694. LEFT JOIN BM_CBB b ON a.sscbb = b.cbbbm
  695. WHERE
  696. a.jfzt = '1'
  697. AND a.cbbz = '1'
  698. <if test="filter.ssgs!=null">
  699. AND a.ssgs = #{filter.ssgs}
  700. </if>
  701. <if test="filter.sscbpq!=null">
  702. AND a.sscbpq = #{filter.sscbpq}
  703. </if>
  704. <if test="filter.sscbb!=null">
  705. <choose>
  706. <when test="filter.sscbb.indexOf(',')!=-1">
  707. AND a.sscbb in
  708. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  709. close=")">
  710. #{item}
  711. </foreach>
  712. </when>
  713. <otherwise>
  714. AND a.sscbb=#{filter.sscbb}
  715. </otherwise>
  716. </choose>
  717. </if>
  718. GROUP BY
  719. b.CBBMC
  720. </if>
  721. </select>
  722. <select id="cbltj" resultType="com.tofly.feesapi.cbgl.entity.vo.CbltjSelect">
  723. <if test="filter.tjlb=='cbry'">
  724. SELECT
  725. b.CBY AS tjlb,
  726. COUNT(1) AS ycbs,
  727. SUM(CASE WHEN a.cbbz = '1' THEN 1 ELSE 0 END) AS scbs,
  728. SUM(CASE WHEN a.cbbz = '1' THEN sl ELSE 0 END) AS scsl
  729. FROM
  730. YY_CBLR a
  731. LEFT JOIN BM_CBB b ON a.sscbb = b.cbbbm
  732. WHERE a.jfzt = '1' and a.xycb=1
  733. <if test="filter.ssgs!=null">
  734. AND a.ssgs = #{filter.ssgs}
  735. </if>
  736. <if test="filter.sscbpq!=null">
  737. AND a.sscbpq = #{filter.sscbpq}
  738. </if>
  739. <if test="filter.sscbb!=null">
  740. <choose>
  741. <when test="filter.sscbb.indexOf(',')!=-1">
  742. AND a.sscbb in
  743. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  744. close=")">
  745. #{item}
  746. </foreach>
  747. </when>
  748. <otherwise>
  749. AND a.sscbb=#{filter.sscbb}
  750. </otherwise>
  751. </choose>
  752. </if>
  753. GROUP BY
  754. b.CBY
  755. </if>
  756. <if test="filter.tjlb=='cbb'">
  757. SELECT
  758. b.cby AS cby,
  759. b.cbbmc AS tjlb,
  760. COUNT(1) AS ycbs,
  761. SUM(CASE WHEN a.cbbz = '1' THEN 1 ELSE 0 END) AS scbs,
  762. SUM(CASE WHEN a.cbbz = '1' THEN sl ELSE 0 END) AS scsl
  763. FROM
  764. YY_CBLR a
  765. LEFT JOIN BM_CBB b ON a.sscbb = b.cbbbm
  766. WHERE a.jfzt = '1' and a.xycb=1
  767. <if test="filter.ssgs!=null">
  768. AND a.ssgs = #{filter.ssgs}
  769. </if>
  770. <if test="filter.sscbpq!=null">
  771. AND a.sscbpq = #{filter.sscbpq}
  772. </if>
  773. <if test="filter.sscbb!=null">
  774. <choose>
  775. <when test="filter.sscbb.indexOf(',')!=-1">
  776. AND a.sscbb in
  777. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  778. close=")">
  779. #{item}
  780. </foreach>
  781. </when>
  782. <otherwise>
  783. AND a.sscbb=#{filter.sscbb}
  784. </otherwise>
  785. </choose>
  786. </if>
  787. GROUP BY b.cbbmc, b.cby
  788. order by b.cby asc, b.cbbmc asc
  789. </if>
  790. </select>
  791. <select id="getZfCblrMap" resultType="java.util.Map">
  792. SELECT COUNT(0) FBS,
  793. NVL(SUM(CASE WHEN CBBZ = 1 and SHBZ = 1 THEN 1 ELSE 0 END), 0) FBYCS,
  794. NVL(SUM(SL), 0) FBHJSL
  795. FROM YY_CBLR a
  796. WHERE exists(select 1
  797. from yh_bjfl_fb fb
  798. left join yh_bjfl_zb zb on fb.zb_id = zb.id
  799. where <![CDATA[ fb.zb_id <> fb.id ]]> and zb.type_id = '1'
  800. and zb.isdisabled = '1'
  801. and (fb.yhbh || fb.cbkh) = a.cbkid
  802. and (zb.yhbh || zb.cbkh) = #{cbkid})
  803. </select>
  804. <select id="getZmCblrMap" resultType="java.util.Map">
  805. SELECT COUNT(0) ZBS,
  806. NVL(SUM(CASE WHEN CBBZ = 1 and SHBZ = 1 THEN 1 ELSE 0 END), 0) ZBYCS,
  807. NVL(SUM(SL), 0) ZBHJSL
  808. FROM YY_CBLR a
  809. WHERE exists(select 1
  810. from yh_bjfl_fb fb
  811. left join yh_bjfl_zb zb on fb.zb_id = zb.id
  812. where <![CDATA[ fb.zb_id <> fb.id ]]> and zb.type_id = '2'
  813. and zb.isdisabled = '1'
  814. and (fb.yhbh || fb.cbkh) = a.cbkid
  815. and (zb.yhbh || zb.cbkh) = #{cbkid})
  816. </select>
  817. <insert id="YMJZSFSB">
  818. INSERT INTO YY_CBLR_YMJZSFSB
  819. SELECT *
  820. FROM YY_CBLR
  821. WHERE CBBZ = '1'
  822. AND SHBZ = '1'
  823. AND JSBZ = '0'
  824. </insert>
  825. <insert id="yyCblrls">
  826. insert into yy_cblr_ls(ID, YHBH, CBKH, CBKID, SSGS,
  827. SSCBPQ, SSCBB, CWRQ, SCDS, BCDS,
  828. JJL, CBRYBM, CBRYXM, CBRQ, LRRYBM,
  829. LRRYXM, LRRQ, PHOTO, CBBZ, SHBZ, JSBZ,
  830. CBCS, CBXH, BZ, CBLX, CBFS, JFZT, SL,
  831. JBZD, XBQD, JBBH, CBLY, X, Y,
  832. SHRY, SHSJ, SHSM, SSREGION, SHRYXM,
  833. NBZXDS, NBZXCBRQ, JSSL, SBZT, xycb,
  834. QYFZRBM, QYFZRXM,SCCBRQ)
  835. select sys_guid(),
  836. YHBH,
  837. CBKH,
  838. CBKID,
  839. a.SSGS,
  840. a.SSCBPQ,
  841. a.SSCBB,
  842. CWRQ,
  843. SCDS,
  844. BCDS,
  845. JJL,
  846. CBRYBM,
  847. CBRYXM,
  848. CBRQ,
  849. LRRYBM,
  850. LRRYXM,
  851. LRRQ,
  852. PHOTO,
  853. CBBZ,
  854. SHBZ,
  855. JSBZ,
  856. CBCS,
  857. CBXH,
  858. a.BZ,
  859. CBLX,
  860. CBFS,
  861. JFZT,
  862. SL,
  863. JBZD,
  864. XBQD,
  865. JBBH,
  866. CBLY,
  867. X,
  868. Y,
  869. SHRY,
  870. SHSJ,
  871. SHSM,
  872. SSREGION,
  873. SHRYXM,
  874. NBZXDS,
  875. NBZXCBRQ,
  876. JSSL,
  877. SBZT,
  878. xycb,
  879. b.qyfzr,
  880. b.qyfzrxm,
  881. SCCBRQ
  882. from yy_cblr a
  883. left join bm_cbb b on a.sscbb = b.cbbbm
  884. where a.ssgs = '1'
  885. </insert>
  886. <sql id="cblrcxsql">
  887. SELECT a.shryxm AS shryxm,
  888. a.yhbh AS yhbh,
  889. a.cbkh AS cbkh,
  890. a.cbkid AS cbkid,
  891. a.ssgs AS ssgs,
  892. a.sscbpq AS sscbpq,
  893. a.sscbb AS sscbb,
  894. a.cwrq AS cwrq,
  895. a.scds AS scds,
  896. a.bcds AS bcds,
  897. a.jjl AS jjl,
  898. a.cbrybm AS cbrybm,
  899. a.cbryxm AS cbryxm,
  900. a.cbrq AS cbrq,
  901. a.lrrybm AS lrrybm,
  902. a.lrryxm AS lrryxm,
  903. a.lrrq AS lrrq,
  904. a.photo AS photo,
  905. a.cbbz AS cbbz,
  906. a.shbz AS shbz,
  907. a.jsbz AS jsbz,
  908. a.cbcs AS cbcs,
  909. a.cbxh AS cbxh,
  910. a.bz AS bz,
  911. a.cblx AS cblx,
  912. a.cbfs AS cbfs,
  913. a.jfzt AS jfzt,
  914. a.sl AS sl,
  915. a.jbzd AS jbzd,
  916. a.xbqd AS xbqd,
  917. a.jbbh AS jbbh,
  918. a.cbly AS cbly,
  919. a.x AS x,
  920. a.y AS y,
  921. a.shry AS shry,
  922. a.shsj AS shsj,
  923. a.shsm AS shsm,
  924. a.ssregion AS ssregion,
  925. a.nbzxds AS nbzxds,
  926. a.nbzxcbrq AS nbzxcbrq,
  927. a.jssl AS jssl,
  928. a.sbzt AS sbzt,
  929. b.qyfzr AS qyfzrbm,
  930. b.qyfzrxm AS qyfzrxm
  931. FROM yy_cblr a
  932. LEFT JOIN
  933. bm_cbb b ON a.sscbb = b.cbbbm
  934. WHERE a.ssgs = '1'
  935. </sql>
  936. <select id="plcxcblrmx" resultType="com.tofly.feesapi.cbgl.entity.YyCblrLs">
  937. <include refid="cblrcxsql"></include>
  938. </select>
  939. <select id="cxcblrmx" resultType="com.tofly.feesapi.cbgl.entity.YyCblrLs">
  940. <include refid="cblrcxsql"></include>
  941. </select>
  942. <update id="updateCbb">
  943. UPDATE (
  944. SELECT SBZD,
  945. ZXCBRQ,
  946. BCDS,
  947. CBRQ
  948. FROM YY_CBLR A,
  949. YH_CBKXX B
  950. WHERE A.YHBH = B.YHBH
  951. AND A.CBKH = B.CBKH )
  952. SET
  953. SBZD = BCDS, ZXCBRQ = CBRQ
  954. </update>
  955. <select id="getListCbmx" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
  956. <include refid="querySql"></include>
  957. UNION ALL
  958. <include refid="querySql1"></include>
  959. </select>
  960. <select id="getCbkids" resultType="java.lang.String">
  961. SELECT a.cbkid
  962. FROM yy_cblr a
  963. LEFT JOIN bm_cbfs b on a.cbfs = b.code
  964. LEFT JOIN bm_cblx c on a.cblx = c.code
  965. LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
  966. LEFT JOIN yh_cbkxx e on a.yhbh = e.yhbh and a.cbkh=e.cbkh
  967. WHERE 1=1 and e.jfzt=1
  968. <!--模糊查询 -->
  969. <if test="filter.searchText!=null">
  970. AND ( a.yhbh like '%${filter.searchText}%'
  971. OR d.yhxm like '%${filter.searchText}%'
  972. OR d.yhdz like '%${filter.searchText}%'
  973. OR d.lxdh like '${filter.searchText}%'
  974. )
  975. </if>
  976. <!--所属公司-->
  977. <if test="filter.ssgs!=null">
  978. AND d.ssgs=#{filter.ssgs}
  979. </if>
  980. <!--所属片区-->
  981. <if test="filter.sscbpq!=null">
  982. AND d.sscbpq=#{filter.sscbpq}
  983. </if>
  984. <!--所属抄表本-->
  985. <if test="filter.sscbb!=null">
  986. <choose>
  987. <when test="filter.sscbb.indexOf(',')!=-1">
  988. AND d.sscbb in
  989. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  990. close=")">
  991. #{item}
  992. </foreach>
  993. </when>
  994. <otherwise>
  995. AND d.sscbb=#{filter.sscbb}
  996. </otherwise>
  997. </choose>
  998. </if>
  999. <if test="filter.shbz!=null">
  1000. AND a.shbz=#{filter.shbz}
  1001. </if>
  1002. <!-- 抄表方式-->
  1003. <if test="filter.cbfs!=null">
  1004. AND a.cbfs=#{filter.cbfs}
  1005. </if>
  1006. <!-- 用水性质(水价编码)-->
  1007. <if test="filter.ysxz!=null">
  1008. AND (e.sjbm in (select code from bm_sj where yslx=#{filter.ysxz})
  1009. OR e.sjbm1 in (select code from bm_sj where yslx=#{filter.ysxz})
  1010. OR e.sjbm2 in (select code from bm_sj where yslx=#{filter.ysxz})
  1011. OR e.sjbm3 in (select code from bm_sj where yslx=#{filter.ysxz})
  1012. )
  1013. </if>
  1014. <!-- 水表口径编码-->
  1015. <if test="filter.sbkj!=null">
  1016. AND e.sbkj=#{filter.sbkj}
  1017. </if>
  1018. <!-- 抄表人员编码-->
  1019. <if test="filter.cbrybm!=null">
  1020. AND a.cbrybm=#{filter.cbrybm}
  1021. </if>
  1022. <!-- 财务日期-->
  1023. <if test="filter.cwrq!=null">
  1024. AND a.cwrq=#{filter.cwrq}
  1025. </if>
  1026. <!-- 录入日期-->
  1027. <if test="filter.lrrqStart!=null and filter.lrrqEnd!=null">
  1028. AND a.lrrq BETWEEN #{filter.lrrqStart} AND #{filter.lrrqEnd}
  1029. </if>
  1030. <if test="filter.kssl!=null and filter.jssl!=null">
  1031. AND a.sl BETWEEN #{filter.kssl} AND #{filter.jssl}
  1032. </if>
  1033. </select>
  1034. <select id="stat" resultType="com.tofly.feesapi.sfgl.entity.vo.YyStat">
  1035. select sum(sl) sl from(
  1036. select nvl(sl, 0) sl
  1037. from yy_cblr
  1038. where yhbh = #{filter.yhbh}
  1039. <if test="filter.ssgs!=null">
  1040. and ssgs = #{filter.ssgs}
  1041. </if>
  1042. union all
  1043. select nvl(sl, 0) sl
  1044. from yy_cblr_ls
  1045. where yhbh = #{filter.yhbh}
  1046. <if test="filter.ssgs!=null">
  1047. and ssgs = #{filter.ssgs}
  1048. </if>
  1049. ) a
  1050. </select>
  1051. <select id="getZbFbs" resultType="java.util.Map">
  1052. select (a.yhbh || a.cbkh) cbkid, count(1) num
  1053. from yh_bjfl_zb a
  1054. left join yh_bjfl_fb b on a.id = b.zb_id
  1055. left join yy_cblr c on a.yhbh = c.yhbh and a.cbkh = c.cbkh
  1056. where <![CDATA[ b.zb_id <> b.id ]]> and a.isdisabled = '1'
  1057. and c.sl > 0
  1058. group by a.yhbh, a.cbkh
  1059. </select>
  1060. <select id="zcbcszsltj" resultType="com.tofly.feesapi.cbgl.entity.dto.ZcbcssltjDto">
  1061. SELECT
  1062. COUNT(*) AS zcbcs,
  1063. SUM(sl) AS zcbsl
  1064. FROM (
  1065. SELECT
  1066. NVL( a.SL, 0 ) AS sl
  1067. FROM
  1068. yy_cblr a
  1069. LEFT JOIN yh_khjbxx d ON a.yhbh = d.yhbh
  1070. WHERE
  1071. a.SHBZ = '1'
  1072. <if test="filter.ssgs != null and filter.ssgs != ''">
  1073. AND a.ssgs = #{filter.ssgs}
  1074. </if>
  1075. <if test="filter.sscbpq != null and filter.sscbpq != ''">
  1076. AND a.sscbpq = #{filter.sscbpq}
  1077. </if>
  1078. <if test="filter.sscbb != null and filter.sscbb != ''">
  1079. AND a.sscbb = #{filter.sscbb}
  1080. </if>
  1081. <if test="filter.searchText != null and filter.searchText != ''">
  1082. AND ( a.yhbh like '%${filter.searchText}%'
  1083. OR d.yhxm like '%${filter.searchText}%'
  1084. OR d.yhdz like '%${filter.searchText}%'
  1085. OR d.lxdh like '${filter.searchText}%'
  1086. )
  1087. </if>
  1088. <if test="filter.cwrqStart != null and filter.cwrqEnd != null">
  1089. AND a.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
  1090. </if>
  1091. UNION ALL
  1092. SELECT
  1093. NVL( ls.SL, 0 ) AS sl
  1094. FROM
  1095. yy_cblr_ls ls
  1096. LEFT JOIN yh_khjbxx d ON ls.yhbh = d.yhbh
  1097. WHERE
  1098. ls.SHBZ = '1'
  1099. <if test="filter.ssgs != null and filter.ssgs != ''">
  1100. AND ls.ssgs = #{filter.ssgs}
  1101. </if>
  1102. <if test="filter.sscbpq != null and filter.sscbpq != ''">
  1103. AND ls.sscbpq = #{filter.sscbpq}
  1104. </if>
  1105. <if test="filter.sscbb != null and filter.sscbb != ''">
  1106. AND ls.sscbb = #{filter.sscbb}
  1107. </if>
  1108. <if test="filter.searchText != null and filter.searchText != ''">
  1109. AND ( ls.yhbh like '%${filter.searchText}%'
  1110. OR d.yhxm like '%${filter.searchText}%'
  1111. OR d.yhdz like '%${filter.searchText}%'
  1112. OR d.lxdh like '${filter.searchText}%'
  1113. )
  1114. </if>
  1115. <if test="filter.cwrqStart != null and filter.cwrqEnd != null">
  1116. AND ls.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
  1117. </if>
  1118. )
  1119. </select>
  1120. <select id="getCblrSl" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrSflxMxSelect">
  1121. select e.code,e.name,nvl(sum(sl),0) sl
  1122. from yy_cblr a left join yh_cbkxx b on a.cbkid=b.cbkid
  1123. left join bm_sj c on b.sjbm=c.code
  1124. left join bm_yslx e on c.yslx=e.code
  1125. where a.cbbz=1
  1126. <if test="filter.yslx!=null">
  1127. and e.code=#{filter.yslx}
  1128. </if>
  1129. <if test="filter.cwrq!=null">
  1130. and a.cwrq=#{filter.cwrq}
  1131. </if>
  1132. group by e.code,e.name
  1133. </select>
  1134. <select id="getCblrSlLs" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrSflxMxSelect">
  1135. select e.code,e.name,nvl(sum(sl),0) sl from yy_cblr_ls a left join yh_cbkxx b on a.cbkid=b.cbkid
  1136. left join bm_sj c on b.sjbm=c.code
  1137. left join bm_yslx e on c.yslx=e.code
  1138. where a.cbbz=1
  1139. <if test="filter.yslx!=null">
  1140. and e.code=#{filter.yslx}
  1141. </if>
  1142. <if test="filter.cwrq!=null">
  1143. and a.cwrq=#{filter.cwrq}
  1144. </if>
  1145. group by e.code,e.name
  1146. </select>
  1147. <select id="retportSlfx" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrSflxMxSelect">
  1148. select a.code,sum(sl) sl from bm_yslx a
  1149. left join (
  1150. select a.*,c.yslx from (
  1151. select yhbh,cbkid,cwrq,sl,sscbpq from yy_cblr_ls where cbbz=1
  1152. union
  1153. select yhbh,cbkid,cwrq,sl,sscbpq from yy_cblr where cbbz=1
  1154. ) a left join yh_cbkxx b on a.cbkid=b.cbkid
  1155. left join bm_sj c on b.sjbm=c.code
  1156. left join yh_khjbxx e on b.yhbh=e.yhbh and e.yhzt='1'
  1157. ) aa on a.code=aa.yslx
  1158. where
  1159. 1=1
  1160. <if test="filter.cwrq!=null and filter.cwrqend!=null ">
  1161. and (aa.cwrq) between #{filter.cwrq} and #{filter.cwrqend}
  1162. </if>
  1163. <if test="filter.sspq!=null and filter.sspq!=null ">
  1164. and aa.sscbpq=#{filter.sspq}
  1165. </if>
  1166. group by a.code
  1167. order by code asc
  1168. </select>
  1169. <select id="retportSlfxMx" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrSflxSelect">
  1170. select a.yhbh,b.yhxm,a.sl dqsl,a.cwrq,nvl(e.sl,0) sysl,(a.sl-nvl(e.sl,0))/nvl(e.sl,1)*100 tbbl,nvl(f.sl,0)
  1171. sndsl,(a.sl-nvl(f.sl,0))/nvl(f.sl,1)*100 hbbl from (
  1172. select yhbh,sl,cwrq,cbkid from yy_cblr
  1173. union all
  1174. select yhbh, sl,cwrq,cbkid from yy_cblr_ls
  1175. ) a left join yh_khjbxx b on a.yhbh=b.yhbh
  1176. left join yh_cbkxx c on a.cbkid=c.cbkid
  1177. <if test="cwrq1!=null and cwrq1!=null">
  1178. left join yy_cblr_ls e on a.cwrq=#{cwrq1} and e.cbkid=a.cbkid
  1179. </if>
  1180. <if test="cwrq2!=null and cwrq2!=null">
  1181. left join yy_cblr_ls f on a.cwrq=#{cwrq2} and e.cbkid=a.cbkid
  1182. </if>
  1183. where 1=1
  1184. <if test="filter.cwrq!=null">
  1185. and a.cwrq=#{filter.cwrq}
  1186. </if>
  1187. <if test="filter.sspq!=null">
  1188. and b.sscbpq=#{filter.sspq}
  1189. </if>
  1190. <if test="filter.sscbb!=null">
  1191. <choose>
  1192. <when test="filter.sscbb.indexOf(',')!=-1">
  1193. AND b.sscbb in
  1194. <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
  1195. close=")">
  1196. #{item}
  1197. </foreach>
  1198. </when>
  1199. <otherwise>
  1200. AND b.sscbb=#{filter.sscbb}
  1201. </otherwise>
  1202. </choose>
  1203. </if>
  1204. <if test="filter.yslx!=null">
  1205. and c.sjbm=#{filter.yslx}
  1206. </if>
  1207. <if test="filter.yhlx!=null">
  1208. and b.dxh=#{filter.yhlx}
  1209. </if>
  1210. <if test="filter.bl!=null">
  1211. and (a.sl-nvl(e.sl,0))/nvl(e.sl,1)*100>#{filter.bl}
  1212. </if>
  1213. </select>
  1214. <select id="retportSlfxMxByYhbh" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrSflxYhbhSelect">
  1215. select yhbh,sl,cwrq from ${tbName}
  1216. where 1=1
  1217. <if test="filter.cwrq!=null and filter.cwrq!=null">
  1218. and cwrq=#{filter.cwrq}
  1219. </if>
  1220. <if test="filter.yhbh!=null and filter.yhbh!=null">
  1221. and yhbh=#{filter.yhbh}
  1222. </if>
  1223. </select>
  1224. <select id="getCblrCount" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrCountSelect">
  1225. SELECT sum(nvl(sl,0)) zysl,sum(nvl(scds,0)) zyscds,sum(nvl(bcds,0)) zybcds
  1226. FROM ( -- 合并当前表和历史表
  1227. SELECT 'current' as table_source,
  1228. yhbh,
  1229. cbkh,
  1230. cbkid,
  1231. scds,
  1232. bcds,
  1233. jjl,
  1234. sl,
  1235. cbfs,
  1236. cbbz,
  1237. shbz,
  1238. jsbz,
  1239. cblx,
  1240. jbzd,
  1241. xbqd,
  1242. jbbh,
  1243. cbrq,
  1244. lrrq,
  1245. photo,
  1246. bz,
  1247. cbrybm,
  1248. cbryxm,
  1249. cbxh,
  1250. cwrq,
  1251. sscbb,
  1252. sbzt,
  1253. lrrybm,
  1254. lrryxm,
  1255. cbcs
  1256. FROM yy_cblr
  1257. UNION ALL
  1258. SELECT 'history' as table_source,
  1259. yhbh,
  1260. cbkh,
  1261. cbkid,
  1262. scds,
  1263. bcds,
  1264. jjl,
  1265. sl,
  1266. cbfs,
  1267. cbbz,
  1268. shbz,
  1269. jsbz,
  1270. cblx,
  1271. jbzd,
  1272. xbqd,
  1273. jbbh,
  1274. cbrq,
  1275. lrrq,
  1276. photo,
  1277. bz,
  1278. cbrybm,
  1279. cbryxm,
  1280. cbxh,
  1281. cwrq,
  1282. sscbb,
  1283. sbzt,
  1284. lrrybm,
  1285. lrryxm,
  1286. cbcs
  1287. FROM yy_cblr_ls) a
  1288. LEFT JOIN bm_cbfs b ON a.cbfs = b.code
  1289. LEFT JOIN bm_cblx c ON a.cblx = c.code
  1290. LEFT JOIN yh_khjbxx d ON a.yhbh = d.yhbh
  1291. -- 根据数据来源动态连接不同的表
  1292. LEFT JOIN yh_cbkxx e ON a.cbkid = e.cbkid AND a.table_source = 'current'
  1293. LEFT JOIN yh_cbkxx ls_e ON a.yhbh = ls_e.yhbh AND a.cbkh = ls_e.cbkh AND a.table_source = 'history'
  1294. LEFT JOIN sys_child_code f ON a.sbzt = f.cccode AND f.pcid = '34'
  1295. LEFT JOIN bm_cbb g ON d.sscbb = g.cbbbm
  1296. <include refid="querySqlWhere2"></include>
  1297. </select>
  1298. </mapper>