package com.engine.htsc.ReimbursementFlow.model;

import com.engine.htsc.ReimbursementFlow.tool.ZbspgzbTool;
import com.weaver.general.Util;
import weaver.conn.RecordSet;

public class NewDepart {
    private String depId;   // 部门唯一标识
    private String depCode; // 部门编码（业务code）
    private String depName;   // 部门名称
    private String departmentId;   // 机构id
    private String depLevel;    //部门层级（用来区分二级部等）
    private String parentDepId; //上级部门唯一标识
    private String parentDepCode;   //上级部门编码（业务code）
    private String depTypeCode; //部门类型编码（JGLX01等业务code）
    private String depClassCode;    //部门类别编码（001等业务code）
    private String directorId;  //部门负责人唯一标识（联席负责人逗号分割）
    private String leaderId;    //部门分管领导唯一标识
    private String parentDirectorId; //上级部门负责人唯一标识

    public NewDepart() {
    }

    public NewDepart(String depId) {
        String sql = "select t1.id,\n" +
                "       t1.departmentcode     as depCode,\n" +
                "       t1.departmentname     as depName,\n" +
                "       t2.deptdepth          as depLevel,\n" +
                "       t1.supdepid           as parentDepId,\n" +
                "       t3.departmentcode     as parentDepCode,\n" +
                "       t2.depttypecode       as depTypeCode,\n" +
                "       t2.deptscalelevelcode as depClassCode,\n" +
                "       t2.deptdirectors      as directorId,\n" +
                "       t2.deptleaders        as leaderId,\n" +
                "       t0.id        as departmentId,\n" +
                "       t4.deptdirectors      as parentDirectorId\n" +
                "  from (select id from (select t.*\n" +
                "          from HrmDepartment t\n" +
                "         start with t.id =  " +depId +"\n"+
                "        connect by prior t.supdepid = t.id) where SUPDEPID is null\n" +
                "    or SUPDEPID = 0 ) t0,hrmdepartment t1, hrmdepartmentdefined t2, hrmdepartment t3, hrmdepartmentdefined t4\n" +
                "   where t1.id = t2.deptid\n" +
                "   and t1.supdepid = t3.id\n" +
                "   and t3.id = t4.deptid\n" +
                "   and t1.id = " +depId+ "";
        RecordSet rs = new RecordSet();
        rs.execute(sql);
        if(rs.next()){
            this.depId = depId;
            this.depCode = Util.null2String(rs.getString("depCode"));
            this.depName = Util.null2String(rs.getString("depName"));
            this.depLevel = Util.null2String(rs.getString("depLevel"));
            this.departmentId = Util.null2String(rs.getString("departmentId"));
            this.parentDepId = Util.null2String(rs.getString("parentDepId"));
            this.parentDepCode = Util.null2String(rs.getString("parentDepCode"));
            this.depTypeCode = Util.null2String(rs.getString("depTypeCode"));
            this.depClassCode = Util.null2String(rs.getString("depClassCode"));
            this.directorId = Util.null2String(rs.getString("directorId"));
            this.leaderId = Util.null2String(rs.getString("leaderId"));
            this.parentDirectorId = Util.null2String(rs.getString("parentDirectorId"));
        }
    }

    public String getDepId() {
        return depId;
    }

    public void setDepId(String depId) {
        this.depId = depId;
    }

    public String getDepCode() {
        return depCode;
    }

    public void setDepCode(String depCode) {
        this.depCode = depCode;
    }

    public String getDepLevel() {
        return depLevel;
    }

    public void setDepLevel(String depLevel) {
        this.depLevel = depLevel;
    }

    public String getParentDepId() {
        return parentDepId;
    }

    public void setParentDepId(String parentDepId) {
        this.parentDepId = parentDepId;
    }

    public String getParentDepCode() {
        return parentDepCode;
    }

    public void setParentDepCode(String parentDepCode) {
        this.parentDepCode = parentDepCode;
    }

    public String getDepTypeCode() {
        return depTypeCode;
    }

    public void setDepTypeCode(String depTypeCode) {
        this.depTypeCode = depTypeCode;
    }

    public String getDepClassCode() {
        return depClassCode;
    }

    public void setDepClassCode(String depClassCode) {
        this.depClassCode = depClassCode;
    }

    public String getDirectorId() {
        return directorId;
    }

    public void setDirectorId(String directorId) {
        this.directorId = directorId;
    }

    public String getLeaderId() {
        return leaderId;
    }

    public void setLeaderId(String leaderId) {
        this.leaderId = leaderId;
    }

    public String getParentDirectorId() {
        return parentDirectorId;
    }

    public void setParentDirectorId(String parentDirectorId) {
        this.parentDirectorId = parentDirectorId;
    }

    public String getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(String departmentId) {
        this.departmentId = departmentId;
    }

    public String getDepName() {
        return depName;
    }

    public void setDepName(String depName) {
        this.depName = depName;
    }
}
