package com.kingdee.shr.customer.gtiit.util;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.eas.util.app.DbUtil;
import com.kingdee.jdbc.rowset.IRowSet;

public class BaseUtil {

	public static Map<String, String> getPersonIdByName(Context ctx, Set<String> personIdSet){
		Map<String, String> personMap = new HashMap<String, String>();
		StringBuffer strBuffer = new StringBuffer();
		if(personIdSet != null && personIdSet.size()>0) {
			for(String personId:personIdSet) {
				strBuffer.append("'"+personId+"',");
			}
			String personSql = "select fid,fname_l1 from t_bd_person where fid in ("+strBuffer.deleteCharAt(strBuffer.length()-1)+")";
			try {
				IRowSet rowSet = DbUtil.executeQuery(ctx, personSql);
				while(rowSet.next()) {
					personMap.put(rowSet.getString("fid"), rowSet.getString("fname_l1"));
				}
				return personMap;
			} catch (BOSException e) {
				e.printStackTrace();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return personMap;
	}
	
	public static Map<String, Map<String, String>> getOverTimeType(Context ctx){
		Map<String, Map<String, String>> map = new HashMap<String, Map<String,String>>();
		String sql = "select fid,fname_l1,fnumber from T_HR_ATS_OverTimeType";
		try {
			IRowSet rowSet = DbUtil.executeQuery(ctx, sql);
			while(rowSet.next()) {
				Map<String, String> overTypeMap = new HashMap<String, String>();
				overTypeMap.put("otTypeValue", rowSet.getString("fid"));
				overTypeMap.put("otTypeText", rowSet.getString("fname_l1"));
				map.put(rowSet.getString("fnumber"), overTypeMap);
			}
		} catch (BOSException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return map;
	}

}
