|
|
@@ -27,7 +27,9 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
-/** 云飞杀虫灯 */
|
|
|
+/**
|
|
|
+ * 云飞杀虫灯
|
|
|
+ */
|
|
|
@Component(ServiceNameConst.SERVICE_YF_SCD)
|
|
|
@Slf4j
|
|
|
public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice {
|
|
|
@@ -58,16 +60,16 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
|
|
|
List<String> topicList = new ArrayList<>();
|
|
|
topicList.add(IotMqttConstant.YFScdTopic.TOPIC_SCD_CMD_PREFIX + devCode);
|
|
|
topicList.add(IotMqttConstant.YFScdTopic.TOPIC_SCD_2_CMD_PREFIX + devCode);
|
|
|
- if(Objects.equals(iotDevice.getDevtypeBid(), IotDeviceDictConst.TYPE_YF_FXSSCD)){
|
|
|
+ if (Objects.equals(iotDevice.getDevtypeBid(), IotDeviceDictConst.TYPE_YF_FXSSCD)) {
|
|
|
//新款风吸式杀虫灯
|
|
|
topicList.add(IotMqttConstant.YFScdTopic.TOPIC_FXSSCD_CMD_PREFIX + devCode);
|
|
|
}
|
|
|
- for(String topic:topicList){
|
|
|
- try{
|
|
|
+ for (String topic : topicList) {
|
|
|
+ try {
|
|
|
mqttManager.publishMsg(iotDevice.getDevconnBid(), topic, mqttMsgContent);
|
|
|
- log.info("【YFSCD】发送指令完毕!connectionId:{},topic :{} mqttMsgContent: {}",iotDevice.getDevconnBid(),topic, mqttMsgContent);
|
|
|
- }catch (Exception e){
|
|
|
- log.error("【YFSCD】发送指令失败!connectionId:{},topic :{} mqttMsgContent: {}",iotDevice.getDevconnBid(),topic, mqttMsgContent);
|
|
|
+ log.info("【YFSCD】发送指令完毕!connectionId:{},topic :{} mqttMsgContent: {}", iotDevice.getDevconnBid(), topic, mqttMsgContent);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("【YFSCD】发送指令失败!connectionId:{},topic :{} mqttMsgContent: {}", iotDevice.getDevconnBid(), topic, mqttMsgContent);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -90,7 +92,7 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
|
|
|
String mqttMsgContent = "";
|
|
|
String clogSendresult = "发送指令成功";
|
|
|
switch (methodName) {
|
|
|
- case CmdDef.YfScdCmdDef.CMD_CONFIG:{
|
|
|
+ case CmdDef.YfScdCmdDef.CMD_CONFIG: {
|
|
|
JSONObject jobjParam = cmdDistribution.getJsons();
|
|
|
Map<String, String> keyMap = new HashMap<>();
|
|
|
keyMap.put("ds", "ds");
|
|
|
@@ -101,7 +103,7 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
|
|
|
keyMap.put("et", "et");
|
|
|
|
|
|
JSONObject configObj = new JSONObject();
|
|
|
- for(Map.Entry<String, String> entry : keyMap.entrySet()) {
|
|
|
+ for (Map.Entry<String, String> entry : keyMap.entrySet()) {
|
|
|
String key = entry.getKey();
|
|
|
String keyName = entry.getValue();
|
|
|
|
|
|
@@ -119,13 +121,13 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
|
|
|
log.info("【杀虫灯】发送指令【config】 mqttMsgContent={}", mqttMsgContent);
|
|
|
break;
|
|
|
}
|
|
|
- case CmdDef.YfScdCmdDef.CMD_REFRESH:{
|
|
|
+ case CmdDef.YfScdCmdDef.CMD_REFRESH: {
|
|
|
JSONObject jobjParam = cmdDistribution.getJsons();
|
|
|
mqttMsgContent = JSONUtils.toJSONString(jobjParam);
|
|
|
log.info("【杀虫灯】发送指令【refresh】 mqttMsgContent={}", mqttMsgContent);
|
|
|
break;
|
|
|
}
|
|
|
- case CmdDef.YfScdCmdDef.CMD_COMMON:{
|
|
|
+ case CmdDef.YfScdCmdDef.CMD_COMMON: {
|
|
|
JSONObject jobjParam = cmdDistribution.getJsons();
|
|
|
mqttMsgContent = JSONUtils.toJSONString(jobjParam);
|
|
|
log.info("【杀虫灯】发送指令【report】 mqttMsgContent={}", mqttMsgContent);
|
|
|
@@ -133,8 +135,8 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(StringUtils.isNotEmpty(mqttMsgContent)){
|
|
|
- IotDevice iotDevice= iIotDeviceService.selectIotDeviceByDevBid(cmdModel.getIotDevice().getDevBid());
|
|
|
+ if (StringUtils.isNotEmpty(mqttMsgContent)) {
|
|
|
+ IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(cmdModel.getIotDevice().getDevBid());
|
|
|
publish(iotDevice, mqttMsgContent);
|
|
|
}
|
|
|
|
|
|
@@ -146,7 +148,7 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
|
|
|
}
|
|
|
|
|
|
public Object cmdData(JSONObject dataJson, String topic, String connectionId, String devUpdateddate) throws Exception {
|
|
|
- log.info("杀虫灯数据解析 {},topic:{}", dataJson.toString(),topic);
|
|
|
+ log.info("杀虫灯数据解析 {},topic:{}", dataJson.toString(), topic);
|
|
|
|
|
|
IotDevice oldIotDevice = findIotDevice(topic, dataJson, connectionId);
|
|
|
if (oldIotDevice == null) {
|
|
|
@@ -234,9 +236,9 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
|
|
|
newIotDevice.setDevUpdateddate(oldIotDevice.getDevUpdateddate());
|
|
|
newIotDevice.setDevCode(oldIotDevice.getDevCode());
|
|
|
newIotDevice.setDevOriginalStatus(oldIotDevice.getDevOriginalStatus());
|
|
|
+ newIotDevice.setDevName(oldIotDevice.getDevName());
|
|
|
iIotDeviceService.updateIotDevice(newIotDevice);
|
|
|
|
|
|
-
|
|
|
//发送离线预警
|
|
|
SpringUtils.getBean(WarnService.class).processWarningOfflineData(newIotDevice, dataJson);
|
|
|
|
|
|
@@ -260,7 +262,7 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public Object receiveData(String topic, JSONObject dataJson,String connectionId) throws Exception {
|
|
|
+ public Object receiveData(String topic, JSONObject dataJson, String connectionId) throws Exception {
|
|
|
log.info("杀虫灯实现类 处理收到的 设备上报数据 " + dataJson.toString());
|
|
|
// 接收设备上报数据后的处理逻辑
|
|
|
String cmd = dataJson.getString("cmd");
|
|
|
@@ -270,8 +272,8 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
|
|
|
}
|
|
|
JSONObject ext = dataJson.getJSONObject("ext");
|
|
|
String devUpdateddate = dataJson.getString("devUpdateddate");
|
|
|
- if(StringUtils.isEmpty(devUpdateddate)){
|
|
|
- devUpdateddate= DateUtils.dateTimeNow();
|
|
|
+ if (StringUtils.isEmpty(devUpdateddate)) {
|
|
|
+ devUpdateddate = DateUtils.dateTimeNow();
|
|
|
}
|
|
|
if (ext == null) {
|
|
|
log.error("未取到ext");
|
|
|
@@ -299,8 +301,8 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public IotDevice findIotDevice(String topic, JSONObject jobjMsg,String connectionId) {
|
|
|
- String devId = mqttManager.getDevIdByTopic(connectionId,topic);
|
|
|
+ public IotDevice findIotDevice(String topic, JSONObject jobjMsg, String connectionId) {
|
|
|
+ String devId = mqttManager.getDevIdByTopic(connectionId, topic);
|
|
|
return iIotDeviceService.selectIotDeviceByDevBid(devId);
|
|
|
}
|
|
|
}
|