From 638c705c6a23974ff6aea3229bc297aad0683acc Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期五, 26 一月 2024 13:24:39 +0800
Subject: [PATCH] 单兵端查看三一车辆位置提交
---
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml | 7 +++
ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml | 7 +++
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java | 2
ard-work/src/main/java/com/ruoyi/sy/mapper/ArdSyCarMapper.java | 2 +
ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java | 13 ++++++
ard-work/src/main/java/com/ruoyi/sy/service/IArdSyCarService.java | 1
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java | 88 ++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 119 insertions(+), 1 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java b/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
index 4bd854e..90f4213 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
@@ -478,4 +478,17 @@
return AjaxResult.success(mapDetail);
}
+ @GetMapping("/getOnlineSYCarPosition")
+ @ApiOperation("鍗曞叺绔煡鐪嬪凡閫氳繃瀹℃壒鐨勫湪绾夸笁涓�杞﹁締浣嶇疆")
+ public AjaxResult getOnlineSYCarPosition() {
+ String soilderId = SecurityUtils.getUserId();
+ try{
+ Map<String,Object> result = ardSyCarService.getOnlineSYCarPosition(soilderId);
+ return AjaxResult.success(result);
+ }catch(Exception e){
+ e.printStackTrace();
+ return AjaxResult.error();
+ }
+ }
+
}
diff --git a/ard-work/src/main/java/com/ruoyi/sy/mapper/ArdSyCarMapper.java b/ard-work/src/main/java/com/ruoyi/sy/mapper/ArdSyCarMapper.java
index 46d0b90..c70b53e 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/mapper/ArdSyCarMapper.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/mapper/ArdSyCarMapper.java
@@ -84,4 +84,6 @@
* 鏍规嵁杞﹁締id鏌ヨ涓変竴杞﹁締鍙婂搴旈儴闂�
*/
public Map<String, Object> getArdSyCarAndDeptByCarId(String carId);
+
+ public List<String> selectArdSyCarByDeptIds(@Param("deptIdList") List<Long> deptIdList);
}
diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/IArdSyCarService.java b/ard-work/src/main/java/com/ruoyi/sy/service/IArdSyCarService.java
index 59c3e58..557ae98 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/IArdSyCarService.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/IArdSyCarService.java
@@ -164,4 +164,5 @@
Map<String, Object> getAlarmHPfmCountDetail(String sessionId,String usersId,String carId,String startTime,String endTime,String syURL);
+ public Map<String,Object> getOnlineSYCarPosition(String soilderId);
}
diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
index 03de3dd..8df1d76 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
@@ -15,7 +15,11 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.dtflys.forest.annotation.Var;
import com.github.pagehelper.PageInfo;
+import com.ruoyi.app.application.domain.ArdAppApplication;
+import com.ruoyi.app.application.mapper.ArdAppApplicationMapper;
+import com.ruoyi.app.position.mapper.ArdAppPositionMapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache;
@@ -24,6 +28,7 @@
import com.ruoyi.sy.domain.ArdAccessFence;
import com.ruoyi.sy.param.ArdSyCarParam;
import com.ruoyi.sy.vo.ArdSyCarVo;
+import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.utils.gis.GisUtil;
import com.ruoyi.utils.gis.Point;
import com.ruoyi.scheduling.domian.SchedulingParam;
@@ -87,6 +92,12 @@
RedisCache redisCache;
@Resource
private ArdSyCarDayMapper ardSyCarDayMapper;
+
+ @Resource
+ private ArdAppApplicationMapper ardAppApplicationMapper;
+
+ @Resource
+ private SysDeptMapper sysDeptMapper;
@Value("${minio.endpoint}")
private String minioEndpoint;
@@ -1304,4 +1315,81 @@
return sYClient.getAlarmHPfmCountDetail(syURL,carId,sessionId,startTime,endTime);
}
+ @Override
+ public Map<String, Object> getOnlineSYCarPosition(String soilderId) {
+ Map<String,Object> result = new HashMap();
+ ArdSyUser ardSyUserPara = new ArdSyUser();
+ ardSyUserPara.setSysUserId(soilderId);
+ List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara);
+ if(ardSyUserList.size() == 0){
+ result.put("code","0");
+ result.put("msg","鐧诲綍鐢ㄦ埛鏈寕鎺ヤ笁涓�杞﹁締璐﹀彿");
+ result.put("SYCarPositionList",new ArrayList());
+ return result;
+ }
+ ArdAppApplication ardAppApplicationPara = new ArdAppApplication();
+ ardAppApplicationPara.setSoilderId(soilderId);
+ ardAppApplicationPara.setApplicationType("SYCar");
+ ardAppApplicationPara.setState("1");
+ List<ArdAppApplication> ardAppApplicationList = ardAppApplicationMapper.selectArdAppApplicationList(ardAppApplicationPara);
+ if(ardAppApplicationList.size() == 0){
+ result.put("code","0");
+ result.put("msg","鐧诲綍鐢ㄦ埛鏈粡鎸囨尌绔悓鎰�");
+ result.put("SYCarPositionList",new ArrayList());
+ return result;
+ }
+ SysUser sysUser = userMapper.selectUserById(soilderId);//鑾峰彇绯荤粺鐢ㄦ埛
+ List<Long> deptIdList = new ArrayList();
+ deptIdList.add(sysUser.getDeptId());
+ deptIdList = getOwnAndChildrenDeptIdList(deptIdList,new ArrayList());//閫掑綊鏌ヨ涓嬪睘閮ㄩ棬涓婚敭
+ List<String> carIdList = ardSyCarMapper.selectArdSyCarByDeptIds(deptIdList);
+ String carIds = "";
+ for(String carId : carIdList){
+ carIds = carIds + carId + ",";
+ }
+ carIds = carIds.substring(0,carIds.length() - 1);
+ String syURL = "";
+ List<SysConfig> sysConfigResult = sysConfigMapper.selectByType("syCarPT");
+ if(sysConfigResult.size() > 0){
+ syURL = sysConfigResult.get(0).getConfigValue();
+ }else{
+ result.put("code","0");
+ result.put("msg","涓変竴杞﹁締url娌℃湁褰曞叆");
+ result.put("SYCarPositionList",new ArrayList());
+ return result;
+ }
+ 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")){
+ result.put("code","1");
+ result.put("msg","涓変竴杞﹁締鏌ヨ鎴愬姛");
+ List<Map<String,Object>> SYCarPositionList = (List<Map<String, Object>>) carNearPositionResult.get("list");
+ //绛涢�夊湪绾�
+ SYCarPositionList = SYCarPositionList.stream().filter(map -> ((String)map.get("stateCn")).startsWith("鍦ㄧ嚎")).collect(Collectors.toList());
+ for(Map<String,Object> sycar : SYCarPositionList){
+ Map<String,Object> map = ardSyCarMapper.getArdSyCarAndDeptByCarId((String)sycar.get("carId"));
+ sycar.putAll(map);
+ }
+ result.put("SYCarPositionList",SYCarPositionList);
+ return result;
+ }else{
+ result.put("code","0");
+ result.put("msg","涓変竴杞﹁締鏌ヨ澶辫触");
+ result.put("SYCarPositionList",new ArrayList());
+ 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/ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml b/ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml
index b47d788..b5e728a 100644
--- a/ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml
+++ b/ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml
@@ -114,4 +114,11 @@
inner join sys_dept sd on asc0.dept_id = sd.dept_id
where asc0.car_id = #{carId}
</select>
+ <select id="selectArdSyCarByDeptIds" parameterType="java.lang.Long" resultType="java.lang.String">
+ select asy.car_id from ard_sy_car asy
+ where asy.dept_id in
+ <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
+ #{deptId}
+ </foreach>
+ </select>
</mapper>
\ No newline at end of file
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
index 22db9eb..4f436ee 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
@@ -125,5 +125,5 @@
*/
public int deleteDeptById(Long deptId);
-
+ public List<Long> getChildrenDeptIdList(@Param("deptIdList")List<Long> deptIdList);
}
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
index 5049c2e..0ade36d 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -158,4 +158,11 @@
update sys_dept set del_flag = '2' where dept_id = #{deptId}
</delete>
+ <select id="getChildrenDeptIdList" resultType="java.lang.Long">
+ select distinct sd.dept_id from sys_dept sd
+ where sd.parent_id in
+ <foreach collection="deptIdList" item="deptId" separator="," open="(" close=")">
+ #{deptId}
+ </foreach>
+ </select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3