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

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

import com.alibaba.fastjson.JSONObject;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.bsf.service.app.IHRMsfService;
import com.kingdee.eas.basedata.org.FullOrgUnitCollection;
import com.kingdee.eas.basedata.org.FullOrgUnitFactory;
import com.kingdee.eas.basedata.org.PositionFactory;
import com.kingdee.eas.common.EASBizException;

public class GetAdminOrPositionNum  implements IHRMsfService{

	/**
	 * 获取岗位和部门简称，根据组织和职位ID
	 */
	@Override
	public Object process(Context ctx, Map arg1) throws EASBizException,
			BOSException {
		Map map = new HashMap();
		// TODO Auto-generated method stub
		if("admin".equals(arg1.get("type"))){
			String superior = arg1.get("superior").toString();//shangjizuzhiID
			String easdept_id = arg1.get("easdept_id").toString();//zuzhiID
			FullOrgUnitCollection parFullOrgUnitCollection = FullOrgUnitFactory.getLocalInstance(ctx).getFullOrgUnitCollection("where id = '"+superior+"'");
			FullOrgUnitCollection fullOrgUnitCollection = FullOrgUnitFactory.getLocalInstance(ctx).getFullOrgUnitCollection("where id = '"+easdept_id+"'");
			map.put("parNum", "");
			if(!parFullOrgUnitCollection.isEmpty()){
				map.put("parNum", parFullOrgUnitCollection.get(0).getNumber());
			}
			map.put("simName", fullOrgUnitCollection.get(0).getSimpleName());
			return JSONObject.toJSON(map);
		}
		

		String simpleName = PositionFactory.getLocalInstance(ctx).getPositionCollection("where id = '"+arg1.get("easdept_id")+"'").get(0).getSimpleName();
		
		return JSONObject.toJSON(map.put("simName", simpleName));
	}

}