package com.engine.htsc.ReimbursementFlow.model;

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

import java.util.HashMap;
import java.util.Map;

public class NewUser {
    private String userId;  //报销人泛微人员唯一标识
    private String workCode;    //工号或主、子账号（业务code）
    private String userName;    //用户名称
    private String depName; //部门名称
    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 roleCode;    //报销人人员角色PT_LV1~5
    private NewDepart newDepart;    //部门信息

    private  String deptLevelcode;
    public  NewUser() {
    }

    public  NewUser(String userId) {
        String sql = "select t1.workcode as workCode,t1.lastname as userName,t2.departmentname as depName,t2.id as depId,t2.departmentcode as depCode,t1.joblevel as jobGrade," +
                "t1.jobtitle as jobId,t3.jobtitlecode as jobCode,t1.seclevel as securityLevel,t4.deptdepth as depLevel\n" +
                "from hrmresource t1,hrmdepartment t2,hrmjobtitles t3 ,hrmdepartmentdefined t4\n" +
                "where t1.departmentid = t2.id\n" +
                "and t1.jobtitle = t3.id\n" +
                "and t2.id = t4.deptid\n" +
                "and t1.id = " +userId+ "";
        RecordSet rs = new RecordSet();
        rs.execute(sql);
        if(rs.next()){
            this.userId = userId;
            this.workCode = Util.null2String(rs.getString("workCode"));
            this.depId = Util.null2String(rs.getString("depId"));
            this.newDepart = new NewDepart(depId);
            this.depCode = Util.null2String(rs.getString("depCode"));
            this.userName = Util.null2String(rs.getString("userName"));
            this.depName = Util.null2String(rs.getString("depName"));
            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.roleCode = ZbspgzbTool.getRoleCode(userId);
            this.deptLevelcode=ZbspgzbTool.getZbspgzbTool(userId);
            //测试使用
           // this.deptLevelcode="ST_0";
        }
    }

    public  NewUser(String userId,String szbm) {
        String sql = "select t1.workcode as workCode,t1.lastname as userName,t2.departmentname as depName,t2.id as depId,t2.departmentcode as depCode,t1.joblevel as jobGrade," +
                "t1.jobtitle as jobId,t3.jobtitlecode as jobCode,t1.seclevel as securityLevel,t4.deptdepth as depLevel\n" +
                "from hrmresource t1,hrmdepartment t2,hrmjobtitles t3 ,hrmdepartmentdefined t4\n" +
                "where t2.id = "+szbm+"\n" +
                "and t1.jobtitle = t3.id\n" +
                "and t2.id = t4.deptid\n" +
                "and t1.id = " +userId+ "";
        RecordSet rs = new RecordSet();
        rs.execute(sql);
        if(rs.next()){
            this.userId = userId;
            this.depId = szbm;
            this.workCode = Util.null2String(rs.getString("workCode"));
            this.newDepart = new NewDepart(szbm);
            this.depCode = Util.null2String(rs.getString("depCode"));
            this.userName = Util.null2String(rs.getString("userName"));
            this.depName = Util.null2String(rs.getString("depName"));
            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.roleCode = ZbspgzbTool.getRoleCode(userId);
            this.deptLevelcode=ZbspgzbTool.getZbspgzbToolDept(userId,szbm);
            //测试使用
            // this.deptLevelcode="ST_0";
        }
    }

    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 String getDeptLevelcode() {
        return deptLevelcode;
    }

    public void setDeptLevelcode(String deptLevelcode) {
        this.deptLevelcode = deptLevelcode;
    }

    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 getRoleCode() {
        return roleCode;
    }

    public void setRoleCode(String roleCode) {
        this.roleCode = roleCode;
    }

    public NewDepart getNewDepart() {
        return newDepart;
    }

    public void setNewDepart(NewDepart newDepart) {
        this.newDepart = newDepart;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getDepName() {
        return depName;
    }

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