package com.kingdee.eas.custom.osf;

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

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.bsf.service.app.IHRMsfService;
import com.kingdee.eas.basedata.org.PositionCollection;
import com.kingdee.eas.basedata.org.PositionFactory;
import com.kingdee.eas.basedata.org.PositionInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.hr.base.EmployeeTypeCollection;
import com.kingdee.eas.hr.base.EmployeeTypeFactory;
import com.kingdee.eas.hr.base.EmployeeTypeInfo;
import com.kingdee.eas.hr.base.VariationReasonCollection;
import com.kingdee.eas.hr.base.VariationReasonFactory;
import com.kingdee.eas.hr.base.VariationReasonInfo;

/**
 * 
 * @author coyle
 *
 */
public class GetCusDataOsfService implements IHRMsfService {

	private static final Logger logger = LoggerFactory.getLogger(GetCusDataOsfService.class);
	// 职位
	private static final String POSITION = "position";
	// 变动原因
	private static final String REASON = "Reason";
	// 用工关系状态
	private static final String RELATIONSHIP = "relationship";


	public Object process(Context ctx, Map map) throws EASBizException, BOSException {
		logger.error("GetCusDataOsfService  enter ");
		

		String dataType = (String) map.get("dataType");
		// 
		String billno = (String) map.get("billno");
		 	
		//返回数据
		Map dataMap = new HashMap();
		if(StringUtils.equals(dataType, POSITION)) {
			PositionCollection positionCol  = PositionFactory.getLocalInstance(ctx).getPositionCollection("where number = '"+ billno+"'");
			PositionInfo info = positionCol.get(0);
			dataMap.put("id", info.getId().toString());
			dataMap.put("name", info.getName().toString());
		}else if(StringUtils.equals(dataType, REASON)) {
			VariationReasonCollection varCol  = VariationReasonFactory .getLocalInstance(ctx).getVariationReasonCollection("where number = '"+ billno+"'");
			VariationReasonInfo info = varCol.get(0);
			dataMap.put("id", info.getId().toString());
			dataMap.put("name", info.getName().toString());
		} else if (StringUtils.equals(dataType, RELATIONSHIP)) {
			EmployeeTypeCollection varCol = EmployeeTypeFactory.getLocalInstance(ctx)
					.getEmployeeTypeCollection("where number = '" + billno + "'");
			EmployeeTypeInfo info = varCol.get(0);
			dataMap.put("id", info.getId().toString());
			dataMap.put("name", info.getName().toString());
		}

		return dataMap;
	}

}
