From 1a2b07f01ba4616fd9e894dddf474b56d020158c Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期一, 07 四月 2025 15:18:51 +0800 Subject: [PATCH] 整理版本 --- pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu202404/src/main/java/com/dy/simRtu202404/PipIrrMwSimulateRtu202404Application.java | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 152 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu202404/src/main/java/com/dy/simRtu202404/PipIrrMwSimulateRtu202404Application.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu202404/src/main/java/com/dy/simRtu202404/PipIrrMwSimulateRtu202404Application.java new file mode 100644 index 0000000..1473f15 --- /dev/null +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu202404/src/main/java/com/dy/simRtu202404/PipIrrMwSimulateRtu202404Application.java @@ -0,0 +1,152 @@ +package com.dy.simRtu202404; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.WebApplicationType; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; + +@Slf4j +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) //绂佹鍚姩鏁版嵁搴撹繛鎺ユ睜 +@ComponentScan(basePackages = {"com.dy.common", "com.dy.pipIrrGlobal", "com.dy.simRtu202404"}, + excludeFilters = { + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = { + com.dy.common.apiDoc.SpringApiConfig.class, //涓�绉嶆帓闄ょ被鐨勬柟寮� + com.dy.pipIrrGlobal.config.DingTalk.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = { + //浜岀鎺掗櫎绫荤殑鏂瑰紡锛屽啓姝e垯琛ㄨ揪寮忥紝闇�瑕佸鐩爣绫荤殑瀹屽叏闄愬畾鍚嶅畬鍏ㄥ尮閰嶏紝鍚﹀垯涓嶇敓鏁� + "com.dy.common.aop..*", + "com.dy.common.apiDoc..*", + "com.dy.common.multiDataSource..*", + "com.dy.common.mybatis..*", + "com.dy.common.singleDataSource..*", + "com.dy.common.webFilter..*", + "com.dy.common.webListener..*", + "com.dy.pipIrrGlobal.webCtrls..*" + }) + } +) +public class PipIrrMwSimulateRtu202404Application implements CommandLineRunner { + + public static void main(String[] args) { + parseArg0(args, 0) ; + parseArg1(args, 1) ; + parseArg2(args, 2) ; + parseArg3(args, 3) ; + parseArg4(args, 4) ; + parseArg5(args, 5) ; + + new SpringApplicationBuilder(PipIrrMwSimulateRtu202404Application.class) + .web(WebApplicationType.NONE)//涓嶅惎鍔╳eb鏈嶅姟 + .run(args); + } + + private static void parseArg0(String[] args, int index){ + if(args != null + && args.length > index + && args[index] != null + && !args[index].trim().equals("")){ + ServerProperties.rtuAddr = args[index] ;//鏈ā鎷熷櫒妯℃嫙RTU鍦板潃 + log.info("鍙傛暟1锛�" + ServerProperties.rtuAddr); + } + if(ServerProperties.rtuAddr == null){ + ServerProperties.rtuAddr = "37142501020100218" ; + } + } + private static void parseArg1(String[] args, int index){ + if(args != null + && args.length > index + && args[index] != null + && !args[index].trim().equals("")){ + ServerProperties.icCardAddr = args[index] ;//IC鍗″湴鍧� + log.info("鍙傛暟2锛�" + ServerProperties.icCardAddr); + } + if(ServerProperties.icCardAddr == null){ + ServerProperties.icCardAddr = "C49A340D" ; + } + } + private static void parseArg2(String[] args, int index){ + if(args != null + && args.length > index + && args[index] != null + && !args[index].trim().equals("")){ + ServerProperties.icCardNo = args[index] ;//IC鍗$紪鍙� + log.info("鍙傛暟3锛�" + ServerProperties.icCardNo); + } + if(ServerProperties.icCardNo == null){ + ServerProperties.icCardNo = "37142501020100257" ; + } + } + private static void parseArg3(String[] args, int index){ + if(args != null + && args.length > index + && args[index] != null + && !args[index].trim().equals("")){ + ServerProperties.serverIp = args[index] ;//閫氫俊涓棿浠舵湇鍔$IP + log.info("鍙傛暟4锛�" + ServerProperties.serverIp); + } + if(ServerProperties.serverIp == null){ + ServerProperties.serverIp = "127.0.0.1" ; + } + } + private static void parseArg4(String[] args, int index){ + if(args != null + && args.length > index + && args[index] != null + && !args[index].trim().equals("")){ + ServerProperties.serverPort = Integer.parseInt(args[index]) ;//閫氫俊涓棿浠舵湇鍔$绔彛 + log.info("鍙傛暟5锛�" + ServerProperties.serverPort); + } + if(ServerProperties.serverPort == null){ + ServerProperties.serverPort = 60000 ; + } + } + private static void parseArg5(String[] args, int index){ + if(args != null + && args.length > index + && args[index] != null + && !args[index].trim().equals("")){ + ServerProperties.type = Integer.parseInt(args[index]) ;//杩愯鏂瑰紡 + log.info("鍙傛暟6锛�" + ServerProperties.type); + } + if(ServerProperties.type == null){ + ServerProperties.type = 0 ; + } + } + /** + * Spring瀹瑰櫒鍚姩瀹屾垚鍚庯紝鎵ц涓嬮潰鏂规硶 + * @param args 鍙傛暟 + * @throws Exception 寮傚父 + */ + @Override + public void run(String... args) throws Exception { + try{ + //绛夊緟涓�涓� + Thread.sleep(500L); + }catch (Exception e){ + e.printStackTrace(); + } + finally { + this.startMwSv() ; + } + } + + private void startMwSv(){ + if(sv != null){ + sv.startServer(); + } + } + + + private Server sv ; + + @Autowired + public void setSv(Server sv){ + this.sv = sv ; + } +} -- Gitblit v1.8.0