desktop_task_schedule/code/db/pkg/telsale_archievement_pkg.pck

310 lines
10 KiB
Plaintext
Raw Normal View History

2023-12-20 14:40:27 +00:00
CREATE OR REPLACE PACKAGE TELSALE_ARCHIEVEMENT_PKG IS
2023-03-10 09:32:13 +00:00
-- 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-03-10 09:32:13 +00:00
2023-12-20 14:40:27 +00:00
TYPE CUR_TYPE IS REF CURSOR;
2023-05-18 07:40:04 +00:00
-- <20>
DEPARTMENTCODE_EXCEPTION_CODE CONSTANT INTEGER := -20000;
DEPARTMENTCODE_EXCEPTION_MSG CONSTANT VARCHAR2(100) := '<27><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>';
2023-08-25 12:47:36 +00:00
CALLERCODE_EXCEPTION_CODE CONSTANT INTEGER := -20001;
CALLERCODE_EXCEPTION_MSG CONSTANT VARCHAR2(100) := '<27><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>';
2023-06-05 10:09:40 +00:00
2023-12-20 14:40:27 +00:00
PROCEDURE DEPARTMENT_ARCHIEVEMENT
(
2023-12-20 14:40:27 +00:00
A_DEPARTMENT_CODE IN VARCHAR2,
A_ATTACHING_RATE OUT VARCHAR2,
A_ATTACHING_RATE_TARGET OUT VARCHAR2,
A_RENEWAL_RATE OUT VARCHAR2,
A_RENEWAL_RATE_TARGET OUT VARCHAR2,
A_TOTAL OUT INTEGER,
A_MENSUAL_CUR OUT CUR_TYPE
);
2023-03-14 01:47:53 +00:00
2023-12-20 14:40:27 +00:00
PROCEDURE CALLER_ARCHIEVEMENT
(
2023-12-20 14:40:27 +00:00
A_CALLER_CODE IN VARCHAR2,
A_ATTACHING_RATE OUT VARCHAR2,
A_RENEWAL_RATE OUT VARCHAR2,
A_TOTAL OUT INTEGER,
A_PRESENT_MONTH OUT NUMBER,
A_MENSUAL_CUR OUT CUR_TYPE
);
2023-08-25 12:47:36 +00:00
2023-12-20 14:40:27 +00:00
PROCEDURE CALLER_ARCH_RANKING_LIST
(
2023-12-20 14:40:27 +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-12-20 14:40:27 +00:00
END TELSALE_ARCHIEVEMENT_PKG;
2023-03-10 09:32:13 +00:00
/
2023-12-20 14:40:27 +00:00
CREATE OR REPLACE PACKAGE BODY TELSALE_ARCHIEVEMENT_PKG IS
-- <20><><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>
PROCEDURE DEPARTMENT_ARCHIEVEMENT
(
2023-12-20 14:40:27 +00:00
A_DEPARTMENT_CODE IN VARCHAR2,
A_ATTACHING_RATE OUT VARCHAR2,
A_ATTACHING_RATE_TARGET OUT VARCHAR2,
A_RENEWAL_RATE OUT VARCHAR2,
A_RENEWAL_RATE_TARGET OUT VARCHAR2,
A_TOTAL OUT INTEGER,
A_MENSUAL_CUR OUT CUR_TYPE
) IS
2023-12-20 14:40:27 +00:00
L_FIRSTDAY DATE;
L_DEPARTMENT_NAME VARCHAR2(100);
L_RENEWAL_RATE_TARGET NUMBER;
2023-03-14 01:47:53 +00:00
BEGIN
L_FIRSTDAY := TO_DATE(TO_CHAR(SYSDATE,
'yyyy') || '-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss');
-- <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BEGIN
2023-12-20 14:40:27 +00:00
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-12-20 14:40:27 +00:00
--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>&Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BEGIN
2023-12-20 14:40:27 +00:00
SELECT ROUND(DEPT.<2E><><EFBFBD>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>,
2),
ROUND(DEPT.Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
2)
2023-12-20 14:40:27 +00:00
INTO A_ATTACHING_RATE,
A_ATTACHING_RATE_TARGET
FROM BI<42><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD>ʸ<EFBFBD><CAB8>ٱ<EFBFBD> DEPT
2023-12-20 14:40:27 +00:00
WHERE DEPT.<2E><><EFBFBD><EFBFBD> = L_DEPARTMENT_NAME;
--<2D><><EFBFBD><EFBFBD>round<6E><64><EFBFBD><EFBFBD>С<EFBFBD><D0A1>ȱ0<C8B1><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SELECT DECODE(SUBSTR(A_ATTACHING_RATE_TARGET,
1,
1),
'.',
'0' || A_ATTACHING_RATE_TARGET,
A_ATTACHING_RATE_TARGET)
INTO A_ATTACHING_RATE_TARGET
FROM DUAL;
EXCEPTION
2023-12-20 14:40:27 +00:00
WHEN NO_DATA_FOUND THEN
A_ATTACHING_RATE := '0.0';
A_ATTACHING_RATE_TARGET := '0.0';
END;
2023-12-20 14:40:27 +00:00
--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>&Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BEGIN
2023-12-20 14:40:27 +00:00
SELECT ROUND(t."<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD>ʱ<EFBFBD><CAB1>(%)",
2),
ROUND(t."<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD>ʱ<EFBFBD><CAB1>(%)" - t."<22><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ֵ1(%)",
2)
2023-12-20 14:40:27 +00:00
INTO A_RENEWAL_RATE,
A_RENEWAL_RATE_TARGET
FROM "BI<42><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8>ٱ<EFBFBD>-24<32><34>" T
2023-12-20 14:40:27 +00:00
WHERE T.<2E><><EFBFBD>β<EFBFBD><CEB2><EFBFBD> = L_DEPARTMENT_NAME;
--<2D><><EFBFBD><EFBFBD>round<6E><64><EFBFBD><EFBFBD>С<EFBFBD><D0A1>ȱ0<C8B1><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SELECT DECODE(SUBSTR(A_RENEWAL_RATE_TARGET,
1,
1),
'.',
'0' || A_RENEWAL_RATE_TARGET,
A_RENEWAL_RATE_TARGET)
INTO A_RENEWAL_RATE_TARGET
FROM DUAL;
EXCEPTION
2023-12-20 14:40:27 +00:00
WHEN NO_DATA_FOUND THEN
A_RENEWAL_RATE := '0.0';
A_RENEWAL_RATE_TARGET := '0.0';
END;
2023-12-20 14:40:27 +00:00
--<2D><>ҵ<EFBFBD><D2B5>
2023-12-20 14:40:27 +00:00
A_TOTAL := 0;
--ÿ<><C3BF>ҵ<EFBFBD><D2B5>
OPEN A_MENSUAL_CUR FOR
SELECT CF.<2E>·<EFBFBD> MM,
ROUND(NVL(SUM(CF.<2E><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF><CDBB><EFBFBD><EFBFBD><EFBFBD> + CF.<2E><><EFBFBD><EFBFBD><EFBFBD>ںϱ<DABA><CFB1><EFBFBD>) / 10000,
0),
0) BF
FROM <20><>ϯ<EFBFBD><CFAF><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')
AND ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> < TO_DATE(TO_CHAR(SYSDATE,
'yyyy-mm') || '-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
GROUP BY CF.<2E>·<EFBFBD>
ORDER BY CF.<2E>·<EFBFBD>;
2023-08-25 12:47:36 +00:00
END;
/*******************************************************/
-- <20><>ϯҵ<CFAF><D2B5>
2023-12-20 14:40:27 +00:00
PROCEDURE CALLER_ARCHIEVEMENT
(
2023-12-20 14:40:27 +00:00
A_CALLER_CODE IN VARCHAR2,
A_ATTACHING_RATE OUT VARCHAR2,
A_RENEWAL_RATE OUT VARCHAR2,
A_TOTAL OUT INTEGER,
A_PRESENT_MONTH OUT NUMBER,
A_MENSUAL_CUR OUT CUR_TYPE
) IS
2023-12-20 14:40:27 +00:00
L_CALLER_NAME VARCHAR2(100);
L_DEPARTMENT_NAME VARCHAR2(100);
L_THIS_YEAR VARCHAR2(4);
L_ROWNUM INTEGER;
2023-08-25 12:47:36 +00:00
BEGIN
--<2D><>ѯ<EFBFBD><D1AF>ϯ<EFBFBD><CFAF><EFBFBD>ƣ<EFBFBD><C6A3>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD>
BEGIN
2023-12-20 14:40:27 +00:00
SELECT ZX.<2E><>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>,
BM.DEPARTMENT_NAME
INTO L_CALLER_NAME,
L_DEPARTMENT_NAME
FROM TWR_TELSALER ZX,
TWR_TELSALER_TEAM T,
IDST0.BM_T BM
WHERE ZX.<2E><>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD> = A_CALLER_CODE
AND ZX.<2E>Ŷ<EFBFBD><C5B6><EFBFBD><EFBFBD><EFBFBD> = T.TEAM_NAME
AND T.DEPARTMENT_CODE = BM.DEPARTMENT_CODE;
EXCEPTION
-- <20><><EFBFBD><EFBFBD>û<EFBFBD>в<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>ϯ<EFBFBD><CFAF><EFBFBD>ƣ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׳<EFBFBD><D7B3>
2023-12-20 14:40:27 +00:00
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(CALLERCODE_EXCEPTION_CODE,
CALLERCODE_EXCEPTION_MSG);
END;
2023-12-20 14:40:27 +00:00
L_THIS_YEAR := TO_CHAR(SYSDATE,
'yyyy');
--<2D>ܳ<EFBFBD><DCB3>ձ<EFBFBD><D5B1><EFBFBD>
2023-12-20 14:40:27 +00:00
SELECT ROUND(NVL(SUM(CF.<2E><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF><CDBB><EFBFBD><EFBFBD><EFBFBD>),
0),
2023-12-20 14:40:27 +00:00
2) BF
INTO A_TOTAL
FROM <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD> CF
WHERE CF.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD> = L_CALLER_NAME
AND CF.<2E><><EFBFBD><EFBFBD> = L_DEPARTMENT_NAME
AND CF.<2E><><EFBFBD><EFBFBD> = L_THIS_YEAR;
--<2D><>͸<EFBFBD><CDB8>
BEGIN
2023-12-20 14:40:27 +00:00
SELECT ROWNUM,
ROUND(NVL(T.<2E><><EFBFBD>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>,
0),
2),
2023-12-20 14:40:27 +00:00
ROUND(NVL(t."<22><><EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>(<28><>)" * 10000,
0),
2)
2023-12-20 14:40:27 +00:00
INTO L_ROWNUM,
A_ATTACHING_RATE,
A_PRESENT_MONTH
FROM BI<42><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD>ʸ<EFBFBD><CAB8>ٱ<EFBFBD> T
WHERE T.<2E><><EFBFBD><EFBFBD> = L_CALLER_NAME
AND ROWNUM = 1;
EXCEPTION
2023-12-20 14:40:27 +00:00
WHEN NO_DATA_FOUND THEN
L_ROWNUM := 1;
A_ATTACHING_RATE := 0.0;
A_PRESENT_MONTH := 0.0;
END;
--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BEGIN
2023-12-20 14:40:27 +00:00
SELECT ROWNUM,
ROUND(NVL(t."<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD>ȫ<EFBFBD>£<EFBFBD>(%)",
0),
2)
2023-12-20 14:40:27 +00:00
INTO L_ROWNUM,
A_RENEWAL_RATE
FROM "BI<42><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8>ٱ<EFBFBD>-24<32><34>" T
2023-12-20 14:40:27 +00:00
WHERE T.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = L_CALLER_NAME
AND ROWNUM = 1;
EXCEPTION
2023-12-20 14:40:27 +00:00
WHEN NO_DATA_FOUND THEN
L_ROWNUM := 1;
A_RENEWAL_RATE := 0.0;
END;
--ÿ<><C3BF>ҵ<EFBFBD><D2B5>
OPEN A_MENSUAL_CUR FOR
SELECT CF.<2E>·<EFBFBD> MM,
ROUND(NVL(SUM(CF.<2E><><EFBFBD>ո<EFBFBD><D5B8>˿ͻ<CBBF><CDBB><EFBFBD><EFBFBD><EFBFBD>),
0),
0) BF
FROM <20><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD>ÿ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD> CF
2023-12-20 14:40:27 +00:00
WHERE CF.<2E><>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD> = L_CALLER_NAME
AND CF.<2E><><EFBFBD><EFBFBD> = L_DEPARTMENT_NAME
AND ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >= TO_DATE(TO_CHAR(SYSDATE,
'yyyy') || '-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
AND ǩ<><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <= SYSDATE
GROUP BY CF.<2E>·<EFBFBD>
ORDER BY CF.<2E>·<EFBFBD>;
2023-04-04 09:58:05 +00:00
END;
/*******************************************************/
-- <20><>ϯ<EFBFBD><CFAF><EFBFBD>а<EFBFBD>
PROCEDURE CALLER_ARCH_RANKING_LIST
(
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
) IS
L_DEPARTMENT_NAME VARCHAR2(100);
BEGIN
-- <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BEGIN
2023-12-20 14:40:27 +00:00
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;
-- <20><><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><DABA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD>
OPEN A_ATTACHING_RANKING_LIST FOR
2023-12-20 14:40:27 +00:00
SELECT ROWNUM,
PAIHANG.<2E><><EFBFBD><EFBFBD> AS CALLER_NAME,
PAIHANG.XBL AS ATTACHING_RATE
FROM (SELECT T.<2E><><EFBFBD><EFBFBD>,
ROUND(T.<2E><><EFBFBD>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>,
2) XBL
FROM BI<42><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD>ʸ<EFBFBD><CAB8>ٱ<EFBFBD> T
WHERE T.<2E><><EFBFBD><EFBFBD> = L_DEPARTMENT_NAME
ORDER BY T.<2E><><EFBFBD>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8> DESC) PAIHANG;
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD>
OPEN A_RENEWAL_RANKING_LIST FOR
2023-12-20 14:40:27 +00:00
SELECT ROWNUM,
PAIHANG.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS CALLER_NAME,
PAIHANG.XBL AS RENEWAL_RATE
FROM (SELECT T.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
ROUND(t."<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD>ȫ<EFBFBD>£<EFBFBD>(%)",
2) XBL
2024-01-11 10:46:08 +00:00
FROM "BI<42><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϯ<EFBFBD><CFAF><EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8>ٱ<EFBFBD>-24<32><34>" T
2023-12-20 14:40:27 +00:00
WHERE T.<2E><><EFBFBD>β<EFBFBD><CEB2><EFBFBD> = L_DEPARTMENT_NAME
ORDER BY XBL DESC) PAIHANG;
END;
2023-03-10 09:32:13 +00:00
BEGIN
NULL;
2023-08-25 12:47:36 +00:00
END TELSALE_ARCHIEVEMENT_PKG;
2023-03-10 09:32:13 +00:00
/