Commit 448beb69 authored by 王东's avatar 王东

指标计算承保字段调整

parent c9dbb37b
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
-- 团队汇总 -- 团队汇总
CREATE TEMPORARY VIEW VIEW_ZB_DM_JRQDBF_HB_TUANDUI AS CREATE TEMPORARY VIEW VIEW_ZB_DM_JRQDBF_HB_TUANDUI AS
select select
a1.`uwConclueDate` as `uwConclueDate` a1.`uwConclueDate` as `uwConclueDate`
,a1.`LEVEL1COMCODE` as `LEVEL1COMCODE` ,a1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,a1.`LEVEL2COMCODE` as `LEVEL2COMCODE` ,a1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,a1.`LEVEL3COMCODE` as `LEVEL3COMCODE` ,a1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,a1.`LEVEL4COMCODE` as `LEVEL4COMCODE` ,a1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
,a1.`startTime` as `startTime` ,a1.`startTime` as `startTime`
,a1.`risk` as `risk` ,a1.`risk` as `risk`
,a1.`cost` + if(t1.cost is null ,0,cast(t1.cost as decimal(18,2))) as `cost` ,a1.`cost` + if(t1.cost is null ,0,cast(t1.cost as decimal(18,2))) as `cost`
from ( from (
SELECT SELECT
s1.`uwConclueDate` as `uwConclueDate` s1.`uwConclueDate` as `uwConclueDate`
...@@ -45,7 +45,7 @@ left join ZB_DM.ZB_DM_MYSQL.TEAM_RISK for system_time as of a1.proctime as t1 ...@@ -45,7 +45,7 @@ left join ZB_DM.ZB_DM_MYSQL.TEAM_RISK for system_time as of a1.proctime as t1
and a1.`LEVEL4COMCODE` = t1.`LEVEL4COMCODE` and a1.`LEVEL4COMCODE` = t1.`LEVEL4COMCODE`
and a1.`startTime` = t1.`startTime` and a1.`startTime` = t1.`startTime`
and a1.`risk` = t1.`risk` and a1.`risk` = t1.`risk`
and LongTimeToStringUDF(t1.log_time,'yyyyMMdd HH') = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd HH') and LongTimeToStringUDF(t1.log_time,'yyyyMMdd') = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
; ;
......
...@@ -5,35 +5,52 @@ ...@@ -5,35 +5,52 @@
-- step1: -- step1:
-- 团队汇总 -- 团队汇总
INSERT INTO ZB_DM.ZB_DM_MYSQL.TEAM_RISK INSERT INTO ZB_DM.ZB_DM_MYSQL.TEAM_RISK
SELECT select
s1.`uwConclueDate` as `uwConclueDate` a1.`uwConclueDate` as `uwConclueDate`
, s1.`LEVEL1COMCODE` as `LEVEL1COMCODE` , a1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
, s1.`LEVEL2COMCODE` as `LEVEL2COMCODE` , a1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
, s1.`LEVEL3COMCODE` as `LEVEL3COMCODE` , a1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
, s1.`LEVEL4COMCODE` as `LEVEL4COMCODE` , a1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
, s1.`startTime` as `startTime` , a1.`startTime` as `startTime`
, s1.`risk` as `risk` , a1.`risk` as `risk`
, cast (sum(cast(s1.`cost` as DECIMAL(18, 2))) as varchar ) as `cost` , a1.`cost`+ if(t1.cost is null ,0,cast(t1.cost as decimal(18,2))) as `cost`
, cast (DateTimeToLongUDF(hop_end(s1.row_time, interval '1' hour , interval '24' hour) ) as varchar ) as `log_time` , a1.`log_time` as `log_time`
from ( from (
select SELECT
* s1.`uwConclueDate` as `uwConclueDate`
-- ,ROW_NUMBER() OVER(PARTITION BY `no`,`COMCODE`,`cost` ORDER BY `uwConclueDate` DESC) as rownum , s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
from ZB_ODS.ZB_ODS_KAFKA.CBDATA , s1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
where , s1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
`COMNAME` is not null , s1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
and LEFT(`uwConclueDate`,8) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') , s1.`startTime` as `startTime`
) s1 , s1.`risk` as `risk`
-- where s1.rownum = 1 , cast (sum(cast(s1.`cost` as DECIMAL(18, 2))) as varchar ) as `cost`
group by , cast (DateTimeToLongUDF(tumble_end(s1.row_time, interval '1' hour) ) as varchar) as `log_time`
s1.`uwConclueDate` , max(s1.proctime) as proctime
, s1.`LEVEL1COMCODE` from ZB_ODS.ZB_ODS_KAFKA.CBDATA
, s1.`LEVEL2COMCODE` where
, s1.`LEVEL3COMCODE` `COMNAME` is not null
, s1.`LEVEL4COMCODE` and LEFT(`uwConclueDate`,8) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
, s1.`startTime` group by
, s1.`risk` s1.`uwConclueDate`
, hop(s1.row_time, interval '1' hour, interval '24' hour) , s1.`LEVEL1COMCODE`
, s1.`LEVEL2COMCODE`
, s1.`LEVEL3COMCODE`
, s1.`LEVEL4COMCODE`
, s1.`startTime`
, s1.`risk`
, tumble(s1.row_time, interval '1' hour)
)a1
left join ZB_DM.ZB_DM_MYSQL.TEAM_RISK for system_time as of s1.proctime as t1
on s1.`uwConclueDate` = t1.`uwConclueDate`
and s1.`LEVEL1COMCODE` = t1.`LEVEL1COMCODE`
and s1.`LEVEL2COMCODE` = t1.`LEVEL2COMCODE`
and s1.`LEVEL3COMCODE` = t1.`LEVEL3COMCODE`
and s1.`LEVEL4COMCODE` = t1.`LEVEL4COMCODE`
and s1.`startTime` = t1.`startTime`
and s1.`risk` = t1.`risk`
and LongTimeToStringUDF(t1.log_time,'yyyyMMdd') = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
; ;
......
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