peoplesoft 更新表接口程序
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f8a66740564a3b43c6bc2fe3ae6744ad.png)
import PS_PT:Integration:IRequestHandler;
class UpdataRecord implements PS_PT:Integration:IRequestHandler
method OnRequest(&MSG As Message) Returns Message;
end-class;
method OnRequest
/+ &MSG as Message +/
/+ Returns Message +/
/+ Extends/implements PS_PT:Integration:IRequestHandler.OnRequest +/
Local string &strMsg;
Local string ¶meter = &MSG.GetContentString();
Local JsonParser &parser = CreateJsonParser();
Local boolean &boolParser = &parser.Parse(¶meter);
If Not &boolParser Then
throw CreateException(10003, - 1, "JsonParser error.");
End-If;
Local JsonObject &jParameter = &parser.GetRootObject();
Local string &strEmplID = &jParameter.GetString("emplId");
Local string &strName = &jParameter.GetString("name");
Local string &strIfTeacher = &jParameter.GetString("ifTeacher");
Local string &strCertificationDate = &jParameter.GetString("certificationDate");
Local string &strExamScore = &jParameter.GetString("examScore");
Local string &strInterviewScore = &jParameter.GetString("interviewScore");
Local string &strPrenticeScore = &jParameter.GetString("prenticeScore");
Local string &strOverallScore = &jParameter.GetString("overallScore");
Local string &strJobTeacher = &jParameter.GetString("jobTeacher");
Local string &strCultivateOpenDate = &jParameter.GetString("cultivateOpenDate");
Local string &strCultivateEndDate = &jParameter.GetString("cultivateEndDate");
Local string &strIfQualified = &jParameter.GetString("ifQualified");
If None(&strEmplID) Then
&strMsg = &strMsg | "EmplId 必须传递";
End-If;
If None(&strName) Then
&strMsg = &strMsg | "name 必须传递";
End-If;
If All(&strIfTeacher) Then
If &strIfTeacher = "Y" Then
If None(&strCertificationDate) Then
&strMsg = &strMsg | "certificationDate 必须传递";
End-If;
If None(&strExamScore) Then
&strMsg = &strMsg | "examScore 必须传递";
End-If;
If None(&strInterviewScore) Then
&strMsg = &strMsg | "interviewScore 必须传递";
End-If;
If None(&strPrenticeScore) Then
&strMsg = &strMsg | "prenticeScore 必须传递";
End-If;
If None(&strOverallScore) Then
&strMsg = &strMsg | "overallScore 必须传递";
End-If;
Else
If All(&strCertificationDate) Then
&strCertificationDate = "";
End-If;
If All(&strExamScore) Then
&strExamScore = "";
End-If;
If All(&strInterviewScore) Then
&strInterviewScore = "";
End-If;
If All(&strPrenticeScore) Then
&strPrenticeScore = "";
End-If;
If All(&strOverallScore) Then
&strOverallScore = "";
End-If;
End-If;
Else
&strMsg = &strMsg | "ifTeacher 必须传递";
End-If;
If All(&strJobTeacher) Then
If &strJobTeacher = &strEmplID Then
&strMsg = &strMsg | "师傅不能为本人";
End-If;
Local string &strSql = "select emplid from PS_C_TCH_PRE_TBL where IF_TEACHER ='Y' and EMPLID =:1";
Local string &strEmplidTeacher;
SQLExec(&strSql, &strJobTeacher, &strEmplidTeacher);
If None(&strEmplidTeacher) Then
&strMsg = &strMsg | "带岗师傅必须为师傅";
End-If;
If None(&strCultivateOpenDate) Then
&strMsg = &strMsg | "cultivateOpenDate 必须传递";
End-If;
If None(&strCultivateEndDate) Then
&strMsg = &strMsg | "cultivateEndDate 必须传递";
End-If;
If None(&strIfQualified) Then
&strMsg = &strMsg | "ifQualified 必须传递";
End-If;
End-If;
Local JsonObject &jsonObjects = CreateJsonObject();
Local Record &recC_TCH_PRE_TBL = CreateRecord(Record.C_TCH_PRE_TBL);
&recC_TCH_PRE_TBL.EMPLID.Value = &strEmplID;
If None(&strMsg) Then
If Not &recC_TCH_PRE_TBL.SelectByKey() Then
&recC_TCH_PRE_TBL.EMPLID.Value = &strEmplID;
&recC_TCH_PRE_TBL.NAME1.Value = &strName;
&recC_TCH_PRE_TBL.IF_TEACHER.Value = &strIfTeacher;
&recC_TCH_PRE_TBL.CERTIFICATION_DATE.Value = &strCertificationDate;
&recC_TCH_PRE_TBL.EXAM_SCORE.Value = &strExamScore;
&recC_TCH_PRE_TBL.INTERVIEW_SCORE.Value = &strInterviewScore;
&recC_TCH_PRE_TBL.PRENTICE_SCORE.Value = &strPrenticeScore;
&recC_TCH_PRE_TBL.OVERALL_SCORE.Value = &strOverallScore;
&recC_TCH_PRE_TBL.JOB_TEACHER.Value = &strJobTeacher;
&recC_TCH_PRE_TBL.CULTIVATE_OPE_DATE.Value = &strCultivateOpenDate;
&recC_TCH_PRE_TBL.CULTIVATE_END_DATE.Value = &strCultivateEndDate;
&recC_TCH_PRE_TBL.IF_QUALIFIED.Value = &strIfQualified;
&recC_TCH_PRE_TBL.Insert();
Else
&recC_TCH_PRE_TBL.NAME1.Value = &strName;
&recC_TCH_PRE_TBL.IF_TEACHER.Value = &strIfTeacher;
&recC_TCH_PRE_TBL.CERTIFICATION_DATE.Value = &strCertificationDate;
&recC_TCH_PRE_TBL.EXAM_SCORE.Value = &strExamScore;
&recC_TCH_PRE_TBL.INTERVIEW_SCORE.Value = &strInterviewScore;
&recC_TCH_PRE_TBL.PRENTICE_SCORE.Value = &strPrenticeScore;
&recC_TCH_PRE_TBL.OVERALL_SCORE.Value = &strOverallScore;
&recC_TCH_PRE_TBL.JOB_TEACHER.Value = &strJobTeacher;
&recC_TCH_PRE_TBL.CULTIVATE_OPE_DATE.Value = &strCultivateOpenDate;
&recC_TCH_PRE_TBL.CULTIVATE_END_DATE.Value = &strCultivateEndDate;
&recC_TCH_PRE_TBL.IF_QUALIFIED.Value = &strIfQualified;
&recC_TCH_PRE_TBL.Update();
End-If;
&jsonObjects.AddProperty("CODE", 200);
&jsonObjects.AddProperty("MESSAGE", "");
&jsonObjects.AddProperty("TIME", %Datetime);
Else
&jsonObjects.AddProperty("CODE", 0);
&jsonObjects.AddProperty("MESSAGE", &strMsg);
&jsonObjects.AddProperty("TIME", %Datetime);
End-If;
Local Message &responseMessage = CreateMessage(@("Operation." | &MSG.OperationName), %IntBroker_Response);
Local boolean &bool = &responseMessage.SetContentString(&jsonObjects.ToString());
Return &responseMessage;
end-method;