package com.engine.recruit.entity.card.process;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.general.BaseBean;
import weaver.hrm.resource.ResourceComInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author:dxfeng
 * @createTime: 2024/08/07
 * @version: 1.0
 */
public class InterviewProcess {
    public static final String ICON_NAME = "interview.png";
    public static final String TITLE = "最近面试";

    private String zt;
    private String msrq;
    List<InterviewDetail> interviewDetails = new ArrayList<>();


    public String getZt() {
        if ("0".equals(zt)) {
            return "待面试";
        } else if ("1".equals(zt)) {
            return "已反馈";
        }
        return "已取消";
    }

    public void setZt(String zt) {
        this.zt = zt;
    }

    public String getMsrq() {
        return msrq;
    }

    public void setMsrq(String msrq) {
        this.msrq = msrq;
    }

    public List<InterviewDetail> getInterviewDetails() {
        return interviewDetails;
    }

    public void addInterviewDetail(String msg, String msjg) {
        interviewDetails.add(new InterviewDetail(msg, msjg));
    }


    @Override
    public String toString() {
        StringBuilder toString = new StringBuilder(getMsrq());
        if(CollectionUtils.isNotEmpty(interviewDetails)) {
            toString.append("    ").append("面试官：");
            for (InterviewDetail interviewDetail : interviewDetails) {
                toString.append("    ").append(interviewDetail.toString());
            }
        }
        return toString.toString();

    }

    public static class InterviewDetail{
        private final String msg;
        private final String msjg;

        InterviewDetail(String msg,String msjg) {
            this.msg = msg;
            this.msjg = msjg;
        }

        public String getMsg() {
            try {
                String lastnames = new ResourceComInfo().getLastnames(msg);
                if (StringUtils.isNotBlank(lastnames)) {
                    return  lastnames;
                }
            } catch (Exception e) {
                new BaseBean().writeLog("人员姓名转换失败", e);
            }
            return "";
        }


        public String getMsjg() {
            if (StringUtils.isBlank(msjg)) {
                return "未反馈";
            } else if ("0".equals(msjg)) {
                return "通过";
            } else if ("1".equals(msjg)) {
                return "不通过";
            } else {
                return "待定";
            }
        }

        @Override
        public String toString() {
            String msgName = getMsg();
            if (StringUtils.isNotBlank(msgName)) {
                return msgName + "    (" + getMsjg()+")";
            }
            return "";
        }
    }
}
