package nckd.jxccl.hrmp.hbpm.business.hr.utils;

import kd.bos.exception.KDBizException;
import kd.bos.form.IFormView;
import nckd.jxccl.hrmp.hbpm.common.hr.PositionBillConstant;

import java.util.Locale;
import java.util.stream.Stream;

/**
 * 岗位申请单工具类
 * @from: kd.hr.homs.business.utils.OrgChgUtil
 * @author: jtd
 * @date: 2025/12/30 15:06
 */
public class PositionBillUtil {

    public static synchronized IFormView getView(IFormView view, String name) {
        String msg = String.format(Locale.ROOT, "需要从 %s 页面进入", name);
        if (view == null) {
            throw new KDBizException(msg);
        } else {
            String pageName = view.getModel().getDataEntityType().getName();
            Stream<String> pause = Stream.of(name, PositionBillConstant.BOS_LIST_ENTITY);
            return pause.anyMatch((s) -> s.equals(pageName)) ? view : getView(view.getParentView(), name);
        }
    }

}
