yuanzhi_kuang 1 month ago
parent
commit
377666a246

+ 0 - 22
src/com/kingdee/eas/custom/recuritment/task/AbstractRecuritmentFacadeControllerBean.java

@@ -80,26 +80,4 @@ public abstract class AbstractRecuritmentFacadeControllerBean extends AbstractBi
         return;
     }
 
-    public void syncBeisenResume(Context ctx, String applyId) throws BOSException, EASBizException
-    {
-        try {
-            ServiceContext svcCtx = createServiceContext(new MetaDataPK("b23d0ff1-8603-4c48-906d-34665ce12ce6"), new Object[]{ctx, applyId});
-            invokeServiceBefore(svcCtx);
-              if(!svcCtx.invokeBreak()) {
-            _syncBeisenResume(ctx, applyId);
-            }
-            invokeServiceAfter(svcCtx);
-        } catch (BOSException ex) {
-            throw ex;
-        } catch (EASBizException ex0) {
-            throw ex0;
-        } finally {
-            super.cleanUpServiceState();
-        }
-    }
-    protected void _syncBeisenResume(Context ctx, String applyId) throws BOSException, EASBizException
-    {    	
-        return;
-    }
-
 }

+ 0 - 1
src/com/kingdee/eas/custom/recuritment/task/IRecuritmentFacade.java

@@ -17,5 +17,4 @@ public interface IRecuritmentFacade extends IBizCtrl
 {
     public void syncRecuritmentToBeisen(String billId) throws BOSException, EASBizException;
     public void updateRecuritment(String startDate, String endDate, int offset) throws BOSException, EASBizException;
-    public void syncBeisenResume(String applyId) throws BOSException, EASBizException;
 }

+ 64 - 52
src/com/kingdee/eas/custom/recuritment/task/RecruitmentDemandService.java

