|
|
|
@ -211,11 +211,12 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
// 加一个begintime参数,endtime参数 stream时间戳 从开始时间0点开始,结束时间23.59.59结束
|
|
|
|
|
public int[] selectTdengine(String beginTime, String endTime, Long sceneId) {
|
|
|
|
|
public Map<Object, Integer> selectTdengine(String beginTime, String endTime, Long sceneId) {
|
|
|
|
|
DeviceStatus queryDeviceStatus = new DeviceStatus();
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = queryDeviceStatus.getParams();
|
|
|
|
|
DateTimeFormatter ofPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA);
|
|
|
|
|
System.out.println(ofPattern);
|
|
|
|
|
LocalDate parse = LocalDate.parse(beginTime, ofPattern);
|
|
|
|
|
long begintime = parse.atStartOfDay().toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
|
|
|
|
|
|
@ -232,18 +233,27 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
|
|
|
|
|
|
|
|
|
|
int sum = 0;
|
|
|
|
|
int values[] = new int[10];
|
|
|
|
|
Map<Object,Integer> valuesMap = new HashMap<>();
|
|
|
|
|
//todo 使用id(以解决)
|
|
|
|
|
//map key时间戳,value List<DeviceStatus> 对象
|
|
|
|
|
R<?> r = remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus);
|
|
|
|
|
Map<Long, List<DeviceStatus>> deviceStatusMap = (Map<Long, List<DeviceStatus>>) r.getData();
|
|
|
|
|
List<DeviceStatus> list = (List<DeviceStatus>) remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus);
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
if (list.get(i).getDeviceType()==1) {
|
|
|
|
|
values[i]=hwMonitorUnitMapper.selectReleatedDeviceIdNums(list.get(i).getDeviceId());
|
|
|
|
|
Set<Long> longs = deviceStatusMap.keySet();
|
|
|
|
|
for (Object key:longs){
|
|
|
|
|
List<DeviceStatus> deviceStatuses = deviceStatusMap.get(key);
|
|
|
|
|
for (int i=0;i<deviceStatuses.size();i++){
|
|
|
|
|
if (deviceStatuses.get(i).getDeviceType()==1){
|
|
|
|
|
sum=sum+hwMonitorUnitMapper.selectReleatedDeviceIdNums(list.get(i).getDeviceId());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
values[i] = hwDeviceMapper.selectSumDeviceFlagNot0();
|
|
|
|
|
sum = sum+1;
|
|
|
|
|
}
|
|
|
|
|
valuesMap.put(key,sum);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return values;
|
|
|
|
|
|
|
|
|
|
return valuesMap;
|
|
|
|
|
|
|
|
|
|
//设备类型==网关 根据releated_device_id = 网关设备设备id查询个数
|
|
|
|
|
//网关子设备数+非网关设备数(getDeviceType()!=1)
|
|
|
|
@ -270,14 +280,18 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
|
|
|
|
|
public List<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
|
|
|
|
|
List<HwMonitorUnit> returnList = new ArrayList<>();
|
|
|
|
|
List<Long> tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<HwMonitorUnit> treeList = new ArrayList<>();
|
|
|
|
|
for (HwMonitorUnit hwMonitorUnit:hwMonitorUnits){
|
|
|
|
|
if (!tempList.contains(hwMonitorUnit.getParentId()))
|
|
|
|
|
recursionFn(hwMonitorUnits,hwMonitorUnit);
|
|
|
|
|
returnList.add(hwMonitorUnit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return returnList;
|
|
|
|
|
for (int i = 0; i < returnList.size(); i++){
|
|
|
|
|
if (returnList.get(i).getParentId()==null){
|
|
|
|
|
treeList.add(returnList.get(i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return treeList;
|
|
|
|
|
}
|
|
|
|
|
private void recursionFn(List<HwMonitorUnit> list, HwMonitorUnit t)
|
|
|
|
|
{
|
|
|
|
|