重新更加xsd生成所有的消息pojo类 。并完整重构代码
This commit is contained in:
@@ -13,7 +13,8 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
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.service.exchange.IExchangeService;
|
||||
|
||||
@Service("cminmsgService")
|
||||
public class CminmsgServiceImpl implements ICminmsgService {
|
||||
@@ -73,9 +74,9 @@ public class CminmsgServiceImpl implements ICminmsgService {
|
||||
.stream()
|
||||
.filter(x->{
|
||||
String msgBlob = x.getCminmsgsClobMsg();
|
||||
Msg msg = exchangeService.xmlstrToObject(msgBlob, Msg.class);
|
||||
String type = msg.getMeta().getType();
|
||||
String subType = msg.getMeta().getStyp();
|
||||
MSG msg = exchangeService.xmlstrToObject(msgBlob, MSG.class);
|
||||
String type = msg.getMETA().getTYPE().name();
|
||||
String subType = msg.getMETA().getSTYP().name();
|
||||
return type.equals("SCHD") && subType.equals("RESP");
|
||||
})
|
||||
.findFirst();
|
||||
|
||||
@@ -8,8 +8,14 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.dao.CmoutmsgDao;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.Cmoutmsg;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.rqfd.RefdMsg;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.rqfd.RefdMsgBody;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.MESSAGESUBTYPES;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.MESSAGETYPES;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.MSG;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.RQFD;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.SUBSYSTEMS;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.builder.METABuilder;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.builder.MSGBuilder;
|
||||
import com.gzzn.omms.msgexchangeapi.service.exchange.IExchangeService;
|
||||
import com.gzzn.omms.msgexchangeapi.utils.DateTimeUtil;
|
||||
|
||||
@Service
|
||||
@@ -23,18 +29,29 @@ public class CmoutmsgServiceImpl implements ICmoutmsgService {
|
||||
public Boolean sendSchdGetMsg(Date date)
|
||||
{
|
||||
//构造消息
|
||||
MSG rqfdMsg = new MSGBuilder().
|
||||
setMETA(
|
||||
new METABuilder()
|
||||
.setSNDR(SUBSYSTEMS.OMMS)
|
||||
.setTYPE(MESSAGETYPES.RQFD)
|
||||
.setSTYP(MESSAGESUBTYPES.NONE)
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
|
||||
RQFD rqfd = new RQFD();
|
||||
rqfd.setSTDB(
|
||||
DateTimeUtil.gtFormatStr(
|
||||
date,
|
||||
"ddMMMyyHHmm",
|
||||
Locale.ENGLISH)
|
||||
.toUpperCase()
|
||||
);
|
||||
rqfdMsg.setRQFD(rqfd);
|
||||
|
||||
//发送消息到数据库
|
||||
Cmoutmsg cmoutmsg = new Cmoutmsg();
|
||||
RefdMsgBody body = new RefdMsgBody();
|
||||
body.setStdb(
|
||||
DateTimeUtil.gtFormatStr(
|
||||
date,
|
||||
"ddMMMyyHHmm",
|
||||
Locale.ENGLISH)
|
||||
.toUpperCase()
|
||||
);
|
||||
RefdMsg msg = new RefdMsg();
|
||||
msg.setRefd(body);
|
||||
cmoutmsg.setCminmsgsClobMsg(exchangeService.objectToXmlstr(msg));
|
||||
cmoutmsg.setCminmsgsClobMsg(exchangeService.objectToXmlstr(rqfdMsg));
|
||||
cmoutmsg.setCminmsgsStatus("VALID");
|
||||
|
||||
Cmoutmsg rtCmoutmsg = cmoutmsgDao.save(cmoutmsg);
|
||||
|
||||
+1
-5
@@ -1,4 +1,4 @@
|
||||
package com.gzzn.omms.msgexchangeapi.service;
|
||||
package com.gzzn.omms.msgexchangeapi.service.exchange;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@@ -26,10 +26,6 @@ public class ExchangeServiceImpl implements IExchangeService {
|
||||
ObjectMapper jsonMapper = new ObjectMapper();
|
||||
String json = jsonMapper.writer().withDefaultPrettyPrinter().writeValueAsString(map);
|
||||
return json;
|
||||
} catch (JsonParseException e) {
|
||||
throw new ExchangeServiceException(e.getMessage(),e);
|
||||
} catch (JsonMappingException e) {
|
||||
throw new ExchangeServiceException(e.getMessage(),e);
|
||||
} catch (IOException e) {
|
||||
throw new ExchangeServiceException(e.getMessage(),e);
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.gzzn.omms.msgexchangeapi.service;
|
||||
package com.gzzn.omms.msgexchangeapi.service.exchange;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.exception.ExchangeServiceException;
|
||||
|
||||
+13
-13
@@ -8,11 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.DNLDMsg;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.FLTR;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.MSG;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.SCHD;
|
||||
import com.gzzn.omms.msgexchangeapi.msghandler.MsgHandlerDispatcher;
|
||||
import com.gzzn.omms.msgexchangeapi.redis.RedisService;
|
||||
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
|
||||
import com.gzzn.omms.msgexchangeapi.service.exchange.IExchangeService;
|
||||
|
||||
@Service("flightInfoService")
|
||||
public class FlightInfoServiceImpl implements IFlightInfoService {
|
||||
@@ -30,16 +30,16 @@ public class FlightInfoServiceImpl implements IFlightInfoService {
|
||||
@Override
|
||||
public Boolean updateByDaySchd(Cminmsg cminmsg) {
|
||||
String clobMsg = cminmsg.getCminmsgsClobMsg();
|
||||
DNLDMsg dnldMsg = exchangeService.xmlstrToObject(clobMsg, DNLDMsg.class);
|
||||
MSG dnldMsg = exchangeService.xmlstrToObject(clobMsg, MSG.class);
|
||||
|
||||
this.removeAll();
|
||||
|
||||
//
|
||||
List<FLTR> lsFltr = dnldMsg
|
||||
List<SCHD.FLTR> lsFltr = dnldMsg
|
||||
.getSCHD()
|
||||
.getFLTR();
|
||||
|
||||
for(FLTR fltr : lsFltr)
|
||||
for(SCHD.FLTR fltr : lsFltr)
|
||||
{
|
||||
Boolean result = redisSet(fltr);
|
||||
if(result == false)
|
||||
@@ -53,14 +53,14 @@ public class FlightInfoServiceImpl implements IFlightInfoService {
|
||||
|
||||
|
||||
@Override
|
||||
public FLTR getByFlid(String flid) {
|
||||
FLTR fltr = (FLTR) redisGet(flid);
|
||||
public SCHD.FLTR getByFlid(String flid) {
|
||||
SCHD.FLTR fltr = (SCHD.FLTR) redisGet(flid);
|
||||
return fltr;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean saveFltr(FLTR fltr) {
|
||||
public boolean saveFltr(SCHD.FLTR fltr) {
|
||||
return redisSet(fltr);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class FlightInfoServiceImpl implements IFlightInfoService {
|
||||
* @param fltr
|
||||
* @return
|
||||
*/
|
||||
private boolean redisSet(FLTR fltr)
|
||||
private boolean redisSet(SCHD.FLTR fltr)
|
||||
{
|
||||
return redisService.set(redisKey + fltr.getFLID(), fltr);
|
||||
}
|
||||
@@ -96,12 +96,12 @@ public class FlightInfoServiceImpl implements IFlightInfoService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<FLTR> findAll() {
|
||||
public List<SCHD.FLTR> findAll() {
|
||||
Set<String> keys = redisService.keys(redisKey + "*");
|
||||
|
||||
List<FLTR> lsResult = new ArrayList();
|
||||
List<SCHD.FLTR> lsResult = new ArrayList();
|
||||
keys.forEach(key->{
|
||||
FLTR fltr = (FLTR) redisService.get(key);
|
||||
SCHD.FLTR fltr = (SCHD.FLTR) redisService.get(key);
|
||||
lsResult.add(fltr);
|
||||
});
|
||||
|
||||
|
||||
+4
-4
@@ -3,7 +3,7 @@ package com.gzzn.omms.msgexchangeapi.service.flightInfo;
|
||||
import java.util.List;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.FLTR;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.SCHD;
|
||||
|
||||
public interface IFlightInfoService {
|
||||
|
||||
@@ -11,7 +11,7 @@ public interface IFlightInfoService {
|
||||
* 获取所有动态航班信息
|
||||
* @return 所有最新的动态航班信息
|
||||
*/
|
||||
public List<FLTR> findAll();
|
||||
public List<SCHD.FLTR> findAll();
|
||||
|
||||
|
||||
/**
|
||||
@@ -24,10 +24,10 @@ public interface IFlightInfoService {
|
||||
* @param flid
|
||||
* @return
|
||||
*/
|
||||
public FLTR getByFlid(String flid);
|
||||
public SCHD.FLTR getByFlid(String flid);
|
||||
|
||||
/**
|
||||
* 保存航班动态信息,新增或更新
|
||||
*/
|
||||
public boolean saveFltr(FLTR fltr);
|
||||
public boolean saveFltr(SCHD.FLTR fltr);
|
||||
}
|
||||
|
||||
+7
-7
@@ -4,12 +4,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.FLTR;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.SCHD;
|
||||
|
||||
public class UpdateByCminmsgsResult {
|
||||
private Boolean isSuccess;//是否更新成功
|
||||
private Cminmsg cminmsg; //消息
|
||||
private List<FLTR> fltrs; //影响的航班动态信息
|
||||
private List<SCHD.FLTR> fltrs; //影响的航班动态信息
|
||||
|
||||
public Boolean getIsSuccess() {
|
||||
return isSuccess;
|
||||
@@ -23,21 +23,21 @@ public class UpdateByCminmsgsResult {
|
||||
public void setCminmsg(Cminmsg cminmsg) {
|
||||
this.cminmsg = cminmsg;
|
||||
}
|
||||
public List<FLTR> getFltrs() {
|
||||
public List<SCHD.FLTR> getFltrs() {
|
||||
return fltrs;
|
||||
}
|
||||
public void setFltrs(List<FLTR> fltrs) {
|
||||
public void setFltrs(List<SCHD.FLTR> fltrs) {
|
||||
this.fltrs = fltrs;
|
||||
}
|
||||
|
||||
|
||||
public static UpdateByCminmsgsResult success(Cminmsg cminmsg,FLTR fltr)
|
||||
public static UpdateByCminmsgsResult success(Cminmsg cminmsg,SCHD.FLTR fltr)
|
||||
{
|
||||
UpdateByCminmsgsResult updateByCminmsgsResult = new UpdateByCminmsgsResult();
|
||||
updateByCminmsgsResult.isSuccess = true;
|
||||
updateByCminmsgsResult.cminmsg = cminmsg;
|
||||
|
||||
List<FLTR> fltrs = new ArrayList();
|
||||
List<SCHD.FLTR> fltrs = new ArrayList();
|
||||
fltrs.add(fltr);
|
||||
|
||||
updateByCminmsgsResult.fltrs = fltrs;
|
||||
@@ -45,7 +45,7 @@ public class UpdateByCminmsgsResult {
|
||||
return updateByCminmsgsResult;
|
||||
}//end function
|
||||
|
||||
public static UpdateByCminmsgsResult success(Cminmsg cminmsg,List<FLTR> fltrs)
|
||||
public static UpdateByCminmsgsResult success(Cminmsg cminmsg,List<SCHD.FLTR> fltrs)
|
||||
{
|
||||
|
||||
UpdateByCminmsgsResult updateByCminmsgsResult = new UpdateByCminmsgsResult();
|
||||
|
||||
Reference in New Issue
Block a user