package com.engine.kq.cmd.attendanceButton;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.log.KQLog;
import java.util.HashMap;
import java.util.Map;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

/**
 * 切换地图
 */
public class ResetUserMapCmd extends AbstractCommonCommand<Map<String, Object>> {
  private KQLog kqLog = new KQLog();

	public ResetUserMapCmd(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 user_last_map = Util.null2String(params.get("user_last_map"));
      String userid = user.getUID()+"";
      kqLog.info("ResetUserMapCmd user:"+user.getLastname()+":user_last_map:"+user_last_map);
      sql = "delete from user_last_map where userid =? ";
      rs.executeUpdate(sql,userid);

      sql = "insert into user_last_map (userid,last_map) values(?,?)";
      rs.executeUpdate(sql, userid,user_last_map);
      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;
	}

}
