package com.engine.kq.cmd.reportdetial;

import com.cloudstore.dev.api.util.Util_TableMap;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQAttFlowSetBiz;
import com.engine.kq.enums.FlowReportTypeEnum;
import com.engine.kq.enums.KqSplitFlowTypeEnum;
import com.engine.kq.enums.ReportColumnEnum;
import com.engine.kq.util.PageUidFactory;
import weaver.conn.RecordSet;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/***
 * 请假信息
 */
public class GetLeaveInfoCmd extends AbstractCommonCommand<Map<String, Object>> {

	public GetLeaveInfoCmd(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{

			String dialogTitle = "";
			String type = Util.null2String(params.get("type"));
			if(type.equals("leave")||type.startsWith("leaveType_")){//请假
				dialogTitle = SystemEnv.getHtmlLabelName(20092, user.getLanguage());
				if(type.startsWith("leaveType_")) {
					String[] typeInfo = Util.splitString(type, "_");
					if (typeInfo[0].equals("leaveType")) {
						params.put("kqtype", KqSplitFlowTypeEnum.LEAVE.getFlowtype());
					}
					params.put("newleavetype", typeInfo[1]);
				}else{
					params.put("kqtype", KqSplitFlowTypeEnum.LEAVE.getFlowtype());
				}
			}else{
				if(type.equals("overtimeTotal")){//加班
					dialogTitle = SystemEnv.getHtmlLabelName(33501, user.getLanguage());
					params.put("kqtype",KqSplitFlowTypeEnum.OVERTIME.getFlowtype());
				}else if(type.equals("businessLeave")){//出差
					dialogTitle = SystemEnv.getHtmlLabelName(20093, user.getLanguage());
					params.put("kqtype",KqSplitFlowTypeEnum.EVECTION.getFlowtype());
				}else if(type.equals("officialBusiness")){//公出
					dialogTitle = SystemEnv.getHtmlLabelName(20094, user.getLanguage());
					params.put("kqtype",KqSplitFlowTypeEnum.OUT.getFlowtype());
				}else if(type.equals("leaveDeduction")){//异常冲抵
					dialogTitle = SystemEnv.getHtmlLabelName(391404, user.getLanguage());
					params.put("kqtype",KqSplitFlowTypeEnum.OTHER.getFlowtype());
				}
			}

			retmap.put("dialogTitle",dialogTitle);
			retmap.put("sessionkey",new KQAttFlowSetBiz().buildFlowSetTableString(params, user));
			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;
	}

}
