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
| /+ &recC_EMPL_PRD_REQ as Record +/ /+ Returns String +/
Local string &reqBody, &rspBody; Local JsonObject &reqObj = CreateJsonObject(); Local JsonObject &reqObjSub = CreateJsonObject(); Local JsonArray &jArr = CreateJsonArray(); &reqObj.AddProperty("message", &reqObj1); &reqObj1.AddProperty("method", "createRequest"); &reqObj1.AddProperty("workflowid", "750"); &reqObj1.AddProperty("requestname", "转正申请"); &reqObj1.AddProperty("requestlevel", "0"); &reqObj1.AddProperty("creator", &recC_EMPL_PRD_REQ.EMPLID.Value); &reqObj1.AddProperty("isnextflow", ""); &reqObj1.AddJsonArray("main", &jArr); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "bh"); &reqObjSub.AddProperty("fieldvalue", &recC_EMPL_PRD_REQ.C_APP_SEQ.Value); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "sqrq"); &reqObjSub.AddProperty("fieldvalue", &recC_EMPL_PRD_REQ.C_APP_DT.Value); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "sqr1"); &reqObjSub.AddProperty("fieldvalue", &recC_EMPL_PRD_REQ.EMPLID.Value); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "sqrbm1"); &reqObjSub.AddProperty("fieldvalue", &recC_EMPL_PRD_REQ.DEPTID.Value); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "xm1"); &reqObjSub.AddProperty("fieldvalue", &recC_EMPL_PRD_REQ.EMPLID2.Value); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "zzrq"); &reqObjSub.AddProperty("fieldvalue", &recC_EMPL_PRD_REQ.C_PRO_PRD_DT.Value); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "bm1"); &reqObjSub.AddProperty("fieldvalue", &recC_EMPL_PRD_REQ.DEPTID1.Value); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "gw1"); &reqObjSub.AddProperty("fieldvalue", &recC_EMPL_PRD_REQ.POSITION_NBR.Value); Local string &strC_POSN_GRDE_DESCR; SQLExec("SELECT G.DESCR from PS_C_POSN_GRDE_VW G WHERE G.OPRID = :1 AND G.SETID = (SELECT P.SETID from ps_C_EMPL_PRD_REQ P WHERE P.C_SECTION_TYPE = '1000000003' AND P.C_APP_SEQ = :2 ) AND G.C_POSN_GRDE_ID = :3 AND G.EFFDT = (SELECT MAX(G1.EFFDT) from PS_C_POSN_GRDE_VW G1 WHERE G1.OPRID = G.OPRID AND G1.SETID = G.SETID AND G1.C_POSN_GRDE_ID = G.C_POSN_GRDE_ID AND G.EFFDT <= SYSDATE )", %OperatorId, &recC_EMPL_PRD_REQ.C_APP_SEQ.Value, &recC_EMPL_PRD_REQ.C_POSN_GRDE_ID.Value, &strC_POSN_GRDE_DESCR); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "ygzj"); &reqObjSub.AddProperty("fieldvalue", &strC_POSN_GRDE_DESCR); Local string &strLOCATION_DESCR4; SQLExec("SELECT L.DESCR from PS_LOCATION_TBL L WHERE L.SETID = (SELECT P.SETID from ps_C_EMPL_PRD_REQ P WHERE P.C_SECTION_TYPE = '1000000003' AND P.C_APP_SEQ = :1 ) AND L.LOCATION = :2 AND L.EFF_STATUS = 'A' AND L.EFFDT = (SELECT MAX(L1.EFFDT) from PS_LOCATION_TBL L1 WHERE L1.SETID = L.SETID AND L1.LOCATION = L.LOCATION AND L1.EFFDT <= SYSDATE) ", &recC_EMPL_PRD_REQ.C_APP_SEQ.Value, &recC_EMPL_PRD_REQ.LOCATION.Value, &strLOCATION_DESCR4); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "gzdd"); &reqObjSub.AddProperty("fieldvalue", &strLOCATION_DESCR4); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "zzrq"); &reqObjSub.AddProperty("fieldvalue", &recC_EMPL_PRD_REQ.C_PRD_DT.Value);
&reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "zzyy"); &reqObjSub.AddProperty("fieldvalue", &recC_EMPL_PRD_REQ.ACT_REASON_SUB.Value); Local string &strACT_REASON_SUB_DESCR; SQLExec("SELECT RB.descr1 from PS_C_ACT_RES_SUB RB WHERE RB.action_reason = 'PPD' AND RB.act_reason_sub = :1 ", &recC_EMPL_PRD_REQ.ACT_REASON_SUB.Value, &strACT_REASON_SUB_DESCR); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "zzyyms"); &reqObjSub.AddProperty("fieldvalue", &strACT_REASON_SUB_DESCR); &reqObjSub = CreateJsonObject(); &jArr.AddJsonObjectElement("", &reqObjSub); &reqObjSub.AddProperty("fieldname", "bcsm"); &reqObjSub.AddProperty("fieldvalue", &recC_EMPL_PRD_REQ.DESCR254.Value); rem &reqBody = &reqObj.ToString(); Local string &sURL = "http://oa.akucun.com/WorkflowCustomServiceServlet"; Local string &jsonBody; &jsonBody = &reqObj.ToString(); rem MessageBox(0, "", 0, 0, "&jsonBody==" | &jsonBody); rem WinMessage("&jsonBody==" | &jsonBody); Local JavaObject &jHttp = CreateJavaObject("org.apache.commons.httpclient.HttpClient"); rem &jHttp.getHttpConnectionManager().getParams().setConnectionTimeout(20000); Local JavaObject &jMethod = CreateJavaObject("org.apache.commons.httpclient.methods.PostMethod", &sURL); &jMethod.setFollowRedirects( False); &jMethod.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); Local number &i;
&jMethod.setRequestBody(&jsonBody); &jHttp.executeMethod(&jMethod);
Local JsonParser &JsonParser = CreateJsonParser(); Local boolean &JsonParserStatus = &JsonParser.Parse(&responseBody); If &JsonParserStatus = False Then throw CreateException(10003, - 1, "Json解析错误"); End-If;
Local JsonObject &jObj = &JsonParser.GetRootObject(); Local string &strCode = &jObj.GetProperty("code"); rem Local string &strMsg = &jObj.GetProperty("msg"); If &strCode <> "0" Then C_EMPL_TRA_REQ.C_APPLI_RS.Value = 5; End-If; If &responseStatus = 0 Then MessageBox(0, "", 0, 0, "提交成功!"); Else MessageBox(0, "", 0, 0, "提交失败!原因:" | &strMsg); End-If;
rem 获取返回结果; Local string &responseBody = &jMethod.getResponseBodyAsString(); Local string &responseStatus = &jMethod.getStatusLine().getStatusCode(); rem MessageBox(0, "", 0, 0, &responseBody | "==" | &responseStatus); rem &responseBody = CreateJavaObject("java.lang.String", CreateJavaObject("java.lang.String", &responseBody).getBytes("ISO8859-1"), "UTF-8").toString(); &jMethod.releaseConnection(); rem 如果网络状态为200,并且返回的接口编码为:0,表示接口成功接收到推送的数据;否则,表示推送失败,需要把员工转正申请单中的数据删除; Local string &strReturn = ""; If &responseStatus = "200" And (Substitute(&responseBody, """code"":""0""", "") <> &responseBody) Then &strReturn = ""; Else SQLExec(" DELETE FROM ps_C_EMPL_PRD_REQ p WHERE p.c_app_seq = :1 and p.C_SECTION_TYPE = '1000000003' ", &recC_EMPL_PRD_REQ.C_APP_SEQ.Value); SQLExec(" COMMIT "); &strReturn = "接口失败:" | &responseBody; End-If; rem MessageBox(0, "", 0, 0, "OA接口的结果&strReturn:" | &strReturn); Return &strReturn;
|