package com.kingdee.eas.custom.recuritment.handler;

import com.kingdee.bos.Context;
import com.kingdee.eas.custom.recuritment.task.RecuritmentFacadeFactory;
import com.kingdee.eas.custom.recuritment.utils.BeisenRecruitOwnerApiHelper;
import com.kingdee.shr.base.syssetting.app.osf.OSFAppUtil;
import com.kingdee.shr.base.syssetting.context.SHRContext;
import com.kingdee.shr.base.syssetting.exception.SHRWebException;
import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
import com.kingdee.shr.base.syssetting.web.handler.ListHandler;
import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
import org.apache.log4j.Logger;
import org.springframework.ui.ModelMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * @author qingwu
 * @date 2025/7/2
 * @apiNote
 */
public class ApplicantBeisenListHandler extends ListHandler {
    private static final Logger logger = Logger.getLogger(ApplicantBeisenListHandler.class);

    /**
     * 同步北森简历
     *
     * @param request
     * @param response
     * @param modelMap
     * @throws SHRWebException
     */
    public void syncBeisenResumeAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
        Context ctx = SHRContext.getInstance().getContext();
        String billId = getBillId(request);
        try {
            RecuritmentFacadeFactory.getLocalInstance(ctx).syncBeisenResume(billId);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ShrWebBizException(e);
        }
    }

    /**
     * 同步招聘负责人
     *
     * @param request
     * @param response
     * @param modelMap
     * @throws SHRWebException
     */
    public void SyncRecruitOwnerAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
        Context ctx = SHRContext.getInstance().getContext();
        String billId = getBillId(request);
        try {
            // 同步招聘负责人
            String serviceName = "syncRecruitOwnerService";
            Map param = new HashMap();
            param.put("billIds", billId);
            Object osfObject = OSFAppUtil.callService(ctx, serviceName, (HashMap) param);
            logger.error("osfObject--" + osfObject);
            JSONUtils.writeJson(response, osfObject);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ShrWebBizException(e);
        }
    }
}