@@ -46,7 +46,7 @@ public class RecruitmentDemandService {
     private static final int REQUIREMENT_STATUS_IN_PROGRESS = 40;
     private static final int SHARE_TYPE_SUBORDINATE = 2;
     private static final int REQUIREMENT_TYPE_NEW = 1;
-    private static final int REQUIREMENT_TYPE_SUPPLY  = 2;
+    private static final int REQUIREMENT_TYPE_SUPPLY  = 4;
     // 值映射关系
     private static final Map<String, Integer> REQUIREMENT_TYPE_MAP = createRequirementTypeMap();
     private static final Map<String, Integer> CATEGORY_MAP = createCategoryMap();
@@ -57,8 +57,8 @@ public class RecruitmentDemandService {
     private static final Map<String, String> FORMAL_CUSTOM_FIELDS = createFormalCustomFields();
     private static final Map<String, String> TEST_CUSTOM_FIELDS = createTestCustomFields();
     //招聘类型
-    private static final Map<String, String> RECRUITMENTTYPE_MAP = createRecruitmentType();
-
+    private static final Map<String, Integer> RECRUITMENTTYPE_MAP = createRecruitmentType();
+    
     private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
     // 缓存工号到用户ID的映射(避免重复查询)
     private static final Map<String, Integer> jobNumberToUserIdCache = new ConcurrentHashMap<>();
@@ -140,23 +140,23 @@ public class RecruitmentDemandService {
         map.put("twelve", "12月");
         return Collections.unmodifiableMap(map);
     }
-
+    
     //招聘类型
-    private static Map<String, String> createRecruitmentType() {
-          Map<String, String> map = new HashMap<>();
+    private static Map<String, Integer> createRecruitmentType() {
+          Map<String, Integer> map = new HashMap<>();
              // 初始化映射关系
-          map.put("001", "001"); // 社会招聘
-          map.put("002", "002"); // 校园招聘
-          map.put("006", "006"); // 实习生招聘
-          map.put("003", "003"); // 内部推荐
-          map.put("004", "004"); // 内部竞聘
-          map.put("005", "005"); // 猎头招聘
-          map.put("007", "007"); // 外包(派遣)
-          map.put("008", "008"); // 管培生
+          map.put("001", 1); // 社会招聘
+          map.put("002", 2); // 校园招聘
+          map.put("006", 3); // 实习生招聘
+          map.put("003", 4); // 内部推荐
+          map.put("004", 5); // 内部竞聘
+          map.put("005", 6); // 猎头招聘
+          map.put("007", 7); // 外包(派遣)
+          map.put("008", 8); // 管培生
           return Collections.unmodifiableMap(map);
       }
 
-
+    
     private static Map<String, String> createFormalCustomFields() {
         Map<String, String> map = new HashMap<>();
         map.put("招聘职位", "extzhaopinzhiwei_614492_675953134");
@@ -174,7 +174,7 @@ public class RecruitmentDemandService {
         map.put("转正考核标准", "extzhuanzhengkaohebiaozhun_614492_1527148155");
         map.put("办公地点", "extbangongdidian_614492_920550595");
         map.put("招聘类型", "extzhaopinqudao_614492_409009478");
-
+        
         return Collections.unmodifiableMap(map);
     }
 
@@ -195,28 +195,28 @@ public class RecruitmentDemandService {
         map.put("转正考核标准", "extzhuanzhengkaohebiaozhun_433899_1527148155");
         map.put("办公地点", "extbangongdidian_433899_920550595");
         map.put("招聘类型", "extzhaopinqudao_433899_409009478");
-
+        
         return Collections.unmodifiableMap(map);
     }
 
 
 
-
+   
 
     /**
      * 构建需求数据公共部分
-     * @throws BOSException
-     * @throws EASBizException
+     * @throws BOSException 
+     * @throws EASBizException 
      */
     private JSONObject buildRequirementData(Context ctx, RecuritmentDemandInfo demandInfo) throws BOSException, EASBizException {
         JSONObject params = new JSONObject();
-
+ 
         // 需求类型映射
         RecPersonType recPersonType = demandInfo.getRecPersonType();
         if (recPersonType != null && StringUtils.isNotBlank(recPersonType.getValue())) {
             Integer mappedType = REQUIREMENT_TYPE_MAP.get(recPersonType.getValue());
             params.put("requirementType", mappedType != null ? mappedType : REQUIREMENT_TYPE_NEW);
-//            //test
+//            //test  
 //            params.put("requirementType", 1);
         }
 
@@ -225,7 +225,7 @@ public class RecruitmentDemandService {
         params.put("requirementCount", demandInfo.getRecuritNumber());
         params.put("jobDescription", demandInfo.getResponsibilities());
         params.put("qualification", demandInfo.getQualification());
-
+        
         AdminOrgUnitInfo department = demandInfo.getDepartment();
         if(null!= department) {
         	IAdminOrgUnit orgIns = AdminOrgUnitFactory.getLocalInstance(ctx);
@@ -235,13 +235,13 @@ public class RecruitmentDemandService {
 //            //test
 //            params.put("departmentId", 0);
         }
-
+        
         // 日期字段
         Date applyDate = demandInfo.getApplyDate();
         if (applyDate != null) {
             params.put("createDate", DATE_FORMAT.format(applyDate));
         }
-
+        
         Date arrivalDate = demandInfo.getArrivalDate();
         if (arrivalDate != null) {
             params.put("arivalTime", DATE_FORMAT.format(arrivalDate));
@@ -271,22 +271,22 @@ public class RecruitmentDemandService {
         params.put("requirementStatus", rStatus);
         // 处理自定义字段
         addCustomFields(  ctx, params, demandInfo);
-
+        
         return params;
     }
 
     /**
      * 添加自定义字段
-     * @throws BOSException
-     * @throws EASBizException
+     * @throws BOSException 
+     * @throws EASBizException 
      */
     private void addCustomFields(Context ctx, JSONObject params, RecuritmentDemandInfo demandInfo) throws BOSException, EASBizException {
         // 招聘职位
         addCustomField(params, "招聘职位", demandInfo.getRecuritPosition().getName());
-
+        
         // 招聘业务组织
         addCustomField(params, "招聘业务组织", demandInfo.getHrOrgUnit().getName());
-
+        
         // 其他自定义字段
      // 招聘申请类型 (headcountType -> 自定义字段)
         String headcountType = Optional.ofNullable(demandInfo.get("headcountType"))
@@ -302,21 +302,21 @@ public class RecruitmentDemandService {
         }
         addCustomField(params, "福利待遇", getBenefits(demandInfo));
         addCustomField(params, "备注", demandInfo.getRecRema());
-
+        
         // 培养周期特殊处理
         String trainPeriod = Optional.ofNullable(getPropertyValue(demandInfo, "trainPeriod"))
                 .map(Object::toString)
                 .map(key -> TRAIN_PERIOD_MAP.getOrDefault(key, ""))
                 .orElse("");
         addCustomField(params, "培养周期", trainPeriod);
-
+        
         // 其他字段
         addCustomField(params, "是否需轮岗", mapYesNo(getPropertyValue(demandInfo, "needJobRotation")));
         addCustomField(params, "轮岗岗位", getPropertyAsString(demandInfo, "rotationPosition"));
         addCustomField(params, "定岗岗位", getPropertyAsString(demandInfo, "fixedPosition"));
         addCustomField(params, "转正考核标准", getPropertyAsString(demandInfo, "regularizationStandard"));
         addCustomField(params, "办公地点", getPropertyAsString(demandInfo, "workPlace"));
-
+        
         //
 //        if( null != demandInfo.get("demandCompType")) {
 //        	   DemandCompTypeInfo demandCompType = (DemandCompTypeInfo) demandInfo.get("demandCompType");
@@ -330,23 +330,23 @@ public class RecruitmentDemandService {
         		IRecType4BaseItem retTypeIns = RecType4BaseItemFactory.getLocalInstance(ctx);
         		recType = retTypeIns.getRecType4BaseItemInfo( new ObjectUuidPK(recType.getId().toString()));
         		String number = recType.getNumber();
-        		String string = RECRUITMENTTYPE_MAP.get(number);
-        		addCustomField(params, "招聘类型", string );
+        		Integer  val = RECRUITMENTTYPE_MAP.get(number);
+        		addCustomField(params, "招聘类型", val );
         	}
         }
     }
 
     /**
      * 创建招聘需求
-     * @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 , "");
         return response.getString("data");
     }
-
+    
     /**
      * 推送招聘需求到北森系统
      * @param demandInfo sHR系统的招聘需求数据
@@ -358,16 +358,16 @@ public class RecruitmentDemandService {
         params.put("shareType", SHARE_TYPE_SUBORDINATE);          // 共享方式固定为2(共享给下级)
         return createRequirement( ctx, demandInfo,params);
     }
-
-
+    
+    
     public void updateRequirement(Context ctx, String requirementId, RecuritmentDemandInfo demandInfo) throws BOSException, EASBizException {
         JSONObject params = buildRequirementData(  ctx, demandInfo);
         params.put("requirementId", requirementId);
-        params.put("requirementStatus", REQUIREMENT_STATUS_IN_PROGRESS); // 进行中
-
+//        params.put("requirementStatus", REQUIREMENT_STATUS_IN_PROGRESS); // 进行中
+        
         try {
             BeisenApiClient apiClient = BeisenApiClient.getInstance();
-            JSONObject response = apiClient.callApi(BeisenParam.UPDATE_REQUIREMENT_URL, params);
+            JSONObject response = apiClient.callPutApi(BeisenParam.UPDATE_REQUIREMENT_URL, params);
 //            String msg = "更新_"+response.getString("message");
             handleApiResponse(ctx,response,demandInfo ,  requirementId);
         } catch (IOException e) {
@@ -377,8 +377,8 @@ public class RecruitmentDemandService {
 
     /**
      * 处理API响应
-     * @throws BOSException
-     * @throws EASBizException
+     * @throws BOSException 
+     * @throws EASBizException 
      */
     private void handleApiResponse(Context ctx, JSONObject response, RecuritmentDemandInfo demandInfo ,String requirementId) throws BOSException, EASBizException {
         int code = response.getIntValue("code");
@@ -411,7 +411,7 @@ public class RecruitmentDemandService {
     private Object getPropertyValue(RecuritmentDemandInfo demandInfo, String property) {
         return demandInfo.get(property);
     }
-
+    
     /**
      * 获取属性字符串值
      */
@@ -452,12 +452,12 @@ public class RecruitmentDemandService {
         String sql = "SELECT BENEFITS.FName FROM T_REC_Benefits BENEFITS " +
                      "JOIN T_REC_RecDemandLinkBenefits LINK01 ON (BENEFITS.FID = LINK01.FBenefitsID) " +
                      "WHERE BENEFITS.FState = 1 AND LINK01.FDemandID = ?";
-
+        
         StringBuilder value = new StringBuilder();
         try {
-            List<Object[]> datas = RecDBUtils.getQueryData(SHRContext.getInstance().getContext(), sql,
+            List<Object[]> datas = RecDBUtils.getQueryData(SHRContext.getInstance().getContext(), sql, 
                     new Object[]{demandInfo.getId().toString()});
-
+            
             if (CollectionUtils.isNotEmpty(datas)) {
                 for (Object[] objects : datas) {
                     if (objects.length > 0) {
@@ -482,6 +482,18 @@ public class RecruitmentDemandService {
             }
         }
     }
+    
+    /**
+     * 添加自定义字段_integer
+     */
+    private void addCustomField(JSONObject params, String fieldName, Integer value) {
+        if (null != value) {
+            String fieldCode = getCustomFieldCode(fieldName);
+            if (fieldCode != null) {
+                params.put(fieldCode, value);
+            }
+        }
+    }
 
     /**
      * 获取自定义字段编码
@@ -495,8 +507,8 @@ public class RecruitmentDemandService {
      * 映射招聘申请类型
      */
     private String mapHeadcountType(String headcountType) {
-        return StringUtils.isNotBlank(headcountType) ?
-                HEADCOUNT_TYPE_MAP.getOrDefault(headcountType, headcountType) :
+        return StringUtils.isNotBlank(headcountType) ? 
+                HEADCOUNT_TYPE_MAP.getOrDefault(headcountType, headcountType) : 
                 null;
     }
 
@@ -603,4 +615,4 @@ public class RecruitmentDemandService {
         }
     }
 
-}
+}

+ 0 - 13
src/com/kingdee/eas/custom/recuritment/task/RecuritmentFacade.java

@@ -62,17 +62,4 @@ public class RecuritmentFacade extends AbstractBizCtrl implements IRecuritmentFa
             throw new EJBRemoteException(err);
         }
     }
-    /**
-     *定时拉取北森简历-User defined method
-     *@param applyId 北森申请id
-     */
-    public void syncBeisenResume(String applyId) throws BOSException, EASBizException
-    {
-        try {
-            getController().syncBeisenResume(getContext(), applyId);
-        }
-        catch(RemoteException err) {
-            throw new EJBRemoteException(err);
-        }
-    }
 }

+ 0 - 1
src/com/kingdee/eas/custom/recuritment/task/RecuritmentFacadeController.java

@@ -20,5 +20,4 @@ public interface RecuritmentFacadeController extends BizController
 {
     public void syncRecuritmentToBeisen(Context ctx, String billId) throws BOSException, EASBizException, RemoteException;
     public void updateRecuritment(Context ctx, String startDate, String endDate, int offset) throws BOSException, EASBizException, RemoteException;
-    public void syncBeisenResume(Context ctx, String applyId) throws BOSException, EASBizException, RemoteException;
 }

+ 40 - 52
src/com/kingdee/eas/custom/recuritment/task/RecuritmentFacadeControllerBean.java

@@ -18,83 +18,72 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 
-public class RecuritmentFacadeControllerBean extends AbstractRecuritmentFacadeControllerBean {
+public class RecuritmentFacadeControllerBean extends AbstractRecuritmentFacadeControllerBean
+{
     private static Logger logger =
-            Logger.getLogger(RecuritmentFacadeControllerBean.class);
+        Logger.getLogger(RecuritmentFacadeControllerBean.class);
 
 
     // 北京时区/shanghai时区
 //    private static final ZoneId BEIJING_ZONE = ZoneId.of("Asia/Shanghai");
 
-    private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-
-    /**
-     * 定时拉取北森简历
-     *
-     * @param ctx
-     * @param applyId 北森申请id
-     * @throws BOSException
-     * @throws EASBizException
-     */
+    private static final DateTimeFormatter TIME_FORMATTER =  DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") ;
+    
     @Override
-    protected void _syncBeisenResume(Context ctx, String applyId) throws BOSException, EASBizException {
-        logger.error("_syncBeisenResume--" + applyId);
-        super._syncBeisenResume(ctx, applyId);
-    }
-
-    @Override
-    protected void _syncRecuritmentToBeisen(Context ctx, String billId) throws BOSException, EASBizException {
-        super._syncRecuritmentToBeisen(ctx, billId);
-
+    protected void _syncRecuritmentToBeisen(Context ctx, String billId)  throws BOSException, EASBizException {
+    	super._syncRecuritmentToBeisen(ctx, billId);
+    	
         IRecuritmentDemand dIns = RecuritmentDemandFactory.getLocalInstance(ctx);
         RecuritmentDemandInfo recuritmentDemandInfo = dIns.getRecuritmentDemandInfo(new ObjectUuidPK(billId));
         RecruitmentDemandService recruitmentDemandService = new RecruitmentDemandService(false);
         //更新或新增
         try {
-            Object requirementId = recuritmentDemandInfo.get("requirementId");
-            if (ObjectUtils.allNotNull(requirementId)) {
-                recruitmentDemandService.updateRequirement(ctx, String.valueOf(requirementId), recuritmentDemandInfo);
-            } else {
-                recruitmentDemandService.createRecruitmentDemand(ctx, recuritmentDemandInfo);
-            }
+        	Object requirementId = recuritmentDemandInfo.get("requirementId");
+        	if(ObjectUtils.allNotNull(requirementId)) {
+        		recruitmentDemandService.updateRequirement(  ctx, String.valueOf(requirementId) , recuritmentDemandInfo);  
+        	}else {
+        		recruitmentDemandService.createRecruitmentDemand (  ctx, recuritmentDemandInfo);
+        	}
         } catch (Exception e) {
-            SelectorItemCollection selectorCol = new SelectorItemCollection();
-            selectorCol.add(new SelectorItemInfo("syncBeisenResult"));
+        	SelectorItemCollection selectorCol = new SelectorItemCollection();
+            selectorCol.add(new  SelectorItemInfo("syncBeisenResult"));
             String message = e.getMessage();
-            recuritmentDemandInfo.put("syncBeisenResult", "失败: " + message);
+            recuritmentDemandInfo.put("syncBeisenResult", "失败: " + message );
             dIns.updatePartial(recuritmentDemandInfo, selectorCol);
             throw new RuntimeException(e);
         }
     }
-
-
+    
+    
+    
+    
     /**
      * 招聘需求更新
      * coyle
      */
     @Override
     protected void _updateRecuritment(Context ctx, String startDate, String endDate, int offset)
-            throws BOSException, EASBizException {
-        super._updateRecuritment(ctx, startDate, endDate, offset);
-
-        // 0. 参数校验与日期解析
+    		throws BOSException, EASBizException {
+    	super._updateRecuritment(ctx, startDate, endDate, offset);
+    	
+    	// 0. 参数校验与日期解析
         DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate start = LocalDate.now();
         LocalDate end = LocalDate.now();
         //如果时间参数都为空,则使用offset参数
-        if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate)) {
-            if (offset > 0) {
+        if(StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate)){
+            if( offset > 0 ){
                 //eDate增加offset天
                 end = end.plusDays(offset);
-            } else if (offset < 0) {
+            }else if( offset < 0 ) {
                 start = start.plusDays(offset);
             }
         }
-        if (!StringUtils.isEmpty(startDate)) {
+        if(!StringUtils.isEmpty(startDate) ){
             //开始日期字定义,结束日期都是今天
             start = LocalDate.parse(startDate, dateFormatter);
         }
-        if (!StringUtils.isEmpty(endDate)) {
+        if(!StringUtils.isEmpty(endDate)){
             //开始日期,结束日期都是今天
             end = LocalDate.parse(endDate, dateFormatter);
         }
@@ -108,24 +97,24 @@ public class RecuritmentFacadeControllerBean extends AbstractRecuritmentFacadeCo
 
         IRecuritmentDemand localInstance = RecuritmentDemandFactory.getLocalInstance(ctx);
         EntityViewInfo ev = new EntityViewInfo();
-        FilterInfo filter = new FilterInfo();
-        filter.getFilterItems().add(new FilterItemInfo("requirementId", null, CompareType.NOTEMPTY));
-        filter.getFilterItems().add(new FilterItemInfo("lastUpdateTime", startStr, CompareType.GREATER_EQUALS));
-        filter.getFilterItems().add(new FilterItemInfo("lastUpdateTime", endStr, CompareType.LESS_EQUALS));
+		FilterInfo filter = new FilterInfo();
+		filter.getFilterItems().add(new FilterItemInfo("requirementId", null, CompareType.NOTEMPTY));
+		filter.getFilterItems().add(new FilterItemInfo("lastUpdateTime",  startStr  , CompareType.GREATER_EQUALS));
+		filter.getFilterItems().add(new FilterItemInfo("lastUpdateTime",  endStr , CompareType.LESS_EQUALS));
         ev.setFilter(filter);
 
         RecuritmentDemandCollection recuritmentDemandCollection = localInstance.getRecuritmentDemandCollection(ev);
-        for (int i = 0; i < recuritmentDemandCollection.size(); i++) {
+        for(int i = 0; i < recuritmentDemandCollection.size(); i++){
             RecuritmentDemandInfo recuritmentDemandInfo = recuritmentDemandCollection.get(i);
             _syncRecuritmentToBeisen(ctx, recuritmentDemandInfo.getId().toString());
         }
 
     }
 
-
+    
+    
     /**
      * 将日期字符串转换为一天的开始时间(UTC格式)
-     *
      * @param dateStr "yyyy-MM-dd"格式的日期字符串
      * @return Moka API要求的时间格式
      */
@@ -134,10 +123,9 @@ public class RecuritmentFacadeControllerBean extends AbstractRecuritmentFacadeCo
         LocalDateTime startOfDay = date.atStartOfDay();
         return TIME_FORMATTER.format(startOfDay);
     }
-
+    
     /**
      * 将日期字符串转换为一天的结束时间(UTC格式)
-     *
      * @param dateStr "yyyy-MM-dd"格式的日期字符串
      * @return Moka API要求的时间格式
      */
@@ -146,6 +134,6 @@ public class RecuritmentFacadeControllerBean extends AbstractRecuritmentFacadeCo
         LocalDateTime endOfDay = date.atTime(23, 59, 59);
         return TIME_FORMATTER.format(endOfDay);
     }
+    
 
-
-}
+}