|
|
@@ -0,0 +1,59 @@
|
|
|
+package org.springblade.app.controller;
|
|
|
+
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.http.util.Asserts;
|
|
|
+import org.springblade.common.constant.CommonConstant;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.device.dto.UserInfoDto;
|
|
|
+import org.springblade.device.entity.DoorDevice;
|
|
|
+import org.springblade.device.feign.IDoorDeviceClient;
|
|
|
+import org.springblade.device.vo.DoorDeviceVO;
|
|
|
+import org.springblade.person.entity.EnterpriseStaff;
|
|
|
+import org.springblade.person.feign.IEnterpriseStaffClient;
|
|
|
+import org.springblade.person.vo.EnterpriseStaffVO;
|
|
|
+import org.springblade.third.doordevice.feign.IDoorDeviceButtClient;
|
|
|
+import org.springframework.util.Assert;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author zwx
|
|
|
+ * @create 2021/5/27 17:42
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/doordevice")
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class DoorDeviceController {
|
|
|
+
|
|
|
+ private final IDoorDeviceClient doorDeviceClient;
|
|
|
+ private final IDoorDeviceButtClient doorDeviceButtClient;
|
|
|
+ private final IEnterpriseStaffClient enterpriseStaffClient;
|
|
|
+
|
|
|
+ @GetMapping("/remoteOpenDoor")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "远程开门", notes = "传入deviceId, userId")
|
|
|
+ public R remoteOpenDoor(@RequestParam(value = "deviceId", required = true) String deviceId,
|
|
|
+ @RequestParam(value = "userId", required = true)String userId){
|
|
|
+
|
|
|
+ DoorDevice doorDevice = new DoorDevice();
|
|
|
+ doorDevice.setId(Func.toLong(deviceId));
|
|
|
+ DoorDeviceVO doorDeviceVO = doorDeviceClient.detail(doorDevice);
|
|
|
+ Assert.isTrue(doorDeviceVO != null, "设备不存在");
|
|
|
+ EnterpriseStaff enterpriseStaff = new EnterpriseStaff();
|
|
|
+ enterpriseStaff.setId(Func.toLong(userId));
|
|
|
+ EnterpriseStaffVO staffVO = enterpriseStaffClient.detail(enterpriseStaff);
|
|
|
+ Assert.isTrue(staffVO != null, "员工不存在");
|
|
|
+ //下发开门指令
|
|
|
+ UserInfoDto userInfoDto = new UserInfoDto();
|
|
|
+ userInfoDto.setId(CommonConstant.UserFlag.ENTERPRISE_STAFF_FLAG + userId);
|
|
|
+ return doorDeviceButtClient.remoteOpenDoor(doorDeviceVO, userInfoDto);
|
|
|
+ }
|
|
|
+}
|