|
@@ -483,12 +483,13 @@ public class IotStaticController {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IotTdParamsMapper iotTdParamsMapper;
|
|
private IotTdParamsMapper iotTdParamsMapper;
|
|
|
- @GetMapping("/td/ly/chart/{deviceName}/{identifier}")
|
|
|
|
|
- public CommonResult<ImmutableMap> getTdChartLy(@PathVariable("deviceName") String deviceName, @PathVariable("identifier") String identifier, @RequestParam("beginTime") String beginTime, @RequestParam("endTime") String endTime) {
|
|
|
|
|
|
|
+ @GetMapping("/td/ly/chart")
|
|
|
|
|
+ public CommonResult<ImmutableMap> getTdChartLy( @RequestParam("pageSize") Integer pageSize, @RequestParam("deviceCode") String deviceCode, @RequestParam(value = "identifier", required = false) String identifier,
|
|
|
|
|
+ @RequestParam("beginTime") String beginTime, @RequestParam("endTime") String endTime) {
|
|
|
// if (StringUtils.isBlank(identifier)) {
|
|
// if (StringUtils.isBlank(identifier)) {
|
|
|
// return null;
|
|
// return null;
|
|
|
// }
|
|
// }
|
|
|
- List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectByCodeIn(Collections.singleton(deviceName));
|
|
|
|
|
|
|
+ List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectByCodeIn(Collections.singleton(deviceCode));
|
|
|
if (CollUtil.isEmpty(iotDeviceDOS)) {
|
|
if (CollUtil.isEmpty(iotDeviceDOS)) {
|
|
|
throw new ServiceException(new ErrorCode(111,"不存在设备"));
|
|
throw new ServiceException(new ErrorCode(111,"不存在设备"));
|
|
|
}
|
|
}
|
|
@@ -500,10 +501,10 @@ public class IotStaticController {
|
|
|
List<ThingsModelDTO> rows = JSON.parseArray(JSON.toJSONString(tableDataInfo.getRows()), ThingsModelDTO.class);
|
|
List<ThingsModelDTO> rows = JSON.parseArray(JSON.toJSONString(tableDataInfo.getRows()), ThingsModelDTO.class);
|
|
|
Timestamp start1 = generateTimestamp(beginTime);
|
|
Timestamp start1 = generateTimestamp(beginTime);
|
|
|
Timestamp end1 = generateTimestamp(endTime);
|
|
Timestamp end1 = generateTimestamp(endTime);
|
|
|
- Integer i = deviceMapper.tableIfExist(deviceName.toLowerCase());
|
|
|
|
|
|
|
+ Integer i = deviceMapper.tableIfExist(deviceCode.toLowerCase());
|
|
|
if (i==1) {
|
|
if (i==1) {
|
|
|
if (StringUtils.isNotBlank(identifier)&&!"undefined".equals(identifier)) {
|
|
if (StringUtils.isNotBlank(identifier)&&!"undefined".equals(identifier)) {
|
|
|
- List<DeviceVO> deviceVOS = tdDeviceMapper.selectAllBtTimeAndIdentifier(deviceName.toLowerCase(), identifier, start1, end1);
|
|
|
|
|
|
|
+ List<DeviceVO> deviceVOS = tdDeviceMapper.selectAllBtTimeAndidentifierAll(deviceCode.toLowerCase(), identifier, start1, end1,pageSize);
|
|
|
deviceVOS.forEach(deviceVO->{
|
|
deviceVOS.forEach(deviceVO->{
|
|
|
deviceVO.setTimestamp(deviceVO.getTs().getTime());
|
|
deviceVO.setTimestamp(deviceVO.getTs().getTime());
|
|
|
deviceVO.setValue(Objects.nonNull(deviceVO.getLogValue())?Double.valueOf(deviceVO.getLogValue()):null);
|
|
deviceVO.setValue(Objects.nonNull(deviceVO.getLogValue())?Double.valueOf(deviceVO.getLogValue()):null);
|
|
@@ -511,18 +512,23 @@ public class IotStaticController {
|
|
|
List<DeviceVO> collect = deviceVOS.stream().sorted(Comparator.comparing(DeviceVO::getTimestamp).reversed()).collect(Collectors.toList());
|
|
List<DeviceVO> collect = deviceVOS.stream().sorted(Comparator.comparing(DeviceVO::getTimestamp).reversed()).collect(Collectors.toList());
|
|
|
return success(ImmutableMap.of("property", rows, "data",collect));
|
|
return success(ImmutableMap.of("property", rows, "data",collect));
|
|
|
} else {
|
|
} else {
|
|
|
- List<DeviceVO> deviceVOS = tdDeviceMapper.selectAllBtTime(deviceName.toLowerCase(), start1, end1);
|
|
|
|
|
|
|
+ List<DeviceVO> deviceVOS = tdDeviceMapper.selectAllBtTime(deviceCode.toLowerCase(), start1, end1, pageSize);
|
|
|
deviceVOS.forEach(deviceVO->{
|
|
deviceVOS.forEach(deviceVO->{
|
|
|
deviceVO.setTimestamp(deviceVO.getTs().getTime());
|
|
deviceVO.setTimestamp(deviceVO.getTs().getTime());
|
|
|
deviceVO.setValue(Objects.nonNull(deviceVO.getLogValue())?Double.valueOf(deviceVO.getLogValue()):null);
|
|
deviceVO.setValue(Objects.nonNull(deviceVO.getLogValue())?Double.valueOf(deviceVO.getLogValue()):null);
|
|
|
|
|
+ rows.stream().filter(e -> e.getIdentifier().equals(deviceVO.getIdentity())).findFirst().ifPresent(deviceVO1->{
|
|
|
|
|
+ deviceVO.setIdentity(deviceVO1.getModelName());
|
|
|
|
|
+ });
|
|
|
|
|
+ deviceVO.setSerialNumber(deviceCode);
|
|
|
|
|
+ deviceVO.setDeviceName(iotDeviceDO.getDeviceName());
|
|
|
});
|
|
});
|
|
|
List<DeviceVO> collect = deviceVOS.stream().sorted(Comparator.comparing(DeviceVO::getTimestamp).reversed()).collect(Collectors.toList());
|
|
List<DeviceVO> collect = deviceVOS.stream().sorted(Comparator.comparing(DeviceVO::getTimestamp).reversed()).collect(Collectors.toList());
|
|
|
- return success(ImmutableMap.of("property", rows, "data",collect));
|
|
|
|
|
|
|
+ return success(ImmutableMap.of( "data",collect));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
List<DeviceVO> deviceVOS = new ArrayList<>();
|
|
List<DeviceVO> deviceVOS = new ArrayList<>();
|
|
|
- return success(ImmutableMap.of("property", rows, "data",deviceVOS));
|
|
|
|
|
|
|
+ return success(ImmutableMap.of( "data",deviceVOS));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|