重新更加xsd生成所有的消息pojo类 。并完整重构代码

This commit is contained in:
zhouxiunai
2018-12-07 15:29:28 +08:00
parent c02dc7929b
commit 63ffe59fd4
176 changed files with 32695 additions and 1757 deletions
@@ -3,8 +3,6 @@ package com.gzzn.omms.msgexchangeapi.service;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.util.Map;
import org.junit.Test;
@@ -17,7 +15,8 @@ import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.gzzn.omms.msgexchangeapi.dao.CminmsgDao;
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.DNLDMsg;
import com.gzzn.omms.msgexchangeapi.entity.msg.MSG;
import com.gzzn.omms.msgexchangeapi.service.exchange.IExchangeService;
import com.gzzn.omms.msgexchangeapi.utils.JsonUtil;
@RunWith(SpringRunner.class)
@@ -89,7 +88,7 @@ public class ExchangeServiceImplTest {
{
String xml = cminmsgDao.findOne(300L).getCminmsgsClobMsg();
DNLDMsg dNLDMsg = exchangeService.xmlstrToObject(xml, DNLDMsg.class);
MSG dNLDMsg = exchangeService.xmlstrToObject(xml, MSG.class);
String jsonString=JsonUtil.getString(dNLDMsg);
File file = new File("schd.json");
@@ -4,32 +4,25 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.StringUtils;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.gzzn.omms.msgexchangeapi.dao.CminmsgDao;
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
import com.gzzn.omms.msgexchangeapi.entity.msg.Msg;
import com.gzzn.omms.msgexchangeapi.entity.msg.MSG;
import com.gzzn.omms.msgexchangeapi.exception.ExchangeServiceException;
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
import com.gzzn.omms.msgexchangeapi.service.exchange.IExchangeService;
import com.gzzn.omms.msgexchangeapi.utils.JsonUtil;
@@ -55,8 +48,8 @@ public class ToolTest {
//每种类型提取一个
for(Cminmsg x : lsCmin)
{
Msg msg = exchangeService.xmlstrToObject(x.getCminmsgsClobMsg(),Msg.class);
mapCminmsg.putIfAbsent(msg.getMeta().getType() + "_" + msg.getMeta().getStyp(), x);
MSG msg = exchangeService.xmlstrToObject(x.getCminmsgsClobMsg(),MSG.class);
mapCminmsg.putIfAbsent(msg.getMETA().getTYPE() + "_" + msg.getMETA().getSTYP(), x);
}
List<Cminmsg> ls = new ArrayList(mapCminmsg.values());
@@ -76,8 +69,8 @@ public class ToolTest {
//提取某个航班的信息
List<Cminmsg> lsFlopTypeCmin = lsCmin.parallelStream()
.filter(node->{
Msg msg = exchangeService.xmlstrToObject(node.getCminmsgsClobMsg(), Msg.class);
return msg.getMeta().getType().equals("FLOP");
MSG msg = exchangeService.xmlstrToObject(node.getCminmsgsClobMsg(), MSG.class);
return msg.getMETA().getTYPE().equals("FLOP");
})
.collect(Collectors.toList());
@@ -97,18 +90,18 @@ public class ToolTest {
for(Cminmsg x : lsCmin)
{
String json = exchangeService.xmlstrToJson(x.getCminmsgsClobMsg());
Msg msg;
MSG msg;
msg = JsonUtil.getObject(json,Msg.class);
String Dttm = msg.getMeta().getDttm();
msg = JsonUtil.getObject(json,MSG.class);
String Dttm = msg.getMETA().getDTTM().toString();
String dir = "json";
StringBuilder path = new StringBuilder();
path.append(dir);
path.append("/");
path.append(msg.getMeta().getType());//Type
path.append("-"+msg.getMeta().getStyp());//Subtype
path.append(msg.getMETA().getTYPE());//Type
// path.append("-"+msg.getMETA().getSTYP());//Subtype
path.append(".json");
//父目录是否存在
@@ -152,7 +145,7 @@ public class ToolTest {
try {
for(Cminmsg x : lsCmin)
{
Msg msg = exchangeService.xmlstrToObject(x.getCminmsgsClobMsg(), Msg.class);
MSG msg = exchangeService.xmlstrToObject(x.getCminmsgsClobMsg(), MSG.class);
Map msgMap = exchangeService.xmlstrToObject(x.getCminmsgsClobMsg(), Map.class);
@@ -190,22 +183,22 @@ public class ToolTest {
} //end function
private String getPath(Msg msg,String type)
private String getPath(MSG msg,String type)
{
String dir = type;
StringBuilder path = new StringBuilder();
path.append(dir);
path.append("/");
path.append(msg.getMeta().getType());//Type
path.append("-"+msg.getMeta().getStyp());//Subtype
path.append(msg.getMETA().getTYPE());//Type
path.append("-"+msg.getMETA().getSTYP());//Subtype
path.append("."+dir);
return path.toString();
}
private String getPathGroupByFlid(Msg msg,String type,String flid)
private String getPathGroupByFlid(MSG msg,String type,String flid)
{
String dir = type;
@@ -214,9 +207,9 @@ public class ToolTest {
path.append("/");
path.append(flid);
path.append("/");
path.append(msg.getMeta().getDttm());//dttm
path.append("-"+msg.getMeta().getType());//Type
path.append("-"+msg.getMeta().getStyp());//Subtype
path.append(msg.getMETA().getDTTM());//dttm
path.append("-"+msg.getMETA().getTYPE());//Type
path.append("-"+msg.getMETA().getSTYP());//Subtype
path.append("."+dir);
return path.toString();
@@ -0,0 +1,55 @@
package com.gzzn.omms.msgexchangeapi.tools;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.gzzn.omms.msgexchangeapi.dao.CminmsgDao;
import com.gzzn.omms.msgexchangeapi.service.exchange.IExchangeService;
/**
* xml 转 pojo
* @author zhouxiunai
*
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class XmlToPojoTest {
@Autowired
private CminmsgDao cminmsgDao;
@Autowired
private IExchangeService exchangeService;
/**
* xml 生成 pojo
*/
@Test
public void testXmlToPojo()
{
String xml = cminmsgDao.findOne(300L).getCminmsgsClobMsg();
//生成pojo类
Map map = exchangeService.xmlstrToObject(xml, Map.class);
}
private void genPojo(Map map,String rootName)
{
//写类的开始
Set<String> keyset = map.keySet();
for( String key: keyset)
{
}
//写类的结束
}//end function
}
@@ -1,12 +1,14 @@
package com.gzzn.omms.msgexchangeapi.utils;
import java.math.BigInteger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.FLTR;
import com.gzzn.omms.msgexchangeapi.entity.msg.SCHD;
import com.gzzn.omms.msgexchangeapi.redis.RedisService;
@RunWith(SpringRunner.class)
@@ -20,10 +22,10 @@ public class RedisServiceTest {
public void testReids()
{
//准备数据
FLTR flightInfo = new FLTR();
flightInfo.setFLID("12333");
SCHD.FLTR flightInfo = new SCHD.FLTR();
flightInfo.setFLID(new BigInteger("12333"));
flightInfo.setACFT("acft");
redisService.set(flightInfo.getFLID(), flightInfo);
redisService.set(flightInfo.getFLID().toString(), flightInfo);
}
}