package com.engine.kq.cmd.upgrade;

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.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

/**
 * 一般工作时间升级 准备
 * @author pzy
 *
 */
public class GetUpgrade1Cmd extends AbstractCommonCommand<Map<String, Object>>{

	public GetUpgrade1Cmd(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 type = Util.null2String((String)params.get("type"));
    RecordSet rs = new RecordSet();
    String scheduleCnt  = "0";
    KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade1;
    try {
      if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){
        String scheduleSql = "select count(1) from hrmschedule  ";
        rs.executeQuery(scheduleSql);
        if(rs.next()){
          scheduleCnt = ""+rs.getInt(1);
        }
      }
    } catch (Exception e) {
      writeLog(e);
    }
    retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), scheduleCnt) );
    retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage()));
    retmap.put("status", "1");
    return retmap;
	}

}
