Browse Source

完成项目和设备组配置

yangxiaokun 3 years ago
parent
commit
c15d389609
36 changed files with 248 additions and 144 deletions
  1. 5 0
      src/main/java/com/zy/bms/common/Constant.java
  2. 82 0
      src/main/java/com/zy/bms/controller/UbiLpWxController.java
  3. 0 72
      src/main/java/com/zy/bms/controller/ubi/UbiWxController.java
  4. 1 3
      src/main/java/com/zy/bms/entity/Admin.java
  5. 1 3
      src/main/java/com/zy/bms/entity/DeviceBase.java
  6. 0 1
      src/main/java/com/zy/bms/entity/Group.java
  7. 1 1
      src/main/java/com/zy/bms/entity/Instructions.java
  8. 1 1
      src/main/java/com/zy/bms/entity/Item.java
  9. 1 1
      src/main/java/com/zy/bms/entity/Logs.java
  10. 1 1
      src/main/java/com/zy/bms/entity/PrivilegeApplyRecord.java
  11. 1 1
      src/main/java/com/zy/bms/entity/Role.java
  12. 2 1
      src/main/java/com/zy/bms/entity/User.java
  13. 0 1
      src/main/java/com/zy/bms/entity/UserPrivilege.java
  14. 1 1
      src/main/java/com/zy/bms/entity/lp/LpInfoState.java
  15. 1 1
      src/main/java/com/zy/bms/entity/ubi/UbiInfoRecord.java
  16. 1 1
      src/main/java/com/zy/bms/entity/ubi/UbiInfoState.java
  17. 1 1
      src/main/java/com/zy/bms/entity/ubi/UbiNtrip.java
  18. 1 1
      src/main/java/com/zy/bms/entity/ubi/UbiTcp.java
  19. 14 2
      src/main/java/com/zy/bms/mapper/DeviceBaseMapper.java
  20. 7 0
      src/main/java/com/zy/bms/mapper/GroupMapper.java
  21. 1 1
      src/main/java/com/zy/bms/mapper/UserPrivilegeMapper.java
  22. 2 8
      src/main/java/com/zy/bms/mapper/ubi/UbiInfoStateMapper.java
  23. 5 0
      src/main/java/com/zy/bms/pojo/vo/LpDeviceListVo.java
  24. 6 1
      src/main/java/com/zy/bms/pojo/vo/UbiDeviceListVo.java
  25. 15 2
      src/main/java/com/zy/bms/service/IDeviceBaseService.java
  26. 7 0
      src/main/java/com/zy/bms/service/IGroupService.java
  27. 1 1
      src/main/java/com/zy/bms/service/IUserPrivilegeService.java
  28. 30 0
      src/main/java/com/zy/bms/service/impl/DeviceBaseServiceImpl.java
  29. 5 0
      src/main/java/com/zy/bms/service/impl/GroupServiceImpl.java
  30. 3 3
      src/main/java/com/zy/bms/service/impl/UserPrivilegeServiceImpl.java
  31. 11 0
      src/main/java/com/zy/bms/service/lp/ILpInfoStateService.java
  32. 3 9
      src/main/java/com/zy/bms/service/ubi/IUbiInfoStateService.java
  33. 3 7
      src/main/java/com/zy/bms/service/ubi/impl/UbiInfoStateServiceImpl.java
  34. 7 0
      src/main/resources/mapper/DeviceBaseMapper.xml
  35. 21 11
      src/main/resources/mapper/GroupMapper.xml
  36. 6 8
      src/main/resources/mapper/UbiInfoStateMapper.xml

+ 5 - 0
src/main/java/com/zy/bms/common/Constant.java

