package com.engine.kq.cmd.attendanceEvent;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQExitRulesBiz;
import com.engine.kq.biz.KQGroupMemberComInfo;
import com.engine.kq.enums.DurationTypeEnum;
import com.engine.kq.enums.KqSplitFlowTypeEnum;
import com.engine.kq.util.KQDurationCalculatorUtil;
import java.util.HashMap;
import java.util.Map;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;

/**
 * 考勤流程变更用的时长计算
 */
public class GetProcessChangeWorkDurationCmd extends AbstractCommonCommand<Map<String, Object>> {

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

	@Override
	public Map<String, Object> execute(CommandContext commandContext) {
		Map<String, Object> retmap = new HashMap<String, Object>();
		RecordSet rs = new RecordSet();
		String sql = "";
		try{
      GetProcessChangeTypeCmd processChangeTypeCmd = new GetProcessChangeTypeCmd(params, user);
      params.put("isAll", "1");
      Map<String, Object> retmaps = processChangeTypeCmd.execute(commandContext);
      if(!retmaps.isEmpty()){
        if(retmaps.containsKey("process_type") && retmaps.containsKey("process_tablename")){
          int process_type = Util.getIntValue(Util.null2String(retmaps.get("process_type")));
          if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == process_type){
            GetEvectionWorkDurationCmd getEvectionWorkDurationCmd = new GetEvectionWorkDurationCmd(params, user);
            return getEvectionWorkDurationCmd.execute(commandContext);
          }else if(KqSplitFlowTypeEnum.OUT.getFlowtype() == process_type){
            GetOutWorkDurationCmd getOutWorkDurationCmd = new GetOutWorkDurationCmd(params, user);
            return getOutWorkDurationCmd.execute(commandContext);
          }
        }
      }
      retmap.put("status", "1");
		}catch (Exception e) {
			retmap.put("status", "-1");
			retmap.put("message",  SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
			writeLog(e);
		}
		return retmap;
	}

	@Override
	public BizLogContext getLogContext() {
		return null;
	}

}
