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

指标计算承保字段调整

parent c9dbb37b
...@@ -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,7 +5,19 @@ ...@@ -5,7 +5,19 @@
-- step1: -- step1:
-- 团队汇总 -- 团队汇总
INSERT INTO ZB_DM.ZB_DM_MYSQL.TEAM_RISK INSERT INTO ZB_DM.ZB_DM_MYSQL.TEAM_RISK
SELECT select
a1.`uwConclueDate` as `uwConclueDate`
, a1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
, a1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
, a1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
, a1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
, a1.`startTime` as `startTime`
, a1.`risk` as `risk`
, a1.`cost`+ if(t1.cost is null ,0,cast(t1.cost as decimal(18,2))) as `cost`
, a1.`log_time` as `log_time`
from (
SELECT
s1.`uwConclueDate` as `uwConclueDate` s1.`uwConclueDate` as `uwConclueDate`
, s1.`LEVEL1COMCODE` as `LEVEL1COMCODE` , s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
, s1.`LEVEL2COMCODE` as `LEVEL2COMCODE` , s1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
...@@ -14,18 +26,13 @@ SELECT ...@@ -14,18 +26,13 @@ SELECT
, s1.`startTime` as `startTime` , s1.`startTime` as `startTime`
, s1.`risk` as `risk` , s1.`risk` as `risk`
, cast (sum(cast(s1.`cost` as DECIMAL(18, 2))) as varchar ) as `cost` , cast (sum(cast(s1.`cost` as DECIMAL(18, 2))) as varchar ) as `cost`
, cast (DateTimeToLongUDF(hop_end(s1.row_time, interval '1' hour , interval '24' hour) ) as varchar ) as `log_time` , cast (DateTimeToLongUDF(tumble_end(s1.row_time, interval '1' hour) ) as varchar) as `log_time`
from ( , max(s1.proctime) as proctime
select
*
-- ,ROW_NUMBER() OVER(PARTITION BY `no`,`COMCODE`,`cost` ORDER BY `uwConclueDate` DESC) as rownum
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 LEFT(`uwConclueDate`,8) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') and LEFT(`uwConclueDate`,8) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
) s1 group by
-- where s1.rownum = 1
group by
s1.`uwConclueDate` s1.`uwConclueDate`
, s1.`LEVEL1COMCODE` , s1.`LEVEL1COMCODE`
, s1.`LEVEL2COMCODE` , s1.`LEVEL2COMCODE`
...@@ -33,7 +40,17 @@ group by ...@@ -33,7 +40,17 @@ group by
, s1.`LEVEL4COMCODE` , s1.`LEVEL4COMCODE`
, s1.`startTime` , s1.`startTime`
, s1.`risk` , s1.`risk`
, hop(s1.row_time, interval '1' hour, interval '24' hour) , 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