作者 朱兆平

线程修改

@@ -38,12 +38,12 @@ spring: @@ -38,12 +38,12 @@ spring:
38 #eureka主机名,会在控制页面中显示 38 #eureka主机名,会在控制页面中显示
39 #DEV环境关闭注册。 39 #DEV环境关闭注册。
40 features: 40 features:
41 - enabled: false 41 + enabled: true
42 discovery: 42 discovery:
43 - enabled: false 43 + enabled: true
44 service-registry: 44 service-registry:
45 auto-registration: 45 auto-registration:
46 - enabled: false 46 + enabled: true
47 47
48 datasource: 48 datasource:
49 type: com.alibaba.druid.pool.DruidDataSource 49 type: com.alibaba.druid.pool.DruidDataSource
@@ -93,7 +93,7 @@ eureka: @@ -93,7 +93,7 @@ eureka:
93 client: 93 client:
94 #eureka注册中心服务器地址 94 #eureka注册中心服务器地址
95 service-url: 95 service-url:
96 - defaultZone: http://10.50.3.82:19527/eureka/ 96 + defaultZone: http://192.168.1.53:12345/eureka/
97 registry-fetch-interval-seconds: 30 97 registry-fetch-interval-seconds: 30
98 lease-renewal-interval-in-seconds: 15 98 lease-renewal-interval-in-seconds: 15
99 lease-expiration-duration-in-seconds: 45 99 lease-expiration-duration-in-seconds: 45
@@ -144,6 +144,8 @@ custom: @@ -144,6 +144,8 @@ custom:
144 delTechnologyReceptMatch: CN_MT(.*)_1P0_460470678920X_(.*).xml 144 delTechnologyReceptMatch: CN_MT(.*)_1P0_460470678920X_(.*).xml
145 #报文导入生成目录,这个地方目录结尾要带/ 145 #报文导入生成目录,这个地方目录结尾要带/
146 extRedioMsgDir: /Users/mrz/Downloads/rdp_temp/logs/transmit/ 146 extRedioMsgDir: /Users/mrz/Downloads/rdp_temp/logs/transmit/
  147 + #系统类型 [windows,linux]转换换行符用来的判断
  148 + operationSystemType: windows
147 devops: 149 devops:
148 dir: 150 dir:
149 singlewindow-tcs-recept: D:\TCSSingleWindow\recive 151 singlewindow-tcs-recept: D:\TCSSingleWindow\recive
@@ -3,6 +3,7 @@ package com.tianbo.analysis.controller; @@ -3,6 +3,7 @@ package com.tianbo.analysis.controller;
3 import lombok.extern.slf4j.Slf4j; 3 import lombok.extern.slf4j.Slf4j;
4 import org.apache.commons.io.FileUtils; 4 import org.apache.commons.io.FileUtils;
5 import org.springframework.beans.factory.annotation.Value; 5 import org.springframework.beans.factory.annotation.Value;
  6 +import org.springframework.web.bind.annotation.GetMapping;
