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