|
|
@@ -1,12 +1,14 @@
|
|
|
package com.zd.laboratory.event;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.zd.laboratory.domain.LabHardware;
|
|
|
import com.zd.laboratory.mapper.LabHardwareMapper;
|
|
|
import com.zd.laboratory.mqtt.entiy.EquipmentStatus;
|
|
|
import com.zd.laboratory.mqtt.entiy.LabRelayStatus;
|
|
|
import com.zd.laboratory.mqtt.service.impl.SubMessageSendManager;
|
|
|
import com.zd.laboratory.service.ILabHardwareService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.ApplicationListener;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
@@ -22,6 +24,7 @@ import java.util.stream.Collectors;
|
|
|
* @description 继电器状态
|
|
|
**/
|
|
|
@Component
|
|
|
+@Slf4j
|
|
|
public class LabRelayNrStatusListener implements ApplicationListener<LabRelayNrStatusEvent> {
|
|
|
|
|
|
@Autowired
|
|
|
@@ -35,6 +38,8 @@ public class LabRelayNrStatusListener implements ApplicationListener<LabRelayNrS
|
|
|
|
|
|
@Override
|
|
|
public void onApplicationEvent(LabRelayNrStatusEvent labRelayNrStatusEvent) {
|
|
|
+ log.info("onApplicationEvent继电器{}", JSON.toJSONString(labRelayNrStatusEvent));
|
|
|
+
|
|
|
LabRelayStatus source = labRelayNrStatusEvent.getSource();
|
|
|
int i = labHardwareService.updateNrRelayStatus(source);
|
|
|
if (i > 0) {
|
|
|
@@ -52,6 +57,7 @@ public class LabRelayNrStatusListener implements ApplicationListener<LabRelayNrS
|
|
|
return equipmentStatus;
|
|
|
}).collect(Collectors.toList());
|
|
|
if (CollUtil.isNotEmpty(collect)) {
|
|
|
+ log.info("sendHardwareUpdate继电器{}", JSON.toJSONString(labHardwareVOS.get(0)));
|
|
|
subMessageSendManager.sendHardwareUpdate(labHardwareVOS.get(0), collect, 1);
|
|
|
}
|
|
|
}
|