Blame view

parking-module-park/src/main/java/com/zteits/park/configuration/schedule/EqpOutDelayQueueMsgSchedule.java 2.32 KB
604bda05   王彪总   1
1
2
3
4
5
6
7
8
9
10
11
  package com.zteits.park.configuration.schedule;
  
  import com.alibaba.fastjson.JSONObject;
  import com.zteits.clouds.api.apibase.bean.BizResult;
  import com.zteits.clouds.api.dto.park.dto.BerthsDTO;
  import com.zteits.clouds.api.dto.park.dto.TpPEqpDTO;
  import com.zteits.park.quene.EqpOutDelayQueueService;
  import com.zteits.park.service.queuemsg.park.EqpOutDelayQueueExecuteService;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
c3fda694   王彪总   1
12
  import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
604bda05   王彪总   1
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  import org.springframework.scheduling.annotation.Scheduled;
  import org.springframework.stereotype.Component;
  
  /**
   * 地磁上报出场,延迟队列定时任务
   * Copyright: Copyright (c) 2018  zteits
   *
   * @Description:
   * @version: v1.0.0
   * @author: xiejianpeng
   * @date: 2019/8/14 23:55
   * Modification History:
   * Date             Author          Version            Description
   *---------------------------------------------------------*
   * 2019/8/14     xiejianpeng         v1.0.0               创建
   */
  @Component
c3fda694   王彪总   1
30
31
32
  // 存量定时任务总开关:新老服务同时在线时默认关闭,避免同一份数据被处理两遍。
  // 切换步骤见 MIGRATION.md「§7.5 存量定时任务去重」。
  @ConditionalOnProperty(prefix = "parking.legacy.scheduler", name = "enabled", havingValue = "true")
604bda05   王彪总   1
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  public class EqpOutDelayQueueMsgSchedule {
  
      Logger logger = LoggerFactory.getLogger(EqpOutDelayQueueMsgSchedule.class);
  
  
      @Autowired
      private EqpOutDelayQueueService eqpOutDelayQueueService;
      @Autowired
      private EqpOutDelayQueueExecuteService eqpOutDelayQueueExecuteService;
  
      @Scheduled(fixedDelay = 10*1000 )//每 10秒获取一次队列消息
  //    @Async
      public void getOrderQueueMsg() {
          while (true) {
          	logger.info("延迟队列开始取数据......");
              BerthsDTO berthsDTO = eqpOutDelayQueueService.getNotice();
              logger.info("延迟队列处理数据入参:"+JSONObject.toJSONString(berthsDTO));
              if (berthsDTO == null) {
                  break;
              }else{
              	//开始处理
  				BizResult<Boolean> result = eqpOutDelayQueueExecuteService.execute(berthsDTO);
  				logger.info("处理地磁上报出场延迟队列任务返回:{}",JSONObject.toJSON(result));
              }
          }
  
      }
  }