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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
| class Applicant method Applicant(); method addMedResult(&ApplicantJsonObj As JsonObject) Returns boolean; method errorHandler(&strC_APP_SEQ As string, &strEMPLID As string);
method updateErrorLogTable(&strC_APP_SEQ As string, &strEMPLID As string, &_errMsgText As string); private instance ApiObject &oSession; end-class;
method Applicant &oSession = GetSession(); &oSession.connect(1, "", "POSTDATA", "", 0); SetLanguage("ZHS"); &oSession.PSMessagesMode = 1; end-method;
method addMedResult /+ &ApplicantJsonObj as JsonObject +/ /+ Returns Boolean +/
Local ApiObject &oCEmplDemandComCi; Local ApiObject &oCWflPrcsVwCollection, &oCWflPrcsVw; Local ApiObject &oCEmplDemandSCollection, &oCEmplDemandS; Local string &strC_APP_SEQ, &strC_APP_DT, &strEMPLID, &NAME, &strC_APPLI_RS, &DEPTID, &DESCR, &strEMPLID2, &NAME2, &DEPTID1, &strDESCR254; Local string &strC_RE_NO, &strC_APPLI_LEVEL, &strPOSITION_NBR, &strC_POSN_GRDE_ID, &strC_DEMAND_NUM, &strEMPLID_ASSIGN_BY, &strC_PRO_PRD_DT, &strDESCR_0; Local date &APP_DATE, &PRO_PRD_DATE; Local File &fileLog; &fileLog = GetFile("/file/C_MED_RESULT.log", "A", "A", %FilePath_Absolute); &fileLog.WriteLine("********* 时间:" | %Date | " ******"); &fileLog.WriteLine("********* Begin C_MED_RESULT ******"); try Local string &isExitFlag = " "; Local string &ERR = ""; &strC_APP_SEQ = &ApplicantJsonObj.GetProperty("C_APP_SEQ"); SQLExec(" SELECT 'X' from PS_C_EMPL_DEMAND_T t WHERE t.c_section_type = '1000000002' AND t.C_APP_SEQ = :1 ", &strC_APP_SEQ, &isExitFlag); If &isExitFlag <> "X" Then &strC_APP_DT = &ApplicantJsonObj.GetProperty("C_APP_DT"); &strC_APPLI_RS = &ApplicantJsonObj.GetProperty("C_APPLI_RS"); &strEMPLID = &ApplicantJsonObj.GetProperty("EMPLID"); &fileLog.WriteLine("&strEMPLID --- " | &strEMPLID); SQLExec("select NAME , DEPTID, DESCR1 FROM PS_C_JOB_CURR_V WHERE EMPLID = :1 ", &strEMPLID, &NAME, &DEPTID, &DESCR); &strEMPLID2 = &ApplicantJsonObj.GetProperty("EMPLID2"); &strDESCR254 = &ApplicantJsonObj.GetProperty("DESCR254"); &fileLog.WriteLine("********* Begin JOSNDATA ******"); &fileLog.WriteLine("&strC_APP_SEQ --- " | &strC_APP_SEQ); &fileLog.WriteLine("&strC_APP_DT --- " | &strC_APP_DT); &fileLog.WriteLine("&strC_APPLI_RS --- " | &strC_APPLI_RS); &fileLog.WriteLine("&strEMPLID --- " | &strEMPLID); &fileLog.WriteLine("&NAME --- " | &NAME); &fileLog.WriteLine("&DEPTID --- " | &DEPTID); &fileLog.WriteLine("&DESCR --- " | &DESCR); &fileLog.WriteLine("&strEMPLID2 --- " | &strEMPLID2); &fileLog.WriteLine("&strDESCR254 --- " | &strDESCR254); If All(&strC_APP_SEQ, &strC_APP_DT, &strC_APPLI_RS, &strEMPLID, &strEMPLID2) Then If Len(&strC_APP_SEQ) > 10 Then &ERR = &ERR | " 审批单号不正确,请检查数据正确性! "; End-If; If Len(&strC_APP_DT) > 10 Then &ERR = &ERR | " 申请日期格式不正确,请检查数据正确性! "; End-If; &isExitFlag = " "; SQLExec("SELECT 'X' from ps_C_PERS_SRCH_VW WHERE OPRID = 'POSTDATA' AND EMPLID = :1 ", &strEMPLID, &isExitFlag); If &isExitFlag <> "X" Then &ERR = &ERR | " 申请人编码不存在,请检查数据正确性! "; End-If; &isExitFlag = " "; SQLExec("SELECT 'X' from ps_C_PERS_SRCH_VW WHERE OPRID = 'POSTDATA' AND EMPLID = :1 ", &strEMPLID2, &isExitFlag); If &isExitFlag <> "X" Then &ERR = &ERR | " 招聘组长编码不存在,请检查数据正确性! "; End-If; If Len(&strDESCR254) > 254 Then &ERR = &ERR | " 申请原因说明超长,请检查数据正确性! "; End-If; If None(&ERR) Then &oCEmplDemandComCi = &oSession.GetCompIntfc(CompIntfc.C_EMPL_DEMAND_COM_CI); If &oCEmplDemandComCi = Null Then %This.errorHandler(&strC_APP_SEQ, &strEMPLID); Return False; End-If; &oCEmplDemandComCi.InteractiveMode = False; &oCEmplDemandComCi.GetHistoryItems = True; &oCEmplDemandComCi.EditHistoryItems = True;
&oCEmplDemandComCi.C_APP_SEQ = &strC_APP_SEQ; If Not &oCEmplDemandComCi.Create() Then; %This.errorHandler(&strC_APP_SEQ, &strEMPLID); Return False; End-If; &oCEmplDemandComCi.C_APP_SEQ = &strC_APP_SEQ; &oCEmplDemandComCi.C_APPLI_RS = &strC_APPLI_RS; SQLExec(" SELECT TO_DATE(:1 ,'YYYY-MM-DD') from DUAL ", &strC_APP_DT, &APP_DATE); &oCEmplDemandComCi.C_APP_DT = &APP_DATE; &oCEmplDemandComCi.EMPLID = &strEMPLID; &oCEmplDemandComCi.NAME = &NAME; &oCEmplDemandComCi.DEPTID = &DEPTID; &oCEmplDemandComCi.DESCR = &DESCR; &oCEmplDemandComCi.EMPLID2 = &strEMPLID2; &oCEmplDemandComCi.DESCR254 = &strDESCR254; rem &oCEmplDemandComCi.COUNT1 = &strCOUNT1; Local JsonArray &jObApplyDataArray = &ApplicantJsonObj.GetJsonArray("LINES");
&oCEmplDemandSCollection = &oCEmplDemandComCi.C_EMPL_DEMAND_S; Local integer &i; For &i = 1 To &jObApplyDataArray.Length(); Local JsonObject &jObApplyDataInfo = &jObApplyDataArray.GetJsonObject(&i); &oCEmplDemandS = &oCEmplDemandSCollection.Item(1); If All(&oCEmplDemandS.C_APPLI_LEVEL) Then &oCEmplDemandS = &oCEmplDemandSCollection.InsertItem(1); End-If; &strC_RE_NO = &jObApplyDataInfo.GetProperty("C_RE_NO"); &strC_APPLI_LEVEL = &jObApplyDataInfo.GetProperty("C_APPLI_LEVEL"); &strPOSITION_NBR = &jObApplyDataInfo.GetProperty("POSITION_NBR"); &strC_POSN_GRDE_ID = &jObApplyDataInfo.GetProperty("C_POSN_GRDE_ID"); &strC_DEMAND_NUM = &jObApplyDataInfo.GetProperty("C_DEMAND_NUM"); &strEMPLID_ASSIGN_BY = &jObApplyDataInfo.GetProperty("EMPLID_ASSIGN_BY"); &strC_PRO_PRD_DT = &jObApplyDataInfo.GetProperty("C_PRO_PRD_DT"); &strDESCR_0 = &jObApplyDataInfo.GetProperty("DESCR"); &fileLog.WriteLine("********* begin 第 " | &i | " 个json对象 ******"); rem &fileLog.WriteLine("ABSW_SEQ_NO --- " | &strABSW_SEQ_NO); &fileLog.WriteLine("C_RE_NO --- " | &strC_RE_NO); &fileLog.WriteLine("C_APPLI_LEVEL --- " | &strC_APPLI_LEVEL); &fileLog.WriteLine("POSITION_NBR --- " | &strPOSITION_NBR); &fileLog.WriteLine("C_POSN_GRDE_ID --- " | &strC_POSN_GRDE_ID); &fileLog.WriteLine("C_DEMAND_NUM --- " | &strC_DEMAND_NUM); &fileLog.WriteLine("EMPLID_ASSIGN_BY --- " | &strEMPLID_ASSIGN_BY); &fileLog.WriteLine("C_PRO_PRD_DT --- " | &strC_PRO_PRD_DT); &fileLog.WriteLine("DESCR --- " | &strDESCR_0); If All(&strC_APPLI_LEVEL, &strPOSITION_NBR, &strC_PRO_PRD_DT, &strC_POSN_GRDE_ID, &strC_RE_NO) Then <* If Len(&strABSW_SEQ_NO) > 2 Then &ERR = &ERR | " 序号超长,请检查数据正确性! "; End-If; *> If Len(&strC_RE_NO) > 30 Then &ERR = &ERR | " 招聘编号超长,请检查数据正确性! "; End-If; If Len(&strC_APPLI_LEVEL) > 2 Then &ERR = &ERR | " 紧急程度超长,请检查数据正确性! "; End-If; If Len(&strPOSITION_NBR) > 8 Then &ERR = &ERR | " 岗位编号超长,请检查数据正确性! "; End-If; If Len(&strC_POSN_GRDE_ID) > 5 Then &ERR = &ERR | " 职级编码超长,请检查数据正确性! "; End-If; If Len(&strC_DEMAND_NUM) > 3 Then &ERR = &ERR | " 需求人数超长,请检查数据正确性! "; End-If; If Len(&strC_PRO_PRD_DT) > 10 Then &ERR = &ERR | " 期望到岗日期格式错误,请检查数据正确性! "; End-If; If Len(&strEMPLID_ASSIGN_BY) > 11 Then &ERR = &ERR | " 招聘组长超长,请检查数据正确性! "; End-If; If Len(&strC_PRO_PRD_DT) > 30 Then &ERR = &ERR | " 其他补充要求超长,请检查数据正确性! "; End-If;
&oCEmplDemandS.C_RE_NO = &strC_RE_NO;; &oCEmplDemandS.C_APPLI_LEVEL = &strC_APPLI_LEVEL;; &oCEmplDemandS.POSITION_NBR = &strPOSITION_NBR;; &oCEmplDemandS.C_POSN_GRDE_ID = &strC_POSN_GRDE_ID;; &oCEmplDemandS.C_DEMAND_NUM = &strC_DEMAND_NUM;; &oCEmplDemandS.EMPLID_ASSIGN_BY = &strEMPLID_ASSIGN_BY;; SQLExec(" SELECT TO_DATE(:1 ,'YYYY-MM-DD') from DUAL ", &strC_PRO_PRD_DT, &PRO_PRD_DATE); &oCEmplDemandS.C_PRO_PRD_DT = &PRO_PRD_DATE; &oCEmplDemandS.DESCR_0 = &strDESCR_0; Else %This.updateErrorLogTable(&strC_APP_SEQ, &strEMPLID, "必填项为空,请检查数据正确性!"); Return False; End-If; &fileLog.WriteLine("********* End 第 " | &i | " 个json对象 ******"); End-For; &fileLog.WriteLine("********* End JOSNDATA ******"); If None(&ERR) Then If Not &oCEmplDemandComCi.Save() Then %This.errorHandler(&strC_APP_SEQ, &strEMPLID); Return False; Else Local Record &reApplyLog = CreateRecord(Record.C_APPLY_LOG); &reApplyLog.C_OA_APPL_NUM.Value = &strC_APP_SEQ; &reApplyLog.C_APPLY_ID.Value = "medresult"; If Not &reApplyLog.SelectByKey() Then &reApplyLog.C_OA_APPL_NUM.Value = &strC_APP_SEQ; &reApplyLog.C_APPLY_ID.Value = "medresult"; &reApplyLog.EMPLID.Value = &strEMPLID; &reApplyLog.C_APPLY_DESCR.Value = "用人需求数据写入"; &reApplyLog.C_INTERFACE_STATUS.Value = "S"; &reApplyLog.DESCRLONG.Value = "成功"; &reApplyLog.LASTUPDDTTM.Value = %Datetime; &reApplyLog.Insert(); Else &reApplyLog.EMPLID.Value = &strEMPLID; &reApplyLog.C_APPLY_DESCR.Value = "用人需求数据写入"; &reApplyLog.C_INTERFACE_STATUS.Value = "S"; &reApplyLog.DESCRLONG.Value = "成功"; &reApplyLog.LASTUPDDTTM.Value = %Datetime; &reApplyLog.Update(); End-If; Return True; End-If; Else %This.updateErrorLogTable(&strC_APP_SEQ, &strEMPLID, &ERR); Return False; End-If; Else %This.updateErrorLogTable(&strC_APP_SEQ, &strEMPLID, &ERR); Return False; End-If; Else %This.updateErrorLogTable(&strC_APP_SEQ, &strEMPLID, "必填项为空,请检查数据正确性!"); Return False; End-If; Else %This.updateErrorLogTable(&strC_APP_SEQ, &strEMPLID, "审批单号重复,请检查数据正确性!"); Return False; End-If; &fileLog.WriteLine("********* End C_MED_RESULT ******"); catch Exception &ex %This.updateErrorLogTable(&strC_APP_SEQ, &strEMPLID, &ex.ToString()); Return False; end-try; end-method;
method errorHandler /+ &strC_APP_SEQ as String, +/ /+ &strEMPLID as String +/ Local string &sErrText; Local ApiObject &oPSMessageCollection, &oPSMessage; Local number &i; Local string &sErrMsgSetNum, &sErrMsgNum, &sErrMsgText, &sErrType; &oPSMessageCollection = &oSession.PSMessages; For &i = 1 To &oPSMessageCollection.Count &oPSMessage = &oPSMessageCollection.Item(&i); &sErrMsgSetNum = &oPSMessage.MessageSetNumber; &sErrMsgNum = &oPSMessage.MessageNumber; &sErrMsgText = &oPSMessage.Text; If &oPSMessage.Type = 1 Then &sErrMsgText = &oPSMessage.Text; Local string &SOURCE = &oPSMessage.Source; Local number &LEN = Len(&SOURCE); Local boolean &FIND = False; Local number &START = Find(".", &SOURCE); While Not (&FIND) Local number &NSTART = Find(".", &SOURCE, &START + 1); If &NSTART = 0 Then &FIND = True; Else &START = &NSTART; End-If; End-While; Local number &FLEN = &LEN - &START; Local string &FIELD = Substring(&SOURCE, &START + 1, &FLEN); End-If; &sErrText = &sErrText | &sErrMsgText | " "; End-For; %This.updateErrorLogTable(&strC_APP_SEQ, &strEMPLID, &sErrText); &oPSMessageCollection.DeleteAll(); end-method;
method updateErrorLogTable /+ &strC_APP_SEQ as String, +/ /+ &strEMPLID as String, +/ /+ &_errMsgText as String +/ Local Record &reApplyLog = CreateRecord(Record.C_APPLY_LOG); &reApplyLog.C_OA_APPL_NUM.Value = &strC_APP_SEQ; &reApplyLog.C_APPLY_ID.Value = "medresult"; If Not &reApplyLog.SelectByKey() Then &reApplyLog.C_OA_APPL_NUM.Value = &strC_APP_SEQ; &reApplyLog.C_APPLY_ID.Value = "medresult"; &reApplyLog.EMPLID.Value = &strEMPLID; &reApplyLog.C_APPLY_DESCR.Value = "用人需求数据写入"; &reApplyLog.C_INTERFACE_STATUS.Value = "F"; &reApplyLog.DESCRLONG.Value = &_errMsgText; &reApplyLog.LASTUPDDTTM.Value = %Datetime; &reApplyLog.Insert(); Else &reApplyLog.EMPLID.Value = &strEMPLID; &reApplyLog.C_APPLY_DESCR.Value = "用人需求数据写入"; &reApplyLog.C_INTERFACE_STATUS.Value = "F"; &reApplyLog.DESCRLONG.Value = &_errMsgText; &reApplyLog.LASTUPDDTTM.Value = %Datetime; &reApplyLog.Update(); End-If; CommitWork(); end-method;
|