Commit 19a89992 authored by suhuiguang's avatar suhuiguang

1.增加缓存

parent 3cf6a524
......@@ -16,4 +16,11 @@ public interface BizCommonConstant {
* 所有区划企业数据redisKey
*/
String REGION_TREE_REDIS_KEY = "REGION_TREE_TCM";
/**
* 企业类型数据redisKey
*/
String UNIT_TYPE_LIST_REDIS_KEY = "UNIT_TYPE_LIST_REDIS_KEY";
}
......@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.module.tcm.biz.service.impl.EquipmentCategoryServic
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.boot.module.tcm.biz.utils.RedisUtil;
import com.yeejoin.amos.boot.module.tcm.flc.api.service.IUnitInfoService;
import com.yeejoin.amos.boot.module.tcm.flc.biz.service.impl.RegUnitInfoServiceImpl;
import com.yeejoin.amos.boot.module.tcm.flc.biz.service.impl.UnitInfoServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
......@@ -94,6 +95,9 @@ public class AmosTcmApplication {
@Autowired
UnitInfoServiceImpl unitInfoService;
@Autowired
RegUnitInfoServiceImpl regUnitInfoService;
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(AmosTcmApplication.class, args);
......@@ -132,6 +136,8 @@ public class AmosTcmApplication {
equipmentCategoryService.creatTree();
//4.区域放redis缓存(依赖1)
unitInfoService.getAllRegionTree();
//5.企业类型放redis缓存(依赖1)
regUnitInfoService.setAndGetUnitTypeList();
}
......
......@@ -446,6 +446,19 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
return iDataDictionaryService.getByType(DICT_TYPE_UNIT_TYPE);
}
public List<DataDictionary> setAndGetUnitTypeList() {
List<DataDictionary> dataDictionaries;
if(redisUtil.hasKey(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY)){
dataDictionaries = JSONObject.parseArray(redisUtil.get(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY).toString(),DataDictionary.class);
} else {
dataDictionaries = iDataDictionaryService.getByType(DICT_TYPE_UNIT_TYPE);
redisUtil.set(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY,JSONObject.toJSONString(dataDictionaries));
}
return dataDictionaries;
}
@Override
public Collection getManagementUnitTree(String orgCode) {
List<LinkedHashMap> companyModels = (List<LinkedHashMap>) redisUtil.get(BizCommonConstant.COMPANY_TREE_REDIS_KEY);
......@@ -672,7 +685,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
Set<String> appCodesSet = new HashSet<>();
Map<Long, List<Long>> roleSeqMap = new HashMap<>();
Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
List<DataDictionary> unitTypeList = getUnitTypeList();
List<DataDictionary> unitTypeList = setAndGetUnitTypeList();
Map<String, DataDictionary> dataDictionaryMap = unitTypeList.stream().collect(Collectors.toMap(DataDictionary::getCode, Function.identity(), (k1, k2) -> k1));
for (String typeCode : units) {
DataDictionary unitType = dataDictionaryMap.get(typeCode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment