diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java index 6a4cd40..0b434b0 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java @@ -53,6 +53,7 @@ public class HwDeviceController extends BaseController { @Autowired private IHwSceneService hwSceneService; + /** * 查询设备信息列表 */ @@ -251,4 +252,10 @@ public class HwDeviceController extends BaseController { return AjaxResult.success(hwDeviceModeService.getDeviceByModel(modelId)); } + @GetMapping("/getDeviceLocation") + private AjaxResult getDeviceLocation(Long deviceId){ + Map deviceLocation = hwDeviceService.getDeviceLocation(deviceId); + return AjaxResult.success(deviceLocation); + } + } diff --git a/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/controller/TdEngineController.java b/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/controller/TdEngineController.java index 232af38..03b8c3a 100644 --- a/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/controller/TdEngineController.java +++ b/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/controller/TdEngineController.java @@ -329,6 +329,25 @@ public class TdEngineController { return R.fail(e.getMessage()); } } + @InnerAuth + @PostMapping("/getDeviceLocation") + public R getDeviceLocation(@Validated @RequestBody TdSelectDto tdSelectDto) { + try { + return R.ok(this.tdEngineService.getDeviceLocation(tdSelectDto)); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + /** * @return R>> diff --git a/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/mapper/TdEngineMapper.java b/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/mapper/TdEngineMapper.java index 0e0a03c..70b638f 100644 --- a/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/mapper/TdEngineMapper.java +++ b/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/mapper/TdEngineMapper.java @@ -163,6 +163,8 @@ public interface TdEngineMapper { void dropTable(@Param("databaseName") String databaseName, @Param("tableName") String tableName); + Map getDeviceLocation(TdSelectDto tdSelectDto); + // /** // * 检查表是否存在 // * @param dataBaseName diff --git a/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/service/ITdEngineService.java b/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/service/ITdEngineService.java index 1ab6212..5aa074c 100644 --- a/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/service/ITdEngineService.java +++ b/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/service/ITdEngineService.java @@ -141,6 +141,8 @@ public interface ITdEngineService { * @date 2024-04-20 11:08 */ public void dropTable(String databaseName, String tableName) throws Exception; + + Map getDeviceLocation(TdSelectDto tdSelectDto); // void initSTableFrame(String msg) throws Exception; // List> getRealtimeData(SelectVisualDto selectVisualDto); diff --git a/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/service/impl/TdEngineServiceImpl.java b/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/service/impl/TdEngineServiceImpl.java index 134c706..a1859d8 100644 --- a/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/service/impl/TdEngineServiceImpl.java +++ b/ruoyi-modules/hw-tdengine/src/main/java/com/ruoyi/tdengine/service/impl/TdEngineServiceImpl.java @@ -242,6 +242,10 @@ public class TdEngineServiceImpl implements ITdEngineService { } + @Override + public Map getDeviceLocation(TdSelectDto tdSelectDto) { + return this.tdEngineMapper.getDeviceLocation(tdSelectDto); + } /** * @param: databaseName diff --git a/ruoyi-modules/hw-tdengine/src/main/resources/mapper/tdengine/TdEngineMapper.xml b/ruoyi-modules/hw-tdengine/src/main/resources/mapper/tdengine/TdEngineMapper.xml index f85667c..e5d99c3 100644 --- a/ruoyi-modules/hw-tdengine/src/main/resources/mapper/tdengine/TdEngineMapper.xml +++ b/ruoyi-modules/hw-tdengine/src/main/resources/mapper/tdengine/TdEngineMapper.xml @@ -309,6 +309,10 @@ group by timetruncate(ts,1d),devicetype,onlinestatus,devicecode order by ts +