desktop_task_schedule/code/db/pkg/telsale_archievement_pkg.pck

130 lines
4.0 KiB
Plaintext
Raw Normal View History

2023-03-10 09:32:13 +00:00
CREATE OR REPLACE PACKAGE telsale_archievement_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>
2023-05-18 07:40:04 +00:00
TYPE cur_type IS REF CURSOR;
2023-05-15 12:06:17 +00:00
PROCEDURE department_archievement
2023-03-14 01:47:53 +00:00
(
2023-05-15 12:06:17 +00:00
a_department_code IN VARCHAR2,
a_attaching_rate OUT VARCHAR2,
2023-05-18 07:40:04 +00:00
a_renewal_rate OUT VARCHAR2,
2023-05-18 10:22:05 +00:00
a_total OUT INTEGER,
2023-05-18 07:40:04 +00:00
a_mensual_cur OUT cur_type
2023-03-14 01:47:53 +00:00
);
2023-06-02 10:04:26 +00:00
PROCEDURE caller_arch_ranking_list
(
a_department_code IN VARCHAR2,
a_ranking_list OUT cur_type
);
2023-03-10 09:32:13 +00:00
END telsale_archievement_pkg;
/
CREATE OR REPLACE PACKAGE BODY telsale_archievement_pkg IS
2023-05-12 16:44:28 +00:00
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>
2023-05-15 12:06:17 +00:00
PROCEDURE department_archievement
2023-03-14 01:47:53 +00:00
(
2023-05-15 12:06:17 +00:00
a_department_code IN VARCHAR2,
a_attaching_rate OUT VARCHAR2,
2023-05-18 07:40:04 +00:00
a_renewal_rate OUT VARCHAR2,
2023-05-18 10:22:05 +00:00
a_total OUT INTEGER,
2023-05-18 07:40:04 +00:00
a_mensual_cur OUT cur_type
2023-03-14 01:47:53 +00:00
) IS
2023-05-15 12:06:17 +00:00
l_this_month VARCHAR2(4);
2023-05-18 07:40:04 +00:00
l_this_year DATE;
2023-05-15 12:06:17 +00:00
l_department_name VARCHAR2(100);
2023-03-14 01:47:53 +00:00
BEGIN
2023-05-12 16:44:28 +00:00
l_this_month := to_char(SYSDATE,
'mm') || '<27><>';
2023-04-04 09:58:05 +00:00
2023-05-18 07:40:04 +00:00
l_this_year := to_date(to_char(SYSDATE,
'yyyy') || '-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss');
SELECT bm.department_name
INTO l_department_name
FROM idst0.bm_t bm
WHERE bm.department_code = a_department_code;
--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>
2023-05-15 12:06:17 +00:00
SELECT decode(SUM(cf.<2E><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF><CDBB><EFBFBD><EFBFBD><EFBFBD>),
0,
0,
round((SUM(cf.<2E><><EFBFBD><EFBFBD><EFBFBD>ںϱ<DABA><CFB1><EFBFBD>) / SUM(cf.<2E><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF><CDBB><EFBFBD><EFBFBD><EFBFBD>) * 100),
2))
INTO a_attaching_rate
2023-05-12 16:44:28 +00:00
FROM <20><><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD> cf
WHERE cf.<2E>·<EFBFBD> = l_this_month
2023-05-15 12:06:17 +00:00
AND <20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD> = a_department_code;
2023-05-18 07:40:04 +00:00
--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2023-05-15 12:06:17 +00:00
SELECT decode(SUM(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),
0,
0,
round(SUM(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>) / SUM(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) * 100,
2))
INTO a_renewal_rate
FROM <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>
WHERE <20><><EFBFBD><EFBFBD> = l_department_name;
2023-05-18 07:40:04 +00:00
--<2D><>ҵ<EFBFBD><D2B5>
SELECT round(nvl(SUM(cf.<2E><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF><CDBB><EFBFBD><EFBFBD><EFBFBD> + cf.<2E><><EFBFBD><EFBFBD><EFBFBD>ںϱ<DABA><CFB1><EFBFBD>),
0),
0)
INTO a_total
FROM <20><><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD> cf
WHERE <20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD> = a_department_code
AND ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >= l_this_year
AND ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <= SYSDATE;
--ÿ<><C3BF>ҵ<EFBFBD><D2B5>
OPEN a_mensual_cur FOR
SELECT cf.<2E>·<EFBFBD> mm,
2023-05-18 10:22:05 +00:00
round(nvl(SUM(cf.<2E><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF><CDBB><EFBFBD><EFBFBD><EFBFBD> + cf.<2E><><EFBFBD><EFBFBD><EFBFBD>ںϱ<DABA><CFB1><EFBFBD>) / 10000,
2023-05-18 07:40:04 +00:00
0),
0) bf
FROM <20><><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD> cf
WHERE <20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD> = a_department_code
AND ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >= to_date(to_char(SYSDATE,
'yyyy') || '-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
2023-05-18 10:22:05 +00:00
AND ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> < to_date(to_char(SYSDATE,
'yyyy-mm') || '-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
2023-05-18 07:40:04 +00:00
GROUP BY cf.<2E>·<EFBFBD>
ORDER BY cf.<2E>·<EFBFBD>;
2023-04-04 09:58:05 +00:00
END;
2023-06-02 10:04:26 +00:00
PROCEDURE caller_arch_ranking_list
(
a_department_code IN VARCHAR2,
a_ranking_list OUT cur_type
) IS
l_current_month VARCHAR2(10);
BEGIN
l_current_month := to_char(SYSDATE,
'mm') || '<27><>';
OPEN a_ranking_list FOR
SELECT <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
round(SUM(<28><><EFBFBD><EFBFBD><EFBFBD>ںϱ<DABA><CFB1><EFBFBD>) / SUM(<28><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF><CDBB><EFBFBD><EFBFBD><EFBFBD>) * 100,
2) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>
FROM <20><><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>
WHERE <20>·<EFBFBD> = l_current_month
AND <20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD> = a_department_code
GROUP BY <20>·<EFBFBD>,
<20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>,
<20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>
HAVING <20>·<EFBFBD> = '06<30><36>'
ORDER BY <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8> DESC;
END;
2023-03-10 09:32:13 +00:00
BEGIN
NULL;
END telsale_archievement_pkg;
/