From ca8c7b4e9c4762acb2fc2c793d79ae58e05dcf36 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期三, 21 二月 2024 14:01:38 +0800
Subject: [PATCH] 查看在线单兵端及车辆提交
---
ard-work/src/main/java/com/ruoyi/app/application/controller/ArdAppApplicationController.java | 14 +++
ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java | 6
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 19 ++++
ard-work/src/main/java/com/ruoyi/app/position/service/IArdAppPositionService.java | 2
ard-work/src/main/java/com/ruoyi/app/application/service/impl/ArdAppApplicationServiceImpl.java | 176 ++++++++++++++++++++++++++++++++++++++++++++
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 | 4
ard-work/src/main/java/com/ruoyi/app/application/service/IArdAppApplicationService.java | 2
8 files changed, 218 insertions(+), 9 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/app/application/controller/ArdAppApplicationController.java b/ard-work/src/main/java/com/ruoyi/app/application/controller/ArdAppApplicationController.java
index 72120d3..4a3ee50 100644
--- a/ard-work/src/main/java/com/ruoyi/app/application/controller/ArdAppApplicationController.java
+++ b/ard-work/src/main/java/com/ruoyi/app/application/controller/ArdAppApplicationController.java
@@ -1,5 +1,6 @@
package com.ruoyi.app.application.controller;
+import java.awt.geom.QuadCurve2D;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
@@ -223,4 +224,17 @@
return AjaxResult.error();
}
}
+
+ @GetMapping("/getSoilderAndCarPositionByCommanderIdNear")
+ @ApiOperation("PC绔寚鎸ョ鏌ョ湅鍗曞叺绔強杞﹁締浣嶇疆")
+ public AjaxResult getSoilderAndCarPositionByCommanderIdNear(@RequestBody Map<String, Double> para) {
+ String commanderId = SecurityUtils.getUserId();
+ try{
+ Map<String,Map<String,List<Map<String,Object>>>> result = ardAppApplicationService.getSoilderAndCarPositionByCommanderId(commanderId,para);
+ return AjaxResult.success(result);
+ }catch(Exception e){
+ e.printStackTrace();
+ return AjaxResult.error();
+ }
+ }
}
diff --git a/ard-work/src/main/java/com/ruoyi/app/application/service/IArdAppApplicationService.java b/ard-work/src/main/java/com/ruoyi/app/application/service/IArdAppApplicationService.java
index 1e74376..9ebdecf 100644
--- a/ard-work/src/main/java/com/ruoyi/app/application/service/IArdAppApplicationService.java
+++ b/ard-work/src/main/java/com/ruoyi/app/application/service/IArdAppApplicationService.java
@@ -78,4 +78,6 @@
public int approvalCheckPositionOwn(String soilderId,Map<String,String> para);
public List<Map<String,Object>> getCheckPositionNo(String commanderId);///
+
+ public Map<String,Map<String,List<Map<String,Object>>>> getSoilderAndCarPositionByCommanderId(String commanderId,Map<String, Double> para);
}
diff --git a/ard-work/src/main/java/com/ruoyi/app/application/service/impl/ArdAppApplicationServiceImpl.java b/ard-work/src/main/java/com/ruoyi/app/application/service/impl/ArdAppApplicationServiceImpl.java
index 4fc1bcf..88ff9ca 100644
--- a/ard-work/src/main/java/com/ruoyi/app/application/service/impl/ArdAppApplicationServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/app/application/service/impl/ArdAppApplicationServiceImpl.java
@@ -1,11 +1,27 @@
package com.ruoyi.app.application.service.impl;
+import java.math.BigDecimal;
import java.util.*;
+import java.util.stream.Collectors;
+import com.ruoyi.app.position.appcontainer.AppContainer;
+import com.ruoyi.app.position.domain.ArdAppPosition;
+import com.ruoyi.app.position.mapper.ArdAppPositionMapper;
+import com.ruoyi.common.core.domain.entity.SysConfig;
import com.ruoyi.common.core.domain.entity.SysRole;
+import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.uuid.IdUtils;
+import com.ruoyi.sy.domain.ArdSyUser;
+import com.ruoyi.sy.mapper.ArdSyCarMapper;
+import com.ruoyi.sy.mapper.ArdSyUserMapper;
+import com.ruoyi.system.mapper.SysConfigMapper;
+import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
+import com.ruoyi.system.mapper.SysUserMapper;
+import com.ruoyi.utils.forest.SYClient;
+import com.ruoyi.utils.gis.GisUtil;
import com.ruoyi.utils.websocket.util.WebSocketUtils;
+import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -34,6 +50,27 @@
@Resource
private SysRoleMapper sysRoleMapper;
+
+ @Resource
+ private SysUserMapper userMapper;
+
+ @Resource
+ private SysDeptMapper sysDeptMapper;
+
+ @Resource
+ private ArdAppPositionMapper ardAppPositionMapper;
+
+ @Resource
+ private ArdSyUserMapper ardSyUserMapper;
+
+ @Resource
+ private SysConfigMapper sysConfigMapper;
+
+ @Resource
+ private ArdSyCarMapper ardSyCarMapper;
+
+ @Resource
+ private SYClient sYClient;
private Map<String,Thread> threadMap = new HashMap();
@@ -404,4 +441,143 @@
}
return ardAppApplicationList;
}
+
+ @Override
+ public Map<String,Map<String,List<Map<String,Object>>>> getSoilderAndCarPositionByCommanderId(String commanderId,Map<String, Double> para) {
+ Map<String,Map<String,List<Map<String,Object>>>> mapResault = new HashMap();
+ SysUser sysUser = userMapper.selectUserById(commanderId);//鑾峰彇绯荤粺鐢ㄦ埛
+ List<Long> deptIdList = new ArrayList();
+ deptIdList.add(sysUser.getDeptId());
+ deptIdList = getOwnAndChildrenDeptIdList(deptIdList,new ArrayList());//閫掑綊鏌ヨ涓嬪睘閮ㄩ棬涓婚敭
+ List<SysUser> sysUsersResult = userMapper.getOwnAndChildrenSoilderListAll(deptIdList);
+ List<SysUser> sysUsersResultOnline = sysUsersResult.stream().filter(sysUserTest -> sysUserTest.getAppOnlineState().equals("1")).collect(Collectors.toList());//鍦ㄧ嚎鐢ㄦ埛
+ List<SysUser> sysUsersResultOffline = sysUsersResult.stream().filter(sysUserTest -> !sysUserTest.getAppOnlineState().equals("1")).collect(Collectors.toList());//绂荤嚎鐢ㄦ埛
+ List<Map<String,Object>> sysUsersOnlineList = new ArrayList();
+ List<Map<String,Object>> sysUsersOfflineList = new ArrayList();
+ for(SysUser sysUserIn : sysUsersResultOnline){
+ 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());
+ }
+ sysUsersOnlineList.add(map);
+ }
+ List<Map<String,Object>> sysUsersOnlineNearList = new ArrayList();//鍦�200绫冲唴
+ for(Map<String,Object> mapOn : sysUsersOnlineList){
+ Double longitude = (Double) mapOn.get("longitude");
+ Double latitude = (Double) mapOn.get("latitude");
+ double distance = GisUtil.getDistance(para.get("longitude"),para.get("latitude"),longitude,latitude);
+ if(distance <= 200){
+ sysUsersOnlineNearList.add(mapOn);
+ }
+ }
+ Map<String,List<Map<String,Object>>> appMap = new HashMap();
+ appMap.put("onlineApp",sysUsersOnlineNearList);
+ for(SysUser sysUserIn : sysUsersResultOffline){
+ 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());
+ sysUsersOfflineList.add(map);
+ }
+ appMap.put("offlineApp",sysUsersOfflineList);
+ mapResault.put("app",appMap);
+
+ ArdSyUser ardSyUserPara = new ArdSyUser();
+ ardSyUserPara.setSysUserId(commanderId);
+ List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara);//鏌ヨ鎸傛帴鐨勪笁涓�璐﹀彿
+
+ String syURL = "";
+ List<SysConfig> sysConfigResult = sysConfigMapper.selectByType("syCarPT");
+ if(sysConfigResult.size() > 0){
+ syURL = sysConfigResult.get(0).getConfigValue();
+ }
+
+ if(ardSyUserList.size() == 0 || syURL.equals("")){
+ List<Map<String,Object>> onlineCar = new ArrayList();
+ List<Map<String,Object>> offlineCar = new ArrayList();
+ Map<String,List<Map<String,Object>>> carMap = new HashMap();
+ carMap.put("onlineCar",onlineCar);
+ carMap.put("offlineCar",offlineCar);
+ mapResault.put("car",carMap);
+ return mapResault;
+ }
+
+ List<String> carIdList = ardSyCarMapper.selectArdSyCarByDeptIds(deptIdList);
+ String carIds = "";
+ for(String carId : carIdList){
+ carIds = carIds + carId + ",";
+ }
+ carIds = carIds.substring(0,carIds.length() - 1);
+ String passwordMd5 = DigestUtils.md5Hex(ardSyUserList.get(0).getPassword());
+ Map<String,Object> syLoginResult = sYClient.logIn(syURL, passwordMd5, ardSyUserList.get(0).getUserId());
+ String sessionId = (String) syLoginResult.get("sessionId");
+ Map<String,Object> carNearPositionResult = sYClient.getCarNearPositionByCarId(syURL, carIds, ardSyUserList.get(0).getUserId(),sessionId);
+ if(((String)carNearPositionResult.get("rspCode")).equals("1")){
+ List<Map<String,Object>> SYCarPositionList = (List<Map<String, Object>>) carNearPositionResult.get("list");
+ //绛涢�夊湪绾�
+ List<Map<String,Object>> onlineSYCarPositionList = SYCarPositionList.stream().filter(map -> ((String)map.get("stateCn")).startsWith("鍦ㄧ嚎")).collect(Collectors.toList());
+ //绛涢��200绫宠寖鍥村唴
+ List<Map<String,Object>> onlineSYCarPositionNearList = new ArrayList();//鍦�200绫冲唴
+ for(Map<String,Object> mapOn : onlineSYCarPositionList){
+ Double longitude = new BigDecimal((String) mapOn.get("lng")).doubleValue();
+ Double latitude = new BigDecimal((String) mapOn.get("lat")).doubleValue();
+ double distance = GisUtil.getDistance(para.get("longitude"),para.get("latitude"),longitude,latitude);
+ if(distance <= 200){
+ mapOn.put("longitude",longitude);
+ mapOn.put("latitude",latitude);
+ onlineSYCarPositionNearList.add(mapOn);
+ }
+ }
+
+ //for(Map<String,Object> sycar : onlineSYCarPositionList){
+ for(Map<String,Object> sycar : onlineSYCarPositionNearList){
+ Map<String,Object> map = ardSyCarMapper.getArdSyCarAndDeptByCarId((String)sycar.get("carId"));
+ sycar.putAll(map);
+ }
+ //绛涢�夌绾�
+ List<Map<String,Object>> offlineSYCarPositionList = SYCarPositionList.stream().filter(map -> ((String)map.get("stateCn")).startsWith("绂荤嚎")).collect(Collectors.toList());
+ for(Map<String,Object> sycar : offlineSYCarPositionList){
+ Map<String,Object> map = ardSyCarMapper.getArdSyCarAndDeptByCarId((String)sycar.get("carId"));
+ sycar.putAll(map);
+ }
+ Map<String,List<Map<String,Object>>> carMap = new HashMap();
+ //carMap.put("onlineCar",onlineSYCarPositionList);
+ carMap.put("onlineCar",onlineSYCarPositionNearList);
+ carMap.put("offlineCar",offlineSYCarPositionList);
+ mapResault.put("car",carMap);
+ }else{
+ List<Map<String,Object>> onlineCar = new ArrayList();
+ List<Map<String,Object>> offlineCar = new ArrayList();
+ Map<String,List<Map<String,Object>>> carMap = new HashMap();
+ carMap.put("onlineCar",onlineCar);
+ carMap.put("offlineCar",offlineCar);
+ mapResault.put("car",carMap);
+ return mapResault;
+ }
+
+ return mapResault;
+ }
+
+ 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/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 fcb6907..7bd5258 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,10 +251,10 @@
}
}
- @GetMapping("/getAPPSoilderByCommanderId")
- public AjaxResult getAPPSoilderByCommanderId() {
+ @GetMapping("/getOnlineAPPSoilderByCommanderId")
+ public AjaxResult getOnlineAPPSoilderByCommanderId() {
String userId = SecurityUtils.getUserId();
- return success(ardAppPositionService.getAPPSoilderByCommanderId(userId));
+ return success(ardAppPositionService.getOnlineAPPSoilderByCommanderId(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 621853e..68c1db2 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,6 +90,6 @@
public List<ArdAppPosition> getAPPPositionByUserIdAndTime(Map<String,String> para);
- public List<Map<String,Object>> getAPPSoilderByCommanderId(String userId);
+ public List<Map<String,Object>> getOnlineAPPSoilderByCommanderId(String userId);
}
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 8cf5417..837d4fc 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
@@ -493,12 +493,12 @@
}
@Override
- public List<Map<String,Object>> getAPPSoilderByCommanderId(String userId) {
+ public List<Map<String,Object>> getOnlineAPPSoilderByCommanderId(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<SysUser> result = sysUserMapper.getOwnAndChildrenOnlineSoilderList(deptIdList);
List<Map<String,Object>> resultList = new ArrayList();
for(SysUser sysUserIn : result){
Map<String,Object> map = new HashMap();
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 36aa2e0..f132a51 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
@@ -145,5 +145,7 @@
List<SysUser> getOnlinePC(@Param("usersId") String usersId,@Param("onLinePCIdList")List<String> onLinePCIdList);
- List<SysUser> getOwnAndChildrenSoilderList(@Param("deptIdList")List<Long> deptIdList);
+ List<SysUser> getOwnAndChildrenOnlineSoilderList(@Param("deptIdList")List<Long> deptIdList);
+
+ List<SysUser> getOwnAndChildrenSoilderListAll(@Param("deptIdList")List<Long> deptIdList);
}
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
index ab32a54..a014700 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -343,7 +343,7 @@
</foreach>
</select>
- <select id="getOwnAndChildrenSoilderList" resultMap="SysUserOnlyResult">
+ <select id="getOwnAndChildrenOnlineSoilderList" resultMap="SysUserOnlyResult">
select distinct su.user_id,su.dept_id,su.user_name,
concat(su.nick_name,'(',sd.dept_name,')') as nick_name from sys_user su
inner join sys_user_role sur on su.user_id = sur.user_id
@@ -353,7 +353,22 @@
<foreach collection="deptIdList" item="deptId" open="(" close=")" separator=",">
#{deptId}
</foreach>
- and su.app_online_state = '1'
+ and su.app_online_state = '1' and su.status = '0' and su.del_flag = '0'
+ order by su.dept_id asc
+ </select>
+
+ <select id="getOwnAndChildrenSoilderListAll" resultMap="SysUserOnlyResult">
+ select distinct su.user_id,su.dept_id,su.user_name,
+ concat(su.nick_name,'(',sd.dept_name,')') as nick_name,
+ su.app_online_state from sys_user su
+ inner join sys_user_role sur on su.user_id = sur.user_id
+ inner join sys_role sr on sur.role_id = sr.role_id
+ inner join sys_dept sd on su.dept_id = sd.dept_id
+ where sr.role_key = 'appUser' and su.dept_id in
+ <foreach collection="deptIdList" item="deptId" open="(" close=")" separator=",">
+ #{deptId}
+ </foreach>
+ and su.status = '0' and su.del_flag = '0'
order by su.dept_id asc
</select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3