| | |
| | | package com.ard.alarm.tube.service; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.ard.utils.other.DateUtils; |
| | | import com.ard.utils.netty.config.NettyUdpConfiguration; |
| | | import com.ard.utils.util.DateUtils; |
| | | import com.ard.utils.mqtt.MqttProducer; |
| | | import com.ard.utils.udp.NettyUdpServer; |
| | | import io.netty.bootstrap.Bootstrap; |
| | | import io.netty.channel.ChannelFuture; |
| | | import io.netty.channel.ChannelOption; |
| | | import io.netty.channel.EventLoopGroup; |
| | | import io.netty.channel.nio.NioEventLoopGroup; |
| | | import io.netty.channel.socket.nio.NioDatagramChannel; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | |
| | | **/ |
| | | @Service |
| | | @Slf4j(topic = "tube") |
| | | @Order(3) |
| | | public class TubeAlarmService { |
| | | @Resource |
| | | NettyUdpServer nettyUdpServer; |
| | | |
| | | @Value("${spring.netty.udp.port}") |
| | | private Integer udpPort; |
| | | @Value("${spring.netty.udp.enabled}") |
| | | private String UdpServerEnable; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | if (UdpServerEnable.equals("false")) { |
| | | return; |
| | | } |
| | | nettyUdpServer.init(udpPort); |
| | | log.debug("管线泄露UDP服务已启动"); |
| | | } |
| | | |
| | | |
| | | @Async("alarm") |
| | | public void alarmHandler(String message) { |
| | |
| | | log.error("tube报警数据推送异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |