| | |
| | | @Override |
| | | public Long saveCruiseCheckInRecord(XpCruiseCheckInRecord dto) { |
| | | Long checkLocationId = dto.getCheckLocationId(); |
| | | List<XpCruiseCheckInRule> list = this.list(new LambdaQueryWrapper<XpCruiseCheckInRule>().eq(XpCruiseCheckInRule::getDeleted, 0) |
| | | .eq(XpCruiseCheckInRule::getOperationsUserId, dto.getOperationsUserId()).last(" and (now() BETWEEN start_time and end_time or cyclic_mode = 1)")); |
| | | if(list.isEmpty()){ |
| | | return null; |
| | | } |
| | | XpCruiseCheckInRule xpCruiseCheckInRule = list.get(0); |
| | | dto.setCruiseCheckInRuleId(xpCruiseCheckInRule.getId()); |
| | | XpCruiseCheckInRuleLocation one = xpCruiseCheckInRuleLocationService.getOne(new LambdaQueryWrapper<XpCruiseCheckInRuleLocation>() |
| | | .eq(XpCruiseCheckInRuleLocation::getCheckLocationId, checkLocationId)); |
| | | .eq(XpCruiseCheckInRuleLocation::getCheckLocationId, checkLocationId).eq(XpCruiseCheckInRuleLocation::getCruiseCheckInRuleId, dto.getCruiseCheckInRuleId())); |
| | | if(null == one){ |
| | | throw new ServiceException("打卡点位不存在", I18nKeyConstant.CHECK_IN_LOCATION_DOES_NOT_EXIST); |
| | | } |
| | |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(xpCheckLocation.getLocationLon() + "," + xpCheckLocation.getLocationLat(), dto.getLongitude() + "," + dto.getLatitude()); |
| | | if(xpCheckLocation.getLocationRange().compareTo(new BigDecimal(distance.get("WGS84"))) >= 0){ |
| | | vo.setIsInRange(true); |
| | | Boolean read = redisService.getCacheObject("CHECK_IN_SCOPE:" + xpCheckLocation.getId()); |
| | | if(null == read || !read){ |
| | | vo.setMessageType(2); |
| | | vo.setCheckLocationId(cruiseCheckInRuleLocation.getCheckLocationId()); |
| | | redisService.setCacheObject("CHECK_IN_SCOPE:" + xpCheckLocation.getId(), true, 1L, TimeUnit.HOURS); |
| | | } |
| | | vo.setMessageType(2); |
| | | vo.setCheckLocationId(cruiseCheckInRuleLocation.getCheckLocationId()); |
| | | // Boolean read = redisService.getCacheObject("CHECK_IN_SCOPE:" + xpCheckLocation.getId()); |
| | | // if(null == read || !read){ |
| | | // vo.setMessageType(2); |
| | | // vo.setCheckLocationId(cruiseCheckInRuleLocation.getCheckLocationId()); |
| | | // redisService.setCacheObject("CHECK_IN_SCOPE:" + xpCheckLocation.getId(), true, 1L, TimeUnit.HOURS); |
| | | // } |
| | | return vo; |
| | | } |
| | | //判断时间小于10分钟首次触发和小于3分钟再次触发 |