예제 #1
0
 /**
  * 签到处理
  *
  * @return
  * @throws UnsupportedEncodingException
  */
 @RequestMapping(
     value = "doSign",
     method = {RequestMethod.GET, RequestMethod.POST})
 public @ResponseBody Object doSign() {
   ResponseResult responseResult = new ResponseResult();
   try {
     // 获取请假申请信息
     JSONObject jsonSignInfoObj =
         JSON.parseObject(
             URLDecoder.decode(HttpRequestUtil.getInstance().getString("signInfo"), "UTF-8"));
     Map<String, Object> resultData = new HashMap<String, Object>();
     responseResult.setValue(resultData);
     if (null != jsonSignInfoObj) {
       String sSignTime = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm");
       Date signTime = DateUtil.stringToDate(sSignTime + ":00");
       String id = CommonUtil.GeneGUID();
       jsonSignInfoObj.put("signTime", signTime);
       jsonSignInfoObj.put("id", id);
       resultData.put("id", id);
       resultData.put("signTime", DateUtil.dateToString(signTime, "HH:mm"));
     }
     signService.doSign(jsonSignInfoObj);
   } catch (Exception e) {
     e.printStackTrace();
     responseResult.setStatus(-1);
   }
   return responseResult;
 }
예제 #2
0
 /**
  * 我发起的签到记录
  *
  * @return
  */
 @RequestMapping(
     value = "getMyLaunchSignRecord",
     method = {RequestMethod.GET, RequestMethod.POST})
 public @ResponseBody DataResult getMyLaunchSignRecord() {
   String spageIndex = HttpRequestUtil.getInstance().getString("pageIndex");
   String spageSize = HttpRequestUtil.getInstance().getString("pageSize");
   String type = HttpRequestUtil.getInstance().getString("type");
   int pageIndex = -1;
   int pageSize = -1;
   if (StringUtils.isNotEmpty(spageIndex)) {
     pageIndex = Integer.valueOf(spageIndex);
   }
   if (StringUtils.isNotEmpty(spageSize)) {
     pageSize = Integer.valueOf(spageSize);
   }
   Sign sign = new Sign();
   Map<String, Object> params = new HashMap<String, Object>();
   // params.put("userId",
   // SystemCacheUtil.getInstance().getCurrentUser().getUserid());
   sign.setUserId(SystemCacheUtil.getInstance().getCurrentUser().getUserid());
   if ("0".equals(type)) {
     params.put("isNoEnd", true);
   } else if ("1".equals(type)) {
     params.put("isEnd", true);
   }
   return signService.querySignRecord(sign, params, pageIndex, pageSize);
 }
예제 #3
0
 /**
  * 获取签到数据
  *
  * @param model
  * @return
  */
 @RequestMapping(
     value = "getWaitSignRecord",
     method = {RequestMethod.GET, RequestMethod.POST})
 public @ResponseBody Object getWaitSignRecord(HttpServletRequest request) {
   Sign sign = new Sign();
   Map<String, Object> params = new HashMap<String, Object>();
   params.put("userId", SystemCacheUtil.getInstance().getCurrentUser().getUserid());
   params.put("isKq", true);
   return signService.querySignRecord(sign, params, -1, -1).getData();
 }
예제 #4
0
 /**
  * 签到处,显示今天所有的签到信息
  *
  * @param model
  * @return
  */
 @RequestMapping(
     value = "signView",
     method = {RequestMethod.GET, RequestMethod.POST})
 public ModelAndView signView(HttpServletRequest request) {
   ModelAndView modelAndView = super.createModelAndView("sign");
   Sign sign = new Sign();
   sign.setSignType(SignType.KQ.value());
   Map<String, Object> params = new HashMap<String, Object>();
   params.put("userId", SystemCacheUtil.getInstance().getCurrentUser().getUserid());
   List<Map<String, Object>> signListMap =
       (List<Map<String, Object>>) signService.querySignRecord(sign, params, -1, -1).getData();
   modelAndView.addObject("signListMap", signListMap);
   return modelAndView;
 }
