@ -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 ;
}
/ * *
* 查 询 电 子 围 栏 列 表
*