提取发送获取日航班计划消息的代码

This commit is contained in:
zhouxiunai
2018-12-06 14:57:32 +08:00
parent 3e588fecf6
commit 47e473d9b1
3 changed files with 69 additions and 29 deletions
@@ -1,7 +1,6 @@
package com.gzzn.omms.msgexchangeapi.runner;
import java.util.Date;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -9,14 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
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.redis.RedisKeyConstant;
import com.gzzn.omms.msgexchangeapi.redis.RedisService;
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
import com.gzzn.omms.msgexchangeapi.utils.DateTimeUtil;
import com.gzzn.omms.msgexchangeapi.service.ICmoutmsgService;
@Component
public class AppRunner implements CommandLineRunner {
@@ -26,35 +20,18 @@ public class AppRunner implements CommandLineRunner {
@Autowired
RedisService redisService;
@Autowired
private CmoutmsgDao cmoutmsgDao;
@Autowired
private IExchangeService exchangeService;
private ICmoutmsgService cmoutmsgService;
@Override
public void run(String... args) throws Exception {
logger.info("发送获取动态航班日计划的消息");
//构造消息
Date nowDate = new Date();
Cmoutmsg cmoutmsg = new Cmoutmsg();
RefdMsgBody body = new RefdMsgBody();
body.setStdb(
DateTimeUtil.gtFormatStr(
nowDate,
"ddMMMyyHHmm",
Locale.ENGLISH)
.toUpperCase()
);
RefdMsg msg = new RefdMsg();
msg.setRefd(body);
cmoutmsg.setCminmsgsClobMsg(exchangeService.objectToXmlstr(msg));
cmoutmsg.setCminmsgsStatus("VALID");
cmoutmsgDao.save(cmoutmsg);
Date nowDate = new Date();
cmoutmsgService.sendSchdGetMsg(nowDate);
//
redisService.set(RedisKeyConstant.KEY_ISWAITSCHD, true); //等待返回日计划状态
@@ -0,0 +1,45 @@
package com.gzzn.omms.msgexchangeapi.service;
import java.util.Date;
import java.util.Locale;
import org.springframework.beans.factory.annotation.Autowired;
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.utils.DateTimeUtil;
@Service
public class CmoutmsgServiceImpl implements ICmoutmsgService {
@Autowired
private IExchangeService exchangeService;
@Autowired
private CmoutmsgDao cmoutmsgDao;
public Boolean sendSchdGetMsg(Date date)
{
//构造消息
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.setCminmsgsStatus("VALID");
Cmoutmsg rtCmoutmsg = cmoutmsgDao.save(cmoutmsg);
return rtCmoutmsg != null;
}
}
@@ -0,0 +1,18 @@
package com.gzzn.omms.msgexchangeapi.service;
import java.util.Date;
/**
*
* @author Administrator
*
*/
public interface ICmoutmsgService {
/**
* 向Cmoutmsgs发送日航班计划获取消息
* @param date 发送获取指定时间后的日航班计划
* @return 成功或失败
*/
public Boolean sendSchdGetMsg(Date date);
}