From 2ba9230d91a80e81d8fa594b82bf886a4ed902f1 Mon Sep 17 00:00:00 2001
From: rain <1679827795@qq.com>
Date: Tue, 13 Jan 2026 16:55:48 +0800
Subject: [PATCH] 防区优化
---
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwDefenseZoneServiceImpl.java | 63 ++++++-------------------------
1 files changed, 13 insertions(+), 50 deletions(-)
diff --git a/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwDefenseZoneServiceImpl.java b/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwDefenseZoneServiceImpl.java
index 27d1da6..ee0147b 100644
--- a/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwDefenseZoneServiceImpl.java
+++ b/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwDefenseZoneServiceImpl.java
@@ -21,21 +21,17 @@
import org.sxkj.common.utils.HeaderUtils;
import org.sxkj.fw.area.dto.FwDefenseZoneDTO;
import org.sxkj.fw.area.entity.FwAreaDivideEntity;
-import org.sxkj.fw.area.entity.FwDefenseSceneEntity;
import org.sxkj.fw.area.entity.FwDefenseZoneEntity;
import org.sxkj.fw.area.vo.FwDefenseZoneVO;
import org.sxkj.fw.area.excel.FwDefenseZoneExcel;
import org.sxkj.fw.area.mapper.FwDefenseZoneMapper;
import org.sxkj.fw.area.service.IFwAreaDivideService;
-import org.sxkj.fw.area.service.IFwDefenseSceneService;
import org.sxkj.fw.area.service.IFwDefenseZoneService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -53,9 +49,6 @@
*/
@Service
public class FwDefenseZoneServiceImpl extends BaseServiceImpl<FwDefenseZoneMapper, FwDefenseZoneEntity> implements IFwDefenseZoneService {
-
- @Resource
- private IFwDefenseSceneService fwDefenseSceneService;
@Resource
private IFwAreaDivideService fwAreaDivideService;
@@ -101,28 +94,17 @@
record.setSceneCount(0);
record.setDeviceCount(0);
record.setAreaCount(0);
- record.setZoneArea(BigDecimal.ZERO);
}
return;
}
- Map<Long, List<Long>> sceneDeviceMap = new HashMap<>();
- if (!sceneIdSet.isEmpty()) {
- List<FwDefenseSceneEntity> sceneList = fwDefenseSceneService.listByIds(sceneIdSet);
- for (FwDefenseSceneEntity scene : sceneList) {
- if (scene == null || scene.getId() == null) {
- continue;
- }
- sceneDeviceMap.put(scene.getId(), parseIdList(scene.getDeviceIds()));
- }
- }
- Map<Long, BigDecimal> areaSizeMap = new HashMap<>();
+ Map<Long, List<Long>> areaDeviceMap = new HashMap<>();
if (!areaIdSet.isEmpty()) {
List<FwAreaDivideEntity> areaList = fwAreaDivideService.listByIds(areaIdSet);
for (FwAreaDivideEntity area : areaList) {
if (area == null || area.getId() == null) {
continue;
}
- areaSizeMap.put(area.getId(), area.getAreaSize());
+ areaDeviceMap.put(area.getId(), parseIdList(area.getDeviceIds()));
}
}
@@ -139,15 +121,14 @@
}
Set<Long> areaIds = new HashSet<>(zoneAreaIds);
Set<Long> deviceIds = new HashSet<>();
- for (Long sceneId : uniqueSceneIds) {
- List<Long> sceneDeviceIds = sceneDeviceMap.get(sceneId);
- if (sceneDeviceIds != null) {
- deviceIds.addAll(sceneDeviceIds);
+ for (Long areaId : areaIds) {
+ List<Long> areaDeviceIds = areaDeviceMap.get(areaId);
+ if (areaDeviceIds != null) {
+ deviceIds.addAll(areaDeviceIds);
}
}
record.setAreaCount(areaIds.size());
record.setDeviceCount(deviceIds.size());
- record.setZoneArea(sumAreaSize(areaIds, areaSizeMap));
}
}
@@ -172,24 +153,6 @@
}
return idList;
}
-
- private BigDecimal sumAreaSize(Set<Long> areaIds, Map<Long, BigDecimal> areaSizeMap) {
- if (areaIds == null || areaIds.isEmpty()) {
- return BigDecimal.ZERO;
- }
- BigDecimal total = BigDecimal.ZERO;
- for (Long areaId : areaIds) {
- BigDecimal areaSize = areaSizeMap.get(areaId);
- if (areaSize != null) {
- total = total.add(areaSize);
- }
- }
- if (BigDecimal.ZERO.compareTo(total) == 0) {
- return BigDecimal.ZERO;
- }
- return total.setScale(2, RoundingMode.HALF_UP);
- }
-
@Override
public List<FwDefenseZoneExcel> exportFwDefenseZone(Wrapper<FwDefenseZoneEntity> queryWrapper) {
@@ -234,19 +197,19 @@
deptId = null;
}
}
- String areaCode = HeaderUtils.getAreaCode();
- if (StringUtil.isBlank(areaCode)) {
- areaCode = fwDefenseZone.getAreaCode();
- }
+// String areaCode = HeaderUtils.getAreaCode();
+// if (StringUtil.isBlank(areaCode)) {
+// areaCode = fwDefenseZone.getAreaCode();
+// }
Date now = new Date();
fwDefenseZone.setCreateUser(userId);
fwDefenseZone.setUpdateUser(userId);
if (deptId != null) {
fwDefenseZone.setCreateDept(deptId);
}
- if (StringUtil.isNotBlank(areaCode)) {
- fwDefenseZone.setAreaCode(areaCode);
- }
+// if (StringUtil.isNotBlank(areaCode)) {
+// fwDefenseZone.setAreaCode(areaCode);
+// }
fwDefenseZone.setCreateTime(now);
fwDefenseZone.setUpdateTime(now);
}
--
Gitblit v1.9.3