Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
ab38952f
提交
ab38952f
authored
8月 15, 2021
作者:
zhoushaopan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[缓存]新增根据id查询缓存
上级
7fefc582
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
32 行增加
和
7 行删除
+32
-7
DeviceLibraryCacheService.java
...dev/device/library/service/DeviceLibraryCacheService.java
+6
-0
CacheLibraryServiceImpl.java
.../device/library/service/impl/CacheLibraryServiceImpl.java
+21
-1
DeviceLibraryServiceImpl.java
...device/library/service/impl/DeviceLibraryServiceImpl.java
+5
-6
没有找到文件。
dev-library/src/main/java/com/tykj/dev/device/library/service/DeviceLibraryCacheService.java
浏览文件 @
ab38952f
...
@@ -18,4 +18,10 @@ public interface DeviceLibraryCacheService {
...
@@ -18,4 +18,10 @@ public interface DeviceLibraryCacheService {
*/
*/
List
<
DeviceLibrary
>
getAllDeviceLibraryList
();
List
<
DeviceLibrary
>
getAllDeviceLibraryList
();
/**
* 根据多个id查询
* @return
*/
List
<
DeviceLibrary
>
findByIds
(
List
<
Integer
>
ids
);
}
}
dev-library/src/main/java/com/tykj/dev/device/library/service/impl/CacheLibraryServiceImpl.java
浏览文件 @
ab38952f
...
@@ -3,11 +3,13 @@ package com.tykj.dev.device.library.service.impl;
...
@@ -3,11 +3,13 @@ package com.tykj.dev.device.library.service.impl;
import
com.tykj.dev.device.library.repository.DeviceLibraryDao
;
import
com.tykj.dev.device.library.repository.DeviceLibraryDao
;
import
com.tykj.dev.device.library.service.DeviceLibraryCacheService
;
import
com.tykj.dev.device.library.service.DeviceLibraryCacheService
;
import
com.tykj.dev.device.library.subject.domin.DeviceLibrary
;
import
com.tykj.dev.device.library.subject.domin.DeviceLibrary
;
import
jdk.nashorn.internal.ir.IfNode
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.function.Function
;
...
@@ -26,7 +28,8 @@ public class CacheLibraryServiceImpl implements DeviceLibraryCacheService {
...
@@ -26,7 +28,8 @@ public class CacheLibraryServiceImpl implements DeviceLibraryCacheService {
// @Autowired
// @Autowired
// private ConcurrentMapCacheManager mapCacheManager;
// private ConcurrentMapCacheManager mapCacheManager;
@Autowired
private
DeviceLibraryCacheService
deviceLibraryCacheService
;
@Override
@Override
@Cacheable
(
key
=
"'device'"
)
@Cacheable
(
key
=
"'device'"
)
public
List
<
DeviceLibrary
>
getAllDeviceLibraryList
()
{
public
List
<
DeviceLibrary
>
getAllDeviceLibraryList
()
{
...
@@ -35,4 +38,21 @@ public class CacheLibraryServiceImpl implements DeviceLibraryCacheService {
...
@@ -35,4 +38,21 @@ public class CacheLibraryServiceImpl implements DeviceLibraryCacheService {
System
.
out
.
println
(
"缓存时间"
+(
System
.
currentTimeMillis
()-
l
));
System
.
out
.
println
(
"缓存时间"
+(
System
.
currentTimeMillis
()-
l
));
return
all
;
return
all
;
}
}
@Override
@Cacheable
(
key
=
"'deviceByIds'"
)
public
List
<
DeviceLibrary
>
findByIds
(
List
<
Integer
>
ids
)
{
List
<
DeviceLibrary
>
deviceLibraries
=
deviceLibraryCacheService
.
getAllDeviceLibraryList
();
Map
<
Integer
,
DeviceLibrary
>
map
=
deviceLibraries
.
stream
().
collect
(
Collectors
.
toMap
(
DeviceLibrary:
:
getId
,
Function
.
identity
()));
List
<
DeviceLibrary
>
libraryList
=
new
ArrayList
<>();
ids
.
forEach
(
id
->{
if
(
map
.
containsKey
(
id
)){
DeviceLibrary
deviceLibrary
=
map
.
get
(
id
);
libraryList
.
add
(
deviceLibrary
);
}
}
);
return
libraryList
;
}
}
}
dev-library/src/main/java/com/tykj/dev/device/library/service/impl/DeviceLibraryServiceImpl.java
浏览文件 @
ab38952f
...
@@ -60,8 +60,6 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
...
@@ -60,8 +60,6 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Autowired
@Autowired
private
DeviceLibraryCacheService
cacheLibraryService
;
private
DeviceLibraryCacheService
cacheLibraryService
;
@Autowired
private
CacheLibraryController
cacheLibraryController
;
@Override
@Override
public
DeviceLibrary
addEntity
(
DeviceLibrary
deviceLibraryEntity
)
{
public
DeviceLibrary
addEntity
(
DeviceLibrary
deviceLibraryEntity
)
{
DeviceLibrary
deviceLibrary
=
deviceLibraryDao
.
save
(
deviceLibraryEntity
);
DeviceLibrary
deviceLibrary
=
deviceLibraryDao
.
save
(
deviceLibraryEntity
);
...
@@ -655,12 +653,13 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
...
@@ -655,12 +653,13 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
public
Map
<
Integer
,
List
<
DeviceLibrary
>>
findAllByPackingId3
()
{
public
Map
<
Integer
,
List
<
DeviceLibrary
>>
findAllByPackingId3
()
{
//筛选出当前单位在库的装备
//筛选出当前单位在库的装备
long
l
=
System
.
currentTimeMillis
();
long
l
=
System
.
currentTimeMillis
();
List
<
DeviceLibrary
>
deviceLibraryList
=
cacheLibraryController
.
getAll
();
//
List<DeviceLibrary> deviceLibraryList = cacheLibraryController.getAll();
//
List<DeviceLibrary> deviceLibraryList = cacheLibraryService.getAllDeviceLibraryList();
List
<
DeviceLibrary
>
deviceLibraryList
=
cacheLibraryService
.
getAllDeviceLibraryList
();
System
.
out
.
println
(
"查询在库时间ggg"
+(
System
.
currentTimeMillis
()-
l
));
System
.
out
.
println
(
"查询在库时间ggg"
+(
System
.
currentTimeMillis
()-
l
));
String
currentUserUnitName
=
userUtils
.
getCurrentUserUnitName
();
List
<
DeviceLibrary
>
deviceLibraries
=
deviceLibraryList
.
stream
().
filter
(
deviceLibrary
->
deviceLibrary
.
getLifeStatus
()
==
2
)
List
<
DeviceLibrary
>
deviceLibraries
=
deviceLibraryList
.
stream
().
filter
(
deviceLibrary
->
deviceLibrary
.
getLifeStatus
()
==
2
)
// .filter(deviceLibrary -> deviceLibrary.getLocationUnit().equals(userUtils.getCurrentUserUnitName()
)
.
filter
(
deviceLibrary
->
deviceLibrary
.
getLocationUnit
().
equals
(
currentUserUnitName
)
// || deviceLibrary.getOwnUnit().equals(userUtils.getCurrentUserUnitName()
))
||
deviceLibrary
.
getOwnUnit
().
equals
(
currentUserUnitName
))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
//转为列装id的map
//转为列装id的map
Map
<
Integer
,
List
<
DeviceLibrary
>>
map
=
deviceLibraries
.
stream
().
collect
(
groupingBy
(
DeviceLibrary:
:
getPackingId
));
Map
<
Integer
,
List
<
DeviceLibrary
>>
map
=
deviceLibraries
.
stream
().
collect
(
groupingBy
(
DeviceLibrary:
:
getPackingId
));
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论