1.1.3电子围栏气泡图

dev
zhouhy 1 year ago
parent 231697d090
commit 75e3b271f8

@ -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<EleMonitorDeviceSumVo> eleMonitorDeviceSumVos = hwElectronicFenceService.selectEleTypeNums(sceneId);
return getDataTable(eleMonitorDeviceSumVos);
}
/**
*
* @param id
* @param monitorUnitId
* */
@PostMapping("/selectMonitorUnitSub")
//ok

@ -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 +
'}';
}
}

@ -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<Integer> selectEleTypeBySceneId(Long sceneId);
//查询监控单元下拥有总的设备量 根据监控单元分组
List<EleMonitorDeviceSumVo> selectSumsFromMonitor(Long sceneId);
//查询该场景下各个监控单元下拥有电子围栏设备的数量
List<EleMonitorDeviceSumVo> selectSumsFromMonitorByElectronicFence(Long sceneId);
//查询该场景下拥有电子围栏的设备的数量并按电子围栏分组
List<EleMonitorDeviceSumVo> selectDevicesFromEleBySceneId(Long sceneId);
//当电子围栏下只有监控单元时
List<EleMonitorDeviceSumVo> selectEleOnlyMonitorBySceneId(Long sceneId);
//当电子围栏下只有场景时
Integer selectEleOnlyScene(Long sceneId);
/**
*
*

@ -31,7 +31,6 @@ public interface IHwDeviceService
public Map<String, Map<String, Object>> selectDeviceByDeviceModeByMonitorUnitId(Long monitorUnitId);
public Map<String, Map<String, Object>> selectDeviceModeFunctionByFunctionType(Long monitorUnitId);
public List<Map<String, Object>> getHistoryData(Long deviceId);
/**
*

@ -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<HwElectronicFence> selectElectronicByScene(Long sceneId);
List<EleMonitorDeviceSumVo> selectEleTypeNums(Long sceneId);
/**
*
*

@ -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<EleMonitorDeviceSumVo> selectEleTypeNums(Long sceneId) {
List<Integer> list = hwElectronicFenceMapper.selectEleTypeBySceneId(sceneId);
list.stream().forEach(v->{});
List<EleMonitorDeviceSumVo> voList = new ArrayList<EleMonitorDeviceSumVo>();
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<EleMonitorDeviceSumVo> devices = new ArrayList<>();
List<EleMonitorDeviceSumVo> monitor = new ArrayList<>();
//查询场景下的所有设备根据电子围栏分组,在查询场景下的所有监控单元以及下面的设备按电子围栏分组
//shebei
devices = hwElectronicFenceMapper.selectSumsFromMonitorByElectronicFence(sceneId);
//jiankongdanyuan
monitor = hwElectronicFenceMapper.selectEleOnlyMonitorBySceneId(sceneId);
for (int i=0; i<devices.size(); i++){
for (int j = 0;j<monitor.size();j++){
if(devices.get(i).getElectronicFenceId()==monitor.get(j).getElectronicFenceId()){
monitor.get(j).setSum(monitor.get(j).getSum()-devices.get(i).getSum());
voList.addAll(devices);
voList.addAll(monitor);
}
}
}
return voList;
}
else if (list.get(0)+list.get(1)==4){
//设备与场景
List<EleMonitorDeviceSumVo> 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<EleMonitorDeviceSumVo> monitor = new ArrayList<>();
monitor=hwElectronicFenceMapper.selectEleOnlyMonitorBySceneId(sceneId);
Integer aLong = hwElectronicFenceMapper.selectEleOnlyScene(sceneId);
for (int i = 0;i<monitor.size();i++){
aLong = aLong-monitor.get(i).getSum();
}
EleMonitorDeviceSumVo eleMonitorDeviceSumVo = new EleMonitorDeviceSumVo();
eleMonitorDeviceSumVo.setSceneId(sceneId);
eleMonitorDeviceSumVo.setSum(aLong);
voList.add(eleMonitorDeviceSumVo);
voList.addAll(monitor);
return voList;
}
}else if (list.size()==3){
List<EleMonitorDeviceSumVo> devices = new ArrayList<>();
List<EleMonitorDeviceSumVo> monitor = new ArrayList<>();
//shebei
devices = hwElectronicFenceMapper.selectSumsFromMonitorByElectronicFence(sceneId);
//jiankongdanyuan
monitor = hwElectronicFenceMapper.selectEleOnlyMonitorBySceneId(sceneId);
Integer aLong = hwElectronicFenceMapper.selectEleOnlyScene(sceneId);
for (int i=0; i<devices.size(); i++){
for (int j = 0;j<monitor.size();j++){
if(devices.get(i).getElectronicFenceId()==monitor.get(j).getElectronicFenceId()){
monitor.get(j).setSum(monitor.get(j).getSum()-devices.get(i).getSum());
}
}
}
for (int i=0; i<monitor.size(); i++){
aLong = aLong - monitor.get(i).getSum();
}
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);
voList.addAll(monitor);
}
return voList;
}
/**
*
*

@ -25,6 +25,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="fenceField" column="fence_field" />
</resultMap>
<resultMap id="EleMonitorDeviceSumVoResult" type="EleMonitorDeviceSumVo">
<result property="sceneId" column="scene_id" />
<result property="monitorUnitId" column="monitor_unit_id"/>
<result property="electronicFenceId" column="electronic_fence_id"/>
<result property="sum" column="sum"/>
</resultMap>
<sql id="selectHwElectronicFenceVo">
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"
<if test="sceneId !=null and sceneId !=''">and scene_id = #{sceneId}</if>
</where>
</select>
<!--根据传入场景查询电子围栏的类型-->
<select id="selectEleTypeBySceneId" parameterType="List" resultType="Integer">
SELECT DISTINCT
target_type
FROM
hw_fence_target
WHERE
electronic_fence_id = (
SELECT
electronic_fence_id
FROM
hw_electronic_fence
WHERE
scene_id = #{sceneId}
)
</select>
<!-- 查询监控单元下拥有总的设备量 新增电子围栏id分层-->
<select id="selectSumsFromMonitor" parameterType="Long" resultMap="EleMonitorDeviceSumVoResult">
SELECT
monitor_unit_id,b.electronic_fence_id,
count(*) AS sum
FROM
hw_device AS a
LEFT JOIN (
SELECT
b.target_id,b.electronic_fence_id
FROM
hw_electronic_fence AS a
LEFT JOIN hw_fence_target AS b ON a.electronic_fence_id = b.target_id
WHERE
a.scene_id = #{sceneId}
AND a.fence_type = '2'
) AS b ON a.monitor_unit_id = b.target_id
GROUP BY
monitor_unit_id,b.electronic_fence_id
</select>
<!-- //查询该场景下拥有电子围栏的设备的数量并按电子围栏分组 todo 获取target里的数量 已发布 -->
<select id="selectSumsFromMonitorByElectronicFence" parameterType="Long" resultMap="EleMonitorDeviceSumVoResult">
select electronic_fence_id,count(*)as sum from hw_fence_target where electronic_fence_id = ( SELECT electronic_fence_id from hw_electronic_fence where scene_id = #{sceneId}
)GROUP BY electronic_fence_id
</select>
<select id="selectDevicesFromEleBySceneId" parameterType="Long" resultMap="EleMonitorDeviceSumVoResult">
SELECT
d.electronic_fence_id,
count(*) AS sum
FROM
hw_device AS c
LEFT JOIN hw_fence_target AS d ON c.device_id = d.target_id
WHERE
device_id = (
SELECT
target_id
FROM
hw_fence_target AS a
LEFT JOIN ( SELECT * FROM hw_electronic_fence WHERE scene_id = #{sceneId} AND fence_type = '1' ) AS b ON a.electronic_fence_id = b.electronic_fence_id
)
GROUP BY
d.electronic_fence_id
</select>
<!---->
<select id="selectEleOnlyMonitorBySceneId" parameterType="Long" resultMap="EleMonitorDeviceSumVoResult">
select b.electronic_fence_id,count(*) from hw_device as a
left join hw_fence_target as b on a.device_id = b.target_id
where a.scene_id = #{sceneId} and a.device_status ='1' group by b.electronic_fence_id
</select>
<select id="selectEleOnlyScene" parameterType="Long" resultType="Integer">
select count(*) from hw_device where scene_id = #{sceneId} where device_status = '1'
</select>
<select id="selectHwElectronicFenceList" parameterType="HwElectronicFence" resultMap="HwElectronicFenceResult">
<include refid="selectHwElectronicFenceVo"/>
<where>

Loading…
Cancel
Save