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

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.recuritment.task.ResignBeisenFacadeFactory;
import com.kingdee.eas.hr.affair.ResignBizBillFactory;
import com.kingdee.eas.hr.affair.ResignBizBillInfo;
import com.kingdee.eas.hr.base.HRBillStateEnum;
import com.kingdee.shr.base.syssetting.context.SHRContext;
import com.kingdee.shr.base.syssetting.exception.SHRWebException;
import org.springframework.ui.ModelMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * description: ResignBizBillHrManListHandlerEx <br>
 * date: 2025/7/10 9:26 <br>
 * author: lhbj <br>
 * version: 1.0 <br>
 */
public class ResignBizBillHrManListHandlerEx extends com.kingdee.shr.affair.web.handler.hrman.ResignBizBillHrManListHandler{

    public String enableAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
        String billId = this.getBillId(request);
        String[] ids = billId.split(",");
        Context ctx = SHRContext.getInstance().getContext();
        try {
            for(String id : ids) {
                ResignBizBillInfo billInfo = ResignBizBillFactory.getLocalInstance(ctx).getResignBizBillInfo(new ObjectUuidPK(id));
                HRBillStateEnum stateEnum = billInfo.getBillState();
                if(HRBillStateEnum.AUDITED.equals(stateEnum)) {
                    ResignBeisenFacadeFactory.getLocalInstance(ctx).syncBeisenReserveTalentPool(id.toString(), billInfo);
                }else {
                    ResignBeisenFacadeFactory.getLocalInstance(ctx).syncUnBeisenReserveTalentPool(id.toString(), billInfo);
                }
            }
        } catch (BOSException e) {
            e.printStackTrace();
        } catch (EASBizException e) {
            e.printStackTrace();
        }
        return null;
    }
}
