Blame view

parking-module-park/src/main/java/com/zteits/park/biz/RefreshParkCacheServiceImpl.java 4.8 KB
9af4a544   王彪总   新项目
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
  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<String> 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<ParkingLotGeo> 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<ParkingLotGeo> 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<String> plnos = new ArrayList<>();
  				plnos.add(plNo);
  				List<ParkFreeBerth> 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<String>(msg);
  	}
  
  }