Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dataquality_doc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王东
dataquality_doc
Commits
d9aa22fb
Commit
d9aa22fb
authored
Oct 25, 2022
by
胡涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
指标计算(函数自增)sql脚本
parent
b4727d91
Changes
33
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
4778 additions
and
3371 deletions
+4778
-3371
ZB_DM/承保指标/方案四(函数自增)/ZB_DM_归属人员和大单.sql
ZB_DM/承保指标/方案四(函数自增)/ZB_DM_归属人员和大单.sql
+574
-0
ZB_DM/承保指标/方案四(函数自增)/ZB_DM_承保合并.sql
ZB_DM/承保指标/方案四(函数自增)/ZB_DM_承保合并.sql
+1524
-0
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单(合并).sql
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单(合并).sql
+199
-238
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单今年待起保保费.sql
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单今年待起保保费.sql
+0
-94
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单今日待起保保费.sql
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单今日待起保保费.sql
+0
-95
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单保费.sql
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单保费.sql
+0
-92
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单季度末待起保保费.sql
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单季度末待起保保费.sql
+0
-119
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单月底前起保保费.sql
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单月底前起保保费.sql
+0
-94
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源(合并).sql
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源(合并).sql
+179
-268
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源季末前起保保费.sql
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源季末前起保保费.sql
+0
-130
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源年底前起保保费.sql
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源年底前起保保费.sql
+0
-110
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源当日签单当日起保保费.sql
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源当日签单当日起保保费.sql
+0
-111
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源月底前起保保费.sql
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源月底前起保保费.sql
+0
-109
ZB_DM/承保指标/方案四(函数自增)/分险类渠道/ZB_DM_分险类渠道保费合并.sql
ZB_DM/承保指标/方案四(函数自增)/分险类渠道/ZB_DM_分险类渠道保费合并.sql
+79
-120
ZB_DM/承保指标/方案四(函数自增)/归属业务人员/ZB_DM_归属业务人员当日签单保费排名.sql
ZB_DM/承保指标/方案四(函数自增)/归属业务人员/ZB_DM_归属业务人员当日签单保费排名.sql
+74
-157
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单(合并).sql
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单(合并).sql
+190
-234
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费.sql
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费.sql
+0
-95
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费季度末前起保.sql
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费季度末前起保.sql
+0
-124
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费年底前起保.sql
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费年底前起保.sql
+0
-100
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费当日签单当日起保.sql
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费当日签单当日起保.sql
+0
-100
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费月底前起保.sql
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费月底前起保.sql
+0
-100
ZB_DM/承保指标/方案四(函数自增)/车险/ZB_DM_承保车险(合并).sql
ZB_DM/承保指标/方案四(函数自增)/车险/ZB_DM_承保车险(合并).sql
+115
-150
ZB_DM/承保指标/方案四(函数自增)/车险/ZB_DM_车险今日签单保费.sql
ZB_DM/承保指标/方案四(函数自增)/车险/ZB_DM_车险今日签单保费.sql
+0
-95
ZB_DM/承保指标/方案四(函数自增)/车险/ZB_DM_车险承保大单.sql
ZB_DM/承保指标/方案四(函数自增)/车险/ZB_DM_车险承保大单.sql
+0
-235
ZB_DM/承保指标/方案四(函数自增)/非车险/ZB_DM_承保非车险(合并).sql
ZB_DM/承保指标/方案四(函数自增)/非车险/ZB_DM_承保非车险(合并).sql
+115
-146
ZB_DM/承保指标/方案四(函数自增)/非车险/ZB_DM_非车险今日签单保费.sql
ZB_DM/承保指标/方案四(函数自增)/非车险/ZB_DM_非车险今日签单保费.sql
+0
-95
ZB_DM/承保指标/方案四(函数自增)/非车险/ZB_DM_非车险承保大单.sql
ZB_DM/承保指标/方案四(函数自增)/非车险/ZB_DM_非车险承保大单.sql
+0
-160
ZB_DM/理赔指标/方案四(函数自增)/ZB_DM_理赔合并.sql
ZB_DM/理赔指标/方案四(函数自增)/ZB_DM_理赔合并.sql
+551
-0
ZB_DM/理赔指标/方案四(函数自增)/ZB_DM_理赔大单.sql
ZB_DM/理赔指标/方案四(函数自增)/ZB_DM_理赔大单.sql
+316
-0
ZB_DM/理赔指标/方案四(函数自增)/已决赔款/ZB_DM_已决赔款(合并).sql
ZB_DM/理赔指标/方案四(函数自增)/已决赔款/ZB_DM_已决赔款(合并).sql
+274
-0
ZB_DM/理赔指标/方案四(函数自增)/未决赔款/ZB_DM_未决赔款(合并).sql
ZB_DM/理赔指标/方案四(函数自增)/未决赔款/ZB_DM_未决赔款(合并).sql
+272
-0
ZB_DM/理赔指标/方案四(函数自增)/车险/ZB_DM_车险未决大单.sql
ZB_DM/理赔指标/方案四(函数自增)/车险/ZB_DM_车险未决大单.sql
+158
-0
ZB_DM/理赔指标/方案四(函数自增)/非车险/ZB_DM_非车险未决大单.sql
ZB_DM/理赔指标/方案四(函数自增)/非车险/ZB_DM_非车险未决大单.sql
+158
-0
No files found.
ZB_DM/承保指标/方案四(函数自增)/ZB_DM_归属人员和大单.sql
0 → 100644
View file @
d9aa22fb
-- ZB_DM_GSDD ZB_DM_承保归属人员和大单
-- ZB_DM_GSYWRNQNBFPM ZB_DM_归属业务人员当日签单保费排名
-- allrybf/日期
-- 取TOP20 按代理人当天出单保费和排序
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'allrybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
topNUDF
(
CONCAT
(
'allrybf/'
,
s1
.
`uwConclueDate`
)
,
cast
(
s1
.
`cost`
AS
VARCHAR
)
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'id'
,
':'
,
`id`
,
','
,
'name'
,
':'
,
`name`
,
','
,
'cost'
,
':'
,
`cost`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`id`
as
`id`
,
d1
.
`name`
as
`name`
,
cast
(
d1
.
`cost`
AS
VARCHAR
)
as
`cost`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
`COMNAME`
is
not
null
and
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
)
s1
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'provrybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'provrybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
cast
(
s1
.
`cost`
AS
VARCHAR
)
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
,
'id'
,
':'
,
`id`
,
','
,
'name'
,
':'
,
`name`
,
','
,
'cost'
,
':'
,
`cost`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`id`
as
`id`
,
d1
.
`name`
as
`name`
,
cast
(
d1
.
`cost`
AS
VARCHAR
)
as
`cost`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
`COMNAME`
is
not
null
and
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
)
s1
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'cityrybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'cityrybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
cast
(
s1
.
`cost`
AS
VARCHAR
)
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
,
'country'
,
':'
,
`country`
,
','
,
'countryname'
,
':'
,
`countryname`
,
','
,
'id'
,
':'
,
`id`
,
','
,
'name'
,
':'
,
`name`
,
','
,
'cost'
,
':'
,
`cost`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`id`
as
`id`
,
d1
.
`name`
as
`name`
,
cast
(
d1
.
`cost`
AS
VARCHAR
)
as
`cost`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
`COMNAME`
is
not
null
and
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
)
s1
;
-- ZB_DM_CAR_HB ZB_DM_承保车险合并
-- 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`
,
cast
(
sumZBUDF
(
CONCAT
(
'allcarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
=
'05'
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provcarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provcarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
=
'05'
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citycarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citycarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
=
'05'
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countycarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countycarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
=
'05'
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamcarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countycarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
=
'05'
;
-- ZB_DM_CXCBDD ZB_DM_车险承保大单
-- bigcbd/日期
-- 核保或者核批时间在今天,按照保费或者未决赔款排序,取前10,车险riskcode 05开头,其他为非车,
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigcbd/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigcbd/'
,
s1
.
`uwConclueDate`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
=
'05'
)
s1
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
=
'05'
)
s1
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
,
'country'
,
':'
,
`country`
,
','
,
'countryname'
,
':'
,
`countryname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
=
'05'
)
s1
;
-- ZB_DM_NOCAR_HB ZB_DM_承保非车险合并
-- 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`
,
cast
(
sumZBUDF
(
CONCAT
(
'allnocarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
<>
'05'
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provnocarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provnocarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
<>
'05'
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citynocarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citynocarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
<>
'05'
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countynocarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countynocarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
<>
'05'
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamnocarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countynocarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
<>
'05'
;
-- ZB_DM_FCXCBDD ZB_DM_非车险承保大单
-- bigfcbd/日期
-- 核保或者核批时间在今天,按照保费或者未决赔款排序,取前10,车险riskcode 05开头,其他为非车,
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfcbd/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfcbd/'
,
s1
.
`uwConclueDate`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
s1
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
s1
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
,
'country'
,
':'
,
`country`
,
','
,
'countryname'
,
':'
,
`countryname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
s1
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/ZB_DM_承保合并.sql
0 → 100644
View file @
d9aa22fb
-- ZB_DM_CBHB ZB_DM_承保合并
-- ZB_DM_JRQDBF ZB_DM_今日签单保费
-- key:allqdbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- sumZBUDF 数据累加 入参(key String ,cost String , date String)
-- sumZBUDF 通过date自动清除前一天数据,key为当前数据唯一主键,cost为需要累加的数据值
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- ZB_DM_JRQDJNQBBF ZB_DM_今日签单今年待起保保费
-- key:allqbbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当年
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 中支 cityqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 县支 countryqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 团队 teamqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- ZB_DM_JRQDJDMQBBF ZB_DM_今日签单季度末待起保保费
-- key:allquarterqdbf
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当季度
-- 总公司 allquarterqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allquarterqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
-- 核保时间在今天并且起保时间的月份小于等于季度。
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 分公司 provquarterqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provquarterqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
-- 核保时间在今天并且起保时间的月份小于等于季度。
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 中支 cityquarterqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityquarterqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
-- 核保时间在今天并且起保时间的月份小于等于季度。
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 县支 countyquarterqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countyquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countyquarterqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
-- 核保时间在今天并且起保时间的月份小于等于季度。
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 团队 teamquarterqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamquarterqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
-- 核保时间在今天并且起保时间的月份小于等于季度。
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- ZB_DM_JRQDYDQQBBF ZB_DM_今日签单月底前起保保费
-- key:allmonthqbbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当月
-- 总公司 allmonthqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allmonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allmonthqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 分公司 provmonthqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provmonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provmonthqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 中支 citymonthqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citymonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citymonthqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 县支 countrymonthqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrymonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countrymonthqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 团队 teammonthqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teammonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teammonthqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- ZB_DM_JRQDJRQBBF ZB_DM_今日签单今日待起保保费
-- key:alldayqdbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当日
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'alldayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'alldayqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provdayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provdayqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 中支 citydayqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citydayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citydayqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 县支 countrydayqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrydayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countrydayqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 团队 teamdayqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamdayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamdayqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- ZB_DM_FYWLYBF_HB ZB_DM_分业务来源起保保费合并
-- ZB_DM_FYWLYBFNDQQB ZB_DM_分业务来源年底前起保保费
-- key:allywlybf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当年
-- 总公司 allywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allywlybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 分公司 provywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 中支 cityywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 县支 countryywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 团队 teamywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- ZB_DM_FYWLYBFJMQQB ZB_DM_分业务来源季末前起保保费
-- key:allquarterywlybf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当季度
-- 总公司 allquarterywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allquarterywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allquarterywlybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 分公司 provquarterywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 中支 cityquarterywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 县支 countryquarterywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 团队 teamquarterywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- ZB_DM_FYWLYBFYDQQB ZB_DM_分业务来源月底前起保保费
-- key:allmonthywlybf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当月
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allmonthywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allmonthywlybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 分公司 provmonthywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provmonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provmonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 中支 citymonthywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 县支 countrymonthywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countrymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 团队 teammonthywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teammonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teammonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- ZB_DM_FYWLYBFDRQDDRQB ZB_DM_分业务来源当日签单当日起保保费
-- key:alldayywlybf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间等于当日
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'alldayywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'alldayywlybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 分公司 provdayywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 中支 citydayywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 县支 countrydayywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countrydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 团队 teamdayywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- ZB_DM_FXLQDBF_HB ZB_DM_分险类渠道保费合并
-- ZB_DM_FXLBF ZB_DM_分险类保费
-- allxlbf/日期 险类代码
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当年
--总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allxlbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allxlbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 分公司 provxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 中支 cityxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 县支 countryxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 团队 teamxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- ZB_DM_FQDBF ZB_DM_分渠道保费
-- chnlbf/日期/00000000 渠道代码
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当年
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlbf/'
,
s1
.
`uwConclueDate`
,
'/00000000'
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlbf/'
,
s1
.
`uwConclueDate`
,
'/00000000'
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 中支 citychnlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citychnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citychnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 县支 countrychnlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrychnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countrychnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 团队 teamchnlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamchnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamchnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- ZB_DM_XXZBDBF_HB ZB_DM_新续转保单保费合并
-- ZB_DM_XXZBDBF ZB_DM_新续转保单保费
-- key:xxzbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、新续转保得保单
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'xxzbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
;
-- 分公司 provxxzbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxxzbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
;
-- 中支 cityxxzbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxxzbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
;
-- 县支 countryxxzbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxxzbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
;
-- 团队 teamxxzbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxxzbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
;
-- ZB_DM_XXZBDBFNDQQB ZB_DM_新续转保单保费年底前起保
-- key:xxzyearbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、新续转保得保单
-- 3、起保时间小于等于今年
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'xxzyearbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 分公司 provxxzyearbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxxzyearbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 中支 cityxxzyearbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxxzyearbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 县支 countryxxzyearbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxxzyearbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- 团队 teamxxzyearbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxxzyearbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
;
-- ZB_DM_XXZBDBFJDMQQB ZB_DM_新续转保单保费季度末前起保
-- key:xxzquarterbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、新续转保得保单
-- 2、起保时间的季度小于等于当前季度
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'xxzquarterbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
-- 起保时间的季度小于等于当前季度
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
-- 起保时间的季度小于等于当前季度
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 中支 cityxxzquarterbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
-- 起保时间的季度小于等于当前季度
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 县支 countryxxzquarterbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
-- 起保时间的季度小于等于当前季度
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 团队 teamxxzquarterbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
-- 起保时间的季度小于等于当前季度
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- ZB_DM_XXZBDBFYDQQBYDQQB ZB_DM_新续转保单保费月底前起保
-- key:xxzmonthbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、新续转保得保单
-- 3、起保时间小于等于当月
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'xxzmonthbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 分公司 provxxzmonthbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 中支 cityxxzmonthbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 县支 countryxxzmonthbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- 团队 teamxxzmonthbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
;
-- ZB_DM_XXZBDBFDRQDDRQB ZB_DM_新续转保单保费当日签单当日起保
-- key:xxzdaybf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、新续转保得保单
-- 3、起保时间等于今天
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'xxzdaybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 分公司 provxxzdaybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxxzdaybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 中支 cityxxzdaybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxxzdaybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 县支 countryxxzdaybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxxzdaybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 团队 teamxxzdaybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxxzdaybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单(合并).sql
View file @
d9aa22fb
...
...
@@ -2,7 +2,7 @@
-- ZB_DM_JRQDBF ZB_DM_今日签单保费
-- ZB_DM_JRQDBF ZB_DM_今日签单保费
-- key:allqdbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
...
...
@@ -13,11 +13,11 @@
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sumZBUDF
(
CONCAT
(
'allqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
`val`
,
cast
(
sumZBUDF
(
CONCAT
(
'allqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
...
...
@@ -27,73 +27,66 @@ and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
CONCAT
(
'provqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
,
cast
(
sumZBUDF
(
CONCAT
(
'provqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'cityqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 县支
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countryqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
;
-- 团队
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
...
...
@@ -107,91 +100,83 @@ group by
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'allqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
cityqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'cityqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countryqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countryqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
...
...
@@ -201,14 +186,15 @@ group by
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当季度
-- 总公司
-- 总公司
allquarterqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'allquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allquarterqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
...
...
@@ -218,19 +204,18 @@ where s1.`COMNAME` is not null
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
;
-- 分公司
-- 分公司
provquarterqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provquarterqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
...
...
@@ -240,20 +225,18 @@ where s1.`COMNAME` is not null
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
cityquarterqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'cityquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityquarterqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
...
...
@@ -263,21 +246,19 @@ where s1.`COMNAME` is not null
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countyquarterqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countyquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countyquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countyquarterqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
...
...
@@ -287,21 +268,19 @@ where s1.`COMNAME` is not null
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamquarterqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamquarterqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
...
...
@@ -311,110 +290,102 @@ where s1.`COMNAME` is not null
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
-- ZB_DM_JRQDYDQQBBF ZB_DM_今日签单月底前起保保费
-- key:allmonthqbbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当月
-- 总公司
-- 总公司
allmonthqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allmonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'allmonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allmonthqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
-- 分公司 provmonthqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provmonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provmonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provmonthqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
citymonthqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citymonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'citymonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citymonthqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countrymonthqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrymonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countrymonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countrymonthqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teammonthqbbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teammonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teammonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teammonthqbbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
-- ZB_DM_JRQDJRQBBF ZB_DM_今日签单今日待起保保费
-- key:alldayqdbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
...
...
@@ -423,91 +394,81 @@ group by
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'alldayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'alldayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'alldayqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provdayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provdayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provdayqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
citydayqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citydayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'citydayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citydayqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countrydayqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrydayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countrydayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countrydayqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamdayqdbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamdayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamdayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamdayqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单今年待起保保费.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_JRQDJNQBBF ZB_DM_今日签单今年待起保保费
-- key:allqbbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当年
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单今日待起保保费.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_JRQDJRQBBF ZB_DM_今日签单今日待起保保费
-- key:alldayqdbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当日
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'alldayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provdayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citydayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrydayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamdayqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单保费.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_JRQDBF ZB_DM_今日签单保费
-- key:allqdbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单季度末待起保保费.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_JRQDJDMQBBF ZB_DM_今日签单季度末待起保保费
-- key:allquarterqdbf
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当季度
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
-- 核保时间在今天并且起保时间的月份小于等于季度。
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
-- 核保时间在今天并且起保时间的月份小于等于季度。
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
-- 核保时间在今天并且起保时间的月份小于等于季度。
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countyquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
-- 核保时间在今天并且起保时间的月份小于等于季度。
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamquarterqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
-- 核保时间在今天并且起保时间的月份小于等于季度。
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
ZB_DM/承保指标/方案四(函数自增)/今日签单/ZB_DM_今日签单月底前起保保费.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_JRQDYDQQBBF ZB_DM_今日签单月底前起保保费
-- key:allmonthqbbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当月
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allmonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provmonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citymonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrymonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teammonthqbbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源(合并).sql
View file @
d9aa22fb
...
...
@@ -7,109 +7,87 @@
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当年
-- 总公司
-- 总公司
allywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'allywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allywlybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
;
-- 分公司
-- 分公司
provywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
cityywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'cityywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countryywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countryywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL4COMCODE`
;
...
...
@@ -119,129 +97,108 @@ group by
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当季度
-- 总公司
-- 总公司
allquarterywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allquarterywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'allquarterywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allquarterywlybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 分公司
-- 分公司
provquarterywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL1COMCODE`
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 中支
-- 中支
cityquarterywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'cityquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL2COMCODE`
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 县支
-- 县支
countryquarterywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countryquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL3COMCODE`
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
-- 团队
-- 团队
teamquarterywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL4COMCODE`
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
;
...
...
@@ -254,106 +211,84 @@ group by
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allmonthywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'allmonthywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allmonthywlybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
;
-- 分公司
-- 分公司
provmonthywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provmonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provmonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provmonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
citymonthywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'citymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countrymonthywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countrymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countrymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teammonthywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teammonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teammonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teammonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL4COMCODE`
;
...
...
@@ -366,105 +301,82 @@ group by
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'alldayywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'alldayywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'alldayywlybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
;
-- 分公司
-- 分公司
provdayywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
citydayywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'citydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countrydayywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countrydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countrydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamdayywlybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源季末前起保保费.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_FYWLYBFJMQQB ZB_DM_分业务来源季末前起保保费
-- key:allquarterywlybf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当季度
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allquarterywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamquarterywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源年底前起保保费.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_FYWLYBFNDQQB ZB_DM_分业务来源年底前起保保费
-- key:allywlybf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当年
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源当日签单当日起保保费.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_FYWLYBFDRQDDRQB ZB_DM_分业务来源当日签单当日起保保费
-- key:alldayywlybf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间等于当日
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'alldayywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrydayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamdayywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/分业务来源/ZB_DM_分业务来源月底前起保保费.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_FYWLYBFYDQQB ZB_DM_分业务来源月底前起保保费
-- key:allmonthywlybf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、起保时间小于等于当月
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allmonthywlybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provmonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrymonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teammonthywlybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`businessNatureCode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`businessNatureCode`
,
s1
.
`LEVEL4COMCODE`
;
ZB_DM/承保指标/方案四(函数自增)/分险类渠道/ZB_DM_分险类渠道保费合并.sql
View file @
d9aa22fb
...
...
@@ -7,104 +7,84 @@
-- 2、起保时间小于等于当年
--总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allxlbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
select
CONCAT
(
'allxlbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allxlbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`classcode`
;
-- 分公司
-- 分公司
provxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`
classcode`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
select
CONCAT
(
'provxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost`
,
s1
.
`
uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`classcode`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
cityxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key
`
,
s1
.
`classcode`
as
`hkey
`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'cityxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost
`
,
s1
.
`uwConclueDate
`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`classcode`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countryxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key
`
,
s1
.
`classcode`
as
`hkey
`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countryxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost
`
,
s1
.
`uwConclueDate
`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`classcode`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key
`
,
s1
.
`classcode`
as
`hkey
`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost
`
,
s1
.
`uwConclueDate
`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`classcode`
,
s1
.
`LEVEL4COMCODE`
;
...
...
@@ -117,104 +97,84 @@ group by
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlbf/'
,
s1
.
`uwConclueDate`
,
'/00000000'
)
as
`key
`
,
s1
.
`chnl`
as
`hkey
`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'chnlbf/'
,
s1
.
`uwConclueDate`
,
'/00000000'
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlbf/'
,
s1
.
`uwConclueDate`
,
'/00000000'
)
,
s1
.
`cost
`
,
s1
.
`uwConclueDate
`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`chnl`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key
`
,
s1
.
`chnl`
as
`hkey
`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'chnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`cost
`
,
s1
.
`uwConclueDate
`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`chnl`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
citychnlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citychnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key
`
,
s1
.
`chnl`
as
`hkey
`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'citychnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citychnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`cost
`
,
s1
.
`uwConclueDate
`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`chnl`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countrychnlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countrychnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key
`
,
s1
.
`chnl`
as
`hkey
`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countrychnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countrychnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`cost
`
,
s1
.
`uwConclueDate
`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`chnl`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamchnlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamchnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key
`
,
s1
.
`chnl`
as
`hkey
`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamchnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamchnlbf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`cost
`
,
s1
.
`uwConclueDate
`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`chnl`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/归属业务人员/ZB_DM_归属业务人员当日签单保费排名.sql
View file @
d9aa22fb
...
...
@@ -7,135 +7,82 @@
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'allrybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'id'
,
':'
,
`id`
,
','
,
'name'
,
':'
,
`name`
,
','
,
'cost'
,
':'
,
cast
(
s1
.
`cost`
AS
VARCHAR
)
),
';'
)
)
as
`val`
CONCAT
(
'allrybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
topNUDF
(
CONCAT
(
'allrybf/'
,
s1
.
`uwConclueDate`
)
,
cast
(
s1
.
`cost`
AS
VARCHAR
)
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'id'
,
':'
,
`id`
,
','
,
'name'
,
':'
,
`name`
,
','
,
'cost'
,
':'
,
`cost`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`id`
as
`id`
,
d1
.
`name`
as
`name`
,
d1
.
`cost`
as
`cost`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
(
select
`uwConclueDate`
as
`uwConclueDate`
,
`LEVEL1COMCODE`
as
`LEVEL1COMCODE`
,
`LEVEL1COMDESC`
as
`LEVEL1COMDESC`
,
`id`
as
`id`
,
`name`
as
`name`
,
sum
(
cast
(
`cost`
as
DECIMAL
(
18
,
2
)))
as
`cost`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
where
`COMNAME`
is
not
null
and
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
`uwConclueDate`
,
`LEVEL1COMCODE`
,
`LEVEL1COMDESC`
,
`id`
,
`name`
)
d1
)
c1
where
c1
.
rownum
<=
20
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`id`
as
`id`
,
d1
.
`name`
as
`name`
,
cast
(
d1
.
`cost`
AS
VARCHAR
)
as
`cost`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
`COMNAME`
is
not
null
and
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
)
s1
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'provrybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
CONCAT
(
'provrybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'provrybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
cast
(
s1
.
`cost`
AS
VARCHAR
)
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
,
'id'
,
':'
,
`id`
,
','
,
'name'
,
':'
,
`name`
,
','
,
'cost'
,
':'
,
cast
(
s1
.
`cost`
AS
VARCHAR
)
),
';'
)
)
as
`val`
,
'cost'
,
':'
,
`cost`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`id`
as
`id`
,
d1
.
`name`
as
`name`
,
d1
.
`cost`
as
`cost`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
(
select
`uwConclueDate`
as
`uwConclueDate`
,
`LEVEL1COMCODE`
as
`LEVEL1COMCODE`
,
`LEVEL1COMDESC`
as
`LEVEL1COMDESC`
,
`LEVEL2COMCODE`
as
`LEVEL2COMCODE`
,
`LEVEL2COMDESC`
as
`LEVEL2COMDESC`
,
`id`
as
`id`
,
`name`
as
`name`
,
sum
(
cast
(
`cost`
as
DECIMAL
(
18
,
2
)))
as
`cost`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
where
`COMNAME`
is
not
null
and
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
`uwConclueDate`
,
`LEVEL1COMCODE`
,
`LEVEL1COMDESC`
,
`LEVEL2COMCODE`
,
`LEVEL2COMDESC`
,
`id`
,
`name`
)
d1
)
c1
where
c1
.
rownum
<=
20
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`id`
as
`id`
,
d1
.
`name`
as
`name`
,
cast
(
d1
.
`cost`
AS
VARCHAR
)
as
`cost`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
`COMNAME`
is
not
null
and
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
)
s1
group
by
s1
.
`uwConclueDate`
,
s1
.
`group_com`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'cityrybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
CONCAT
(
'cityrybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'cityrybf/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
cast
(
s1
.
`cost`
AS
VARCHAR
)
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
...
...
@@ -143,57 +90,27 @@ select
,
'countryname'
,
':'
,
`countryname`
,
','
,
'id'
,
':'
,
`id`
,
','
,
'name'
,
':'
,
`name`
,
','
,
'cost'
,
':'
,
cast
(
s1
.
`cost`
AS
VARCHAR
)
),
';'
)
)
as
`val`
,
'cost'
,
':'
,
`cost`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`id`
as
`id`
,
d1
.
`name`
as
`name`
,
d1
.
`cost`
as
`cost`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
(
select
`uwConclueDate`
as
`uwConclueDate`
,
`LEVEL1COMCODE`
as
`LEVEL1COMCODE`
,
`LEVEL1COMDESC`
as
`LEVEL1COMDESC`
,
`LEVEL2COMCODE`
as
`LEVEL2COMCODE`
,
`LEVEL2COMDESC`
as
`LEVEL2COMDESC`
,
`LEVEL3COMCODE`
as
`LEVEL3COMCODE`
,
`LEVEL3COMDESC`
as
`LEVEL3COMDESC`
,
`id`
as
`id`
,
`name`
as
`name`
,
sum
(
cast
(
`cost`
as
DECIMAL
(
18
,
2
)))
as
`cost`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
where
`COMNAME`
is
not
null
and
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
`uwConclueDate`
,
`LEVEL1COMCODE`
,
`LEVEL1COMDESC`
,
`LEVEL2COMCODE`
,
`LEVEL2COMDESC`
,
`LEVEL3COMCODE`
,
`LEVEL3COMDESC`
,
`id`
,
`name`
)
d1
)
c1
where
c1
.
rownum
<=
20
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`id`
as
`id`
,
d1
.
`name`
as
`name`
,
cast
(
d1
.
`cost`
AS
VARCHAR
)
as
`cost`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
`COMNAME`
is
not
null
and
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
)
s1
group
by
s1
.
`uwConclueDate`
,
s1
.
`group_com`
;
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单(合并).sql
View file @
d9aa22fb
...
...
@@ -9,91 +9,82 @@
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'xxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'xxzbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
group
by
s1
.
`uwConclueDate`
;
-- 分公司
-- 分公司
provxxzbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxxzbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
cityxxzbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
CONCAT
(
'cityxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxxzbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countryxxzbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countryxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxxzbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamxxzbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxxzbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
-- ZB_DM_XXZBDBFNDQQB ZB_DM_新续转保单保费年底前起保
...
...
@@ -105,95 +96,87 @@ group by
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'xxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'xxzyearbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
-- 分公司
provxxzyearbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxxzyearbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
cityxxzyearbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'cityxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxxzyearbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countryxxzyearbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countryxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxxzyearbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamxxzyearbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxxzyearbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
...
...
@@ -205,11 +188,12 @@ group by
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'xxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'xxzquarterbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
...
...
@@ -220,19 +204,18 @@ where s1.`COMNAME` is not null
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
...
...
@@ -243,21 +226,19 @@ where s1.`COMNAME` is not null
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
cityxxzquarterbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'cityxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
...
...
@@ -268,20 +249,18 @@ where s1.`COMNAME` is not null
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countryxxzquarterbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countryxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
...
...
@@ -292,20 +271,18 @@ where s1.`COMNAME` is not null
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamxxzquarterbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
...
...
@@ -316,9 +293,7 @@ where s1.`COMNAME` is not null
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
...
...
@@ -332,95 +307,86 @@ group by
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'xxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'xxzmonthbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
-- 分公司
provxxzmonthbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
cityxxzmonthbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'cityxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countryxxzmonthbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countryxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamxxzmonthbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
...
...
@@ -434,93 +400,84 @@ group by
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'xxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'xxzdaybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
-- 分公司
provxxzdaybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'provxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provxxzdaybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
-- 中支
cityxxzdaybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'cityxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityxxzdaybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
-- 县支
countryxxzdaybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'countryxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countryxxzdaybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
-- 团队
teamxxzdaybf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamxxzdaybf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_XXZBDBF ZB_DM_新续转保单保费
-- key:xxzbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、新续转保得保单
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费季度末前起保.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_XXZBDBFJDMQQB ZB_DM_新续转保单保费季度末前起保
-- key:xxzquarterbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、新续转保得保单
-- 2、起保时间的季度小于等于当前季度
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
-- 起保时间的季度小于等于当前季度
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
-- 起保时间的季度小于等于当前季度
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
-- 起保时间的季度小于等于当前季度
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
-- 起保时间的季度小于等于当前季度
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzquarterbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
-- 起保时间的季度小于等于当前季度
and
CASE
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'01'
,
'02'
,
'03'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'03'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'04'
,
'05'
,
'06'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'06'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'07'
,
'08'
,
'09'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'09'
)
WHEN
DATE_FORMAT
(
LOCALTIMESTAMP
,
'MM'
)
in
(
'10'
,
'11'
,
'12'
)
THEN
left
(
s1
.
`startTime`
,
6
)
<=
CONCAT
(
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
),
'12'
)
END
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费年底前起保.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_XXZBDBFNDQQB ZB_DM_新续转保单保费年底前起保
-- key:xxzyearbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、新续转保得保单
-- 3、起保时间小于等于今年
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzyearbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
4
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyy'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费当日签单当日起保.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_XXZBDBFDRQDDRQB ZB_DM_新续转保单保费当日签单当日起保
-- key:xxzdaybf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、新续转保得保单
-- 3、起保时间等于今天
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzdaybf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/新续转/ZB_DM_新续转保单保费月底前起保.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_XXZBDBFYDQQBYDQQB ZB_DM_新续转保单保费月底前起保
-- key:xxzmonthbf/日期
-- 1、日期:核保日期或者核批完成日期(yyyyMMdd)
-- 2、新续转保得保单
-- 3、起保时间小于等于当月
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'xxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL1COMCODE`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL2COMCODE`
;
-- 县支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countryxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL3COMCODE`
;
-- 团队
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamxxzmonthbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`xxzflag`
=
'1'
and
left
(
s1
.
`startTime`
,
6
)
<=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMM'
)
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/车险/ZB_DM_承保车险(合并).sql
View file @
d9aa22fb
...
...
@@ -10,91 +10,82 @@
-- 总公司
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`
CONCAT
(
'allcarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allcarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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`
CONCAT
(
'provcarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provcarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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`
CONCAT
(
'citycarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citycarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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`
CONCAT
(
'countycarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countycarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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`
CONCAT
(
'teamcarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
,
cast
(
sumZBUDF
(
CONCAT
(
'countycarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
=
'05'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
...
...
@@ -105,13 +96,12 @@ group by
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigcbd/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
CONCAT
(
'bigcbd/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigcbd/'
,
s1
.
`uwConclueDate`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
...
...
@@ -119,32 +109,26 @@ select
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
=
'05'
)
c1
where
c1
.
rownum
<=
20
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
=
'05'
)
s1
group
by
s1
.
`uwConclueDate`
;
...
...
@@ -152,14 +136,12 @@ group by
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
CONCAT
(
'bigccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
...
...
@@ -167,52 +149,43 @@ select
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`LEVEL1COMCODE`
,
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
=
'05'
)
c1
where
c1
.
rownum
<=
20
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
=
'05'
)
s1
group
by
s1
.
`uwConclueDate`
,
s1
.
`group_com`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
CONCAT
(
'bigccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
...
...
@@ -222,38 +195,31 @@ select
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
cast
(
`cost`
as
varchar
)
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`LEVEL2COMCODE`
,
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
=
'05'
)
c1
where
c1
.
rownum
<=
20
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
=
'05'
)
s1
group
by
s1
.
`uwConclueDate`
,
s1
.
`group_com`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/车险/ZB_DM_车险今日签单保费.sql
deleted
100644 → 0
View file @
b4727d91
-- 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
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
=
'05'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/车险/ZB_DM_车险承保大单.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_CXCBDD ZB_DM_车险承保大单
-- bigcbd/日期
-- 核保或者核批时间在今天,按照保费或者未决赔款排序,按保单的保费取前10,车险riskcode 05开头,其他为非车,
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigcbd/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
(
select
a1
.
`uwConclueDate`
as
`uwConclueDate`
,
a1
.
`LEVEL1COMCODE`
as
`LEVEL1COMCODE`
,
a1
.
`LEVEL1COMDESC`
as
`LEVEL1COMDESC`
,
a1
.
`risk`
as
`risk`
,
a1
.
`riskname`
as
`riskname`
,
a1
.
`chnl`
as
`chnl`
,
a1
.
`chnlname`
as
`chnlname`
,
sum
(
cast
(
a1
.
`cost`
as
decimal
(
18
,
2
)))
as
`cost`
,
a1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
a1
where
a1
.
`COMNAME`
is
not
null
and
a1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
a1
.
risk
,
2
)
=
'05'
group
by
a1
.
`uwConclueDate`
,
a1
.
`LEVEL1COMCODE`
,
a1
.
`LEVEL1COMDESC`
,
a1
.
`risk`
,
a1
.
`riskname`
,
a1
.
`chnl`
,
a1
.
`chnlname`
,
a1
.
`no`
)
d1
)
c1
where
c1
.
rownum
<=
20
)
s1
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`LEVEL1COMCODE`
,
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
(
select
a1
.
`uwConclueDate`
as
`uwConclueDate`
,
a1
.
`LEVEL1COMCODE`
as
`LEVEL1COMCODE`
,
a1
.
`LEVEL1COMDESC`
as
`LEVEL1COMDESC`
,
a1
.
`LEVEL2COMCODE`
as
`LEVEL2COMCODE`
,
a1
.
`LEVEL2COMDESC`
as
`LEVEL2COMDESC`
,
a1
.
`risk`
as
`risk`
,
a1
.
`riskname`
as
`riskname`
,
a1
.
`chnl`
as
`chnl`
,
a1
.
`chnlname`
as
`chnlname`
,
sum
(
cast
(
a1
.
`cost`
as
decimal
(
18
,
2
)))
as
`cost`
,
a1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
a1
where
a1
.
`COMNAME`
is
not
null
and
a1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
a1
.
risk
,
2
)
=
'05'
group
by
a1
.
`uwConclueDate`
,
a1
.
`LEVEL1COMCODE`
,
a1
.
`LEVEL1COMDESC`
,
a1
.
`LEVEL2COMCODE`
,
a1
.
`LEVEL2COMDESC`
,
a1
.
`risk`
,
a1
.
`riskname`
,
a1
.
`chnl`
,
a1
.
`chnlname`
,
a1
.
`no`
)
d1
)
c1
where
c1
.
rownum
<=
20
)
s1
group
by
s1
.
`uwConclueDate`
,
s1
.
`group_com`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
,
'country'
,
':'
,
`country`
,
','
,
'countryname'
,
':'
,
`countryname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
cast
(
`cost`
as
varchar
)
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`LEVEL2COMCODE`
,
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
(
select
a1
.
`uwConclueDate`
as
`uwConclueDate`
,
a1
.
`LEVEL1COMCODE`
as
`LEVEL1COMCODE`
,
a1
.
`LEVEL1COMDESC`
as
`LEVEL1COMDESC`
,
a1
.
`LEVEL2COMCODE`
as
`LEVEL2COMCODE`
,
a1
.
`LEVEL2COMDESC`
as
`LEVEL2COMDESC`
,
a1
.
`LEVEL3COMCODE`
as
`LEVEL3COMCODE`
,
a1
.
`LEVEL3COMDESC`
as
`LEVEL3COMDESC`
,
a1
.
`risk`
as
`risk`
,
a1
.
`riskname`
as
`riskname`
,
a1
.
`chnl`
as
`chnl`
,
a1
.
`chnlname`
as
`chnlname`
,
sum
(
cast
(
a1
.
`cost`
as
decimal
(
18
,
2
)))
as
`cost`
,
a1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
a1
where
a1
.
`COMNAME`
is
not
null
and
a1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
a1
.
risk
,
2
)
=
'05'
group
by
a1
.
`uwConclueDate`
,
a1
.
`LEVEL1COMCODE`
,
a1
.
`LEVEL1COMDESC`
,
a1
.
`LEVEL2COMCODE`
,
a1
.
`LEVEL2COMDESC`
,
a1
.
`LEVEL3COMCODE`
,
a1
.
`LEVEL3COMDESC`
,
a1
.
`risk`
,
a1
.
`riskname`
,
a1
.
`chnl`
,
a1
.
`chnlname`
,
a1
.
`no`
)
d1
)
c1
where
c1
.
rownum
<=
20
)
s1
group
by
s1
.
`uwConclueDate`
,
s1
.
`group_com`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/非车险/ZB_DM_承保非车险(合并).sql
View file @
d9aa22fb
...
...
@@ -10,91 +10,82 @@
-- 总公司
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`
CONCAT
(
'allnocarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allnocarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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`
CONCAT
(
'provnocarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provnocarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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`
CONCAT
(
'citynocarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citynocarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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`
CONCAT
(
'countynocarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
,
cast
(
sumZBUDF
(
CONCAT
(
'countynocarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
CONCAT
(
'teamnocarqdbf/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countynocarqdbf/'
,
s1
.
`uwConclueDate`
)
,
s1
.
`cost`
,
s1
.
`uwConclueDate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
<>
'05'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
...
...
@@ -105,12 +96,11 @@ group by
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfcbd/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
CONCAT
(
'bigfcbd/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfcbd/'
,
s1
.
`uwConclueDate`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
...
...
@@ -119,32 +109,26 @@ select
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
c1
where
c1
.
rownum
<=
20
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
s1
group
by
s1
.
`uwConclueDate`
;
...
...
@@ -152,14 +136,12 @@ group by
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
CONCAT
(
'bigfccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
...
...
@@ -169,50 +151,42 @@ select
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`LEVEL1COMCODE`
,
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
c1
where
c1
.
rownum
<=
20
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
s1
group
by
s1
.
`uwConclueDate`
,
s1
.
`group_com`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
CONCAT
(
'bigfccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
,
`cost`
,
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
...
...
@@ -224,36 +198,30 @@ select
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
)
,
20
,
s1
.
`uwConclueDate`
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`LEVEL2COMCODE`
,
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
c1
where
c1
.
rownum
<=
20
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
s1
group
by
s1
.
`uwConclueDate`
,
s1
.
`group_com`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/非车险/ZB_DM_非车险今日签单保费.sql
deleted
100644 → 0
View file @
b4727d91
-- 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
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
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`
,
sum
(
cast
(
s1
.
`cost`
as
DECIMAL
(
18
,
2
)))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
s1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
s1
.
risk
,
2
)
<>
'05'
group
by
s1
.
`uwConclueDate`
,
s1
.
`LEVEL4COMCODE`
;
\ No newline at end of file
ZB_DM/承保指标/方案四(函数自增)/非车险/ZB_DM_非车险承保大单.sql
deleted
100644 → 0
View file @
b4727d91
-- ZB_DM_FCXCBDD ZB_DM_非车险承保大单
-- bigfcbd/日期
-- 核保或者核批时间在今天,按照保费或者未决赔款排序,取前10,车险riskcode 05开头,其他为非车,
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfcbd/'
,
s1
.
`uwConclueDate`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
c1
where
c1
.
rownum
<=
20
)
s1
group
by
s1
.
`uwConclueDate`
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfccitybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`LEVEL1COMCODE`
,
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
c1
where
c1
.
rownum
<=
20
)
s1
group
by
s1
.
`uwConclueDate`
,
s1
.
`group_com`
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfccountrybd/'
,
s1
.
`uwConclueDate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
CastToJsonArrayUDF
(
listagg
(
concat
(
'com'
,
':'
,
`com`
,
','
,
'comname'
,
':'
,
`comname`
,
','
,
'city'
,
':'
,
`city`
,
','
,
'cityname'
,
':'
,
`cityname`
,
','
,
'country'
,
':'
,
`country`
,
','
,
'countryname'
,
':'
,
`countryname`
,
','
,
'risk'
,
':'
,
`risk`
,
','
,
'riskname'
,
':'
,
`riskname`
,
','
,
'chnl'
,
':'
,
`chnl`
,
','
,
'chnlname'
,
':'
,
`chnlname`
,
','
,
'cost'
,
':'
,
`cost`
,
','
,
'no'
,
':'
,
`no`
),
';'
)
)
as
`val`
from
(
select
*
from
(
select
d1
.
`uwConclueDate`
as
`uwConclueDate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL2COMCODE`
as
`city`
,
d1
.
`LEVEL2COMDESC`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
cast
(
d1
.
`cost`
as
varchar
)
as
`cost`
,
d1
.
`no`
as
`no`
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
d1
.
`LEVEL2COMCODE`
,
d1
.
`uwConclueDate`
ORDER
BY
d1
.
`cost`
DESC
)
as
rownum
from
ZB_ODS
.
ZB_ODS_KAFKA
.
CBDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`uwConclueDate`
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
left
(
d1
.
risk
,
2
)
<>
'05'
)
c1
where
c1
.
rownum
<=
20
)
s1
group
by
s1
.
`uwConclueDate`
,
s1
.
`group_com`
;
\ No newline at end of file
ZB_DM/理赔指标/方案四(函数自增)/ZB_DM_理赔合并.sql
0 → 100644
View file @
d9aa22fb
-- ZB_DM_LPHB ZB_DM_理赔合并
-- ZB_DM_YJPK ZB_DM_已决赔款
-- key:allyjpk/日期
-- 1、日期:已决立案日期 未决估损调整日期(yyyyMMdd)
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allyjpk/'
,
s1
.
`setdate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allyjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
;
-- 分公司 provyjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provyjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provyjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
;
-- 中支 cityyjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityyjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityyjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
;
-- 县支 countyyjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countyyjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countyyjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
;
-- 团队 teamyjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamyjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamyjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
;
-- ZB_DM_FXLYJPK ZB_DM_分险类已决赔款
-- allyjxlbf/日期 险类代码
-- 1、日期:已决立案日期 未决估损调整日期(yyyyMMdd)
--总公司 allyjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allyjxlbf/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allyjxlbf/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`classcode`
is
not
null
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`classcode`
is
not
null
;
-- 中支 cityyjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`classcode`
is
not
null
;
-- 县支 countyyjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countyyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countyyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`classcode`
is
not
null
;
-- 团队 teamyjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`classcode`
is
not
null
;
-- ZB_DM_FQDYJPK ZB_DM_分渠道已决赔款
-- chnlyjbf/日期 渠道代码
-- 1、日期:已决立案日期 未决估损调整日期(yyyyMMdd)
--总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlyjbf/'
,
s1
.
`setdate`
,
'/00000000'
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlyjbf/'
,
s1
.
`setdate`
,
'/00000000'
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`chnl`
is
not
null
;
-- 分公司 chnlyjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`chnl`
is
not
null
;
-- 中支 citychnlyjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citychnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citychnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`chnl`
is
not
null
;
-- 县支 countychnlyjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countychnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countychnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`chnl`
is
not
null
;
-- 团队 teamchnlyjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamchnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamchnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`chnl`
is
not
null
;
-- ZB_DM_WJPK_HB ZB_DM_未决赔款合并
-- ZB_DM_WJPK ZB_DM_未决赔款
-- key:allwjpk/日期
-- 1、日期:未决估损调整日期(yyyyMMdd)
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allwjpk/'
,
s1
.
`setdate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allwjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provwjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provwjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
;
-- 中支 citywjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citywjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citywjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
;
-- 县支 countywjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countywjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countywjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
;
-- 团队 teamwjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamwjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamwjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
;
-- ZB_DM_FXLWJPK ZB_DM_分险类未决赔款
-- allwjxlbf/日期 险类代码
-- 1、日期:已决立案日期 未决估损调整日期(yyyyMMdd)
--总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allwjxlbf/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allwjxlbf/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`classcode`
is
not
null
;
-- 分公司 provwjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provwjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provwjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`classcode`
is
not
null
;
-- 中支 citywjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citywjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citywjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`classcode`
is
not
null
;
-- 县支 countywjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countywjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countywjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`classcode`
is
not
null
;
-- 团队 teamwjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamwjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamwjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`classcode`
is
not
null
;
-- ZB_DM_FQDWJPK ZB_DM_分渠道未决赔款
-- chnlwjbf/日期 渠道代码
-- 1、日期:已决立案日期 未决估损调整日期(yyyyMMdd)
--总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlwjbf/'
,
s1
.
`setdate`
,
'/00000000'
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlwjbf/'
,
s1
.
`setdate`
,
'/00000000'
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`chnl`
is
not
null
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`chnl`
is
not
null
;
-- 中支 citychnlwjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citychnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citychnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`chnl`
is
not
null
;
-- 县支 countychnlwjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countychnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countychnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`chnl`
is
not
null
;
-- 团队 teamchnlwjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamchnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamchnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`chnl`
is
not
null
;
ZB_DM/理赔指标/方案四(函数自增)/ZB_DM_理赔大单.sql
0 → 100644
View file @
d9aa22fb
-- ZB_DM_LPDD ZB_DM_理赔大单
-- bigclpbdt/日期
-- 估损调整日期在今天,按照估损金额排序,取前20,车险riskcode 05开头,其他为非车,
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigclpbdt/'
,
s1
.
`setdate`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigclpbdt/'
,
s1
.
`setdate`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
coalesce
(
s1
.
`com`
,
' '
)
,
','
,
'maincom'
,
':'
,
coalesce
(
s1
.
`maincom`
,
' '
)
,
','
,
'no'
,
':'
,
coalesce
(
s1
.
`no`
,
' '
)
,
','
,
'claimno'
,
':'
,
coalesce
(
s1
.
`claimno`
,
' '
)
,
','
,
'cost'
,
':'
,
coalesce
(
s1
.
`cost`
,
' '
)
,
','
,
'comname'
,
':'
,
coalesce
(
s1
.
`comname`
,
' '
)
,
','
,
'chnl'
,
':'
,
coalesce
(
s1
.
`chnl`
,
' '
)
,
','
,
'mainkey'
,
':'
,
coalesce
(
s1
.
`mainkey`
,
' '
)
,
','
,
'riskname'
,
':'
,
coalesce
(
s1
.
`riskname`
,
' '
)
,
','
,
'chnlname'
,
':'
,
coalesce
(
s1
.
`chnlname`
,
' '
)
,
','
,
'risk'
,
':'
,
coalesce
(
s1
.
`risk`
,
' '
)
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
=
'05'
)
s1
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigcitylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigcitylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
coalesce
(
s1
.
`com`
,
' '
)
,
','
,
'maincom'
,
':'
,
coalesce
(
s1
.
`maincom`
,
' '
)
,
','
,
'city'
,
':'
,
coalesce
(
s1
.
`city`
,
' '
)
,
','
,
'cityname'
,
':'
,
coalesce
(
s1
.
`cityname`
,
' '
)
,
','
,
'no'
,
':'
,
coalesce
(
s1
.
`no`
,
' '
)
,
','
,
'claimno'
,
':'
,
coalesce
(
s1
.
`claimno`
,
' '
)
,
','
,
'cost'
,
':'
,
coalesce
(
s1
.
`cost`
,
' '
)
,
','
,
'comname'
,
':'
,
coalesce
(
s1
.
`comname`
,
' '
)
,
','
,
'chnl'
,
':'
,
coalesce
(
s1
.
`chnl`
,
' '
)
,
','
,
'mainkey'
,
':'
,
coalesce
(
s1
.
`mainkey`
,
' '
)
,
','
,
'riskname'
,
':'
,
coalesce
(
s1
.
`riskname`
,
' '
)
,
','
,
'chnlname'
,
':'
,
coalesce
(
s1
.
`chnlname`
,
' '
)
,
','
,
'risk'
,
':'
,
coalesce
(
s1
.
`risk`
,
' '
)
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`LEVEL2COMDESC`
as
`city`
,
d1
.
`LEVEL2COMCODE`
as
`cityname`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
=
'wj'
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
=
'05'
)
s1
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigcountrylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigcountrylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
coalesce
(
s1
.
`com`
,
' '
)
,
','
,
'maincom'
,
':'
,
coalesce
(
s1
.
`maincom`
,
' '
)
,
','
,
'city'
,
':'
,
coalesce
(
s1
.
`city`
,
' '
)
,
','
,
'cityname'
,
':'
,
coalesce
(
s1
.
`cityname`
,
' '
)
,
','
,
'country'
,
':'
,
coalesce
(
s1
.
`country`
,
' '
)
,
','
,
'countryname'
,
':'
,
coalesce
(
s1
.
`countryname`
,
' '
)
,
','
,
'no'
,
':'
,
coalesce
(
s1
.
`no`
,
' '
)
,
','
,
'claimno'
,
':'
,
coalesce
(
s1
.
`claimno`
,
' '
)
,
','
,
'cost'
,
':'
,
coalesce
(
s1
.
`cost`
,
' '
)
,
','
,
'comname'
,
':'
,
coalesce
(
s1
.
`comname`
,
' '
)
,
','
,
'chnl'
,
':'
,
coalesce
(
s1
.
`chnl`
,
' '
)
,
','
,
'mainkey'
,
':'
,
coalesce
(
s1
.
`mainkey`
,
' '
)
,
','
,
'riskname'
,
':'
,
coalesce
(
s1
.
`riskname`
,
' '
)
,
','
,
'chnlname'
,
':'
,
coalesce
(
s1
.
`chnlname`
,
' '
)
,
','
,
'risk'
,
':'
,
coalesce
(
s1
.
`risk`
,
' '
)
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`LEVEL2COMDESC`
as
`city`
,
d1
.
`LEVEL2COMCODE`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
=
'wj'
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
=
'05'
)
s1
;
-- ZB_DM_FCXWJDD ZB_DM_非车未决大单
-- bigfclpbdt/日期
-- 估损调整日期在今天,按照估损金额排序,取前20,车险riskcode 05开头,其他为非车,
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfclpbdt/'
,
s1
.
`setdate`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfclpbdt/'
,
s1
.
`setdate`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
coalesce
(
s1
.
`com`
,
' '
)
,
','
,
'maincom'
,
':'
,
coalesce
(
s1
.
`maincom`
,
' '
)
,
','
,
'no'
,
':'
,
coalesce
(
s1
.
`no`
,
' '
)
,
','
,
'claimno'
,
':'
,
coalesce
(
s1
.
`claimno`
,
' '
)
,
','
,
'cost'
,
':'
,
coalesce
(
s1
.
`cost`
,
' '
)
,
','
,
'comname'
,
':'
,
coalesce
(
s1
.
`comname`
,
' '
)
,
','
,
'chnl'
,
':'
,
coalesce
(
s1
.
`chnl`
,
' '
)
,
','
,
'mainkey'
,
':'
,
coalesce
(
s1
.
`mainkey`
,
' '
)
,
','
,
'riskname'
,
':'
,
coalesce
(
s1
.
`riskname`
,
' '
)
,
','
,
'chnlname'
,
':'
,
coalesce
(
s1
.
`chnlname`
,
' '
)
,
','
,
'risk'
,
':'
,
coalesce
(
s1
.
`risk`
,
' '
)
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
<>
'05'
)
s1
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfcitylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfcitylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
coalesce
(
s1
.
`com`
,
' '
)
,
','
,
'maincom'
,
':'
,
coalesce
(
s1
.
`maincom`
,
' '
)
,
','
,
'city'
,
':'
,
coalesce
(
s1
.
`city`
,
' '
)
,
','
,
'cityname'
,
':'
,
coalesce
(
s1
.
`cityname`
,
' '
)
,
','
,
'no'
,
':'
,
coalesce
(
s1
.
`no`
,
' '
)
,
','
,
'claimno'
,
':'
,
coalesce
(
s1
.
`claimno`
,
' '
)
,
','
,
'cost'
,
':'
,
coalesce
(
s1
.
`cost`
,
' '
)
,
','
,
'comname'
,
':'
,
coalesce
(
s1
.
`comname`
,
' '
)
,
','
,
'chnl'
,
':'
,
coalesce
(
s1
.
`chnl`
,
' '
)
,
','
,
'mainkey'
,
':'
,
coalesce
(
s1
.
`mainkey`
,
' '
)
,
','
,
'riskname'
,
':'
,
coalesce
(
s1
.
`riskname`
,
' '
)
,
','
,
'chnlname'
,
':'
,
coalesce
(
s1
.
`chnlname`
,
' '
)
,
','
,
'risk'
,
':'
,
coalesce
(
s1
.
`risk`
,
' '
)
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`LEVEL2COMDESC`
as
`city`
,
d1
.
`LEVEL2COMCODE`
as
`cityname`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
=
'wj'
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
<>
'05'
)
s1
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfcountrylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfcountrylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
coalesce
(
s1
.
`com`
,
' '
)
,
','
,
'maincom'
,
':'
,
coalesce
(
s1
.
`maincom`
,
' '
)
,
','
,
'city'
,
':'
,
coalesce
(
s1
.
`city`
,
' '
)
,
','
,
'cityname'
,
':'
,
coalesce
(
s1
.
`cityname`
,
' '
)
,
','
,
'country'
,
':'
,
coalesce
(
s1
.
`country`
,
' '
)
,
','
,
'countryname'
,
':'
,
coalesce
(
s1
.
`countryname`
,
' '
)
,
','
,
'no'
,
':'
,
coalesce
(
s1
.
`no`
,
' '
)
,
','
,
'claimno'
,
':'
,
coalesce
(
s1
.
`claimno`
,
' '
)
,
','
,
'cost'
,
':'
,
coalesce
(
s1
.
`cost`
,
' '
)
,
','
,
'comname'
,
':'
,
coalesce
(
s1
.
`comname`
,
' '
)
,
','
,
'chnl'
,
':'
,
coalesce
(
s1
.
`chnl`
,
' '
)
,
','
,
'mainkey'
,
':'
,
coalesce
(
s1
.
`mainkey`
,
' '
)
,
','
,
'riskname'
,
':'
,
coalesce
(
s1
.
`riskname`
,
' '
)
,
','
,
'chnlname'
,
':'
,
coalesce
(
s1
.
`chnlname`
,
' '
)
,
','
,
'risk'
,
':'
,
coalesce
(
s1
.
`risk`
,
' '
)
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`LEVEL2COMDESC`
as
`city`
,
d1
.
`LEVEL2COMCODE`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
=
'wj'
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
<>
'05'
)
s1
;
ZB_DM/理赔指标/方案四(函数自增)/已决赔款/ZB_DM_已决赔款(合并).sql
0 → 100644
View file @
d9aa22fb
-- ZB_DM_YJPK_HB ZB_DM_已决赔款合并
-- ZB_DM_YJPK ZB_DM_已决赔款
-- key:allyjpk/日期
-- 1、日期:已决立案日期 未决估损调整日期(yyyyMMdd)
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allyjpk/'
,
s1
.
`setdate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allyjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
;
-- 分公司 provyjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provyjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provyjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
;
-- 中支 cityyjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityyjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityyjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
;
-- 县支 countyyjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countyyjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countyyjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
;
-- 团队 teamyjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamyjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamyjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
;
-- ZB_DM_FXLYJPK ZB_DM_分险类已决赔款
-- allyjxlbf/日期 险类代码
-- 1、日期:已决立案日期 未决估损调整日期(yyyyMMdd)
--总公司 allyjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allyjxlbf/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allyjxlbf/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`classcode`
is
not
null
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`classcode`
is
not
null
;
-- 中支 cityyjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'cityyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'cityyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`classcode`
is
not
null
;
-- 县支 countyyjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countyyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countyyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`classcode`
is
not
null
;
-- 团队 teamyjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamyjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`classcode`
is
not
null
;
-- ZB_DM_FQDYJPK ZB_DM_分渠道已决赔款
-- chnlyjbf/日期 渠道代码
-- 1、日期:已决立案日期 未决估损调整日期(yyyyMMdd)
--总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlyjbf/'
,
s1
.
`setdate`
,
'/00000000'
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlyjbf/'
,
s1
.
`setdate`
,
'/00000000'
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`chnl`
is
not
null
;
-- 分公司 chnlyjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`chnl`
is
not
null
;
-- 中支 citychnlyjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citychnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citychnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`chnl`
is
not
null
;
-- 县支 countychnlyjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countychnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countychnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`chnl`
is
not
null
;
-- 团队 teamchnlyjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamchnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamchnlyjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
=
'yj'
and
s1
.
`chnl`
is
not
null
;
\ No newline at end of file
ZB_DM/理赔指标/方案四(函数自增)/未决赔款/ZB_DM_未决赔款(合并).sql
0 → 100644
View file @
d9aa22fb
-- ZB_DM_WJPK_HB ZB_DM_未决赔款合并
-- ZB_DM_WJPK ZB_DM_未决赔款
-- key:allwjpk/日期
-- 1、日期:未决估损调整日期(yyyyMMdd)
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_DECIMAL
select
CONCAT
(
'allwjpk/'
,
s1
.
`setdate`
)
as
`key`
,
cast
(
sumZBUDF
(
CONCAT
(
'allwjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provwjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL1COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provwjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
;
-- 中支 citywjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citywjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL2COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citywjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
;
-- 县支 countywjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countywjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL3COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countywjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
;
-- 团队 teamwjpk
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamwjpk/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`LEVEL4COMCODE`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamwjpk/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
;
-- ZB_DM_FXLWJPK ZB_DM_分险类未决赔款
-- allwjxlbf/日期 险类代码
-- 1、日期:已决立案日期 未决估损调整日期(yyyyMMdd)
--总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'allwjxlbf/'
,
s1
.
`setdate`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'allwjxlbf/'
,
s1
.
`setdate`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`classcode`
is
not
null
;
-- 分公司 provwjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'provwjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'provwjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`classcode`
is
not
null
;
-- 中支 citywjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citywjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citywjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`classcode`
is
not
null
;
-- 县支 countywjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countywjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countywjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`classcode`
is
not
null
;
-- 团队 teamwjxlbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamwjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`classcode`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamwjxlbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`classcode`
is
not
null
;
-- ZB_DM_FQDWJPK ZB_DM_分渠道未决赔款
-- chnlwjbf/日期 渠道代码
-- 1、日期:已决立案日期 未决估损调整日期(yyyyMMdd)
--总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlwjbf/'
,
s1
.
`setdate`
,
'/00000000'
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlwjbf/'
,
s1
.
`setdate`
,
'/00000000'
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`chnl`
is
not
null
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'chnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'chnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL1COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`chnl`
is
not
null
;
-- 中支 citychnlwjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'citychnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'citychnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL2COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`chnl`
is
not
null
;
-- 县支 countychnlwjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'countychnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'countychnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL3COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`chnl`
is
not
null
;
-- 团队 teamchnlwjbf
insert
into
ZB_DM
.
ZB_DM_REDIS
.
HSET_DECIMAL
select
CONCAT
(
'teamchnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
as
`key`
,
s1
.
`chnl`
as
`hkey`
,
cast
(
sumZBUDF
(
CONCAT
(
'teamchnlwjbf/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`LEVEL4COMCODE`
)
,
s1
.
`settledamount`
,
s1
.
`setdate`
)
as
decimal
(
18
,
2
))
as
`val`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
s1
where
s1
.
`COMNAME`
is
not
null
and
LEFT
(
s1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
s1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
s1
.
`chnl`
is
not
null
;
\ No newline at end of file
ZB_DM/理赔指标/方案四(函数自增)/车险/ZB_DM_车险未决大单.sql
0 → 100644
View file @
d9aa22fb
-- ZB_DM_CXDD ZB_DM_车险未决大单
-- bigclpbdt/日期
-- 估损调整日期在今天,按照估损金额排序,取前20,车险riskcode 05开头,其他为非车,
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigclpbdt/'
,
s1
.
`setdate`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigclpbdt/'
,
s1
.
`setdate`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
s1
.
`com`
,
','
,
'maincom'
,
':'
,
s1
.
`maincom`
,
','
,
'no'
,
':'
,
s1
.
`no`
,
','
,
'claimno'
,
':'
,
s1
.
`claimno`
,
','
,
'cost'
,
':'
,
s1
.
`cost`
,
','
,
'comname'
,
':'
,
s1
.
`comname`
,
','
,
'chnl'
,
':'
,
s1
.
`chnl`
,
','
,
'mainkey'
,
':'
,
s1
.
`mainkey`
,
','
,
'riskname'
,
':'
,
s1
.
`riskname`
,
','
,
'chnlname'
,
':'
,
s1
.
`chnlname`
,
','
,
'risk'
,
':'
,
s1
.
`risk`
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
=
'05'
)
s1
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigcitylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigcitylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
s1
.
`com`
,
','
,
'maincom'
,
':'
,
s1
.
`maincom`
,
','
,
'city'
,
':'
,
s1
.
`city`
,
','
,
'cityname'
,
':'
,
s1
.
`cityname`
,
','
,
'no'
,
':'
,
s1
.
`no`
,
','
,
'claimno'
,
':'
,
s1
.
`claimno`
,
','
,
'cost'
,
':'
,
s1
.
`cost`
,
','
,
'comname'
,
':'
,
s1
.
`comname`
,
','
,
'chnl'
,
':'
,
s1
.
`chnl`
,
','
,
'mainkey'
,
':'
,
s1
.
`mainkey`
,
','
,
'riskname'
,
':'
,
s1
.
`riskname`
,
','
,
'chnlname'
,
':'
,
s1
.
`chnlname`
,
','
,
'risk'
,
':'
,
s1
.
`risk`
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`LEVEL2COMDESC`
as
`city`
,
d1
.
`LEVEL2COMCODE`
as
`cityname`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
=
'wj'
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
=
'05'
)
s1
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigcountrylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigcountrylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
s1
.
`com`
,
','
,
'maincom'
,
':'
,
s1
.
`maincom`
,
','
,
'city'
,
':'
,
s1
.
`city`
,
','
,
'cityname'
,
':'
,
s1
.
`cityname`
,
','
,
'country'
,
':'
,
s1
.
`country`
,
','
,
'countryname'
,
':'
,
s1
.
`countryname`
,
','
,
'no'
,
':'
,
s1
.
`no`
,
','
,
'claimno'
,
':'
,
s1
.
`claimno`
,
','
,
'cost'
,
':'
,
s1
.
`cost`
,
','
,
'comname'
,
':'
,
s1
.
`comname`
,
','
,
'chnl'
,
':'
,
s1
.
`chnl`
,
','
,
'mainkey'
,
':'
,
s1
.
`mainkey`
,
','
,
'riskname'
,
':'
,
s1
.
`riskname`
,
','
,
'chnlname'
,
':'
,
s1
.
`chnlname`
,
','
,
'risk'
,
':'
,
s1
.
`risk`
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`LEVEL2COMDESC`
as
`city`
,
d1
.
`LEVEL2COMCODE`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
=
'wj'
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
=
'05'
)
s1
;
ZB_DM/理赔指标/方案四(函数自增)/非车险/ZB_DM_非车险未决大单.sql
0 → 100644
View file @
d9aa22fb
-- ZB_DM_FCXWJDD ZB_DM_非车未决大单
-- bigfclpbdt/日期
-- 估损调整日期在今天,按照估损金额排序,取前20,车险riskcode 05开头,其他为非车,
-- 总公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfclpbdt/'
,
s1
.
`setdate`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfclpbdt/'
,
s1
.
`setdate`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
s1
.
`com`
,
','
,
'maincom'
,
':'
,
s1
.
`maincom`
,
','
,
'no'
,
':'
,
s1
.
`no`
,
','
,
'claimno'
,
':'
,
s1
.
`claimno`
,
','
,
'cost'
,
':'
,
s1
.
`cost`
,
','
,
'comname'
,
':'
,
s1
.
`comname`
,
','
,
'chnl'
,
':'
,
s1
.
`chnl`
,
','
,
'mainkey'
,
':'
,
s1
.
`mainkey`
,
','
,
'riskname'
,
':'
,
s1
.
`riskname`
,
','
,
'chnlname'
,
':'
,
s1
.
`chnlname`
,
','
,
'risk'
,
':'
,
s1
.
`risk`
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
in
(
'wj'
,
'yjwj'
)
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
<>
'05'
)
s1
;
-- 分公司
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfcitylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfcitylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
s1
.
`com`
,
','
,
'maincom'
,
':'
,
s1
.
`maincom`
,
','
,
'city'
,
':'
,
s1
.
`city`
,
','
,
'cityname'
,
':'
,
s1
.
`cityname`
,
','
,
'no'
,
':'
,
s1
.
`no`
,
','
,
'claimno'
,
':'
,
s1
.
`claimno`
,
','
,
'cost'
,
':'
,
s1
.
`cost`
,
','
,
'comname'
,
':'
,
s1
.
`comname`
,
','
,
'chnl'
,
':'
,
s1
.
`chnl`
,
','
,
'mainkey'
,
':'
,
s1
.
`mainkey`
,
','
,
'riskname'
,
':'
,
s1
.
`riskname`
,
','
,
'chnlname'
,
':'
,
s1
.
`chnlname`
,
','
,
'risk'
,
':'
,
s1
.
`risk`
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL1COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`LEVEL2COMDESC`
as
`city`
,
d1
.
`LEVEL2COMCODE`
as
`cityname`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
=
'wj'
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
<>
'05'
)
s1
;
-- 中支
insert
into
ZB_DM
.
ZB_DM_REDIS
.
SET_VARCHAR
select
CONCAT
(
'bigfcountrylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
as
`key`
,
topNUDF
(
CONCAT
(
'bigfcountrylpbdt/'
,
s1
.
`setdate`
,
'/'
,
s1
.
`group_com`
)
,
s1
.
`cost`
,
concat
(
'com'
,
':'
,
s1
.
`com`
,
','
,
'maincom'
,
':'
,
s1
.
`maincom`
,
','
,
'city'
,
':'
,
s1
.
`city`
,
','
,
'cityname'
,
':'
,
s1
.
`cityname`
,
','
,
'country'
,
':'
,
s1
.
`country`
,
','
,
'countryname'
,
':'
,
s1
.
`countryname`
,
','
,
'no'
,
':'
,
s1
.
`no`
,
','
,
'claimno'
,
':'
,
s1
.
`claimno`
,
','
,
'cost'
,
':'
,
s1
.
`cost`
,
','
,
'comname'
,
':'
,
s1
.
`comname`
,
','
,
'chnl'
,
':'
,
s1
.
`chnl`
,
','
,
'mainkey'
,
':'
,
s1
.
`mainkey`
,
','
,
'riskname'
,
':'
,
s1
.
`riskname`
,
','
,
'chnlname'
,
':'
,
s1
.
`chnlname`
,
','
,
'risk'
,
':'
,
s1
.
`risk`
)
,
20
,
s1
.
`setdate`
)
as
`val`
from
(
select
d1
.
`setdate`
as
`setdate`
,
d1
.
`LEVEL2COMCODE`
as
`group_com`
,
d1
.
`LEVEL1COMCODE`
as
`com`
,
d1
.
`LEVEL1COMDESC`
as
`comname`
,
d1
.
`LEVEL1COMCODE`
as
`maincom`
,
d1
.
`LEVEL2COMDESC`
as
`city`
,
d1
.
`LEVEL2COMCODE`
as
`cityname`
,
d1
.
`LEVEL3COMCODE`
as
`country`
,
d1
.
`LEVEL3COMDESC`
as
`countryname`
,
d1
.
`no`
as
`no`
,
d1
.
`claimno`
as
`claimno`
,
d1
.
`settledamount`
as
`cost`
,
d1
.
`chnl`
as
`chnl`
,
d1
.
`chnlname`
as
`chnlname`
,
CONCAT
(
d1
.
`LEVEL1COMCODE`
,
'/'
,
d1
.
`claimno`
,
'/'
,
d1
.
`no`
)
as
`mainkey`
,
d1
.
`risk`
as
`risk`
,
d1
.
`riskname`
as
`riskname`
from
ZB_ODS
.
ZB_ODS_KAFKA
.
LPDATA
d1
where
d1
.
`COMNAME`
is
not
null
and
d1
.
`flag`
=
'wj'
and
LEFT
(
d1
.
`setdate`
,
8
)
=
DATE_FORMAT
(
LOCALTIMESTAMP
,
'yyyyMMdd'
)
and
LEFT
(
d1
.
`risk`
,
2
)
<>
'05'
)
s1
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment