|
@@ -1,18 +1,25 @@
|
|
|
package com.zy.bms.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.zy.bms.common.ServerResponse;
|
|
|
+import com.zy.bms.entity.DeviceBase;
|
|
|
+import com.zy.bms.entity.UserPrivilege;
|
|
|
+import com.zy.bms.entity.lp.LpInfoState;
|
|
|
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 com.zy.bms.service.lp.ILpInfoStateService;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
+ * 普适型,路牌 微信小程序接口
|
|
|
+ *
|
|
|
* @author yang xiao kun
|
|
|
* create on 2021/8/24
|
|
|
*/
|
|
@@ -20,18 +27,18 @@ 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;
|
|
|
+ @Resource
|
|
|
+ private ILpInfoStateService lpInfoStateService;
|
|
|
|
|
|
/**
|
|
|
* 查看用户拥有权限的设备组列表
|
|
|
*/
|
|
|
- @GetMapping("getGroupsByUserId.do")
|
|
|
+ @GetMapping("getGroups.do")
|
|
|
public ServerResponse getGroupsByUserId() {
|
|
|
return ServerResponse.success(groupService.getByUserId(userId()));
|
|
|
}
|
|
@@ -47,11 +54,30 @@ public class UbiLpWxController extends BaseController {
|
|
|
/**
|
|
|
* 通过设备组ID查询设备列表
|
|
|
*/
|
|
|
- @GetMapping("getDevicesByGroupId.do")
|
|
|
+ @GetMapping("getDevices.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));
|
|
|
+ return ServerResponse.success(deviceBaseService.listByGroupIdWx(groupId));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 扫码查询
|
|
|
+ */
|
|
|
+ @GetMapping("scan.do")
|
|
|
+ public ServerResponse scan(String openNum) {
|
|
|
+ DeviceBase device = deviceBaseService.getOne(new QueryWrapper<DeviceBase>().eq("open_num", openNum));
|
|
|
+ if (device == null) return ServerResponse.warning("设备码错误!");
|
|
|
+ //如果该用户没有该设备组权限,则加上权限
|
|
|
+ UserPrivilege userPrivilege = userPrivilegeService.getOne(new QueryWrapper<UserPrivilege>()
|
|
|
+ .eq("group_id", device.getGroupId()).eq("user_id", userId()));
|
|
|
+ if (userPrivilege == null) {
|
|
|
+ UserPrivilege entity = new UserPrivilege();
|
|
|
+ entity.setUserId(userId());
|
|
|
+ entity.setGroupId(device.getGroupId());
|
|
|
+ userPrivilegeService.save(entity);
|
|
|
+ }
|
|
|
+ return ServerResponse.success(deviceBaseService.getDetailWx(openNum));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -59,7 +85,15 @@ public class UbiLpWxController extends BaseController {
|
|
|
*/
|
|
|
@GetMapping("getDeviceDetail.do")
|
|
|
public ServerResponse getDeviceDetail(String openNum) {
|
|
|
- return ServerResponse.success(ubiInfoStateService.getDetailWx(openNum));
|
|
|
+ return ServerResponse.success(deviceBaseService.getDetailWx(openNum));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新唤醒时间和阈值
|
|
|
+ */
|
|
|
+ @PostMapping("update.do")
|
|
|
+ public ServerResponse update(LpInfoState entity) {
|
|
|
+ return ServerResponse.success(lpInfoStateService.updateWakeAndThresh(entity));
|
|
|
}
|
|
|
|
|
|
/**
|