6 import org.springframework.web.bind.annotation.PostMapping; 7 import org.springframework.web.bind.annotation.PostMapping;
7 import org.springframework.web.bind.annotation.RequestMapping; 8 import org.springframework.web.bind.annotation.RequestMapping;
8 import org.springframework.web.bind.annotation.RestController; 9 import org.springframework.web.bind.annotation.RestController;
@@ -23,8 +24,12 @@ public class RadioMsgController { @@ -23,8 +24,12 @@ public class RadioMsgController {
23 @Value("${custom.extRedioMsgDir}") 24 @Value("${custom.extRedioMsgDir}")
24 private String extRedioMsgDir; 25 private String extRedioMsgDir;
25 26
  27 + //系统类型
  28 + @Value("${custom.operationSystemType}")
  29 + private String operationSystemType;
  30 +
26 private final static String FFM_HEADER = "<MSG>\n" + 31 private final static String FFM_HEADER = "<MSG>\n" +
27 - "<META>\n" + 32 + "<META>\r\n" +
28 "<SNDR>TXD</SNDR>\n" + 33 "<SNDR>TXD</SNDR>\n" +
29 "<DDTM>20200113050339</DDTM>\n" + 34 "<DDTM>20200113050339</DDTM>\n" +
30 "<TYPE>IATA</TYPE>\n" + 35 "<TYPE>IATA</TYPE>\n" +
@@ -60,13 +65,14 @@ public class RadioMsgController { @@ -60,13 +65,14 @@ public class RadioMsgController {
60 private final static String FHL_FOOTER="\n</FHL>\n" + 65 private final static String FHL_FOOTER="\n</FHL>\n" +
61 "</MSG>"; 66 "</MSG>";
62 67
63 - @PostMapping("ffm") 68 + @GetMapping("ffm")
64 public int extFFM(String ffmmsg){ 69 public int extFFM(String ffmmsg){
65 if (ffmmsg!=null){ 70 if (ffmmsg!=null){
66 ffmmsg = FFM_HEADER + ffmmsg; 71 ffmmsg = FFM_HEADER + ffmmsg;
67 ffmmsg = ffmmsg + FFM_FOOTER; 72 ffmmsg = ffmmsg + FFM_FOOTER;
68 File file = new File(extRedioMsgDir+UUID.randomUUID()+".txt"); 73 File file = new File(extRedioMsgDir+UUID.randomUUID()+".txt");
69 try { 74 try {
  75 + ffmmsg = redioStrFilter(ffmmsg);
70 FileUtils.writeStringToFile(file,ffmmsg,"UTF-8"); 76 FileUtils.writeStringToFile(file,ffmmsg,"UTF-8");
71 log.info("FFM报文导入成功"); 77 log.info("FFM报文导入成功");
72 return 1; 78 return 1;
@@ -78,13 +84,14 @@ public class RadioMsgController { @@ -78,13 +84,14 @@ public class RadioMsgController {
78 } 84 }
79 85
80 86
81 - @PostMapping("fwb") 87 + @GetMapping("fwb")
82 public int extFWB(String ffmmsg){ 88 public int extFWB(String ffmmsg){
83 if (ffmmsg!=null) { 89 if (ffmmsg!=null) {
84 ffmmsg = FWB_HEADER + ffmmsg; 90 ffmmsg = FWB_HEADER + ffmmsg;
85 ffmmsg = ffmmsg + FWB_FOOTER; 91 ffmmsg = ffmmsg + FWB_FOOTER;
86 File file = new File(extRedioMsgDir + UUID.randomUUID() + ".txt"); 92 File file = new File(extRedioMsgDir + UUID.randomUUID() + ".txt");
87 try { 93 try {
  94 + ffmmsg = redioStrFilter(ffmmsg);
88 FileUtils.writeStringToFile(file, ffmmsg, "UTF-8"); 95 FileUtils.writeStringToFile(file, ffmmsg, "UTF-8");
89 log.info("FWB报文导入成功"); 96 log.info("FWB报文导入成功");
90 return 1; 97 return 1;
@@ -95,13 +102,14 @@ public class RadioMsgController { @@ -95,13 +102,14 @@ public class RadioMsgController {
95 return 0; 102 return 0;
96 } 103 }
97 104
98 - @PostMapping("fhl") 105 + @GetMapping("fhl")
99 public int extFHL(String ffmmsg){ 106 public int extFHL(String ffmmsg){
100 if (ffmmsg!=null) { 107 if (ffmmsg!=null) {
101 ffmmsg = FHL_HEADER + ffmmsg; 108 ffmmsg = FHL_HEADER + ffmmsg;
102 ffmmsg = ffmmsg + FHL_FOOTER; 109 ffmmsg = ffmmsg + FHL_FOOTER;
103 File file = new File(extRedioMsgDir + UUID.randomUUID() + ".txt"); 110 File file = new File(extRedioMsgDir + UUID.randomUUID() + ".txt");
104 try { 111 try {
  112 + ffmmsg = redioStrFilter(ffmmsg);
105 FileUtils.writeStringToFile(file, ffmmsg, "UTF-8"); 113 FileUtils.writeStringToFile(file, ffmmsg, "UTF-8");
106 log.info("FHL报文导入成功"); 114 log.info("FHL报文导入成功");
107 return 1; 115 return 1;
@@ -111,4 +119,21 @@ public class RadioMsgController { @@ -111,4 +119,21 @@ public class RadioMsgController {
111 } 119 }
112 return 0; 120 return 0;
113 } 121 }
  122 +
  123 + /**
  124 + * 过滤处理不同操作系统的换行符
  125 + * @param content
  126 + * @return
  127 + */
  128 + private String redioStrFilter(String content){
  129 + if ("windows".equals(operationSystemType)){
  130 + /**
  131 + * 如果用户端的操作系统是windows,那么传过来的报文内容的换行符是\r\n,
  132 + * 先删除文本中过来的\r,再统一替换成\r\n.
  133 + * 如果用户端的操作系统是linux,则无所谓
  134 + */
  135 + content = content.replaceAll("\\r?\\n","\r\n");
  136 + }
  137 + return content;
  138 + }
114 } 139 }
@@ -24,8 +24,8 @@ public class AgentXmlHandle { @@ -24,8 +24,8 @@ public class AgentXmlHandle {
24 public void Http_resolver(CustomReception customReception){ 24 public void Http_resolver(CustomReception customReception){
25 try{ 25 try{
26 SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); 26 SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
27 - requestFactory.setConnectTimeout(5000);  
28 - requestFactory.setReadTimeout(5000); 27 + requestFactory.setConnectTimeout(3000);
  28 + requestFactory.setReadTimeout(3000);
29 RestTemplate restTemplate = new RestTemplate(requestFactory); 29 RestTemplate restTemplate = new RestTemplate(requestFactory);
30 30
31 String secondSplit = "_"; 31 String secondSplit = "_";
@@ -36,7 +36,7 @@ public class TaskAnalysis { @@ -36,7 +36,7 @@ public class TaskAnalysis {
36 /** 36 /**
37 * 线程数量 37 * 线程数量
38 */ 38 */
39 - private final static int theadamount = 50; 39 + private final static int theadamount = 64;
40 40
41 @Scheduled(fixedRate = 5000) 41 @Scheduled(fixedRate = 5000)
42 public void startTask(){ 42 public void startTask(){
@@ -11,7 +11,7 @@ public class XMLThreadPoolFactory { @@ -11,7 +11,7 @@ public class XMLThreadPoolFactory {
11 public static ThreadPoolExecutor instance(){ 11 public static ThreadPoolExecutor instance(){
12 if (threadPool==null){ 12 if (threadPool==null){
13 XMLThreadFactory xmlThreadFactory = new XMLThreadFactory("xml"); 13 XMLThreadFactory xmlThreadFactory = new XMLThreadFactory("xml");
14 - threadPool = new ThreadPoolExecutor(10, 100, 14 + threadPool = new ThreadPoolExecutor(64, 128,
15 0L, TimeUnit.MILLISECONDS, 15 0L, TimeUnit.MILLISECONDS,
16 new LinkedBlockingQueue<Runnable>(1024), 16 new LinkedBlockingQueue<Runnable>(1024),
17 xmlThreadFactory, 17 xmlThreadFactory,