package com.zteits.park.cache; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.clouds.common.cache.base.AbstractCache; import com.clouds.common.cache.base.GeoCacheVO; import com.clouds.common.constants.RedisKeyEnum; import com.github.pagehelper.PageHelper; import com.google.common.collect.Lists; import com.zteits.clouds.api.apibase.constants.DataStatusEnum; import com.zteits.park.domain.TdPParkingShare; import com.zteits.park.domain.TdPParkingShareExample; import com.zteits.park.mapper.TdPParkingShareMapper; /**** * * Copyright: Copyright (c) 2017 ZTE-ITS * c * @ClassName: ParkingLotSharedCache.java * @Description: 共享车位缓存处理 * @version: v1.0.0 * @author: wangbiao * @date: 2018年1月12日 * Modification History: * Date Author Version Description *---------------------------------------------------------* * 2018年1月12日 wangbiao v1.0.0 创建 */ @Component public class ParkingLotSharedGeoCache extends AbstractCache{ @Autowired private TdPParkingShareMapper tdPParkingShareMapper; @Override protected List getData(int pageNum, int pageSize) { PageHelper.startPage(pageNum, pageSize); TdPParkingShareExample example = new TdPParkingShareExample(); example.createCriteria().andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value()); List parkingLots = tdPParkingShareMapper.selectByExample(example ); List cacheVOs = Lists.newArrayList(); for (TdPParkingShare tabParkinglot : parkingLots) { if(tabParkinglot.getPsLonId()==null || tabParkinglot.getPsLatId()==null){ continue; } GeoCacheVO vo = new GeoCacheVO(tabParkinglot.getPlNo(), tabParkinglot.getPsLonId().doubleValue(),tabParkinglot.getPsLatId().doubleValue()); cacheVOs.add(vo); } return cacheVOs; } @Override protected long getTotalSize() { TdPParkingShareExample example = new TdPParkingShareExample(); example.createCriteria().andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value()); return tdPParkingShareMapper.countByExample(example ); } @Override protected String getKey() { return RedisKeyEnum.PARK_PARKINGLOT_SHARED_PLNO_GEO_PARKLOTINFO.key(); } }