diff --git a/springboot/wumei-admin/src/main/resources/application-druid.yml b/springboot/wumei-admin/src/main/resources/application-druid.yml index f8135ae5..0a5defb7 100644 --- a/springboot/wumei-admin/src/main/resources/application-druid.yml +++ b/springboot/wumei-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://localhost/wumei-smart?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: root - password: admin + url: jdbc:mysql://kerwincui.mysql.rds.aliyuncs.com/wumei-smart?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: kerwincui + password: 1a2b3c4D # 从库数据源 slave: # 从数据源开关/默认关闭 @@ -22,7 +22,7 @@ spring: # 默认不启用TDengine,true=启用,false=不启用 enabled: false driverClassName: com.taosdata.jdbc.TSDBDriver - url: jdbc:TAOS://127.0.0.1:6030/wumei_smart_log?timezone=Asia/Beijing&charset=utf-8 + url: jdbc:TAOS://wumei.live:6030/wumei_smart_log?timezone=Asia/Beijing&charset=utf-8 username: root password: taosdata dbName: wumei_smart_log diff --git a/springboot/wumei-admin/src/main/resources/application.yml b/springboot/wumei-admin/src/main/resources/application.yml index 60297c88..a66cb2fa 100644 --- a/springboot/wumei-admin/src/main/resources/application.yml +++ b/springboot/wumei-admin/src/main/resources/application.yml @@ -9,7 +9,7 @@ ruoyi: # 实例演示开关 demoEnabled: true # 文件路径,以uploadPath结尾 示例( Windows配置D:/wumei-smart/uploadPath,Linux配置 /var/wumei-smart/java/uploadPath) - profile: /var/wumei-smart/java/uploadPath + profile: D:/wumei-smart/uploadPath # 获取ip地址开关 addressEnabled: true # 验证码类型 math 数组计算 char 字符验证 @@ -59,13 +59,13 @@ spring: # redis 配置 redis: # 地址 - host: localhost + host: wumei.live # 端口,默认为6379 port: 6379 # 数据库索引 database: 0 # 密码 - password: wumei-smart + password: 1a2b3c4D # 连接超时时间 timeout: 10s lettuce: @@ -82,7 +82,7 @@ spring: mqtt: username: wumei-smart # 账号 password: wumei-smart # 密码 - host-url: tcp://localhost:1883 # mqtt连接tcp地址 + host-url: tcp://wumei.live:1883 # mqtt连接tcp地址 client-id: ${random.int} # 客户端Id,不能相同,采用随机数 ${random.value} default-topic: test # 默认主题 timeout: 30000 # 超时时间 diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/CategoryController.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/CategoryController.java index fab144bd..da436a70 100644 --- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/CategoryController.java +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/CategoryController.java @@ -60,16 +60,9 @@ public class CategoryController extends BaseController @PreAuthorize("@ss.hasPermi('iot:category:list')") @GetMapping("/shortlist") @ApiOperation("分类简短列表") - public AjaxResult shortlist(Category category) + public AjaxResult shortlist() { - List list = new ArrayList<>(); - if(category.getTenantName()==""||category.getTenantName()==null) - { - list = categoryService.selectCategoryShortList(); - }else { - list = categoryService.selectCategoryShortListAccurate(category); - } - return AjaxResult.success(list); + return AjaxResult.success(categoryService.selectCategoryShortList()); } /** diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceController.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceController.java index b83ec4a8..50b96664 100644 --- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceController.java +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceController.java @@ -65,16 +65,9 @@ public class DeviceController extends BaseController @PreAuthorize("@ss.hasPermi('iot:device:list')") @GetMapping("/all") @ApiOperation("查询所有设备简短列表") - public TableDataInfo allShortList(Device device) + public TableDataInfo allShortList() { - List list = new ArrayList<>(); - if(device.getUserName()==null || device.getUserName().equals("")) - { - list = deviceService.selectAllDeviceShortList(); - }else { - list = deviceService.selectAllDeviceShortListAccurate(device.getUserName()); - } - return getDataTable(list); + return getDataTable(deviceService.selectAllDeviceShortList()); } /** diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/CategoryMapper.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/CategoryMapper.java index 36287aa1..3c9ee4ad 100644 --- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/CategoryMapper.java +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/CategoryMapper.java @@ -36,7 +36,7 @@ public interface CategoryMapper * * @return 产品分类集合 */ - public List selectCategoryShortList(); + public List selectCategoryShortList(Category category); /** * 新增产品分类 @@ -78,5 +78,4 @@ public interface CategoryMapper */ public int productCountInCategorys(Long[] categoryIds); - List selectCategoryShortListAccurate(Category category); } diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceMapper.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceMapper.java index bc99be99..ad55de48 100644 --- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceMapper.java +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceMapper.java @@ -98,7 +98,7 @@ public interface DeviceMapper * * @return 设备集合 */ - public List selectAllDeviceShortList(); + public List selectAllDeviceShortList(Device device); /** * 新增设备 @@ -168,16 +168,4 @@ public interface DeviceMapper */ public int resetDeviceStatus(String deviceNum); - /** - * 查询所有简短设备列表 - * @return 结果 - */ - List selectAllDeviceShortListAccurate(String userName); - - /** - * 精准查询 - * @return 结果 - */ - List selectDeviceListAccurate(Device device); - } diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/ICategoryService.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/ICategoryService.java index 27bf5eff..fd715ff7 100644 --- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/ICategoryService.java +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/ICategoryService.java @@ -69,5 +69,4 @@ public interface ICategoryService */ public int deleteCategoryByCategoryId(Long categoryId); - List selectCategoryShortListAccurate(Category category); } diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/IDeviceService.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/IDeviceService.java index 775df5db..f9dfa6c4 100644 --- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/IDeviceService.java +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/IDeviceService.java @@ -158,18 +158,5 @@ public interface IDeviceService */ public int resetDeviceStatus(String deviceNum); - /** - * 获取所有简短设备列表 - * @param userName - * @return - */ - List selectAllDeviceShortListAccurate(String userName); - - /** - * 精准查询 - * @param device - * @return - */ - List selectDeviceListAccurate(Device device); } diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/CategoryServiceImpl.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/CategoryServiceImpl.java index 76c13286..52694798 100644 --- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/CategoryServiceImpl.java +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/CategoryServiceImpl.java @@ -65,7 +65,14 @@ public class CategoryServiceImpl implements ICategoryService @Override public List selectCategoryShortList() { - return categoryMapper.selectCategoryShortList(); + Category category=new Category(); + SysUser user = getLoginUser().getUser(); + List roles=user.getRoles(); + // 租户 + if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){ + category.setTenantId(user.getUserId()); + } + return categoryMapper.selectCategoryShortList(category); } /** @@ -103,11 +110,6 @@ public class CategoryServiceImpl implements ICategoryService return categoryMapper.updateCategory(category); } - @Override - public List selectCategoryShortListAccurate(Category category) { - return categoryMapper.selectCategoryShortListAccurate(category); - } - /** * 批量删除产品分类 * diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java index 6741af0d..10123873 100644 --- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java @@ -240,8 +240,19 @@ public class DeviceServiceImpl implements IDeviceService { */ @Override public List selectAllDeviceShortList() { - // TODO redis缓存 - return deviceMapper.selectAllDeviceShortList(); + Device device=new Device(); + SysUser user = getLoginUser().getUser(); + List roles=user.getRoles(); + for(int i=0;i selectDeviceShortList(Device device) { - // TODO 关联设备用户表 - SysUser user = getLoginUser().getUser(); List roles=user.getRoles(); for(int i=0;i selectAllDeviceShortListAccurate(String userName) { - return deviceMapper.selectAllDeviceShortListAccurate(userName); - } - // 精准查询 新增别人分享给自己的设备 - @Override - public List selectDeviceListAccurate(Device device) { - return deviceMapper.selectDeviceListAccurate(device); - } - /** * diff --git a/springboot/wumei-iot/src/main/resources/mapper/iot/CategoryMapper.xml b/springboot/wumei-iot/src/main/resources/mapper/iot/CategoryMapper.xml index a1856517..aae70055 100644 --- a/springboot/wumei-iot/src/main/resources/mapper/iot/CategoryMapper.xml +++ b/springboot/wumei-iot/src/main/resources/mapper/iot/CategoryMapper.xml @@ -33,12 +33,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by order_num + - - select device_id, device_name, product_name, user_name, serial_number, firmware_version, status,rssi,is_shadow , - is_custom_location, active_time,network_address,longitude,latitude from iot_device - - and user_name = #{userName} - - select device_id, device_name, product_name, user_name, serial_number, firmware_version, status,rssi,is_shadow , is_custom_location, active_time,network_address,longitude,latitude from iot_device + + and user_id = #{userId} + - + select d.device_id, d.device_name, d.product_id, d.product_name, + d.user_id, d.user_name, d.tenant_id, d.tenant_name, d.serial_number, + d.firmware_version, d.status,d.rssi,d.is_shadow ,d.is_custom_location, + d.things_model_value, d.active_time,img_url + from iot_device d + left join iot_device_user u on u.device_id = d.device_id - and device_name like concat('%', #{deviceName}, '%') - and product_id = #{productId} - and product_name like concat('%', #{productName}, '%') - and user_id = #{userId} - and user_name like concat('%', #{userName}, '%') - and tenant_id = #{tenantId} - and tenant_name like concat('%', #{tenantName}, '%') - and serial_number = #{serialNumber} - and status = #{status} - and active_time between #{params.beginActiveTime} and #{params.endActiveTime} + and u.user_id = #{userId} + and d.device_name like concat('%', #{deviceName}, '%') + and d.product_id = #{productId} + and d.product_name like concat('%', #{productName}, '%') + and d.user_name like concat('%', #{userName}, '%') + and d.tenant_id = #{tenantId} + and d.tenant_name like concat('%', #{tenantName}, '%') + and d.serial_number = #{serialNumber} + and d.status = #{status} + and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime} - order by create_time desc - - -