From 83ef78640c563640ad97220d88e9aa00dd520eb0 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期六, 20 一月 2024 13:47:44 +0800
Subject: [PATCH] 查询本部门在线PC端及指挥端提交
---
ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java | 11 +++++++++++
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 22 ++++++++++++++++++++++
ard-work/src/main/java/com/ruoyi/app/position/service/IArdAppPositionService.java | 3 +++
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java | 4 ++++
ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java | 17 +++++++++++++++++
5 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java b/ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java
index 594920e..292e891 100644
--- a/ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java
+++ b/ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java
@@ -2,13 +2,16 @@
import javax.servlet.http.HttpServletResponse;
+import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellParam;
import com.ruoyi.app.position.domain.ArdAppPosition;
import com.ruoyi.app.position.service.IArdAppPositionService;
import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.utils.minio.MinioUtil;
+import com.ruoyi.utils.result.Results;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -214,4 +217,12 @@
String url = MinioUtil.putObjectAndGetUrl("app",type, file);
return AjaxResult.success(url);
}
+
+ @GetMapping("/getOnlinePCOrCommander")
+ @ApiOperation("鏌ヨ鏈儴闂ㄥ湪绾縋C绔強鎸囨尌绔�")
+ public AjaxResult getOnlinePCOrCommander() {
+ String usersId = SecurityUtils.getUserId();
+ Map<String,List<SysUser>> result = ardAppPositionService.getOnlinePCOrCommander(usersId);
+ return AjaxResult.success(result);
+ }
}
diff --git a/ard-work/src/main/java/com/ruoyi/app/position/service/IArdAppPositionService.java b/ard-work/src/main/java/com/ruoyi/app/position/service/IArdAppPositionService.java
index 7e56881..e96b753 100644
--- a/ard-work/src/main/java/com/ruoyi/app/position/service/IArdAppPositionService.java
+++ b/ard-work/src/main/java/com/ruoyi/app/position/service/IArdAppPositionService.java
@@ -1,6 +1,7 @@
package com.ruoyi.app.position.service;
import java.util.List;
+import java.util.Map;
import com.ruoyi.alarm.wall.domain.ArdAlarmWall;
import com.ruoyi.app.position.domain.ArdAppPosition;
@@ -82,4 +83,6 @@
* 2023/8/17 13:56:36
*/
public List<SysUser>getNearAppUsersWithPolygon(SchedulingParam param);
+
+ public Map<String,List<SysUser>> getOnlinePCOrCommander(String usersId);
}
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 8aead3f..fe36f94 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
@@ -14,6 +14,7 @@
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.scheduling.domian.SchedulingParam;
+import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.utils.gis.GisUtil;
import com.ruoyi.utils.gis.Point;
@@ -24,6 +25,8 @@
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
+
+import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS;
/**
@@ -45,6 +48,8 @@
ArdWallMapper ardWallMapper;
@Resource
IArdAlarmWallService ardAlarmWallService;
+ @Resource
+ private SysUserMapper sysUserMapper;
Map<String, String> firstAlarmMap = new HashMap<>();//棣栨鎶ヨ缂撳瓨key:鐢ㄦ埛id_鍥存爮id value: 鎶ヨid
/**
@@ -321,4 +326,16 @@
}
return ardAlarmWalls;
}
+
+ @Override
+ public Map<String, List<SysUser>> getOnlinePCOrCommander(String usersId) {
+ Map<String, List<SysUser>> result = new HashMap();
+ List<SysUser> commanderList = sysUserMapper.getOnlineCommander(usersId);
+ result.put("commander",commanderList);
+ List<String> onLinePCIdList = new ArrayList();
+ onLinePCIdList.addAll(ONLINE_USER_SESSIONS.keySet());
+ List<SysUser> pcList = sysUserMapper.getOnlinePC(usersId,onLinePCIdList);
+ result.put("pc",pcList);
+ return result;
+ }
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
index 686bafd..c7567df 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
@@ -140,4 +140,8 @@
public List<SysUser> getSysUserByCarId(String carId);
List<SysUser> userByPlanId(String id);
+
+ List<SysUser> getOnlineCommander(String usersId);
+
+ List<SysUser> getOnlinePC(@Param("usersId") String usersId,@Param("onLinePCIdList")List<String> onLinePCIdList);
}
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
index 49f1b86..11e6b31 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -295,4 +295,26 @@
<select id="userByPlanId" parameterType="String" resultMap="SysUserResult">
select user_id,nick_name from sys_user where user_id in (select app_user_id from ard_app_patroluser where patrolplan_id = #{id})
</select>
+
+ <select id="getOnlineCommander" parameterType="String" resultMap="SysUserResult">
+ select distinct su0.* from sys_user su
+ inner join sys_user su0 on su.dept_id = su0.dept_id
+ inner join sys_user_role aur on su0.user_id = aur.user_id
+ inner join sys_role sr on aur.role_id = sr.role_id
+ where su.user_id = #{usersId} and su0.user_id != #{usersId}
+ and sr.role_key = 'appLeader' and su0.app_online_state = '1'
+ </select>
+
+ <select id="getOnlinePC" resultMap="SysUserResult">
+ select distinct su0.* from sys_user su
+ inner join sys_user su0 on su.dept_id = su0.dept_id
+ inner join sys_user_role aur on su0.user_id = aur.user_id
+ inner join sys_role sr on aur.role_id = sr.role_id
+ where su.user_id = #{usersId} and su0.user_id != #{usersId}
+ and sr.role_key != 'appLeader' and sr.role_key != 'appUser'
+ and su0.user_id in
+ <foreach collection="onLinePCIdList" item="userId" open="(" close=")" separator=",">
+ #{userId}
+ </foreach>
+ </select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3