@@ -8,6 +8,11 @@ package com.zy.bms.common;
  */
 public class Constant {
 
+    public static class TYPE {
+        public static final String UBI = "gnss";
+        public static final String LP = "lupai";
+    }
+
     public static class WX {
         /**
          * 微信小程序登录相关配置

+ 82 - 0
src/main/java/com/zy/bms/controller/UbiLpWxController.java

@@ -0,0 +1,82 @@
+package com.zy.bms.controller;
+
+import com.zy.bms.common.ServerResponse;
+import com.zy.bms.service.IDeviceBaseService;
+import com.zy.bms.service.IGroupService;
+import com.zy.bms.service.IPostMqttMsgService;
+import com.zy.bms.service.IUserPrivilegeService;
+import com.zy.bms.service.ubi.IUbiInfoStateService;
+import org.springframework.web.bind.annotation.GetMapping;
+
+import javax.annotation.Resource;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author yang xiao kun
+ * create on 2021/8/24
+ */
+public class UbiLpWxController extends BaseController {
+    @Resource
+    private IUserPrivilegeService userPrivilegeService;
+    @Resource
+    private IUbiInfoStateService ubiInfoStateService;
+    @Resource
+    private IGroupService groupService;
+    @Resource
+    private IDeviceBaseService deviceBaseService;
+    @Resource
+    private IPostMqttMsgService postMqttMsgService;
+
+    /**
+     * 查看用户拥有权限的设备组列表
+     */
+    @GetMapping("getGroupsByUserId.do")
+    public ServerResponse getGroupsByUserId() {
+        return ServerResponse.success(groupService.getByUserId(userId()));
+    }
+
+    /**
+     * 校验设备码是否存在
+     */
+    @GetMapping("checkOpenNum.do")
+    public ServerResponse checkOpenNum(String openNum) {
+        return ServerResponse.success(deviceBaseService.checkOpenNum(openNum));
+    }
+
+    /**
+     * 通过设备组ID查询设备列表
+     */
+    @GetMapping("getDevicesByGroupId.do")
+    public ServerResponse getDevicesByGroupId(String groupId) {
+        Set<String> groupIds = new HashSet<>(userPrivilegeService.getGroupIdsByUserId(userId()));
+        if (!groupIds.contains(groupId)) return ServerResponse.warning("无权限");
+        return ServerResponse.success(deviceBaseService.listWx(group));
+    }
+
+    /**
+     * 获取设备详情信息
+     */
+    @GetMapping("getDeviceDetail.do")
+    public ServerResponse getDeviceDetail(String openNum) {
+        return ServerResponse.success(ubiInfoStateService.getDetailWx(openNum));
+    }
+
+    /**
+     * 蜂鸣器
+     */
+    @GetMapping("buzzing.do")
+    public ServerResponse buzzing(String openNum) {
+        postMqttMsgService.requestBuzzingUbi(openNum);
+        return ServerResponse.success();
+    }
+
+    /**
+     * 立即请求获取最新心跳包
+     */
+    @GetMapping("heartbeat.do")
+    public ServerResponse heartbeat(String openNum) {
+        postMqttMsgService.requestHeartbeatUbi(openNum);
+        return ServerResponse.success();
+    }
+}

+ 0 - 72
src/main/java/com/zy/bms/controller/ubi/UbiWxController.java

@@ -30,77 +30,5 @@ import java.util.Set;
 @RestController
 @RequestMapping("/bms/api/ubiapp")
 public class UbiWxController extends BaseController {
-    @Resource
-    private IPrivilegeApplyRecordService privilegeApplyRecordService;
-    @Resource
-    private IUserPrivilegeService userPrivilegeService;
-    @Resource
-    private IUbiInfoStateService ubiInfoStateService;
-    @Resource
-    private IGroupService groupService;
-    @Resource
-    private IPostMqttMsgService postMqttMsgService;
 
-    /**
-     * 查看用户拥有权限的设备组列表
-     */
-    @GetMapping("getOwnGroups.do")
-    public ServerResponse getOwnGroups() {
-        List<String> groupIds = userPrivilegeService.ownGroupIds(userId());
-        return ServerResponse.success(groupService.list(new QueryWrapper<Group>()
-                .in("id", groupIds.toArray())));
-    }
-
-    /**
-     * 申请查看设备组权限
-     */
-    @PostMapping("apply.do")
-    public ServerResponse apply(PrivilegeApplyRecord entity) {
-        entity.setUserId(userId());
-        return ServerResponse.success(privilegeApplyRecordService.save(entity));
-    }
-
-    /**
-     * 通过用户ID分页查询该用户拥有权限的设备列表
-     */
-    @GetMapping("getDeviceList.do")
-    public ServerResponse getDeviceList(String group) {
-        Set<String> groupIds = new HashSet<>(userPrivilegeService.ownGroupIds(userId()));
-        if (!groupIds.contains(group)) return ServerResponse.warning("无权限");
-        return ServerResponse.success(ubiInfoStateService.listWx(group));
-    }
-
-    /**
-     * 获取设备详情信息
-     */
-    @GetMapping("getDeviceDetail.do")
-    public ServerResponse getDeviceDetail(String openNum) {
-        return ServerResponse.success(ubiInfoStateService.getDetailWx(openNum));
-    }
-
-    /**
-     * 蜂鸣器
-     */
-    @GetMapping("buzzing.do")
-    public ServerResponse buzzing(String openNum) {
-        postMqttMsgService.requestBuzzingUbi(openNum);
-        return ServerResponse.success();
-    }
-
-    /**
-     * 立即请求获取最新心跳包
-     */
-    @GetMapping("heartbeat.do")
-    public ServerResponse heartbeat(String openNum) {
-        postMqttMsgService.requestHeartbeatUbi(openNum);
-        return ServerResponse.success();
-    }
-
-    /**
-     * 获取设备详情信息
-     */
-    @GetMapping("checkOpenNum.do")
-    public ServerResponse checkOpenNum(String openNum) {
-        return ServerResponse.success(ubiInfoStateService.checkOpenNum(openNum));
-    }
 }

+ 1 - 3
src/main/java/com/zy/bms/entity/Admin.java

@@ -8,9 +8,7 @@ import java.time.LocalDateTime;
 import java.io.Serializable;
 
 /**
- * <p>
  * 管理员表
- * </p>
  *
  * @author yangxiaokun
  * @since 2021-06-03
@@ -20,7 +18,7 @@ public class Admin implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 1 - 3
src/main/java/com/zy/bms/entity/DeviceBase.java

@@ -8,9 +8,7 @@ import java.time.LocalDateTime;
 import java.io.Serializable;
 
 /**
- * <p>
  * 设备基础信息
- * </p>
  *
  * @author yangxiaokun
  * @since 2021-06-01
@@ -20,7 +18,7 @@ public class DeviceBase implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 0 - 1
src/main/java/com/zy/bms/entity/Group.java

@@ -56,5 +56,4 @@ public class Group implements Serializable {
      */
     private Integer status;
 
-
 }

+ 1 - 1
src/main/java/com/zy/bms/entity/Instructions.java

@@ -21,7 +21,7 @@ public class Instructions implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 1 - 1
src/main/java/com/zy/bms/entity/Item.java

@@ -20,7 +20,7 @@ public class Item implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 1 - 1
src/main/java/com/zy/bms/entity/Logs.java

@@ -19,7 +19,7 @@ import java.time.LocalDateTime;
 @TableName("logs")
 public class Logs {
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 1 - 1
src/main/java/com/zy/bms/entity/PrivilegeApplyRecord.java

@@ -18,7 +18,7 @@ public class PrivilegeApplyRecord implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 1 - 1
src/main/java/com/zy/bms/entity/Role.java

@@ -20,7 +20,7 @@ public class Role implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 2 - 1
src/main/java/com/zy/bms/entity/User.java

@@ -1,5 +1,6 @@
 package com.zy.bms.entity;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import lombok.Data;
 
@@ -20,7 +21,7 @@ public class User implements Serializable {
     /**
      * 主键
      */
-    @TableId
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 0 - 1
src/main/java/com/zy/bms/entity/UserPrivilege.java

@@ -16,7 +16,6 @@ import lombok.EqualsAndHashCode;
  * @since 2021-07-13
  */
 @Data
-@EqualsAndHashCode(callSuper = false)
 public class UserPrivilege implements Serializable {
 
     private static final long serialVersionUID = 1L;

+ 1 - 1
src/main/java/com/zy/bms/entity/lp/LpInfoState.java

@@ -20,7 +20,7 @@ public class LpInfoState implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 1 - 1
src/main/java/com/zy/bms/entity/ubi/UbiInfoRecord.java

@@ -19,7 +19,7 @@ public class UbiInfoRecord implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 1 - 1
src/main/java/com/zy/bms/entity/ubi/UbiInfoState.java

@@ -18,7 +18,7 @@ public class UbiInfoState implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 1 - 1
src/main/java/com/zy/bms/entity/ubi/UbiNtrip.java

@@ -18,7 +18,7 @@ public class UbiNtrip implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 1 - 1
src/main/java/com/zy/bms/entity/ubi/UbiTcp.java

@@ -18,7 +18,7 @@ public class UbiTcp implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**

+ 14 - 2
src/main/java/com/zy/bms/mapper/DeviceBaseMapper.java

@@ -3,12 +3,11 @@ package com.zy.bms.mapper;
 import com.zy.bms.entity.DeviceBase;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 /**
- * <p>
  * 设备静态信息 Mapper 接口
- * </p>
  *
  * @author yangxiaokun
  * @since 2021-06-01
@@ -17,4 +16,17 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface DeviceBaseMapper extends BaseMapper<DeviceBase> {
 
+    /**
+     * 检查设备码是否存在
+     *
+     * @param openNum 设备码
+     */
+    int checkOpenNum(@Param("openNum") String openNum);
+
+    /**
+     * 通过设备组查询类型
+     *
+     * @param groupId 设备组
+     */
+    String getTypeByGroupId(String groupId);
 }

+ 7 - 0
src/main/java/com/zy/bms/mapper/GroupMapper.java

@@ -35,4 +35,11 @@ public interface GroupMapper extends BaseMapper<Group> {
      * 获取全部的设备组
      */
     List<GroupListVo> getAllList();
+
+    /**
+     * 通过userId 查询设备组
+     *
+     * @param userId 用户ID
+     */
+    List<Group> getByUserId(@Param("userId") Integer userId);
 }

+ 1 - 1
src/main/java/com/zy/bms/mapper/UserPrivilegeMapper.java

@@ -23,7 +23,7 @@ public interface UserPrivilegeMapper extends BaseMapper<UserPrivilege> {
      *
      * @param userId 用户ID
      */
-    List<String> ownGroupIds(@Param("userId") Integer userId);
+    List<String> getGroupIdsByUserId(@Param("userId") Integer userId);
 
     /**
      * 批量保存实体类

+ 2 - 8
src/main/java/com/zy/bms/mapper/ubi/UbiInfoStateMapper.java

@@ -48,14 +48,8 @@ public interface UbiInfoStateMapper extends BaseMapper<UbiInfoState> {
      * 微信端
      * 通过设备组分页查询设备列表
      *
-     * @param group 设备组
+     * @param groupId 设备组
      */
-    List<UbiDeviceListVo> listWx(@Param("group") String group);
+    List<UbiDeviceListVo> listByGroupIdWx(@Param("groupId") String groupId);
 
-    /**
-     * 检查设备码是否存在
-     *
-     * @param openNum 设备码
-     */
-    int checkOpenNum(@Param("openNum") String openNum);
 }

+ 5 - 0
src/main/java/com/zy/bms/pojo/vo/LpDeviceListVo.java

@@ -132,4 +132,9 @@ public class LpDeviceListVo {
      * 数据更新时间
      */
     private LocalDateTime updateTime;
+
+    public Integer getStatus() {
+        if (updateTime == null || wakeInt == null) return 0;
+        return LocalDateTime.now().isAfter(updateTime.plusMinutes(wakeInt.multiply(BigDecimal.valueOf(60)).intValue() + 3)) ? 0 : 1;
+    }
 }

+ 6 - 1
src/main/java/com/zy/bms/pojo/vo/UbiDeviceListVo.java

@@ -6,7 +6,7 @@ import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
 /**
- * 普适
+ * 普适
  * 设备基础信息,状态信息Vo
  *
  * @author yang xiao kun
@@ -97,4 +97,9 @@ public class UbiDeviceListVo {
      * 数据更新时间
      */
     private LocalDateTime updateTime;
+
+    public Integer getStatus() {
+        if (updateTime == null || freq == null) return 0;
+        return LocalDateTime.now().isAfter(updateTime.plusSeconds(freq + 500)) ? 0 : 1;
+    }
 }

+ 15 - 2
src/main/java/com/zy/bms/service/IDeviceBaseService.java

@@ -3,14 +3,27 @@ package com.zy.bms.service;
 import com.zy.bms.entity.DeviceBase;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
- * <p>
  * 设备静态信息 服务类
- * </p>
  *
  * @author yangxiaokun
  * @since 2021-06-01
  */
 public interface IDeviceBaseService extends IService<DeviceBase> {
 
+    /**
+     * 校验设备码是否存在
+     *
+     * @param openNum 设备码
+     */
+    boolean checkOpenNum(String openNum);
+
+    /**
+     * 通过设备组查询设备集合
+     *
+     * @param groupId 设备组
+     */
+    List listByGroupIdWx(String groupId);
 }

+ 7 - 0
src/main/java/com/zy/bms/service/IGroupService.java

@@ -29,4 +29,11 @@ public interface IGroupService extends IService<Group> {
      * 获取全部的设备组
      */
     List<GroupListVo> getAllList();
+
+    /**
+     * 通过userId 查询设备组
+     *
+     * @param userId 用户ID
+     */
+    List<Group> getByUserId(Integer userId);
 }

+ 1 - 1
src/main/java/com/zy/bms/service/IUserPrivilegeService.java

@@ -22,7 +22,7 @@ public interface IUserPrivilegeService extends IService<UserPrivilege> {
      *
      * @param userId 用户ID
      */
-    List<String> ownGroupIds(Integer userId);
+    List<String> getGroupIdsByUserId(Integer userId);
 
     /**
      * 通过用户Id 查询全部的设备组

+ 30 - 0
src/main/java/com/zy/bms/service/impl/DeviceBaseServiceImpl.java

@@ -1,11 +1,17 @@
 package com.zy.bms.service.impl;
 
+import com.zy.bms.common.Constant;
 import com.zy.bms.entity.DeviceBase;
 import com.zy.bms.mapper.DeviceBaseMapper;
 import com.zy.bms.service.IDeviceBaseService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zy.bms.service.lp.ILpInfoStateService;
+import com.zy.bms.service.ubi.IUbiInfoStateService;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.List;
+
 /**
  * <p>
  * 设备静态信息 服务实现类
@@ -17,4 +23,28 @@ import org.springframework.stereotype.Service;
 @Service
 public class DeviceBaseServiceImpl extends ServiceImpl<DeviceBaseMapper, DeviceBase> implements IDeviceBaseService {
 
+    @Resource
+    private IUbiInfoStateService ubiInfoStateService;
+
+    @Resource
+    private ILpInfoStateService lpInfoStateService;
+
+    @Override
+    public boolean checkOpenNum(String openNum) {
+        return baseMapper.checkOpenNum(openNum) > 0;
+    }
+
+    @Override
+    public List listByGroupIdWx(String groupId) {
+        String type = baseMapper.getTypeByGroupId(groupId);
+        switch (type) {
+            case Constant.TYPE.UBI: {
+                return ubiInfoStateService.listByGroupIdWx(groupId);
+            }
+            case Constant.TYPE.LP: {
+                return lpInfoStateService.listByGroupIdWx(groupId);
+            }
+        }
+        return null;
+    }
 }

+ 5 - 0
src/main/java/com/zy/bms/service/impl/GroupServiceImpl.java

@@ -31,4 +31,9 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
     public List<GroupListVo> getAllList() {
         return baseMapper.getAllList();
     }
+
+    @Override
+    public List<Group> getByUserId(Integer userId) {
+        return baseMapper.getByUserId(userId);
+    }
 }

+ 3 - 3
src/main/java/com/zy/bms/service/impl/UserPrivilegeServiceImpl.java

@@ -30,14 +30,14 @@ public class UserPrivilegeServiceImpl extends ServiceImpl<UserPrivilegeMapper, U
 
 
     @Override
-    public List<String> ownGroupIds(Integer userId) {
-        return baseMapper.ownGroupIds(userId);
+    public List<String> getGroupIdsByUserId(Integer userId) {
+        return baseMapper.getGroupIdsByUserId(userId);
     }
 
     @Override
     public Map<String, List<GroupListVo>> getGroupByUserId(Integer userId) {
         List<GroupListVo> allGroup = groupService.getAllList();
-        HashSet<String> ownGroup = new HashSet<>(baseMapper.ownGroupIds(userId));
+        HashSet<String> ownGroup = new HashSet<>(baseMapper.getGroupIdsByUserId(userId));
         return allGroup.stream().filter(item -> !ownGroup.contains(item.getCode()))
                 .collect(Collectors.groupingBy(GroupListVo::getItem));
     }

+ 11 - 0
src/main/java/com/zy/bms/service/lp/ILpInfoStateService.java

@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.zy.bms.entity.lp.LpInfoState;
 import com.zy.bms.pojo.io.DeviceIO;
 import com.zy.bms.pojo.vo.LpDeviceListVo;
+import com.zy.bms.pojo.vo.UbiDeviceListVo;
+
+import java.util.List;
 
 /**
  * 设备-路牌 服务类
@@ -21,6 +24,14 @@ public interface ILpInfoStateService extends IService<LpInfoState> {
      */
     IPage<LpDeviceListVo> listPage(DeviceIO io);
 
+    /**
+     * 微信端
+     * 通过设备组查询设备
+     *
+     * @param groupId 设备组
+     */
+    List<LpDeviceListVo> listByGroupIdWx(String groupId);
+
     /**
      * 通过设备ID获取设备信息
      *

+ 3 - 9
src/main/java/com/zy/bms/service/ubi/IUbiInfoStateService.java

@@ -41,11 +41,11 @@ public interface IUbiInfoStateService extends IService<UbiInfoState> {
 
     /**
      * 微信端
-     * 通过用户ID分页查询该用户拥有权限的设备列表
+     * 通过设备组查询设备
      *
-     * @param group 设备组
+     * @param groupId 设备组
      */
-    List<UbiDeviceListVo> listWx(String group);
+    List<UbiDeviceListVo> listByGroupIdWx(String groupId);
 
     /**
      * 微信端
@@ -55,10 +55,4 @@ public interface IUbiInfoStateService extends IService<UbiInfoState> {
      */
     UbiDeviceDetailVo getDetailWx(String openNum);
 
-    /**
-     * 校验设备码是否存在
-     *
-     * @param openNum 设备码
-     */
-    boolean checkOpenNum(String openNum);
 }

+ 3 - 7
src/main/java/com/zy/bms/service/ubi/impl/UbiInfoStateServiceImpl.java

@@ -22,7 +22,7 @@ import java.util.List;
 import java.util.Set;
 
 /**
- * 普适
+ * 普适
  * 设备动态信息表 服务实现类
  *
  * @author yangxiaokun
@@ -56,8 +56,8 @@ public class UbiInfoStateServiceImpl extends ServiceImpl<UbiInfoStateMapper, Ubi
     }
 
     @Override
-    public List<UbiDeviceListVo> listWx(String group) {
-        return baseMapper.listWx(group);
+    public List<UbiDeviceListVo> listByGroupIdWx(String groupId) {
+        return baseMapper.listByGroupIdWx(groupId);
     }
 
     @Override
@@ -65,8 +65,4 @@ public class UbiInfoStateServiceImpl extends ServiceImpl<UbiInfoStateMapper, Ubi
         return baseMapper.getDetail(openNum);
     }
 
-    @Override
-    public boolean checkOpenNum(String openNum) {
-        return baseMapper.checkOpenNum(openNum) > 0;
-    }
 }

+ 7 - 0
src/main/resources/mapper/DeviceBaseMapper.xml

@@ -2,4 +2,11 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zy.bms.mapper.DeviceBaseMapper">
 
+    <select id="checkOpenNum" resultType="java.lang.Integer">
+        SELECT IFNULL((SELECT 1 FROM device_base WHERE open_num = #{openNum} LIMIT 1), 0)
+    </select>
+
+    <select id="getTypeByGroupId" resultType="java.lang.String">
+        SELECT type FROM device_base WHERE group_id = #{group_id} LIMIT 1
+    </select>
 </mapper>

+ 21 - 11
src/main/resources/mapper/GroupMapper.xml

@@ -4,14 +4,14 @@
 
     <select id="listPage" resultType="com.zy.bms.pojo.vo.GroupListVo">
         SELECT
-            t1.id,
-            t1.code,
-            t1.name,
-            t1.remark,
-            t1.status,
-            t1.create_time,
-            t2.name             AS item,
-            t2.id               AS itemId
+        t1.id,
+        t1.code,
+        t1.name,
+        t1.remark,
+        t1.status,
+        t1.create_time,
+        t2.name AS item,
+        t2.id AS itemId
         FROM item_group t1
         LEFT JOIN item t2 ON t1.item_id = t2.id
         <where>
@@ -31,11 +31,21 @@
 
     <select id="getAllList" resultType="com.zy.bms.pojo.vo.GroupListVo">
         SELECT
-            t1.code,
-            t1.name,
-            t2.name AS item
+        t1.code,
+        t1.name,
+        t2.name AS item
         FROM item_group t1
         LEFT JOIN item t2 ON t1.item_id = t2.id
     </select>
 
+    <select id="getByUserId" resultType="com.zy.bms.entity.Group">
+        SELECT
+            *
+        FROM
+            item_group
+        WHERE
+            `code` IN (SELECT group_id FROM user_privilege WHERE userId = #{userId})
+            AND `status` = 1
+    </select>
+
 </mapper>

+ 6 - 8
src/main/resources/mapper/UbiInfoStateMapper.xml

@@ -47,19 +47,17 @@
             t1.type = "gnss" AND t1.open_num = #{openNum}
     </select>
 
-    <select id="listWx" resultType="com.zy.bms.pojo.vo.UbiDeviceListVo">
-        SELECT t1.open_num,
-               t1.create_time,
-               t2.status
+    <select id="listByGroupIdWx" resultType="com.zy.bms.pojo.vo.UbiDeviceListVo">
+        SELECT
+            t1.open_num,
+            t2.freq,
+            t2.update_time
         FROM
             device_base t1
         LEFT JOIN
             ubi_info_state t2 ON t1.open_num = t2.open_num
         WHERE
-            t1.type = "gnss" t1.group_id = #{group}
+            t1.type = "gnss" AND t1.group_id = #{group}
     </select>
 
-    <select id="checkOpenNum" resultType="java.lang.Integer">
-        SELECT IFNULL((SELECT 1 FROM device_base WHERE open_num = #{openNum} LIMIT 1), 0)
-    </select>
 </mapper>