Commit f6303fc2 authored by 胡涛's avatar 胡涛

指标统计sql脚本

parent 3fe7c8f2
-- ZB_DM_JRQDBF_HB ZB_DM_今日签单合并 -- ZB_DM_TDHZJG ZB_DM_团队汇总结果
-- step1: -- step1:
-- 团队汇总 -- 团队汇总
CREATE TEMPORARY VIEW ZB_DM.ZB_DM_MYSQL.TEAM AS INSERT INTO ZB_DM.ZB_DM_MYSQL.TEAM
SELECT SELECT
s1.`uwConclueDate` as `uwConclueDate` s1.`uwConclueDate` as `uwConclueDate`
, s1.`LEVEL1COMCODE` as `LEVEL1COMCODE` , s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
...@@ -15,18 +15,18 @@ SELECT ...@@ -15,18 +15,18 @@ SELECT
, s1.`risk` as `risk` , s1.`risk` as `risk`
, 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` , cast (sum(cast(s1.`cost` as DECIMAL(18, 2))) as varchar ) as `cost`
, DATE_FORMAT(tumble_end(s1.row_time, interval '1' hour) ,'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
* *
,ROW_NUMBER() OVER(PARTITION BY `no`,`COMCODE`,`cost` ORDER BY `uwConclueDate` DESC) as rownum -- ,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 ) s1
where s1.rownum = 1 -- where s1.rownum = 1
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
, s1.`LEVEL1COMCODE` , s1.`LEVEL1COMCODE`
......
...@@ -24,6 +24,7 @@ from ( ...@@ -24,6 +24,7 @@ from (
and `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') and `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
) s1 ) s1
where s1.rownum = 1 where s1.rownum = 1
and left(s1.risk,2) ='05'
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`LEVEL1COMCODE` ,s1.`LEVEL1COMCODE`
...@@ -48,7 +49,6 @@ select ...@@ -48,7 +49,6 @@ select
) as `key` ) as `key`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val` ,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_QDBF_CAR_TUANDUI s1 from VIEW_ZB_DM_QDBF_CAR_TUANDUI s1
where left(s1.risk,2) ='05'
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
; ;
...@@ -63,7 +63,6 @@ select ...@@ -63,7 +63,6 @@ select
,s1.`LEVEL1COMCODE` as `hkey` ,s1.`LEVEL1COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val` ,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_QDBF_CAR_TUANDUI s1 from VIEW_ZB_DM_QDBF_CAR_TUANDUI s1
where left(s1.risk,2) ='05'
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`LEVEL1COMCODE` ,s1.`LEVEL1COMCODE`
...@@ -79,7 +78,6 @@ select ...@@ -79,7 +78,6 @@ select
,s1.`LEVEL2COMCODE` as `hkey` ,s1.`LEVEL2COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val` ,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_QDBF_CAR_TUANDUI s1 from VIEW_ZB_DM_QDBF_CAR_TUANDUI s1
where left(s1.risk,2) ='05'
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`LEVEL2COMCODE` ,s1.`LEVEL2COMCODE`
...@@ -96,7 +94,6 @@ select ...@@ -96,7 +94,6 @@ select
,s1.`LEVEL3COMCODE` as `hkey` ,s1.`LEVEL3COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val` ,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_QDBF_CAR_TUANDUI s1 from VIEW_ZB_DM_QDBF_CAR_TUANDUI s1
where left(s1.risk,2) ='05'
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`LEVEL3COMCODE` ,s1.`LEVEL3COMCODE`
...@@ -113,6 +110,4 @@ select ...@@ -113,6 +110,4 @@ select
,s1.`LEVEL4COMCODE` as `hkey` ,s1.`LEVEL4COMCODE` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val` ,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_QDBF_CAR_TUANDUI s1 from VIEW_ZB_DM_QDBF_CAR_TUANDUI s1
where left(s1.risk,2) ='05'
; ;
\ No newline at end of file
...@@ -20,7 +20,7 @@ from ( ...@@ -20,7 +20,7 @@ from (
,`riskname` as `riskname` ,`riskname` as `riskname`
,`chnl` as `chnl` ,`chnl` as `chnl`
,`chnlname` as `chnlname` ,`chnlname` as `chnlname`
,cast(`cost` as decimal(18,2)) as `cost` ,`cost` as `cost`
,`no` as `no` ,`no` as `no`
,ROW_NUMBER() OVER(PARTITION BY `no`,`COMCODE`,`cost` ORDER BY `uwConclueDate` DESC) as rownum ,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
...@@ -29,6 +29,7 @@ from ( ...@@ -29,6 +29,7 @@ from (
and `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') and `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
) s1 ) s1
where s1.rownum = 1 where s1.rownum = 1
and LEFT(s1.`risk`,2) = '05'
; ;
...@@ -64,11 +65,10 @@ from ( ...@@ -64,11 +65,10 @@ from (
,d1.`riskname` as `riskname` ,d1.`riskname` as `riskname`
,d1.`chnl` as `chnl` ,d1.`chnl` as `chnl`
,d1.`chnlname` as `chnlname` ,d1.`chnlname` as `chnlname`
,d1.`cost` as `cost` ,cast(d1.`cost` as decimal(18,2)) as `cost`
,d1.`no` as `no` ,d1.`no` as `no`
,ROW_NUMBER() OVER(PARTITION BY d1.`uwConclueDate` ORDER BY d1.`cost` DESC) as rownum ,ROW_NUMBER() OVER(PARTITION BY d1.`uwConclueDate` ORDER BY d1.`cost` DESC) as rownum
from VIEW_ZB_DM_CXCBDD d1 from VIEW_ZB_DM_CXCBDD d1
where LEFT(d1.`risk`,2) = '05'
) c1 ) c1
where c1.rownum <= 20 where c1.rownum <= 20
) s1 ) s1
...@@ -115,11 +115,10 @@ from ( ...@@ -115,11 +115,10 @@ from (
,d1.`riskname` as `riskname` ,d1.`riskname` as `riskname`
,d1.`chnl` as `chnl` ,d1.`chnl` as `chnl`
,d1.`chnlname` as `chnlname` ,d1.`chnlname` as `chnlname`
,d1.`cost` as `cost` ,cast(d1.`cost` as decimal(18,2)) as `cost`
,d1.`no` as `no` ,d1.`no` as `no`
,ROW_NUMBER() OVER(PARTITION BY d1.`LEVEL1COMCODE`,d1.`uwConclueDate` ORDER BY d1.`cost` DESC) as rownum ,ROW_NUMBER() OVER(PARTITION BY d1.`LEVEL1COMCODE`,d1.`uwConclueDate` ORDER BY d1.`cost` DESC) as rownum
from VIEW_ZB_DM_CXCBDD d1 from VIEW_ZB_DM_CXCBDD d1
where LEFT(d1.`risk`,2) = '05'
) c1 ) c1
where c1.rownum <= 20 where c1.rownum <= 20
) s1 ) s1
...@@ -170,11 +169,10 @@ from ( ...@@ -170,11 +169,10 @@ from (
,d1.`riskname` as `riskname` ,d1.`riskname` as `riskname`
,d1.`chnl` as `chnl` ,d1.`chnl` as `chnl`
,d1.`chnlname` as `chnlname` ,d1.`chnlname` as `chnlname`
,d1.`cost` as `cost` ,cast(d1.`cost` as decimal(18,2)) as `cost`
,d1.`no` as `no` ,d1.`no` as `no`
,ROW_NUMBER() OVER(PARTITION BY d1.`LEVEL2COMCODE`,d1.`uwConclueDate` ORDER BY d1.`cost` DESC) as rownum ,ROW_NUMBER() OVER(PARTITION BY d1.`LEVEL2COMCODE`,d1.`uwConclueDate` ORDER BY d1.`cost` DESC) as rownum
from VIEW_ZB_DM_CXCBDD d1 from VIEW_ZB_DM_CXCBDD d1
where LEFT(d1.`risk`,2) = '05'
) c1 ) c1
where c1.rownum <= 20 where c1.rownum <= 20
) s1 ) s1
......
-- ZB_DM_NOCAR_HB ZB_DM_承保非车险合并
-- 非车险去重
CREATE TEMPORARY VIEW VIEW_ZB_DM_NOCAR_HB AS
SELECT
s1.`uwConclueDate` as `uwConclueDate`
,s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,s1.`LEVEL1COMDESC` as `LEVEL1COMDESC`
,s1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,s1.`LEVEL2COMDESC` as `LEVEL2COMDESC`
,s1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,s1.`LEVEL3COMDESC` as `LEVEL3COMDESC`
,s1.`risk` as `risk`
,s1.`riskname` as `riskname`
,s1.`chnl` as `chnl`
,s1.`chnlname` as `chnlname`
,s1.`cost` as `cost`
,s1.`no` as `no`
from (
select
*
,ROW_NUMBER() OVER(PARTITION BY `no`,`COMCODE`,`cost` ORDER BY `uwConclueDate` DESC) as rownum
from ZB_ODS.ZB_ODS_KAFKA.CBDATA
where
`COMNAME` is not null
and `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
) s1
where s1.rownum = 1
and 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 (
SELECT
d1.`uwConclueDate` as `uwConclueDate`
,d1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,d1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,d1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,d1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
,d1.`risk` as `risk`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `cost`
from VIEW_ZB_DM_NOCAR_HB d1
group by
d1.`uwConclueDate`
,d1.`LEVEL1COMCODE`
,d1.`LEVEL2COMCODE`
,d1.`LEVEL3COMCODE`
,d1.`LEVEL4COMCODE`
,d1.`risk`
) s1
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 (
SELECT
d1.`uwConclueDate` as `uwConclueDate`
,d1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,d1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,d1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,d1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
,d1.`risk` as `risk`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `cost`
from VIEW_ZB_DM_NOCAR_HB d1
group by
d1.`uwConclueDate`
,d1.`LEVEL1COMCODE`
,d1.`LEVEL2COMCODE`
,d1.`LEVEL3COMCODE`
,d1.`LEVEL4COMCODE`
,d1.`risk`
) s1
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 (
SELECT
d1.`uwConclueDate` as `uwConclueDate`
,d1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,d1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,d1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,d1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
,d1.`risk` as `risk`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `cost`
from VIEW_ZB_DM_NOCAR_HB d1
group by
d1.`uwConclueDate`
,d1.`LEVEL1COMCODE`
,d1.`LEVEL2COMCODE`
,d1.`LEVEL3COMCODE`
,d1.`LEVEL4COMCODE`
,d1.`risk`
) s1
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 (
SELECT
d1.`uwConclueDate` as `uwConclueDate`
,d1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,d1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,d1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,d1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
,d1.`risk` as `risk`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `cost`
from VIEW_ZB_DM_NOCAR_HB d1
group by
d1.`uwConclueDate`
,d1.`LEVEL1COMCODE`
,d1.`LEVEL2COMCODE`
,d1.`LEVEL3COMCODE`
,d1.`LEVEL4COMCODE`
,d1.`risk`
) s1
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 (
SELECT
d1.`uwConclueDate` as `uwConclueDate`
,d1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,d1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,d1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,d1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
,d1.`risk` as `risk`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `cost`
from VIEW_ZB_DM_NOCAR_HB d1
group by
d1.`uwConclueDate`
,d1.`LEVEL1COMCODE`
,d1.`LEVEL2COMCODE`
,d1.`LEVEL3COMCODE`
,d1.`LEVEL4COMCODE`
,d1.`risk`
) s1
;
\ No newline at end of file
...@@ -24,7 +24,7 @@ from ( ...@@ -24,7 +24,7 @@ from (
and `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') and `uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
) s1 ) s1
where s1.rownum = 1 where s1.rownum = 1
and left(s1.risk,2) <>'05'
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`LEVEL1COMCODE` ,s1.`LEVEL1COMCODE`
...@@ -49,7 +49,6 @@ select ...@@ -49,7 +49,6 @@ select
) as `key` ) as `key`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val` ,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_QDBF_NOCAR_TUANDUI s1 from VIEW_ZB_DM_QDBF_NOCAR_TUANDUI s1
where left(s1.risk,2) <>'05'
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
; ;
...@@ -64,7 +63,6 @@ select ...@@ -64,7 +63,6 @@ select
,s1.`LEVEL1COMCODE` as `hkey` ,s1.`LEVEL1COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val` ,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_QDBF_NOCAR_TUANDUI s1 from VIEW_ZB_DM_QDBF_NOCAR_TUANDUI s1
where left(s1.risk,2) <>'05'
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`LEVEL1COMCODE` ,s1.`LEVEL1COMCODE`
...@@ -80,7 +78,6 @@ select ...@@ -80,7 +78,6 @@ select
,s1.`LEVEL2COMCODE` as `hkey` ,s1.`LEVEL2COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val` ,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_QDBF_NOCAR_TUANDUI s1 from VIEW_ZB_DM_QDBF_NOCAR_TUANDUI s1
where left(s1.risk,2) <>'05'
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`LEVEL2COMCODE` ,s1.`LEVEL2COMCODE`
...@@ -97,7 +94,6 @@ select ...@@ -97,7 +94,6 @@ select
,s1.`LEVEL3COMCODE` as `hkey` ,s1.`LEVEL3COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val` ,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_QDBF_NOCAR_TUANDUI s1 from VIEW_ZB_DM_QDBF_NOCAR_TUANDUI s1
where left(s1.risk,2) <>'05'
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`LEVEL3COMCODE` ,s1.`LEVEL3COMCODE`
...@@ -114,6 +110,5 @@ select ...@@ -114,6 +110,5 @@ select
,s1.`LEVEL4COMCODE` as `hkey` ,s1.`LEVEL4COMCODE` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val` ,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_QDBF_NOCAR_TUANDUI s1 from VIEW_ZB_DM_QDBF_NOCAR_TUANDUI s1
where left(s1.risk,2) <>'05'
; ;
\ No newline at end of file
-- ZB_CHECK_HB ZB_CHECK_生产数据核对
-- SET_DECIMAL_CHECK SET格式DECIMAL数值存储核对 -- SET_DECIMAL_CHECK SET格式DECIMAL数值存储核对
insert into ZB_DM.ZB_CK_RESULT.ZB_CK insert into ZB_DM.ZB_CK_MYSQL.ZB_CK_RESULT
select select
case when s1.`key` is null then concat(s2.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss')) case when s1.`key` is null then concat(s2.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss'))
else concat(s1.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss') else concat(s1.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss'))
end AS id end AS id
,s1.`key` AS current_key ,s1.`key` AS current_key
,s1.`val` AS current_val ,s1.`val` AS current_val
...@@ -16,7 +19,7 @@ select ...@@ -16,7 +19,7 @@ select
from ZB_ODS.ZB_DM_REDIS.SET_DECIMAL s1 from ZB_ODS.ZB_DM_REDIS.SET_DECIMAL s1
full outer join ZB_ODS.ZB_DM_REDIS_PRD.SET_DECIMAL s2 on s1.`key` = s2.`key` full outer join ZB_ODS.ZB_DM_REDIS_PRD.SET_DECIMAL s2 on s1.`key` = s2.`key`
where case when s1.`key` is null then SPLIT_INDEX(s2.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') where case when s1.`key` is null then SPLIT_INDEX(s2.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
when s1.`key` is not null then SPLIT_INDEX(s1.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') else SPLIT_INDEX(s1.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
end end
AND case when s1.`key` is null then s2.`key` regexp'allqdbf/|allcarqdbf/|allnocarqdbf/|allqbbf/|allmonthqbbf/|allmonthqbbf/|allquarterqdbf/|xxzbf/' || AND case when s1.`key` is null then s2.`key` regexp'allqdbf/|allcarqdbf/|allnocarqdbf/|allqbbf/|allmonthqbbf/|allmonthqbbf/|allquarterqdbf/|xxzbf/' ||
'xxzbf/|xxzbf/' 'xxzbf/|xxzbf/'
...@@ -28,22 +31,22 @@ where case when s1.`key` is null then SPLIT_INDEX(s2.`key`,'/',1) = DATE_FORMAT( ...@@ -28,22 +31,22 @@ where case when s1.`key` is null then SPLIT_INDEX(s2.`key`,'/',1) = DATE_FORMAT(
-- SET_VARCHAR_CHECK SET格式VARCHAR数值存储核对 -- SET_VARCHAR_CHECK SET格式VARCHAR数值存储核对
insert into ZB_DM.ZB_CK_RESULT.ZB_CK insert into ZB_DM.ZB_CK_MYSQL.ZB_CK_RESULT
select select
case when s1.`key` is null then concat(s2.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss')) case when s1.`key` is null then concat(s2.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss'))
else concat(s1.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss') else concat(s1.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss'))
end AS id end AS id
,s1.`key` AS current_key ,s1.`key` AS current_key
,s1.`val` AS current_val ,s1.`val` AS current_val
,s2.`key` AS actual_key ,s2.`key` AS actual_key
,s2.`val` AS actual_val ,s2.`val` AS actual_val
,case when s1.`val` = s2.`val` then '是' ,case when MD5(s1.`val`) = MD5(s2.`val`) then '是'
else '否' else '否'
end AS ifSign end AS ifSign
from ZB_ODS.ZB_DM_REDIS.SET_VARCHAR s1 from ZB_ODS.ZB_DM_REDIS.SET_VARCHAR s1
full outer join ZB_ODS.ZB_DM_REDIS_PRD.SET_VARCHAR s2 on s1.`key` = s2.`key` full outer join ZB_ODS.ZB_DM_REDIS_PRD.SET_VARCHAR s2 on s1.`key` = s2.`key`
where case when s1.`key` is null then SPLIT_INDEX(s2.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') where case when s1.`key` is null then SPLIT_INDEX(s2.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
when s1.`key` is not null then SPLIT_INDEX(s1.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') else SPLIT_INDEX(s1.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
end end
AND case when s1.`key` is null then s2.`key` regexp'bigcbd/|bigfcbd/|allrybf/|bigclpbdt/|bigfclpbdt/|bigccitybd/|bigfccitybd/|provrybf/|bigcitylpbdt/|bigfcitylpbdt/' || AND case when s1.`key` is null then s2.`key` regexp'bigcbd/|bigfcbd/|allrybf/|bigclpbdt/|bigfclpbdt/|bigccitybd/|bigfccitybd/|provrybf/|bigcitylpbdt/|bigfcitylpbdt/' ||
'|bigfcitylpbdt/|bigfccountrybd/|cityrybf/|bigcountrylpbdt/|bigfcountrylpbdt/' '|bigfcitylpbdt/|bigfccountrybd/|cityrybf/|bigcountrylpbdt/|bigfcountrylpbdt/'
...@@ -54,25 +57,25 @@ where case when s1.`key` is null then SPLIT_INDEX(s2.`key`,'/',1) = DATE_FORMAT( ...@@ -54,25 +57,25 @@ where case when s1.`key` is null then SPLIT_INDEX(s2.`key`,'/',1) = DATE_FORMAT(
-- HSET_DECIMAL_CHECK HSET格式DECIMAL数值存储核对 -- HSET_DECIMAL_CHECK HSET格式DECIMAL数值存储核对
insert into ZB_DM.ZB_CK_RESULT.ZB_CK insert into ZB_DM.ZB_CK_MYSQL.ZB_CK_RESULT
select select
case when s1.`key` is null then concat(s2.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss')) case when s1.`key` is null then concat(s2.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss'))
else concat(s1.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss') else concat(s1.`key`,DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMddHHmmss'))
end AS id end AS id
,s1.`key` AS current_key ,s1.`key` AS current_key
,s1.`hkey` AS current_hkey ,s1.`hkey` AS current_hkey
,s1.`val` AS current_val ,s1.`val` AS current_val
,s2.`key` AS actual_key ,s2.`key` AS actual_key
,s2.`hkey` AS actual_hkey ,s2.`hkey` AS actual_hkey
,s2.`val` AS actual_val ,s2.`val` AS actual_val
,cast(cast (s1.`val` as decimal (18,2)) - cast (s2.`val` as decimal (18,2)) as varchar ) AS poorVal ,cast(cast (s1.`val` as decimal (18,2)) - cast (s2.`val` as decimal (18,2)) as varchar ) AS poorVal
,case when (cast (s1.`val` as decimal (18,2)) - cast (s2.`val` as decimal (18,2))) = 0 then '是' ,case when (cast (s1.`val` as decimal (18,2)) - cast (s2.`val` as decimal (18,2))) = 0 then '是'
else '否' else '否'
end AS ifSign end AS ifSign
from ZB_ODS.ZB_DM_REDIS.HSET_DECIMAL s1 from ZB_ODS.ZB_DM_REDIS.HSET_DECIMAL s1
full outer join ZB_ODS.ZB_DM_REDIS_PRD.HSET_DECIMAL s2 on s1.`key` = s2.`key` full outer join ZB_ODS.ZB_DM_REDIS_PRD.HSET_DECIMAL s2 on s1.`key` = s2.`key`
where case when s1.`key` is null then SPLIT_INDEX(s2.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') where case when s1.`key` is null then SPLIT_INDEX(s2.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
when s1.`key` is not null then SPLIT_INDEX(s1.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') else SPLIT_INDEX(s1.`key`,'/',1) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
end end
AND case when s1.`key` is null then s2.`key` regexp'allxlbf/|chnlbf/|alldayywlybf/|allmonthywlybf/|allquarterywlybf/|allywlybf/|xxzdaybf/|xxzmonthbf/|' || AND case when s1.`key` is null then s2.`key` regexp'allxlbf/|chnlbf/|alldayywlybf/|allmonthywlybf/|allquarterywlybf/|allywlybf/|xxzdaybf/|xxzmonthbf/|' ||
'xxzquarterbf/|xxzyearbf/|allyjxlbf/|chnlyjbf/|allwjxlbf/|chnlwjbf/|provqdbf/|provcarqdbf/|provnocarqdbf/|' || 'xxzquarterbf/|xxzyearbf/|allyjxlbf/|chnlyjbf/|allwjxlbf/|chnlwjbf/|provqdbf/|provcarqdbf/|provnocarqdbf/|' ||
......
-- zb_ck 指标计算测试生产数据核对 -- zb_ck 指标计算测试生产数据核对
create table zb_ck( create table ZB_CK_RESULT(
`id` varchar(256) , `id` varchar(256) ,
`current_key` varchar(256) , `current_key` varchar(256) ,
`current_hkey` varchar(256) , `current_hkey` varchar(256) ,
......
...@@ -24,7 +24,7 @@ from ( ...@@ -24,7 +24,7 @@ from (
from ZB_ODS.ZB_ODS_KAFKA.LPDATA from ZB_ODS.ZB_ODS_KAFKA.LPDATA
where `COMNAME` is not null where `COMNAME` is not null
and `flag` = 'wj' and `flag` = 'wj'
and LEFT(`setdate`,8) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') and LEFT(`setdate`,8) = '20220824'
group by group by
`setdate` `setdate`
,`LEVEL1COMCODE` ,`LEVEL1COMCODE`
......
...@@ -20,7 +20,7 @@ from ( ...@@ -20,7 +20,7 @@ from (
from ZB_ODS.ZB_ODS_KAFKA.LPDATA from ZB_ODS.ZB_ODS_KAFKA.LPDATA
where where
`COMNAME` is not null `COMNAME` is not null
and LEFT(`setdate`,8) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') and LEFT(`setdate`,8) = '20220824'
) s1 ) s1
where s1.`flag`= 'yj' where s1.`flag`= 'yj'
group by group by
......
...@@ -19,7 +19,7 @@ from ( ...@@ -19,7 +19,7 @@ from (
from ZB_ODS.ZB_ODS_KAFKA.LPDATA from ZB_ODS.ZB_ODS_KAFKA.LPDATA
where where
`COMNAME` is not null `COMNAME` is not null
and LEFT(`setdate`,8) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd') and LEFT(`setdate`,8) = '20220824'
) s1 ) s1
where s1.`flag`= 'wj' where s1.`flag`= 'wj'
group by group by
......
...@@ -42,8 +42,8 @@ select ...@@ -42,8 +42,8 @@ select
,s1.log_time as log_time ,s1.log_time as log_time
from ( from (
select select
LongTimeToStringUDF(uwConclueDate,'yyyyMMdd HH:mm:ss') as uwConclueDate -- 核保通过时间 LongTimeToStringUDF(uwConclueDate,'yyyyMMdd') as uwConclueDate -- 核保通过时间
,LongTimeToStringUDF(startTime,'yyyyMMdd HH:mm:ss') as startTime -- 起保时间 ,LongTimeToStringUDF(startTime,'yyyyMMdd') as startTime -- 起保时间
,businessOffice as businessOffice -- 保单归属机构代码 ,businessOffice as businessOffice -- 保单归属机构代码
,productCode as productCode -- 险种代码 ,productCode as productCode -- 险种代码
,businessChannelCode as businessChannelCode -- 业务渠道 ,businessChannelCode as businessChannelCode -- 业务渠道
...@@ -77,8 +77,8 @@ from ( ...@@ -77,8 +77,8 @@ from (
) )
union all union all
select select
LongTimeToStringUDF(uwConclueDate,'yyyyMMdd HH:mm:ss') as uwConclueDate -- 核保通过时间 ?? LongTimeToStringUDF(uwConclueDate,'yyyyMMdd') as uwConclueDate -- 核保通过时间 ??
,LongTimeToStringUDF(plpEndorse.endorseEffectiveTime,'yyyyMMdd HH:mm:ss') as startTime -- 起保时间 ,LongTimeToStringUDF(plpEndorse.endorseEffectiveTime,'yyyyMMdd') as startTime -- 起保时间
,businessOffice as businessOffice -- 保单归属机构代码 ,businessOffice as businessOffice -- 保单归属机构代码
,productCode as productCode -- 险种代码 ,productCode as productCode -- 险种代码
,businessChannelCode as businessChannelCode -- 业务渠道 ,businessChannelCode as businessChannelCode -- 业务渠道
......
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