package com.zteits.park.cache; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.apache.commons.lang3.StringUtils; import com.clouds.common.cache.base.AbstractCache; import com.clouds.common.cache.base.HashCacheVO; 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.ParkingLot; import com.zteits.park.domain.ParkingLotExample; import com.zteits.park.mapper.ParkingLotMapper; /** * 停车场外部编码和内部编码映射关系缓存
* 是要hash类型,hkey为停车场编号,value为停车场信息 * * Copyright: Copyright (c) 2017 zteits * * @ClassName: ParkingLotAndGeoInfoCache.java * @Description: * @version: v1.0.0 * @author: zhaowg * @date: 2017年6月6日 上午9:58:38 * Modification History: * Date Author Version Description *---------------------------------------------------------* * 2017年6月6日 zhaowg v1.0.0 创建 */ @Component public class ParkLotPlOutNoAndPlNoCache extends AbstractCache{ @Autowired private ParkingLotMapper parkingLotMapper; @Override protected List getData(int pageNum, int pageSize) { PageHelper.startPage(pageNum, pageSize); ParkingLotExample example = new ParkingLotExample(); example.createCriteria() .andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value()) .andPlOutNoIsNotNull(); List parkingLots = parkingLotMapper.selectByExample(example ); List cacheVOs = Lists.newArrayList(); for (ParkingLot tabParkinglot : parkingLots) { if(StringUtils.isBlank(tabParkinglot.getPlOutNo()) || StringUtils.isBlank(tabParkinglot.getPlNo())){ continue; } HashCacheVO vo = new HashCacheVO(tabParkinglot.getPlOutNo(), tabParkinglot.getPlNo()); cacheVOs.add(vo); } return cacheVOs; } @Override protected long getTotalSize() { ParkingLotExample example = new ParkingLotExample(); example.createCriteria().andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value()); return parkingLotMapper.countByExample(example ); } @Override protected String getKey() { return RedisKeyEnum.PARK_PARKINGLOT_PLOUTNO.key(); } }