package nckd.jxccl.wtc.wtabm.web.validate;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.validate.AbstractValidator;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.util.StringUtils;
import nckd.jxccl.wtc.wtabm.web.service.VaApplyValidateService;

/**
 * Tyx
 * 2025-09-28
 * 休假单提交校验器，校验以下内容：
 * 1，当员工当年事假N天以上，不允许进行当年度年假申请； N在nckd_wtparam配置中；
 * 2，社会工龄1年以上10年以下的员工，当年病假累计2个月以上，不允许进行当年度年假申请
 */
public class VaApplySubmitValidator extends AbstractValidator {

    private static final Log log = LogFactory.getLog(VaApplySubmitValidator.class);

    @Override
    public void validate() {
        for (ExtendedDataEntity dataEntity : dataEntities) {
            DynamicObject bill = dataEntity.getDataEntity();
            String msg = VaApplyValidateService.checkOverTimeByPersonalLeave(bill);
            if(!StringUtils.isEmpty(msg)) {
                log.info("-------- 休假单事假校验返回信息：{}", msg);
                this.addErrorMessage(dataEntity, msg);
            }
            msg = VaApplyValidateService.checkOverTimeByAnnualSickLeave(bill);
            if(!StringUtils.isEmpty(msg)) {
                log.info("-------- 休假单年病假校验返回信息：{}", msg);
                this.addErrorMessage(dataEntity, msg);
            }
        }
    }
}
