package com.kingdee.eas.custom.projectbonus.web.handler;

import com.kingdee.bos.Context;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.eas.custom.projectbonus.BonusCycleFactory;
import com.kingdee.eas.custom.projectbonus.BonusCycleInfo;
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 com.kingdee.util.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.ui.ModelMap;

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

/**
 * @Description 事业部项目负责人ListHandler
 * @Date 2024/5/27 9:35
 * @Created by Heyuan
 */
public class BusDepProjectPrincipalListHandler extends ListHandler {
    private static Logger logger = Logger.getLogger(BusDepProjectPrincipalListHandler.class);

    /**
     * 通过周期id获取提醒内容
     *
     * @param request
     * @param response
     * @param modelMap
     * @return getReminderContentByBonusCycleIdAction
     * @throws SHRWebException
     */
    public void getReminderContentByBonusCycleIdAction(HttpServletRequest request,
                                                       HttpServletResponse response,
                                                       ModelMap modelMap) throws SHRWebException {
        //周期id
        String bonusCycleId = request.getParameter("bonusCycleId");
        if (StringUtils.isEmpty(bonusCycleId)) {
            throw new ShrWebBizException("周期id不能为空！");
        }
        Context ctx = SHRContext.getInstance().getContext();
        try {
            BonusCycleInfo info = BonusCycleFactory.getLocalInstance(ctx).getBonusCycleInfo(new ObjectUuidPK(bonusCycleId));
            String reminderContent = info.getReminderContent();
            JSONUtils.SUCCESS(reminderContent);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ShrWebBizException(e.getMessage());
        }
    }
}
