package com.engine.kq.cmd.shiftmanagement;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import java.util.HashMap;
import java.util.Map;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.moduledetach.ManageDetachComInfo;
import weaver.systeminfo.SystemEnv;
import weaver.systeminfo.systemright.CheckSubCompanyRight;

/**
 * 获取班次管理 分权操作级别
 * @author pzy
 *
 */
public class GetDetachOperatelevelCmd extends AbstractCommonCommand<Map<String, Object>>{

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

	@Override
	public BizLogContext getLogContext() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Map<String, Object> execute(CommandContext commandContext) {
		Map<String,Object> retmap = new HashMap<String,Object>();
		String subcompanyid = Util.null2String((String)params.get("subcompanyid"));
		try {
      CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight();
      ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();
      boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权
      int operatelevel = -1;
      if(hrmdetachable){
        operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"KQClass:Management",Util.getIntValue(subcompanyid,-1));
      }else{
        operatelevel = 2;
      }
      if(user.getUID() == 1){
        operatelevel = 2;
      }

      retmap.put("operatelevel", operatelevel);
			retmap.put("status", "1");
		} catch (Exception e) {
			writeLog(e);
      retmap.put("status", "-1");
      retmap.put("message",  SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
		}
		return retmap;
	}

}
