|
|
@ -1,18 +1,25 @@ |
|
|
|
package com.qyft.gd.device.service; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.qyft.gd.device.event.LiquidTrayStatusChangedEvent; |
|
|
|
import com.qyft.gd.device.model.bo.DeviceOperationalStatus; |
|
|
|
import com.qyft.gd.device.model.bo.DeviceStatus; |
|
|
|
import lombok.Getter; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.Setter; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.context.ApplicationEventPublisher; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
/** |
|
|
|
* 设备传感器状态推送 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class DeviceStatusService { |
|
|
|
private final ApplicationEventPublisher eventPublisher; |
|
|
|
|
|
|
|
/** |
|
|
|
* 设备运行状态 |
|
|
|
*/ |
|
|
@ -22,13 +29,22 @@ public class DeviceStatusService { |
|
|
|
* 更新设备业务操作状态 |
|
|
|
*/ |
|
|
|
@Getter |
|
|
|
private final DeviceOperationalStatus deviceOperationalStatus = new DeviceOperationalStatus(); |
|
|
|
public DeviceOperationalStatus deviceOperationalStatus = new DeviceOperationalStatus(); |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新设备状态 |
|
|
|
*/ |
|
|
|
public void updateDeviceStatus(DeviceStatus newStatus) { |
|
|
|
synchronized (deviceStatus) { |
|
|
|
try { |
|
|
|
if (deviceStatus.getLiquidArea() != null) { |
|
|
|
if (deviceStatus.getLiquidArea().getLiquidTray() != newStatus.getLiquidArea().getLiquidTray()) { |
|
|
|
eventPublisher.publishEvent(new LiquidTrayStatusChangedEvent(this, BeanUtil.copyProperties(newStatus, DeviceStatus.class))); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception ignored) { |
|
|
|
} |
|
|
|
|
|
|
|
BeanUtil.copyProperties(newStatus, deviceStatus); |
|
|
|
} |
|
|
|
} |
|
|
|