| | |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.UpdateDetailTeamDto; |
| | | import com.ruoyi.system.dto.UserIdDto; |
| | | import com.ruoyi.system.model.TAppUser; |
| | | import com.ruoyi.system.model.TAppUserEquipment; |
| | | import com.ruoyi.system.model.TAppUserLocation; |
| | | import com.ruoyi.system.service.TAppUserEquipmentService; |
| | | import com.ruoyi.system.service.TAppUserLocationService; |
| | | import com.ruoyi.system.service.TAppUserService; |
| | | import com.ruoyi.system.utils.GDMapGeocodingUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 用户打点 |
| | | */ |
| | | @ApiOperation(value = "获取用户打点数据",response = TAppUserLocation.class) |
| | | @GetMapping(value = "/open/t-app-user/getAppUserLocation") |
| | | public R<List<TAppUserLocation>> getAppUserLocation() { |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | List<TAppUserLocation> list = appUserLocationService.list(new LambdaQueryWrapper<TAppUserLocation>().eq(TAppUserLocation::getAppUserId, userId).orderByDesc(TAppUserLocation::getTime)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * 用户打点 |
| | | */ |
| | | @ApiOperation(value = "获取用户打点数据--详情",response = TAppUserLocation.class) |
| | | @PostMapping(value = "/open/t-app-user/getAppUserLocationFromId") |
| | | public R<TAppUserLocation> getAppUserLocationFromId(@RequestBody String param) { |
| | | UserIdDto dto = JSON.parseObject(param, UserIdDto.class); |
| | | TAppUserLocation location = appUserLocationService.getById(dto.getId()); |
| | | return R.ok(location); |
| | | } |
| | | |
| | | /** |
| | | * 用户附近人员定位 |
| | | */ |
| | | @ApiOperation(value = "用户附近人员定位") |
| | | @PostMapping(value = "/open/t-app-user/nearUserLocation") |
| | | public R<List<TAppUser>> nearUserLocation(@RequestParam(value = "lon") String lon , |
| | | @RequestParam(value = "lat") String lat ) { |
| | | List<TAppUser> list = appUserService.list(Wrappers.lambdaQuery(TAppUser.class) |
| | | .eq(TAppUser::getStatus, 1) |
| | | .eq(TAppUser::getState, 1)); |
| | | |
| | | Iterator<TAppUser> iterator = list.iterator(); |
| | | while (iterator.hasNext()) { |
| | | TAppUser appUser = iterator.next(); |
| | | String location = redisCache.getCacheObject(Constants.LOCATION + appUser.getId()); |
| | | if(!StringUtils.hasLength(location)){ |
| | | iterator.remove(); |
| | | }else { |
| | | // 计算距离 |
| | | double startLon = Double.parseDouble(location.split(",")[0]); |
| | | double startLat = Double.parseDouble(location.split(",")[1]); |
| | | double distance = GDMapGeocodingUtil.getDistance(Double.parseDouble(lon), Double.parseDouble(lat), startLon, startLat); |
| | | distance = distance / 1000; |
| | | if(distance>50){ |
| | | iterator.remove(); |
| | | }else { |
| | | appUser.setLon(String.valueOf(startLon)); |
| | | appUser.setLat(String.valueOf(startLat)); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(list); |
| | | } |
| | | |
| | | } |
| | | |