package com.zteits.pay.job.whitecarpush; 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.clouds.common.utils.ResultUtils; 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.apibase.constants.BasicEnum; import com.zteits.clouds.api.dto.bill.vipcard.VipNoPushCardCustInfoDTO; import com.zteits.clouds.api.dto.bill.vipcard.param.VipPushRequest; import com.zteits.clouds.api.dto.bill.whitelist.WhitelistParkRelPushDTO; import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; import com.zteits.clouds.api.service.bill.vipcard.VipCardService; import com.zteits.clouds.api.service.bill.whitelist.WhitelistService; import com.zteits.clouds.api.service.park.ParkingLotQueryService; import com.zteits.pay.job.vipcardpush.route.VipCardPushRoute; import com.zteits.pay.job.vipcardpush.service.VipCardPushService; import com.zteits.pay.job.vipcardpush.vo.VipNoPushCardCustInfoVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; /** * 白名单推送 * Copyright: Copyright (c) 2018 zteits * * @Description: * @version: v1.0.0 * @author: xiejianpeng * @date: 2020/7/2 15:44 * Modification History: * Date Author Version Description *---------------------------------------------------------* * 2020/7/2 xiejianpeng v1.0.0 创建 */ @Component public class WhiteCarNoPushJob { private static final Logger logger = LoggerFactory.getLogger(WhiteCarNoPushJob.class); @Autowired private VipCardPushRoute vipCardPushRoute; @Autowired private WhitelistService whitelistService; @XxlJob(value = "WhiteCarNoPushJob") public ReturnT execute(String... arg0) throws Exception { int updateCount = 0; this.logger("---begin查询未推送白名单信息"); BaseRequest baseRequest = new BaseRequest(); baseRequest.setSysCode("1001"); BizResult> rsList = whitelistService.queryNoPustWhiteCarNoList(baseRequest); this.logger("本次未推送条数=" + (CollectionUtils.isNotEmpty(rsList.getData()) ? rsList.getData().size() : 0)); if (rsList.isSuccess() && rsList.getData() != null) { int index = 1; for (WhitelistParkRelPushDTO cardInfo : rsList.getData()) { if (cardInfo == null || StringUtils.isEmpty(cardInfo.getPlNo())) { continue; } ParkingLotDTO parkingLotDTO = ParkingLotCacheUtil.getParkLotByPlNo(cardInfo.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; } cardInfo.setParkingLotDTO(parkingLotDTO); try { updateCount = route.pushWhiteCar(cardInfo); } catch (Exception e) { logger.error("白名单同步异常",e); logger(cardInfo.getCarNum()+":白名单同步路由服务失败:" + e); } } } else { this.logger("---本次没有要推送的白名单信息.."); updateCount = 1; } return updateCount > 0 ? ReturnT.SUCCESS : ReturnT.FAIL; } private void logger(String msg) { XxlJobHelper.log(msg); logger.info(msg); } }