Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
edcc4126
提交
edcc4126
authored
1月 07, 2022
作者:
zjm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(库房模块): 添加库房的缓存
添加库房的缓存
上级
3306f2a2
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
61 行增加
和
10 行删除
+61
-10
CacheBeanConfig.java
...dev/device/confirmcheck/entity/cache/CacheBeanConfig.java
+12
-8
StoreCache.java
.../main/java/com/tykj/dev/device/user/cache/StoreCache.java
+39
-0
UnitStoreLocationServiceImpl.java
...er/subject/service/impl/UnitStoreLocationServiceImpl.java
+10
-2
没有找到文件。
dev-confirmcheck/src/main/java/com/tykj/dev/device/confirmcheck/entity/cache/CacheBeanConfig.java
浏览文件 @
edcc4126
...
...
@@ -2,14 +2,8 @@ package com.tykj.dev.device.confirmcheck.entity.cache;
import
com.tykj.dev.config.cache.ConfigCache
;
import
com.tykj.dev.config.repository.SystemConfigDao
;
import
com.tykj.dev.device.user.cache.AreaCache
;
import
com.tykj.dev.device.user.cache.AreaExhibitionCache
;
import
com.tykj.dev.device.user.cache.UnitsCache
;
import
com.tykj.dev.device.user.cache.UserCache
;
import
com.tykj.dev.device.user.subject.dao.AreaDao
;
import
com.tykj.dev.device.user.subject.dao.AreaExhibitionDao
;
import
com.tykj.dev.device.user.subject.dao.UnitsDao
;
import
com.tykj.dev.device.user.subject.dao.UserDao
;
import
com.tykj.dev.device.user.cache.*
;
import
com.tykj.dev.device.user.subject.dao.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -38,6 +32,10 @@ public class CacheBeanConfig {
@Autowired
AreaExhibitionDao
areaExhibitionDao
;
@Autowired
UnitStoreLocationDao
unitStoreLocationDao
;
@Bean
public
AreaCache
initAreaCache
()
{
return
new
AreaCache
(
areaRepo
.
findAll
());
...
...
@@ -61,4 +59,10 @@ public class CacheBeanConfig {
public
ConfigCache
initConfigCache
(){
return
new
ConfigCache
(
systemConfigDao
.
findAll
());
}
@Bean
public
StoreCache
initStoreCache
(){
return
new
StoreCache
(
unitStoreLocationDao
.
findAllByTypeName
(
"存放位置"
));
}
}
dev-user/src/main/java/com/tykj/dev/device/user/cache/StoreCache.java
0 → 100644
浏览文件 @
edcc4126
package
com
.
tykj
.
dev
.
device
.
user
.
cache
;
import
com.tykj.dev.device.user.subject.entity.Area
;
import
com.tykj.dev.device.user.subject.entity.UnitStoreLocation
;
import
com.tykj.dev.device.user.subject.service.UnitStoreLocationService
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* AreaCache.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/9/22 at 5:33 下午
*/
@Data
public
class
StoreCache
{
private
Map
<
Integer
,
String
>
idMap
;
public
StoreCache
(
List
<
UnitStoreLocation
>
unitStoreLocations
)
{
idMap
=
unitStoreLocations
.
stream
().
collect
(
Collectors
.
toMap
(
UnitStoreLocation:
:
getId
,
UnitStoreLocation:
:
getStoreName
));
}
public
StoreCache
refresh
(
List
<
UnitStoreLocation
>
unitStoreLocations
)
{
idMap
=
unitStoreLocations
.
stream
().
collect
(
Collectors
.
toMap
(
UnitStoreLocation:
:
getId
,
UnitStoreLocation:
:
getStoreName
));
return
this
;
}
public
String
idToName
(
Integer
id
){
return
idMap
.
getOrDefault
(
id
,
""
);
}
}
dev-user/src/main/java/com/tykj/dev/device/user/subject/service/impl/UnitStoreLocationServiceImpl.java
浏览文件 @
edcc4126
package
com
.
tykj
.
dev
.
device
.
user
.
subject
.
service
.
impl
;
import
com.tykj.dev.device.user.base.req.UnitStoreLocationVo
;
import
com.tykj.dev.device.user.cache.StoreCache
;
import
com.tykj.dev.device.user.subject.dao.UnitStoreLocationDao
;
import
com.tykj.dev.device.user.subject.entity.UnitStoreLocation
;
import
com.tykj.dev.device.user.subject.service.UnitStoreLocationService
;
...
...
@@ -29,6 +30,9 @@ public class UnitStoreLocationServiceImpl implements UnitStoreLocationService {
@Autowired
UnitStoreLocationDao
unitStoreLocationDao
;
@Autowired
StoreCache
storeCache
;
@Override
public
List
<
UnitStoreLocation
>
findAllByUnitIdAndTypeName
(
UnitStoreLocationVo
unitStoreLocationVo
)
{
return
unitStoreLocationDao
.
findAllByUnitIdAndTypeName
(
unitStoreLocationVo
.
getUnitId
(),
unitStoreLocationVo
.
getTypeName
()).
stream
().
sorted
(
Comparator
.
comparing
(
UnitStoreLocation:
:
getShowOrder
)).
collect
(
Collectors
.
toList
());
...
...
@@ -70,7 +74,9 @@ public class UnitStoreLocationServiceImpl implements UnitStoreLocationService {
throw
new
ApiException
(
ResponseEntity
.
status
(
20020
).
body
(
"区域名称重复"
));
}
}
return
unitStoreLocationDao
.
save
(
unitStoreLocation
);
unitStoreLocation
=
unitStoreLocationDao
.
save
(
unitStoreLocation
);
storeCache
.
refresh
(
unitStoreLocationDao
.
findAllByTypeName
(
"存放位置"
));
return
unitStoreLocation
;
}
@Override
...
...
@@ -86,6 +92,8 @@ public class UnitStoreLocationServiceImpl implements UnitStoreLocationService {
@Override
public
UnitStoreLocation
update
(
UnitStoreLocation
unitStoreLocation
)
{
return
unitStoreLocationDao
.
save
(
unitStoreLocation
);
unitStoreLocation
=
unitStoreLocationDao
.
save
(
unitStoreLocation
);
storeCache
.
refresh
(
unitStoreLocationDao
.
findAllByTypeName
(
"存放位置"
));
return
unitStoreLocation
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论