| | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.ard.utils.DateUtils; |
| | | import com.ard.utils.mqtt.MqttConsumer; |
| | | import com.ard.utils.tcp.NettyTcpClient; |
| | | import com.ard.utils.udp.NettyUdpServer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.ApplicationArguments; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * @Description: 管线泄漏报警服务 |
| | |
| | | **/ |
| | | @Service |
| | | @Slf4j(topic = "tube") |
| | | public class TubeAlarmService { |
| | | @Order(3) |
| | | public class TubeAlarmService implements ApplicationRunner { |
| | | @Resource |
| | | NettyUdpServer nettyUdpServer; |
| | | @Value("${spring.netty.port}") |
| | | private Integer udpPort; |
| | | @Value("${spring.netty.enabled}") |
| | | private String UdpServerEnable; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | @Value("${spring.netty.udp.port}") |
| | | private Integer udpPort; |
| | | @Value("${spring.netty.udp.enabled}") |
| | | private String UdpServerEnable; |
| | | @Override |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | if (UdpServerEnable.equals("false")) { |
| | | return; |
| | | } |
| | | nettyUdpServer.init(udpPort); |
| | | log.info("UDP服务已经启动"); |
| | | log.info("管线泄露UDP服务已启动"); |
| | | } |
| | | |
| | | |
| | | @Async("alarm") |
| | | public void alarmHandler(String message) { |
| | |
| | | String start = messages[0]; |
| | | String host = messages[1]; |
| | | String tubeId = messages[2]; |
| | | String alarmTime = DateUtils.convertDate(messages[3]); |
| | | String alarmTime = DateUtils.convertDate(messages[3],"yyyy/M/d H:m:s"); |
| | | String position = messages[4]; |
| | | String type = messages[5]; |
| | | String watcher = messages[6]; |
| | |
| | | log.error("tube报警数据推送异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |