添加runner ,启动时发送获取日航班计划的消息
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.gzzn.omms.msgexchangeapi.task;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -11,10 +10,9 @@ import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
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.entiy.Cminmsg;
|
||||
import com.gzzn.omms.msgexchangeapi.exception.ExchangeServiceException;
|
||||
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
|
||||
import com.gzzn.omms.msgexchangeapi.service.IKafkaService;
|
||||
|
||||
@@ -49,27 +47,24 @@ public class ExchangeTask {
|
||||
while(lenSend < lenTotal && lenSend < maxPerLong)
|
||||
{
|
||||
List<Cminmsg> ls = cminmsgDao.findByCminmsgsDateProcessedIsNotNull(new PageRequest(pageIndex,pageSize));
|
||||
ls.forEach(x -> {
|
||||
String strJson = null;
|
||||
try {
|
||||
strJson = exchangeService.xmlToJson(x.getCminmsgsClobMsg());
|
||||
if(!StringUtils.isEmpty(strJson))
|
||||
{
|
||||
kafkaservice.msgSend("topic2", strJson);
|
||||
}
|
||||
} catch (JsonParseException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JsonMappingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
for(Cminmsg node:ls)
|
||||
{
|
||||
String strJson = null;
|
||||
try {
|
||||
strJson = exchangeService.xmlToJson(node.getCminmsgsClobMsg());
|
||||
if(!StringUtils.isEmpty(strJson))
|
||||
{
|
||||
kafkaservice.msgSend("topic2", strJson);
|
||||
}
|
||||
});
|
||||
} catch (ExchangeServiceException e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
} // end for
|
||||
|
||||
|
||||
lenSend += ls.size();
|
||||
pageIndex++;
|
||||
}
|
||||
}//end while
|
||||
//
|
||||
logger.info("同步完成");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user