forked from dyf/fys-Multi-tenant
设备行为
This commit is contained in:
@ -21,6 +21,7 @@ import org.springframework.messaging.MessageHandler;
|
||||
*/
|
||||
@Configuration
|
||||
public class CustomMqttInboundConfiguration {
|
||||
|
||||
@Autowired
|
||||
private MqttPropertiesConfig mqttPropertiesConfig;
|
||||
@Autowired
|
||||
@ -28,11 +29,13 @@ public class CustomMqttInboundConfiguration {
|
||||
@Autowired
|
||||
private DeviceReceiverMessageHandler deviceReceiverMessageHandler;
|
||||
|
||||
|
||||
@Bean
|
||||
public MessageChannel customMqttChannel(){
|
||||
return new DirectChannel();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public MessageProducer customMessageProducer(){
|
||||
String clientId = "custom_client_" + UUID.fastUUID();
|
||||
@ -48,9 +51,11 @@ public class CustomMqttInboundConfiguration {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
@ServiceActivator(inputChannel = "customMqttChannel")
|
||||
public MessageHandler customMessageHandler(){
|
||||
return deviceReceiverMessageHandler;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,11 +8,18 @@ public enum InstructType6170 {
|
||||
|
||||
EQUIPMENT_REPORTING(0, "设备上报"),
|
||||
LIGHT_MODE(1, "灯光模式"),
|
||||
UNIT_INFO(2, "单位/姓名/职位"),
|
||||
/**
|
||||
* 设备信息
|
||||
* 单位/姓名/职位
|
||||
*/
|
||||
UNIT_INFO(2, "设备信息"),
|
||||
BOOT_IMAGE(3, "开机图片"),
|
||||
LASER_LIGHT(4, "激光灯"),
|
||||
BRIGHTNESS(5, "亮度调节"),
|
||||
LOCATION_DATA(11, "定位数据");
|
||||
LOCATION_DATA(11, "定位数据"),
|
||||
|
||||
|
||||
UNKNOWN(-1, "未知操作");
|
||||
|
||||
private final int code;
|
||||
private final String description;
|
||||
@ -36,7 +43,8 @@ public enum InstructType6170 {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("未知的指令类型代码: " + code);
|
||||
// throw new IllegalArgumentException("未知的指令类型代码: " + code);
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
package com.fuyuanshen.web.handler.mqtt;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fuyuanshen.app.domain.APPDevice;
|
||||
import com.fuyuanshen.app.enums.UserType;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceLog;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
|
||||
@ -14,7 +11,6 @@ import com.fuyuanshen.web.enums.InstructType6170;
|
||||
import com.fuyuanshen.web.enums.LightModeEnum6170;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
@ -22,8 +18,6 @@ import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定义监听主题消息的处理器
|
||||
*
|
||||
@ -164,11 +158,18 @@ public class DeviceReceiverMessageHandler implements MessageHandler {
|
||||
break;
|
||||
|
||||
case 4: // 激光灯
|
||||
// record.setLaserLight(array.get(1).asInt() == 1);
|
||||
int anInt = array.get(1).asInt();
|
||||
if (anInt == 0) {
|
||||
record.setContent("关闭激光灯");
|
||||
} else if (anInt == 1) {
|
||||
record.setContent("开启激光灯");
|
||||
} else {
|
||||
record.setContent("未知操作");
|
||||
}
|
||||
break;
|
||||
|
||||
case 5: // 亮度调节
|
||||
// record.setBrightness(array.get(1).asInt());
|
||||
record.setContent(+array.get(1).asInt() + "%");
|
||||
break;
|
||||
|
||||
case 11: // 定位数据
|
||||
|
Reference in New Issue
Block a user