| | |
| | | import com.ruoyi.scheduling.domian.SchedulingParam; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.utils.tools.GisTool; |
| | | import com.ruoyi.utils.tools.Point; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import java.awt.geom.Point2D; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | */ |
| | | @Override |
| | | public List<SysUser> getNearAppUsers(SchedulingParam param) { |
| | | Double longitude = param.getLongitude(); |
| | | Double latitude = param.getLatitude(); |
| | | if (longitude == null && latitude == null) { |
| | | log.debug("原点坐标为空"); |
| | | return null; |
| | | } |
| | | Integer radius = param.getSealingRadius(); |
| | | |
| | | if (radius == null) { |
| | | log.debug("半径距离为空"); |
| | | return null; |
| | | } |
| | | |
| | | SysUser user = new SysUser(); |
| | | List<SysUser> appUserList = iSysUserService.selectAllAppUserList(user); |
| | | //过滤在线 |
| | | List<SysUser> onLineList = appUserList.stream() |
| | | .filter(sysUser -> (sysUser.getAppOnlineState().equals("0"))) |
| | | .collect(Collectors.toList()); |
| | | //过滤范围 |
| | | List<SysUser> filteredList = new ArrayList<>(); |
| | | for(SysUser sysUser:onLineList) { |
| | | ArdAppPosition ardAppPosition = ardAppPositionMapper.selectLastArdAppPositionByUserId(sysUser.getUserId()); |
| | | if (ardAppPosition != null) { |
| | | Double lon = ardAppPosition.getLongitude(); |
| | | Double lat = ardAppPosition.getLatitude(); |
| | | if(longitude==null||latitude==null) |
| | | { |
| | | continue; |
| | | } |
| | | double distance = GisTool.getDistance(new double[]{ longitude, latitude}, new double[]{ lon, lat}); |
| | | if (distance <= radius) { |
| | | filteredList.add(sysUser); // 将满足条件的用户添加到筛选列表中 |
| | | try { |
| | | Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId(); |
| | | Double longitude = param.getLongitude(); |
| | | Double latitude = param.getLatitude(); |
| | | if (longitude == null && latitude == null) { |
| | | log.debug("原点坐标为空"); |
| | | return null; |
| | | } |
| | | Integer radius = param.getSealingRadius(); |
| | | |
| | | if (radius == null) { |
| | | log.debug("半径距离为空"); |
| | | return null; |
| | | } |
| | | |
| | | SysUser user = new SysUser(); |
| | | user.setDeptId(deptId); |
| | | List<SysUser> appUserList = iSysUserService.selectAllAppUserList(user); |
| | | //过滤在线 |
| | | List<SysUser> onLineList = appUserList.stream() |
| | | .filter(sysUser -> (sysUser.getAppOnlineState().equals("1"))) |
| | | .collect(Collectors.toList()); |
| | | //过滤范围 |
| | | for (SysUser sysUser : onLineList) { |
| | | ArdAppPosition ardAppPosition = ardAppPositionMapper.selectLastArdAppPositionByUserId(sysUser.getUserId()); |
| | | if (ardAppPosition != null) { |
| | | Double lon = ardAppPosition.getLongitude(); |
| | | Double lat = ardAppPosition.getLatitude(); |
| | | if (longitude == null || latitude == null) { |
| | | continue; |
| | | } |
| | | double distance = GisTool.getDistance(new double[]{longitude, latitude}, new double[]{lon, lat}); |
| | | if (distance <= radius) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("longitude", lon); |
| | | params.put("latitude", lat); |
| | | sysUser.setParams(params); |
| | | filteredList.add(sysUser); // 将满足条件的用户添加到筛选列表中 |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("获取封控圈内所有在线app用户异常" + ex.getMessage()); |
| | | } |
| | | return filteredList; |
| | | } |
| | | /** |
| | | * 获取封控圈内所有在线app用户(多边形) |
| | | * 刘苏义 |
| | | * 2023/8/17 13:56:36 |
| | | */ |
| | | @Override |
| | | public List<SysUser> getNearAppUsersWithPolygon(SchedulingParam param) { |
| | | List<SysUser> filteredList = new ArrayList<>(); |
| | | try { |
| | | Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId(); |
| | | List<Point> partitionLocation = param.getPartitionLocation(); |
| | | |
| | | SysUser user = new SysUser(); |
| | | user.setDeptId(deptId); |
| | | List<SysUser> appUserList = iSysUserService.selectAllAppUserList(user); |
| | | //过滤在线 |
| | | List<SysUser> onLineList = appUserList.stream() |
| | | .filter(sysUser -> (sysUser.getAppOnlineState().equals("1"))) |
| | | .collect(Collectors.toList()); |
| | | //过滤范围 |
| | | for (SysUser sysUser : onLineList) { |
| | | ArdAppPosition ardAppPosition = ardAppPositionMapper.selectLastArdAppPositionByUserId(sysUser.getUserId()); |
| | | if (ardAppPosition != null) { |
| | | Double lon = ardAppPosition.getLongitude(); |
| | | Double lat = ardAppPosition.getLatitude(); |
| | | if (lon == null || lat == null) { |
| | | continue; |
| | | } |
| | | Point point2D=new Point(); |
| | | point2D.setLongitude(lon); |
| | | point2D.setLatitude(lat); |
| | | boolean inPolygon = GisTool.isInPolygon(point2D, partitionLocation); |
| | | if (inPolygon) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("longitude", lon); |
| | | params.put("latitude", lat); |
| | | sysUser.setParams(params); |
| | | filteredList.add(sysUser); // 将满足条件的用户添加到筛选列表中 |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("获取封控圈内所有在线app用户异常" + ex.getMessage()); |
| | | } |
| | | return filteredList; |
| | | } |
| | | } |