|
|
@@ -0,0 +1,2106 @@
|
|
|
+<?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.linkwechat.coal.modules.xxxt.renewal.mapper.QwSqlScriptMapper">
|
|
|
+
|
|
|
+ <select id="selectBjjl" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.BjjlVo">
|
|
|
+ select distinct
|
|
|
+ a.proposalno proposalno,
|
|
|
+ a.inputdate,
|
|
|
+ f.underwriteind,
|
|
|
+ a.appliname appliname,
|
|
|
+ a.inputdate operatedate,
|
|
|
+ nvl(jqSuminsured,0) jqSuminsured,
|
|
|
+ nvl(jqSumgrosspremium,0) jqSumgrosspremium,
|
|
|
+ nvl(sySuminsured,0) sySuminsured,
|
|
|
+ nvl(sySumgrosspremium,0) sySumgrosspremium,
|
|
|
+ f.operatorcode,
|
|
|
+ #{lisenseno} as lisenseno,
|
|
|
+ nvl(tax.sumpaytax,0) sumpaytax,
|
|
|
+ (nvl(tax.sumpaytax,0)+nvl(jqSumgrosspremium,0)+nvl(sySumgrosspremium,0)) sumgrosspremium
|
|
|
+ from guproposalmain@${dblink} a
|
|
|
+ left join (select max(proposalno) proposalno,
|
|
|
+ max(case when riskcode = '0330' then
|
|
|
+ SUMINSURED
|
|
|
+ end) jqSuminsured,
|
|
|
+ max(case when riskcode = '0330' then
|
|
|
+ b.SUMGROSSPREMIUM
|
|
|
+ end) jqSumgrosspremium,
|
|
|
+ max(case when riskcode like '036%' then
|
|
|
+ SUMINSURED
|
|
|
+ end) sySuminsured,
|
|
|
+ max(case when riskcode like '036%' then
|
|
|
+ b.SUMGROSSPREMIUM
|
|
|
+ end) sySumgrosspremium
|
|
|
+ from guproposalrisk@${dblink} b
|
|
|
+ where exists (select 1
|
|
|
+ from guproposalitemmotor@${dblink} t
|
|
|
+ where b.proposalno = t.proposalno
|
|
|
+ and t.licenseno = #{lisenseno})
|
|
|
+ group by b.proposalno) c
|
|
|
+ on c.proposalno = a.proposalno
|
|
|
+ left join guproposalitemmotor@${dblink} d
|
|
|
+ on a.proposalno = d.proposalno
|
|
|
+ left join QW_RENEWAL_FRAMENO_LIST e
|
|
|
+ on e.lisenseno = d.licenseno
|
|
|
+ LEFT JOIN guproposalmain@${dblink} f
|
|
|
+ on a.proposalno = f.proposalno
|
|
|
+ left join guproposalcarshiptax@${dblink} tax
|
|
|
+ on a.proposalno = tax.proposalno
|
|
|
+ where a.wechatopenid like '%'||#{phone}||'%'
|
|
|
+ and trunc(a.inputdate)
|
|
|
+ between
|
|
|
+ (trunc(LEAST(NVL(e.OLDSYENDDATE, e.OLDJQENDDATE), e.OLDJQENDDATE)) - 60)
|
|
|
+ AND
|
|
|
+ (trunc(greatest(NVL(e.OLDSYENDDATE, e.OLDJQENDDATE), e.OLDJQENDDATE)) + 10) --原保单终保时间前60天到终保时间范围内的报价记录
|
|
|
+ AND d.licenseno = #{lisenseno}
|
|
|
+
|
|
|
+ order by a.inputdate desc
|
|
|
+ </select>
|
|
|
+ <select id="selectSyxRisk" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.HisInsureVo$SyxRisk">
|
|
|
+ SELECT
|
|
|
+ a.kindcode,
|
|
|
+ b.kindcname kindcname,
|
|
|
+ sum(a.notaxpremium) notaxpremium,
|
|
|
+ sum(a.amount) amount
|
|
|
+ FROM mid_cb_premium_kind_all@dblink_statdw a
|
|
|
+ left join cd_kind0616@dblink_statdw b
|
|
|
+ on a.riskcode = b.riskcode
|
|
|
+ and a.kindcode = b.kindcode
|
|
|
+ WHERE a.policyno = #{sypolicyno}
|
|
|
+ group by a.kindcode,b.kindcname
|
|
|
+ order by a.kindcode
|
|
|
+ </select>
|
|
|
+ <select id="selectSumSyx" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.HisInsureVo$Syx">
|
|
|
+ select
|
|
|
+ aa.policyno ,
|
|
|
+ aa.premium ,
|
|
|
+ bb.discount ,
|
|
|
+ bb.ncdfactor ,
|
|
|
+ bb.ClaimAdjust as claimAdjust
|
|
|
+ from
|
|
|
+ (SELECT a.policyno ,
|
|
|
+ sum(a.premium) premium
|
|
|
+ FROM mid_cb_premium_kind_all@dblink_statdw a
|
|
|
+ WHERE a.policyno = #{sypolicyno}
|
|
|
+ group by a.policyno) aa
|
|
|
+ left join
|
|
|
+ (SELECT distinct a.policyno ,
|
|
|
+ a.discount ,--建议折扣率
|
|
|
+ a.ncdfactor ,--无赔优调整系数
|
|
|
+ b.ClaimAdjust --交通违法调整系数
|
|
|
+ FROM mid_cb_premium_kind_all@dblink_statdw a
|
|
|
+ left join (select subpolicyno, rate / 100 as ClaimAdjust
|
|
|
+ from ODS.ODS_gupolicyriskprofit@dblink_statdw
|
|
|
+ where profitcode in ('C09', 'G09')) b
|
|
|
+ on a.policyno = b.subpolicyno
|
|
|
+ WHERE a.policyno = #{sypolicyno})bb
|
|
|
+ on bb.policyno=aa.policyno
|
|
|
+ </select>
|
|
|
+ <select id="selectSumJqx" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.HisInsureVo$Jqx">
|
|
|
+ select
|
|
|
+ aa.policyno policyno,
|
|
|
+ aa.premium premium,
|
|
|
+ aa.amount amount,
|
|
|
+ bb.SUMPAYTAX sumpaytax
|
|
|
+ from ( SELECT policyno, sum(a.premium) premium, sum(a.amount) amount
|
|
|
+ FROM mid_cb_premium_kind_all@dblink_statdw a
|
|
|
+ WHERE a.policyno = #{jqpolicyno}
|
|
|
+ group by policyno) aa
|
|
|
+ left join (select subpolicyno policyno, sum(nvl(SUMPAYTAX, 0)) SUMPAYTAX
|
|
|
+ from ods.ODS_GUPOLICYCOPYCARSHIPTAX@dblink_statdw
|
|
|
+ where subpolicyno = #{jqpolicyno}
|
|
|
+ group by subpolicyno) bb
|
|
|
+ on bb.policyno = aa.policyno
|
|
|
+ </select>
|
|
|
+ <select id="selectClaim" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.HisClaimVo">
|
|
|
+ SELECT
|
|
|
+ a.policyno,
|
|
|
+ a.registno registno,
|
|
|
+ a.claimno claimno,
|
|
|
+ a.damagedate damagedate,
|
|
|
+ a.claimdate claimdate,
|
|
|
+ dam.name name,
|
|
|
+ a.damageaddress damageaddress,
|
|
|
+ decode(c.injuredflag, '1', '是', '否') injuredflag,
|
|
|
+ decode(a.REPLACEREPAYFLAG, '1', '是', '否') replacerepayflag,
|
|
|
+ case
|
|
|
+ when b.endcaseflag = '4' then
|
|
|
+ '是'
|
|
|
+ else
|
|
|
+ '否'
|
|
|
+ end endcaseflag,
|
|
|
+ decode(a.ZEROENDFLAG, '1', '是', '否') zeroendflag,
|
|
|
+ b.endcasedate as endcasedate,
|
|
|
+ case
|
|
|
+ when b.claimno is null then
|
|
|
+ '未结案'
|
|
|
+ else
|
|
|
+ '已结案'
|
|
|
+ end as claimstatus,
|
|
|
+ c.sumpaid as sumpaid,
|
|
|
+ decode(a.policyno, NVL(#{oldjqpolicyno, jdbcType=VARCHAR},''), '交强险',NVL(#{oldsypolicyno, jdbcType=VARCHAR},''), '商业险', '' ) policynoType
|
|
|
+ FROM mid_lp_newclaim_dim_car@dblink_statdw a
|
|
|
+ left join mid_lp_endcase_all@dblink_statdw b
|
|
|
+ on a.claimno = b.claimno
|
|
|
+ and b.endcaseflag not in ('2', '5')
|
|
|
+ left join (SELECT loss.claimno,
|
|
|
+ sum(nvl(loss.injuredflag, 0)) injuredflag,
|
|
|
+ sum(sumpaid) sumpaid
|
|
|
+ FROM mid_lp_settleloss_risk_all@dblink_statdw loss
|
|
|
+ group by loss.claimno) c
|
|
|
+ on a.claimno = c.claimno
|
|
|
+ left join
|
|
|
+ (select cxyy.codecode as id,
|
|
|
+ cxyy.codecname as name
|
|
|
+ from bistat.cd_ggcode@dblink_statdw cxyy
|
|
|
+ WHERE CODETYPE = 'DamageCode'
|
|
|
+ ) dam
|
|
|
+ on a.damagereason=dam.id
|
|
|
+ WHERE a.policyno in(#{oldjqpolicyno, jdbcType=VARCHAR}, #{oldsypolicyno, jdbcType=VARCHAR})
|
|
|
+ </select>
|
|
|
+ <select id="carCount" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.CarCountVo">
|
|
|
+ SELECT t.comcode,
|
|
|
+ (SELECT a.comcname FROM SaCompany@dblink_sales a where a.comcode=t.comcode) as comcname,
|
|
|
+ sum(t.day_ying) day_ying, sum(t.day_yi)day_yi,(sum(t.day_lv) || '%') day_lv,
|
|
|
+ sum(t.month_ying)month_ying, sum(t.month_yi)month_yi,(sum(t.month_lv) || '%')month_lv,
|
|
|
+ sum(t.year_ying)year_ying, sum(t.year_yi)year_yi,(sum(t.year_lv) || '%')year_lv
|
|
|
+ FROM (
|
|
|
+ -- 昨日
|
|
|
+ SELECT aaa.comcode,
|
|
|
+ sum(aaa.ying) day_ying,
|
|
|
+ sum(aaa.yi) day_yi,
|
|
|
+ DECODE(sum(aaa.ying),
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ (ROUND(sum(aaa.yi) / sum(aaa.ying), 4) * 100)) as day_lv,
|
|
|
+ 0 month_ying,
|
|
|
+ 0 month_yi,
|
|
|
+ 0 month_lv,
|
|
|
+ 0 year_ying,
|
|
|
+ 0 year_yi,
|
|
|
+ 0 year_lv
|
|
|
+ FROM (SELECT substr(a.comcode, 1, 4) comcode, count(1) ying, 0 as yi -- 应续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy-MM-dd') = TO_CHAR(sysdate-1, 'yyyy-MM-dd')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy-MM-dd') = TO_CHAR(sysdate-1, 'yyyy-MM-dd')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+ union all
|
|
|
+ SELECT substr(a.comcode, 1, 4) comcode, 0, count(1) yi -- 已续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy-MM-dd') = TO_CHAR(sysdate-1, 'yyyy-MM-dd')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy-MM-dd') = TO_CHAR(sysdate-1, 'yyyy-MM-dd')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)
|
|
|
+ group by substr(a.comcode, 1, 4)) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+ union all
|
|
|
+ -- 本月
|
|
|
+ SELECT aaa.comcode,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ sum(aaa.ying) ying,
|
|
|
+ sum(aaa.yi) yi,
|
|
|
+ DECODE(sum(aaa.ying),
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ (ROUND(sum(aaa.yi) / sum(aaa.ying), 4) * 100)),
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0
|
|
|
+ FROM (SELECT substr(a.comcode, 1, 4) comcode, count(1) ying, 0 as yi -- 应续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy-MM') = TO_CHAR(sysdate, 'yyyy-MM')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy-MM') = TO_CHAR(sysdate, 'yyyy-MM')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+ union all
|
|
|
+ SELECT substr(a.comcode, 1, 4) comcode, 0, count(1) yi -- 已续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy-MM') = TO_CHAR(sysdate, 'yyyy-MM')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy-MM') = TO_CHAR(sysdate, 'yyyy-MM')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)
|
|
|
+ group by substr(a.comcode, 1, 4)) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+ union all
|
|
|
+ -- 本年
|
|
|
+ SELECT aaa.comcode,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ sum(aaa.ying) ying,
|
|
|
+ sum(aaa.yi) yi,
|
|
|
+ DECODE(sum(aaa.ying),
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ (ROUND(sum(aaa.yi) / sum(aaa.ying), 4) * 100))
|
|
|
+ FROM (SELECT substr(a.comcode, 1, 4) comcode, count(1) ying, 0 as yi -- 应续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy') = TO_CHAR(sysdate, 'yyyy')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy') = TO_CHAR(sysdate, 'yyyy')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+ union all
|
|
|
+ SELECT substr(a.comcode, 1, 4) comcode, 0, count(1) yi -- 已续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy') = TO_CHAR(sysdate, 'yyyy')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy') = TO_CHAR(sysdate, 'yyyy')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)
|
|
|
+ group by substr(a.comcode, 1, 4)) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+
|
|
|
+ <if test="comcodeLength == 2">
|
|
|
+ union all
|
|
|
+ -- 昨日
|
|
|
+ SELECT aaa.comcode,
|
|
|
+ sum(aaa.ying) day_ying,
|
|
|
+ sum(aaa.yi) day_yi,
|
|
|
+ DECODE(sum(aaa.ying),
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ (ROUND(sum(aaa.yi) / sum(aaa.ying), 4) * 100)) as day_lv,
|
|
|
+ 0 month_ying,
|
|
|
+ 0 month_yi,
|
|
|
+ 0 month_lv,
|
|
|
+ 0 year_ying,
|
|
|
+ 0 year_yi,
|
|
|
+ 0 year_lv
|
|
|
+ FROM (SELECT substr(a.comcode, 1, 2) comcode, count(1) ying, 0 as yi -- 应续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy-MM-dd') = TO_CHAR(sysdate-1, 'yyyy-MM-dd')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy-MM-dd') = TO_CHAR(sysdate-1, 'yyyy-MM-dd')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+ union all
|
|
|
+ SELECT substr(a.comcode, 1, 2) comcode, 0, count(1) yi -- 已续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy-MM-dd') = TO_CHAR(sysdate-1, 'yyyy-MM-dd')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy-MM-dd') = TO_CHAR(sysdate-1, 'yyyy-MM-dd')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)
|
|
|
+ group by substr(a.comcode, 1, 2)) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+ union all
|
|
|
+ -- 本月
|
|
|
+ SELECT aaa.comcode,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ sum(aaa.ying) ying,
|
|
|
+ sum(aaa.yi) yi,
|
|
|
+ DECODE(sum(aaa.ying),
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ (ROUND(sum(aaa.yi) / sum(aaa.ying), 4) * 100)),
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0
|
|
|
+ FROM (SELECT substr(a.comcode, 1, 2) comcode, count(1) ying, 0 as yi -- 应续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy-MM') = TO_CHAR(sysdate, 'yyyy-MM')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy-MM') = TO_CHAR(sysdate, 'yyyy-MM')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+ union all
|
|
|
+ SELECT substr(a.comcode, 1, 2) comcode, 0, count(1) yi -- 已续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy-MM') = TO_CHAR(sysdate, 'yyyy-MM')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy-MM') = TO_CHAR(sysdate, 'yyyy-MM')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)
|
|
|
+ group by substr(a.comcode, 1, 2)) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+ union all
|
|
|
+ -- 本年
|
|
|
+ SELECT aaa.comcode,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ sum(aaa.ying) ying,
|
|
|
+ sum(aaa.yi) yi,
|
|
|
+ DECODE(sum(aaa.ying),
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ (ROUND(sum(aaa.yi) / sum(aaa.ying), 4) * 100))
|
|
|
+ FROM (SELECT substr(a.comcode, 1, 2) comcode, count(1) ying, 0 as yi -- 应续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy') = TO_CHAR(sysdate, 'yyyy')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy') = TO_CHAR(sysdate, 'yyyy')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+ union all
|
|
|
+ SELECT substr(a.comcode, 1, 2) comcode, 0, count(1) yi -- 已续保数量
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where (
|
|
|
+ TO_CHAR(trunc(a.oldjqenddate), 'yyyy') = TO_CHAR(sysdate, 'yyyy')
|
|
|
+ or TO_CHAR(trunc(a.oldsyenddate), 'yyyy') = TO_CHAR(sysdate, 'yyyy')
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)
|
|
|
+ group by substr(a.comcode, 1, 2)) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+ </if>
|
|
|
+
|
|
|
+ ) t where t.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{comcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ <if test="dfComcode != null and dfComcode !=''">
|
|
|
+ AND t.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{dfComcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and t.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ group by t.comcode
|
|
|
+ order by t.comcode
|
|
|
+ </select>
|
|
|
+ <select id="renewalLv" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.RenewalLvVo">
|
|
|
+ SELECT t.comcode,
|
|
|
+ (SELECT a.comcname FROM SaCompany@dblink_sales a where a.comcode=t.comcode) as comcname,
|
|
|
+ sum(t.ying_count) ying_count,
|
|
|
+ sum(t.yi_count) yi_count,
|
|
|
+ (DECODE(sum(t.ying_count),0, 0,(ROUND(sum(t.yi_count) / sum(t.ying_count), 4) * 100)) || '%') lv_count,
|
|
|
+ ROUND(sum(t.ying_fee), 2) ying_fee,
|
|
|
+ ROUND(sum(t.yi_fee),2) yi_fee,
|
|
|
+ (DECODE(sum(t.ying_fee),0,0,(ROUND(sum(t.yi_fee) / sum(t.ying_fee), 4) * 100))|| '%') lv_fee
|
|
|
+ FROM (
|
|
|
+ SELECT aaa.comcode,
|
|
|
+ sum(aaa.ying) ying_count,
|
|
|
+ sum(aaa.yi) yi_count,
|
|
|
+ 0 as ying_fee,
|
|
|
+ 0 yi_fee
|
|
|
+ FROM (
|
|
|
+ -- 应续保数量
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, count(1) ying, 0 as yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+
|
|
|
+ -- 已续保数量
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, 0, count(1) yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+ ) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+
|
|
|
+ union all
|
|
|
+
|
|
|
+ SELECT aaa.comcode,0,0,
|
|
|
+ sum(aaa.ying) ying,
|
|
|
+ sum(aaa.yi) yi
|
|
|
+ FROM (
|
|
|
+ -- 应续保保费(oldjqpolicyno)
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, sum(nvl(a.old_jq_newsumpre,0)) ying, 0 yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+
|
|
|
+ -- 应续保保费(oldsypolicyno)
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, sum(nvl(a.old_sy_newsumpre,0)) ying, 0 yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+
|
|
|
+ -- 已续保保费(jqpolicyno)
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, 0, sum(nvl(a.jq_newsumpre, 0)) yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and a.jqpolicyno is not null
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+
|
|
|
+ -- 已续保保费(sypolicyno)
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, 0, sum(nvl(a.sy_newsumpre, 0)) yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and a.sypolicyno is not null
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+ ) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+ <if test="comcodeLength == 2">
|
|
|
+ union all
|
|
|
+ SELECT aaa.comcode,
|
|
|
+ sum(aaa.ying) ying_count,
|
|
|
+ sum(aaa.yi) yi_count,
|
|
|
+ 0 as ying_fee,
|
|
|
+ 0 yi_fee
|
|
|
+ FROM (
|
|
|
+ -- 应续保数量
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, count(1) ying, 0 as yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+
|
|
|
+ -- 已续保数量
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, 0, count(1) yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+ ) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+
|
|
|
+ union all
|
|
|
+
|
|
|
+ SELECT aaa.comcode,0,0,
|
|
|
+ sum(aaa.ying) ying,
|
|
|
+ sum(aaa.yi) yi
|
|
|
+ FROM (
|
|
|
+ -- 应续保保费(oldjqpolicyno)
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, sum(nvl(a.old_jq_newsumpre,0)) ying, 0 yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+
|
|
|
+ -- 应续保保费(oldsypolicyno)
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, sum(nvl(a.old_sy_newsumpre,0)) ying, 0 yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+
|
|
|
+ -- 已续保保费(jqpolicyno)
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, 0, sum(nvl(a.jq_newsumpre, 0)) yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and a.jqpolicyno is not null
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+
|
|
|
+ -- 已续保保费(sypolicyno)
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, 0, sum(nvl(a.sy_newsumpre, 0)) yi
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and a.sypolicyno is not null
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+ ) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+
|
|
|
+ </if>
|
|
|
+
|
|
|
+ ) t where t.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{comcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ <if test="dfComcode != null and dfComcode !=''">
|
|
|
+ AND t.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{dfComcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and t.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ group by t.comcode
|
|
|
+ order by t.comcode
|
|
|
+ </select>
|
|
|
+ <select id="fcRenewalLv" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.RenewalLvVo">
|
|
|
+ SELECT
|
|
|
+ t.comcode,
|
|
|
+ (SELECT a.comcname FROM SaCompany@dblink_sales a where a.comcode=t.comcode) as comcname,
|
|
|
+ sum(t.ying_count) ying_count,
|
|
|
+ sum(t.yi_count) yi_count,
|
|
|
+ (to_char(DECODE(sum(t.ying_count),0, 0,(ROUND(sum(t.yi_count) / sum(t.ying_count), 4) * 100)),'FM9999999990.00') || '%') lv_count,
|
|
|
+ ROUND(sum(t.ying_fee), 2) ying_fee,
|
|
|
+ ROUND(sum(t.yi_fee),2) yi_fee,
|
|
|
+ (to_char(DECODE(sum(t.ying_fee),0,0,(ROUND(sum(t.yi_fee) / sum(t.ying_fee), 4) * 100)),'FM9999999990.00')|| '%') lv_fee
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ aaa.comcode,
|
|
|
+ sum(aaa.ying) ying_count,
|
|
|
+ sum(aaa.yi) yi_count,
|
|
|
+ 0 as ying_fee,
|
|
|
+ 0 yi_fee
|
|
|
+ FROM (
|
|
|
+ -- 应续保数量
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, count(1) ying, 0 as yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+
|
|
|
+ -- 已续保数量
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, 0, count(1) yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ and (a.POLICYNO_N is not null)
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+ ) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+
|
|
|
+ union all
|
|
|
+
|
|
|
+ SELECT
|
|
|
+ aaa.comcode,0,0,
|
|
|
+ sum(aaa.ying) ying,
|
|
|
+ sum(aaa.yi) yi
|
|
|
+ FROM (
|
|
|
+ -- 应续保保费
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, sum(nvl(a.SUMPREMIUM,0)) ying, 0 yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where
|
|
|
+ trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+
|
|
|
+ -- 已续保保费
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, 0, sum(nvl(a.SUMPREMIUM, 0)) yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where
|
|
|
+ trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ and a.POLICYNO_N is not null
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+ ) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+ <if test="comcodeLength == 2">
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ aaa.comcode,
|
|
|
+ sum(aaa.ying) ying_count,
|
|
|
+ sum(aaa.yi) yi_count,
|
|
|
+ 0 as ying_fee,
|
|
|
+ 0 yi_fee
|
|
|
+ FROM (
|
|
|
+ -- 应续保数量
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, count(1) ying, 0 as yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where
|
|
|
+ trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+ -- 已续保数量
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, 0, count(1) yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where
|
|
|
+ trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ and a.POLICYNO_N is not null
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+ ) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ aaa.comcode,0,0,
|
|
|
+ sum(aaa.ying) ying,
|
|
|
+ sum(aaa.yi) yi
|
|
|
+ FROM (
|
|
|
+ -- 应续保保费
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, sum(nvl(a.SUMPREMIUM,0)) ying, 0 yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where
|
|
|
+ trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+ -- 已续保保费
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, 0, sum(nvl(a.SUMPREMIUM, 0)) yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where
|
|
|
+ trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ and a.POLICYNO_N is not null
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+ ) aaa
|
|
|
+ group by aaa.comcode
|
|
|
+ </if>
|
|
|
+ ) t where t.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{comcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ <if test="dfComcode != null and dfComcode !=''">
|
|
|
+ AND t.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{dfComcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by t.comcode
|
|
|
+ order by t.comcode
|
|
|
+ </select>
|
|
|
+ <select id="cplanRenewalLv"
|
|
|
+ resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.CPlanRenewalLvVo">
|
|
|
+ SELECT
|
|
|
+ t.comcode,t.c_plan_code as cplancode,
|
|
|
+ nvl(t.c_plan_name, (select tt.riskcname from prpdrisk@dblink_sales tt where tt.riskcode=t.c_plan_code)) cplanname,
|
|
|
+ (SELECT a.comcname FROM SaCompany@dblink_sales a where a.comcode=t.comcode) as comcname,
|
|
|
+ sum(t.ying_count) ying_count,
|
|
|
+ sum(t.yi_count) yi_count,
|
|
|
+ (to_char(DECODE(sum(t.ying_count),0, 0,(ROUND(sum(t.yi_count) / sum(t.ying_count), 4) * 100)),'FM9999999990.00') || '%') lv_count,
|
|
|
+ ROUND(sum(t.ying_fee), 2) ying_fee,
|
|
|
+ ROUND(sum(t.yi_fee),2) yi_fee,
|
|
|
+ (to_char(DECODE(sum(t.ying_fee),0,0,(ROUND(sum(t.yi_fee) / sum(t.ying_fee), 4) * 100)),'FM9999999990.00')|| '%') lv_fee
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ aaa.comcode, aaa.c_plan_code, aaa.c_plan_name,
|
|
|
+ sum(aaa.ying) ying_count,
|
|
|
+ sum(aaa.yi) yi_count,
|
|
|
+ 0 as ying_fee,
|
|
|
+ 0 yi_fee
|
|
|
+ FROM (
|
|
|
+ -- 应续保数量
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, nvl(a.c_plan_code, a.riskcode) c_plan_code, a.c_plan_name, count(1) ying, 0 as yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ group by substr(a.comcode, 1, 4), nvl(a.c_plan_code, a.riskcode), a.c_plan_name
|
|
|
+
|
|
|
+ -- 已续保数量
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, nvl(a.c_plan_code, a.riskcode) c_plan_code, a.c_plan_name, 0, count(1) yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ and (a.POLICYNO_N is not null)
|
|
|
+ group by substr(a.comcode, 1, 4), nvl(a.c_plan_code, a.riskcode), a.c_plan_name
|
|
|
+ ) aaa
|
|
|
+ group by aaa.comcode, aaa.c_plan_code, aaa.c_plan_name
|
|
|
+
|
|
|
+ union all
|
|
|
+
|
|
|
+ SELECT
|
|
|
+ aaa.comcode, aaa.c_plan_code, aaa.c_plan_name,0,0,
|
|
|
+ sum(aaa.ying) ying,
|
|
|
+ sum(aaa.yi) yi
|
|
|
+ FROM (
|
|
|
+ -- 应续保保费
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, nvl(a.c_plan_code, a.riskcode) c_plan_code, a.c_plan_name, sum(nvl(a.SUMPREMIUM,0)) ying, 0 yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where
|
|
|
+ trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ group by substr(a.comcode, 1, 4), nvl(a.c_plan_code, a.riskcode), a.c_plan_name
|
|
|
+
|
|
|
+ -- 已续保保费
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, nvl(a.c_plan_code, a.riskcode) c_plan_code, a.c_plan_name, 0, sum(nvl(a.SUMPREMIUM, 0)) yi
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where
|
|
|
+ trunc(a.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ and a.POLICYNO_N is not null
|
|
|
+ group by substr(a.comcode, 1, 4), nvl(a.c_plan_code, a.riskcode), a.c_plan_name
|
|
|
+ ) aaa
|
|
|
+ group by aaa.comcode, aaa.c_plan_code, aaa.c_plan_name
|
|
|
+ ) t where 1=1
|
|
|
+ and t.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{comcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ <if test="dfComcode != null and dfComcode !=''">
|
|
|
+ AND t.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{dfComcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by t.comcode, t.c_plan_code, t.c_plan_name
|
|
|
+ order by t.comcode, t.c_plan_code
|
|
|
+ </select>
|
|
|
+ <select id="renewalFun" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.RenewalFunVo">
|
|
|
+ SELECT
|
|
|
+ aaa.comcode,
|
|
|
+ (SELECT a.comcname FROM SaCompany@dblink_sales a where a.comcode=aaa.comcode) as comcname,
|
|
|
+ sum(aaa.ying_lisenseno) ying_Car_Count,
|
|
|
+ sum(aaa.send_count)send_count,
|
|
|
+ sum(aaa.genjin_count)genjin_count,
|
|
|
+ sum(aaa.baojia_count)baojia_count,
|
|
|
+ sum(aaa.suncess_count)suncess_count
|
|
|
+ FROM (
|
|
|
+ -- 应续车辆
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, count(1) ying_lisenseno, 0 send_count, 0 genjin_count, 0 baojia_count, 0 suncess_count
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+
|
|
|
+ -- 跟进次数
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, 0 , 0 , count(b.key_id) as genjin_count ,0,0
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ join qw_genjin_msg b
|
|
|
+ on a.lisenseno=b.lisenseno and a.FRAMENO=b.FRAMENO and a.ENGINENO=b.ENGINENO
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+
|
|
|
+ -- 报价次数
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, 0, 0,0,count(1),0
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ join QW_RENEWAL_BAOJIA_msg b
|
|
|
+ on a.lisenseno=b.LICENSENO
|
|
|
+ and a.FRAMENO=b.FRAMENO
|
|
|
+ and a.ENGINENO=b.ENGINENO
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and b.OPERATEDATE between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+
|
|
|
+ -- 成交量
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 4) comcode, 0, 0,0,0,count(1) suncess_count
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)
|
|
|
+ group by substr(a.comcode, 1, 4)
|
|
|
+
|
|
|
+ <if test="comcodeLength == 2">
|
|
|
+ union all
|
|
|
+ -- 应续车辆
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, count(1) ying_lisenseno, 0 send_count, 0 genjin_count, 0 baojia_count, 0 suncess_count
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+
|
|
|
+ -- 跟进次数
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, 0 , 0 , count(b.key_id) as genjin_count ,0,0
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ join qw_genjin_msg b
|
|
|
+ on a.lisenseno=b.lisenseno and a.FRAMENO=b.FRAMENO and a.ENGINENO=b.ENGINENO
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+
|
|
|
+ -- 报价次数
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, 0, 0,0,count(1),0
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ join QW_RENEWAL_BAOJIA_msg b
|
|
|
+ on a.lisenseno=b.LICENSENO
|
|
|
+ and a.FRAMENO=b.FRAMENO
|
|
|
+ and a.ENGINENO=b.ENGINENO
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and b.OPERATEDATE between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+
|
|
|
+ -- 成交量
|
|
|
+ union all
|
|
|
+ SELECT
|
|
|
+ substr(a.comcode, 1, 2) comcode, 0, 0,0,0,count(1) suncess_count
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where
|
|
|
+ (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)
|
|
|
+ group by substr(a.comcode, 1, 2)
|
|
|
+ </if>
|
|
|
+ ) aaa
|
|
|
+ where aaa.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{comcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ <if test="dfComcode != null and dfComcode !=''">
|
|
|
+ AND aaa.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{dfComcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and aaa.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ group by aaa.comcode
|
|
|
+ order by aaa.comcode
|
|
|
+ </select>
|
|
|
+ <select id="renewalUser" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.RenewalUserVo">
|
|
|
+ select
|
|
|
+ genjin_user as userId,
|
|
|
+ nvl2(genjin_user_name,
|
|
|
+ genjin_user_name,
|
|
|
+ NVL((select t.username
|
|
|
+ from sauser@dblink_sales t
|
|
|
+ where t.usercode = genjin_user),
|
|
|
+ (select t.netpointname
|
|
|
+ from prpdnetpoint@dblink_sales t
|
|
|
+ where t.netpointcode = genjin_user))) userName,
|
|
|
+ sum(countSum) countSum,
|
|
|
+ sum(genjinSum) genjinSum,
|
|
|
+ sum(genjinCount) genjinCount,
|
|
|
+ sum(xbCount) xbCount
|
|
|
+ from (
|
|
|
+ -- 任务总数
|
|
|
+ SELECT
|
|
|
+ genjin_user,
|
|
|
+ genjin_user_name,
|
|
|
+ count(1) countSum,
|
|
|
+ 0 genjinSum,
|
|
|
+ 0 genjinCount,
|
|
|
+ 0 xbCount
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where a.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{comcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ <if test="dfComcode != null and dfComcode !=''">
|
|
|
+ AND a.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{dfComcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ group by a.genjin_user, a.genjin_user_name
|
|
|
+ union all
|
|
|
+ -- 跟进总数
|
|
|
+ SELECT
|
|
|
+ a.genjin_user,
|
|
|
+ genjin_user_name,
|
|
|
+ 0 as countSum,
|
|
|
+ count(1) genjinSum,
|
|
|
+ 0,
|
|
|
+ 0
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where a.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{comcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ <if test="dfComcode != null and dfComcode !=''">
|
|
|
+ AND a.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{dfComcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ and exists (SELECT 1
|
|
|
+ FROM QW_genjin_msg t
|
|
|
+ where t.lisenseno = a.lisenseno
|
|
|
+ and t.frameno = a.frameno
|
|
|
+ and t.engineno = a.engineno
|
|
|
+ and t.oldjqpolicyno = a.oldjqpolicyno
|
|
|
+ and t.oldsypolicyno = a.oldsypolicyno
|
|
|
+ and t.oldjqenddate = a.oldjqenddate
|
|
|
+ )
|
|
|
+ group by a.genjin_user, a.genjin_user_name
|
|
|
+ union all
|
|
|
+ -- 跟进记录
|
|
|
+ SELECT
|
|
|
+ a.genjin_user,
|
|
|
+ a. genjin_user_name,
|
|
|
+ 0 countSum,
|
|
|
+ 0 genjinSum,
|
|
|
+ count(1) as genjinCount,
|
|
|
+ 0 as xbCount
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ join QW_genjin_msg b
|
|
|
+ on b.lisenseno = a.lisenseno
|
|
|
+ and b.frameno = a.frameno
|
|
|
+ and b.engineno = a.engineno
|
|
|
+ and b.oldjqpolicyno = a.oldjqpolicyno
|
|
|
+ and b.oldsypolicyno = a.oldsypolicyno
|
|
|
+ and b.oldjqenddate = a.oldjqenddate
|
|
|
+ where a.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{comcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ <if test="dfComcode != null and dfComcode !=''">
|
|
|
+ AND a.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{dfComcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ group by a.genjin_user, a.genjin_user_name
|
|
|
+ union all
|
|
|
+ -- 续保数量(续保成功-外呼业务)
|
|
|
+ SELECT
|
|
|
+ a.genjin_user,
|
|
|
+ a. genjin_user_name,
|
|
|
+ 0 countSum,
|
|
|
+ 0 genjinSum,
|
|
|
+ 0 genjinCount,
|
|
|
+ count(1) as xbCount
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where a.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{comcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ <if test="dfComcode != null and dfComcode !=''">
|
|
|
+ AND a.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{dfComcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and a.status = '6'
|
|
|
+ and (
|
|
|
+ trunc(a.oldjqenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ or
|
|
|
+ trunc(a.oldsyenddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ group by a.genjin_user, a.genjin_user_name) aaa
|
|
|
+ where aaa.genjin_user is not null
|
|
|
+ group by genjin_user, genjin_user_name
|
|
|
+ ORDER BY xbCount desc
|
|
|
+
|
|
|
+ </select>
|
|
|
+ <select id="monthRenewalLv"
|
|
|
+ resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.MonthRenewalLvVo">
|
|
|
+ SELECT
|
|
|
+ substr(enddate, 6) "month",
|
|
|
+ sum(sum_all) sumAll,
|
|
|
+ sum(sum_yi) sumYi,
|
|
|
+ (round(sum(sum_yi)/sum(sum_all)*100, 2) ) AS lvYi
|
|
|
+ FROM (
|
|
|
+ -- 应续
|
|
|
+ SELECT enddate, count(1) sum_all, 0 sum_yi
|
|
|
+ FROM (select distinct *
|
|
|
+ from (SELECT to_char(a.oldjqenddate, 'yyyy-MM') enddate,
|
|
|
+ a.lisenseno,
|
|
|
+ a.frameno,
|
|
|
+ a.engineno,
|
|
|
+ a.jqpolicyno,
|
|
|
+ a.sypolicyno
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where to_char(a.oldjqenddate, 'yyyy') = #{yearStr}
|
|
|
+ <if test="comcode != '00'">
|
|
|
+ AND substr(a.comcode, 1, ${comcodeLength2}) = #{comcode}
|
|
|
+ </if>
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ union all
|
|
|
+ SELECT to_char(a.oldsyenddate, 'yyyy-MM') enddate,
|
|
|
+ a.lisenseno,
|
|
|
+ a.frameno,
|
|
|
+ a.engineno,
|
|
|
+ a.jqpolicyno,
|
|
|
+ a.sypolicyno
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where to_char(a.oldsyenddate, 'yyyy') = #{yearStr}
|
|
|
+ <if test="comcode != '00'">
|
|
|
+ AND substr(a.comcode, 1, ${comcodeLength2}) = #{comcode}
|
|
|
+ </if>
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ ))
|
|
|
+ group by enddate
|
|
|
+ union all
|
|
|
+
|
|
|
+ -- 已续
|
|
|
+ SELECT enddate, 0, count(1) sum_yi
|
|
|
+ FROM (select distinct *
|
|
|
+ from (SELECT to_char(a.oldjqenddate, 'yyyy-MM') enddate,
|
|
|
+ a.lisenseno,
|
|
|
+ a.frameno,
|
|
|
+ a.engineno,
|
|
|
+ a.jqpolicyno,
|
|
|
+ a.sypolicyno
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where to_char(a.oldjqenddate, 'yyyy') = #{yearStr}
|
|
|
+ <if test="comcode != '00'">
|
|
|
+ AND substr(a.comcode, 1, ${comcodeLength2}) = #{comcode}
|
|
|
+ </if>
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)
|
|
|
+ union all
|
|
|
+ SELECT to_char(a.oldsyenddate, 'yyyy-MM') enddate,
|
|
|
+ a.lisenseno,
|
|
|
+ a.frameno,
|
|
|
+ a.engineno,
|
|
|
+ a.jqpolicyno,
|
|
|
+ a.sypolicyno
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ where to_char(a.oldsyenddate, 'yyyy') = #{yearStr}
|
|
|
+ <if test="comcode != '00'">
|
|
|
+ AND substr(a.comcode, 1, ${comcodeLength2}) = #{comcode}
|
|
|
+ </if>
|
|
|
+ <if test="comcodeNotin != null and comcodeNotin.size()>0">
|
|
|
+ <foreach collection="comcodeNotin" item="item" index="i" >
|
|
|
+ and a.comcode not like #{item} || '%'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserList != null and genjinUserList.size() > 0">
|
|
|
+ AND a.GENJIN_USER in
|
|
|
+ <foreach collection="genjinUserList" index="item" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUser != null and genjinUser !=''">
|
|
|
+ AND a.GENJIN_USER =#{genjinUser}
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserNullFlag != null and genjinUserNullFlag !='' and genjinUserNullFlag == '0'.toString()">
|
|
|
+ AND a.GENJIN_USER is not null
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and (a.jqpolicyno is not null or a.sypolicyno is not null)))
|
|
|
+ group by enddate)
|
|
|
+ group by enddate
|
|
|
+ ORDER BY enddate
|
|
|
+ </select>
|
|
|
+ <select id="fcMonthRenewalLv"
|
|
|
+ resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.FcMonthRenewalLvVo">
|
|
|
+ SELECT
|
|
|
+ substr(enddate, 6) "month",
|
|
|
+ sum(sum_all) SUMALL,
|
|
|
+ sum(sum_yi) SUMYI,
|
|
|
+ (round(sum(sum_yi) / sum(sum_all) * 100, 2)) AS LVYI,
|
|
|
+ sum(SUMPREMIUM) SUMPREMIUM,
|
|
|
+ sum(SUMPREMIUM_YI) SUMPREMIUMYI,
|
|
|
+ (round(sum(SUMPREMIUM_YI) / sum(SUMPREMIUM) * 100, 2)) AS LVSUMPREMIUM
|
|
|
+ FROM (
|
|
|
+ -- 应续
|
|
|
+ SELECT
|
|
|
+ enddate,
|
|
|
+ count(1) sum_all,
|
|
|
+ 0 sum_yi,
|
|
|
+ sum(SUMPREMIUM) SUMPREMIUM,
|
|
|
+ 0 SUMPREMIUM_YI
|
|
|
+ FROM (select distinct *
|
|
|
+ from (SELECT to_char(a.enddate, 'yyyy-MM') enddate,
|
|
|
+ a.policyno,
|
|
|
+ a.SUMPREMIUM
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where to_char(a.enddate, 'yyyy') = #{yearStr}
|
|
|
+ <if test="comcode != '00'">
|
|
|
+ AND substr(a.comcode, 1, ${comcodeLength2}) = #{comcode}
|
|
|
+ </if>
|
|
|
+ )
|
|
|
+ )
|
|
|
+ group by enddate
|
|
|
+ union all
|
|
|
+
|
|
|
+ -- 已续
|
|
|
+ SELECT
|
|
|
+ enddate, 0, count(1) sum_yi, 0, sum(SUMPREMIUM) SUMPREMIUM_YI
|
|
|
+ FROM (select distinct *
|
|
|
+ from (SELECT to_char(a.enddate, 'yyyy-MM') enddate,
|
|
|
+ a.POLICYNO_N,
|
|
|
+ a.SUMPREMIUM
|
|
|
+ FROM QW_MID_RENEWAL_GF_LIST a
|
|
|
+ where to_char(a.enddate, 'yyyy') = #{yearStr}
|
|
|
+ and a.POLICYNO_N is not null
|
|
|
+ <if test="comcode != '00'">
|
|
|
+ AND substr(a.COMCODE_N, 1, ${comcodeLength2}) = #{comcode}
|
|
|
+ </if>
|
|
|
+ )
|
|
|
+ )
|
|
|
+ group by enddate
|
|
|
+ )
|
|
|
+ group by enddate
|
|
|
+ ORDER BY enddate
|
|
|
+ </select>
|
|
|
+ <select id="selectByPolicyno" resultType="java.lang.Double">
|
|
|
+ SELECT round(sum(a.premium),2) premium
|
|
|
+ FROM mid_cb_premium_kind_all@dblink_statdw a
|
|
|
+ WHERE a.policyno = #{policyno}
|
|
|
+ group by policyno
|
|
|
+ </select>
|
|
|
+ <select id="sendMsgCount" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.SendCountVo">
|
|
|
+ SELECT
|
|
|
+ m.comcode,
|
|
|
+ (SELECT t.comcname FROM SaCompany@dblink_sales t where t.comcode=m.comcode) as comcname,
|
|
|
+ m.policyno,
|
|
|
+ '' applycode,
|
|
|
+ m.appliname applyname,
|
|
|
+ m.mobile applyphone,
|
|
|
+ m.mobile phone,
|
|
|
+ m.enddate,
|
|
|
+ NVL((SELECT t.dictvalue
|
|
|
+ FROM QW_SYS_DICT t
|
|
|
+ where t.dicttype = 'SOURCE'
|
|
|
+ and t.dictcode = c.source),
|
|
|
+ c.source) source,
|
|
|
+ a.senddate,
|
|
|
+ c.operatetime,
|
|
|
+ m.wxurl duan_url,
|
|
|
+ m.prourl chang_url
|
|
|
+ FROM xubao_fc m
|
|
|
+ left join NOCARFEE_MSG a
|
|
|
+ on m.policyno=a.policyno and trunc(m.statdate)=trunc(a.senddate)
|
|
|
+ left join xubao_fc_log c
|
|
|
+ on m.policyno = c.plyno
|
|
|
+ WHERE 1=1
|
|
|
+ AND m.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{comcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ <if test="dfComcode != null and dfComcode !=''">
|
|
|
+ AND m.comcode IN (
|
|
|
+ select comcode
|
|
|
+ from SaCompany@dblink_sales
|
|
|
+ where validstatus = '1'
|
|
|
+ start with comcode = #{dfComcode}
|
|
|
+ connect by prior comcode = uppercomcode
|
|
|
+ and prior comcode != comcode
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="startDate != null and endDate != null">
|
|
|
+ and trunc(m.enddate) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ </if>
|
|
|
+ <if test="phone != null and phone != ''">
|
|
|
+ and m.mobile = #{phone}
|
|
|
+ </if>
|
|
|
+ ORDER BY a.senddate DESC
|
|
|
+ </select>
|
|
|
+ <select id="selectByMainpolicyno" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.CarVo">
|
|
|
+ select distinct
|
|
|
+ motor.licenseno licenseno,
|
|
|
+ re.insuredname name,
|
|
|
+ fun_aes_decrypt(re.contactphoneno) mobile
|
|
|
+ from guproposalitemmotor@${dblink} motor, guproposalrelatedparty@${dblink} re
|
|
|
+ where motor.proposalno = re.proposalno
|
|
|
+ and re.proposalno = #{mainpolicyno}
|
|
|
+ </select>
|
|
|
+ <select id="xbrwzztj" resultType="com.linkwechat.coal.modules.xxxt.renewal.domain.vo.XbrwzztjVo">
|
|
|
+ SELECT
|
|
|
+ a.genjin_user genjinUser,
|
|
|
+ a.genjin_user_name genjinUserName,
|
|
|
+ count(1) yiCount,
|
|
|
+ SUM(CASE WHEN a.status ='1' THEN 1 ELSE 0 END) AS zhengzaiCount,
|
|
|
+ SUM(CASE WHEN a.status ='6' THEN 1 ELSE 0 END) AS grokCount,
|
|
|
+ SUM(a.JQ_NEWSUMPRE ) + SUM(a.SY_NEWSUMPRE) AS grokFee,
|
|
|
+ round(SUM(CASE WHEN a.status ='6' THEN 1 ELSE 0 END)/count(1) *100, 2) AS grlv,
|
|
|
+ SUM(CASE WHEN a.status ='2' THEN 1 ELSE 0 END) AS zrokCount,
|
|
|
+ (SUM(CASE WHEN a.status ='2' THEN 1 ELSE 0 END) + SUM(CASE WHEN a.status ='6' THEN 1 ELSE 0 END)) AS allokCount,
|
|
|
+ round((SUM(CASE WHEN a.status ='2' THEN 1 ELSE 0 END) + SUM(CASE WHEN a.status ='6' THEN 1 ELSE 0 END))/count(1) *100, 2) AS alllv,
|
|
|
+ '' remake
|
|
|
+ FROM QW_RENEWAL_FRAMENO_LIST a
|
|
|
+ WHERE
|
|
|
+ a.comcode IN (select companycode
|
|
|
+ from cd_gglevelcompany@dblink_statdw
|
|
|
+ where level1com = #{comcode}
|
|
|
+ or level2com = #{comcode}
|
|
|
+ or level3com = #{comcode}
|
|
|
+ or level4com = #{comcode}
|
|
|
+ or level5com = #{comcode})
|
|
|
+ and a.comcode IN (select companycode
|
|
|
+ from cd_gglevelcompany@dblink_statdw
|
|
|
+ where level1com = #{dfComcode}
|
|
|
+ or level2com = #{dfComcode}
|
|
|
+ or level3com = #{dfComcode}
|
|
|
+ or level4com = #{dfComcode}
|
|
|
+ or level5com = #{dfComcode})
|
|
|
+ AND (trunc(a.OLDSYENDDATE) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ OR
|
|
|
+ trunc(a.OLDJQENDDATE) between trunc(#{startDate, jdbcType=TIMESTAMP}) and trunc(#{endDate, jdbcType=TIMESTAMP})
|
|
|
+ )
|
|
|
+ AND a.is_audit = '1'
|
|
|
+ AND a.genjin_user is not null
|
|
|
+ <if test="genjinUserIdList != null">
|
|
|
+ AND a.genjin_user in
|
|
|
+ <foreach collection="genjinUserIdList" index="i" item="item" open="(" close=")" separator=" union all ">
|
|
|
+ select #{item} from dual
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="genjinUserName != null and genjinUserName !=''">
|
|
|
+ AND a.genjin_user_name like '%' || #{genjinUserName} || '%'
|
|
|
+ </if>
|
|
|
+ <if test="yearStr != null and yearStr !=''">
|
|
|
+ AND (to_char(a.oldjqstartdate,'yyyy') =#{yearStr}
|
|
|
+ OR
|
|
|
+ to_char(a.oldsystartdate,'yyyy') =#{yearStr}
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by a.genjin_user,a.genjin_user_name
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+</mapper>
|