Blame view

parking-module-pay/src/main/java/com/zteits/pay/job/appointment/AppointmentPushJob.java 3.94 KB
55f68655   王彪总   新项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
  package com.zteits.pay.job.appointment;
  
  
  import org.apache.commons.collections4.CollectionUtils;
  import org.apache.commons.lang3.StringUtils;
  import com.alibaba.fastjson.JSONObject;
  import com.clouds.common.cache.park.ParkingLotCacheUtil;
  import com.xxl.job.core.biz.model.ReturnT;
  
  import com.xxl.job.core.context.XxlJobHelper;
  import com.xxl.job.core.handler.annotation.XxlJob;
  import com.zteits.clouds.api.apibase.bean.BaseRequest;
  import com.zteits.clouds.api.apibase.bean.BizResult;
  import com.zteits.clouds.api.dto.bill.whitelist.WhitelistParkRelPushDTO;
  import com.zteits.clouds.api.dto.order.dto.OrderAppointmentDTO;
  import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO;
  import com.zteits.clouds.api.service.bill.whitelist.WhitelistService;
  import com.zteits.clouds.api.service.order.orderappointment.OrderAppointmentService;
  import com.zteits.pay.job.vipcardpush.route.VipCardPushRoute;
  import com.zteits.pay.job.vipcardpush.service.VipCardPushService;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  import java.util.List;
  
  /**
   * 预约车位信息推送
   * Copyright: Copyright (c) 2018
   *
   * @Description:
   * @version: v1.0.0
   * @author: xiejianpeng
   * @date: 2020/11/11 18:13
   * Modification History:
   * Date             Author          Version            Description
   *---------------------------------------------------------*
   * 2020/11/11     xiejianpeng         v1.0.0               创建
   */
  @Component
  public class AppointmentPushJob {
      private static final Logger logger = LoggerFactory.getLogger(AppointmentPushJob.class);
      @Autowired
      private VipCardPushRoute vipCardPushRoute;
      @Autowired
      private OrderAppointmentService orderAppointmentService;
  
  
      @XxlJob(value = "AppointmentPushJob")
      public ReturnT<String> execute(String... arg0) throws Exception {
  
          int updateCount = 0;
          this.logger("---begin查询未推送预约车新增信息");
          BaseRequest baseRequest = new BaseRequest();
          baseRequest.setSysCode("1001");
          BizResult<List<OrderAppointmentDTO>> rsList = orderAppointmentService.queryNoPustAppointmentCarList(baseRequest);
  
          this.logger("本次未推送条数=" + (CollectionUtils.isNotEmpty(rsList.getData()) ? rsList.getData().size() : 0));
          if (rsList.isSuccess() && rsList.getData() != null) {
              int index = 1;
              for (OrderAppointmentDTO orderAppointmentDTO : rsList.getData()) {
                  if (orderAppointmentDTO == null || StringUtils.isEmpty(orderAppointmentDTO.getPlNo())) {
                      continue;
                  }
                  ParkingLotDTO parkingLotDTO =  ParkingLotCacheUtil.getParkLotByPlNo(orderAppointmentDTO.getPlNo());
                  if (parkingLotDTO == null) {
                      continue;
                  }
                  this.logger("begin开始推送第" + (index++) + "条,从缓存获取停车场信息=" + JSONObject.toJSON(parkingLotDTO));
  
                  VipCardPushService route = vipCardPushRoute.getRoute(parkingLotDTO.getSourceType());
                  if (route == null) {
                      logger("预约车新增同步路由服务失败,未找到sourceType:" + parkingLotDTO.getSourceType() + "对应的服务");
                      continue;
                  }
                  try {
                      updateCount = route.pushAppointment(orderAppointmentDTO);
                  } catch (Exception e) {
                      logger.error("预约车新增同步异常",e);
                      logger(orderAppointmentDTO.getCarNumber()+":预约车新增同步路由服务失败:" + e);
                  }
              }
          } else {
              this.logger("---本次没有要推送的预约车新增信息..");
              updateCount = 1;
          }
          return updateCount > 0 ? ReturnT.SUCCESS : ReturnT.FAIL;
      }
  
  
      private void logger(String msg) {
          XxlJobHelper.log(msg);
          logger.info(msg);
      }
  
  }