Explorar o código

视频告警设备名称、连油数采查询

Zimo hai 11 horas
pai
achega
e78853c822

+ 8 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/alarm/IotVideoAlarmController.java

@@ -4,7 +4,9 @@ import cn.iocoder.yudao.module.pms.controller.admin.alarm.vo.IotVideoAlarmPageRe
 import cn.iocoder.yudao.module.pms.controller.admin.alarm.vo.IotVideoAlarmRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.alarm.vo.IotVideoAlarmSaveReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.alarm.IotVideoAlarmDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.device.YfIotDeviceDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.sip.device.channel.YfSipDeviceChannelDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.yanfan.device.YfIotDeviceMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.yanfan.sip.device.channel.YfSipDeviceChannelMapper;
 import cn.iocoder.yudao.module.pms.hik.HikIsapiService;
 import cn.iocoder.yudao.module.pms.service.alarm.IotVideoAlarmService;
@@ -53,6 +55,8 @@ public class IotVideoAlarmController {
     private YfSipDeviceChannelMapper yfsipDeviceChannelMapper;
     @Resource
     private HikIsapiService hikIsapiService;
+    @Resource
+    private YfIotDeviceMapper yfIotDeviceMapper;
 
     @PostMapping("/create")
     @Operation(summary = "创建资料")
@@ -98,7 +102,10 @@ public class IotVideoAlarmController {
             if (StringUtils.isNotBlank(e.getBusinessChannel())) {
                 YfSipDeviceChannelDO yfSipDeviceChannelDO = yfsipDeviceChannelMapper.selectSipDeviceChannelByChannelSipId(e.getBusinessChannel());
                 if (yfSipDeviceChannelDO != null) {
-                    iotVideoAlarmRespVO.setDeviceName(yfSipDeviceChannelDO.getDeviceSipId());
+                    if (Objects.nonNull(yfSipDeviceChannelDO.getDeviceSipId())&&StringUtils.isNotBlank(yfSipDeviceChannelDO.getDeviceSipId())) {
+                        YfIotDeviceDO yfIotDeviceDO = yfIotDeviceMapper.selectDeviceBySerialNumber(yfSipDeviceChannelDO.getDeviceSipId());
+                        iotVideoAlarmRespVO.setDeviceName(yfIotDeviceDO.getDeviceName());
+                    }
                     iotVideoAlarmRespVO.setChannelName(yfSipDeviceChannelDO.getChannelName());
                 }
             }

+ 14 - 8
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/stat/IotStaticController.java

@@ -483,12 +483,13 @@ public class IotStaticController {
 
     @Autowired
     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)) {
 //            return null;
 //        }
-        List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectByCodeIn(Collections.singleton(deviceName));
+        List<IotDeviceDO> iotDeviceDOS = iotDeviceMapper.selectByCodeIn(Collections.singleton(deviceCode));
         if (CollUtil.isEmpty(iotDeviceDOS)) {
             throw new ServiceException(new ErrorCode(111,"不存在设备"));
         }
@@ -500,10 +501,10 @@ public class IotStaticController {
         List<ThingsModelDTO> rows = JSON.parseArray(JSON.toJSONString(tableDataInfo.getRows()), ThingsModelDTO.class);
         Timestamp start1 = generateTimestamp(beginTime);
         Timestamp end1 = generateTimestamp(endTime);
-        Integer i = deviceMapper.tableIfExist(deviceName.toLowerCase());
+        Integer i = deviceMapper.tableIfExist(deviceCode.toLowerCase());
         if (i==1) {
             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->{
                     deviceVO.setTimestamp(deviceVO.getTs().getTime());
                     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());
                 return success(ImmutableMap.of("property", rows, "data",collect));
             } else {
-                List<DeviceVO> deviceVOS = tdDeviceMapper.selectAllBtTime(deviceName.toLowerCase(), start1, end1);
+                List<DeviceVO> deviceVOS = tdDeviceMapper.selectAllBtTime(deviceCode.toLowerCase(), start1, end1, pageSize);
                 deviceVOS.forEach(deviceVO->{
                     deviceVO.setTimestamp(deviceVO.getTs().getTime());
                     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());
-                return success(ImmutableMap.of("property", rows, "data",collect));
+                return success(ImmutableMap.of( "data",collect));
             }
 
         } else {
             List<DeviceVO> deviceVOS = new ArrayList<>();
-            return success(ImmutableMap.of("property", rows, "data",deviceVOS));
+            return success(ImmutableMap.of( "data",deviceVOS));
         }
     }
 

+ 12 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/TDDeviceMapper.java

@@ -123,19 +123,27 @@ public interface TDDeviceMapper extends BaseMapperX<TDDeviceDO> {
     List<DeviceTdVO> batchGetYesInfo(@Param("queries") List<DeviceTdVO> queries);
 
 
-    @Select("SELECT   _WSTART AS ts, AVG(CAST(log_value AS FLOAT)) as log_value   FROM iot_log.device_${deviceName} " +
+    @Select("SELECT   _WSTART AS ts, AVG(CAST(log_value AS FLOAT)) as log_value,identity   FROM iot_log.device_${deviceName} " +
             "WHERE ts between #{start} and #{end} and identity = #{identifier}  INTERVAL(1m) " )
     @DS("tdengine")
     @TenantIgnore
     @InterceptorIgnore(tenantLine = "true")
     List<DeviceVO> selectAllBtTimeAndIdentifier(@Param("deviceName") String tableName, @Param("identifier") String identifier,@Param("start") Timestamp start,@Param("end") Timestamp end);
 
-    @Select("SELECT   _WSTART AS ts, AVG(CAST(log_value AS FLOAT)) as log_value   FROM iot_log.device_${deviceName} " +
-            "WHERE ts between #{start} and #{end}INTERVAL(1m) " )
+    @Select("SELECT   ts, CAST(log_value AS FLOAT) as log_value,identity   FROM iot_log.device_${deviceName} " +
+            "WHERE ts between #{start} and #{end} ORDER BY ts DESC LIMIT #{pageSize} " )
     @DS("tdengine")
     @TenantIgnore
     @InterceptorIgnore(tenantLine = "true")
-    List<DeviceVO> selectAllBtTime(@Param("deviceName") String tableName,@Param("start") Timestamp start,@Param("end") Timestamp end);
+    List<DeviceVO> selectAllBtTime(@Param("deviceName") String tableName,@Param("start") Timestamp start,@Param("end") Timestamp end, @Param("pageSize") Integer pageSize);
+
+    @Select("SELECT   ts, CAST(log_value AS FLOAT) as log_value,identity   FROM iot_log.device_${deviceName} " +
+            "WHERE ts between #{start} and #{end} and identity = #{identifier} ORDER BY ts DESC LIMIT #{pageSize} " )
+    @DS("tdengine")
+    @TenantIgnore
+    @InterceptorIgnore(tenantLine = "true")
+    List<DeviceVO> selectAllBtTimeAndidentifierAll(@Param("deviceName") String tableName,@Param("identifier") String identifier,@Param("start") Timestamp start,@Param("end") Timestamp end, @Param("pageSize") Integer pageSize);
+
 
     @InterceptorIgnore(tenantLine = "true")
     @DS("tdengine")