Commit 3fe7c8f2 authored by 王东's avatar 王东

指标计算承保字段调整

parent 6782baee
-- ZB_DM_JRQDBF_HB ZB_DM_今日签单合并 -- ZB_DM_JRQDBF_HB ZB_DM_今日签单合并
-- step1: -- step1:
-- 团队汇总 -- 团队汇总
CREATE TEMPORARY VIEW VIEW_ZB_DM_JRQDBF_HB_TUANDUI AS CREATE TEMPORARY VIEW VIEW_ZB_DM_JRQDBF_HB_TUANDUI AS
SELECT s1.`uwConclueDate` as `uwConclueDate` SELECT
s1.`uwConclueDate` as `uwConclueDate`
, s1.`LEVEL1COMCODE` as `LEVEL1COMCODE` , s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
, s1.`LEVEL2COMCODE` as `LEVEL2COMCODE` , s1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
, s1.`LEVEL3COMCODE` as `LEVEL3COMCODE` , s1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
...@@ -13,16 +12,10 @@ SELECT s1.`uwConclueDate` as `uwConclueDate` ...@@ -13,16 +12,10 @@ SELECT s1.`uwConclueDate` as `uwConclueDate`
, s1.`startTime` as `startTime` , s1.`startTime` as `startTime`
, s1.`risk` as `risk` , s1.`risk` as `risk`
, sum(cast(s1.`cost` as DECIMAL(18, 2))) as `cost` , sum(cast(s1.`cost` as DECIMAL(18, 2))) as `cost`
from ( from ZB_ODS.ZB_ODS_KAFKA.CBDATA
select where
* `COMNAME` is not null
,ROW_NUMBER() OVER(PARTITION BY `no`,`COMCODE`,`cost` ORDER BY `uwConclueDate` DESC) as rownum and `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
from ZB_ODS.ZB_ODS_KAFKA.CBDATA
where
`COMNAME` is not null
and `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
) s1
where s1.rownum = 1
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
, s1.`LEVEL1COMCODE` , s1.`LEVEL1COMCODE`
...@@ -474,171 +467,4 @@ where left(s1.`startTime`,8) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') ...@@ -474,171 +467,4 @@ where left(s1.`startTime`,8) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
; ;
-- ZB_DM_QDBF_CAR/ZB_DM_车险今日签单保费
-- key:allcarqbbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、车险
-- 总公司
insert into ZB_DM.ZB_DM_REDIS.SET_DECIMAL
select
CONCAT(
'allcarqdbf/'
,s1.`uwConclueDate`
) as `key`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDBF_HB_TUANDUI s1
where left(s1.risk,2) ='05'
group by
s1.`uwConclueDate`
;
-- 分公司
insert into ZB_DM.ZB_DM_REDIS.HSET_DECIMAL
select
CONCAT(
'provcarqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL1COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDBF_HB_TUANDUI s1
where left(s1.risk,2) ='05'
group by
s1.`uwConclueDate`
,s1.`LEVEL1COMCODE`
;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.HSET_DECIMAL
select
CONCAT(
'citycarqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL2COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDBF_HB_TUANDUI s1
where left(s1.risk,2) ='05'
group by
s1.`uwConclueDate`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.HSET_DECIMAL
select
CONCAT(
'countycarqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL3COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDBF_HB_TUANDUI s1
where left(s1.risk,2) ='05'
group by
s1.`uwConclueDate`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.HSET_DECIMAL
select
CONCAT(
'teamcarqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL4COMCODE` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_JRQDBF_HB_TUANDUI s1
where left(s1.risk,2) ='05'
;
-- ZB_DM_QDBF_NOCAR/ZB_DM_非车险今日签单保费
-- key:allnocarqbbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、非车险
-- 总公司
insert into ZB_DM.ZB_DM_REDIS.SET_DECIMAL
select
CONCAT(
'allnocarqdbf/'
,s1.`uwConclueDate`
) as `key`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDBF_HB_TUANDUI s1
where left(s1.risk,2) <>'05'
group by
s1.`uwConclueDate`
;
-- 分公司
insert into ZB_DM.ZB_DM_REDIS.HSET_DECIMAL
select
CONCAT(
'provnocarqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL1COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDBF_HB_TUANDUI s1
where left(s1.risk,2) <>'05'
group by
s1.`uwConclueDate`
,s1.`LEVEL1COMCODE`
;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.HSET_DECIMAL
select
CONCAT(
'citynocarqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL2COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDBF_HB_TUANDUI s1
where left(s1.risk,2) <>'05'
group by
s1.`uwConclueDate`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.HSET_DECIMAL
select
CONCAT(
'countynocarqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL3COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDBF_HB_TUANDUI s1
where left(s1.risk,2) <>'05'
group by
s1.`uwConclueDate`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.HSET_DECIMAL
select
CONCAT(
'teamnocarqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL4COMCODE` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_JRQDBF_HB_TUANDUI s1
where left(s1.risk,2) <>'05'
;
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
-- step1: -- step1:
-- 团队汇总 -- 团队汇总
CREATE TEMPORARY VIEW ZB_DM.ZB_DM_MYSQL.TDHZ AS CREATE TEMPORARY VIEW ZB_DM.ZB_DM_MYSQL.TEAM AS
SELECT SELECT
s1.`uwConclueDate` as `uwConclueDate` s1.`uwConclueDate` as `uwConclueDate`
, s1.`LEVEL1COMCODE` as `LEVEL1COMCODE` , s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
...@@ -16,7 +16,7 @@ SELECT ...@@ -16,7 +16,7 @@ SELECT
, s1.`chnl` as `chnl` , s1.`chnl` as `chnl`
, s1.`businessNatureCode` as `businessNatureCode` , s1.`businessNatureCode` as `businessNatureCode`
, sum(cast(s1.`cost` as DECIMAL(18, 2))) as `cost` , sum(cast(s1.`cost` as DECIMAL(18, 2))) as `cost`
, DATE_FORMAT(tumble_end(s1.row_time, interval '1' minute) ,'yyyy-MM-dd HH:mm:ss') as `log_time` , DATE_FORMAT(tumble_end(s1.row_time, interval '1' hour) ,'yyyy-MM-dd HH:mm:ss') as `log_time`
from ( from (
select select
* *
...@@ -24,7 +24,7 @@ from ( ...@@ -24,7 +24,7 @@ from (
from ZB_ODS.ZB_ODS_KAFKA.CBDATA from ZB_ODS.ZB_ODS_KAFKA.CBDATA
where where
`COMNAME` is not null `COMNAME` is not null
and `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') and LEFT(`uwConclueDate`,8) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
) s1 ) s1
where s1.rownum = 1 where s1.rownum = 1
group by group by
......
...@@ -27,6 +27,7 @@ create table CBDATA( ...@@ -27,6 +27,7 @@ create table CBDATA(
`no` String , -- 保单号 `no` String , -- 保单号
`xxzflag` String , -- 新续转标记 1是0否 `xxzflag` String , -- 新续转标记 1是0否
`id` String , -- 14 归属业务员ID `id` String , -- 14 归属业务员ID
`name` String -- 15 归属业务员名称 `name` String ,-- 15 归属业务员名称
log_time String
) )
; ;
\ No newline at end of file
...@@ -39,10 +39,11 @@ select ...@@ -39,10 +39,11 @@ select
,s1.xxzflag as xxzflag -- 新续转标记 1是0否 ,s1.xxzflag as xxzflag -- 新续转标记 1是0否
,s1.recordClerkCode as `id` -- 14 归属业务员ID ,s1.recordClerkCode as `id` -- 14 归属业务员ID
,s1.recordClerkName as `name` -- 15 归属业务员名称 ,s1.recordClerkName as `name` -- 15 归属业务员名称
,s1.log_time as log_time
from ( from (
select select
LongTimeToStringUDF(uwConclueDate,'yyyyMMdd') as uwConclueDate -- 核保通过时间 LongTimeToStringUDF(uwConclueDate,'yyyyMMdd HH:mm:ss') as uwConclueDate -- 核保通过时间
,LongTimeToStringUDF(startTime,'yyyyMMdd') as startTime -- 起保时间 ,LongTimeToStringUDF(startTime,'yyyyMMdd HH:mm:ss') as startTime -- 起保时间
,businessOffice as businessOffice -- 保单归属机构代码 ,businessOffice as businessOffice -- 保单归属机构代码
,productCode as productCode -- 险种代码 ,productCode as productCode -- 险种代码
,businessChannelCode as businessChannelCode -- 业务渠道 ,businessChannelCode as businessChannelCode -- 业务渠道
...@@ -63,6 +64,7 @@ from ( ...@@ -63,6 +64,7 @@ from (
,recordClerkName as recordClerkName -- 15 归属业务员名称 ,recordClerkName as recordClerkName -- 15 归属业务员名称
,'bd' as flag -- 保单或批单标记 ,'bd' as flag -- 保单或批单标记
,proctime as proctime ,proctime as proctime
,uwConclueDate as log_time
from ODS.ODS_KAFKA.POLICY -- 保单业务数据 from ODS.ODS_KAFKA.POLICY -- 保单业务数据
where LongTimeToStringUDF(uwConclueDate,'yyyyMMdd') = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') where LongTimeToStringUDF(uwConclueDate,'yyyyMMdd') = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
and ( and (
...@@ -75,8 +77,8 @@ from ( ...@@ -75,8 +77,8 @@ from (
) )
union all union all
select select
LongTimeToStringUDF(uwConclueDate,'yyyyMMdd') as uwConclueDate -- 核保通过时间 ?? LongTimeToStringUDF(uwConclueDate,'yyyyMMdd HH:mm:ss') as uwConclueDate -- 核保通过时间 ??
,LongTimeToStringUDF(plpEndorse.endorseEffectiveTime,'yyyyMMdd') as startTime -- 起保时间 ,LongTimeToStringUDF(plpEndorse.endorseEffectiveTime,'yyyyMMdd HH:mm:ss') as startTime -- 起保时间
,businessOffice as businessOffice -- 保单归属机构代码 ,businessOffice as businessOffice -- 保单归属机构代码
,productCode as productCode -- 险种代码 ,productCode as productCode -- 险种代码
,businessChannelCode as businessChannelCode -- 业务渠道 ,businessChannelCode as businessChannelCode -- 业务渠道
...@@ -97,6 +99,8 @@ from ( ...@@ -97,6 +99,8 @@ from (
,recordClerkName as recordClerkName -- 15 归属业务员名称 ,recordClerkName as recordClerkName -- 15 归属业务员名称
,'pd' as flag -- 保单或批单标记 ,'pd' as flag -- 保单或批单标记
,proctime as proctime ,proctime as proctime
,uwConclueDate as log_time
from ODS.ODS_KAFKA.ENDOR -- 批单业务数据 from ODS.ODS_KAFKA.ENDOR -- 批单业务数据
where LongTimeToStringUDF(uwConclueDate,'yyyyMMdd') = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') where LongTimeToStringUDF(uwConclueDate,'yyyyMMdd') = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
and ( and (
......
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