Authored by wangnan9279

fix

... ... @@ -53,8 +53,8 @@ public class BrandIndexBuilder extends IIndexBuilder {
public void loadData() {
tblBrandMap = basicDataCacheService.getTblBrandRelationMap();
ufoBrandMap = basicDataCacheService.getUfoBrandRelationMap();
tblBrandMap = basicDataCacheService.getTblBrandRelationReverseMap();
ufoBrandMap = basicDataCacheService.getUfoRelationMapReverseMap();
}
public void clearData() {
... ...
... ... @@ -47,12 +47,14 @@ public class BasicDataCacheService {
private static final String TBL_SITE_CACHE_KEY = "tblSite";
private static final String TBL_SORT_RELATION_CACHE_KEY = "tblSortRelation";
private static final String TBL_BRAND_RELATION_CACHE_KEY = "tblBrandRelation";
private static final String TBL_BRAND_RELATION_REVERSE_CACHE_KEY = "tblBrandRelationReverse";
//UFO
private static final String UFO_BRAND_CACHE_KEY = "ufoBrand";
private static final String UFO_BRAND_SERIES_CACHE_KEY = "ufoBrandSeries";
private static final String UFO_SIZE_CACHE_KEY = "ufoSize";
private static final String UFO_BRAND_RELATION_CACHE_KEY = "ufoBrandRelation";
private static final String UFO_SORT_RELATION_CACHE_KEY = "ufoSortRelation";
private static final String UFO_SORT_RELATION_REVERSE_CACHE_KEY = "ufoSortRelationReverse";
//有货品牌
LoadingCache<String, Map<Integer, Brand>> brandCache = CacheBuilder.newBuilder()
... ... @@ -398,6 +400,28 @@ public class BasicDataCacheService {
}
//TBL品牌映射-反向
LoadingCache<String, Map<Integer, Integer>> tblBrandRelationReverseCache = CacheBuilder.newBuilder()
.expireAfterWrite(10, TimeUnit.MINUTES)
.build(new CacheLoader<String, Map<Integer, Integer>>() {
public Map<Integer, Integer> load(String key) {
return basicDataLogicService.getTblRelationMapReverse();
}
});
public Map<Integer, Integer> getTblBrandRelationReverseMap() {
try {
return tblBrandRelationReverseCache.get(TBL_BRAND_RELATION_REVERSE_CACHE_KEY);
} catch (Exception e) {
logger.error(e.getMessage());
return new HashMap<>();
}
}
public void clearTblBrandRelationReverse() {
tblBrandRelationReverseCache.invalidateAll();
}
//UFO品牌
LoadingCache<String, Map<Short, UfoBrand>> ufoBrandCache = CacheBuilder.newBuilder()
.expireAfterWrite(10, TimeUnit.MINUTES)
... ... @@ -488,6 +512,28 @@ public class BasicDataCacheService {
ufoBrandRelationCache.invalidateAll();
}
//UFO品牌映射-反向
LoadingCache<String, Map<Integer, Integer>> ufoBrandRelationReverseCache = CacheBuilder.newBuilder()
.expireAfterWrite(10, TimeUnit.MINUTES)
.build(new CacheLoader<String, Map<Integer, Integer>>() {
public Map<Integer, Integer> load(String key) {
return basicDataLogicService.getUfoRelationMap();
}
});
public Map<Integer, Integer> getUfoRelationMapReverseMap() {
try {
return ufoBrandRelationReverseCache.get(UFO_SORT_RELATION_REVERSE_CACHE_KEY);
} catch (Exception e) {
logger.error(e.getMessage());
return new HashMap<>();
}
}
public void clearUfoBrandRelationReverse() {
ufoBrandRelationReverseCache.invalidateAll();
}
//UFO品类映射
LoadingCache<String, Map<Integer, UfoSearchSortRelation>> ufoSortRelationCache = CacheBuilder.newBuilder()
.expireAfterWrite(10, TimeUnit.MINUTES)
... ...
... ... @@ -251,7 +251,21 @@ public class BasicDataLogicService {
}
for (CsBrandRelation csBrandRelation : csBrandRelationList) {
if (csBrandRelation.getTblBrandId() != null) {
tblRelationMap.put(csBrandRelation.getTblBrandId(),csBrandRelation.getYohoBrandId());
tblRelationMap.put(csBrandRelation.getTblBrandId(), csBrandRelation.getYohoBrandId());
}
}
return tblRelationMap;
}
public Map<Integer, Integer> getTblRelationMapReverse() {
Map<Integer, Integer> tblRelationMap = new HashMap<>();
List<CsBrandRelation> csBrandRelationList = csBrandRelationService.selectAll();
if (CollectionUtils.isEmpty(csBrandRelationList)) {
return new HashMap<>();
}
for (CsBrandRelation csBrandRelation : csBrandRelationList) {
if (csBrandRelation.getTblBrandId() != null) {
tblRelationMap.put(csBrandRelation.getYohoBrandId(), csBrandRelation.getTblBrandId());
}
}
return tblRelationMap;
... ... @@ -265,10 +279,25 @@ public class BasicDataLogicService {
}
for (CsBrandRelation csBrandRelation : csBrandRelationList) {
if (csBrandRelation.getUfoBrandId() != null) {
ufoRelationMap.put(csBrandRelation.getUfoBrandId(),csBrandRelation.getYohoBrandId());
ufoRelationMap.put(csBrandRelation.getUfoBrandId(), csBrandRelation.getYohoBrandId());
}
}
return ufoRelationMap;
}
public Map<Integer, Integer> getUfoRelationMapReverse() {
Map<Integer, Integer> ufoRelationMap = new HashMap<>();
List<CsBrandRelation> csBrandRelationList = csBrandRelationService.selectAll();
if (CollectionUtils.isEmpty(csBrandRelationList)) {
return new HashMap<>();
}
for (CsBrandRelation csBrandRelation : csBrandRelationList) {
if (csBrandRelation.getUfoBrandId() != null) {
ufoRelationMap.put(csBrandRelation.getYohoBrandId(), csBrandRelation.getUfoBrandId());
}
}
return ufoRelationMap;
}
}
\ No newline at end of file
... ...
... ... @@ -70,6 +70,8 @@ public class BrandRelationUtils {
}
basicDataCacheService.clearTblBrandRelation();
basicDataCacheService.clearUfoBrandRelation();
basicDataCacheService.clearTblBrandRelationReverse();
basicDataCacheService.clearUfoBrandRelationReverse();
return true;
} catch (Exception e) {
logger.error(e.getMessage(), e);
... ...