package com.engine.organization.entity.chart;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @author:dxfeng
 * @createTime: 2023/06/30
 * @version: 1.0
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ChartPO {
    private String fname;
    /**
     * 0:集团,1:分部,2:部门
     */
    private String ftype;
    private String fnumber;
    private String fobjid;
    private String parentId;
    private String expand;
    private String fisvitual;
    private String hasChildren;

    // 在岗数
    private Integer fonjob;

    // 部门负责人
    private String fleader;

    // 人员主次账号
    private String belongto;
    // 人员工龄
    private String companyWorkYear;
    // 人员头像
    private String fleaderimg;

    private String id;
    private String key;

    // 部门层级
    private int departmentDepth;

    // 在编数
    private int onJobNum;
    // 编制数
    private int staffNum;

    public String getId() {
        if (StringUtils.isNotBlank(ftype)) {
            switch (ftype) {
                case "0":
                    id = "c_" + fobjid;
                    break;
                case "1":
                    id = "s_" + fobjid;
                    break;
                case "2":
                    id = "d_" + fobjid;
                    break;
                default:
                    break;
            }
        }
        return id;
    }

    public String getFisvitual() {
        // 人员、岗位不展示次字段
        if (StringUtils.isNotBlank(ftype) && ("3".equals(ftype) || "4".equals(ftype))) {
            return null;
        }
        return StringUtils.isBlank(fisvitual) ? "0" : fisvitual;
    }

    public String getKey() {
        return getId();
    }

    public String getCompanyWorkYear() {
        if (StringUtils.isNotBlank(ftype) && "4".equals(ftype)) {
            return StringUtils.isNotBlank(companyWorkYear) ? companyWorkYear : "0";
        }
        return null;
    }
}