예제 #5
0
 /**
  * 签到处理
  *
  * @return
  * @throws UnsupportedEncodingException
  */
 @RequestMapping(
     value = "doRemark",
     method = {RequestMethod.GET, RequestMethod.POST})
 public @ResponseBody Object doRemark() {
   ResponseResult responseResult = new ResponseResult();
   // 获取请假申请信息
   try {
     JSONObject jsonRemarkObj =
         JSON.parseObject(
             URLDecoder.decode(HttpRequestUtil.getInstance().getString("remarkInfo"), "UTF-8"));
     signService.doRemark(jsonRemarkObj);
   } catch (Exception e) {
     e.printStackTrace();
     responseResult.setStatus(-1);
   }
   return responseResult;
 }
예제 #6
0
 /**
  * 发起签到
  *
  * @param model
  * @return
  */
 @RequestMapping(
     value = "launchSign",
     method = {RequestMethod.GET, RequestMethod.POST})
 public @ResponseBody Object launchSign(HttpServletRequest request) {
   ResponseResult responseResult = new ResponseResult();
   try {
     // 获取签到发布信息
     JSONObject jsonLaunchSignInfo =
         JSON.parseObject(
             URLDecoder.decode(
                 HttpRequestUtil.getInstance().getString("launchSignInfo"), "UTF-8"));
     String id = CommonUtil.GeneGUID();
     jsonLaunchSignInfo.put("id", id);
     responseResult.setValue(id);
     signService.launchSign(jsonLaunchSignInfo);
   } catch (Exception e) {
     e.printStackTrace();
     responseResult.setStatus(-1);
   }
   return responseResult;
 }
예제 #7
0
  /**
   * 我发起的签到信息
   *
   * @return
   */
  @RequestMapping(value = "myLaunchSignDetailView", method = RequestMethod.GET)
  public ModelAndView myLaunchSignDetailView() {
    ModelAndView modelAndView = super.createModelAndView("myLaunch_signDetail");
    String id = HttpRequestUtil.getInstance().getString("id");
    // 需要获取签到信息
    Map<String, Object> dataMap = signService.getSignById(id);
    modelAndView.addObject("signInfo", dataMap);
    EntityAccount entityAccount = new EntityAccount();
    entityAccount.setEntityId(id);
    entityAccount.setEntityType(EntityType.QD.value());
    // 获取应签到用户
    List<EntityAccount> entityAccountList = entityAccountService.getEntityAccount(entityAccount);
    // 获取所有应签到用户
    SignUser signUser = new SignUser();
    signUser.setSignId(id);
    List<Map<String, Object>> signUserList = signUserService.getSignUser(signUser);
    // 查询已经签到用户
    List<String> userList = new ArrayList<String>();
    String userId = null;
    for (Map<String, Object> map : signUserList) {
      userId = StringUtil.getString(map.get("userId"));
      if (!userList.contains(userId)) {
        userList.add(userId);
      }
    }
    // 应该签到者
    StringBuffer shouldSignUserInfo = new StringBuffer();
    // 已签到者
    StringBuffer signUserInfo = new StringBuffer();
    // 未签到者
    StringBuffer noSignUserInfo = new StringBuffer();

    // 遍历应签到人
    for (int i = 0, size = (entityAccountList == null) ? 0 : entityAccountList.size();
        i < size;
        i++) {
      entityAccount = entityAccountList.get(i);
      userId = entityAccount.getAccountId();
      if (userList.contains(userId)) {
        signUserInfo.append(',').append(entityAccount.getAccountName());
      } else {
        noSignUserInfo.append(',').append(entityAccount.getAccountName());
      }
      shouldSignUserInfo.append(',').append(entityAccount.getAccountName());
    }

    if (signUserInfo.length() > 0) {
      signUserInfo.deleteCharAt(0);
    }
    if (noSignUserInfo.length() > 0) {
      noSignUserInfo.deleteCharAt(0);
    }
    if (shouldSignUserInfo.length() > 0) {
      shouldSignUserInfo.deleteCharAt(0);
    }
    if (StringUtils.isEmpty(signUserInfo.toString())) {
      signUserInfo.append("无");
    }
    if (StringUtils.isEmpty(noSignUserInfo.toString())) {
      noSignUserInfo.append("无");
    }
    if (StringUtils.isEmpty(shouldSignUserInfo.toString())) {
      shouldSignUserInfo.append("无");
    }
    modelAndView.addObject("signUserInfo", signUserInfo.toString());
    modelAndView.addObject("noSignUserInfo", noSignUserInfo.toString());
    modelAndView.addObject("shouldSignUserInfo", shouldSignUserInfo.toString());
    // 当前时间信息
    Date curentDate = new Date();
    modelAndView.addObject(
        "date", DateUtil.dateToString(curentDate, "MM月dd日") + DateUtil.getDayOfWeek(curentDate));
    modelAndView.addObject("time", DateUtil.dateToString(curentDate, "HH:mm"));

    // TODO 取出当月统计数据
    return modelAndView;
  }
