作者 朱兆平

运单API

1 -数据数据仓库报文解析服务 1 +#数据数据仓库报文解析服务
2 解析FWB,PFFM,ABME等不规则XML报文 2 解析FWB,PFFM,ABME等不规则XML报文
@@ -28,11 +28,27 @@ @@ -28,11 +28,27 @@
28 <dependencies> 28 <dependencies>
29 <dependency> 29 <dependency>
30 <groupId>org.springframework.boot</groupId> 30 <groupId>org.springframework.boot</groupId>
  31 + <artifactId>spring-boot-starter</artifactId>
  32 + <exclusions>
  33 + <exclusion>
  34 + <groupId>ch.qos.logback</groupId>
  35 + <artifactId>logback-classic</artifactId>
  36 + </exclusion>
  37 + </exclusions>
  38 + </dependency>
  39 + <dependency>
  40 + <groupId>org.springframework.boot</groupId>
31 <artifactId>spring-boot-starter-jdbc</artifactId> 41 <artifactId>spring-boot-starter-jdbc</artifactId>
32 </dependency> 42 </dependency>
33 <dependency> 43 <dependency>
34 <groupId>org.springframework.boot</groupId> 44 <groupId>org.springframework.boot</groupId>
35 <artifactId>spring-boot-starter-web</artifactId> 45 <artifactId>spring-boot-starter-web</artifactId>
  46 + <exclusions>
  47 + <exclusion>
  48 + <groupId>ch.qos.logback</groupId>
  49 + <artifactId>logback-classic</artifactId>
  50 + </exclusion>
  51 + </exclusions>
36 </dependency> 52 </dependency>
37 <dependency> 53 <dependency>
38 <groupId>org.mybatis.spring.boot</groupId> 54 <groupId>org.mybatis.spring.boot</groupId>
@@ -88,6 +104,12 @@ @@ -88,6 +104,12 @@
88 <dependency> 104 <dependency>
89 <groupId>org.springframework.boot</groupId> 105 <groupId>org.springframework.boot</groupId>
90 <artifactId>spring-boot-starter-log4j2</artifactId> 106 <artifactId>spring-boot-starter-log4j2</artifactId>
  107 + <exclusions>
  108 + <exclusion>
  109 + <groupId>org.slf4j</groupId>
  110 + <artifactId>slf4j-log4j12</artifactId>
  111 + </exclusion>
  112 + </exclusions>
