FrontServices { public ResponseMessage userJoinv2(UserJoinRequest userJoinRequest) { log.info(userJoinRequest.toString()); ThisLocalizedWeek thisLocalizedWeek = new ThisLocalizedWeek(Locale.CHINA); List<UserRecord> userRecords = runningRecordMapper.selectDailyUserRecord(thisLocalizedWeek.getFirstDay(), thisLocalizedWeek.getLastDay()); UserJoinResponse userJoinResponse = new UserJoinResponse(); userRecords = userRecords.stream() .map(e -> { if (e.getDislikes() == null) { e.setDislikes(0); } if (e.getLikes() == null) { e.setLikes(0); } return e; }).collect(Collectors.toList()); List<UserRecord> collectUserRecord = userRecords.stream().filter(e -> e.getUserOpenId().equals(userJoinRequest.getOpenId())).collect(Collectors.toList()); if (collectUserRecord.size() > 0) { userJoinResponse.setUserRecord(collectUserRecord.get(0)); } else { UserRecord userRecord1 = runningRecordMapper.selectDailyUserRecordWithOpenId(thisLocalizedWeek.getFirstDay(), thisLocalizedWeek.getLastDay(), userJoinRequest.getOpenId()); if (userRecord1 != null) { if (userRecord1.getDislikes() == null) { userRecord1.setDislikes(0); } if (userRecord1.getLikes() == null) { userRecord1.setLikes(0); } userJoinResponse.setUserRecord(userRecord1); } else { UserInfo userInfo = userInfoMapper.selectByOpenId(userJoinRequest.getOpenId()); UserGroup userGroup = userGroupMapper.selectByGroupIdAndUserOpenId(1, userJoinRequest.getOpenId()); TargetDistance targetDistance = targetDistanceMapper.selectByUserGroupIdAndTimeRange(userGroup.getUserGroupId(), thisLocalizedWeek.getFirstDay(), thisLocalizedWeek.getLastDay()); UserRecord userRecord = new UserRecord(); userRecord.setCoins(userInfo.getCoins()); userRecord.setDislikes(0); userRecord.setLikes(0); userRecord.setCurrent((float) 0); userRecord.setDistanceValided((float) 0); userRecord.setTarget(targetDistance.getTargetDistance()); userRecord.setUserGroupId(userGroup.getUserGroupId()); userRecord.setIcon(userInfo.getIcon()); userRecord.setNickName(userInfo.getUserName()); userRecord.setUserOpenId(userInfo.getOpenId()); userJoinResponse.setUserRecord(userRecord); } } List<UserRecord> collectOtherUserRecord = userRecords.stream().filter(e -> !e.getUserOpenId().equals(userJoinRequest.getOpenId())).collect(Collectors.toList()); userJoinResponse.setOtherUsersRecord(collectOtherUserRecord); return ResultUtils.success(userJoinResponse); } @Autowired  FrontServices(UserInfoMapper userInfoMapper,
                         UserGroupMapper userGroupMapper,
                         TargetDistanceMapper targetDistanceMapper,
                         RunningRecordMapper runningRecordMapper,
                         VoteRecordMapper voteRecordMapper); ResponseMessage userJoin(UserJoinRequest userJoinRequest); ResponseMessage userJoinv3(UserJoinRequest userJoinRequest); ResponseMessage currentUserWeekly(CurrentUserWeeklyReportRequest currentUserWeeklyReportRequest); ResponseMessage everyOneWeekly(WeeklyReportRequest weeklyReportRequest); ResponseMessage everyOneWeekly2(WeeklyReportRequest weeklyReportRequest); ResponseMessage userJoinv2(UserJoinRequest userJoinRequest);  }
@Test public void userJoinv2() { UserJoinRequest userJoinRequest = new UserJoinRequest(); userJoinRequest.setGroupId(1); userJoinRequest.setOpenId("otvlM5VATjthdCeLQVfEDAzzBsro"); long v1begin = System.currentTimeMillis(); ResponseMessage responseMessage = frontServices.userJoin(userJoinRequest); long v1end = System.currentTimeMillis(); System.err.println("old: "+ (v1end-v1begin)); System.err.println(JSON.toJSON(responseMessage)); long v2begin = System.currentTimeMillis(); ResponseMessage responseMessage2 = frontServices.userJoinv2(userJoinRequest); long v2end = System.currentTimeMillis(); System.err.println(v2end-v2begin); System.err.println(JSON.toJSON(responseMessage2)); long v3begin = System.currentTimeMillis(); ResponseMessage responseMessage3 = frontServices.userJoinv3(userJoinRequest); long v3end = System.currentTimeMillis(); System.err.println(v3end-v3begin); System.err.println(JSON.toJSON(responseMessage3)); }