예제 #8
0
  /**
   * 签到详情
   *
   * @return
   */
  @RequestMapping(value = "signDetailView", method = RequestMethod.GET)
  public ModelAndView signDetailView(HttpServletRequest request) {
    ModelAndView modelAndView = super.createModelAndViewWithSign("sign_detail", request);
    Map<String, Object> requestParams = getRequestParams(request);
    String id = StringUtil.getString(requestParams.get("id"));
    if (StringUtils.isEmpty(id)) {
      throw new BusinessEnergyException(
          SpringContextUtil.getI18n("1002002", new String[] {"id"}, null));
    }
    // 需要获取签到信息
    Sign sign = new Sign();
    sign.setId(id);
    List<Map<String, Object>> signListMap = signService.getSign(sign);
    if (!CollectionUtils.isEmpty(signListMap)) {
      modelAndView.addObject("signInfo", signListMap.get(0));
    } else {
      if (CollectionUtils.isEmpty(signListMap)) {
        throw new EnergyException(
            SpringContextUtil.getI18n("1002003", new String[] {"id", id}, null));
      }
    }
    // 判断如果已经过期需要提醒
    Date currentDate = new Date();
    String signType = (String) signListMap.get(0).get("signType");
    Date beginTime = (Date) signListMap.get(0).get("beginTime");

    SignUser signUser = new SignUser();
    signUser.setSignId(id);
    signUser.setUserId(SystemCacheUtil.getInstance().getCurrentUser().getUserid());
    List<Map<String, Object>> signUserList = signUserService.getSignUser(signUser);
    if (!CollectionUtils.isEmpty(signUserList)) {
      Map<String, Object> temp = null;
      for (int i = 0, size = signUserList.size(); i < size; i++) {
        temp = signUserList.get(i);
        // 签到信息
        if ("0".equals(temp.get("attendType"))) {
          modelAndView.addObject("sign_in", temp);
          List<Accessory> accessoryList =
              accessoryService.getAccessoryByEntityId(StringUtil.getString(temp.get("id")));
          if (!CollectionUtils.isEmpty(accessoryList)) {
            modelAndView.addObject("signInAccessoryInfor", accessoryList);
          }
        } else
        /** 签退信息 */
        {
          modelAndView.addObject("sign_out", temp);
          List<Accessory> accessoryList =
              accessoryService.getAccessoryByEntityId(StringUtil.getString(temp.get("id")));
          if (!CollectionUtils.isEmpty(accessoryList)) {
            modelAndView.addObject("signOutAccessoryInfor", accessoryList);
          }
        }
      }
    }
    if ("0".equals(signType) && signUserList.size() < 2) {
      // 判断如果不是当天的考勤不能正常进行
      if (!DateUtil.dateToString(currentDate, "yyyy-MM-dd")
          .equals(DateUtil.dateToString(beginTime, "yyyy-MM-dd"))) {
        throw new BusinessEnergyException(SpringContextUtil.getI18n("1002007"));
      }
    }
    Date curentDate = new Date();
    modelAndView.addObject(
        "date", DateUtil.dateToString(curentDate, "MM月dd日") + DateUtil.getDayOfWeek(curentDate));
    modelAndView.addObject("time", DateUtil.dateToString(curentDate, "HH:mm"));

    return modelAndView;
  }