修改flop数组为单个对象 ,去除多余的 runner
This commit is contained in:
@@ -212,7 +212,7 @@ public class MSG
|
||||
protected SCHD schd;
|
||||
@XmlElement(name = "FLOP")
|
||||
@JsonProperty("FLOP")
|
||||
protected List<FLOP> flop;
|
||||
protected FLOP flop;
|
||||
@XmlElement(name = "WTHR")
|
||||
@JsonProperty("WTHR")
|
||||
protected List<WTHR> wthr;
|
||||
@@ -584,10 +584,7 @@ public class MSG
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<FLOP> getFLOP() {
|
||||
if (flop == null) {
|
||||
flop = new ArrayList<FLOP>();
|
||||
}
|
||||
public FLOP getFLOP() {
|
||||
return this.flop;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,14 +21,7 @@ public class FDELHandler extends FlopBaseHandler {
|
||||
@Override
|
||||
public HandlerResult run(Cminmsg cminmsg) {
|
||||
MSG msg = exchangeService.xmlstrToObject(cminmsg.getCminmsgsClobMsg(), MSG.class);
|
||||
//每条消息业务上只会包含一条动态消息记录。
|
||||
if(msg.getFLOP().size() != 1)
|
||||
{
|
||||
logger.error("预期每条消息只会包含一条动态消息记录,当前{}条",msg.getFLOP().size());
|
||||
return HandlerResult.failure();
|
||||
}
|
||||
|
||||
FLOP flop = msg.getFLOP().get(0);
|
||||
FLOP flop = msg.getFLOP();
|
||||
|
||||
|
||||
SCHD.FLTR fltr = flightInfoService.getByFlid(flop.getFLID().toString());
|
||||
|
||||
+1
-8
@@ -46,14 +46,7 @@ public class FlopBaseHandler implements IBaseHandler {
|
||||
@Override
|
||||
public HandlerResult run(Cminmsg cminmsg) {
|
||||
MSG msg = exchangeService.xmlstrToObject(cminmsg.getCminmsgsClobMsg(), MSG.class);
|
||||
//每条消息业务上只会包含一条动态消息记录。
|
||||
if(msg.getFLOP().size() != 1)
|
||||
{
|
||||
logger.error("预期每条消息只会包含一条动态消息记录,当前{}条",msg.getFLOP().size());
|
||||
return HandlerResult.failure();
|
||||
}
|
||||
|
||||
FLOP flop = msg.getFLOP().get(0);
|
||||
FLOP flop = msg.getFLOP();
|
||||
|
||||
|
||||
SCHD.FLTR fltr = flightInfoService.getByFlid(flop.getFLID().toString());
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
package com.gzzn.omms.msgexchangeapi.runner;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
|
||||
import com.gzzn.omms.msgexchangeapi.redis.RedisKeyConstant;
|
||||
import com.gzzn.omms.msgexchangeapi.redis.RedisService;
|
||||
import com.gzzn.omms.msgexchangeapi.service.ICminmsgService;
|
||||
import com.gzzn.omms.msgexchangeapi.service.flightInfo.IFlightInfoService;
|
||||
import com.gzzn.omms.msgexchangeapi.utils.SpringUtil;
|
||||
|
||||
/**
|
||||
* 等待航班日计划返回线程
|
||||
* @author zhouxiunai
|
||||
*
|
||||
*/
|
||||
public class SchdWaitRunner implements Runnable {
|
||||
private static Logger logger = LoggerFactory.getLogger(SchdWaitRunner.class);
|
||||
|
||||
private RedisService redisService;
|
||||
private ICminmsgService cminmsgService;
|
||||
private IFlightInfoService flightInfoService;
|
||||
|
||||
private Long intervalSeconds;
|
||||
|
||||
public SchdWaitRunner()
|
||||
{
|
||||
Environment env = (Environment)SpringUtil.getBean("environment");
|
||||
intervalSeconds = Long.valueOf(env.getProperty("msgExchange.intervalSeconds"));
|
||||
|
||||
flightInfoService = (IFlightInfoService) SpringUtil.getBean("flightInfoService");
|
||||
redisService = (RedisService) SpringUtil.getBean("redisService");
|
||||
cminmsgService = (ICminmsgService) SpringUtil.getBean("cminmsgService");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
logger.info("获取日计划航班信息返回结果开始...,采集间隔{}",intervalSeconds);
|
||||
Boolean isRun = true;
|
||||
Long intervalMs = 30L;
|
||||
Long tryTimes = 0L;
|
||||
|
||||
while (isRun) {
|
||||
tryTimes++;
|
||||
logger.info("尝试第{}次获取返回日计划消息",tryTimes);
|
||||
|
||||
//获取
|
||||
Date waitSchdDate = (Date) redisService.get(RedisKeyConstant.KEY_WAITSCHDDATE);
|
||||
Optional<Cminmsg> opCminmsg = cminmsgService.getRespSchdCminmsg(waitSchdDate,10,3000L);
|
||||
if(!opCminmsg.isPresent())
|
||||
{
|
||||
sleepInMs(intervalMs);
|
||||
continue ;
|
||||
}
|
||||
|
||||
|
||||
//更新
|
||||
logger.info("找到返回的动态航班计划,开始更新动态航班信息...");
|
||||
Boolean updateResult = flightInfoService.updateByDaySchd(opCminmsg.get());
|
||||
if(false == updateResult)
|
||||
{
|
||||
logger.warn("更新动态航班信息失败,稍后重试...");
|
||||
sleepInMs(intervalMs);
|
||||
continue ;
|
||||
}
|
||||
|
||||
//更新返回消息为已处理
|
||||
cminmsgService.updateBatchProcessed(Arrays.asList(opCminmsg.get()));
|
||||
|
||||
//状态记录
|
||||
Long beginId = opCminmsg.get().getCminmsgsId();
|
||||
redisService.set(RedisKeyConstant.KEY_LASTBEGINID,beginId);
|
||||
|
||||
|
||||
Boolean isWaitSchd = false;
|
||||
redisService.set(RedisKeyConstant.KEY_ISWAITSCHD,isWaitSchd);
|
||||
|
||||
//启动消息采集线程
|
||||
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
|
||||
scheduledExecutorService.scheduleAtFixedRate(new MsgExchangeRunner(), 0, intervalSeconds , TimeUnit.SECONDS);
|
||||
|
||||
|
||||
isRun = false; //退出
|
||||
}
|
||||
|
||||
logger.info("获取日计划航班信息返回结果结束...");
|
||||
} //end run
|
||||
|
||||
/**
|
||||
* 休眠指定时间间隔-毫秒
|
||||
* @param intervalMs
|
||||
*/
|
||||
private void sleepInMs(Long intervalMs)
|
||||
{
|
||||
try {
|
||||
Thread.sleep(intervalMs);
|
||||
} catch (InterruptedException e) {
|
||||
logger.info("sleep error:{}",e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user