Commit 27f0539e authored by 王东's avatar 王东

调整指标计算目标表

parent b1567b79
-- RZ_DM_QUANTILE ZB_DM_单位时间内访问时间排序
-- 视图
-- step1:
-- 排序
CREATE TEMPORARY VIEW VIEW_RZ_DM_QUANTILE AS
SELECT
d1.`applicationname` as `applicationname`
,d1.`agentid` as `agentid`
,concat(LongTimeToStringUDF(cast(d1.endTime as bigint)*60000,'yyyy-MM-dd HH:mm'),":00" ) as `time`
,d1.`elapsed` as `elapsed`
,ROW_NUMBER() OVER(PARTITION BY
d1.`applicationname`
,d1.`agentid`
,concat(LongTimeToStringUDF(cast(d1.endTime as bigint)*60000,'yyyy-MM-dd HH:mm'),":00" )
ORDER BY d1.`elapsed` ASC
) AS rownum
from RZ_ODS.RZ_ODS_KAFKA_RZ.RZDATA d1
where
LongTimeToStringUDF(d1.endTime,'yyyy-MM-dd HH:mm') > DATEFORMAT(TIMESTAMPADD(MINUTE,-3,LOCALTIMESTAMP),'yyyy-MM-dd HH:mm')
and d1.status = '200'
and LEFT(d1.`rpc`,3) not in ('.js')
and LEFT(d1.`rpc`,4) not in ('.jpg','.ico','.css','.ttf','.png','.PNG','.JPG','.txt','.mp4','.mp3','.pdf','.dwr')
and LEFT(d1.`rpc`,5) not in ('.json','.html','.less','.jpeg')
and LEFT(d1.`rpc`,6) not in ('.woff2')
;
-- RZ_DM_QUANTILE_AGENTID ZB_DM_单位时间内访问时间排序按应用统计
insert into RZ_DM_QUANTILE_AGENTID
SELECT
s1.`applicationname` as `applicationname`
,s1.`agentid` as `agentid`
,s1.`time` as `time`
,s1.`quantile50` as `quantile50`
,s1.`quantile75` as `quantile75`
,s1.`quantile95` as `quantile95`
,s1.`quantile99` as `quantile99`
,DateTimeToLongUDF() as `createtime`
from(
select
c1.`applicationname` as `applicationname`
,c1.`agentid` as `agentid`
,c1.`time` as `time`
,v1.`elapsed` as `quantile50`
,v2.`elapsed` as `quantile75`
,v3.`elapsed` as `quantile95`
,v4.`elapsed` as `quantile99`
from (
select
d1.`applicationname` as `applicationname`
,d1.`agentid` as `agentid`
,oncat(LongTimeToStringUDF(cast(s1.endTime as bigint)*60000,'yyyy-MM-dd HH:mm'),":00" ) as `time`
,CEIL(count(1)*0.5 ) as `num50`
,CEIL(count(1)*0.75 ) as `num75`
,CEIL(count(1)*0.95 ) as `num95`
,CEIL(count(1)*0.99 ) as `num99`
from RZ_ODS.RZ_ODS_KAFKA_RZ.RZDATA d1
where
LongTimeToStringUDF(d1.endTime,'yyyy-MM-dd HH:mm') > DATEFORMAT(TIMESTAMPADD(MINUTE,-3,LOCALTIMESTAMP),'yyyy-MM-dd HH:mm')
and d1.status = '200'
and LEFT(d1.`rpc`,3) not in ('.js')
and LEFT(d1.`rpc`,4) not in ('.jpg','.ico','.css','.ttf','.png','.PNG','.JPG','.txt','.mp4','.mp3','.pdf','.dwr')
and LEFT(d1.`rpc`,5) not in ('.json','.html','.less','.jpeg')
and LEFT(d1.`rpc`,6) not in ('.woff2')
group by
d1.`applicationname` as `applicationname`
,d1.`agentid` as `agentid`
,oncat(LongTimeToStringUDF(cast(s1.endTime as bigint)*60000,'yyyy-MM-dd HH:mm'),":00" ) as `time`
) c1
left join VIEW_RZ_DM_QUANTILE v1
on c1.`applicationname` = c2.`applicationname`
and c1.`agentid`=c2.`agentid`
and c1.`time` = c2.`time`
and c1.`num50` = c2.rownum
left join VIEW_RZ_DM_QUANTILE v2
on c1.`applicationname` = c2.`applicationname`
and c1.`agentid`=c2.`agentid`
and c1.`time` = c2.`time`
and c1.`num75` = c2.rownum
left join VIEW_RZ_DM_QUANTILE v3
on c1.`applicationname` = c2.`applicationname`
and c1.`agentid`=c2.`agentid`
and c1.`time` = c2.`time`
and c1.`num95` = c2.rownum
left join VIEW_RZ_DM_QUANTILE v4
on c1.`applicationname` = c2.`applicationname`
and c1.`agentid`=c2.`agentid`
and c1.`time` = c2.`time`
and c1.`num99` = c2.rownum
) s1
;
-- ZB_ODS_CBDATA ZB_ODS_指标加工承保业务数据 -- ZB_ODS_CBDATA ZB_ODS_指标加工承保业务数据
insert into ZB_ODS.ZB_ODS_KAFKA.CDDATA insert into ZB_ODS.ZB_ODS_KAFKA.CBDATA
select select
s1.uwConclueDate as `uwConclueDate` -- 核保通过时间 s1.uwConclueDate as `uwConclueDate` -- 核保通过时间
,s1.startTime as `startTime` -- 起保时间 ,s1.startTime as `startTime` -- 起保时间
......
-- ZB_ODS_LPDATA ZB_ODS_指标加工理赔业务数据
insert into ZB_ODS.ZB_ODS_KAFKA.LPDATA
select
,s1.businessOffice as `COMCODE` --
,t1.COMNAME as `COMNAME` --
,t1.LEVEL1COMCODE as `LEVEL1COMCODE` --
,t1.LEVEL2COMCODE as `LEVEL2COMCODE` --
,t1.LEVEL3COMCODE as `LEVEL3COMCODE` --
,t1.LEVEL4COMCODE as `LEVEL4COMCODE` --
,t1.LEVEL5COMCODE as `LEVEL5COMCODE` --
,t1.LEVEL1COMDESC as `LEVEL1COMDESC` --
,t1.LEVEL2COMDESC as `LEVEL2COMDESC` --
,t1.LEVEL3COMDESC as `LEVEL3COMDESC` --
,t1.LEVEL4COMDESC as `LEVEL4COMDESC` --
,t1.LEVEL5COMDESC as `LEVEL5COMDESC` --
,s1.productCode as `risk` -- 险种代码
,t3.RISKNAME as `riskname` --
,s1.businessNatureCode as `businessNatureCode` -- 业务来源
,t4.CODEDESC as `businessNatureName` --
,s1.businessChannelCode as `chnl` -- 业务渠道
,t2.NEWCHNLTYPEDESC as `chnlname` --
,s1.netPremium as `cost` -- 不含税保费
,s1.policyNo as `no` -- 保单号
,s1.xxzflag as xxzflag -- 新续转标记 1是0否
,s1.recordClerkCode as `id` -- 14 归属业务员ID
,s1.recordClerkName as `name` -- 15 归属业务员名称
from (
select
机构
险种
业务来源
渠道
立案日期
估损调整日期
估损提转差
估损金额
类型
赔案号
保单号
,businessOffice as businessOffice -- 保单归属机构代码
,productCode as productCode -- 险种代码
,businessChannelCode as businessChannelCode -- 业务渠道
,businessNatureCode as businessNatureCode -- 业务来源
,netPremium as netPremium -- 不含税保费
,policyNo as policyNo -- 保单号
,'bd' as flag -- 保单或批单标记
,proctime as proctime
,case
when LEFT(productCode,2) = '05' and (newPolicyFlag = '1' or autoTransrenewFlag = '1' or autoTransrenewFlag = '4' or transferPolicyFlag = '1' or transrenewFlag = '1' or transrenewFlag ='4') then '1'
when LEFT(productCode,2) <> '05' and (newPolicyFlag = '0' or autoTransrenewFlag = '1' or autoTransrenewFlag = '4' or transferPolicyFlag = '2' or transrenewFlag = '1' ) then '1'
else '0' end as xxzflag -- 新续转标记 1是0否
,recordClerkCode as recordClerkCode -- 14 归属业务员ID
,recordClerkName as recordClerkName -- 15 归属业务员名称
,ROW_NUMBER() OVER(PARTITION BY policyNo,businessOffice,netPremium ORDER BY uwConclueDate DESC) as rownum
from ZB_ODS.ZB_SOURCE_RMQ_POLICY_SIT.POLICY -- 保单业务数据
where `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
union all
select
LongTimeToStringUDF(policyCreatDate,'yyyyMMdd') as uwConclueDate -- 核保通过时间 ??
,LongTimeToStringUDF(endorseEffectiveTime,'yyyyMMdd') as startTime -- 起保时间
,businessOffice as businessOffice -- 保单归属机构代码
,productCode as productCode -- 险种代码
,businessChannelCode as businessChannelCode -- 业务渠道
,businessNatureCode as businessNatureCode -- 业务来源
,plpEndorse.staCurPremiumVariation as netPremium -- 不含税保费 ??
,endorseNo as policyNo -- 批单号
,'pd' as flag -- 保单或批单标记
,proctime as proctime
,case
when LEFT(productCode,2) = '05' and (newPolicyFlag = '1' or autoTransrenewFlag = '1' or autoTransrenewFlag = '4' or transferPolicyFlag = '1' or transrenewFlag = '1' or transrenewFlag ='4') then '1'
when LEFT(productCode,2) <> '05' and (newPolicyFlag = '0' or autoTransrenewFlag = '1' or autoTransrenewFlag = '4' or transferPolicyFlag = '2' or transrenewFlag = '1' ) then '1'
else '0' end as xxzflag -- 新续转标记 1是0否
,recordClerkCode as recordClerkCode -- 14 归属业务员ID
,recordClerkName as recordClerkName -- 15 归属业务员名称
,ROW_NUMBER() OVER(PARTITION BY endorseNo,businessOffice,plpEndorse.staCurPremiumVariation ORDER BY uwConclueDate DESC) as rownum
from ZB_ODS.ZB_SOURCE_RMQ_ENDOR_SIT.ENDOR -- 批单业务数据
where `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
) s1
left join ZB_ODS.ZB_ODS_MYSQL.CD_COM_ALL for system_time as of s1.proctime as t1 on s1.businessOffice = t1.COMCODE
left join ZB_ODS.ZB_ODS_MYSQL.CD_NEWCHNLTYPE for system_time as of s1.proctime as t2 on s1.businessChannelCode = t2.NEWCHNLTYPE
left join ZB_ODS.ZB_ODS_MYSQL.CD_REALTIME_RISK for system_time as of s1.proctime as t3 on s1.productCode = t3.RISKCODE
left join ZB_ODS.ZB_ODS_MYSQL.CD_BUSINESSNATURE for system_time as of s1.proctime as t4 on s1.businessNatureCode = t4.CODE
where s1.rownum = 1
;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment