Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
4c2a0563
Commit
4c2a0563
authored
Dec 16, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加查询缓存
parent
6839b90a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
base-manager/src/main/java/com/mortals/xhx/module/window/service/impl/WindowBusinessServiceImpl.java
...module/window/service/impl/WindowBusinessServiceImpl.java
+14
-7
No files found.
base-manager/src/main/java/com/mortals/xhx/module/window/service/impl/WindowBusinessServiceImpl.java
View file @
4c2a0563
...
...
@@ -69,7 +69,7 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
public
Result
<
WindowBusinessEntity
>
find
(
WindowBusinessEntity
entity
,
PageInfo
pageInfo
,
Context
context
)
throws
AppException
{
WindowBusinessEntity
query
=
this
.
findBefore
(
entity
,
pageInfo
,
context
);
//判断查询结果是否用缓存
if
(!
ObjectUtils
.
isEmpty
(
query
)
&&!
ObjectUtils
.
isEmpty
(
query
.
getSearchCache
())
&&
!
ObjectUtils
.
isEmpty
(
query
.
getSearchCache
()
==
YesNoEnum
.
YES
.
getValue
()))
{
if
(!
ObjectUtils
.
isEmpty
(
query
)
&&
!
ObjectUtils
.
isEmpty
(
query
.
getSearchCache
())
&&
!
ObjectUtils
.
isEmpty
(
query
.
getSearchCache
()
==
YesNoEnum
.
YES
.
getValue
()))
{
//根据查询条件 获取缓存,如果缓存有则直接取缓存,否则读数据库后 再写入缓存
return
getWindowBusinessEntityCacheResult
(
entity
,
pageInfo
,
context
,
query
);
}
else
{
...
...
@@ -85,12 +85,16 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
Long
siteBusinessId
=
query
.
getSiteBusinessId
();
String
cacheResult
=
cacheService
.
get
(
KEY_SEARCH_SITEBUSINESSID_CACHE
+
siteBusinessId
,
String
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
cacheResult
))
{
result
=
JSON
.
parseObject
(
cacheResult
,
new
TypeReference
<
Result
<
WindowBusinessEntity
>>()
{});
result
=
JSON
.
parseObject
(
cacheResult
,
new
TypeReference
<
Result
<
WindowBusinessEntity
>>()
{
});
}
else
{
//查询数据库
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
this
.
findAfter
(
entity
,
pageInfo
,
context
,
result
.
getList
());
cacheService
.
set
(
KEY_SEARCH_SITEBUSINESSID_CACHE
+
siteBusinessId
,
JSON
.
toJSONString
(
result
),
KEY_SEARCH_TIMEOUTT_CACHE
);
if
(!
ObjectUtils
.
isEmpty
(
result
.
getList
()))
{
cacheService
.
set
(
KEY_SEARCH_SITEBUSINESSID_CACHE
+
siteBusinessId
,
JSON
.
toJSONString
(
result
),
KEY_SEARCH_TIMEOUTT_CACHE
);
}
}
}
else
if
(!
ObjectUtils
.
isEmpty
(
query
.
getWindowId
()))
{
Long
windowId
=
query
.
getWindowId
();
...
...
@@ -102,7 +106,10 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
//查询数据库
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
this
.
findAfter
(
entity
,
pageInfo
,
context
,
result
.
getList
());
cacheService
.
set
(
KEY_SEARCH_WINDOWID_CACHE
+
windowId
,
JSON
.
toJSONString
(
result
),
KEY_SEARCH_TIMEOUTT_CACHE
);
//无查询结果的不做保存
if
(!
ObjectUtils
.
isEmpty
(
result
.
getList
()))
{
cacheService
.
set
(
KEY_SEARCH_WINDOWID_CACHE
+
windowId
,
JSON
.
toJSONString
(
result
),
KEY_SEARCH_TIMEOUTT_CACHE
);
}
}
}
else
if
(!
ObjectUtils
.
isEmpty
(
query
.
getWindowIdList
()))
{
String
windowIdlist
=
query
.
getWindowIdList
().
stream
().
map
(
String:
:
valueOf
).
collect
(
Collectors
.
joining
(
"#"
));
...
...
@@ -114,7 +121,9 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
//查询数据库
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
this
.
findAfter
(
entity
,
pageInfo
,
context
,
result
.
getList
());
cacheService
.
set
(
KEY_SEARCH_WINDOWID_LIST_CACHE
+
windowIdlist
,
JSON
.
toJSONString
(
result
),
KEY_SEARCH_TIMEOUTT_CACHE
);
if
(!
ObjectUtils
.
isEmpty
(
result
.
getList
()))
{
cacheService
.
set
(
KEY_SEARCH_WINDOWID_LIST_CACHE
+
windowIdlist
,
JSON
.
toJSONString
(
result
),
KEY_SEARCH_TIMEOUTT_CACHE
);
}
}
}
else
{
result
=
this
.
dao
.
getList
(
query
,
pageInfo
);
...
...
@@ -125,11 +134,9 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
@Override
protected
void
findAfter
(
WindowBusinessEntity
entity
,
PageInfo
pageInfo
,
Context
context
,
List
<
WindowBusinessEntity
>
list
)
throws
AppException
{
Map
<
Long
,
WindowEntity
>
collect
=
windowService
.
getCacheList
().
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getId
(),
y
->
y
,
(
o
,
n
)
->
n
));
//Map<Long, WindowEntity> collect = windowService.findToMap(new WindowQuery(), context);
Map
<
Long
,
WindowHallEntity
>
windowHallEntityMap
=
windowHallService
.
getCacheList
().
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getId
(),
y
->
y
,
(
o
,
n
)
->
n
));
//Map<Long, WindowHallEntity> windowHallEntityMap = windowHallService.find(new WindowHallQuery(), context).parallelStream().collect(Collectors.toMap(x -> x.getWindowId(), Function.identity()));
Iterator
iterator
=
list
.
iterator
();
while
(
iterator
.
hasNext
())
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment