1.1.3 监控单元Controller修改

dev
zhouhy 1 year ago
parent 656c9b47a3
commit 93bf5a3dcd

File diff suppressed because it is too large Load Diff

@ -195,8 +195,8 @@ public class HwMonitorPlatformController extends BaseController {
* @param sceneId id * @param sceneId id
* */ * */
@PostMapping("/getDeviceOperations") @PostMapping("/getDeviceOperations")
public Integer selectTdengine(String beginTime,String endTime,Long sceneId){ public int[] selectTdengine(String beginTime,String endTime,Long sceneId){
int ints = hwMonitorUnitService.selectTdengine(beginTime,endTime,sceneId); int ints[] = hwMonitorUnitService.selectTdengine(beginTime,endTime,sceneId);
return ints; return ints;
} }
/** /**

@ -21,6 +21,7 @@ public interface HwDeviceMapper
*/ */
public HwDevice selectHwDeviceByDeviceId(Long deviceId); public HwDevice selectHwDeviceByDeviceId(Long deviceId);
List<HwDevice> selectDeviceByMonitorId(Long monitorUnitId); List<HwDevice> selectDeviceByMonitorId(Long monitorUnitId);
Integer selectSumDeviceFlagNot0();
/** /**
* 3. * 3.

@ -40,7 +40,7 @@ public interface HwMonitorUnitMapper
* */ * */
public List<HwMonitorUnit> selectLimitSubMonitorUnit(); public List<HwMonitorUnit> selectLimitSubMonitorUnit();
Integer selectReleatedDeviceIdNums(Long deviceCode); Integer selectReleatedDeviceIdNums(Long deviceCode);
Integer selectDeviceNums(); String selectDeviceNums();
Integer selectSubDeviceSum(Long sceneId); Integer selectSubDeviceSum(Long sceneId);
/** /**

@ -71,7 +71,7 @@ public interface IHwMonitorUnitService
* tdengine * tdengine
* *
* @return*/ * @return*/
public int selectTdengine(String beginTime,String endTime,Long sceneId); public int[] selectTdengine(String beginTime, String endTime, Long sceneId);
/** /**
* *
* *

@ -8,16 +8,13 @@ import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.github.pagehelper.PageHelper;
import com.ruoyi.business.domain.HwDevice; import com.ruoyi.business.domain.HwDevice;
import com.ruoyi.business.domain.HwElectronicFence;
import com.ruoyi.business.domain.VO.*; import com.ruoyi.business.domain.VO.*;
import com.ruoyi.business.mapper.HwDeviceMapper; import com.ruoyi.business.mapper.HwDeviceMapper;
import com.ruoyi.business.mapper.HwElectronicFenceMapper; import com.ruoyi.business.mapper.HwElectronicFenceMapper;
import com.ruoyi.common.core.constant.TdEngineConstants; import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.tdengine.api.RemoteTdEngineService; import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.DeviceStatus; import com.ruoyi.tdengine.api.domain.DeviceStatus;
import com.ruoyi.tdengine.api.domain.TdSelectDto; import com.ruoyi.tdengine.api.domain.TdSelectDto;
@ -108,17 +105,38 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
public AllNumsVo selectAllNums() { public AllNumsVo selectAllNums() {
//监控单元 //监控单元
String monitor = hwMonitorUnitMapper.selectSubSetNums(); String monitor = hwMonitorUnitMapper.selectSubSetNums();
Integer integer = hwMonitorUnitMapper.selectDeviceNums(); String integer = hwMonitorUnitMapper.selectDeviceNums();
System.out.println(monitor+" dsaas "+integer);
Integer monitor1 = 0;
Integer monitor2 = 0;
AllNumsVo vo = new AllNumsVo(); AllNumsVo vo = new AllNumsVo();
vo.setSubSum(Integer.valueOf(monitor)); if (monitor == null){
vo.setSum(integer); monitor1 = 0;
}
else {
monitor1 = Integer.valueOf(monitor);
}
if (integer == null){
monitor2 = 0;
}
else {
monitor2 = Integer.valueOf(integer);
}
vo.setSubSum(monitor1);
vo.setSum(monitor2);
return vo; return vo;
} }
public static void main(String[] args) {
String str1 = "1";
String str2 = null;
int q = Integer.valueOf(str2);
System.out.println(q);
}
@Override @Override
public List<AllNumsVo> selectSenceAllNums() { public List<AllNumsVo> selectSenceAllNums() {
List<AllNumsVo> allNumsVos = hwMonitorUnitMapper.selectAllNums(); List<AllNumsVo> allNumsVos = hwMonitorUnitMapper.selectAllNums();
@ -191,7 +209,7 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
@Override @Override
// 加一个begintime参数endtime参数 stream时间戳 从开始时间0点开始结束时间23.59.59结束 // 加一个begintime参数endtime参数 stream时间戳 从开始时间0点开始结束时间23.59.59结束
public int selectTdengine(String beginTime,String endTime,Long sceneId) { public int[] selectTdengine(String beginTime, String endTime, Long sceneId) {
DeviceStatus queryDeviceStatus = new DeviceStatus(); DeviceStatus queryDeviceStatus = new DeviceStatus();
Map<String, Object> params = queryDeviceStatus.getParams(); Map<String, Object> params = queryDeviceStatus.getParams();
@ -209,21 +227,21 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
if (sceneId != null) { if (sceneId != null) {
queryDeviceStatus.setSceneId(sceneId); queryDeviceStatus.setSceneId(sceneId);
} }
int value = 0;
int sum = 0; int sum = 0;
int values[] = new int[10];
//todo 使用id(以解决) //todo 使用id(以解决)
//map key时间戳value List<DeviceStatus> 对象 //map key时间戳value List<DeviceStatus> 对象
List<DeviceStatus> list = (List<DeviceStatus>) remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus); List<DeviceStatus> list = (List<DeviceStatus>) remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus);
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
if (list.get(i).getDeviceType()==1) { if (list.get(i).getDeviceType()==1) {
sum =sum+ hwMonitorUnitMapper.selectReleatedDeviceIdNums(list.get(i).getDeviceId()); values[i]=hwMonitorUnitMapper.selectReleatedDeviceIdNums(list.get(i).getDeviceId());
} }
else { else {
value++; values[i] = hwDeviceMapper.selectSumDeviceFlagNot0();
} }
value = value+sum;
} }
return value; return values;
//设备类型==网关 根据releated_device_id = 网关设备设备id查询个数 //设备类型==网关 根据releated_device_id = 网关设备设备id查询个数
//网关子设备数+非网关设备数getDeviceType()=1 //网关子设备数+非网关设备数getDeviceType()=1

@ -97,13 +97,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectAllNums" resultMap="AllNumsVoResult"> <select id="selectAllNums" resultMap="AllNumsVoResult">
select scene_id,count(*) as sub_sum from select scene_id,count(*) as sub_sum from
(select monitor_unit_id,scene_id from hw_monitor_unit (select monitor_unit_id,scene_id from hw_monitor_unit
where monitor_unit_id not in (select parent_id from hw_monitor_unit))as temp where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null))as temp
GROUP BY scene_id GROUP BY scene_id
</select> </select>
<select id="selectSubSetNums" resultType="String"> <select id="selectSubSetNums" resultType="String">
select count(*)from hw_monitor_unit select count(*)from hw_monitor_unit
where monitor_unit_id not in (select parent_id from hw_monitor_unit) where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null)
</select> </select>
<select id="selectDeviceNums" resultType="String"> <select id="selectDeviceNums" resultType="String">
select count(*) as sum from hw_device select count(*) as sum from hw_device
@ -139,13 +139,13 @@ where device_status = '1'GROUP BY scene_id
<!-- 分页查询在impl实现分页--> <!-- 分页查询在impl实现分页-->
<select id="selectLimitSubMonitorUnit" resultMap="HwMonitorUnitResult"> <select id="selectLimitSubMonitorUnit" resultMap="HwMonitorUnitResult">
select * from hw_monitor_unit where monitor_unit_id select * from hw_monitor_unit where monitor_unit_id
not in (select parent_id from hw_monitor_unit) not in (select parent_id from hw_monitor_unit where parent_id is not null)
</select> </select>
<!-- 查询最子集监控单元使用sceneid进行分组--> <!-- 查询最子集监控单元使用sceneid进行分组-->
<select id="selectMonitorPercentage" resultMap="HwMonitorUnitVoResult"> <select id="selectMonitorPercentage" resultMap="HwMonitorUnitVoResult">
select scene_id,count(*) as sum from (select monitor_unit_id,scene_id select scene_id,count(*) as sum from (select monitor_unit_id,scene_id
from hw_monitor_unit where monitor_unit_id not in from hw_monitor_unit where monitor_unit_id not in
(select parent_id from hw_monitor_unit))as temp (select parent_id from hw_monitor_unit where parent_id is not null))as temp
GROUP BY scene_id order by sum desc GROUP BY scene_id order by sum desc
</select> </select>
<!-- 先通过报警信息表查询报警的监控单元id与数量在查询监控单元的名字--> <!-- 先通过报警信息表查询报警的监控单元id与数量在查询监控单元的名字-->
@ -158,7 +158,7 @@ select b.monitor_unit_id,b.monitor_unit_name,sum from
<select id="selectSubDeviceSum" parameterType="Long" resultType="Integer"> <select id="selectSubDeviceSum" parameterType="Long" resultType="Integer">
select count(*) from (select monitor_unit_id,scene_id select count(*) from (select monitor_unit_id,scene_id
from hw_monitor_unit where monitor_unit_id not in from hw_monitor_unit where monitor_unit_id not in
(select parent_id from hw_monitor_unit))as temp where scene_id = #{sceneId} (select parent_id from hw_monitor_unit where parent_id is not null))as temp where scene_id = #{sceneId}
</select> </select>

Loading…
Cancel
Save