|
@@ -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 {
|
|
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");
|
|
return response.getString("data");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 推送招聘需求到北森系统
|
|
* 推送招聘需求到北森系统
|
|
* @param demandInfo sHR系统的招聘需求数据
|
|
* @param demandInfo sHR系统的招聘需求数据
|
|
@@ -364,13 +371,13 @@ public class RecruitmentDemandService {
|
|
JSONObject params = buildRequirementData( ctx, demandInfo);
|
|
JSONObject params = buildRequirementData( ctx, demandInfo);
|
|
params.put("requirementId", requirementId);
|
|
params.put("requirementId", requirementId);
|
|
// params.put("requirementStatus", REQUIREMENT_STATUS_IN_PROGRESS); // 进行中
|
|
// params.put("requirementStatus", REQUIREMENT_STATUS_IN_PROGRESS); // 进行中
|
|
-
|
|
|
|
|
|
+ JSONObject response = new JSONObject();
|
|
try {
|
|
try {
|
|
BeisenApiClient apiClient = BeisenApiClient.getInstance();
|
|
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);
|
|
logger.error("更新招聘需求时发生错误", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -381,8 +388,15 @@ public class RecruitmentDemandService {
|
|
* @throws EASBizException
|
|
* @throws EASBizException
|
|
*/
|
|
*/
|
|
private void handleApiResponse(Context ctx, JSONObject response, RecuritmentDemandInfo demandInfo ,String requirementId) throws BOSException, 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();
|
|
SelectorItemCollection selectorCol = new SelectorItemCollection();
|
|
selectorCol.add(new SelectorItemInfo("requirementId"));
|
|
selectorCol.add(new SelectorItemInfo("requirementId"));
|
|
selectorCol.add(new SelectorItemInfo("syncBeisenResult"));
|
|
selectorCol.add(new SelectorItemInfo("syncBeisenResult"));
|