yuanzhi_kuang hai 2 semanas
pai
achega
461882c067

+ 11 - 5
src/com/kingdee/eas/custom/beisen/utils/BeisenApiClient.java

@@ -114,6 +114,9 @@ public class BeisenApiClient {
                     retryCount++;
                     handleTokenRefresh(retryCount);
                     continue;
+                }else {
+                	retryCount++;
+                	break;
                 }
             }
         }
@@ -125,22 +128,25 @@ public class BeisenApiClient {
     // ÏìÓ¦´¦ÀíÂß¼­-------------------------------------------------------------
 
     private JSONObject handleResponse(Response response, String apiUrl, String method) throws IOException {
+    	String responseBody = response.body() != null ? response.body().string() : "null";
+     
         if (!response.isSuccessful()) {
-            handleHttpError(response, apiUrl, method);
+            handleHttpError(responseBody, apiUrl, method);
         }
 
-        String responseBody = response.body().string();
+      
         JSONObject jsonResponse = parseResponse(responseBody, apiUrl);
 
         validateBusinessStatus(jsonResponse, apiUrl);
         return jsonResponse;
     }
 
-    private void handleHttpError(Response response, String apiUrl, String method) throws IOException {
-        String errorBody = response.body() != null ? response.body().string() : "null";
-        logger.error("API request failed. Code: " + response.code() +
+    private void handleHttpError(String errorBody, String apiUrl, String method) throws IOException {
+         
+        logger.error("API request failed "+
                 ", URL: " + apiUrl + ", Method: " + method +
                 ", Body: " + errorBody);
+        System.out.print("µ÷ÓôíÎó"+errorBody);
 //        throw new IOException("HTTP error: " + response.code());
     }
 

+ 26 - 12
src/com/kingdee/eas/custom/recuritment/task/RecruitmentDemandService.java

@@ -338,15 +338,22 @@ public class RecruitmentDemandService {
 
     /**
      * 创建招聘需求
-     * @throws BOSException 
-     * @throws EASBizException 
+     * @throws BOSException
+     * @throws EASBizException
      */
     public String createRequirement(Context ctx, RecuritmentDemandInfo demandInfo,JSONObject requirementData) throws IOException, EASBizException, BOSException {
-        JSONObject response = BeisenApiClient.getInstance().callApi(BeisenParam.CREATE_REQUIREMENT_URL, requirementData);
-        handleApiResponse(ctx,response,demandInfo , "");
+        JSONObject response = new JSONObject();
+        try {
+            response = BeisenApiClient.getInstance().callApi(BeisenParam.CREATE_REQUIREMENT_URL, requirementData);
+            handleApiResponse(ctx,response,demandInfo , "");
+        }catch (Exception e) {
+            handleApiResponse(ctx,response,demandInfo , "");
+            logger.error("创建招聘需求时发生错误", e);
+        }
+
         return response.getString("data");
     }
-    
+
     /**
      * 推送招聘需求到北森系统
      * @param demandInfo sHR系统的招聘需求数据
@@ -364,13 +371,13 @@ public class RecruitmentDemandService {
         JSONObject params = buildRequirementData(  ctx, demandInfo);
         params.put("requirementId", requirementId);
 //        params.put("requirementStatus", REQUIREMENT_STATUS_IN_PROGRESS); // 进行中
-        
+        JSONObject response = new JSONObject();
         try {
             BeisenApiClient apiClient = BeisenApiClient.getInstance();
-            JSONObject response = apiClient.callPutApi(BeisenParam.UPDATE_REQUIREMENT_URL, params);
-//            String msg = "更新_"+response.getString("message");
-            handleApiResponse(ctx,response,demandInfo ,  requirementId);
-        } catch (IOException e) {
+            response = apiClient.callPutApi(BeisenParam.UPDATE_REQUIREMENT_URL, params);
+            handleApiResponse(ctx,response,demandInfo , requirementId);
+        } catch (Exception e) {
+            handleApiResponse(ctx,response,demandInfo , requirementId);
             logger.error("更新招聘需求时发生错误", e);
         }
     }
@@ -381,8 +388,15 @@ public class RecruitmentDemandService {
      * @throws EASBizException 
      */
     private void handleApiResponse(Context ctx, JSONObject response, RecuritmentDemandInfo demandInfo ,String requirementId) throws BOSException, EASBizException {
-        int code = response.getIntValue("code");
-        String message =  response.getString("message");
+        //如果不包含code字段,则认为是错误的响应
+        int code = 500;
+        if (response.containsKey("code")) {
+            code = response.getIntValue("code");
+        }
+        String message =  "发生调用错误,请查看后台日志!";
+       if (response.containsKey("message")) {
+           message = response.getString("message");
+       }
         SelectorItemCollection selectorCol = new SelectorItemCollection();
         selectorCol.add(new  SelectorItemInfo("requirementId"));
         selectorCol.add(new  SelectorItemInfo("syncBeisenResult"));

BIN=BIN
部署/部署包20250717/server/lib/sp/sp_gyt_recuritment_qy.jar