diff --git a/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/RemoteTdEngineService.java b/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/RemoteTdEngineService.java index 62038da..4c65bbb 100644 --- a/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/RemoteTdEngineService.java +++ b/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/RemoteTdEngineService.java @@ -63,8 +63,8 @@ public interface RemoteTdEngineService { @PostMapping("/tdengine/getDeviceStatusList") R>> getDeviceStatusList(@Validated @RequestBody DeviceStatus queryDeviceStatus, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); - - + @PostMapping("/tdengine/getDeviceLocation") + R> getDeviceLocation(@Validated @RequestBody TdSelectDto tdSelectDto, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); @PostMapping("/tdengine/dropTable") R dropTable(@Validated @RequestBody TdTableDropVo tdTableDropVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); } diff --git a/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/factory/RemoteTdEngineFallbackFactory.java b/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/factory/RemoteTdEngineFallbackFactory.java index 624cc50..58db51f 100644 --- a/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/factory/RemoteTdEngineFallbackFactory.java +++ b/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/factory/RemoteTdEngineFallbackFactory.java @@ -102,6 +102,11 @@ public class RemoteTdEngineFallbackFactory implements FallbackFactory> getDeviceLocation(TdSelectDto tdSelectDto, String source) { + return R.fail("获取设备位置失败:" + throwable.getMessage()); + } + @Override public R dropTable(TdTableDropVo tdTableDropVo, String source) { return R.fail("drop子表失败:" + throwable.getMessage()); diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutConfigController.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutConfigController.java index e2a5d44..f7c55cc 100644 --- a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutConfigController.java +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutConfigController.java @@ -2,17 +2,29 @@ package com.ruoyi.basic.controller; +import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; +import com.baomidou.dynamic.datasource.creator.DataSourceCreator; +import com.baomidou.dynamic.datasource.creator.DruidDataSourceCreator; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ruoyi.basic.domain.HwTemplate; import com.ruoyi.basic.domain.LayoutConfig; +import com.ruoyi.basic.domain.LayoutDesc; +import com.ruoyi.basic.service.HwTemplateService; import com.ruoyi.basic.service.LayoutConfigService; +import com.ruoyi.basic.service.LayoutDescService; import com.ruoyi.common.core.web.domain.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.sql.DataSource; import java.util.List; import java.util.Map; @@ -30,6 +42,10 @@ public class LayoutConfigController { */ @Resource private LayoutConfigService layoutConfigService; + @Autowired + private LayoutDescService layoutDescService; + @Autowired + private HwTemplateService hwTemplateService; /** * 分页查询 @@ -89,10 +105,10 @@ public class LayoutConfigController { // 添加组件新配置 @PostMapping("/insertLayoutConfig") public AjaxResult insertLayoutConfig(@RequestBody Map config) throws JsonProcessingException { - System.out.println(config.get("items")); List items = (List)config.get("items"); String option = config.get("option").toString(); - return layoutConfigService.insertSceneConfig(items,option); + String layoutName = config.get("layoutDesc").toString(); + return layoutConfigService.insertSceneConfig(items,option,layoutName); } // 查询所有场景 @@ -106,5 +122,4 @@ public class LayoutConfigController { public AjaxResult selectConfigById(String sceneId){ return layoutConfigService.selectConfigById(sceneId); } - } diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutDescDao.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutDescDao.java index 7ec9159..a5f0832 100644 --- a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutDescDao.java +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutDescDao.java @@ -4,6 +4,7 @@ package com.ruoyi.basic.mapper; import com.ruoyi.basic.domain.LayoutDesc; import java.util.List; +import java.util.Map; /** * 布局配置表(LayoutConfig)表数据库访问层 @@ -18,4 +19,7 @@ public interface LayoutDescDao { List selectAllScenes(); + + LayoutDesc queryById(); + } diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutConfigService.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutConfigService.java index 9f67332..96324fa 100644 --- a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutConfigService.java +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutConfigService.java @@ -57,10 +57,11 @@ public interface LayoutConfigService { */ boolean deleteById(Long configId); - AjaxResult insertSceneConfig(List items, String option) throws JsonProcessingException; + AjaxResult insertSceneConfig(List items, String option,String layoutName) throws JsonProcessingException; AjaxResult selectConfigById(String sceneId); AjaxResult selectAllScenes(); + } diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutConfigServiceImpl.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutConfigServiceImpl.java index bdf17bb..30781fa 100644 --- a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutConfigServiceImpl.java +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutConfigServiceImpl.java @@ -20,10 +20,7 @@ import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; +import java.util.*; /** * 布局配置表(LayoutConfig)表服务实现类 @@ -99,12 +96,13 @@ public class LayoutConfigServiceImpl implements LayoutConfigService { } @Override - public AjaxResult insertSceneConfig(List items, String option) throws JsonProcessingException { + public AjaxResult insertSceneConfig(List items, String option,String layoutName) throws JsonProcessingException { String layoutId = UUID.randomUUID().toString().replaceAll("-", ""); LoginUser loginUser = SecurityUtils.getLoginUser(); LayoutDesc layoutDesc = new LayoutDesc(); layoutDesc.setLayoutId(layoutId); layoutDesc.setSceneConfig(option); + layoutDesc.setLayoutDesc(layoutName); // layoutDesc.setCreateBy(loginUser.getUsername()); Date date = new Date(); layoutDesc.setCreateTime(date); diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutDescServiceImpl.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutDescServiceImpl.java index f7e4eaf..dc59083 100644 --- a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutDescServiceImpl.java +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutDescServiceImpl.java @@ -27,7 +27,7 @@ public class LayoutDescServiceImpl implements LayoutDescService { @Override public LayoutDesc queryById(Long layoutId) { - return null; + return layoutDescDao.queryById(); } @Override diff --git a/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutDescDao.xml b/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutDescDao.xml index 140d41d..2bc4d19 100644 --- a/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutDescDao.xml +++ b/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutDescDao.xml @@ -13,11 +13,8 @@ - + @@ -76,6 +73,9 @@ + diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java index 9066b95..dc30410 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java @@ -6,6 +6,7 @@ import java.util.Map; import com.ruoyi.business.domain.HwScene; import com.ruoyi.business.domain.VO.HwSceneVo; import com.ruoyi.business.domain.VO.TreeDeviceVo; +import org.apache.ibatis.annotations.Param; /** * 场景信息Mapper接口 @@ -74,4 +75,6 @@ public interface HwSceneMapper * 查询场景信息集合 * */ public List selectHwSceneListReturnMap(); + + HwScene selectHwSceneByTenantId(@Param("tenantId") Long tenantId); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java index 8b27011..2ffcf9b 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java @@ -80,6 +80,8 @@ public class HwSceneServiceImpl implements IHwSceneService { @Override public List selectHwSceneJoinList(HwSceneVo hwScene) { + Long tenantId = SecurityUtils.getTenantId(); + hwScene.setTenantId(tenantId); hwScene.setSceneStatus(HwDictConstants.SCENE_STATUS_NORMAL); return hwSceneMapper.selectHwSceneVoList(hwScene); } diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml index 28f7aec..1d3f0cd 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml @@ -207,4 +207,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +