919 lines
42 KiB
Plaintext
919 lines
42 KiB
Plaintext
|
CREATE OR REPLACE PACKAGE telsale_pkg IS
|
|||
|
|
|||
|
-- Author : WANGWEI-202
|
|||
|
-- Created : 2023/3/10 15:13:34
|
|||
|
-- Purpose : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɰ<EFBFBD>
|
|||
|
|
|||
|
PROCEDURE <20><><EFBFBD>ǻ<EFBFBD><C7BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
(
|
|||
|
a_start_date IN DATE,
|
|||
|
a_end_date IN DATE
|
|||
|
);
|
|||
|
|
|||
|
PROCEDURE gen_<6E><5F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|||
|
(
|
|||
|
a_start_date IN DATE,
|
|||
|
a_end_date IN DATE
|
|||
|
);
|
|||
|
|
|||
|
PROCEDURE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|||
|
PROCEDURE chefei_daily_job;
|
|||
|
PROCEDURE xubao_daily_job;
|
|||
|
|
|||
|
END telsale_pkg;
|
|||
|
/
|
|||
|
CREATE OR REPLACE PACKAGE BODY telsale_pkg IS
|
|||
|
|
|||
|
PROCEDURE <20><><EFBFBD>ǻ<EFBFBD><C7BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
(
|
|||
|
a_start_date IN DATE,
|
|||
|
a_end_date IN DATE
|
|||
|
) IS
|
|||
|
--l_count INTEGER; --<2D><><EFBFBD>м<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
BEGIN
|
|||
|
--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|||
|
gen_<6E><5F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>(a_start_date,
|
|||
|
a_end_date);
|
|||
|
|
|||
|
FOR caller_record IN (SELECT *
|
|||
|
FROM desktop_archievement_admin.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>_t)
|
|||
|
LOOP
|
|||
|
BEGIN
|
|||
|
DELETE desktop_archievement_admin.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD> cf
|
|||
|
WHERE cf.ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = caller_record.ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
AND cf.<2E><><EFBFBD><EFBFBD> = caller_record.<2E><><EFBFBD><EFBFBD>
|
|||
|
AND cf.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>n = caller_record.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>n
|
|||
|
AND cf.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD> = caller_record.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>;
|
|||
|
EXCEPTION
|
|||
|
WHEN no_data_found THEN
|
|||
|
dbms_output.put_line(caller_record.ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> || '<27><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
END;
|
|||
|
|
|||
|
INSERT INTO desktop_archievement_admin.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>
|
|||
|
VALUES caller_record;
|
|||
|
|
|||
|
END LOOP;
|
|||
|
|
|||
|
COMMIT;
|
|||
|
/*EXCEPTION
|
|||
|
WHEN OTHERS THEN
|
|||
|
NULL;*/
|
|||
|
END;
|
|||
|
|
|||
|
/**********************************************************************/
|
|||
|
|
|||
|
PROCEDURE gen_<6E><5F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|||
|
(
|
|||
|
a_start_date IN DATE,
|
|||
|
a_end_date IN DATE
|
|||
|
) IS
|
|||
|
BEGIN
|
|||
|
desktop_archievement_admin.clean_temp_data;
|
|||
|
|
|||
|
INSERT INTO desktop_archievement_admin.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>_t
|
|||
|
WITH aa AS
|
|||
|
(SELECT to_char(t.signature_date,
|
|||
|
'yyyy-mm-dd') ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
(to_char(T.signature_date,
|
|||
|
'yyyy')) the_year,
|
|||
|
(to_char(T.signature_date,
|
|||
|
'mm')) the_month,
|
|||
|
t.policy_no bdh,
|
|||
|
t.endorsement_no pdh,
|
|||
|
qt.t_cre tid,
|
|||
|
QT.B_CRE BTID, -----<2D><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
|
|||
|
e.inception_date qbsj,
|
|||
|
e.planned_end_date zzsj,
|
|||
|
pt.premium_amount - nvl(pt.tax_amount,
|
|||
|
0) bf
|
|||
|
--,qt.qdbf - nvl(qt.qdbf_tax_amount,0) bf
|
|||
|
,
|
|||
|
nt.ecompensation_rate * (pt.premium_amount - nvl(pt.tax_amount,
|
|||
|
0)) fxbf,
|
|||
|
z.department_name bm,
|
|||
|
z.department_code bmdm,
|
|||
|
CASE
|
|||
|
WHEN (et.telpartnercode LIKE '%HC%' OR
|
|||
|
zx.workerno IN (SELECT code
|
|||
|
FROM datacenter.dc_lsj_zx_hc)) THEN
|
|||
|
'<27><><EFBFBD>ῥ'
|
|||
|
ELSE
|
|||
|
''
|
|||
|
END <20>Ƿ<EFBFBD><C7B7>ῥ,
|
|||
|
nvl(zx.workerno,
|
|||
|
et.telpartnercode) <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
(CASE
|
|||
|
WHEN nvl(zx.workerno,
|
|||
|
et.telpartnercode) = 'DX001' AND
|
|||
|
xx.staff_name LIKE '%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%' THEN
|
|||
|
'<27><>ΰ<EFBFBD><CEB0>'
|
|||
|
WHEN nvl(zx.workerno,
|
|||
|
et.telpartnercode) = 'DX001' AND
|
|||
|
xx.staff_name NOT LIKE '%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>'
|
|||
|
ELSE
|
|||
|
to_char(ys.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>)
|
|||
|
END) <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
YS.<2E>Ŷ<EFBFBD> <20><>ϯ<EFBFBD>Ŷ<EFBFBD>,
|
|||
|
nvl(YS.<2E>Ŷ<EFBFBD>,
|
|||
|
y.section_office_name) <20><><EFBFBD><EFBFBD>N,
|
|||
|
nvl((CASE
|
|||
|
WHEN nvl(zx.workerno,
|
|||
|
et.telpartnercode) = 'DX001' AND
|
|||
|
xx.staff_name LIKE '%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%' THEN
|
|||
|
'<27><>ΰ<EFBFBD><CEB0>'
|
|||
|
WHEN nvl(zx.workerno,
|
|||
|
et.telpartnercode) = 'DX001' AND
|
|||
|
xx.staff_name NOT LIKE '%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>'
|
|||
|
ELSE
|
|||
|
to_char(ys.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>)
|
|||
|
END),
|
|||
|
xx.staff_name) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N
|
|||
|
FROM idst0.auto_agreement_request_t t
|
|||
|
LEFT JOIN idst0.auto_agreement_t e
|
|||
|
ON e.policy_no = t.policy_no
|
|||
|
LEFT JOIN idst0.motorised_vehicle_t v
|
|||
|
ON v.policy_no = e.policy_no
|
|||
|
LEFT JOIN idst0.auto_premium_t pt
|
|||
|
ON pt.policy_no = t.policy_no
|
|||
|
AND pt.endorsement_no = t.endorsement_no
|
|||
|
LEFT JOIN ywglxt.w_dxbd_i i
|
|||
|
ON e.policy_no = i.bdh
|
|||
|
LEFT JOIN idst0.rydm_t xx
|
|||
|
ON xx.staff_code = nvl(i.zhjywy,
|
|||
|
e.operator_code)
|
|||
|
LEFT JOIN idst0.ks_t y
|
|||
|
ON y.section_office_code = nvl(xx.section_office_code,
|
|||
|
e.section_office_code)
|
|||
|
LEFT JOIN idst0.bm_t z
|
|||
|
ON z.department_code = nvl(xx.department_code,
|
|||
|
e.department_code)
|
|||
|
--left join datacenter.dc_cx_csteam ct on ct.jbrcode = xx.staff_code
|
|||
|
LEFT JOIN idst0.auto_new_product_info_t nt
|
|||
|
ON nt.policy_no = t.policy_no
|
|||
|
AND nt.endorsement_no = t.endorsement_no
|
|||
|
--left join ywglxt.q_auto_agreement_extend_t qe on qe.policy_no = e.policy_no
|
|||
|
LEFT JOIN ywglxt.q_auto_agreement_t qt
|
|||
|
ON qt.policy_no = e.policy_no
|
|||
|
LEFT JOIN datacenter.dc_yangg_qdcode qd
|
|||
|
ON qd.code = e.selling_channel_type
|
|||
|
LEFT JOIN datacenter.dc_tb_jc_c_tag cl
|
|||
|
ON cl.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = e.policy_no
|
|||
|
LEFT JOIN datacenter.dc_yangg_basecode_teams fg
|
|||
|
ON fg.bm = z.department_name
|
|||
|
AND fg.ks = y.section_office_name
|
|||
|
--left join idst0.t_sell_policy_autobase_t zx on zx.policy_no=e.policy_no
|
|||
|
--left join idst0.auto_agreement_extend_t et on et.policy_no = e.policy_no
|
|||
|
LEFT JOIN idst0.auto_agreement_extend_t et
|
|||
|
ON et.policy_no = e.policy_no
|
|||
|
LEFT JOIN idst0.t_sell_policy_autobase_t zx
|
|||
|
ON zx.policy_no = e.policy_no
|
|||
|
LEFT JOIN datacenter.dc_YZH_ZXYS YS
|
|||
|
ON YS.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD> = nvl(zx.workerno,
|
|||
|
et.telpartnercode)
|
|||
|
--left join v_lsj_dimian dm on dm.vin=v.vin and e.selling_channel_type='25' and dm.MEMO like'%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%'
|
|||
|
--left join datacenter.dc_lsj_zx_team zt on zt.name=coalesce(zc.name,zc1.name,bc.name,dm.JBRMC)
|
|||
|
WHERE t.signature_date >= to_date('2023-01-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND t.signature_date < to_date(to_char(SYSDATE - 1,
|
|||
|
'yyyy-mm-dd') || ' 23:59:59',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
--and t.endorsement_no = '<27><>'
|
|||
|
AND e.policy_status = '1' --<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
|
|||
|
AND qt.tflag = '0' --<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
|||
|
AND qt.usage_xm = '<27><>ͥ<EFBFBD><CDA5><EFBFBD>ó<EFBFBD>'
|
|||
|
--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᳵ<EFBFBD><E1B3B5>Ħ<EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
--and e.policy_no in ('AXIMC90Y1419B038594J','AXIMC90CTP19B039593R','AXIMC04CTP19B013473X')
|
|||
|
AND e.planned_end_date - e.inception_date >= 360
|
|||
|
--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
)
|
|||
|
-----<2D><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
|
|||
|
,
|
|||
|
dd2 AS
|
|||
|
(SELECT ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
the_year,
|
|||
|
the_month,
|
|||
|
bm,
|
|||
|
bmdm,
|
|||
|
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
<20><>ϯ<EFBFBD>Ŷ<EFBFBD>,
|
|||
|
<20><><EFBFBD><EFBFBD>N,
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N,
|
|||
|
CASE
|
|||
|
WHEN pdh = '<27><>' THEN
|
|||
|
tid
|
|||
|
END tid,
|
|||
|
to_number('1') <20>ͻ<EFBFBD><CDBB><EFBFBD>,
|
|||
|
COUNT(DISTINCT CASE
|
|||
|
WHEN pdh = '<27><>' THEN
|
|||
|
bdh
|
|||
|
END) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
SUM(bf) <20><><EFBFBD><EFBFBD>
|
|||
|
FROM (SELECT DISTINCT *
|
|||
|
FROM aa) aa
|
|||
|
GROUP BY bm,
|
|||
|
bmdm,
|
|||
|
CASE
|
|||
|
WHEN pdh = '<27><>' THEN
|
|||
|
tid
|
|||
|
END,
|
|||
|
the_year,
|
|||
|
the_month,
|
|||
|
BTID,
|
|||
|
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
<20><>ϯ<EFBFBD>Ŷ<EFBFBD>,
|
|||
|
ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
<20><><EFBFBD><EFBFBD>N,
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N
|
|||
|
UNION
|
|||
|
SELECT ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
the_year,
|
|||
|
the_month,
|
|||
|
bm,
|
|||
|
bmdm,
|
|||
|
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
<20><>ϯ<EFBFBD>Ŷ<EFBFBD>,
|
|||
|
<20><><EFBFBD><EFBFBD>N,
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N,
|
|||
|
CASE
|
|||
|
WHEN btid = tid THEN
|
|||
|
''
|
|||
|
ELSE
|
|||
|
btid
|
|||
|
END btid,
|
|||
|
to_number('0') <20>ͻ<EFBFBD><CDBB><EFBFBD>,
|
|||
|
to_number('0') <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
to_number('0') <20><><EFBFBD><EFBFBD>
|
|||
|
FROM (SELECT DISTINCT *
|
|||
|
FROM aa) aa),
|
|||
|
DD AS
|
|||
|
(SELECT *
|
|||
|
FROM DD2
|
|||
|
WHERE TID IS NOT NULL)
|
|||
|
--select * from dd
|
|||
|
,
|
|||
|
bb AS
|
|||
|
(SELECT DISTINCT q.policy_no bdh,
|
|||
|
q.endorsement_no pdh,
|
|||
|
qna.t_cre tid,
|
|||
|
to_number(to_char(q.signature_date,
|
|||
|
'yyyy')) || '<27><>' nf,
|
|||
|
(to_char(q.signature_date,
|
|||
|
'mm')) mm_f,
|
|||
|
to_char(q.signature_date,
|
|||
|
'dd') || '<27><>' dd,
|
|||
|
q.signature_date sj,
|
|||
|
round((pt.premium_amount - nvl(pt.taxamount,
|
|||
|
0)) * c.rate / 100,
|
|||
|
2) bf,
|
|||
|
z.department_name bm
|
|||
|
FROM idst0.nonauto_agreement_request_t q
|
|||
|
LEFT JOIN idst0.nonauto_agreement_t e
|
|||
|
ON e.policy_no = q.policy_no
|
|||
|
LEFT JOIN idst0.nonauto_premium_t pt
|
|||
|
ON pt.endorsement_no = q.endorsement_no
|
|||
|
AND pt.policy_no = q.policy_no
|
|||
|
LEFT JOIN idst0.reinsurance_t r
|
|||
|
ON r.reinsurance_policy_no = e.policy_no
|
|||
|
LEFT JOIN idst0.exrate_month_t c
|
|||
|
ON pt.currency_code = c.bzh
|
|||
|
AND to_char(q.signature_date,
|
|||
|
'YYYY') = c.theyear
|
|||
|
AND to_char(q.signature_date,
|
|||
|
'fmmm') = c.themonth
|
|||
|
|
|||
|
LEFT JOIN idst0.rydm_t x
|
|||
|
ON x.staff_code = e.operator_code
|
|||
|
LEFT JOIN idst0.ks_t y
|
|||
|
ON y.section_office_code = x.section_office_code
|
|||
|
LEFT JOIN idst0.bm_t z
|
|||
|
ON z.department_code = x.department_code
|
|||
|
LEFT JOIN ywglxt.q_nonauto_agreement_t qna
|
|||
|
ON qna.policy_no = q.policy_no
|
|||
|
LEFT JOIN datacenter.dc_yangg_gkxzh gk
|
|||
|
ON gk.product_code = e.product_code --<2D><>ɢ<EFBFBD><C9A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
--left join datacenter.dc_yangg_zbxzh zb on zb.product_code = e.product_code --<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
LEFT JOIN dd
|
|||
|
ON dd.tid = qna.t_cre
|
|||
|
WHERE qna.tflag = '0'
|
|||
|
AND (CASE
|
|||
|
WHEN q.endorsement_no != '<27><>' AND
|
|||
|
round((pt.premium_amount - nvl(pt.taxamount,
|
|||
|
0)) * c.rate / 100,
|
|||
|
2) != 0 THEN
|
|||
|
'<27><>'
|
|||
|
END) IS NULL
|
|||
|
--and q.endorsement_no = '<27><>'
|
|||
|
AND e.policy_status = '1'
|
|||
|
AND gk.product_code IS NOT NULL
|
|||
|
AND (e.product_code LIKE '2%' OR e.product_code LIKE '1106%' --<2D>⽡ --<2D><><EFBFBD><EFBFBD>
|
|||
|
OR e.product_code LIKE '1107%' OR e.product_code LIKE '1108%' OR e.product_code LIKE '1307%' OR e.product_code LIKE '1304A400%' --<2D>Ҳ<EFBFBD>
|
|||
|
|
|||
|
)
|
|||
|
--and e.product_code not in ('22KC9800')
|
|||
|
AND q.signature_date >= to_date('2023-01-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND q.signature_date < to_date(to_char(SYSDATE - 1,
|
|||
|
'yyyy-mm-dd') || ' 23:59:59',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND e.planned_end_date - e.inception_date >= 90
|
|||
|
AND dd.tid IS NOT NULL
|
|||
|
--<2D><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF>)
|
|||
|
)
|
|||
|
--SELECT * FROM BB
|
|||
|
,
|
|||
|
cc AS
|
|||
|
(SELECT mm_f,
|
|||
|
tid <20>ں<EFBFBD>֤<EFBFBD><D6A4>,
|
|||
|
COUNT(DISTINCT bdh) <20>ںϱ<DABA><CFB1><EFBFBD>,
|
|||
|
SUM(bf) <20>ںϱ<DABA><CFB1><EFBFBD>
|
|||
|
FROM bb
|
|||
|
GROUP BY tid,
|
|||
|
mm_f),
|
|||
|
ff AS
|
|||
|
(SELECT dd.*,
|
|||
|
cc.*
|
|||
|
FROM dd
|
|||
|
LEFT JOIN cc
|
|||
|
ON cc.<2E>ں<EFBFBD>֤<EFBFBD><D6A4> = dd.tid
|
|||
|
AND cc.mm_f = dd.the_month) --OR cc.<2E>ں<EFBFBD>֤<EFBFBD><D6A4> = dd.btid
|
|||
|
--select * from ff
|
|||
|
SELECT to_date(ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
'yyyy-mm-dd') ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
the_year <20><><EFBFBD><EFBFBD>,
|
|||
|
the_month <20>·<EFBFBD>,
|
|||
|
bm <20><><EFBFBD><EFBFBD>,
|
|||
|
bmdm <20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>,
|
|||
|
<20><><EFBFBD><EFBFBD>N,
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N,
|
|||
|
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
<20><>ϯ<EFBFBD>Ŷ<EFBFBD>,
|
|||
|
nvl(SUM(<28><><EFBFBD><EFBFBD>),
|
|||
|
0) <20><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF><CDBB><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
nvl(SUM(<28>ںϱ<DABA><CFB1><EFBFBD>),
|
|||
|
0) <20><><EFBFBD><EFBFBD><EFBFBD>ںϱ<DABA><CFB1><EFBFBD>
|
|||
|
FROM ff
|
|||
|
WHERE to_date(ff.ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
'yyyy-mm-dd') >= a_start_date
|
|||
|
AND to_date(ff.ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
'yyyy-mm-dd') < a_end_date
|
|||
|
AND bm IN ('<27><><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>',
|
|||
|
'<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>˾')
|
|||
|
GROUP BY ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
the_year,
|
|||
|
the_month,
|
|||
|
bm,
|
|||
|
bmdm,
|
|||
|
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
<20><>ϯ<EFBFBD>Ŷ<EFBFBD>,
|
|||
|
<20><><EFBFBD><EFBFBD>N,
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N
|
|||
|
ORDER BY <20><><EFBFBD><EFBFBD>,
|
|||
|
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>;
|
|||
|
COMMIT;
|
|||
|
END;
|
|||
|
|
|||
|
/**********************************************************************/
|
|||
|
|
|||
|
PROCEDURE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IS
|
|||
|
BEGIN
|
|||
|
--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
desktop_archievement_admin.clean_mensual_renewal;
|
|||
|
|
|||
|
--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
INSERT INTO desktop_archievement_admin.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>
|
|||
|
WITH cc AS
|
|||
|
(SELECT pt.policy_no policy_no,
|
|||
|
SUM(pt.premium_amount) premium_amount,
|
|||
|
SUM(pt.tax_amount) tax_amount
|
|||
|
FROM idst0.auto_premium_t pt
|
|||
|
GROUP BY pt.policy_no)
|
|||
|
|
|||
|
,
|
|||
|
bb AS
|
|||
|
(SELECT t.policy_no <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
(CASE
|
|||
|
WHEN e.product_code LIKE '1102%' AND
|
|||
|
e.product_code NOT LIKE '110224%' AND
|
|||
|
e.product_code != '11026000' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>'
|
|||
|
WHEN e.product_code LIKE '1101%' OR
|
|||
|
e.product_code LIKE '1301%' OR
|
|||
|
e.product_code LIKE '11110000%' THEN
|
|||
|
'<27>Ʋ<EFBFBD><C6B2><EFBFBD>'
|
|||
|
WHEN e.product_code LIKE '1107%' OR
|
|||
|
e.product_code LIKE '1307%' OR
|
|||
|
e.product_code LIKE '1304A400%' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
WHEN e.product_code LIKE '1106%' OR
|
|||
|
e.product_code LIKE '51015700' THEN
|
|||
|
'<27>Ҳ<EFBFBD><D2B2><EFBFBD>'
|
|||
|
WHEN (e.product_code LIKE '1104%' OR e.product_code LIKE '1204%' OR e.product_code LIKE '13040000%') AND
|
|||
|
e.product_code NOT LIKE '120404%' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
WHEN e.product_code LIKE '1203%' OR
|
|||
|
e.product_code LIKE '1103%' OR
|
|||
|
e.product_code LIKE '120404%' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
WHEN e.product_code LIKE '1305%' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
WHEN e.product_code LIKE '111%' AND
|
|||
|
e.product_code NOT LIKE '11110000%' THEN
|
|||
|
'ũҵ<C5A9><D2B5>'
|
|||
|
WHEN e.product_code LIKE '1109%' OR
|
|||
|
e.product_code LIKE '1309%' THEN
|
|||
|
'<27><>֤<EFBFBD><D6A4><EFBFBD><EFBFBD>'
|
|||
|
WHEN e.product_code LIKE '1312%' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
WHEN e.product_code LIKE '1308%' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
WHEN e.product_code LIKE '23%' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
WHEN e.product_code LIKE '22%' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
WHEN e.product_code LIKE '110224%' OR
|
|||
|
e.product_code = '11026000' THEN
|
|||
|
'<27><>ǿ<EFBFBD><C7BF>'
|
|||
|
ELSE
|
|||
|
'δ<><CEB4><EFBFBD><EFBFBD>'
|
|||
|
END) AS <20><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>
|
|||
|
FROM idst0.auto_agreement_request_t t
|
|||
|
LEFT JOIN idst0.auto_agreement_t e
|
|||
|
ON e.policy_no = t.policy_no)
|
|||
|
|
|||
|
,
|
|||
|
aa1 AS
|
|||
|
(SELECT a.policy_no <20>ɱ<EFBFBD><C9B1><EFBFBD>,
|
|||
|
a.selling_shop_code <20><><EFBFBD>̴<EFBFBD><CCB4><EFBFBD>,
|
|||
|
a.planned_end_date <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>,
|
|||
|
CASE
|
|||
|
WHEN to_number(to_char(a.planned_end_date,
|
|||
|
'yyyy')) = '2022' AND
|
|||
|
a.selling_shop_code || a.tel_sale_4s_code = '00GK' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>רҵ<D7A8><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>'
|
|||
|
WHEN a.planned_end_date > to_date('2023-04-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss') AND
|
|||
|
(a.selling_shop_code || a.tel_sale_4s_code IN ('00EA',
|
|||
|
'00F1',
|
|||
|
'00G9')) THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>רҵ<D7A8><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>'
|
|||
|
ELSE
|
|||
|
nvl(dt.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
z.section_office_name)
|
|||
|
END <20><><EFBFBD><EFBFBD>,
|
|||
|
(CASE
|
|||
|
WHEN to_number(to_char(a.planned_end_date,
|
|||
|
'yyyy')) = '2023' AND
|
|||
|
nvl(dt.<2E><><EFBFBD><EFBFBD>,
|
|||
|
y.department_name) NOT LIKE '<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>˾' and<6E><64>cd.memo LIKE '%<25><><EFBFBD><EFBFBD>%' OR
|
|||
|
cd.memo LIKE '%<25><><EFBFBD><EFBFBD>%' <20><>and v.vehicle_brand IN ('<27><>˹<EFBFBD><CBB9>',
|
|||
|
'ε<><CEB5>',
|
|||
|
'<27><><EFBFBD><EFBFBD>',
|
|||
|
'С<><D0A1>',
|
|||
|
'<27><><EFBFBD><EFBFBD>',
|
|||
|
'<27><><EFBFBD><EFBFBD>',
|
|||
|
'AITO',
|
|||
|
'ARCFOX<4F><58><EFBFBD><EFBFBD>',
|
|||
|
'<27><>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>',
|
|||
|
'<27><>˹<EFBFBD><CBB9>(<28>й<EFBFBD>)') AND
|
|||
|
v.vin NOT IN ('LJ1E6A2UXL7744108',
|
|||
|
'LW433B10XL1001411',
|
|||
|
'LJ1E6A3U2L7742089',
|
|||
|
'L1NSPGHB0MA002652') THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>չ<EFBFBD><D5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
WHEN (CASE
|
|||
|
WHEN to_number(to_char(a.planned_end_date,
|
|||
|
'yyyy')) = '2022' AND
|
|||
|
a.selling_shop_code || a.tel_sale_4s_code = '00GK' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>˾'
|
|||
|
ELSE
|
|||
|
nvl(dt.<2E><><EFBFBD><EFBFBD>,
|
|||
|
y.department_name)
|
|||
|
END) = '<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>˾' THEN
|
|||
|
(CASE
|
|||
|
WHEN to_number(to_char(a.planned_end_date,
|
|||
|
'yyyy')) = '2022' AND
|
|||
|
a.selling_shop_code || a.tel_sale_4s_code = '00GK' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>˾'
|
|||
|
ELSE
|
|||
|
nvl(dt.<2E><><EFBFBD><EFBFBD>,
|
|||
|
y.department_name)
|
|||
|
END)
|
|||
|
WHEN <20><>cd.memo LIKE '%<25><><EFBFBD><EFBFBD>%' OR
|
|||
|
cd.memo LIKE '%<25><><EFBFBD><EFBFBD>%' <20><> THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>'
|
|||
|
WHEN a.planned_end_date > to_date('2023-04-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss') AND
|
|||
|
(a.selling_shop_code || a.tel_sale_4s_code IN ('00EA',
|
|||
|
'00F1',
|
|||
|
'00G9')) THEN
|
|||
|
'ͬ<><CDAC>֧<EFBFBD><D6A7>˾'
|
|||
|
ELSE
|
|||
|
(CASE
|
|||
|
WHEN to_number(to_char(a.planned_end_date,
|
|||
|
'yyyy')) = '2022' AND
|
|||
|
a.selling_shop_code || a.tel_sale_4s_code = '00GK' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>˾'
|
|||
|
ELSE
|
|||
|
nvl(dt.<2E><><EFBFBD><EFBFBD>,
|
|||
|
y.department_name)
|
|||
|
END)
|
|||
|
END) <20><><EFBFBD>β<EFBFBD><CEB2><EFBFBD>,
|
|||
|
qa.USAGE_XM ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
decode(qa.bd_type,
|
|||
|
'1',
|
|||
|
'<27><><EFBFBD><EFBFBD>ǿ',
|
|||
|
'2',
|
|||
|
'<27><><EFBFBD><EFBFBD>ҵ',
|
|||
|
'3',
|
|||
|
'<27><><EFBFBD>̹<EFBFBD><CCB9><EFBFBD>',
|
|||
|
'<27><><EFBFBD><EFBFBD>') <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
(CASE
|
|||
|
WHEN (qa.bd_type = '1' AND nt.ecompensation_rate > 1) THEN
|
|||
|
'<27><>'
|
|||
|
END) <20><>Ԥ<EFBFBD><D4A4>,
|
|||
|
x.staff_name AS <20><><EFBFBD><EFBFBD>,
|
|||
|
bb.<2E><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>,
|
|||
|
cc.signature_date <20>±<EFBFBD><C2B1><EFBFBD>ǩ<EFBFBD><C7A9>ʱ<EFBFBD><CAB1>,
|
|||
|
(SELECT hmd.<2E>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
FROM (SELECT DISTINCT *
|
|||
|
FROM dc_lsj_xb_hmd) hmd
|
|||
|
WHERE hmd.vin = v.vin) <20>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
FROM idst0.auto_agreement_t a
|
|||
|
LEFT JOIN bb
|
|||
|
ON bb.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = a.policy_no
|
|||
|
LEFT JOIN ywglxt.w_dxbd_i i
|
|||
|
ON a.policy_no = i.bdh
|
|||
|
LEFT JOIN idst0.motorised_vehicle_t v
|
|||
|
ON a.policy_no = v.policy_no
|
|||
|
LEFT JOIN ywglxt.q_auto_agreement_t qa
|
|||
|
ON qa.policy_no = a.policy_no
|
|||
|
|
|||
|
LEFT JOIN idst0.auto_new_product_info_t nt
|
|||
|
ON nt.policy_no = a.policy_no
|
|||
|
AND nt.endorsement_no = '<27><>'
|
|||
|
LEFT JOIN idst0.rydm_t x
|
|||
|
ON x.staff_code = nvl(upper(i.zhjywy),
|
|||
|
a.operator_code)
|
|||
|
LEFT JOIN idst0.bm_t y
|
|||
|
ON x.department_code = y.department_code
|
|||
|
LEFT JOIN idst0.ks_t z
|
|||
|
ON x.section_office_code = z.section_office_code
|
|||
|
LEFT JOIN cc pt
|
|||
|
ON pt.policy_no = a.policy_no
|
|||
|
LEFT JOIN (SELECT DISTINCT aa.policy_no,
|
|||
|
vv.vin,
|
|||
|
aa.inception_date,
|
|||
|
t.signature_date,
|
|||
|
(pt.premium_amount - nvl(pt.tax_amount,
|
|||
|
0)) qdbf,
|
|||
|
(CASE
|
|||
|
WHEN aa.inception_date - aa.issue_date >= '30' THEN
|
|||
|
vv.vin
|
|||
|
END) if30,
|
|||
|
bb.<2E><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>
|
|||
|
FROM idst0.auto_agreement_t aa
|
|||
|
LEFT JOIN bb
|
|||
|
ON bb.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = aa.policy_no
|
|||
|
LEFT JOIN idst0.motorised_vehicle_t vv
|
|||
|
ON vv.policy_no = aa.policy_no
|
|||
|
LEFT JOIN idst0.auto_agreement_request_t t
|
|||
|
ON t.policy_no = aa.policy_no
|
|||
|
AND t.endorsement_no = '<27><>'
|
|||
|
LEFT JOIN idst0.auto_premium_t pt
|
|||
|
ON pt.policy_no = aa.policy_no
|
|||
|
AND pt.endorsement_no = '<27><>'
|
|||
|
WHERE aa.policy_no = vv.policy_no
|
|||
|
AND aa.policy_status = '1' --and aa.product_code not in ('11022400','11023900','11024000','11024600','11026000')
|
|||
|
AND aa.branch_company_code = '3080100'
|
|||
|
AND (pt.premium_amount - nvl(pt.tax_amount,
|
|||
|
0)) > 100
|
|||
|
AND aa.inception_date >= to_date('2022-12-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND aa.inception_date < to_date('2023-11-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND aa.branch_company_code = vv.branch_company_code) cc
|
|||
|
ON (cc.vin = v.vin AND cc.<2E><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD> = bb.<2E><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>)
|
|||
|
AND cc.inception_date > a.planned_end_date - 30 --ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD>Ʒſ<C6B7>Ϊ30<33><30>
|
|||
|
LEFT JOIN dc_yangg_cx_dianxiaodoudi cd
|
|||
|
ON cd.policy_no = a.policy_no
|
|||
|
LEFT JOIN dc_tb_jc_c_tag dt
|
|||
|
ON dt.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = a.policy_no
|
|||
|
LEFT JOIN idst0.auto_agreement_t aa
|
|||
|
ON aa.policy_no = cc.policy_no
|
|||
|
LEFT JOIN cc pt1
|
|||
|
ON pt1.policy_no = aa.policy_no
|
|||
|
WHERE a.policy_status = '1'
|
|||
|
AND a.planned_end_date - a.inception_date > 270
|
|||
|
AND a.planned_end_date >= to_date('2023-01-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND a.planned_end_date < to_date('2023-10-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')),
|
|||
|
aa2 AS
|
|||
|
(SELECT a.policy_no <20>ɱ<EFBFBD><C9B1><EFBFBD>,
|
|||
|
a.selling_shop_code <20><><EFBFBD>̴<EFBFBD><CCB4><EFBFBD>,
|
|||
|
a.planned_end_date <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>,
|
|||
|
CASE
|
|||
|
WHEN to_number(to_char(a.planned_end_date,
|
|||
|
'yyyy')) = '2022' AND
|
|||
|
a.selling_shop_code || a.tel_sale_4s_code = '00GK' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>רҵ<D7A8><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>'
|
|||
|
WHEN a.planned_end_date > to_date('2023-04-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss') AND
|
|||
|
(a.selling_shop_code || a.tel_sale_4s_code IN ('00EA',
|
|||
|
'00F1',
|
|||
|
'00G9')) THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>רҵ<D7A8><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>'
|
|||
|
ELSE
|
|||
|
nvl(dt.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
z.section_office_name)
|
|||
|
END <20><><EFBFBD><EFBFBD>,
|
|||
|
(CASE
|
|||
|
WHEN to_number(to_char(a.planned_end_date,
|
|||
|
'yyyy')) = '2023' AND
|
|||
|
nvl(dt.<2E><><EFBFBD><EFBFBD>,
|
|||
|
y.department_name) NOT LIKE '<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>˾' and<6E><64>cd.memo LIKE '%<25><><EFBFBD><EFBFBD>%' OR
|
|||
|
cd.memo LIKE '%<25><><EFBFBD><EFBFBD>%' <20><>and v.vehicle_brand IN ('<27><>˹<EFBFBD><CBB9>',
|
|||
|
'ε<><CEB5>',
|
|||
|
'<27><><EFBFBD><EFBFBD>',
|
|||
|
'С<><D0A1>',
|
|||
|
'<27><><EFBFBD><EFBFBD>',
|
|||
|
'<27><><EFBFBD><EFBFBD>',
|
|||
|
'AITO',
|
|||
|
'ARCFOX<4F><58><EFBFBD><EFBFBD>',
|
|||
|
'<27><>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>',
|
|||
|
'<27><>˹<EFBFBD><CBB9>(<28>й<EFBFBD>)') AND
|
|||
|
v.vin NOT IN ('LJ1E6A2UXL7744108',
|
|||
|
'LW433B10XL1001411',
|
|||
|
'LJ1E6A3U2L7742089',
|
|||
|
'L1NSPGHB0MA002652') THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>չ<EFBFBD><D5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
WHEN (CASE
|
|||
|
WHEN to_number(to_char(a.planned_end_date,
|
|||
|
'yyyy')) = '2022' AND
|
|||
|
a.selling_shop_code || a.tel_sale_4s_code = '00GK' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>˾'
|
|||
|
ELSE
|
|||
|
nvl(dt.<2E><><EFBFBD><EFBFBD>,
|
|||
|
y.department_name)
|
|||
|
END) = '<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>˾' THEN
|
|||
|
(CASE
|
|||
|
WHEN to_number(to_char(a.planned_end_date,
|
|||
|
'yyyy')) = '2022' AND
|
|||
|
a.selling_shop_code || a.tel_sale_4s_code = '00GK' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>˾'
|
|||
|
ELSE
|
|||
|
nvl(dt.<2E><><EFBFBD><EFBFBD>,
|
|||
|
y.department_name)
|
|||
|
END)
|
|||
|
WHEN <20><>cd.memo LIKE '%<25><><EFBFBD><EFBFBD>%' OR
|
|||
|
cd.memo LIKE '%<25><><EFBFBD><EFBFBD>%' <20><> THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>'
|
|||
|
WHEN a.planned_end_date > to_date('2023-04-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss') AND
|
|||
|
(a.selling_shop_code || a.tel_sale_4s_code IN ('00EA',
|
|||
|
'00F1',
|
|||
|
'00G9')) THEN
|
|||
|
'ͬ<><CDAC>֧<EFBFBD><D6A7>˾'
|
|||
|
ELSE
|
|||
|
(CASE
|
|||
|
WHEN to_number(to_char(a.planned_end_date,
|
|||
|
'yyyy')) = '2022' AND
|
|||
|
a.selling_shop_code || a.tel_sale_4s_code = '00GK' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>˾'
|
|||
|
ELSE
|
|||
|
nvl(dt.<2E><><EFBFBD><EFBFBD>,
|
|||
|
y.department_name)
|
|||
|
END)
|
|||
|
END) <20><><EFBFBD>β<EFBFBD><CEB2><EFBFBD>,
|
|||
|
qa.USAGE_XM ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
decode(qa.bd_type,
|
|||
|
'1',
|
|||
|
'<27><><EFBFBD><EFBFBD>ǿ',
|
|||
|
'2',
|
|||
|
'<27><><EFBFBD><EFBFBD>ҵ',
|
|||
|
'3',
|
|||
|
'<27><><EFBFBD>̹<EFBFBD><CCB9><EFBFBD>',
|
|||
|
'<27><><EFBFBD><EFBFBD>') <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
(CASE
|
|||
|
WHEN (qa.bd_type = '1' AND nt.ecompensation_rate > 1) THEN
|
|||
|
'<27><>'
|
|||
|
END) <20><>Ԥ<EFBFBD><D4A4>,
|
|||
|
x.staff_name AS <20><><EFBFBD><EFBFBD>,
|
|||
|
bb.<2E><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>,
|
|||
|
cc.signature_date <20>±<EFBFBD><C2B1><EFBFBD>ǩ<EFBFBD><C7A9>ʱ<EFBFBD><CAB1>,
|
|||
|
(SELECT hmd.<2E>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
FROM (SELECT DISTINCT *
|
|||
|
FROM dc_lsj_xb_hmd) hmd
|
|||
|
WHERE hmd.vin = v.vin) <20>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
FROM idst0.auto_agreement_t a
|
|||
|
LEFT JOIN bb
|
|||
|
ON bb.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = a.policy_no
|
|||
|
LEFT JOIN ywglxt.w_dxbd_i i
|
|||
|
ON a.policy_no = i.bdh
|
|||
|
LEFT JOIN idst0.motorised_vehicle_t v
|
|||
|
ON a.policy_no = v.policy_no
|
|||
|
LEFT JOIN ywglxt.q_auto_agreement_t qa
|
|||
|
ON qa.policy_no = a.policy_no
|
|||
|
LEFT JOIN idst0.auto_new_product_info_t nt
|
|||
|
ON nt.policy_no = a.policy_no
|
|||
|
AND nt.endorsement_no = '<27><>'
|
|||
|
LEFT JOIN idst0.rydm_t x
|
|||
|
ON x.staff_code = nvl(upper(i.zhjywy),
|
|||
|
a.operator_code)
|
|||
|
LEFT JOIN idst0.bm_t y
|
|||
|
ON x.department_code = y.department_code
|
|||
|
LEFT JOIN idst0.ks_t z
|
|||
|
ON x.section_office_code = z.section_office_code
|
|||
|
LEFT JOIN cc pt
|
|||
|
ON pt.policy_no = a.policy_no
|
|||
|
LEFT JOIN (SELECT DISTINCT aa.policy_no,
|
|||
|
vv.vin,
|
|||
|
aa.inception_date,
|
|||
|
t.signature_date,
|
|||
|
(pt.premium_amount - nvl(pt.tax_amount,
|
|||
|
0)) qdbf,
|
|||
|
(CASE
|
|||
|
WHEN aa.inception_date - aa.issue_date >= '30' THEN
|
|||
|
vv.vin
|
|||
|
END) if30,
|
|||
|
bb.<2E><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>
|
|||
|
FROM idst0.auto_agreement_t aa
|
|||
|
LEFT JOIN bb
|
|||
|
ON bb.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = aa.policy_no
|
|||
|
LEFT JOIN idst0.motorised_vehicle_t vv
|
|||
|
ON vv.policy_no = aa.policy_no
|
|||
|
LEFT JOIN idst0.auto_agreement_request_t t
|
|||
|
ON t.policy_no = aa.policy_no
|
|||
|
AND t.endorsement_no = '<27><>'
|
|||
|
LEFT JOIN idst0.auto_premium_t pt
|
|||
|
ON pt.policy_no = aa.policy_no
|
|||
|
AND pt.endorsement_no = '<27><>'
|
|||
|
WHERE aa.policy_no = vv.policy_no
|
|||
|
AND aa.policy_status = '1' --and aa.product_code not in ('11022400','11023900','11024000','11024600','11026000')
|
|||
|
AND aa.branch_company_code = '3080100'
|
|||
|
AND (pt.premium_amount - nvl(pt.tax_amount,
|
|||
|
0)) > 100
|
|||
|
AND aa.inception_date >= to_date('2022-12-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND aa.inception_date < to_date('2023-11-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND aa.branch_company_code = vv.branch_company_code) cc
|
|||
|
ON (cc.vin = v.vin AND cc.<2E><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD> = bb.<2E><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>)
|
|||
|
AND cc.inception_date > a.planned_end_date - 30 --ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD>Ʒſ<C6B7>Ϊ30<33><30>
|
|||
|
LEFT JOIN dc_yangg_cx_dianxiaodoudi cd
|
|||
|
ON cd.policy_no = a.policy_no
|
|||
|
LEFT JOIN dc_tb_jc_c_tag dt
|
|||
|
ON dt.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = a.policy_no
|
|||
|
LEFT JOIN idst0.auto_agreement_t aa
|
|||
|
ON aa.policy_no = cc.policy_no
|
|||
|
LEFT JOIN cc pt1
|
|||
|
ON pt1.policy_no = aa.policy_no
|
|||
|
WHERE a.policy_status = '1'
|
|||
|
AND a.planned_end_date - a.inception_date > 270
|
|||
|
AND a.planned_end_date >= to_date('2023-10-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND a.planned_end_date < to_date('2024-01-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss'))
|
|||
|
|
|||
|
,
|
|||
|
aa3 AS
|
|||
|
(SELECT DISTINCT *
|
|||
|
FROM aa1
|
|||
|
UNION ALL (SELECT DISTINCT *
|
|||
|
FROM aa2))
|
|||
|
|
|||
|
,
|
|||
|
AA AS
|
|||
|
(SELECT AA3.*,
|
|||
|
nvl<76><6C>zx.workerno,
|
|||
|
et.telpartnercode) <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
(CASE WHEN nvl<76><6C>zx.workerno,
|
|||
|
et.telpartnercode) =
|
|||
|
'DX001' AND aa3.<2E><><EFBFBD><EFBFBD> LIKE
|
|||
|
'%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%' THEN
|
|||
|
'<27><>ΰ<EFBFBD><CEB0>' WHEN nvl<76><6C>zx.workerno,
|
|||
|
et.telpartnercode) =
|
|||
|
'DX001' AND aa3.<2E><><EFBFBD><EFBFBD> NOT LIKE
|
|||
|
'%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%' THEN
|
|||
|
'<27><><EFBFBD><EFBFBD>' ELSE to_char
|
|||
|
(ys.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>) END) <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
YS.<2E>Ŷ<EFBFBD> <20><>ϯ<EFBFBD>Ŷ<EFBFBD> FROM AA3 LEFT JOIN idst0.auto_agreement_extend_t et ON et.policy_no = AA3.<2E>ɱ<EFBFBD><C9B1><EFBFBD> LEFT JOIN idst0.t_sell_policy_autobase_t zx ON zx.policy_no = AA3.<2E>ɱ<EFBFBD><C9B1><EFBFBD> LEFT JOIN dc_YZH_ZXYS YS ON YS.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD> = nvl<76><6C>zx.workerno,
|
|||
|
et.telpartnercode))
|
|||
|
|
|||
|
,
|
|||
|
yxb AS
|
|||
|
(
|
|||
|
---<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
SELECT aa.<2E><><EFBFBD>β<EFBFBD><CEB2><EFBFBD> <20><><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD>Ŷ<EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
--(case when a.<2E><>ʶ='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'and A.<2E><><EFBFBD>β<EFBFBD><CEB2><EFBFBD>='<27><><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>' then '<27><><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>' else A.<2E><><EFBFBD><EFBFBD> end) <20><><EFBFBD><EFBFBD>,
|
|||
|
(CASE
|
|||
|
WHEN COUNT(1) IS NULL THEN
|
|||
|
0
|
|||
|
ELSE
|
|||
|
COUNT(1)
|
|||
|
END) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>
|
|||
|
FROM aa
|
|||
|
WHERE aa.ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IN ('<27><>ͥ<EFBFBD><CDA5><EFBFBD>ó<EFBFBD>',
|
|||
|
'<27><>ҵ<EFBFBD>ͳ<EFBFBD>')
|
|||
|
AND aa.<2E><>Ԥ<EFBFBD><D4A4> IS NULL
|
|||
|
AND aa.<2E>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD> IS NULL
|
|||
|
AND aa.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IN <20><> '<27><><EFBFBD>̹<EFBFBD><CCB9><EFBFBD>', '<27><><EFBFBD><EFBFBD>ǿ' <20><>
|
|||
|
AND aa.<2E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> >= to_date(to_char(SYSDATE,
|
|||
|
'yyyy-mm') || '-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND aa.<2E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> < to_date(to_char(SYSDATE - 1,
|
|||
|
'yyyy-mm-dd') || ' 23:59:59',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND aa.<2E>±<EFBFBD><C2B1><EFBFBD>ǩ<EFBFBD><C7A9>ʱ<EFBFBD><CAB1> <= to_date(to_char(SYSDATE - 1,
|
|||
|
'yyyy-mm-dd') || ' 23:59:59',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
GROUP BY aa.<2E><><EFBFBD>β<EFBFBD><CEB2><EFBFBD>,
|
|||
|
aa.<2E><><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD>Ŷ<EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>)
|
|||
|
--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D>ۼ<EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D>ۼ<EFBFBD>
|
|||
|
,
|
|||
|
dqs AS
|
|||
|
(
|
|||
|
---<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
SELECT aa.<2E><><EFBFBD>β<EFBFBD><CEB2><EFBFBD> <20><><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD>Ŷ<EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
(CASE
|
|||
|
WHEN COUNT(1) IS NULL THEN
|
|||
|
0
|
|||
|
ELSE
|
|||
|
COUNT(1)
|
|||
|
END) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
FROM aa
|
|||
|
WHERE aa.ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IN ('<27><>ͥ<EFBFBD><CDA5><EFBFBD>ó<EFBFBD>',
|
|||
|
'<27><>ҵ<EFBFBD>ͳ<EFBFBD>')
|
|||
|
AND aa.<2E><>Ԥ<EFBFBD><D4A4> IS NULL
|
|||
|
AND aa.<2E>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD> IS NULL
|
|||
|
AND aa.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IN <20><> '<27><><EFBFBD>̹<EFBFBD><CCB9><EFBFBD>', '<27><><EFBFBD><EFBFBD>ǿ' <20><>
|
|||
|
AND aa.<2E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> >= to_date(to_char(SYSDATE,
|
|||
|
'yyyy-mm') || '-01 00:00:00',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
AND aa.<2E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> < to_date(to_char(SYSDATE - 1,
|
|||
|
'yyyy-mm-dd') || ' 23:59:59',
|
|||
|
'yyyy-mm-dd hh24:mi:ss')
|
|||
|
GROUP BY aa.<2E><><EFBFBD>β<EFBFBD><CEB2><EFBFBD>,
|
|||
|
aa.<2E><><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD>Ŷ<EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
aa.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>)
|
|||
|
SELECT dqs.<2E><><EFBFBD><EFBFBD>,
|
|||
|
dqs.<2E><><EFBFBD><EFBFBD>,
|
|||
|
dqs.<2E><><EFBFBD><EFBFBD>,
|
|||
|
dqs.<2E><>ϯ<EFBFBD>Ŷ<EFBFBD>,
|
|||
|
dqs.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
dqs.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
|
|||
|
yxb.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>,
|
|||
|
dqs.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
FROM yxb,
|
|||
|
dqs --,sdqs,syxs,cyxs,cdqs
|
|||
|
WHERE dqs.<2E><><EFBFBD><EFBFBD> = yxb.<2E><><EFBFBD><EFBFBD>
|
|||
|
AND dqs.<2E><><EFBFBD><EFBFBD> = yxb.<2E><><EFBFBD><EFBFBD>
|
|||
|
AND dqs.<2E><><EFBFBD><EFBFBD> = yxb.<2E><><EFBFBD><EFBFBD>
|
|||
|
AND dqs.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD> = yxb.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>
|
|||
|
AND dqs.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD> = yxb.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>;
|
|||
|
COMMIT;
|
|||
|
END;
|
|||
|
|
|||
|
PROCEDURE chefei_daily_job IS
|
|||
|
BEGIN
|
|||
|
<20><><EFBFBD>ǻ<EFBFBD><C7BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(SYSDATE - 3,
|
|||
|
SYSDATE);
|
|||
|
END;
|
|||
|
|
|||
|
PROCEDURE xubao_daily_job IS
|
|||
|
BEGIN
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
END;
|
|||
|
|
|||
|
BEGIN
|
|||
|
NULL;
|
|||
|
END telsale_pkg;
|
|||
|
/
|