Browse Source

修复BUG

yangxiaokun 3 years ago
parent
commit
6316861938

+ 0 - 16
src/main/java/com/zy/bms/controller/RoleController.java

@@ -1,16 +0,0 @@
-package com.zy.bms.controller;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * 角色表 前端控制器
- *
- * @author yangxiaokun
- * @since 2021-06-03
- */
-@RestController
-@RequestMapping("/builder/role")
-public class RoleController {
-
-}

+ 38 - 2
src/main/java/com/zy/bms/controller/UserController.java

@@ -1,9 +1,13 @@
 package com.zy.bms.controller;
 
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.zy.bms.common.ServerResponse;
-import com.zy.bms.pojo.io.UserIO;
+import com.zy.bms.entity.User;
+import com.zy.bms.pojo.io.SearchIO;
+import com.zy.bms.service.IUserPrivilegeService;
 import com.zy.bms.service.IUserService;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -21,11 +25,43 @@ public class UserController {
     @Resource
     private IUserService userService;
 
+    @Resource
+    private IUserPrivilegeService userPrivilegeService;
+
     /**
      * 分页查询用户列表
      */
     @GetMapping("listPage.do")
-    public ServerResponse listPage(UserIO io) {
+    public ServerResponse listPage(SearchIO io) {
         return ServerResponse.success(userService.listPage(io));
     }
+
+    /**
+     * 获取用户未有权限的设备组
+     */
+    @GetMapping("getNoAccessGroups.do")
+    public ServerResponse getNoAccessGroups(Integer userId) {
+        return ServerResponse.success(userPrivilegeService.getNoAccessGroups(userId));
+    }
+
+    /**
+     * 设备组权限
+     */
+    @PostMapping("saveGroupAccess.do")
+    public ServerResponse saveGroupAccess(Integer userId, String[] groups) {
+        userPrivilegeService.saveBatch(userId, groups);
+        return ServerResponse.success();
+    }
+
+    /**
+     * 管理员权限
+     *
+     * @param userId 用户ID
+     */
+    @PostMapping("saveAdminAccess.do")
+    public ServerResponse saveAdminAccess(Integer userId) {
+        userService.update(new UpdateWrapper<User>().set("admin", 1).eq("id", userId));
+        return ServerResponse.success();
+    }
+
 }

+ 0 - 41
src/main/java/com/zy/bms/controller/UserPrivilegeController.java

@@ -1,41 +0,0 @@
-package com.zy.bms.controller;
-
-import com.zy.bms.common.ServerResponse;
-import com.zy.bms.service.IUserPrivilegeService;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-
-/**
- * 用户设备组权限
- *
- * @author chenyi
- * @since 2021-07-12
- */
-@RestController
-@RequestMapping("/bms/api/operate/userPrivilege")
-public class UserPrivilegeController extends BaseController {
-
-    @Resource
-    private IUserPrivilegeService userPrivilegeService;
-
-    /**
-     * 获取用户未有权限的设备组
-     */
-    @GetMapping("getGroupsByUserId.do")
-    public ServerResponse getGroupsByUserId(Integer userId) {
-        return ServerResponse.success(userPrivilegeService.getGroupByUserId(userId()));
-    }
-
-    /**
-     * 添加权限
-     */
-    @PostMapping("save.do")
-    public ServerResponse save(Integer userId, String[] groups) {
-        userPrivilegeService.saveBatch(userId, groups);
-        return ServerResponse.success();
-    }
-}

+ 7 - 0
src/main/java/com/zy/bms/controller/lp/LpDeviceController.java

@@ -30,4 +30,11 @@ public class LpDeviceController {
         return ServerResponse.success(lpInfoStateService.listPage(io));
     }
 
+    /**
+     * 查询设备详情
+     */
+    @GetMapping("detail.do")
+    public ServerResponse detail(String openNum) {
+        return ServerResponse.success(lpInfoStateService.getByOpenNum(openNum));
+    }
 }

+ 2 - 3
src/main/java/com/zy/bms/controller/ubi/UbiDeviceController.java

@@ -1,6 +1,5 @@
 package com.zy.bms.controller.ubi;
 