91 </dependency> 113 </dependency>
92 <dependency> <!-- 加上这个才能辨认到log4j2.yml文件 --> 114 <dependency> <!-- 加上这个才能辨认到log4j2.yml文件 -->
93 <groupId>com.fasterxml.jackson.dataformat</groupId> 115 <groupId>com.fasterxml.jackson.dataformat</groupId>
1 package com.example.demo; 1 package com.example.demo;
2 2
3 -import org.slf4j.Logger;  
4 -import org.slf4j.LoggerFactory;  
5 import org.mybatis.spring.annotation.MapperScan; 3 import org.mybatis.spring.annotation.MapperScan;
6 4
7 import org.springframework.boot.SpringApplication; 5 import org.springframework.boot.SpringApplication;
@@ -16,7 +14,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; @@ -16,7 +14,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
16 @EnableEurekaClient 14 @EnableEurekaClient
17 @MapperScan("com.example.demo.mapper")//将项目中对应的mapper类的路径加进来就可以了 15 @MapperScan("com.example.demo.mapper")//将项目中对应的mapper类的路径加进来就可以了
18 public class DemoApplication { 16 public class DemoApplication {
19 - protected static final Logger logger = LoggerFactory.getLogger(DemoApplication.class);  
20 17
21 public static void main(String[] args) { 18 public static void main(String[] args) {
22 SpringApplication.run(DemoApplication.class, args); 19 SpringApplication.run(DemoApplication.class, args);
@@ -12,15 +12,15 @@ public class FSUFohController { @@ -12,15 +12,15 @@ public class FSUFohController {
12 private NMS_FSU_FOH_Service fohService; 12 private NMS_FSU_FOH_Service fohService;
13 13
14 @GetMapping("list") 14 @GetMapping("list")
15 - public Object list(@RequestParam(name = "pageNum",required = false,defaultValue = "1") 15 + public Object list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")
16 int pageNum, 16 int pageNum,
17 - @RequestParam(name = "pageSize",required = false,defaultValue = "10") 17 + @RequestParam(value = "pageSize",required = false,defaultValue = "10")
18 int pageSize){ 18 int pageSize){
19 return fohService.selectAll(pageNum,pageSize); 19 return fohService.selectAll(pageNum,pageSize);
20 } 20 }
21 21
22 @GetMapping("getByAutoid") 22 @GetMapping("getByAutoid")
23 - public Object getByAutoid(@RequestParam(name = "autoid",required = true) String autoid){ 23 + public Object getByAutoid(@RequestParam(value = "autoid",required = true) String autoid){
24 return fohService.selectByPrimaryKey(autoid); 24 return fohService.selectByPrimaryKey(autoid);
25 } 25 }
26 } 26 }
@@ -16,6 +16,7 @@ public class IMF_Reader extends Thread{ @@ -16,6 +16,7 @@ public class IMF_Reader extends Thread{
16 this.client = client; 16 this.client = client;
17 } 17 }
18 18
  19 + @Override
19 public void run() { 20 public void run() {
20 21
21 try{ 22 try{
@@ -24,11 +25,11 @@ public class IMF_Reader extends Thread{ @@ -24,11 +25,11 @@ public class IMF_Reader extends Thread{
24 if (IMF_Task.LOGIN_OK) { 25 if (IMF_Task.LOGIN_OK) {
25 String message = this.client.getMSG(); 26 String message = this.client.getMSG();
26 if (message != null) { 27 if (message != null) {
27 - FileTool.writeFile("all",message,true); 28 + FileTool.writeFileToBak(message);
28 IMF_Message_MainHandle mainHandle = new IMF_Message_MainHandle(); 29 IMF_Message_MainHandle mainHandle = new IMF_Message_MainHandle();
29 IMF_META meta = mainHandle.messageHandle(message); 30 IMF_META meta = mainHandle.messageHandle(message);
30 } 31 }
31 - logger.info("当前线程:"+Thread.currentThread().getName()); 32 + //logger.info("当前线程:"+Thread.currentThread().getName());
32 } else { 33 } else {
33 //logger.info("***"); 34 //logger.info("***");
34 } 35 }
@@ -24,9 +24,9 @@ public class IMF_Task { @@ -24,9 +24,9 @@ public class IMF_Task {
24 24
25 25
26 if (client != null) { 26 if (client != null) {
27 - IMF_Reader kako_reader = new IMF_Reader(client);  
28 - if (!kako_reader.isrunning) {  
29 - kako_reader.start(); 27 + IMF_Reader reader = new IMF_Reader(client);
  28 + if (!IMF_Reader.isrunning) {
  29 + reader.start();
30 logger.info("*********KAKO读取线程已开启***********"); 30 logger.info("*********KAKO读取线程已开启***********");
31 } else { 31 } else {
32 logger.info("*********KAKO读取线程已开启-不再启动线程*********"); 32 logger.info("*********KAKO读取线程已开启-不再启动线程*********");
@@ -43,7 +43,7 @@ public class IMF_Task { @@ -43,7 +43,7 @@ public class IMF_Task {
43 public void sendMsg(String msg){ 43 public void sendMsg(String msg){
44 if (!msg.equals(null) && !msg.isEmpty()){ 44 if (!msg.equals(null) && !msg.isEmpty()){
45 IMF_Sender kako_sender = new IMF_Sender(client,msg); 45 IMF_Sender kako_sender = new IMF_Sender(client,msg);
46 - if(!kako_sender.isrunning) { 46 + if(!IMF_Sender.isrunning) {
47 kako_sender.start(); 47 kako_sender.start();
48 } 48 }
49 } 49 }
@@ -12,6 +12,7 @@ public final class FileTool { @@ -12,6 +12,7 @@ public final class FileTool {
12 private final static String errorRootDirectory = "errorLogs";//错误的根目录名 12 private final static String errorRootDirectory = "errorLogs";//错误的根目录名
13 private final static String xmlRootDirectory = "xmlLog"; //记录已收到的报文目录 13 private final static String xmlRootDirectory = "xmlLog"; //记录已收到的报文目录
14 private final static String Cherector = "UTF-8"; 14 private final static String Cherector = "UTF-8";
  15 + private final static String messageBakDir = "xmlFromImf";
15 16
16 /** 17 /**
17 * 写入文件 18 * 写入文件
@@ -49,4 +50,18 @@ public final class FileTool { @@ -49,4 +50,18 @@ public final class FileTool {
49 } 50 }
50 51
51 } 52 }
  53 +
  54 + public static void writeFileToBak(String content){
  55 + StringBuffer stringBuffer = new StringBuffer();
  56 + stringBuffer.append(messageBakDir).append("/").append(Helper.getUUID()).append(".log");
  57 +
  58 + File file = new File(stringBuffer.toString());
  59 +
  60 + try{
  61 + FileUtils.writeStringToFile(file,content,Cherector);
  62 + }catch (IOException e){
  63 + e.printStackTrace();
  64 + }
  65 +
  66 + }
52 } 67 }
1 package com.example.demo.util.XML; 1 package com.example.demo.util.XML;
2 2
3 -import ch.qos.logback.core.joran.spi.XMLUtil; 3 +
4 import com.example.demo.DemoApplication; 4 import com.example.demo.DemoApplication;
5 import org.jdom.Document; 5 import org.jdom.Document;
6 import org.jdom.Element; 6 import org.jdom.Element;
@@ -8,7 +8,7 @@ eureka.instance.status-page-url=http://localhost:7002/index @@ -8,7 +8,7 @@ eureka.instance.status-page-url=http://localhost:7002/index
8 #eureka注册中心服务器地址 8 #eureka注册中心服务器地址
9 eureka.client.service-url.defaultZone=http://10.50.3.82:19527/eureka/ 9 eureka.client.service-url.defaultZone=http://10.50.3.82:19527/eureka/
10 #服务名 10 #服务名
11 -spring.application.name=wareHouseAnalysis 11 +spring.application.name=imf-nms-reder
12 12
13 #spring.datasource.name=CGOETL 13 #spring.datasource.name=CGOETL
14 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 14 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource