|
@@ -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();
|
|
|
+ }
|
|
|
+}
|