1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
| class CENTERCOST method CENTERCOST(); REM +-----------------------------------------------------------+; REM | 职务数据拆分函数 |; REM +-----------------------------------------------------------+; method splitJobRecord(&strEmplid As string, &strBgnDt As string, &strEndDt As string) Returns string; end-class;
method CENTERCOST end-method;
method splitJobRecord /+ &strEmplid as String, +/ /+ &strBgnDt as String, +/ /+ &strEndDt as String +/ /+ Returns String +/ Local string &strRtn; Local string &bgnDt = &strBgnDt; Local string &endDt = &strEndDt; Local string &cal_prd_id = Substring(&bgnDt, 1, 7);; Local number &i; Local string &beforeBgnDt; Local string &beforeEndDt; Local string &strCOUNT; Local string &strEFFDT; Local string &MonthDays; Local string &strC_RE_NO, &strC_DESCR, &strC_COST_CENTRE, &strC_DESCR2, &strDEPTID, &strC_DESCR3, &strC_COST_TYPE, &strC_DESCR4; Local array of string &arrBgn = CreateArrayRept("tmp", 11); Local array of string &arrEnd = CreateArrayRept("tmp", 11); Local array of string &arrRet = CreateArrayRept("tmp", 15); try SQLExec(SQL.C_JOB_BGN_DT_SQL, &strEmplid, &bgnDt, &arrBgn [1], &arrBgn [2], &arrBgn [3], &arrBgn [4], &arrBgn [5], &arrBgn [6], &arrBgn [7], &arrBgn [8], &arrBgn [9], &arrBgn [10], &arrBgn [11]); SQLExec(SQL.C_JOB_END_DT_SQL, &strEmplid, &endDt, &arrEnd [1], &arrEnd [2], &arrEnd [3], &arrEnd [4], &arrEnd [5], &arrEnd [6], &arrEnd [7], &arrEnd [8], &arrEnd [9], &arrEnd [10], &arrEnd [11]); rem WinMessage("&arrBgn [5]=" | &arrBgn [5]); rem WinMessage("&arrEnd [5]=" | &arrEnd [5]); rem WinMessage("&strEmplid =" | &strEmplid); rem WinMessage("&cal_prd_id =" | &cal_prd_id); rem MessageBox(0, "", 0, 0, "&arrBgn [5]==" | &arrBgn [5] | "----&arrEnd [5]==" | &arrEnd [5] | "----&strEmplid==" | &strEmplid | "---&cal_prd_id==" | &cal_prd_id); rem 清空该员工的历史数据; SQLExec("DELETE FROM PS_C_CAL_JOB_TBL C WHERE C.EMPLID = :1 AND C.CAL_PRD_ID = :2", &strEmplid, &cal_prd_id); SQLExec("commit"); rem a = b; If &arrBgn [1] = &arrEnd [1] And &arrBgn [2] = &arrEnd [2] And &arrBgn [3] = &arrEnd [3] And &arrBgn [4] = &arrEnd [4] Then If &arrEnd [5] = "TER" Then rem MessageBox(0, "", 0, 0, "月前离职"); &arrRet = CreateArrayRept("tmp", 15); &arrRet [1] = &arrBgn [1]; &arrRet [2] = &arrBgn [2]; &arrRet [3] = &arrBgn [3]; &arrRet [4] = &arrBgn [4]; &arrRet [5] = &arrBgn [5]; &arrRet [6] = &arrBgn [6]; &MonthDays = "0"; SQLExec("SELECT to_date(:1,'yyyy-mm-dd') - to_date(:2,'yyyy-mm-dd') + 1 FROM dual", &endDt, &bgnDt, &MonthDays); &arrRet [7] = &MonthDays; rem WinMessage(&bgnDt); SQLExec(SQL.C_FULL_MONTHS_SQL, &arrBgn [1], &bgnDt, &strC_RE_NO, &strC_DESCR, &strC_COST_CENTRE, &strC_DESCR2, &strDEPTID, &strC_DESCR3, &strC_COST_TYPE, &strC_DESCR4); &arrRet [8] = &strC_RE_NO; &arrRet [9] = &strC_DESCR; &arrRet [10] = &strC_COST_CENTRE; &arrRet [11] = &strC_DESCR2; &arrRet [12] = &strDEPTID; &arrRet [13] = &strC_DESCR3; &arrRet [14] = &strC_COST_TYPE; &arrRet [15] = &strC_DESCR4; rem 记录表 月前离职,但是当月的薪资表中有数据; rem WinMessage(&MonthDays | "天:" | &arrRet [1] | "===" | &arrRet [2] | "===" | &arrRet [3] | "===" | &arrRet [4] | "===" | &arrRet [5] | "===" | &arrRet [6] | "===" | &arrRet [7] | "===" | &arrRet [8] | "===" | &arrRet [9] | "===" | &arrRet [10] | "===" | &arrRet [11]); SQLExec("insert into PS_C_CAL_JOB_TBL values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,to_date(:11,'YYYY-MM-DD'),:12,:13,'N')", &arrRet [1], &cal_prd_id, &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15], &endDt, &arrRet [7], "0"); SQLExec("commit"); rem 月后入职,不处理; If &arrEnd [5] = "" Then rem MessageBox(0, "", 0, 0, "月后入职"); End-If; Else rem WinMessage("进入月前入职,月后离职,且月中无操作"); &arrRet = CreateArrayRept("tmp", 15); &arrRet [1] = &arrBgn [1]; &arrRet [2] = &arrBgn [2]; &arrRet [3] = &arrBgn [3]; &arrRet [4] = &arrBgn [4]; &arrRet [5] = &arrBgn [5]; &arrRet [6] = &arrBgn [6]; &MonthDays = "0"; SQLExec("SELECT to_date(:1,'yyyy-mm-dd') - to_date(:2,'yyyy-mm-dd') + 1 FROM dual", &endDt, &bgnDt, &MonthDays); &arrRet [7] = &MonthDays; rem WinMessage(&bgnDt); SQLExec(SQL.C_FULL_MONTHS_SQL, &arrBgn [1], &bgnDt, &strC_RE_NO, &strC_DESCR, &strC_COST_CENTRE, &strC_DESCR2, &strDEPTID, &strC_DESCR3, &strC_COST_TYPE, &strC_DESCR4); &arrRet [8] = &strC_RE_NO; &arrRet [9] = &strC_DESCR; &arrRet [10] = &strC_COST_CENTRE; &arrRet [11] = &strC_DESCR2; &arrRet [12] = &strDEPTID; &arrRet [13] = &strC_DESCR3; &arrRet [14] = &strC_COST_TYPE; &arrRet [15] = &strC_DESCR4; rem 记录表 月后离职; rem WinMessage(&MonthDays | "天:" | &arrRet [1] | "===" | &arrRet [2] | "===" | &arrRet [3] | "===" | &arrRet [4] | "===" | &arrRet [5] | "===" | &arrRet [6] | "===" | &arrRet [7] | "===" | &arrRet [8] | "===" | &arrRet [9] | "===" | &arrRet [10] | "===" | &arrRet [11]); SQLExec("insert into PS_C_CAL_JOB_TBL values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,to_date(:11,'YYYY-MM-DD'),:12,:13,'N')", &arrRet [1], &cal_prd_id, &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15], &endDt, &arrRet [7], "0"); SQLExec("commit"); End-If; Else rem a<>b; If &arrEnd [5] = "TER" Then rem 月中入职,月中离职; If &arrBgn [5] = "" Or &arrBgn [3] = &bgnDt Or &arrBgn [5] = "TER" Then &strCOUNT = "0"; &strEFFDT = "0"; rem WinMessage("进入月中入职,月中离职"); SQLExec(SQL.C_JOB_COUNT_SQL, &arrEnd [1], &bgnDt, &endDt, &strCOUNT); &arrRet = CreateArrayRept("tmp", 15); SQLExec(SQL.C_FIRST_DAYS_SQL, &arrEnd [1], &bgnDt, &strEFFDT); &bgnDt = &strEFFDT; REM WinMessage("&strCOUNT==" | &strCOUNT | "&bgnDt==" | &bgnDt); For &i = 1 To Value(&strCOUNT) - 1 If &i > 1 Then &bgnDt = &arrRet [3] End-If; SQLExec(SQL.C_JOB_DAYS_SQL, &arrEnd [1], &bgnDt, &arrRet [1], &arrRet [2], &arrRet [3], &arrRet [4], &arrRet [5], &arrRet [6], &arrRet [7], &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15]); rem 记录表 月中入职,月中离职; rem WinMessage("月中入职,月中离职:" | &arrRet [1] | "===" | &arrRet [2] | "===" | &arrRet [3] | "===" | &arrRet [4] | "===" | &arrRet [5] | "===" | &arrRet [6] | "===" | &arrRet [7] | "===" | &arrRet [8] | "===" | &arrRet [9] | "===" | &arrRet [10] | "===" | &arrRet [11]); SQLExec("insert into PS_C_CAL_JOB_TBL values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,to_date(:11,'YYYY-MM-DD'),:12,:13,'N')", &arrRet [1], &cal_prd_id, &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15], &arrRet [3], &arrRet [7], "0"); SQLExec("commit"); End-For; Else rem 月前入职,月中离职; If Date(&arrBgn [3]) < Date(&bgnDt) Then rem WinMessage("进入月前入职,月中离职"); &strCOUNT = "0"; SQLExec(SQL.C_JOB_COUNT_SQL, &arrBgn [1], &bgnDt, &endDt, &strCOUNT); &arrRet = CreateArrayRept("tmp", 15); For &i = 1 To Value(&strCOUNT) If &i > 1 Then &bgnDt = &arrRet [3] End-If; SQLExec(SQL.C_JOB_DAYS_SQL, &arrBgn [1], &bgnDt, &arrRet [1], &arrRet [2], &arrRet [3], &arrRet [4], &arrRet [5], &arrRet [6], &arrRet [7], &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15]); rem 记录表 月中离职; rem WinMessage("月中离职:" | &arrRet [1] | "===" | &arrRet [2] | "===" | &arrRet [3] | "===" | &arrRet [4] | "===" | &arrRet [5] | "===" | &arrRet [6] | "===" | &arrRet [7] | "===" | &arrRet [8] | "===" | &arrRet [9] | "===" | &arrRet [10] | "===" | &arrRet [11]); SQLExec("insert into PS_C_CAL_JOB_TBL values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,to_date(:11,'YYYY-MM-DD'),:12,:13,'N')", &arrRet [1], &cal_prd_id, &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15], &arrRet [3], &arrRet [7], "0"); SQLExec("commit"); End-For; End-If; End-If; Else If &arrBgn [5] = "" Or &arrBgn [5] = "TER" Or &arrBgn [3] = &bgnDt Then rem WinMessage("&arrBgn [3] =" | &arrBgn [3]); SQLExec(SQL.C_JOB_COUNT_SQL, &arrEnd [1], &bgnDt, &endDt, &strCOUNT); rem WinMessage("&strCOUNT=" | &strCOUNT); If &arrBgn [3] <> &bgnDt Then SQLExec("SELECT MIN(J.EFFDT) FROM ps_job j where j.emplid = :1 and j.empl_rcd = 0 and j.effdt > to_date(:2,'YYYY-MM-DD')", &strEmplid, &bgnDt, &bgnDt); End-If; &arrRet = CreateArrayRept("tmp", 15); For &i = 1 To Value(&strCOUNT) If &i > 1 Then &bgnDt = &arrRet [3] End-If; SQLExec(SQL.C_JOB_DAYS_SQL, &arrEnd [1], &bgnDt, &arrRet [1], &arrRet [2], &arrRet [3], &arrRet [4], &arrRet [5], &arrRet [6], &arrRet [7], &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15]); rem If &i > 1 Then rem WinMessage("&arrBgn [3]=" | &arrBgn [3] | "----&bgnDt=" | &bgnDt); rem WinMessage("月中入职:" | &arrRet [1] | "===" | &arrRet [2] | "===" | &arrRet [3] | "===" | &arrRet [4] | "===" | &arrRet [5] | "===" | &arrRet [6] | "===" | &arrRet [7] | "===" | &arrRet [8] | "===" | &arrRet [9] | "===" | &arrRet [10] | "===" | &arrRet [11]); rem End-If; rem 记录表 月中入职; If &i < Value(&strCOUNT) Then rem WinMessage("月中入职:" | &arrRet [1] | "===" | &arrRet [2] | "===" | &arrRet [3] | "===" | &arrRet [4] | "===" | &arrRet [5] | "===" | &arrRet [6] | "===" | &arrRet [7] | "===" | &arrRet [8] | "===" | &arrRet [9] | "===" | &arrRet [10] | "===" | &arrRet [11]); SQLExec("insert into PS_C_CAL_JOB_TBL values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,to_date(:11,'YYYY-MM-DD'),:12,:13,'N')", &arrRet [1], &cal_prd_id, &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15], &arrRet [3], &arrRet [7], "0"); SQLExec("commit"); End-If; End-For; rem 处理月末的记录; SQLExec(SQL.C_LAST_DAYS_SQL, &arrEnd [1], &endDt, &arrRet [1], &arrRet [2], &arrRet [3], &arrRet [4], &arrRet [5], &arrRet [6], &arrRet [7], &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15]); rem WinMessage("月中入职:" | &arrRet [1] | "===" | &arrRet [2] | "===" | &arrRet [3] | "===" | &arrRet [4] | "===" | &arrRet [5] | "===" | &arrRet [6] | "===" | &arrRet [7] | "===" | &arrRet [8] | "===" | &arrRet [9] | "===" | &arrRet [10] | "===" | &arrRet [11]); SQLExec("insert into PS_C_CAL_JOB_TBL values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,to_date(:11,'YYYY-MM-DD'),:12,:13,'N')", &arrRet [1], &cal_prd_id, &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15], &arrRet [3], &arrRet [7], "0"); SQLExec("commit"); Else rem WinMessage("进入月前入职,月后离职"); SQLExec(SQL.C_JOB_COUNT_SQL, &arrBgn [1], &bgnDt, &endDt, &strCOUNT); &arrRet = CreateArrayRept("tmp", 15); For &i = 1 To Value(&strCOUNT) If &i > 1 Then &bgnDt = &arrRet [3] End-If; SQLExec(SQL.C_JOB_DAYS_SQL, &arrBgn [1], &bgnDt, &arrRet [1], &arrRet [2], &arrRet [3], &arrRet [4], &arrRet [5], &arrRet [6], &arrRet [7], &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15]); rem 记录表 月前入职月后离职; rem WinMessage("月前入职,月后离职:" | &arrRet [1] | "===" | &arrRet [2] | "===" | &arrRet [3] | "===" | &arrRet [4] | "===" | &arrRet [5] | "===" | &arrRet [6] | "===" | &arrRet [7] | "===" | &arrRet [8] | "===" | &arrRet [9] | "===" | &arrRet [10] | "===" | &arrRet [11]); SQLExec("insert into PS_C_CAL_JOB_TBL values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,to_date(:11,'YYYY-MM-DD'),:12,:13,'N')", &arrRet [1], &cal_prd_id, &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15], &arrRet [3], &arrRet [7], "0"); SQLExec("commit"); End-For; SQLExec(SQL.C_LAST_DAYS_SQL, &arrEnd [1], &endDt, &arrRet [1], &arrRet [2], &arrRet [3], &arrRet [4], &arrRet [5], &arrRet [6], &arrRet [7], &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15]); rem MessageBox(0, "", 0, 0, "月前入职,月后离职:" | &arrRet [1] | "===" | &arrRet [2] | "===" | &arrRet [3] | "===" | &arrRet [4] | "===" | &arrRet [5] | "===" | &arrRet [6] | "===" | &arrRet [7] | "===" | &arrRet [8] | "===" | &arrRet [9] | "===" | &arrRet [10] | "===" | &arrRet [11]); SQLExec("insert into PS_C_CAL_JOB_TBL values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,to_date(:11,'YYYY-MM-DD'),:12,:13,'N')", &arrRet [1], &cal_prd_id, &arrRet [8], &arrRet [9], &arrRet [10], &arrRet [11], &arrRet [12], &arrRet [13], &arrRet [14], &arrRet [15], &arrRet [3], &arrRet [7], "0"); SQLExec("commit"); End-If; End-If; End-If; Local number &numCount; Local number &numTotal_days; SQLExec("SELECT count(1) FROM PS_C_CAL_JOB_TBL c where c.emplid = :1 and c.cal_prd_id = :2 ", &strEmplid, &cal_prd_id, &numCount); If &numCount > 0 Then SQLExec("SELECT SUM(C.DAYS) TOTAL_DAYS FROM PS_C_CAL_JOB_TBL C WHERE C.EMPLID = :1 AND C.CAL_PRD_ID = :2 GROUP BY C.EMPLID, C.CAL_PRD_ID ", &strEmplid, &cal_prd_id, &numTotal_days); SQLExec("UPDATE PS_C_CAL_JOB_TBL C SET C.DAYS_TOTAL = :1 where c.emplid = :2 and c.cal_prd_id = :3 ", &numTotal_days, &strEmplid, &cal_prd_id); SQLExec("commit"); End-If; end-method;
|