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

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.handover.task.WorkHandoverFacadeFactory;
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 org.apache.log4j.Logger;
import org.springframework.ui.ModelMap;

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

/**
 * @Description 工作交接人表单EditHandler
 * @Date 2025/5/30 17:46
 * @Created by Heyuan
 */
public class WorkHandoverListHandler extends ListHandler {
    private static Logger logger = Logger.getLogger(WorkHandoverListHandler.class);


    /**
     * 提交生效批量
     *
     * @param request
     * @param response
     * @param modelMap
     * @throws SHRWebException
     * @throws BOSException
     */
    public void submitEffectAction(
            HttpServletRequest request,
            HttpServletResponse response,
            ModelMap modelMap
    ) throws SHRWebException, BOSException {
        this.handleEnableWithTips(request, "submitEffect");
    }


    /**
     * 反审批批量
     *
     * @param request
     * @param response
     * @param modelMap
     * @throws SHRWebException
     * @throws BOSException
     */
    public void againstApproveAction(
            HttpServletRequest request,
            HttpServletResponse response,
            ModelMap modelMap
    ) throws SHRWebException, BOSException {
        this.handleEnableWithTips(request, "untiCheckBizBill");
    }

    /**
     * 撤回
     *
     * @param request
     * @param response
     * @param modelMap
     * @throws SHRWebException
     * @throws EASBizException
     * @throws BOSException
     */
    public void abortBizBillAction(
            HttpServletRequest request,
            HttpServletResponse response,
            ModelMap modelMap
    ) throws SHRWebException {
        this.handleEnableWithTips(request, "abortBizBill");
    }

    /**
     * 撤回
     *
     * @param request
     * @param response
     * @param modelMap
     * @throws SHRWebException
     * @throws EASBizException
     * @throws BOSException
     */
    public void createAndSubmitHandoverAction(
            HttpServletRequest request,
            HttpServletResponse response,
            ModelMap modelMap
    ) throws SHRWebException {
        try {
            Context ctx = SHRContext.getInstance().getContext();
            WorkHandoverFacadeFactory.getLocalInstance(ctx).createAndSubmitHandover(3);
        } catch (BOSException e) {
            throw new ShrWebBizException(e);
        } catch (EASBizException e) {
            throw new ShrWebBizException(e);
        }
    }
}
