diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/InusedScheduleResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/InusedScheduleResponse.java index 0c282b2..caf97f1 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/InusedScheduleResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/InusedScheduleResponse.java @@ -90,7 +90,6 @@ public class InusedScheduleResponse extends MessageResponse { planBuild.setLineId(this.lineId); planBuild.setDate(DateTimeUtil.epochSecond(this.date)); planBuild.setActionId(this.subId.val()); - planBuild.setTrainId(this.trainId); planBuilds.add(planBuild); return planBuilds; } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index a72eef8..c60a814 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -19,7 +19,7 @@ occ: lineId: 3 collectorData: false #故障测试 -mock-alert-test: false +mock-alert-test: true #加载历史模拟数据 load-mock-history-data: false #延时加载告警处理 diff --git a/src/test/java/club/joylink/xiannccda/service/CacheTest.java b/src/test/java/club/joylink/xiannccda/service/CacheTest.java new file mode 100644 index 0000000..97477fa --- /dev/null +++ b/src/test/java/club/joylink/xiannccda/service/CacheTest.java @@ -0,0 +1,102 @@ +package club.joylink.xiannccda.service; + +import club.joylink.xiannccda.ats.message.MessageData; +import club.joylink.xiannccda.ats.message.MessageId; +import club.joylink.xiannccda.ats.message.OccMessageEncoder; +import club.joylink.xiannccda.ats.message.OccMessageManage; +import club.joylink.xiannccda.entity.DeviceAreaConfig; +import club.joylink.xiannccda.mock.message.occ.MockOccServer; +import club.joylink.xiannccda.mock.message.occ.OutHandle; +import club.joylink.xiannccda.repository.impl.DeviceAreaConfigRepository; +import club.joylink.xiannccda.vo.AreaConfigVO; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +public class CacheTest { + + @Autowired + private DeviceAreaConfigRepository deviceAreaConfigRepository; + @Autowired + private OccMessageManage occMessageManage; + + @Autowired + private OutHandle outHandle; + + @Test + public void timeOutTest() throws InterruptedException { + for (var i = 0; i < 17; i++) { + System.out.println("----------------"); + new Thread(() -> { + List configs = deviceAreaConfigRepository.list(Wrappers.lambdaQuery(DeviceAreaConfig.class).eq(DeviceAreaConfig::getLineId, 3)); + List listVO = configs.stream().map(AreaConfigVO::new).toList(); + }).start(); + } + + TimeUnit.HOURS.sleep(1); + } + + @Test + public void test2() throws InterruptedException { +// MessageData md = MessageId.MESSAGE_POLLING.create(); +// this.occServer.write(md); +// TimeUnit.SECONDS.sleep(10); +// this.occServer.disconnect(); +/* try { + this.occMessageManage.sendMsg(3, md, true); + } catch (Exception e) { + e.printStackTrace(); + }*/ + TimeUnit.HOURS.sleep(1); + } + + @Test + public void testServer() throws InterruptedException { + this.initClient(); + TimeUnit.HOURS.sleep(1); + } + + public void initClient() { + EventLoopGroup bossGroup = new NioEventLoopGroup(); + EventLoopGroup workerGroup = new NioEventLoopGroup(); + ServerBootstrap serverBootstrap = new ServerBootstrap(); + serverBootstrap.group(bossGroup, workerGroup) + .channel(NioServerSocketChannel.class) + .childHandler(new ChannelInitializer() { + @Override + public void initChannel(SocketChannel ch) throws Exception { + ChannelPipeline pipeline = ch.pipeline(); + pipeline.addLast(outHandle); + pipeline.addLast(new OccMessageEncoder(null)); + } + }) + .option(ChannelOption.SO_BACKLOG, 128) + .childOption(ChannelOption.SO_KEEPALIVE, true); + + try { + ChannelFuture future = serverBootstrap.bind(2603).sync(); + if (future.isSuccess()) { + +// log.info(String.format("modbus-tcp server start on port [%s]", this.modbusTcpConfig.getPort())); + } else { +// log.error("modbus-tcp server start failed", future.cause()); + } + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } +}