package com.steering.comm.data;

import java.util.List;
import java.util.Map;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;

import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.StringTool;

/**
 * 通用基础信息维护类
 * @author siy 2014/11/11
 * @version v1.0
 */
public class ComBaseInfo extends DBCommon {
    /**
     * COM_BASE_INFO通用基础信息查询
     * @param sortCode 快速检索码
     * @return CoreReturnObject 通用基础信息集合
     */
    public CoreReturnObject getBaseInfo(String sortCode) {
        return this.getDataBySqlID("ClsBaseInfo.COMMQUERY",
                new Object[] { sortCode });
    }

    /**
     * COM_BASE_INFO通用基础信息查询
     * @param sortCode 快速检索码
     * @return List<Map<Object,Object>> 通用基础信息Map集合
     */
    public List<Map<Object, Object>> getBaseInfoList(String sortCode) {
        @SuppressWarnings("unchecked")
        List<Map<Object, Object>> result = (List<Map<Object, Object>>) this
                .getBaseInfo(sortCode).getResult();
        return result;
    }

    /**
     * 获取所有部门信息
     * @return CoreReturnObject 部门信息集合
     */
    public CoreReturnObject getDepartment() {
        return this.getDataBySqlID("ClsBaseInfo.GetDepartment");
    }

    /**
     * 获取所有部门信息
     * @return List<Map<Object,Object>> 部门信息Map集合
     */
    public List<Map<Object, Object>> getDepartmentList() {
        @SuppressWarnings("unchecked")
        List<Map<Object, Object>> result = (List<Map<Object, Object>>) this
                .getDepartment().getResult();
        return result;
    }

    /**
     * 获取所有科室信息
     * @return CoreReturnObject 科室信息集合
     */
    public CoreReturnObject getSection() {
        return this.getDataBySqlID("ClsBaseInfo.GetSection");
    }

    /**
     * 获取所有科室信息
     * @return List<Map<Object,Object>> 科室信息Map集合
     */
    public List<Map<Object, Object>> getSectionList() {
        @SuppressWarnings("unchecked")
        List<Map<Object, Object>> result = (List<Map<Object, Object>>) this
                .getSection().getResult();
        return result;
    }

    /**
     * 根据部门编号获取科室信息
     * @param departmentId 部门编号
     * @return CoreReturnObject 科室信息集合
     */
    public CoreReturnObject getSection(String departmentId) {
        return this.getDataBySqlID("ClsBaseInfo.GetSectionByDepartment",
                new Object[] { departmentId });
    }

    /**
     * 根据部门编号获取科室信息
     * @param departmentId 部门编号
     * @return List<Map<Object,Object>> 科室信息Map集合
     */
    public List<Map<Object, Object>> getSectionList(String departmentId) {
        @SuppressWarnings("unchecked")
        List<Map<Object, Object>> result = (List<Map<Object, Object>>) this
                .getSection(departmentId).getResult();
        return result;
    }
    
    /**
     * 根据科室ID查询对应的部门信息
     * @param section 科室
     * @return obj
     */
    public CoreReturnObject getDeptBySection(String section){
        Object[] params = new Object[]{section};
        return this.getDataBySqlID("ClsBaseInfo.getDepartmentBySectionID", params);
    }
    
    /**
     * 根据部门表的ID获取对应的描述
     * @param id
     * @return
     */
    public CoreReturnObject getDepartDescByDepartId(String id){
    	String sql = CoreXmlSqlParsersFactory.getSql("ClsBaseInfo.getDepartDescByDepartId");
    	sql = StringTool.ReplaceAll(sql, "#DEPARTID#", id);
    	
    	return this.getData(sql);
    }
}
