From fac4425e76ee53a0a77373d87cb0563387364f0e Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期五, 10 十一月 2023 13:58:15 +0800
Subject: [PATCH] 增加递归获取部门和雷达组织
---
ard-work/src/main/java/com/ruoyi/device/radar/mapper/ArdEquipRadarMapper.java | 9 ++++
ard-work/src/main/java/com/ruoyi/device/radar/service/IArdEquipRadarService.java | 11 +++++
ard-work/src/main/java/com/ruoyi/device/radar/controller/ArdEquipRadarController.java | 8 ++++
ard-work/src/main/java/com/ruoyi/device/radar/service/impl/ArdEquipRadarServiceImpl.java | 70 ++++++++++++++++++++++++++++++++++-
ard-work/src/main/resources/mapper/device/ArdEquipRadarMapper.xml | 3 +
5 files changed, 99 insertions(+), 2 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/device/radar/controller/ArdEquipRadarController.java b/ard-work/src/main/java/com/ruoyi/device/radar/controller/ArdEquipRadarController.java
index 42ea28a..af3ce6b 100644
--- a/ard-work/src/main/java/com/ruoyi/device/radar/controller/ArdEquipRadarController.java
+++ b/ard-work/src/main/java/com/ruoyi/device/radar/controller/ArdEquipRadarController.java
@@ -1,6 +1,7 @@
package com.ruoyi.device.radar.controller;
import java.util.List;
+import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@@ -127,4 +128,11 @@
return radarClient.guideInfoBack(guideInfo);
}
+ @GetMapping("/getDeptAndRadar")
+ @ApiOperation("鑾峰彇閮ㄩ棬鍜岄浄杈�")
+ public AjaxResult getDeptAndCamera() {
+ Map deptAndCamera = ardEquipRadarService.getChildDeptAndRadar(true);
+ return AjaxResult.success(deptAndCamera);
+ }
+
}
diff --git a/ard-work/src/main/java/com/ruoyi/device/radar/mapper/ArdEquipRadarMapper.java b/ard-work/src/main/java/com/ruoyi/device/radar/mapper/ArdEquipRadarMapper.java
index 4bfb025..0432220 100644
--- a/ard-work/src/main/java/com/ruoyi/device/radar/mapper/ArdEquipRadarMapper.java
+++ b/ard-work/src/main/java/com/ruoyi/device/radar/mapper/ArdEquipRadarMapper.java
@@ -66,4 +66,13 @@
* 閫氳繃闆疯揪id鎵惧埌鍏宠仈濉斾笂鐨勫ぇ鍏夌數
*/
ArdCameras getCameraByRadar(String radarId);
+
+
+ /**
+ * 鏍规嵁閮ㄩ棬ID鏌ヨ鎸傝浇鐨勯浄杈�
+ *
+ * @param deptId 閮ㄩ棬ID
+ * @return 閮ㄩ棬鍒楄〃
+ */
+ public List<ArdEquipRadar> selectArdRadarsByDeptId(Long deptId);
}
diff --git a/ard-work/src/main/java/com/ruoyi/device/radar/service/IArdEquipRadarService.java b/ard-work/src/main/java/com/ruoyi/device/radar/service/IArdEquipRadarService.java
index d651b69..5fdb180 100644
--- a/ard-work/src/main/java/com/ruoyi/device/radar/service/IArdEquipRadarService.java
+++ b/ard-work/src/main/java/com/ruoyi/device/radar/service/IArdEquipRadarService.java
@@ -1,6 +1,8 @@
package com.ruoyi.device.radar.service;
import java.util.List;
+import java.util.Map;
+
import com.ruoyi.device.radar.domain.ArdEquipRadar;
/**
@@ -58,4 +60,13 @@
* @return 缁撴灉
*/
public int deleteArdEquipRadarById(String id);
+ /**
+ * @鎻忚堪 鑾峰彇鏈儴闂ㄤ互涓嬬殑鎵�鏈夐浄杈惧拰閮ㄩ棬
+ * @鍙傛暟 []
+ * @杩斿洖鍊� java.util.Map
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/6/2 10:58
+ * @淇敼浜哄拰鍏跺畠淇℃伅
+ */
+ public Map getChildDeptAndRadar(Boolean disabled);
}
diff --git a/ard-work/src/main/java/com/ruoyi/device/radar/service/impl/ArdEquipRadarServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/radar/service/impl/ArdEquipRadarServiceImpl.java
index e8436d8..250264f 100644
--- a/ard-work/src/main/java/com/ruoyi/device/radar/service/impl/ArdEquipRadarServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/device/radar/service/impl/ArdEquipRadarServiceImpl.java
@@ -1,16 +1,26 @@
package com.ruoyi.device.radar.service.impl;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import com.ruoyi.common.annotation.DataScope;
+import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
+import com.ruoyi.device.camera.domain.ArdCameras;
+import com.ruoyi.device.channel.domain.ArdChannel;
+import com.ruoyi.system.mapper.SysDeptMapper;
+import com.ruoyi.utils.tools.ArdTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.device.radar.mapper.ArdEquipRadarMapper;
import com.ruoyi.device.radar.domain.ArdEquipRadar;
import com.ruoyi.device.radar.service.IArdEquipRadarService;
+
+import javax.annotation.Resource;
/**
* radarService涓氬姟灞傚鐞�
@@ -21,9 +31,10 @@
@Service
public class ArdEquipRadarServiceImpl implements IArdEquipRadarService
{
- @Autowired
+ @Resource
private ArdEquipRadarMapper ardEquipRadarMapper;
-
+ @Resource
+ private SysDeptMapper sysDeptMapper;
/**
* 鏌ヨradar
*
@@ -102,4 +113,59 @@
{
return ardEquipRadarMapper.deleteArdEquipRadarById(id);
}
+
+
+ /**
+ * @鎻忚堪 鑾峰彇鏈儴闂ㄤ互涓嬬殑鎵�鏈夐浄杈惧拰閮ㄩ棬
+ * @鍙傛暟 []
+ * @杩斿洖鍊� java.util.Map
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/6/2 10:58
+ * @淇敼浜哄拰鍏跺畠淇℃伅
+ */
+
+ @Override
+ public Map getChildDeptAndRadar(Boolean disabled) {
+ Long deptId = SecurityUtils.getDeptId();
+ SysDept sysDept = sysDeptMapper.selectDeptById(deptId);
+ Map<String, Object> map = fetchChildDepartments(sysDept, disabled);
+ return map;
+ }
+
+ /**
+ * @鎻忚堪 閫掑綊鏌ヨ
+ * @鍙傛暟 [sysDept]
+ * @杩斿洖鍊� java.util.Map<java.lang.String, java.lang.Object>
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/6/2 14:38
+ * @淇敼浜哄拰鍏跺畠淇℃伅
+ */
+ public Map<String, Object> fetchChildDepartments(SysDept sysDept, Boolean disabled) {
+ Map<String, Object> map = new HashMap<>();
+ map.put("name", sysDept.getDeptName());
+ map.put("deptId", sysDept.getDeptId());
+ map.put("disabled", disabled);
+ List<SysDept> sysDepts = sysDeptMapper.selectNextChildrenDeptById(sysDept.getDeptId());
+ List<ArdEquipRadar> ardRadars = ardEquipRadarMapper.selectArdRadarsByDeptId(sysDept.getDeptId());
+ List<Object> childList = new ArrayList<>();
+ for (SysDept childDept : sysDepts) {
+ Map<String, Object> childMap = new HashMap<>();
+ childMap.put("name", childDept.getDeptName());
+ childMap.put("deptId", childDept.getDeptId());
+ childMap.put("disabled", disabled);
+ Map<String, Object> map1 = fetchChildDepartments(childDept, disabled);
+ childMap.putAll(map1);
+ childList.add(childMap);
+ }
+ if (ardRadars.size() > 0) {
+ for (ArdEquipRadar radar : ardRadars) {
+ Map<String, Object> cameraMap = ArdTool.convertEntityToMap(radar);
+ childList.add(cameraMap);
+ }
+ }
+ map.put("children", childList);
+ return map;
+
+ }
+
}
diff --git a/ard-work/src/main/resources/mapper/device/ArdEquipRadarMapper.xml b/ard-work/src/main/resources/mapper/device/ArdEquipRadarMapper.xml
index f11397e..5338123 100644
--- a/ard-work/src/main/resources/mapper/device/ArdEquipRadarMapper.xml
+++ b/ard-work/src/main/resources/mapper/device/ArdEquipRadarMapper.xml
@@ -201,4 +201,7 @@
INNER JOIN ard_cameras ac on aer.tower_id=ac.tower_id
where aer.id=#{radarId} limit 1
</select>
+ <select id="selectArdRadarsByDeptId" parameterType="Long" resultMap="ArdEquipRadarResult">
+ select * from ard_equip_radar where dept_id = #{deptId}
+ </select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3