From e7ff4f706d31473cfa8cadd2415204e932894e73 Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Thu, 29 Jan 2026 13:05:30 +0800
Subject: [PATCH] 设备共享
---
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.xml | 88 ++++++++++++++++++++++++++++++++++++++++----
1 files changed, 80 insertions(+), 8 deletions(-)
diff --git a/drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.xml b/drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.xml
index 73d37ea..a4a2dae 100644
--- a/drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.xml
+++ b/drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.xml
@@ -185,10 +185,19 @@
AND effective_range_km is not null
AND effective_range_km > 0
<if test="deptList != null and deptList.size > 0">
- and create_dept in
+ and (create_dept in
<foreach collection="deptList" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
+ <!-- 或者设备是共享给当前部门的 -->
+ <if test="currentDeptId != null and currentDeptId != '' ">
+ or id in (
+ SELECT device_id FROM ja_fw_device_per_share
+ WHERE loan_to_dept_id = #{currentDeptId}
+ AND is_deleted = 0
+ )
+ </if>
+ )
</if>
UNION ALL -- 合并拆分的反制部分
@@ -211,10 +220,19 @@
AND effective_range_km is not null
AND effective_range_km > 0
<if test="deptList != null and deptList.size > 0">
- and create_dept in
+ and (create_dept in
<foreach collection="deptList" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
+ <!-- 或者设备是共享给当前部门的 -->
+ <if test="currentDeptId != null and currentDeptId != '' ">
+ or id in (
+ SELECT device_id FROM ja_fw_device_per_share
+ WHERE loan_to_dept_id = #{currentDeptId}
+ AND is_deleted = 0
+ )
+ </if>
+ )
</if>
) AS temp
GROUP BY split_device_type
@@ -319,10 +337,19 @@
and
effective_range_km > 0
<if test="deptList != null and deptList.size > 0">
- and create_dept in
+ and (create_dept in
<foreach collection="deptList" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
+ <!-- 或者设备是共享给当前部门的 -->
+ <if test="currentDeptId != null and currentDeptId != '' ">
+ or id in (
+ SELECT device_id FROM ja_fw_device_per_share
+ WHERE loan_to_dept_id = #{currentDeptId}
+ AND is_deleted = 0
+ )
+ </if>
+ )
</if>
) AS deviceCount,
-- 无线电设备数量
@@ -339,10 +366,19 @@
and
effective_range_km > 0
<if test="deptList != null and deptList.size > 0">
- and create_dept in
+ and (create_dept in
<foreach collection="deptList" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
+ <!-- 或者设备是共享给当前部门的 -->
+ <if test="currentDeptId != null and currentDeptId != '' ">
+ or id in (
+ SELECT device_id FROM ja_fw_device_per_share
+ WHERE loan_to_dept_id = #{currentDeptId}
+ AND is_deleted = 0
+ )
+ </if>
+ )
</if>
) AS radioCount,
-- 光电设备数量
@@ -355,10 +391,19 @@
and effective_range_km is not null
and effective_range_km > 0
<if test="deptList != null and deptList.size > 0">
- and create_dept in
+ and (create_dept in
<foreach collection="deptList" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
+ <!-- 或者设备是共享给当前部门的 -->
+ <if test="currentDeptId != null and currentDeptId != '' ">
+ or id in (
+ SELECT device_id FROM ja_fw_device_per_share
+ WHERE loan_to_dept_id = #{currentDeptId}
+ AND is_deleted = 0
+ )
+ </if>
+ )
</if>
) AS opticalCount,
-- 雷达设备数量
@@ -370,10 +415,19 @@
and effective_range_km is not null
and effective_range_km > 0
<if test="deptList != null and deptList.size > 0">
- and create_dept in
+ and (create_dept in
<foreach collection="deptList" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
+ <!-- 或者设备是共享给当前部门的 -->
+ <if test="currentDeptId != null and currentDeptId != '' ">
+ or id in (
+ SELECT device_id FROM ja_fw_device_per_share
+ WHERE loan_to_dept_id = #{currentDeptId}
+ AND is_deleted = 0
+ )
+ </if>
+ )
</if>
) AS radarCount,
-- 设备告警
@@ -385,10 +439,19 @@
and effective_range_km is not null
and effective_range_km > 0
<if test="deptList != null and deptList.size > 0">
- and create_dept in
+ and (create_dept in
<foreach collection="deptList" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
+ <!-- 或者设备是共享给当前部门的 -->
+ <if test="currentDeptId != null and currentDeptId != '' ">
+ or id in (
+ SELECT device_id FROM ja_fw_device_per_share
+ WHERE loan_to_dept_id = #{currentDeptId}
+ AND is_deleted = 0
+ )
+ </if>
+ )
</if>
) AS deviceAlarmCount
</select>
@@ -443,10 +506,19 @@
and d.belong_dept = #{param2.belongDept}
</if>
<if test="param2.deptList != null and param2.deptList.size > 0">
- and d.create_dept in
+ and (d.create_dept in
<foreach collection="param2.deptList" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
+ <!-- 或者设备是共享给当前部门的 -->
+ <if test="param2.currentDeptId != null and param2.currentDeptId != '' ">
+ or d.id in (
+ SELECT device_id FROM ja_fw_device_per_share
+ WHERE loan_to_dept_id = #{param2.currentDeptId}
+ AND is_deleted = 0
+ )
+ </if>
+ )
</if>
<if test="param2.deviceStatusList != null and param2.deviceStatusList != ''">
and d.status in
--
Gitblit v1.9.3