package com.engine.htsc.generaltrip.model;

import com.engine.htsc.generaltrip.tools.CcsqModelTools;
import com.weaver.general.Util;
import weaver.conn.RecordSet;

public class CcsqDept {
    private String depId;// 部门唯一标识
    private String depCode;// 部门编码（业务code）
    private String depName;// 部门名称
    private String depLevel;//部门层级（用来区分二级部等）
    private String parentDepId;//上级部门唯一标识
    private String depTypeCode;//部门类型编码（JGLX01等业务code）
    private String jglx;//部门所属机构类型（JGLX01等业务code）
    private String depClassCode;//部门类别编码（001等业务code）
    private String directorId;//部门负责人唯一标识（联席负责人逗号分割）
    private String directorFlId;//部门负责人唯一标识（非联席负责人）
    private String leaderId;//部门分管领导唯一标识
    private String cohead;//部门联席负责人
    private String canceled;//是否为虚拟部门1是0否

    public CcsqDept(String id) {
        this.depId = id;
        String sql = "\n" +
                "select t1.id,\n" +
                "       t1.departmentCode     as depCode,\n" +
                "       t1.departmentname     as departmentname,\n" +
                "       t1.canceled     as canceled,\n" +
                "       t2.deptdepth          as depLevel,\n" +
                "       t1.supdepid           as parentDepId,\n" +
                "       t2.depttypecode       as depTypeCode,\n" +
                "       t2.deptscalelevelcode as depClassCode,\n" +
                "       t2.deptdirectors      as directorId,\n" +
                "       t2.cohead      as cohead,\n" +
                "       t2.deptleaders        as leaderId\n" +
                "  from hrmdepartment t1, hrmdepartmentdefined t2\n" +
                " where t1.id = t2.deptid\n" +
                "   and t1.id = " + depId ;
        RecordSet rs = new RecordSet();
        rs.execute(sql);
        if(rs.next()){
            CcsqModelTools ccsqModelTools = new CcsqModelTools();
            this.depCode = Util.null2String(rs.getString("depCode"));
            this.depName = Util.null2String(rs.getString("departmentname"));
            this.depLevel = Util.null2String(rs.getString("depLevel"));
            this.canceled = Util.null2String(rs.getString("canceled"));
            this.parentDepId =  Util.null2String(rs.getString("parentDepId"));
            this.depTypeCode = Util.null2String(rs.getString("depTypeCode"));
            this.jglx = ccsqModelTools.getJglx(rs.getString("depTypeCode"));
            this.depClassCode = Util.null2String(rs.getString("depClassCode"));
            this.cohead = Util.null2String(rs.getString("cohead"));
            this.directorId = Util.null2String(rs.getString("directorId"));
            this.directorFlId = ccsqModelTools.distinctString(Util.null2String(rs.getString("directorId")),Util.null2String(rs.getString("cohead")));
            this.leaderId = Util.null2String(rs.getString("leaderId"));

        }else {
            this.depCode = "";
            this.depName = "";
            this.depLevel = "";
            this.canceled = "";
            this.parentDepId = "";
            this.depTypeCode = "";
            this.jglx = "";
            this.depClassCode = "";
            this.cohead = "";
            this.directorId = "";
            this.directorFlId = "";
            this.leaderId = "";
        }
    }

    public CcsqDept() {
    }

    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 getDepName() {
        return depName;
    }

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

    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 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 getDirectorFlId() {
        return directorFlId;
    }

    public void setDirectorFlId(String directorFlId) {
        this.directorFlId = directorFlId;
    }

    public String getLeaderId() {
        return leaderId;
    }

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

    public String getCohead() {
        return cohead;
    }

    public void setCohead(String cohead) {
        this.cohead = cohead;
    }

    public String getCanceled() {
        return canceled;
    }

    public void setCanceled(String canceled) {
        this.canceled = canceled;
    }

    public String getJglx() {
        return jglx;
    }

    public void setJglx(String jglx) {
        this.jglx = jglx;
    }
}
