作者 朱兆平

运单API

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