Example #1
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;
  }