|
@@ -1,6 +1,7 @@
|
|
|
package org.dromara.util;
|
|
package org.dromara.util;
|
|
|
|
|
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.springframework.context.annotation.Import;
|
|
import org.springframework.context.annotation.Import;
|
|
|
|
|
|
|
@@ -8,21 +9,33 @@ import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
@Import(cn.hutool.extra.spring.SpringUtil.class)
|
|
@Import(cn.hutool.extra.spring.SpringUtil.class)
|
|
|
|
|
+@Slf4j
|
|
|
public class MessageUtils {
|
|
public class MessageUtils {
|
|
|
public static void sendLed(String devicecode,String message){
|
|
public static void sendLed(String devicecode,String message){
|
|
|
|
|
+ if(StringUtils.isNotEmpty(devicecode)&&StringUtils.isNotEmpty(message)) {
|
|
|
|
|
+ Map<String, String> data = new HashMap<>();
|
|
|
|
|
+ data.put("devtype", "led");
|
|
|
|
|
+ data.put("devcode", devicecode);
|
|
|
|
|
+ final CamelDataUtil camelDataUtil = SpringUtil.getBean("camelDataUtil");
|
|
|
|
|
+ camelDataUtil.SendData("direct:sendMessage", StringUtils.format("{\"val\":\"{}\"}", message), "mqheader", data);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ log.error("------------------");
|
|
|
|
|
+ log.error("devicecode:"+devicecode.toString()+" message:"+message.toString());
|
|
|
|
|
+ log.error("------------------");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- Map<String,String> data = new HashMap<>();
|
|
|
|
|
- data.put("devtype","led");
|
|
|
|
|
- data.put("devcode",devicecode);
|
|
|
|
|
- final CamelDataUtil camelDataUtil = SpringUtil.getBean("camelDataUtil");
|
|
|
|
|
- camelDataUtil.SendData("direct:sendMessage", StringUtils.format("{\"val\":\"{}\"}",message), "mqheader", data);
|
|
|
|
|
}
|
|
}
|
|
|
public static void sendTTs(String devicecode,String message){
|
|
public static void sendTTs(String devicecode,String message){
|
|
|
-
|
|
|
|
|
- Map<String,String> data = new HashMap<>();
|
|
|
|
|
- data.put("devtype","tts");
|
|
|
|
|
- data.put("devcode",devicecode);
|
|
|
|
|
- final CamelDataUtil camelDataUtil = SpringUtil.getBean("camelDataUtil");
|
|
|
|
|
- camelDataUtil.SendData("direct:sendMessage", StringUtils.format("{\"val\":\"{}\",\"vol\":7}",message), "mqheader", data);
|
|
|
|
|
|
|
+ if(StringUtils.isNotEmpty(devicecode)&&StringUtils.isNotEmpty(message)) {
|
|
|
|
|
+ Map<String, String> data = new HashMap<>();
|
|
|
|
|
+ data.put("devtype", "tts");
|
|
|
|
|
+ data.put("devcode", devicecode);
|
|
|
|
|
+ final CamelDataUtil camelDataUtil = SpringUtil.getBean("camelDataUtil");
|
|
|
|
|
+ camelDataUtil.SendData("direct:sendMessage", StringUtils.format("{\"val\":\"{}\",\"vol\":7}", message), "mqheader", data);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ log.error("------------------");
|
|
|
|
|
+ log.error("devicecode:"+devicecode.toString()+" message:"+message.toString());
|
|
|
|
|
+ log.error("------------------");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|