desktop_task_schedule/code/db/pkg/telsale_archievement_pkg.pck

177 lines
5.8 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-06-05 10:09:40 +00:00
-- <20>
DEPARTMENTCODE_EXCEPTION_CODE CONSTANT INTEGER := -20000;
DEPARTMENTCODE_EXCEPTION_MSG CONSTANT VARCHAR2(100) := '<27><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>Ч';
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
(
2023-06-05 10:09:40 +00:00
a_department_code IN VARCHAR2,
a_year IN VARCHAR2,
a_month IN VARCHAR2,
a_attaching_ranking_list OUT cur_type,
a_renewal_ranking_list OUT cur_type
2023-06-02 10:04:26 +00:00
);
2023-03-10 09:32:13 +00:00
END telsale_archievement_pkg;
/
CREATE OR REPLACE PACKAGE BODY telsale_archievement_pkg IS
2023-07-27 13:43:56 +00:00
-- <20><><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>
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-06-04 11:11:44 +00:00
l_this_year VARCHAR2(4);
l_firstday 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,
2023-06-04 11:11:44 +00:00
'mm');
l_this_year := to_char(SYSDATE,
'yyyy');
l_firstday := to_date(to_char(SYSDATE,
'yyyy') || '-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss');
2023-06-05 10:09:40 +00:00
-- <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BEGIN
SELECT department_name
INTO l_department_name
FROM idst0.bm_t bm
WHERE bm.department_code = a_department_code;
EXCEPTION
-- <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׳<EFBFBD><D7B3>
WHEN NO_DATA_FOUND THEN
raise_application_error(DEPARTMENTCODE_EXCEPTION_CODE,
DEPARTMENTCODE_EXCEPTION_MSG);
END;
2023-05-18 07:40:04 +00:00
--<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-06-04 11:11:44 +00:00
FROM <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD> cf
2023-05-12 16:44:28 +00:00
WHERE cf.<2E>·<EFBFBD> = l_this_month
2023-06-04 11:11:44 +00:00
AND cf.<2E><><EFBFBD><EFBFBD> = l_this_year
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
2023-06-04 11:11:44 +00:00
FROM <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD> cf
2023-05-18 07:40:04 +00:00
WHERE <20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD> = a_department_code
2023-06-04 11:11:44 +00:00
AND ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >= l_firstday
2023-05-18 07:40:04 +00:00
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
2023-06-04 11:11:44 +00:00
FROM <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD> cf
2023-05-18 07:40:04 +00:00
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-05 10:09:40 +00:00
/*******************************************************/
-- <20><>ϯ<EFBFBD><CFAF><EFBFBD>а<EFBFBD>
2023-06-02 10:04:26 +00:00
PROCEDURE caller_arch_ranking_list
(
2023-06-05 10:09:40 +00:00
a_department_code IN VARCHAR2,
a_year IN VARCHAR2,
a_month IN VARCHAR2,
a_attaching_ranking_list OUT cur_type,
a_renewal_ranking_list OUT cur_type
2023-06-02 10:04:26 +00:00
) IS
2023-06-05 10:09:40 +00:00
l_department_name VARCHAR2(100);
2023-06-02 10:04:26 +00:00
BEGIN
2023-06-05 10:09:40 +00:00
-- <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BEGIN
SELECT department_name
INTO l_department_name
FROM idst0.bm_t bm
WHERE bm.department_code = a_department_code;
EXCEPTION
-- <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׳<EFBFBD><D7B3>
WHEN NO_DATA_FOUND THEN
raise_application_error(DEPARTMENTCODE_EXCEPTION_CODE,
DEPARTMENTCODE_EXCEPTION_MSG);
END;
2023-06-02 10:04:26 +00:00
2023-06-05 10:09:40 +00:00
-- <20><><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><DABA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD>
OPEN a_attaching_ranking_list FOR
2023-06-02 10:04:26 +00:00
SELECT <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
2023-07-27 13:43:56 +00:00
round(decode(SUM(<28><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF><CDBB><EFBFBD><EFBFBD><EFBFBD>),
0,
0,
(SUM(<28><><EFBFBD><EFBFBD><EFBFBD>ںϱ<DABA><CFB1><EFBFBD>) / SUM(<28><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF><CDBB><EFBFBD><EFBFBD><EFBFBD>)) * 100),
2023-06-02 10:04:26 +00:00
2) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>
2023-06-04 11:11:44 +00:00
FROM <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>
2023-06-05 10:09:40 +00:00
WHERE <20>·<EFBFBD> = a_month
AND <20><><EFBFBD><EFBFBD> = a_year
2023-06-02 10:04:26 +00:00
AND <20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD> = a_department_code
2023-06-05 10:09:40 +00:00
GROUP BY <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>
2023-06-02 10:04:26 +00:00
ORDER BY <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8> DESC;
2023-06-05 10:09:40 +00:00
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD>
OPEN a_renewal_ranking_list FOR
SELECT <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>,
2023-06-06 09:31:16 +00:00
round(nvl((SUM(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>) / SUM(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)) * 100,
2023-06-05 10:09:40 +00:00
0),
2) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FROM <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3> xb
2023-06-06 09:31:16 +00:00
WHERE xb.<2E><><EFBFBD><EFBFBD> = l_department_name
GROUP BY <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>
2023-06-05 10:09:40 +00:00
ORDER BY <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DESC;
2023-06-02 10:04:26 +00:00
END;
2023-03-10 09:32:13 +00:00
BEGIN
NULL;
END telsale_archievement_pkg;
/