调整包路径
This commit is contained in:
@@ -1,34 +1,18 @@
|
|||||||
package com.gzzn.omms.msgexchangeapi.domain.primary.dao;
|
package com.gzzn.omms.msgexchangeapi.domain.primary.dao;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.Cminmsg;
|
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.Cminmsg;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface CminmsgDao extends CrudRepository<Cminmsg, Long> {
|
public interface CminmsgDao extends CrudRepository<Cminmsg, Long> {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Query("select count(*) from Cminmsg c where cminmsgsDateProcessed is not null")
|
|
||||||
public Long getCminmsgsDateProcessedIsNotNullCount();
|
|
||||||
|
|
||||||
|
public List<Cminmsg> findByCminmsgsDateReceivedAfterOrderByCminmsgsDateReceived(Date date);
|
||||||
|
|
||||||
/**
|
public List<Cminmsg> findByCminmsgsIdGreaterThanOrderByCminmsgsDateReceived(Long id);
|
||||||
* 根据处理时间字段查询列表,Null情况
|
|
||||||
* @param date
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List<Cminmsg> findByCminmsgsDateProcessedIsNull(Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 非空情况
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List<Cminmsg> findByCminmsgsDateProcessedIsNotNull(Pageable pageable);
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.gzzn.omms.msgexchangeapi.domain.primary.entiy.msg.rqfd;
|
package com.gzzn.omms.msgexchangeapi.domain.primary.entity.msg.rqfd;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -21,6 +21,7 @@ public class RefdMsg extends Msg {
|
|||||||
meta.setSndr("OMMS");
|
meta.setSndr("OMMS");
|
||||||
meta.setSeqn("1"); //消息序号,自增
|
meta.setSeqn("1"); //消息序号,自增
|
||||||
meta.setDttm(DateTimeUtil.gtFormatStr(new Date(), "yyMMddHHmmss", Locale.CHINA));
|
meta.setDttm(DateTimeUtil.gtFormatStr(new Date(), "yyMMddHHmmss", Locale.CHINA));
|
||||||
|
meta.setType("RQFD");
|
||||||
meta.setStyp("NONE");
|
meta.setStyp("NONE");
|
||||||
|
|
||||||
this.setMeta(meta);
|
this.setMeta(meta);
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.gzzn.omms.msgexchangeapi.domain.primary.entiy.msg.rqfd;
|
package com.gzzn.omms.msgexchangeapi.domain.primary.entity.msg.rqfd;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.gzzn.omms.msgexchangeapi.domain.secondary.dao;
|
||||||
|
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
|
import com.gzzn.omms.msgexchangeapi.domain.secondary.entity.Context;
|
||||||
|
|
||||||
|
public interface ContextDao extends CrudRepository<Context, String> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.gzzn.omms.msgexchangeapi.domain.secondary.dao;
|
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
|
||||||
|
|
||||||
import com.gzzn.omms.msgexchangeapi.domain.secondary.entity.Status;
|
|
||||||
|
|
||||||
public interface StatusDao extends CrudRepository<Status, Long> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.gzzn.omms.msgexchangeapi.domain.secondary.entity;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用上下文
|
||||||
|
* @author Administrator
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name="context")
|
||||||
|
public class Context {
|
||||||
|
public static String KEY_ISWAITSCHD="isWaitSchd";
|
||||||
|
public static String KEY_MSGPROGRESS="msgProgress";
|
||||||
|
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private String key;
|
||||||
|
private String value;
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.gzzn.omms.msgexchangeapi.domain.secondary.entity;
|
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name="status")
|
|
||||||
public class Status {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
private Long id;
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
public String getRemark() {
|
|
||||||
return remark;
|
|
||||||
}
|
|
||||||
public void setRemark(String remark) {
|
|
||||||
this.remark = remark;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,8 +10,10 @@ import org.springframework.boot.CommandLineRunner;
|
|||||||
|
|
||||||
import com.gzzn.omms.msgexchangeapi.domain.primary.dao.CmoutmsgDao;
|
import com.gzzn.omms.msgexchangeapi.domain.primary.dao.CmoutmsgDao;
|
||||||
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.Cmoutmsg;
|
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.Cmoutmsg;
|
||||||
import com.gzzn.omms.msgexchangeapi.domain.primary.entiy.msg.rqfd.RefdMsg;
|
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.msg.rqfd.RefdMsg;
|
||||||
import com.gzzn.omms.msgexchangeapi.domain.primary.entiy.msg.rqfd.RefdMsgBody;
|
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.msg.rqfd.RefdMsgBody;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.domain.secondary.dao.ContextDao;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.domain.secondary.entity.Context;
|
||||||
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
|
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
|
||||||
import com.gzzn.omms.msgexchangeapi.utils.DateTimeUtil;
|
import com.gzzn.omms.msgexchangeapi.utils.DateTimeUtil;
|
||||||
|
|
||||||
@@ -24,29 +26,47 @@ public class AppRunner implements CommandLineRunner {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CmoutmsgDao cmoutmsgDao;
|
private CmoutmsgDao cmoutmsgDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ContextDao contextDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IExchangeService exchangeService;
|
private IExchangeService exchangeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(String... args) throws Exception {
|
public void run(String... args) throws Exception {
|
||||||
|
//构造消息
|
||||||
|
Date nowDate = new Date();
|
||||||
Cmoutmsg cmoutmsg = new Cmoutmsg();
|
Cmoutmsg cmoutmsg = new Cmoutmsg();
|
||||||
|
|
||||||
|
|
||||||
RefdMsgBody body = new RefdMsgBody();
|
RefdMsgBody body = new RefdMsgBody();
|
||||||
body.setStdb(
|
body.setStdb(
|
||||||
DateTimeUtil.gtFormatStr(
|
DateTimeUtil.gtFormatStr(
|
||||||
new Date(),
|
nowDate,
|
||||||
"ddMMMyyHHmm",
|
"ddMMMyyHHmm",
|
||||||
Locale.ENGLISH)
|
Locale.ENGLISH)
|
||||||
.toUpperCase()
|
.toUpperCase()
|
||||||
);
|
);
|
||||||
RefdMsg msg = new RefdMsg();
|
RefdMsg msg = new RefdMsg();
|
||||||
msg.setRefd(body);
|
msg.setRefd(body);
|
||||||
|
|
||||||
|
|
||||||
cmoutmsg.setCminmsgsClobMsg(exchangeService.objectToXmlstr(msg));
|
cmoutmsg.setCminmsgsClobMsg(exchangeService.objectToXmlstr(msg));
|
||||||
cmoutmsg.setCminmsgsStatus("VALID");
|
cmoutmsg.setCminmsgsStatus("VALID");
|
||||||
|
|
||||||
cmoutmsgDao.save(cmoutmsg);
|
cmoutmsgDao.save(cmoutmsg);
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
Context isWaitSchd = new Context();
|
||||||
|
isWaitSchd.setKey(Context.KEY_ISWAITSCHD); //等待返回日计划状态
|
||||||
|
isWaitSchd.setValue("true");
|
||||||
|
contextDao.save(isWaitSchd);
|
||||||
|
|
||||||
|
//初始化消息进度
|
||||||
|
Context msgProgress = new Context();
|
||||||
|
msgProgress.setKey(Context.KEY_MSGPROGRESS);
|
||||||
|
msgProgress.setValue( DateTimeUtil.gtFormatStr(
|
||||||
|
nowDate,
|
||||||
|
"yyyy-MM-dd hh:mm:ss",
|
||||||
|
Locale.ENGLISH)
|
||||||
|
);
|
||||||
|
contextDao.save(msgProgress);
|
||||||
}//end function run
|
}//end function run
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.gzzn.omms.msgexchangeapi.service;
|
package com.gzzn.omms.msgexchangeapi.service;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -23,4 +25,28 @@ public class CminmsgServiceImpl implements ICminmsgService {
|
|||||||
Cminmsg rt = cminmsgDao.save(cminmsg);
|
Cminmsg rt = cminmsgDao.save(cminmsg);
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Cminmsg> getNewMsgsAfterDate(Date afterdate) {
|
||||||
|
List<Cminmsg> lsCminmsgs = cminmsgDao.findByCminmsgsDateReceivedAfterOrderByCminmsgsDateReceived(afterdate);
|
||||||
|
if(null == lsCminmsgs)
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return lsCminmsgs;
|
||||||
|
} //end function
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Cminmsg> getNewMsgsAfterId(Long id) {
|
||||||
|
List<Cminmsg> lsCminmsgs = cminmsgDao.findByCminmsgsIdGreaterThanOrderByCminmsgsDateReceived(id);
|
||||||
|
if(null == lsCminmsgs)
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return lsCminmsgs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package com.gzzn.omms.msgexchangeapi.service;
|
package com.gzzn.omms.msgexchangeapi.service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.Cminmsg;
|
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.Cminmsg;
|
||||||
|
|
||||||
|
|
||||||
public interface ICminmsgService {
|
public interface ICminmsgService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9,4 +13,17 @@ public interface ICminmsgService {
|
|||||||
* @param xmlMsg
|
* @param xmlMsg
|
||||||
*/
|
*/
|
||||||
public Cminmsg sendXmlMsg(String xmlMsg);
|
public Cminmsg sendXmlMsg(String xmlMsg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定时间后的新消息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Cminmsg> getNewMsgsAfterDate(Date afterdate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定id后的消息,消息id有序
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Cminmsg> getNewMsgsAfterId(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
package com.gzzn.omms.msgexchangeapi.task;
|
package com.gzzn.omms.msgexchangeapi.task;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.Cminmsg;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.domain.secondary.dao.ContextDao;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.domain.secondary.entity.Context;
|
||||||
import com.gzzn.omms.msgexchangeapi.service.ICminmsgService;
|
import com.gzzn.omms.msgexchangeapi.service.ICminmsgService;
|
||||||
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
|
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
|
||||||
import com.gzzn.omms.msgexchangeapi.service.IKafkaService;
|
import com.gzzn.omms.msgexchangeapi.service.IKafkaService;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.utils.DateTimeUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换任务,获取cim的消息,转换成json,写入到kafka队列中
|
* 转换任务,获取cim的消息,转换成json,写入到kafka队列中
|
||||||
@@ -28,11 +37,38 @@ public class ExchangeTask {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ICminmsgService cminmsgService;
|
private ICminmsgService cminmsgService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ContextDao contextDao;
|
||||||
|
|
||||||
@Scheduled(cron="0 0/1 * * * ?")
|
@Scheduled(cron="0 0/1 * * * ?")
|
||||||
public void corn()
|
public void corn()
|
||||||
{
|
{
|
||||||
logger.info("定时任务启动....");
|
logger.info("定时任务启动....");
|
||||||
|
|
||||||
|
Context isWaitSchd = contextDao.findOne(Context.KEY_ISWAITSCHD);
|
||||||
|
Context msgProgress = contextDao.findOne(Context.KEY_MSGPROGRESS);
|
||||||
|
|
||||||
|
|
||||||
|
while (isWaitSchd.getValue().equalsIgnoreCase("true")) {
|
||||||
|
|
||||||
|
//查找回复的日计划消息
|
||||||
|
String strDate = msgProgress.getValue();
|
||||||
|
Date date = DateTimeUtil.toDate(strDate, "yyyy-MM-dd hh:mm:ss");
|
||||||
|
|
||||||
|
|
||||||
|
List<Cminmsg> lsCminmsgs = cminmsgService.getNewMsgsAfterDate(date);
|
||||||
|
Optional<Cminmsg> opCminmsg = lsCminmsgs.stream().findFirst();
|
||||||
|
|
||||||
|
//如果找到,添加到内存数据库动态航班信息表
|
||||||
|
|
||||||
|
//更新状态
|
||||||
|
isWaitSchd.setValue("false");
|
||||||
|
contextDao.save(isWaitSchd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
logger.info("同步完成");
|
logger.info("同步完成");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.gzzn.omms.msgexchangeapi.utils;
|
package com.gzzn.omms.msgexchangeapi.utils;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -17,4 +18,24 @@ public class DateTimeUtil {
|
|||||||
SimpleDateFormat sdf = new SimpleDateFormat(pattern,locale);
|
SimpleDateFormat sdf = new SimpleDateFormat(pattern,locale);
|
||||||
return sdf.format(date);
|
return sdf.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符串转日期
|
||||||
|
* @param strDate 字符串的日期
|
||||||
|
* @param pattern 日期格式
|
||||||
|
* @return
|
||||||
|
* @throws ParseException
|
||||||
|
*/
|
||||||
|
public static Date toDate(String strDate,String pattern)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
||||||
|
return sdf.parse(strDate);
|
||||||
|
}
|
||||||
|
catch (ParseException e)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("日期转换失败:"+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user