package com.engine.htsc.generaltrip.model;

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

public class CcsqUser {
    private String userId;//报销人泛微人员唯一标识
    private String workCode;//工号或主、子账号（业务code）
    private String depId;//报销人所属部门范围部门唯一标识
    private String depCode;//报销人所属部门编码（业务code）
    private String jobGrade;//职级 预留字段 为差旅标准预留
    private String jobId;//报销人岗位唯一标识
    private String jobCode;//报销人岗位编码（业务code）
    private Integer securityLevel;//安全级别
    private String depLevel;//部门层级（用来区分二级部等）
    private String jobGradeLevel;//部门职级如二级部门普通员工例如：PT_LV2，查询审批人角色
    private CcsqDept ccsqDept;

    public CcsqUser(String userId) {
        this.userId = userId;
        String sql = "select a.*,t3.jobtitlecode as jobCode\n" +
                " from (select t1.workcode       as workCode,\n" +
                "       t1.lastname       as userName,\n" +
                "       t2.departmentname as depName,\n" +
                "       t2.id             as depId,\n" +
                "       t2.departmentcode as depCode,\n" +
                "       t1.joblevel       as jobGrade,\n" +
                "       t1.jobtitle       as jobId,\n" +
                "       t1.seclevel       as securityLevel,\n" +
                "       t4.deptdepth      as depLevel\n" +
                "  from hrmresource t1, hrmdepartment t2, hrmdepartmentdefined t4 \n" +
                " where t1.departmentid = t2.id\n" +
                "   and t2.id = t4.deptid\n" +
                "   and t1.id = "+userId+") a left join hrmjobtitles t3 on a.jobId = t3.id";
        RecordSet rs = new RecordSet();
        rs.execute(sql);
        if(rs.next()){
            CcsqModelTools ccsqModelTools = new CcsqModelTools();
            this.workCode = Util.null2String(rs.getString("workCode"));
            this.depId = Util.null2String(rs.getString("depId"));
            this.ccsqDept = new CcsqDept(depId);
            this.depCode = Util.null2String(rs.getString("depCode"));
            this.jobGrade = Util.null2String(rs.getString("jobGrade"));
            this.jobId = Util.null2String(rs.getString("jobId"));
            this.jobCode = Util.null2String(rs.getString("jobCode"));
            this.securityLevel = Util.getIntValue(Util.null2String(rs.getString("securityLevel")));
            this.depLevel = Util.null2String(rs.getString("depLevel"));
            this.jobGradeLevel = ccsqModelTools.getZbJobGrade(userId);
        }
    }

    public CcsqUser() {
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getWorkCode() {
        return workCode;
    }

    public void setWorkCode(String workCode) {
        this.workCode = workCode;
    }

    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 getJobGrade() {
        return jobGrade;
    }

    public void setJobGrade(String jobGrade) {
        this.jobGrade = jobGrade;
    }

    public String getJobId() {
        return jobId;
    }

    public void setJobId(String jobId) {
        this.jobId = jobId;
    }

    public String getJobCode() {
        return jobCode;
    }

    public void setJobCode(String jobCode) {
        this.jobCode = jobCode;
    }

    public Integer getSecurityLevel() {
        return securityLevel;
    }

    public void setSecurityLevel(Integer securityLevel) {
        this.securityLevel = securityLevel;
    }

    public String getDepLevel() {
        return depLevel;
    }

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

    public String getJobGradeLevel() {
        return jobGradeLevel;
    }

    public void setJobGradeLevel(String jobGradeLevel) {
        this.jobGradeLevel = jobGradeLevel;
    }

    public CcsqDept getCcsqDept() {
        return ccsqDept;
    }

    public void setCcsqDept(CcsqDept ccsqDept) {
        this.ccsqDept = ccsqDept;
    }

}
