Commit 41d6f23d by 吕明尚

小程序设备管理增加延时5秒

parent e1c32830
......@@ -9,6 +9,7 @@ import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.common.enums.BusinessType;
import share.common.enums.OpTypeEnum;
import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum;
import share.common.utils.SecurityUtils;
......@@ -20,10 +21,7 @@ import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MqttxVo;
import share.system.mapper.SStoreConsumerMapper;
import share.system.mqtt.MqttGatewayComponent;
import share.system.service.DeviceLogService;
import share.system.service.DeviceService;
import share.system.service.MqttxService;
import share.system.service.SConsumerService;
import share.system.service.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
......@@ -38,15 +36,12 @@ import java.util.List;
@RequestMapping("/device")
public class DeviceController extends BaseController {
@Autowired
private MqttxService mqttxService;
@Autowired
private DeviceLogService deviceLogService;
@Autowired
private MqttGatewayComponent mqttGatewayComponent;
private DeviceOpService deviceOpService;
@Autowired
private SConsumerService consumerService;
@Autowired
private SStoreConsumerMapper storeConsumerMapper;
private static final long FIVE = 5;
/**
......@@ -62,14 +57,8 @@ public class DeviceController extends BaseController {
if (CollectionUtils.isEmpty(longs)) {
throw new RuntimeException("当前用户不是管理员");
}
// 获取mqtt的topic、payload
MqttxVo mqttxVo = mqttxService.openOrCloseDevice(deviceParam.getDevId(),
user.getAccount(), deviceParam.getOpType());
// 发送mqtt消息
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
int result = deviceLogService.addDeviceLog(mqttxVo, user.getAccount());
return toAjax(result);
deviceOpService.openOrCloseDevice(deviceParam.getRoomId(), user.getPhone(), deviceParam.getOpType(), true, FIVE);
return toAjax(true);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment