package com.engine.kq.biz.chain.duration;

import com.engine.kq.wfset.bean.SplitBean;
import com.engine.kq.wfset.util.SplitActionUtil;
import java.util.List;

/**
 * 非工作时长 按天计算
 */
public class NonDayUnitSplitChain extends NonWorkDurationChain {


  public NonDayUnitSplitChain(List<SplitBean> splitBeans) {
    super(splitBeans);
  }

  @Override
  public void handleDuration(SplitBean splitBean) throws Exception{
    String durationrule = splitBean.getDurationrule();
    if("1".equalsIgnoreCase(durationrule)){
      getSplitDurationBean(splitBean);
      if(!splitBeans.isEmpty()){
        SplitActionUtil.turnOvertimeBeansWithRule(splitBeans);
      }
    }else{
      this.success.handleDuration(splitBean);
    }
  }

  /**
   * 没有排除休息时间的加班时长
   * @param splitBean
   * @throws Exception
   */
  @Override
  public void handleNonBreakDuration(SplitBean splitBean) throws Exception {
    String durationrule = splitBean.getDurationrule();
    if("1".equalsIgnoreCase(durationrule)){
      getNonBreaksSplitDurationBean(splitBean);
      if(!splitBeans.isEmpty()){
        SplitActionUtil.turnOvertimeBeansWithRule(splitBeans);
      }
    }else{
      this.success.handleDuration(splitBean);
    }
  }

}
