From 75e3b271f869a07cc1535c974c0c3a9b5ae46bed Mon Sep 17 00:00:00 2001 From: zhouhy Date: Mon, 11 Sep 2023 09:20:21 +0800 Subject: [PATCH] =?UTF-8?q?1.1.3=E7=94=B5=E5=AD=90=E5=9B=B4=E6=A0=8F?= =?UTF-8?q?=E6=B0=94=E6=B3=A1=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HwMonitorUnitController.java | 13 +- .../domain/VO/EleMonitorDeviceSumVo.java | 56 +++++++++ .../mapper/HwElectronicFenceMapper.java | 15 ++- .../business/service/IHwDeviceService.java | 1 - .../service/IHwElectronicFenceService.java | 3 + .../impl/HwElectronicFenceServiceImpl.java | 114 ++++++++++++++++++ .../business/HwElectronicFenceMapper.xml | 74 ++++++++++++ 7 files changed, 269 insertions(+), 7 deletions(-) create mode 100644 ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/EleMonitorDeviceSumVo.java diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java index 8dfa598..27505b5 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java @@ -10,6 +10,7 @@ import com.ruoyi.business.domain.HwScene; import com.ruoyi.business.domain.VO.*; import com.ruoyi.business.mapper.HwSceneMapper; import com.ruoyi.business.service.IHwDeviceService; +import com.ruoyi.business.service.IHwElectronicFenceService; import com.ruoyi.business.service.IHwSceneService; import com.ruoyi.common.core.domain.R; import org.springframework.beans.factory.annotation.Autowired; @@ -47,6 +48,8 @@ public class HwMonitorUnitController extends BaseController private IHwDeviceService hwDeviceService; @Autowired private IHwSceneService hwSceneService; + @Autowired + private IHwElectronicFenceService hwElectronicFenceService; @@ -181,16 +184,16 @@ public class HwMonitorUnitController extends BaseController } /** * 按电子围栏定位显示其下设备数量,以及报警的设备数量。 - * @param 场景id + * @param sceneId * */ @PostMapping("/ElectronicNumVo") - public AjaxResult ElectronicNumVo(Long sceneId){ - Integer integer = hwMonitorUnitService.selectElectronicNum(sceneId); - return success(integer); + public TableDataInfo ElectronicNumVo(Long sceneId){ + List eleMonitorDeviceSumVos = hwElectronicFenceService.selectEleTypeNums(sceneId); + return getDataTable(eleMonitorDeviceSumVos); } /** * 获取监控单元详细信息 - * @param 监控单元id + * @param monitorUnitId * */ @PostMapping("/selectMonitorUnitSub") //ok diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/EleMonitorDeviceSumVo.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/EleMonitorDeviceSumVo.java new file mode 100644 index 0000000..7b79be5 --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/EleMonitorDeviceSumVo.java @@ -0,0 +1,56 @@ +package com.ruoyi.business.domain.VO; + +/** + * @ClassName : EleMonitorSumVo + * @Description : + * @Author : + * @Date: 2023-09-07 15:06 + */ +public class EleMonitorDeviceSumVo { + private Long sceneId; + private String monitorUnitId; + private String electronicFenceId; + private Integer sum; + + public String getElectronicFenceId() { + return electronicFenceId; + } + + public void setElectronicFenceId(String electronicFenceId) { + this.electronicFenceId = electronicFenceId; + } + + public Long getSceneId() { + return sceneId; + } + + public void setSceneId(Long sceneId) { + this.sceneId = sceneId; + } + + public String getMonitorUnitId() { + return monitorUnitId; + } + + public void setMonitorUnitId(String monitorUnitId) { + this.monitorUnitId = monitorUnitId; + } + + public Integer getSum() { + return sum; + } + + public void setSum(Integer sum) { + this.sum = sum; + } + + @Override + public String toString() { + return "EleMonitorDeviceSumVo{" + + "sceneId=" + sceneId + + ", monitorUnitId='" + monitorUnitId + '\'' + + ", electronicFenceId='" + electronicFenceId + '\'' + + ", sum=" + sum + + '}'; + } +} diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwElectronicFenceMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwElectronicFenceMapper.java index d28058c..393e87d 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwElectronicFenceMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwElectronicFenceMapper.java @@ -2,6 +2,8 @@ package com.ruoyi.business.mapper; import java.util.List; import com.ruoyi.business.domain.HwElectronicFence; +import com.ruoyi.business.domain.VO.EleMonitorDeviceSumVo; + /** * 电子围栏Mapper接口 @@ -38,7 +40,18 @@ public interface HwElectronicFenceMapper * @return 结果 */ public int insertHwElectronicFence(HwElectronicFence hwElectronicFence); - + //根据传入场景查询电子围栏的类型 + List selectEleTypeBySceneId(Long sceneId); + //查询监控单元下拥有总的设备量 根据监控单元分组 + List selectSumsFromMonitor(Long sceneId); + //查询该场景下各个监控单元下拥有电子围栏设备的数量 + List selectSumsFromMonitorByElectronicFence(Long sceneId); + //查询该场景下拥有电子围栏的设备的数量并按电子围栏分组 + List selectDevicesFromEleBySceneId(Long sceneId); + //当电子围栏下只有监控单元时 + List selectEleOnlyMonitorBySceneId(Long sceneId); + //当电子围栏下只有场景时 + Integer selectEleOnlyScene(Long sceneId); /** * 修改电子围栏 * diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceService.java index 479c2a1..488869e 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceService.java @@ -31,7 +31,6 @@ public interface IHwDeviceService public Map> selectDeviceByDeviceModeByMonitorUnitId(Long monitorUnitId); public Map> selectDeviceModeFunctionByFunctionType(Long monitorUnitId); - public List> getHistoryData(Long deviceId); /** * 查询设备信息列表 diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwElectronicFenceService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwElectronicFenceService.java index 17c3106..caf311a 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwElectronicFenceService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwElectronicFenceService.java @@ -2,6 +2,8 @@ package com.ruoyi.business.service; import java.util.List; import com.ruoyi.business.domain.HwElectronicFence; +import com.ruoyi.business.domain.VO.EleMonitorDeviceSumVo; +import com.ruoyi.business.domain.VO.ElectronicNumVo; /** * 电子围栏Service接口 @@ -22,6 +24,7 @@ public interface IHwElectronicFenceService * 根据场景查询电子围栏信息 * */ public List selectElectronicByScene(Long sceneId); + List selectEleTypeNums(Long sceneId); /** * 查询电子围栏列表 * diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java index 351bd63..c8133e1 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java @@ -1,6 +1,9 @@ package com.ruoyi.business.service.impl; +import java.util.ArrayList; import java.util.List; + +import com.ruoyi.business.domain.VO.EleMonitorDeviceSumVo; import com.ruoyi.common.core.utils.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -37,6 +40,117 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService return hwElectronicFenceMapper.selectElectronicByScene(sceneId); } + @Override + public List selectEleTypeNums(Long sceneId) { + List list = hwElectronicFenceMapper.selectEleTypeBySceneId(sceneId); + list.stream().forEach(v->{}); + List voList = new ArrayList(); + if (list.size()==1){ + if (list.get(0)==1){ + //电子围栏下只有设备 + voList = hwElectronicFenceMapper.selectSumsFromMonitorByElectronicFence(sceneId); + + return voList; + } + else if (list.get(0)==2){ + //电子围栏下只有监控单元 + voList = hwElectronicFenceMapper.selectEleOnlyMonitorBySceneId(sceneId); + return voList; + } + else if (list.get(0)==3){ + //电子围栏下只有场景 + Integer integer = hwElectronicFenceMapper.selectEleOnlyScene(sceneId); + EleMonitorDeviceSumVo eleMonitorDeviceSumVo = new EleMonitorDeviceSumVo(); + eleMonitorDeviceSumVo.setSceneId(sceneId); + eleMonitorDeviceSumVo.setSum(integer); + voList.add(eleMonitorDeviceSumVo); + return voList; + } + } + else if (list.size()==2){ + if (list.get(0)+list.get(1)==3){ + //设备与监控单元 + List devices = new ArrayList<>(); + List monitor = new ArrayList<>(); + //查询场景下的所有设备根据电子围栏分组,在查询场景下的所有监控单元以及下面的设备按电子围栏分组 + //shebei + devices = hwElectronicFenceMapper.selectSumsFromMonitorByElectronicFence(sceneId); + //jiankongdanyuan + monitor = hwElectronicFenceMapper.selectEleOnlyMonitorBySceneId(sceneId); + for (int i=0; i devices = new ArrayList<>(); + + devices = hwElectronicFenceMapper.selectSumsFromMonitorByElectronicFence(sceneId); + Integer aLong = hwElectronicFenceMapper.selectEleOnlyScene(sceneId); + for (int i = 0; i < devices.size();i++){ + aLong = aLong-devices.get(i).getSum(); + } + EleMonitorDeviceSumVo eleMonitorDeviceSumVo = new EleMonitorDeviceSumVo(); + eleMonitorDeviceSumVo.setSceneId(sceneId); + eleMonitorDeviceSumVo.setSum(aLong); + voList.add(eleMonitorDeviceSumVo); + voList.addAll(devices); + return voList; + } + else if (list.get(0)+list.get(1)==5){ + //场景与监控单元 + List monitor = new ArrayList<>(); + monitor=hwElectronicFenceMapper.selectEleOnlyMonitorBySceneId(sceneId); + Integer aLong = hwElectronicFenceMapper.selectEleOnlyScene(sceneId); + for (int i = 0;i devices = new ArrayList<>(); + List monitor = new ArrayList<>(); + //shebei + devices = hwElectronicFenceMapper.selectSumsFromMonitorByElectronicFence(sceneId); + //jiankongdanyuan + monitor = hwElectronicFenceMapper.selectEleOnlyMonitorBySceneId(sceneId); + Integer aLong = hwElectronicFenceMapper.selectEleOnlyScene(sceneId); + for (int i=0; i + + + + + + select electronic_fence_id, electronic_fence_name, scene_id, fence_type, effective_time_flag, time_zone, effective_time, trigger_status, area_shape_flag, area_range, fence_push_flag, fence_push_content, fence_recover_content, remark, create_by, create_time, update_by, update_time, fence_field from hw_electronic_fence @@ -36,7 +42,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and scene_id = #{sceneId} + + + + + + + + + +