作者 朱兆平

线程修改

... ... @@ -38,12 +38,12 @@ spring:
#eureka主机名,会在控制页面中显示
#DEV环境关闭注册。
features:
enabled: false
enabled: true
discovery:
enabled: false
enabled: true
service-registry:
auto-registration:
enabled: false
enabled: true
datasource:
type: com.alibaba.druid.pool.DruidDataSource
... ... @@ -93,7 +93,7 @@ eureka:
client:
#eureka注册中心服务器地址
service-url:
defaultZone: http://10.50.3.82:19527/eureka/
defaultZone: http://192.168.1.53:12345/eureka/
registry-fetch-interval-seconds: 30
lease-renewal-interval-in-seconds: 15
lease-expiration-duration-in-seconds: 45
... ... @@ -144,6 +144,8 @@ custom:
delTechnologyReceptMatch: CN_MT(.*)_1P0_460470678920X_(.*).xml
#报文导入生成目录,这个地方目录结尾要带/
extRedioMsgDir: /Users/mrz/Downloads/rdp_temp/logs/transmit/
#系统类型 [windows,linux]转换换行符用来的判断
operationSystemType: windows
devops:
dir:
singlewindow-tcs-recept: D:\TCSSingleWindow\recive
... ...
... ... @@ -3,6 +3,7 @@ package com.tianbo.analysis.controller;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
... ... @@ -23,8 +24,12 @@ public class RadioMsgController {
@Value("${custom.extRedioMsgDir}")
private String extRedioMsgDir;
//系统类型
@Value("${custom.operationSystemType}")
private String operationSystemType;
private final static String FFM_HEADER = "<MSG>\n" +
"<META>\n" +
"<META>\r\n" +
"<SNDR>TXD</SNDR>\n" +
"<DDTM>20200113050339</DDTM>\n" +
"<TYPE>IATA</TYPE>\n" +
... ... @@ -60,13 +65,14 @@ public class RadioMsgController {
private final static String FHL_FOOTER="\n</FHL>\n" +
"</MSG>";
@PostMapping("ffm")
@GetMapping("ffm")
public int extFFM(String ffmmsg){
if (ffmmsg!=null){
ffmmsg = FFM_HEADER + ffmmsg;
ffmmsg = ffmmsg + FFM_FOOTER;
File file = new File(extRedioMsgDir+UUID.randomUUID()+".txt");
try {
ffmmsg = redioStrFilter(ffmmsg);
FileUtils.writeStringToFile(file,ffmmsg,"UTF-8");
log.info("FFM报文导入成功");
return 1;
... ... @@ -78,13 +84,14 @@ public class RadioMsgController {
}
@PostMapping("fwb")
@GetMapping("fwb")
public int extFWB(String ffmmsg){
if (ffmmsg!=null) {
ffmmsg = FWB_HEADER + ffmmsg;
ffmmsg = ffmmsg + FWB_FOOTER;
File file = new File(extRedioMsgDir + UUID.randomUUID() + ".txt");
try {
ffmmsg = redioStrFilter(ffmmsg);
FileUtils.writeStringToFile(file, ffmmsg, "UTF-8");
log.info("FWB报文导入成功");
return 1;
... ... @@ -95,13 +102,14 @@ public class RadioMsgController {
return 0;
}
@PostMapping("fhl")
@GetMapping("fhl")
public int extFHL(String ffmmsg){
if (ffmmsg!=null) {
ffmmsg = FHL_HEADER + ffmmsg;
ffmmsg = ffmmsg + FHL_FOOTER;
File file = new File(extRedioMsgDir + UUID.randomUUID() + ".txt");
try {
ffmmsg = redioStrFilter(ffmmsg);
FileUtils.writeStringToFile(file, ffmmsg, "UTF-8");
log.info("FHL报文导入成功");
return 1;
... ... @@ -111,4 +119,21 @@ public class RadioMsgController {
}
return 0;
}
/**
* 过滤处理不同操作系统的换行符
* @param content
* @return
*/
private String redioStrFilter(String content){
if ("windows".equals(operationSystemType)){
/**
* 如果用户端的操作系统是windows,那么传过来的报文内容的换行符是\r\n,
* 先删除文本中过来的\r,再统一替换成\r\n.
* 如果用户端的操作系统是linux,则无所谓
*/
content = content.replaceAll("\\r?\\n","\r\n");
}
return content;
}
}
... ...
... ... @@ -24,8 +24,8 @@ public class AgentXmlHandle {
public void Http_resolver(CustomReception customReception){
try{
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(5000);
requestFactory.setReadTimeout(5000);
requestFactory.setConnectTimeout(3000);
requestFactory.setReadTimeout(3000);
RestTemplate restTemplate = new RestTemplate(requestFactory);
String secondSplit = "_";
... ...
... ... @@ -36,7 +36,7 @@ public class TaskAnalysis {
/**
* 线程数量
*/
private final static int theadamount = 50;
private final static int theadamount = 64;
@Scheduled(fixedRate = 5000)
public void startTask(){
... ...
... ... @@ -11,7 +11,7 @@ public class XMLThreadPoolFactory {
public static ThreadPoolExecutor instance(){
if (threadPool==null){
XMLThreadFactory xmlThreadFactory = new XMLThreadFactory("xml");
threadPool = new ThreadPoolExecutor(10, 100,
threadPool = new ThreadPoolExecutor(64, 128,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1024),
xmlThreadFactory,
... ...