package com.zteits.park.biz; import org.springframework.stereotype.Service; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import com.clouds.common.cache.park.ParkFreeBerthsCacheUtil; import com.clouds.common.cache.park.ParkingLotCacheUtil; import com.clouds.common.cache.park.ParkingLotGeoCacheUtil; import com.zteits.clouds.api.apibase.bean.BizResult; import com.zteits.clouds.api.apibase.constants.LonLatTypeEnum; import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; import com.zteits.clouds.api.dto.park.param.RefreshParkCacheRequest; import com.zteits.clouds.api.service.park.RefreshParkCacheService; import com.zteits.park.cache.*; import com.zteits.park.dao.ParkFreeBerthDao; import com.zteits.park.dao.ParkingLotDao; import com.zteits.park.domain.ParkFreeBerth; import com.zteits.park.domain.ParkingLot; import com.zteits.park.domain.ParkingLotGeo; import com.zteits.park.mapper.smapper.ParkingLotGeoSMapper; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; import java.util.List; @Service("com.zteits.park.biz.RefreshParkCacheServiceImpl") public class RefreshParkCacheServiceImpl implements RefreshParkCacheService { @Autowired private ParkFreeBerthsCache freeBerthsCache; @Autowired private ParkingLotGeoForBaiduCache lotGeoCache; @Autowired private ParkingLotGeoForMarsCache parkingLotGeoForMarsCache; @Autowired private ParkingLotCache lotCache; @Autowired private IRainPkNoRelationCache relationCache; @Autowired private ParkingLotSharedCache parkingLotSharedCache; @Autowired private ParkingLotSharedGeoCache parkingLotSharedGeoCache; @Autowired private ParkingLotDao parkingLotDao; @Autowired private ParkingLotGeoSMapper parkingLotGeoSMapper; @Autowired private ParkFreeBerthDao parkFreeBerthDao; @Autowired private ParkingLotDoorCache parkingLotDoorCache; @Autowired private ParkLotPlOutNoAndPlNoCache parkLotPlOutNoAndPlNoCache; @Autowired private ParkingLotExtendCache parkingLotExtendCache; @Override public BizResult refreshCache(RefreshParkCacheRequest request) { String msg = "成功"; String plNo = request.getPlNo(); switch (request.getType()) { case -1: freeBerthsCache.writeData(); lotGeoCache.writeData(); parkingLotGeoForMarsCache.writeData(); lotCache.writeData(); relationCache.writeData(); parkLotPlOutNoAndPlNoCache.writeData(); break; case 2: if(StringUtils.isBlank(plNo)){ lotCache.writeData(); }else{ ParkingLot parkingLot = parkingLotDao.queryParkingLotInfoByPlNo(plNo); ParkingLotDTO parkingLotDTO = new ParkingLotDTO(); BeanUtils.copyProperties(parkingLot, parkingLotDTO); ParkingLotCacheUtil.setParkLotByPlNo(plNo, parkingLotDTO); } break; case 3: if(StringUtils.isBlank(plNo)){ lotGeoCache.writeData(); parkingLotGeoForMarsCache.writeData(); }else{ //百度 List parkingLotGeos = parkingLotGeoSMapper.queryParkingLotGeoByParkNo(plNo, 1, LonLatTypeEnum.LON_LAT_TYPE_1.value()); if(CollectionUtils.isNotEmpty(parkingLotGeos)){ ParkingLotGeoCacheUtil.setPointByPlNo(LonLatTypeEnum.LON_LAT_TYPE_1, plNo, parkingLotGeos.get(0).getLonId().doubleValue(), parkingLotGeos.get(0).getLatId().doubleValue()); } List parkingLotGeos2 = parkingLotGeoSMapper.queryParkingLotGeoByParkNo(plNo, 1, LonLatTypeEnum.LON_LAT_TYPE_2.value()); if(CollectionUtils.isNotEmpty(parkingLotGeos2)){ ParkingLotGeoCacheUtil.setPointByPlNo(LonLatTypeEnum.LON_LAT_TYPE_2, plNo, parkingLotGeos2.get(0).getLonId().doubleValue(), parkingLotGeos2.get(0).getLatId().doubleValue()); } } break; case 4: if(StringUtils.isBlank(plNo)){ freeBerthsCache.writeData(); }else{ List plnos = new ArrayList<>(); plnos.add(plNo); List freeBerths = parkFreeBerthDao.queryFreeBerthByPlno(plnos ); if(CollectionUtils.isNotEmpty(freeBerths)){ ParkFreeBerthsCacheUtil.setFreeBerthsByPlNo(plNo, freeBerths.get(0).getFreeBerth(),freeBerths.get(0).getRealFreeBerth()); } } break; case 5: relationCache.writeData(); break; case 6: parkingLotSharedCache.writeData(); parkingLotSharedGeoCache.writeData(); break; case 7: parkingLotDoorCache.writeData(); break; case 8: parkLotPlOutNoAndPlNoCache.writeData(); break; //车场扩展信息缓存 case 9: parkingLotExtendCache.writeData(); break; default: msg = "入参不正确:-1:全部刷新;2:刷新停车场信息;3:刷新经纬度信息;4:刷新空闲车位信息;5:刷新艾润停车场编号对应关系;6:刷新共享车位信息(包含共享车位坐标;7:刷新车场进出口信息;8:刷新外部停车场编号和内部编号对应关系"; break; } return new BizResult(msg); } }