From c3cace620c5bc6b0049bf0c677f729ea2c406203 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期二, 20 二月 2024 13:51:40 +0800
Subject: [PATCH] 指挥端查看app历史轨迹提交
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java | 20 ----
ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java | 67 +------------
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 1
ard-work/src/main/java/com/ruoyi/app/position/service/IArdAppPositionService.java | 9 -
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java | 1
ard-work/src/main/java/com/ruoyi/app/position/appcontainer/AppContainer.java | 19 +++
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java | 5 -
ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java | 152 +++++++++---------------------
ard-work/src/main/java/com/ruoyi/app/position/mapper/ArdAppPositionMapper.java | 2
ard-work/src/main/resources/mapper/app/ArdAppPositionMapper.xml | 6 +
10 files changed, 79 insertions(+), 203 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/app/position/appcontainer/AppContainer.java b/ard-work/src/main/java/com/ruoyi/app/position/appcontainer/AppContainer.java
new file mode 100644
index 0000000..96ed100
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/app/position/appcontainer/AppContainer.java
@@ -0,0 +1,19 @@
+package com.ruoyi.app.position.appcontainer;
+
+import com.ruoyi.app.position.domain.ArdAppPosition;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class AppContainer {
+
+ private static Map<String, ArdAppPosition> ardAppPositionMap = new HashMap();
+
+ public static Map<String, ArdAppPosition> getArdAppPositionMap() {
+ return ardAppPositionMap;
+ }
+
+ public static void setArdAppPositionMap(Map<String, ArdAppPosition> ardAppPositionMap) {
+ ardAppPositionMap = ardAppPositionMap;
+ }
+}
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 2a89eef..fcb6907 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
@@ -251,67 +251,10 @@
}
}
- /*@PostMapping("/sendCheckCommandersPosition")
- @ApiOperation("鍙戣捣鏌ョ湅鎸囨尌绔綅缃�")
- public AjaxResult sendCheckCommandersPosition(@RequestBody Map<String,Object> para) {
- String usersId = SecurityUtils.getUserId();
- try{
- ardAppPositionService.sendCheckCommandersPosition(usersId,para);
- return AjaxResult.success();
- }catch(Exception e){
- return AjaxResult.error();
- }
- }*/
-
- /*@PostMapping("/sendCheckSYCarsPosition")
- @ApiOperation("鍙戣捣鏌ョ湅杞﹁締浣嶇疆")
- public AjaxResult sendCheckSYCarsPosition(@RequestBody Map<String,Object> para) {
- String usersId = SecurityUtils.getUserId();
- try{
- ardAppPositionService.sendCheckSYCarsPosition(usersId,para);
- return AjaxResult.success();
- }catch(Exception e){
- return AjaxResult.error();
- }
- }*/
-
- /*@GetMapping("/getCheckCommandersPosition")
- @ApiOperation("鎸囨尌绔煡鐪嬫寚鎸ョ浣嶇疆鐢宠")
- public AjaxResult getCheckCommandersPosition() {//寮冪敤
- String usersId = SecurityUtils.getUserId();
- try{
- List<Map<String,Object>> result = ardAppPositionService.getCheckCommandersPosition(usersId);
- return AjaxResult.success(result);
- }catch(Exception e){
- e.printStackTrace();
- return AjaxResult.error();
- }
- }*/
-
- /*@GetMapping("/getCheckSYCarsPosition")
- @ApiOperation("鎸囨尌绔煡鐪嬭溅杈嗕綅缃敵璇�")
- public AjaxResult getCheckSYCarsPosition() {//寮冪敤
- String usersId = SecurityUtils.getUserId();
- try{
- List<Map<String,Object>> result = ardAppPositionService.getCheckSYCarsPosition(usersId);
- return AjaxResult.success(result);
- }catch(Exception e){
- e.printStackTrace();
- return AjaxResult.error();
- }
- }*/
-
- /*@GetMapping("/getCheckPosition")
- @ApiOperation("鎸囨尌绔煡鐪嬩綅缃敵璇�")
- public AjaxResult getCheckPosition() {
- String usersId = SecurityUtils.getUserId();
- try{
- Map<String,List<Map<String,Object>>> result = ardAppPositionService.getCheckPosition(usersId);
- return AjaxResult.success(result);
- }catch(Exception e){
- e.printStackTrace();
- return AjaxResult.error();
- }
- }*/
+ @GetMapping("/getAPPSoilderByCommanderId")
+ public AjaxResult getAPPSoilderByCommanderId() {
+ String userId = SecurityUtils.getUserId();
+ return success(ardAppPositionService.getAPPSoilderByCommanderId(userId));
+ }
}
diff --git a/ard-work/src/main/java/com/ruoyi/app/position/mapper/ArdAppPositionMapper.java b/ard-work/src/main/java/com/ruoyi/app/position/mapper/ArdAppPositionMapper.java
index 4b4ad05..2f81a24 100644
--- a/ard-work/src/main/java/com/ruoyi/app/position/mapper/ArdAppPositionMapper.java
+++ b/ard-work/src/main/java/com/ruoyi/app/position/mapper/ArdAppPositionMapper.java
@@ -73,4 +73,6 @@
public List<Map<String,Object>> getOnlineCommanderPosition(String soilderId);
public List<ArdAppPosition> getAPPPositionByUserIdAndTime(@Param("userId") String userId,@Param("beginTime") String beginTime,@Param("endTime") String endTime);
+
+ public ArdAppPosition getLastAPPPositionByUserId(String userId);
}
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 b08b7f9..621853e 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
@@ -90,13 +90,6 @@
public List<ArdAppPosition> getAPPPositionByUserIdAndTime(Map<String,String> para);
- //public void sendCheckCommandersPosition(String usersId,Map<String,Object> para);
+ public List<Map<String,Object>> getAPPSoilderByCommanderId(String userId);
- //public void sendCheckSYCarsPosition(String usersId,Map<String,Object> para);
-
- //public List<Map<String,Object>> getCheckCommandersPosition(String usersId);
-
- //public List<Map<String,Object>> getCheckSYCarsPosition(String usersId);
-
- //public Map<String,List<Map<String,Object>>> getCheckPosition(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 2909fdf..8cf5417 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
@@ -1,11 +1,10 @@
package com.ruoyi.app.position.service.impl;
-import com.alibaba.fastjson2.JSON;
import com.ruoyi.alarm.wall.domain.ArdAlarmWall;
-import com.ruoyi.alarm.wall.mapper.ArdAlarmWallMapper;
import com.ruoyi.alarm.wall.service.IArdAlarmWallService;
import com.ruoyi.alarmpoints.wall.domain.ArdWall;
import com.ruoyi.alarmpoints.wall.mapper.ArdWallMapper;
+import com.ruoyi.app.position.appcontainer.AppContainer;
import com.ruoyi.app.position.domain.ArdAppPosition;
import com.ruoyi.app.position.mapper.ArdAppPositionMapper;
import com.ruoyi.app.position.service.IArdAppPositionService;
@@ -15,16 +14,15 @@
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.scheduling.domian.SchedulingParam;
+import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.utils.gis.GisUtil;
import com.ruoyi.utils.gis.Point;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
-import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -52,6 +50,8 @@
IArdAlarmWallService ardAlarmWallService;
@Resource
private SysUserMapper sysUserMapper;
+ @Resource
+ private SysDeptMapper sysDeptMapper;
Map<String, String> firstAlarmMap = new HashMap<>();//棣栨鎶ヨ缂撳瓨key:鐢ㄦ埛id_鍥存爮id value: 鎶ヨid
/**
@@ -98,7 +98,12 @@
ardAppPosition.setId(IdUtils.simpleUUID());
ardAppPosition.setCreateTime(DateUtils.getNowDate());
ardAppPositionMapper.insertArdAppPosition(ardAppPosition);
- return DetectionWallAlarm(ardAppPosition);
+ try{
+ return DetectionWallAlarm(ardAppPosition);
+ }finally {
+ AppContainer.getArdAppPositionMap().put(ardAppPosition.getUserId(),ardAppPosition);//瀹炴椂浣嶇疆瀛樺叆瀹瑰櫒
+ }
+
}
/**
@@ -487,111 +492,44 @@
return result;
}
- /*@Override
- public void sendCheckCommandersPosition(String usersId,Map<String, Object> para) {
- String reason = (String) para.get("reason");
- List<String> usersIdList = (List<String>) para.get("usersIdList");
- for(String commanderId : usersIdList){
- //璁剧疆key涓篶heckCommanderPosition_鎸囨尌绔富閿甠鍗曞叺绔富閿�
- String key = "checkCommanderPosition_" + commanderId + "_" + usersId;
- Map<String,Object> value = new HashMap();
- value.put("reason",reason);
- value.put("state","0");
- value.put("begin","");
- value.put("commanderId",commanderId);
- value.put("soilderId",usersId);
- redisCache.setCacheObject(key, JSON.toJSONString(value));
- }
- }*/
-
- /*@Override
- public void sendCheckSYCarsPosition(String usersId, Map<String, Object> para) {
- String reason = (String) para.get("reason");
- List<String> usersIdList = (List<String>) para.get("usersIdList");
- for(String commanderId : usersIdList){
- //璁剧疆key涓篶heckSYCarsPosition_鎸囨尌绔富閿�/PC绔富閿甠鍗曞叺绔富閿�
- String key = "checkSYCarsPosition_" + commanderId + "_" + usersId;
- Map<String,Object> value = new HashMap();
- value.put("reason",reason);
- value.put("state","0");
- value.put("begin","");
- value.put("commanderId",commanderId);
- value.put("soilderId",usersId);
- redisCache.setCacheObject(key, JSON.toJSONString(value));
- }
- }*/
-
- /*@Override
- public List<Map<String, Object>> getCheckCommandersPosition(String usersId) {
- String key = "checkCommanderPosition_" + usersId + "_";
- List<Object> keyValueList = redisCache.getListKey(key);
- List<Map<String, Object>> result = new ArrayList();
- for(Object o : keyValueList){
- Map<String,Object> map = JSON.parseObject((String) o);
- if(((String)map.get("state")).equals("0")){//state涓�0灏辨槸鏈鎵�
- SysUser sysUser = sysUserMapper.selectUserById((String) map.get("soilderId"));
- map.put("userName",sysUser.getUserName());
- result.add(map);
+ @Override
+ public List<Map<String,Object>> getAPPSoilderByCommanderId(String userId) {
+ SysUser sysUser = sysUserMapper.selectUserById(userId);//鑾峰彇绯荤粺鐢ㄦ埛
+ List<Long> deptIdList = new ArrayList();
+ deptIdList.add(sysUser.getDeptId());
+ deptIdList = getOwnAndChildrenDeptIdList(deptIdList,new ArrayList());//閫掑綊鏌ヨ涓嬪睘閮ㄩ棬涓婚敭
+ List<SysUser> result = sysUserMapper.getOwnAndChildrenSoilderList(deptIdList);
+ List<Map<String,Object>> resultList = new ArrayList();
+ for(SysUser sysUserIn : result){
+ Map<String,Object> map = new HashMap();
+ map.put("userId",sysUserIn.getUserId());
+ map.put("deptId",sysUserIn.getDeptId());
+ map.put("userName",sysUserIn.getUserName());
+ map.put("nickName",sysUserIn.getNickName());
+ try{
+ map.put("longitude",AppContainer.getArdAppPositionMap().get(sysUserIn.getUserId()).getLongitude());
+ map.put("latitude",AppContainer.getArdAppPositionMap().get(sysUserIn.getUserId()).getLatitude());
+ map.put("altitude",AppContainer.getArdAppPositionMap().get(sysUserIn.getUserId()).getAltitude());
+ }catch(Exception e){
+ ArdAppPosition ardAppPosition = ardAppPositionMapper.getLastAPPPositionByUserId(sysUserIn.getUserId());
+ map.put("longitude",ardAppPosition.getLongitude());
+ map.put("latitude",ardAppPosition.getLatitude());
+ map.put("altitude",ardAppPosition.getAltitude());
}
+ resultList.add(map);
}
- return result;
- }*/
+ return resultList;
+ }
- /*@Override
- public List<Map<String, Object>> getCheckSYCarsPosition(String usersId) {
- String key = "checkSYCarsPosition_" + usersId + "_";
- List<Object> keyValueList = redisCache.getListKey(key);
- List<Map<String, Object>> result = new ArrayList();
- for(Object o : keyValueList){
- Map<String,Object> map = JSON.parseObject((String) o);
- if(((String)map.get("state")).equals("0")){//state涓�0灏辨槸鏈鎵�
- SysUser sysUser = sysUserMapper.selectUserById((String) map.get("soilderId"));
- map.put("userName",sysUser.getUserName());
- result.add(map);
- }
+ public List<Long> getOwnAndChildrenDeptIdList(List<Long> deptIdList,List<Long> deptIdListr){
+ deptIdListr.addAll(deptIdList);
+ List<Long> result = sysDeptMapper.getChildrenDeptIdList(deptIdList);
+ if(result.size() != 0){
+ deptIdListr.addAll(result);
+ result = getOwnAndChildrenDeptIdList(result,deptIdListr);
}
- return result;
- }*/
+ deptIdListr = deptIdListr.stream().distinct().collect(Collectors.toList());
+ return deptIdListr;
+ }
- /*@Override
- public Map<String, List<Map<String, Object>>> getCheckPosition(String usersId) {
- Map<String, List<Map<String, Object>>> result = new HashMap();
- //鏌ョ湅鎸囨尌绔綅缃敵璇�
- String keyCommanderPosition = "checkCommanderPosition_" + usersId + "_";
- List<Object> keyValueCommanderPositionList = redisCache.getListKey(keyCommanderPosition);
- List<Map<String, Object>> resultCommanderPosition = new ArrayList();
- for(Object o : keyValueCommanderPositionList){
- Map<String,Object> map = JSON.parseObject((String) o);
- if(((String)map.get("state")).equals("0")){//state涓�0灏辨槸鏈鎵�
- SysUser sysUser = sysUserMapper.selectUserById((String) map.get("soilderId"));
- map.put("userName",sysUser.getUserName());
- if(sysUser.getNickName() != null){
- map.put("nickName",sysUser.getNickName());
- }else{
- map.put("nickName",sysUser.getNickName());
- }
- resultCommanderPosition.add(map);
- }
- }
- //鏌ョ湅杞﹁締浣嶇疆鐢宠
- String keySYCarsPosition = "checkSYCarsPosition_" + usersId + "_";
- List<Object> keyValueSYCarsPositionList = redisCache.getListKey(keySYCarsPosition);
- List<Map<String, Object>> resultSYCarsPosition = new ArrayList();
- for(Object o : keyValueSYCarsPositionList){
- Map<String,Object> map = JSON.parseObject((String) o);
- if(((String)map.get("state")).equals("0")){//state涓�0灏辨槸鏈鎵�
- SysUser sysUser = sysUserMapper.selectUserById((String) map.get("soilderId"));
- map.put("userName",sysUser.getUserName());
- if(sysUser.getNickName() != null){
- map.put("nickName",sysUser.getNickName());
- }else{
- map.put("nickName",sysUser.getNickName());
- }
- resultSYCarsPosition.add(map);
- }
- }
- result.put("commander",resultCommanderPosition);
- result.put("SYCars",resultSYCarsPosition);
- return result;
- }*/
}
diff --git a/ard-work/src/main/resources/mapper/app/ArdAppPositionMapper.xml b/ard-work/src/main/resources/mapper/app/ArdAppPositionMapper.xml
index 6c7916d..0517147 100644
--- a/ard-work/src/main/resources/mapper/app/ArdAppPositionMapper.xml
+++ b/ard-work/src/main/resources/mapper/app/ArdAppPositionMapper.xml
@@ -103,4 +103,10 @@
where aap.user_id = #{userId} and aap.create_time >= #{beginTime}
and aap.create_time <= #{endTime} order by aap.create_time asc
</select>
+
+ <select id="getLastAPPPositionByUserId" parameterType="java.lang.String" resultMap="ArdAppPositionResult">
+ select * from ard_app_position aap
+ where aap.user_id = #{userId}
+ order by aap.create_time desc limit 1 offset 0
+ </select>
</mapper>
\ No newline at end of file
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
index f26fc52..d81d647 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
@@ -266,9 +266,4 @@
}
}
- @GetMapping("/getAPPSoilderByCommanderId")
- public AjaxResult getAPPSoilderByCommanderId() {
- String userId = SecurityUtils.getUserId();
- return success(userService.getAPPSoilderByCommanderId(userId));
- }
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
index 43ff491..ed79e23 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
@@ -238,5 +238,4 @@
List<SysUser> userByDept(Long deptId);
- List<SysUser> getAPPSoilderByCommanderId(String userId);
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
index 2720897..a37f029 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -647,24 +647,4 @@
return userMapper.selectList(queryWrapper);
}
- @Override
- public List<SysUser> getAPPSoilderByCommanderId(String userId) {
- SysUser sysUser = userMapper.selectUserById(userId);//鑾峰彇绯荤粺鐢ㄦ埛
- List<Long> deptIdList = new ArrayList();
- deptIdList.add(sysUser.getDeptId());
- deptIdList = getOwnAndChildrenDeptIdList(deptIdList,new ArrayList());//閫掑綊鏌ヨ涓嬪睘閮ㄩ棬涓婚敭
- List<SysUser> result = userMapper.getOwnAndChildrenSoilderList(deptIdList);
- return result;
- }
-
- public List<Long> getOwnAndChildrenDeptIdList(List<Long> deptIdList,List<Long> deptIdListr){
- deptIdListr.addAll(deptIdList);
- List<Long> result = sysDeptMapper.getChildrenDeptIdList(deptIdList);
- if(result.size() != 0){
- deptIdListr.addAll(result);
- result = getOwnAndChildrenDeptIdList(result,deptIdListr);
- }
- deptIdListr = deptIdListr.stream().distinct().collect(Collectors.toList());
- return deptIdListr;
- }
}
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
index 66aa0b8..ab32a54 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -353,6 +353,7 @@
<foreach collection="deptIdList" item="deptId" open="(" close=")" separator=",">
#{deptId}
</foreach>
+ and su.app_online_state = '1'
order by su.dept_id asc
</select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3