| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.tofly.feesapi.cbgl.mapper.YyCblrMapper">
- <sql id="querySql">
- SELECT
- 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,
- b.name AS cbfsmc, a.cbbz, a.shbz, a.jsbz, a.cblx, c.name AS cblxmc, a.jbzd, a.xbqd, a.jbbh, a.cbrq,
- a.lrrq, a.photo, a.bz, a.cbrybm, a.cbryxm, a.cbxh, a.cwrq,a.sscbb, f.ccname as sbzt,e.fmzt,
- g.qyfzr as qyfzrbm,g.qyfzrxm,a.lrrybm, a.lrryxm, e.cbpl
- <if test="filter.cxly!=null and filter.cxly=='app'">
- ,(select LISTAGG(cwrq||'-'||ysje,'|') WITHIN GROUP (ORDER BY cwrq) from yy_qfmx where sfbz=0 and
- yy_qfmx.yhbh=a.yhbh) qfje,
- (SELECT nvl(sum(nvl(syje, 0)), 0) FROM yy_zjzh WHERE yy_zjzh.yhbh = a.yhbh ) ycje
- </if>
- FROM yy_cblr a
- LEFT JOIN bm_cbfs b on a.cbfs = b.code
- LEFT JOIN bm_cblx c on a.cblx = c.code
- LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
- LEFT JOIN yh_cbkxx e on a.yhbh = e.yhbh and a.cbkh=e.cbkh
- LEFT JOIN sys_child_code f on a.sbzt=f.cccode and f.pcid='34'
- LEFT JOIN bm_cbb g on a.sscbb = g.cbbbm
- <include refid="querySqlWhere"></include>
- </sql>
- <sql id="querySqlWhere">
- <if test="filter.cwrq!=null and filter.cwrq!=''">
- LEFT JOIN (
- SELECT yhbh,cbkid, sl FROM YY_CBLR_LS
- WHERE cwrq = #{filter.cwrq}
- <!--所属公司-->
- <if test="filter.ssgs != null and filter.ssgs != ''">
- AND ssgs=#{filter.ssgs}
- </if>
- <!--所属片区-->
- <if test="filter.sscbpq != null and filter.sscbpq != ''">
- AND sscbpq=#{filter.sscbpq}
- </if>
- <!--所属抄表本-->
- <if test="filter.sscbb != null and filter.sscbb != ''">
- <choose>
- <when test="filter.sscbb.indexOf(',')!=-1">
- AND sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND sscbb=#{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- <if test="filter.userId!= null">
- AND sscbb in (select cbbbm from yh_sjqx where user_id=#{filter.userId})
- </if>
- ) ls ON a.cbkid=ls.cbkid
- </if>
- WHERE 1=1 AND e.jfzt='1'
- <!--模糊查询 -->
- <if test="filter.searchText!=null">
- AND ( a.yhbh like '%${filter.searchText}%'
- OR d.yhxm like '%${filter.searchText}%'
- OR d.yhdz like '%${filter.searchText}%'
- OR d.lxdh like '${filter.searchText}%'
- )
- </if>
- <!--所属公司-->
- <if test="filter.ssgs != null and filter.ssgs != ''">
- AND a.ssgs = #{filter.ssgs}
- </if>
- <!--所属片区-->
- <if test="filter.sscbpq != null and filter.sscbpq != ''">
- AND a.sscbpq=#{filter.sscbpq}
- </if>
- <!--所属抄表本-->
- <if test="filter.sscbb != null and filter.sscbb != ''">
- <choose>
- <when test="filter.sscbb.indexOf(',')!=-1">
- AND a.sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND a.sscbb=#{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- <!-- 抄表方式-->
- <if test="filter.cbfs!=null">
- AND a.cbfs=#{filter.cbfs}
- </if>
- <!-- 用水性质(水价编码)-->
- <if test="filter.ysxz!=null">
- AND (
- e.sjbm in (select code from bm_sj where yslx=#{filter.ysxz})
- OR e.sjbm1 in (select code from bm_sj where yslx=#{filter.ysxz})
- OR e.sjbm2 in (select code from bm_sj where yslx=#{filter.ysxz})
- OR e.sjbm3 in (select code from bm_sj where yslx=#{filter.ysxz})
- )
- </if>
- <!-- 水表口径编码-->
- <if test="filter.sbkj!=null">
- AND e.sbkj = #{filter.sbkj}
- </if>
- <!-- 抄表人员编码-->
- <if test="filter.cbrybm!=null">
- AND a.cbrybm = #{filter.cbrybm}
- </if>
- <!-- 财务日期-->
- <if test="filter.cwrq!=null">
- AND a.cwrq = #{filter.cwrq}
- </if>
- <!-- 抄表标志-->
- <if test="filter.cbbz!=null">
- AND nvl(a.cbbz,0) = #{filter.cbbz}
- </if>
- <!-- 审核标志-->
- <if test="filter.shbz!=null">
- AND nvl(a.shbz,0) = #{filter.shbz}
- </if>
- <!-- 计算标志-->
- <if test="filter.jsbz!=null">
- AND nvl(a.jsbz,0) = #{filter.jsbz}
- </if>
- <!-- 录入日期-->
- <if test="filter.lrrqStart!=null and filter.lrrqEnd!=null">
- AND a.lrrq BETWEEN #{filter.lrrqStart} AND
- #{filter.lrrqEnd}
- </if>
- <!--抄表序号-->
- <if test="filter.cbxh !=null and filter.cbxh != ''">
- AND a.cbxh=#{filter.cbxh}
- </if>
- <!--用户编号-->
- <if test="filter.yhbh != null and filter.yhbh != ''">
- AND a.yhbh = #{filter.yhbh}
- </if>
- <if test="filter.sfssfb!=null">
- <if test="filter.sfssfb==1">
- AND not exists (select 1 from yh_bjfl_fb fb left join yh_bjfl_zb zb on
- fb.zb_id=zb.id where <![CDATA[ fb.zb_id<>fb.id ]]> and zb.isdisabled='1' and
- (fb.yhbh||fb.cbkh)=a.cbkid)
- </if>
- <if test="filter.sfssfb==0">
- AND exists (select 1 from yh_bjfl_fb fb left join yh_bjfl_zb zb on
- fb.zb_id=zb.id where <![CDATA[ fb.zb_id<>fb.id ]]> and zb.isdisabled='1' and
- (fb.yhbh||fb.cbkh)=a.cbkid)
- </if>
- </if>
- <if test="filter.qyfzr!=null">
- AND a.sscbb in(select cbbbm from bm_cbb where qyfzr=#{filter.qyfzr})
- </if>
- <if test="filter.cwrqStart!=null and filter.cwrqEnd!=null">
- AND a.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
- </if>
- <if test="filter.yhbhStart!=null">
- <![CDATA[ AND a.yhbh>=#{filter.yhbhStart} ]]>
- </if>
- <if test="filter.yhbhEnd!=null">
- <![CDATA[ AND a.yhbh<=#{filter.yhbhEnd} ]]>
- </if>
- <if test="filter.sbzt!=null">
- AND a.sbzt=#{filter.sbzt}
- </if>
- <if test="filter.sblb!=null">
- AND e.sblb=#{filter.sblb}
- </if>
- <if test="filter.cbly!=null">
- AND a.cbly=#{filter.cbly}
- </if>
- <if test="filter.kssl!=null and filter.jssl!=null">
- AND a.sl BETWEEN #{filter.kssl} AND #{filter.jssl}
- </if>
- <if test="filter.bfb!=null">
- AND ( ls.sl != 0 AND a.sl != 0 AND
- ((a.sl>=ls.sl AND round((a.sl-ls.sl)/ls.sl*100,2)>=#{filter.bfb})
- or (ls.sl>=a.sl AND round((ls.sl-a.sl)/a.sl*100,2)>=#{filter.bfb}))
- )
- </if>
- <if test="filter.userId != null">
- AND a.sscbb in (select cbbbm from yh_sjqx where user_id=#{filter.userId})
- </if>
- <if test="filter.dxh != null">
- AND d.dxh = #{dxh}
- </if>
- </sql>
- <!--查询抄表录入历史-->
- <sql id="querySql1">
- SELECT
- 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,
- b.name AS cbfsmc, a.cbbz, a.shbz, a.jsbz, a.cblx, c.name AS cblxmc, a.jbzd, a.xbqd, a.jbbh, a.cbrq,
- a.lrrq, a.photo, a.bz, a.cbrybm, a.cbryxm, a.cbxh, a.cwrq,a.sscbb, f.ccname as sbzt,e.fmzt,
- a.qyfzrbm,a.qyfzrxm,a.lrrybm, a.lrryxm,e.cbpl cbpl
- FROM yy_cblr_ls a
- LEFT JOIN bm_cbfs b on a.cbfs = b.code
- LEFT JOIN bm_cblx c on a.cblx = c.code
- LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
- LEFT JOIN yh_cbkxx e on a.yhbh = e.yhbh and a.cbkh=e.cbkh
- LEFT JOIN sys_child_code f on a.sbzt=f.cccode and pcid='34'
- <include refid="querySqlWhere2"></include>
- </sql>
- <sql id="querySqlWhere2">
- WHERE 1=1
- <!--模糊查询 -->
- <if test="filter.searchText!=null">
- AND ( a.yhbh like '%${filter.searchText}%'
- OR d.yhxm like '%${filter.searchText}%'
- OR d.yhdz like '%${filter.searchText}%' )
- </if>
- <!--所属公司-->
- <if test="filter.ssgs!=null">
- AND d.ssgs=#{filter.ssgs}
- </if>
- <!--所属片区-->
- <if test="filter.sscbpq!=null">
- AND d.sscbpq=#{filter.sscbpq}
- </if>
- <!--所属抄表本-->
- <if test="filter.sscbb!=null">
- <choose>
- <when test="filter.sscbb.indexOf(',')!=-1">
- AND d.sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND d.sscbb=#{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- <!-- 抄表方式-->
- <if test="filter.cbfs!=null">
- AND a.cbfs=#{filter.cbfs}
- </if>
- <!-- 用水性质(水价编码)-->
- <if test="filter.ysxz!=null">
- AND (e.sjbm in (select code from bm_sj where yslx=#{filter.ysxz})
- OR e.sjbm1 in (select code from bm_sj where yslx=#{filter.ysxz})
- OR e.sjbm2 in (select code from bm_sj where yslx=#{filter.ysxz})
- OR e.sjbm3 in (select code from bm_sj where yslx=#{filter.ysxz})
- )
- </if>
- <!-- 水表口径编码-->
- <if test="filter.sbkj!=null">
- AND e.sbkj=#{filter.sbkj}
- </if>
- <!-- 抄表人员编码-->
- <if test="filter.cbrybm != null and filter.cbrybm != ''">
- AND a.cbrybm=#{filter.cbrybm}
- </if>
- <!-- 财务日期-->
- <if test="filter.cwrq != null and filter.cwrq != ''">
- AND a.cwrq=#{filter.cwrq}
- </if>
- <!-- 抄表标志-->
- <if test="filter.cbbz!=null">
- AND nvl(a.cbbz,0)=#{filter.cbbz}
- </if>
- <!-- 审核标志-->
- <if test="filter.shbz!=null">
- AND nvl(a.shbz,0)=#{filter.shbz}
- </if>
- <!-- 计算标志-->
- <if test="filter.jsbz!=null">
- AND nvl(a.jsbz,0)=#{filter.jsbz}
- </if>
- <!-- 录入日期-->
- <if test="filter.lrrqStart!=null and filter.lrrqEnd!=null">
- AND a.lrrq BETWEEN #{filter.lrrqStart} AND #{filter.lrrqEnd}
- </if>
- <!--抄表序号-->
- <if test="filter.cbxh!=null">
- AND a.cbxh=#{filter.cbxh}
- </if>
- <!--用户编号-->
- <if test="filter.yhbh!=null">
- AND a.yhbh=#{filter.yhbh}
- </if>
- <if test="filter.qyfzr!=null">
- AND a.sscbb in(select cbbbm from bm_cbb where qyfzr=#{filter.qyfzr})
- </if>
- <if test="filter.cwrqStart!=null and filter.cwrqEnd!=null">
- AND a.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
- </if>
- <if test="filter.yhbhStart!=null">
- <![CDATA[ AND a.yhbh>=#{filter.yhbhStart} ]]>
- </if>
- <if test="filter.yhbhEnd!=null">
- <![CDATA[ AND a.yhbh<=#{filter.yhbhEnd} ]]>
- </if>
- <if test="filter.sbzt!=null">
- AND a.sbzt=#{filter.sbzt}
- </if>
- <if test="filter.sblb!=null">
- AND e.sbzt=#{filter.sblb}
- </if>
- <if test="filter.cbly!=null">
- AND a.cbly=#{filter.cbly}
- </if>
- <if test="filter.userId != null">
- AND a.sscbb in (select cbbbm from yh_sjqx where user_id=#{filter.userId})
- </if>
- <if test="filter.dxh != null">
- AND d.dxh = #{filter.dxh}
- </if>
- <if test="filter.cblx!=null">
- AND a.cblx=#{filter.cblx}
- </if>
- </sql>
- <sql id="querySqldqorls">
- SELECT a.yhbh,
- a.cbkh,
- a.cbkid,
- a.scds,
- a.bcds,
- a.jjl,
- a.sl AS sjsl,
- a.cbfs,
- a.cbbz,
- a.shbz,
- a.jsbz,
- a.cblx,
- a.jbzd,
- a.xbqd,
- a.jbbh,
- a.cbrq,
- a.lrrq,
- a.photo,
- a.bz,
- a.cbrybm,
- a.cbryxm,
- a.cbxh,
- a.cwrq,
- a.sscbb,
- a.sbzt,
- a.lrrybm,
- a.lrryxm,
- a.cbcs,
- -- 动态决定连接哪个表
- CASE WHEN a.table_source = 'current' THEN e.sbbh ELSE ls_e.sbbh END AS sbbh,
- CASE WHEN a.table_source = 'current' THEN e.sblc ELSE ls_e.sblc END AS sblc,
- CASE WHEN a.table_source = 'current' THEN e.fmzt ELSE ls_e.fmzt END AS fmzt,
- d.yhxm,
- d.yhdz,
- d.lxdh,
- b.name AS cbfsmc,
- c.name AS cblxmc,
- f.ccname AS sbztmc,
- g.qyfzr AS qyfzrbm,
- g.qyfzrxm,
- a.table_source
- FROM ( -- 合并当前表和历史表
- SELECT 'current' as table_source,
- yhbh,
- cbkh,
- cbkid,
- scds,
- bcds,
- jjl,
- sl,
- cbfs,
- cbbz,
- shbz,
- jsbz,
- cblx,
- jbzd,
- xbqd,
- jbbh,
- cbrq,
- lrrq,
- photo,
- bz,
- cbrybm,
- cbryxm,
- cbxh,
- cwrq,
- sscbb,
- sbzt,
- lrrybm,
- lrryxm,
- cbcs
- FROM yy_cblr
- UNION ALL
- SELECT 'history' as table_source,
- yhbh,
- cbkh,
- cbkid,
- scds,
- bcds,
- jjl,
- sl,
- cbfs,
- cbbz,
- shbz,
- jsbz,
- cblx,
- jbzd,
- xbqd,
- jbbh,
- cbrq,
- lrrq,
- photo,
- bz,
- cbrybm,
- cbryxm,
- cbxh,
- cwrq,
- sscbb,
- sbzt,
- lrrybm,
- lrryxm,
- cbcs
- FROM yy_cblr_ls) a
- LEFT JOIN bm_cbfs b ON a.cbfs = b.code
- LEFT JOIN bm_cblx c ON a.cblx = c.code
- LEFT JOIN yh_khjbxx d ON a.yhbh = d.yhbh
- -- 根据数据来源动态连接不同的表
- LEFT JOIN yh_cbkxx e ON a.cbkid = e.cbkid AND a.table_source = 'current'
- LEFT JOIN yh_cbkxx ls_e ON a.yhbh = ls_e.yhbh AND a.cbkh = ls_e.cbkh AND a.table_source = 'history'
- LEFT JOIN sys_child_code f ON a.sbzt = f.cccode AND f.pcid = '34'
- LEFT JOIN bm_cbb g ON d.sscbb = g.cbbbm
- </sql>
- <select id="getPage" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
- <include refid="querySql"/>
- </select>
- <select id="getPage2" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
- <include refid="querySqldqorls"></include>
- <include refid="querySqlWhere2"></include>
- </select>
- <select id="getList" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
- <include refid="querySqldqorls"></include>
- <include refid="querySqlWhere2"></include>
- <if test="filter.orders!=null and !filter.orders.isEmpty()">
- order by
- <foreach item="item" index="index" collection="filter.orders" separator=",">
- ${item.column} ${item.asc? 'asc':'desc'}
- </foreach>
- </if>
- </select>
- <select id="getCbjlByYhbhs" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
- SELECT * FROM (
- SELECT
- 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,
- b.name AS cbfsmc, a.cbbz, a.shbz, a.jsbz, a.cblx, c.name AS cblxmc, a.jbzd, a.xbqd, a.jbbh, a.cbrq,
- a.lrrq, a.photo, a.bz, a.cbrybm, a.cbryxm, a.cbxh, a.cwrq,a.sscbb, f.ccname as sbzt,e.fmzt,
- g.qyfzr as qyfzrbm,g.qyfzrxm,a.lrrybm, a.lrryxm
- FROM yy_cblr a
- LEFT JOIN bm_cbfs b on a.cbfs = b.code
- LEFT JOIN bm_cblx c on a.cblx = c.code
- LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
- LEFT JOIN yh_cbkxx e on a.yhbh = e.yhbh and a.cbkh=e.cbkh
- LEFT JOIN sys_child_code f on a.sbzt=f.cccode and f.pcid='34'
- LEFT JOIN bm_cbb g on a.sscbb = g.cbbbm
- WHERE 1=1
- <if test="filter.ssgs!=null">
- AND a.ssgs = #{filter.ssgs}
- </if>
- <if test="filter.sscbpq!=null">
- AND a.sscbpq=#{filter.sscbpq}
- </if>
- <if test="filter.sscbb!=null">
- <choose>
- <when test="filter.sscbb.indexOf(',')!=-1">
- AND a.sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND a.sscbb=#{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- <if test="filter.searchText!=null">
- AND ( a.yhbh like '%${filter.searchText}%'
- OR d.yhxm like '%${filter.searchText}%'
- OR d.yhdz like '%${filter.searchText}%'
- OR d.lxdh like '${filter.searchText}%'
- )
- </if>
- <if test="filter.cwrqStart!=null and filter.cwrqEnd!=null">
- AND a.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
- </if>
- <if test="filter.yhbhs != null and filter.yhbhs.size() > 0">
- AND a.yhbh IN
- <foreach collection="filter.yhbhs" open="(" separator="," item="yhbh" close=")">
- #{yhbh}
- </foreach>
- </if>
- UNION ALL
- SELECT
- 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,
- b.name AS cbfsmc, a.cbbz, a.shbz, a.jsbz, a.cblx, c.name AS cblxmc, a.jbzd, a.xbqd, a.jbbh, a.cbrq,
- a.lrrq, a.photo, a.bz, a.cbrybm, a.cbryxm, a.cbxh, a.cwrq,a.sscbb, f.ccname as sbzt,e.fmzt,
- a.qyfzrbm,a.qyfzrxm,a.lrrybm, a.lrryxm
- FROM yy_cblr_ls a
- LEFT JOIN bm_cbfs b on a.cbfs = b.code
- LEFT JOIN bm_cblx c on a.cblx = c.code
- LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
- LEFT JOIN yh_cbkxx e on a.yhbh = e.yhbh and a.cbkh=e.cbkh
- LEFT JOIN sys_child_code f on a.sbzt=f.cccode and pcid='34'
- WHERE 1=1
- <if test="filter.searchText!=null">
- AND ( a.yhbh like '%${filter.searchText}%'
- OR d.yhxm like '%${filter.searchText}%'
- OR d.yhdz like '%${filter.searchText}%' )
- </if>
- <if test="filter.ssgs!=null">
- AND d.ssgs=#{filter.ssgs}
- </if>
- <if test="filter.sscbpq!=null">
- AND d.sscbpq=#{filter.sscbpq}
- </if>
- <if test="filter.sscbb!=null">
- <choose>
- <when test="filter.sscbb.indexOf(',')!=-1">
- AND d.sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND d.sscbb=#{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- <if test="filter.cwrqStart!=null and filter.cwrqEnd!=null">
- AND a.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
- </if>
- <if test="filter.yhbhs != null and filter.yhbhs.size() > 0">
- AND a.yhbh IN
- <foreach collection="filter.yhbhs" open="(" separator="," item="yhbh" close=")">
- #{yhbh}
- </foreach>
- </if>
- )
- </select>
- <select id="lycbglfy" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
- SELECT
- 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, a.xycb,
- b.name AS cbfsmc, a.cbbz, a.shbz, a.jsbz, a.cblx, c.name AS cblxmc, a.jbzd, a.xbqd, a.jbbh, a.cbrq,
- a.lrrq, a.photo, a.bz, a.cbrybm, a.cbryxm, a.cbxh, a.cwrq,a.sscbb,
- f.ccname as sbzt,
- e.fmzt, e.cbpl,
- g.qyfzr as qyfzrbm, g.qyfzrxm, a.lrrybm, a.lrryxm
- FROM yy_cblr a
- LEFT JOIN bm_cbfs b ON a.cbfs = b.code
- LEFT JOIN bm_cblx c ON a.cblx = c.code
- LEFT JOIN yh_khjbxx d ON a.yhbh = d.yhbh
- LEFT JOIN yh_cbkxx e ON a.yhbh = e.yhbh and a.cbkh=e.cbkh
- LEFT JOIN sys_child_code f ON a.sbzt=f.cccode and f.pcid='34'
- LEFT JOIN bm_cbb g ON a.sscbb = g.cbbbm
- WHERE 1=1 AND e.jfzt='1'
- <!--所属公司-->
- <if test="filter.ssgs!=null">
- AND a.ssgs = #{filter.ssgs}
- </if>
- <!--所属片区-->
- <if test="filter.sscbpq!=null">
- AND a.sscbpq = #{filter.sscbpq}
- </if>
- <if test="filter.sscbb != null and filter.sscbb != ''">
- <choose>
- <when test="filter.sscbb.indexOf(',') != -1">
- AND a.sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND a.sscbb = #{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- <if test="filter.cwrq!= null and filter.cwrq != ''">
- AND a.cwrq = #{filter.cwrq}
- </if>
- <if test="filter.cbrybm != null and filter.cbrybm != ''">
- AND a.cbrybm = #{filter.cbrybm}
- </if>
- <if test="filter.cbbz != null">
- AND nvl(a.cbbz, 0)=#{filter.cbbz}
- </if>
- <if test="filter.shbz != null">
- AND nvl(a.shbz, 0) = #{filter.shbz}
- </if>
- <if test="filter.searchText!=null">
- AND ( a.yhbh like '%${filter.searchText}%'
- OR d.yhxm like '%${filter.searchText}%'
- OR d.yhdz like '%${filter.searchText}%'
- OR d.lxdh like '${filter.searchText}%'
- )
- </if>
- <if test="filter.userId != null">
- AND a.sscbb in (select cbbbm from yh_sjqx where user_id=#{filter.userId})
- </if>
- <if test="filter.dxh != null">
- AND d.dxh = #{dxh}
- </if>
- </select>
- <select id="getViewById" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrView">
- SELECT a.yhbh,
- a.cwrq,
- a.cbkh,
- b.sbbh,
- d.yhxm,
- d.lxdh,
- d.yhdz,
- b.sblc,
- a.cbfs,
- a.cblx,
- a.scds,
- a.bcds,
- a.jjl,
- a.bcds - a.scds AS sjsl,
- a.bz,
- a.photo,
- f.ccname as sbzt
- FROM yy_cblr a
- LEFT JOIN yh_cbkxx b on a.yhbh = b.yhbh and a.cbkh = b.cbkh
- LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
- LEFT JOIN sys_child_code f on a.sbzt = f.cccode and pcid = '34'
- WHERE a.yhbh = #{yhbh}
- and a.cbkh = #{cbkh}
- </select>
- <select id="cbsltj" resultType="com.tofly.feesapi.cbgl.entity.vo.CbSltjSelect">
- <if test="filter.tjlb=='cbry'">
- SELECT
- cbryxm AS tjlb,
- NVL(COUNT(1), 0) AS cbhs,
- NVL(SUM(sl), 0) AS cbsl FROM
- YY_CBLR
- WHERE jfzt = '1' AND cbbz = '1'
- <if test="filter.ssgs != null and filter.ssgs!= ''">
- AND ssgs = #{filter.ssgs}
- </if>
- <if test="filter.sscbpq != null and filter.sscbpq != ''">
- AND sscbpq = #{filter.sscbpq}
- </if>
- <if test="filter.sscbb != null and filter.sscbb != ''">
- AND sscbb = #{filter.sscbb}
- </if>
- GROUP BY
- cbryxm
- </if>
- <if test="filter.tjlb=='ysxz'">
- SELECT
- a.NAME AS tjlb,
- NVL(COUNT(1),0) AS cbhs,
- NVL(SUM(sl),0) AS cbsl
- FROM bm_yslx a
- Left JOIN BM_SJ b ON b.yslx = a.CODE
- Left JOIN YH_CBKXX c ON c.sjbm=b.code
- Left join YY_CBLR d ON c.CBKID = d.CBKID
- WHERE d.jfzt = '1'
- AND d.cbbz = '1'
- <if test="filter.ssgs!=null">
- AND d.ssgs = #{filter.ssgs}
- </if>
- <if test="filter.sscbpq!=null">
- AND d.sscbpq = #{filter.sscbpq}
- </if>
- <if test="filter.sscbb!=null">
- <choose>
- <when test="filter.sscbb.indexOf(',')!=-1">
- AND d.sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND d.sscbb=#{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- GROUP BY
- a.NAME
- </if>
- <if test="filter.tjlb=='cbb'">
- SELECT
- b.CBBMC AS tjlb,
- NVL(COUNT(1),0) AS cbhs,
- NVL(SUM(sl),0) AS cbsl
- FROM
- YY_CBLR a
- LEFT JOIN BM_CBB b ON a.sscbb = b.cbbbm
- WHERE
- a.jfzt = '1'
- AND a.cbbz = '1'
- <if test="filter.ssgs!=null">
- AND a.ssgs = #{filter.ssgs}
- </if>
- <if test="filter.sscbpq!=null">
- AND a.sscbpq = #{filter.sscbpq}
- </if>
- <if test="filter.sscbb!=null">
- <choose>
- <when test="filter.sscbb.indexOf(',')!=-1">
- AND a.sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND a.sscbb=#{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- GROUP BY
- b.CBBMC
- </if>
- </select>
- <select id="cbltj" resultType="com.tofly.feesapi.cbgl.entity.vo.CbltjSelect">
- <if test="filter.tjlb=='cbry'">
- SELECT
- b.CBY AS tjlb,
- COUNT(1) AS ycbs,
- SUM(CASE WHEN a.cbbz = '1' THEN 1 ELSE 0 END) AS scbs,
- SUM(CASE WHEN a.cbbz = '1' THEN sl ELSE 0 END) AS scsl
- FROM
- YY_CBLR a
- LEFT JOIN BM_CBB b ON a.sscbb = b.cbbbm
- WHERE a.jfzt = '1' and a.xycb=1
- <if test="filter.ssgs!=null">
- AND a.ssgs = #{filter.ssgs}
- </if>
- <if test="filter.sscbpq!=null">
- AND a.sscbpq = #{filter.sscbpq}
- </if>
- <if test="filter.sscbb!=null">
- <choose>
- <when test="filter.sscbb.indexOf(',')!=-1">
- AND a.sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND a.sscbb=#{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- GROUP BY
- b.CBY
- </if>
- <if test="filter.tjlb=='cbb'">
- SELECT
- b.cby AS cby,
- b.cbbmc AS tjlb,
- COUNT(1) AS ycbs,
- SUM(CASE WHEN a.cbbz = '1' THEN 1 ELSE 0 END) AS scbs,
- SUM(CASE WHEN a.cbbz = '1' THEN sl ELSE 0 END) AS scsl
- FROM
- YY_CBLR a
- LEFT JOIN BM_CBB b ON a.sscbb = b.cbbbm
- WHERE a.jfzt = '1' and a.xycb=1
- <if test="filter.ssgs!=null">
- AND a.ssgs = #{filter.ssgs}
- </if>
- <if test="filter.sscbpq!=null">
- AND a.sscbpq = #{filter.sscbpq}
- </if>
- <if test="filter.sscbb!=null">
- <choose>
- <when test="filter.sscbb.indexOf(',')!=-1">
- AND a.sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND a.sscbb=#{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- GROUP BY b.cbbmc, b.cby
- order by b.cby asc, b.cbbmc asc
- </if>
- </select>
- <select id="getZfCblrMap" resultType="java.util.Map">
- SELECT COUNT(0) FBS,
- NVL(SUM(CASE WHEN CBBZ = 1 and SHBZ = 1 THEN 1 ELSE 0 END), 0) FBYCS,
- NVL(SUM(SL), 0) FBHJSL
- FROM YY_CBLR a
- WHERE exists(select 1
- from yh_bjfl_fb fb
- left join yh_bjfl_zb zb on fb.zb_id = zb.id
- where <![CDATA[ fb.zb_id <> fb.id ]]> and zb.type_id = '1'
- and zb.isdisabled = '1'
- and (fb.yhbh || fb.cbkh) = a.cbkid
- and (zb.yhbh || zb.cbkh) = #{cbkid})
- </select>
- <select id="getZmCblrMap" resultType="java.util.Map">
- SELECT COUNT(0) ZBS,
- NVL(SUM(CASE WHEN CBBZ = 1 and SHBZ = 1 THEN 1 ELSE 0 END), 0) ZBYCS,
- NVL(SUM(SL), 0) ZBHJSL
- FROM YY_CBLR a
- WHERE exists(select 1
- from yh_bjfl_fb fb
- left join yh_bjfl_zb zb on fb.zb_id = zb.id
- where <![CDATA[ fb.zb_id <> fb.id ]]> and zb.type_id = '2'
- and zb.isdisabled = '1'
- and (fb.yhbh || fb.cbkh) = a.cbkid
- and (zb.yhbh || zb.cbkh) = #{cbkid})
- </select>
- <insert id="YMJZSFSB">
- INSERT INTO YY_CBLR_YMJZSFSB
- SELECT *
- FROM YY_CBLR
- WHERE CBBZ = '1'
- AND SHBZ = '1'
- AND JSBZ = '0'
- </insert>
- <insert id="yyCblrls">
- insert into yy_cblr_ls(ID, YHBH, CBKH, CBKID, SSGS,
- SSCBPQ, SSCBB, CWRQ, SCDS, BCDS,
- JJL, CBRYBM, CBRYXM, CBRQ, LRRYBM,
- LRRYXM, LRRQ, PHOTO, CBBZ, SHBZ, JSBZ,
- CBCS, CBXH, BZ, CBLX, CBFS, JFZT, SL,
- JBZD, XBQD, JBBH, CBLY, X, Y,
- SHRY, SHSJ, SHSM, SSREGION, SHRYXM,
- NBZXDS, NBZXCBRQ, JSSL, SBZT, xycb,
- QYFZRBM, QYFZRXM,SCCBRQ)
- select sys_guid(),
- YHBH,
- CBKH,
- CBKID,
- a.SSGS,
- a.SSCBPQ,
- a.SSCBB,
- CWRQ,
- SCDS,
- BCDS,
- JJL,
- CBRYBM,
- CBRYXM,
- CBRQ,
- LRRYBM,
- LRRYXM,
- LRRQ,
- PHOTO,
- CBBZ,
- SHBZ,
- JSBZ,
- CBCS,
- CBXH,
- a.BZ,
- CBLX,
- CBFS,
- JFZT,
- SL,
- JBZD,
- XBQD,
- JBBH,
- CBLY,
- X,
- Y,
- SHRY,
- SHSJ,
- SHSM,
- SSREGION,
- SHRYXM,
- NBZXDS,
- NBZXCBRQ,
- JSSL,
- SBZT,
- xycb,
- b.qyfzr,
- b.qyfzrxm,
- SCCBRQ
- from yy_cblr a
- left join bm_cbb b on a.sscbb = b.cbbbm
- where a.ssgs = '1'
- </insert>
- <sql id="cblrcxsql">
- SELECT a.shryxm AS shryxm,
- a.yhbh AS yhbh,
- a.cbkh AS cbkh,
- a.cbkid AS cbkid,
- a.ssgs AS ssgs,
- a.sscbpq AS sscbpq,
- a.sscbb AS sscbb,
- a.cwrq AS cwrq,
- a.scds AS scds,
- a.bcds AS bcds,
- a.jjl AS jjl,
- a.cbrybm AS cbrybm,
- a.cbryxm AS cbryxm,
- a.cbrq AS cbrq,
- a.lrrybm AS lrrybm,
- a.lrryxm AS lrryxm,
- a.lrrq AS lrrq,
- a.photo AS photo,
- a.cbbz AS cbbz,
- a.shbz AS shbz,
- a.jsbz AS jsbz,
- a.cbcs AS cbcs,
- a.cbxh AS cbxh,
- a.bz AS bz,
- a.cblx AS cblx,
- a.cbfs AS cbfs,
- a.jfzt AS jfzt,
- a.sl AS sl,
- a.jbzd AS jbzd,
- a.xbqd AS xbqd,
- a.jbbh AS jbbh,
- a.cbly AS cbly,
- a.x AS x,
- a.y AS y,
- a.shry AS shry,
- a.shsj AS shsj,
- a.shsm AS shsm,
- a.ssregion AS ssregion,
- a.nbzxds AS nbzxds,
- a.nbzxcbrq AS nbzxcbrq,
- a.jssl AS jssl,
- a.sbzt AS sbzt,
- b.qyfzr AS qyfzrbm,
- b.qyfzrxm AS qyfzrxm
- FROM yy_cblr a
- LEFT JOIN
- bm_cbb b ON a.sscbb = b.cbbbm
- WHERE a.ssgs = '1'
- </sql>
- <select id="plcxcblrmx" resultType="com.tofly.feesapi.cbgl.entity.YyCblrLs">
- <include refid="cblrcxsql"></include>
- </select>
- <select id="cxcblrmx" resultType="com.tofly.feesapi.cbgl.entity.YyCblrLs">
- <include refid="cblrcxsql"></include>
- </select>
- <update id="updateCbb">
- UPDATE (
- SELECT SBZD,
- ZXCBRQ,
- BCDS,
- CBRQ
- FROM YY_CBLR A,
- YH_CBKXX B
- WHERE A.YHBH = B.YHBH
- AND A.CBKH = B.CBKH )
- SET
- SBZD = BCDS, ZXCBRQ = CBRQ
- </update>
- <select id="getListCbmx" resultType="com.tofly.feesapi.cbgl.entity.vo.YyCblrSelect">
- <include refid="querySql"></include>
- UNION ALL
- <include refid="querySql1"></include>
- </select>
- <select id="getCbkids" resultType="java.lang.String">
- SELECT a.cbkid
- FROM yy_cblr a
- LEFT JOIN bm_cbfs b on a.cbfs = b.code
- LEFT JOIN bm_cblx c on a.cblx = c.code
- LEFT JOIN yh_khjbxx d on a.yhbh = d.yhbh
- LEFT JOIN yh_cbkxx e on a.yhbh = e.yhbh and a.cbkh=e.cbkh
- WHERE 1=1 and e.jfzt=1
- <!--模糊查询 -->
- <if test="filter.searchText!=null">
- AND ( a.yhbh like '%${filter.searchText}%'
- OR d.yhxm like '%${filter.searchText}%'
- OR d.yhdz like '%${filter.searchText}%'
- OR d.lxdh like '${filter.searchText}%'
- )
- </if>
- <!--所属公司-->
- <if test="filter.ssgs!=null">
- AND d.ssgs=#{filter.ssgs}
- </if>
- <!--所属片区-->
- <if test="filter.sscbpq!=null">
- AND d.sscbpq=#{filter.sscbpq}
- </if>
- <!--所属抄表本-->
- <if test="filter.sscbb!=null">
- <choose>
- <when test="filter.sscbb.indexOf(',')!=-1">
- AND d.sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND d.sscbb=#{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- <if test="filter.shbz!=null">
- AND a.shbz=#{filter.shbz}
- </if>
- <!-- 抄表方式-->
- <if test="filter.cbfs!=null">
- AND a.cbfs=#{filter.cbfs}
- </if>
- <!-- 用水性质(水价编码)-->
- <if test="filter.ysxz!=null">
- AND (e.sjbm in (select code from bm_sj where yslx=#{filter.ysxz})
- OR e.sjbm1 in (select code from bm_sj where yslx=#{filter.ysxz})
- OR e.sjbm2 in (select code from bm_sj where yslx=#{filter.ysxz})
- OR e.sjbm3 in (select code from bm_sj where yslx=#{filter.ysxz})
- )
- </if>
- <!-- 水表口径编码-->
- <if test="filter.sbkj!=null">
- AND e.sbkj=#{filter.sbkj}
- </if>
- <!-- 抄表人员编码-->
- <if test="filter.cbrybm!=null">
- AND a.cbrybm=#{filter.cbrybm}
- </if>
- <!-- 财务日期-->
- <if test="filter.cwrq!=null">
- AND a.cwrq=#{filter.cwrq}
- </if>
- <!-- 录入日期-->
- <if test="filter.lrrqStart!=null and filter.lrrqEnd!=null">
- AND a.lrrq BETWEEN #{filter.lrrqStart} AND #{filter.lrrqEnd}
- </if>
- <if test="filter.kssl!=null and filter.jssl!=null">
- AND a.sl BETWEEN #{filter.kssl} AND #{filter.jssl}
- </if>
- </select>
- <select id="stat" resultType="com.tofly.feesapi.sfgl.entity.vo.YyStat">
- select sum(sl) sl from(
- select nvl(sl, 0) sl
- from yy_cblr
- where yhbh = #{filter.yhbh}
- <if test="filter.ssgs!=null">
- and ssgs = #{filter.ssgs}
- </if>
- union all
- select nvl(sl, 0) sl
- from yy_cblr_ls
- where yhbh = #{filter.yhbh}
- <if test="filter.ssgs!=null">
- and ssgs = #{filter.ssgs}
- </if>
- ) a
- </select>
- <select id="getZbFbs" resultType="java.util.Map">
- select (a.yhbh || a.cbkh) cbkid, count(1) num
- from yh_bjfl_zb a
- left join yh_bjfl_fb b on a.id = b.zb_id
- left join yy_cblr c on a.yhbh = c.yhbh and a.cbkh = c.cbkh
- where <![CDATA[ b.zb_id <> b.id ]]> and a.isdisabled = '1'
- and c.sl > 0
- group by a.yhbh, a.cbkh
- </select>
- <select id="zcbcszsltj" resultType="com.tofly.feesapi.cbgl.entity.dto.ZcbcssltjDto">
- SELECT
- COUNT(*) AS zcbcs,
- SUM(sl) AS zcbsl
- FROM (
- SELECT
- NVL( a.SL, 0 ) AS sl
- FROM
- yy_cblr a
- LEFT JOIN yh_khjbxx d ON a.yhbh = d.yhbh
- WHERE
- a.SHBZ = '1'
- <if test="filter.ssgs != null and filter.ssgs != ''">
- AND a.ssgs = #{filter.ssgs}
- </if>
- <if test="filter.sscbpq != null and filter.sscbpq != ''">
- AND a.sscbpq = #{filter.sscbpq}
- </if>
- <if test="filter.sscbb != null and filter.sscbb != ''">
- AND a.sscbb = #{filter.sscbb}
- </if>
- <if test="filter.searchText != null and filter.searchText != ''">
- AND ( a.yhbh like '%${filter.searchText}%'
- OR d.yhxm like '%${filter.searchText}%'
- OR d.yhdz like '%${filter.searchText}%'
- OR d.lxdh like '${filter.searchText}%'
- )
- </if>
- <if test="filter.cwrqStart != null and filter.cwrqEnd != null">
- AND a.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
- </if>
- UNION ALL
- SELECT
- NVL( ls.SL, 0 ) AS sl
- FROM
- yy_cblr_ls ls
- LEFT JOIN yh_khjbxx d ON ls.yhbh = d.yhbh
- WHERE
- ls.SHBZ = '1'
- <if test="filter.ssgs != null and filter.ssgs != ''">
- AND ls.ssgs = #{filter.ssgs}
- </if>
- <if test="filter.sscbpq != null and filter.sscbpq != ''">
- AND ls.sscbpq = #{filter.sscbpq}
- </if>
- <if test="filter.sscbb != null and filter.sscbb != ''">
- AND ls.sscbb = #{filter.sscbb}
- </if>
- <if test="filter.searchText != null and filter.searchText != ''">
- AND ( ls.yhbh like '%${filter.searchText}%'
- OR d.yhxm like '%${filter.searchText}%'
- OR d.yhdz like '%${filter.searchText}%'
- OR d.lxdh like '${filter.searchText}%'
- )
- </if>
- <if test="filter.cwrqStart != null and filter.cwrqEnd != null">
- AND ls.cwrq BETWEEN #{filter.cwrqStart} AND #{filter.cwrqEnd}
- </if>
- )
- </select>
- <select id="getCblrSl" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrSflxMxSelect">
- select e.code,e.name,nvl(sum(sl),0) sl
- from yy_cblr a left join yh_cbkxx b on a.cbkid=b.cbkid
- left join bm_sj c on b.sjbm=c.code
- left join bm_yslx e on c.yslx=e.code
- where a.cbbz=1
- <if test="filter.yslx!=null">
- and e.code=#{filter.yslx}
- </if>
- <if test="filter.cwrq!=null">
- and a.cwrq=#{filter.cwrq}
- </if>
- group by e.code,e.name
- </select>
- <select id="getCblrSlLs" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrSflxMxSelect">
- 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
- left join bm_sj c on b.sjbm=c.code
- left join bm_yslx e on c.yslx=e.code
- where a.cbbz=1
- <if test="filter.yslx!=null">
- and e.code=#{filter.yslx}
- </if>
- <if test="filter.cwrq!=null">
- and a.cwrq=#{filter.cwrq}
- </if>
- group by e.code,e.name
- </select>
- <select id="retportSlfx" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrSflxMxSelect">
- select a.code,sum(sl) sl from bm_yslx a
- left join (
- select a.*,c.yslx from (
- select yhbh,cbkid,cwrq,sl,sscbpq from yy_cblr_ls where cbbz=1
- union
- select yhbh,cbkid,cwrq,sl,sscbpq from yy_cblr where cbbz=1
- ) a left join yh_cbkxx b on a.cbkid=b.cbkid
- left join bm_sj c on b.sjbm=c.code
- left join yh_khjbxx e on b.yhbh=e.yhbh and e.yhzt='1'
- ) aa on a.code=aa.yslx
- where
- 1=1
- <if test="filter.cwrq!=null and filter.cwrqend!=null ">
- and (aa.cwrq) between #{filter.cwrq} and #{filter.cwrqend}
- </if>
- <if test="filter.sspq!=null and filter.sspq!=null ">
- and aa.sscbpq=#{filter.sspq}
- </if>
- group by a.code
- order by code asc
- </select>
- <select id="retportSlfxMx" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrSflxSelect">
- 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)
- sndsl,(a.sl-nvl(f.sl,0))/nvl(f.sl,1)*100 hbbl from (
- select yhbh,sl,cwrq,cbkid from yy_cblr
- union all
- select yhbh, sl,cwrq,cbkid from yy_cblr_ls
- ) a left join yh_khjbxx b on a.yhbh=b.yhbh
- left join yh_cbkxx c on a.cbkid=c.cbkid
- <if test="cwrq1!=null and cwrq1!=null">
- left join yy_cblr_ls e on a.cwrq=#{cwrq1} and e.cbkid=a.cbkid
- </if>
- <if test="cwrq2!=null and cwrq2!=null">
- left join yy_cblr_ls f on a.cwrq=#{cwrq2} and e.cbkid=a.cbkid
- </if>
- where 1=1
- <if test="filter.cwrq!=null">
- and a.cwrq=#{filter.cwrq}
- </if>
- <if test="filter.sspq!=null">
- and b.sscbpq=#{filter.sspq}
- </if>
- <if test="filter.sscbb!=null">
- <choose>
- <when test="filter.sscbb.indexOf(',')!=-1">
- AND b.sscbb in
- <foreach item="item" index="index" collection="filter.sscbb.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- AND b.sscbb=#{filter.sscbb}
- </otherwise>
- </choose>
- </if>
- <if test="filter.yslx!=null">
- and c.sjbm=#{filter.yslx}
- </if>
- <if test="filter.yhlx!=null">
- and b.dxh=#{filter.yhlx}
- </if>
- <if test="filter.bl!=null">
- and (a.sl-nvl(e.sl,0))/nvl(e.sl,1)*100>#{filter.bl}
- </if>
- </select>
- <select id="retportSlfxMxByYhbh" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrSflxYhbhSelect">
- select yhbh,sl,cwrq from ${tbName}
- where 1=1
- <if test="filter.cwrq!=null and filter.cwrq!=null">
- and cwrq=#{filter.cwrq}
- </if>
- <if test="filter.yhbh!=null and filter.yhbh!=null">
- and yhbh=#{filter.yhbh}
- </if>
- </select>
- <select id="getCblrCount" resultType="com.tofly.feesapi.cbgl.entity.vo.CblrCountSelect">
- SELECT sum(nvl(sl,0)) zysl,sum(nvl(scds,0)) zyscds,sum(nvl(bcds,0)) zybcds
- FROM ( -- 合并当前表和历史表
- SELECT 'current' as table_source,
- yhbh,
- cbkh,
- cbkid,
- scds,
- bcds,
- jjl,
- sl,
- cbfs,
- cbbz,
- shbz,
- jsbz,
- cblx,
- jbzd,
- xbqd,
- jbbh,
- cbrq,
- lrrq,
- photo,
- bz,
- cbrybm,
- cbryxm,
- cbxh,
- cwrq,
- sscbb,
- sbzt,
- lrrybm,
- lrryxm,
- cbcs
- FROM yy_cblr
- UNION ALL
- SELECT 'history' as table_source,
- yhbh,
- cbkh,
- cbkid,
- scds,
- bcds,
- jjl,
- sl,
- cbfs,
- cbbz,
- shbz,
- jsbz,
- cblx,
- jbzd,
- xbqd,
- jbbh,
- cbrq,
- lrrq,
- photo,
- bz,
- cbrybm,
- cbryxm,
- cbxh,
- cwrq,
- sscbb,
- sbzt,
- lrrybm,
- lrryxm,
- cbcs
- FROM yy_cblr_ls) a
- LEFT JOIN bm_cbfs b ON a.cbfs = b.code
- LEFT JOIN bm_cblx c ON a.cblx = c.code
- LEFT JOIN yh_khjbxx d ON a.yhbh = d.yhbh
- -- 根据数据来源动态连接不同的表
- LEFT JOIN yh_cbkxx e ON a.cbkid = e.cbkid AND a.table_source = 'current'
- LEFT JOIN yh_cbkxx ls_e ON a.yhbh = ls_e.yhbh AND a.cbkh = ls_e.cbkh AND a.table_source = 'history'
- LEFT JOIN sys_child_code f ON a.sbzt = f.cccode AND f.pcid = '34'
- LEFT JOIN bm_cbb g ON d.sscbb = g.cbbbm
- <include refid="querySqlWhere2"></include>
- </select>
- </mapper>
|