package com.engine.kq.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.kq.service.KQUpgradeService;
import com.engine.kq.service.impl.KQUpgradeServiceImpl;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import weaver.general.BaseBean;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;


/**
 * 新考勤历史数据升级
 */
public class KQUpgradeAction {
	private BaseBean logger = new BaseBean();

	private KQUpgradeService getService(User user) {
		return (KQUpgradeServiceImpl) ServiceUtil.getService(KQUpgradeServiceImpl.class, user);
	}

	/**
	 * 是否有权限
	 * @param request
	 * @param response
	 * @return
	 */
	@POST
	@Path("/getHasRight")
	@Produces(MediaType.TEXT_PLAIN)
	public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) {
		Map<String, Object> apidatas = new HashMap<String, Object>();
		try {
			User user = HrmUserVarify.getUser (request , response) ;
			if(user.getUID() == 1){
        apidatas.put("hasRight", true);
      }else{
        apidatas.put("hasRight", false);
      }
			apidatas.put("status", "1");
		} catch (Exception e) {
			apidatas.put("status", "-1");
			logger.writeLog(e);
		}
		return JSONObject.toJSONString(apidatas);
	}

  /**
   * 获取右键菜单
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getRightMenu")
  @Produces(MediaType.TEXT_PLAIN)
  public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser (request , response) ;
//      apidatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }
	
	/**
	 * 获取左侧Tab信息
	 * @param request
	 * @param response
	 * @return
	 */
	@POST
	@Path("/getTreeTabs")
	@Produces(MediaType.TEXT_PLAIN)
	public String getTreeTabs(@Context HttpServletRequest request, @Context HttpServletResponse response) {
		Map<String, Object> apidatas = new HashMap<String, Object>();
		try {
			User user = HrmUserVarify.getUser(request, response);
			apidatas = getService(user).getTreeTabs(ParamUtil.request2Map(request), user);
		} catch (Exception e) {
			apidatas.put("status", "-1");
			logger.writeLog(e);
		}
		return JSONObject.toJSONString(apidatas);
	}

  /**
   * 一般工作时间升级 准备
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade1")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade1(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade1(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 排班设置，排班人员数据升级 准备
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade2")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade2(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade2(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 请假类型升级 准备
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade3")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade3(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade3(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 工作日期调整升级 准备
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade4")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade4(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade4(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 年假数据升级 准备
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade5")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade5(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade5(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 带薪假数据升级 准备
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade6")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade6(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade6(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 调休数据升级 准备
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade7")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade7(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade7(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 考勤流程设置升级 准备
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade8")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade8(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade8(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 外部集成考勤设置升级 准备
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade9")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade9(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade9(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 历史考勤流程数据升级 准备
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade10")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade10(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade10(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 考勤报表数据升级 准备
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade12")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade12(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade12(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 一般工作时间升级
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/doUpgrade1")
  @Produces(MediaType.TEXT_PLAIN)
  public String doUpgrade1(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).doUpgrade1(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 排班设置，排班人员数据升级
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/doUpgrade2")
  @Produces(MediaType.TEXT_PLAIN)
  public String doUpgrade2(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).doUpgrade2(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 请假类型升级
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/doUpgrade3")
  @Produces(MediaType.TEXT_PLAIN)
  public String doUpgrade3(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).doUpgrade3(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 工作日期调整升级
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/doUpgrade4")
  @Produces(MediaType.TEXT_PLAIN)
  public String doUpgrade4(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).doUpgrade4(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 年假数据升级
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/doUpgrade5")
  @Produces(MediaType.TEXT_PLAIN)
  public String doUpgrade5(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).doUpgrade5(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 带薪假数据升级
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/doUpgrade6")
  @Produces(MediaType.TEXT_PLAIN)
  public String doUpgrade6(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).doUpgrade6(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 调休数据升级
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/doUpgrade7")
  @Produces(MediaType.TEXT_PLAIN)
  public String doUpgrade7(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).doUpgrade7(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 考勤流程设置升级
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/doUpgrade8")
  @Produces(MediaType.TEXT_PLAIN)
  public String doUpgrade8(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).doUpgrade8(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 外部集成考勤设置升级
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/doUpgrade9")
  @Produces(MediaType.TEXT_PLAIN)
  public String doUpgrade9(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).doUpgrade9(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 历史考勤流程数据升级
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/doUpgrade10")
  @Produces(MediaType.TEXT_PLAIN)
  public String doUpgrade10(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).doUpgrade10(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 考勤报表数据升级
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/doUpgrade12")
  @Produces(MediaType.TEXT_PLAIN)
  public String doUpgrade12(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).doUpgrade12(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }

  /**
   * 获取考考勤报表剩余数据
   * @param request
   * @param response
   * @return
   */
  @POST
  @Path("/getUpgrade12Data")
  @Produces(MediaType.TEXT_PLAIN)
  public String getUpgrade12Data(@Context HttpServletRequest request, @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      User user = HrmUserVarify.getUser(request, response);
      apidatas = getService(user).getUpgrade12Data(ParamUtil.request2Map(request), user);
    } catch (Exception e) {
      apidatas.put("status", "-1");
      logger.writeLog(e);
    }
    return JSONObject.toJSONString(apidatas);
  }
}