-
 import com.zy.bms.common.ServerResponse;
 import com.zy.bms.controller.BaseController;
 import com.zy.bms.pojo.io.DeviceIO;
@@ -36,8 +35,8 @@ public class UbiDeviceController extends BaseController {
     /**
      * 查询设备详情信息
      */
-    @GetMapping("getDetail.do")
-    public ServerResponse getDetail(String openNum) {
+    @GetMapping("detail.do")
+    public ServerResponse detail(String openNum) {
         return ServerResponse.success(ubiInfoStateService.getDetail(openNum));
     }
 }

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

@@ -113,6 +113,7 @@ public class LpInfoState implements Serializable {
      * 数据更新时间
      */
     private LocalDateTime updateTime;
+
     /**
      * 更新位置标记
      */

+ 4 - 5
src/main/java/com/zy/bms/mapper/UserMapper.java

@@ -4,15 +4,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zy.bms.entity.User;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.zy.bms.pojo.io.UserIO;
+import com.zy.bms.pojo.io.SearchIO;
 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-03
@@ -24,7 +22,8 @@ public interface UserMapper extends BaseMapper<User> {
     /**
      * 分页查询用户
      *
-     * @param io 查询参数
+     * @param page 分页
+     * @param io   查询参数
      */
-    IPage<User> listPage(Page<User> page, @Param("io") UserIO io);
+    IPage<User> listPage(Page<User> page, @Param("io") SearchIO io);
 }

+ 1 - 0
src/main/java/com/zy/bms/mapper/lp/LpInfoStateMapper.java

@@ -39,6 +39,7 @@ public interface LpInfoStateMapper extends BaseMapper<LpInfoState> {
     List<LpInfoState> listByGroupId(@Param("groupId") String groupId);
 
     /**
+     * 微信端
      * 通过用户ID 查询设备集合
      *
      * @param userId 用户ID

+ 5 - 7
src/main/java/com/zy/bms/pojo/io/PrivilegeApplyIO.java → src/main/java/com/zy/bms/pojo/io/SearchIO.java

@@ -3,22 +3,20 @@ package com.zy.bms.pojo.io;
 import lombok.Data;
 
 /**
- * 权限申请记录IO
+ * 搜索 入参
  *
  * @author yang xiao kun
- * create on 2021/7/13
+ * create on 2021/9/23
  */
 @Data
-public class PrivilegeApplyIO extends PageIO {
-
+public class SearchIO extends PageIO {
     /**
-     * 关键字
-     * 手机号,备注
+     * 搜索关键字
      */
     private String key;
 
     /**
-     * 1通过 -1拒绝 0待审核
+     * 状态 0:禁用 1:启用
      */
     private Integer status;
 }

+ 0 - 33
src/main/java/com/zy/bms/pojo/io/UserIO.java

@@ -1,33 +0,0 @@
-package com.zy.bms.pojo.io;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-/**
- * 用户查询入参
- *
- * @author yang xiao kun
- * create on 2021/2/18
- */
-@Data
-public class UserIO extends PageIO {
-    /**
-     * 昵称/用户名/手机号
-     */
-    private String key;
-
-    /**
-     * 性别 1:男 2:女
-     */
-    private Integer gender;
-
-    /**
-     * 状态 0:禁用 1:启用
-     */
-    private Integer status;
-
-    /**
-     * 项目
-     */
-    private Integer itemId;
-}

+ 2 - 69
src/main/java/com/zy/bms/pojo/vo/LpDeviceListVo.java

@@ -1,6 +1,5 @@
 package com.zy.bms.pojo.vo;
 
-import com.alibaba.fastjson.annotation.JSONField;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -31,30 +30,20 @@ public class LpDeviceListVo {
     private String password;
 
     /**
-     * SN码
+     * 设备组
      */
-    private String sn;
+    private String groupId;
 
     /**
      * 创建时间
      */
     private LocalDateTime createTime;
 
-    /**
-     * 设备组
-     */
-    private String groupId;
-
     /**
      * 定时唤醒时间
      */
     private BigDecimal wakeInt;
 
-    /**
-     * 阈值
-     */
-    private Integer thresh;
-
     /**
      * 电量
      */
@@ -65,62 +54,6 @@ public class LpDeviceListVo {
      */
     private String s4g;
 
-    private String x;
-
-    private String y;
-
-    private String z;
-
-    private String anglex;
-
-    private String angley;
-
-    private String anglez;
-
-    /**
-     * 温度
-     */
-    private String temp;
-
-    /**
-     * 经度
-     */
-    @JSONField(format = "#.######")
-    private Double lon;
-
-    /**
-     * 纬度
-     */
-    @JSONField(format = "#.######")
-    private Double lat;
-
-    /**
-     * 经度(Gcj)
-     */
-    @JSONField(format = "#.######")
-    private Double lonGcj;
-
-    /**
-     * 纬度(Gcj)
-     */
-    @JSONField(format = "#.######")
-    private Double latGcj;
-
-    /**
-     * 格式化位置
-     */
-    private String site;
-
-    /**
-     * 定位模式 1:GPS 2:基站
-     */
-    private Integer mode;
-
-    /**
-     * 上传类型
-     */
-    private String dataType;
-
     /**
      * 数据更新时间
      */

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

@@ -1,6 +1,5 @@
 package com.zy.bms.pojo.vo;
 
-import com.alibaba.fastjson.annotation.JSONField;
 import lombok.Data;
 
 import java.time.LocalDateTime;
@@ -29,15 +28,10 @@ public class UbiDeviceListVo {
     private String password;
 
     /**
-     * 项目
+     * 设备
      */
     private String groupId;
 
-    /**
-     * SN码
-     */
-    private String sn;
-
     /**
      * 创建时间
      */
@@ -63,35 +57,6 @@ public class UbiDeviceListVo {
      */
     private String version;
 
-    /**
-     * 经度
-     */
-    @JSONField(format = "#.######")
-    private Double lon;
-
-    /**
-     * 纬度
-     */
-    @JSONField(format = "#.######")
-    private Double lat;
-
-    /**
-     * 经度(Gcj)
-     */
-    @JSONField(format = "#.######")
-    private Double lonGcj;
-
-    /**
-     * 纬度(Gcj)
-     */
-    @JSONField(format = "#.######")
-    private Double latGcj;
-
-    /**
-     * 卫星颗数
-     */
-    private Integer satNum;
-
     /**
      * 数据更新时间
      */

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

@@ -28,7 +28,7 @@ public interface IUserPrivilegeService extends IService<UserPrivilege> {
      *
      * @param userId 用户ID
      */
-    Map<String, List<GroupListVo>> getGroupByUserId(Integer userId);
+    Map<String, List<GroupListVo>> getNoAccessGroups(Integer userId);
 
     /**
      * 查询用户是否有某设备组的权限

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

@@ -3,7 +3,7 @@ package com.zy.bms.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.zy.bms.entity.User;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.zy.bms.pojo.io.UserIO;
+import com.zy.bms.pojo.io.SearchIO;
 
 /**
  * <p>
@@ -25,5 +25,5 @@ public interface IUserService extends IService<User> {
      *
      * @param io 查询参数
      */
-    IPage<User> listPage(UserIO io);
+    IPage<User> listPage(SearchIO io);
 }

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

@@ -16,9 +16,7 @@ import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
- * <p>
  * 用户查看手机设备权限表 服务实现类
- * </p>
  *
  * @author chenyi
  * @since 2021-07-13
@@ -36,9 +34,12 @@ public class UserPrivilegeServiceImpl extends ServiceImpl<UserPrivilegeMapper, U
     }
 
     @Override
-    public Map<String, List<GroupListVo>> getGroupByUserId(Integer userId) {
+    public Map<String, List<GroupListVo>> getNoAccessGroups(Integer userId) {
+        //全部的设备组
         List<GroupListVo> allGroup = groupService.getAllList();
+        //用户已拥有权限的设备组ID
         HashSet<String> ownGroup = new HashSet<>(getGroupIdsByUserId(userId));
+        //过滤掉已拥有权限的设备组后按项目ID分组
         return allGroup.stream().filter(item -> !ownGroup.contains(item.getCode()))
                 .collect(Collectors.groupingBy(GroupListVo::getItem));
     }

+ 2 - 2
src/main/java/com/zy/bms/service/impl/UserServiceImpl.java

@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zy.bms.common.Constant;
 import com.zy.bms.entity.User;
 import com.zy.bms.mapper.UserMapper;
-import com.zy.bms.pojo.io.UserIO;
+import com.zy.bms.pojo.io.SearchIO;
 import com.zy.bms.service.IUserService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zy.bms.utils.HttpUtil;
@@ -39,7 +39,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     }
 
     @Override
-    public IPage<User> listPage(UserIO io) {
+    public IPage<User> listPage(SearchIO io) {
         Page<User> page = new Page<>(io.getCurrent(), io.getSize());
         return baseMapper.listPage(page, io);
     }

+ 0 - 5
src/main/resources/mapper/InstructionsMapper.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.zy.bms.mapper.InstructionsMapper">
-
-</mapper>

+ 5 - 2
src/main/resources/mapper/LpInfoStateMapper.xml

@@ -9,7 +9,10 @@
         t1.sn,
         t1.create_time,
         t1.group_id,
-        t2.*
+        t2.wake_int,
+        t2.update_time,
+        t2.battery,
+        t2.s4g
         FROM
         device_base t1
         LEFT JOIN lp_info_state t2 ON t1.open_num = t2.open_num
@@ -17,7 +20,7 @@
         <if test="io.openNum != null and io.openNum != ''">
             AND t1.open_num LIKE CONCAT('%',#{io.openNum},'%')
         </if>
-        <if test="io.groupId != null and io.groupId > -1">
+        <if test="io.groupId != null">
             AND t1.group_id = #{io.groupId}
         </if>
     </select>

+ 0 - 5
src/main/resources/mapper/UbiInfoRecordMapper.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.zy.bms.mapper.ubi.UbiInfoRecordMapper">
-
-</mapper>

+ 0 - 5
src/main/resources/mapper/UbiNtripMapper.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.zy.bms.mapper.ubi.UbiNtripMapper">
-
-</mapper>

+ 0 - 5
src/main/resources/mapper/UbiTcpMapper.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.zy.bms.mapper.ubi.UbiTcpMapper">
-
-</mapper>

+ 0 - 28
src/test/java/com/zy/bms/SendMsg.java

@@ -1,28 +0,0 @@
-package com.zy.bms;
-
-import com.zy.bms.config.mqtt.MqttGateway;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import javax.annotation.Resource;
-
-/**
- * @author yang xiao kun
- * create on 2021/7/12
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = BmsApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class SendMsg {
-    @Resource
-    private MqttGateway mqttGateway;
-
-    @Test
-    public void test() {
-        String msg1 = "{m: \"10\",data:{regnum:\"yxktest\"}}";
-        String msg2 = "{m:\"21\",data:{timee:\"2021-3-15 13:23:14\",freq:\"300\",powervolt:\"12.5\",satnum:\"12\",signal4g:\"26\",deviceid:\"none\",lon:\"104.456123\",lat:\"40.13654\",version:\"1.1.2\"}}";
-        String msg3 = "{m:\"30\",data:{deviceid:\"xxxx\",ntripserver:{en:\"on\",host:\"ntrip.ailishi.org\",port:\"2101\",mountpoint:\"xxx\",password:\"xxxx\",linkF:\"true\"},ntripclient:{en:\"on\",host:\"ntrip.ailishi.org\",port:\"2101\",mountpoint:\"xxx\",user:\"xxx\",password:\"xxxx\",linkF:\"true\"},tcplink1:{en:\"on\",host:\"111.2.1.34\",port:\"1234\",type:\"xyz\",linkF:\"true\"},tcplink2:{en:\"off\"},tcplink3:{en:\"on\",host:\"111.2.1.36\",port:\"3456\",type:\"xyz\",linkF:\"true\"}}}";
-        mqttGateway.sendMsgToMqtt(msg3,"$dtx2/IMEIyxktest");
-    }
-}