package com.engine.htsc.clsysq.dao;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import org.apache.commons.collections.map.HashedMap;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;

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

public class GetBmlxCMD extends AbstractCommonCommand<Map<String, Object>> {
    @Override
    public BizLogContext getLogContext() {
        return null;
    }

    public GetBmlxCMD(Map<String, Object> params, User user) {
        this.params = params;
        this.user = user;
    }


    @Override
    public Map<String, Object> execute(CommandContext commandContext) {
        String bmlx = "";
        Map<String, Object> mapResult = new HashMap<>();
        String id = Util.null2String(params.get("id"));
        RecordSet rs = new RecordSet();
        String getSql = "select DEPTTYPECODE from hrmdepartmentdefined where DEPTID = (SELECT DEPARTMENTID FROM hrmresource WHERE ID = '" + id + "')";
        rs.execute(getSql);
        if (rs.next()) {
            bmlx = rs.getString("DEPTTYPECODE");
        }
        new BaseBean().writeLog("从数据库中获取的部门类型是："+bmlx);
        mapResult.put("bmid", bmlx);
        return mapResult;
    }
}
