From 4a10315e35dd547300990e9f806d19d33c261d74 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期一, 21 八月 2023 17:14:29 +0800
Subject: [PATCH] 一键调度按登录用户得部门查询人和相机
---
ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java | 2
ard-work/src/main/java/com/ruoyi/scheduling/domian/SchedulingParam.java | 2 -
ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java | 77 ++++++++++++++++++++------------------
ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java | 7 ++-
4 files changed, 47 insertions(+), 41 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java b/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java
index 2ca4552..c046a48 100644
--- a/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java
@@ -125,45 +125,50 @@
*/
@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("1")))
- .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) {
- Map<String,Object> params=new HashMap<>();
- params.put("longitude",lon);
- params.put("latitude",lat);
- sysUser.setParams(params);
- 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("鑾峰彇灏佹帶鍦堝唴鎵�鏈夊湪绾縜pp鐢ㄦ埛寮傚父" + ex.getMessage());
}
return filteredList;
}
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java b/ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java
index cfdf554..1c8ed55 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java
@@ -104,7 +104,7 @@
* 閮ㄩ棬ID
*/
@Excel(name = "閮ㄩ棬ID")
- private Integer deptId;
+ private Long deptId;
/**
* 鏂逛綅瑙�
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
index eeac1a7..e14f950 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
@@ -303,6 +303,7 @@
@Override
public List<ArdCameras> getNearCameras(SchedulingParam param) {
try {
+ Long deptId=SecurityUtils.getLoginUser().getUser().getDeptId();
Double longitude = param.getLongitude();
Double latitude = param.getLatitude();
if (longitude == null && latitude == null) {
@@ -315,8 +316,10 @@
return null;
}
String dayNightTime = redisCache.getCacheObject("sys_config:dayNightTime");
- //鑾峰彇鎵�鏈夊厜鐢�
- List<ArdCameras> ardCamerasList = ardCamerasMapper.selectArdCamerasList(new ArdCameras());
+ //鑾峰彇鎵�鏈夊厜鐢�(鎸夐儴闂�)
+ ArdCameras cameras= new ArdCameras();
+ cameras.setDeptId(deptId);
+ List<ArdCameras> ardCamerasList = ardCamerasMapper.selectArdCamerasList(cameras);
//缁熻鎵�鏈夊厜鐢靛彲瑙嗚寖鍥村唴涓庢姤璀︾偣鐨勮窛绂�
List<ArdCameras> ardCameras = new ArrayList<>();
for (ArdCameras camera : ardCamerasList) {
diff --git a/ard-work/src/main/java/com/ruoyi/scheduling/domian/SchedulingParam.java b/ard-work/src/main/java/com/ruoyi/scheduling/domian/SchedulingParam.java
index 9b911d5..b75ed90 100644
--- a/ard-work/src/main/java/com/ruoyi/scheduling/domian/SchedulingParam.java
+++ b/ard-work/src/main/java/com/ruoyi/scheduling/domian/SchedulingParam.java
@@ -1,7 +1,5 @@
package com.ruoyi.scheduling.domian;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
--
Gitblit v1.9.3