缓存线pad接口更新
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -70,27 +70,25 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
return getMaterialDto(materialList, param);
|
||||
}
|
||||
//2.查reids
|
||||
// materialList = redisUtils.get("materialList", MaterialDto.class);
|
||||
// if(null != materialList) {
|
||||
// //设置本地缓存
|
||||
// cache.setLocalCache("materialList", materialList);
|
||||
// return getMaterialDto(materialList, param);
|
||||
// }
|
||||
materialList = redisUtils.get("materialList", MaterialDto.class);
|
||||
if(null != materialList) {
|
||||
//设置本地缓存
|
||||
cache.setLocalCache("materialList", materialList);
|
||||
return getMaterialDto(materialList, param);
|
||||
}
|
||||
//3.查db
|
||||
JSONArray materialJsonArray = WQL.getWO("PDA_QUERY").addParam("flag", "5").process().getResultJSONArray(0);
|
||||
materialList = materialJsonArray.toJavaList(MaterialDto.class);
|
||||
//缓存到redis
|
||||
List<MaterialDto> finalMaterialList1 = materialList;
|
||||
CompletableFuture<Void> f1 = CompletableFuture.runAsync(() -> redisUtils.set("materialList", finalMaterialList1, 3600, TimeUnit.SECONDS), pool);
|
||||
CompletableFuture<Void> f1 = CompletableFuture.runAsync(() -> redisUtils.set("materialList", finalMaterialList1), pool);
|
||||
//缓存到本地
|
||||
List<MaterialDto> finalMaterialList = materialList;
|
||||
CompletableFuture<Void> f2 = CompletableFuture.runAsync(() -> cache.setLocalCache("materialList", finalMaterialList), pool);
|
||||
f1.exceptionally((e) -> {
|
||||
log.error("物料信息缓存redis失败: {}", e.getMessage(), e);
|
||||
throw new BadRequestException("物料信息缓存redis失败");
|
||||
});
|
||||
f2.exceptionally((e) -> {
|
||||
log.error("物料信息缓存本地失败: {}", e.getMessage(), e);
|
||||
throw new BadRequestException("物料信息缓存本地失败");
|
||||
});
|
||||
return materialList;
|
||||
|
||||
Reference in New Issue
Block a user