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
8dcf9fd1
Commit
8dcf9fd1
authored
Apr 26, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加大厅与窗口关联
parent
7d97de9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
8 deletions
+81
-8
base-manager/src/main/java/com/mortals/xhx/common/utils/MemoryPagination.java
...n/java/com/mortals/xhx/common/utils/MemoryPagination.java
+62
-0
base-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteBusinessServiceImpl.java
...xhx/module/site/service/impl/SiteBusinessServiceImpl.java
+19
-8
No files found.
base-manager/src/main/java/com/mortals/xhx/common/utils/MemoryPagination.java
0 → 100644
View file @
8dcf9fd1
package
com.mortals.xhx.common.utils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.function.Function
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
/**
* @author: zxfei
* @date: 2022/6/28 14:38
* @description: 内存分页
**/
public
class
MemoryPagination
{
/**
* 内存分页
*
* @param records 待分页的数据
* @param pageNum 当前页码
* @param pageSize 每页显示的条数
* @return 分页之后的数据
*/
public
static
<
T
>
List
<
T
>
pagination
(
List
<
T
>
records
,
int
pageNum
,
int
pageSize
)
{
if
(
CollectionUtils
.
isEmpty
(
records
))
{
return
Collections
.
emptyList
();
}
int
totalCount
=
records
.
size
();
int
remainder
=
totalCount
%
pageSize
;
int
pageCount
=
(
remainder
>
0
)
?
totalCount
/
pageSize
+
1
:
totalCount
/
pageSize
;
if
(
remainder
==
0
)
{
return
records
.
stream
().
skip
((
pageNum
-
1
)
*
pageSize
).
limit
(
pageSize
).
collect
(
Collectors
.
toList
());
}
else
{
if
(
pageNum
==
pageCount
)
{
return
records
.
stream
().
skip
((
pageNum
-
1
)
*
pageSize
).
limit
(
totalCount
).
collect
(
Collectors
.
toList
());
}
else
{
return
records
.
stream
().
skip
((
pageNum
-
1
)
*
pageSize
).
limit
(
pageSize
).
collect
(
Collectors
.
toList
());
}
}
}
/* public static List<SitestatEntity> search(String name, List<SitestatEntity> list){
List<SitestatEntity> results = new ArrayList();
Pattern pattern = Pattern.compile(name,Pattern.CASE_INSENSITIVE);
for(int i=0; i < list.size(); i++){
Matcher matcher = pattern.matcher((list.get(i)).getSiteName());
if(matcher.find()){
results.add(list.get(i));
}
}
return results;
}*/
public
static
<
T
>
Predicate
<
T
>
distinctByKey
(
Function
<?
super
T
,
?>
keyExtractor
)
{
Set
<
Object
>
seen
=
ConcurrentHashMap
.
newKeySet
();
return
t
->
seen
.
add
(
keyExtractor
.
apply
(
t
));
}
}
base-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteBusinessServiceImpl.java
View file @
8dcf9fd1
...
...
@@ -6,7 +6,9 @@ import com.mortals.framework.model.Context;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.framework.utils.PageUtils
;
import
com.mortals.xhx.common.code.IsBusinessEnum
;
import
com.mortals.xhx.common.utils.MemoryPagination
;
import
com.mortals.xhx.module.business.model.BusinessEntity
;
import
com.mortals.xhx.module.business.model.BusinessMatterEntity
;
import
com.mortals.xhx.module.business.model.BusinessMatterQuery
;
...
...
@@ -53,6 +55,10 @@ public class SiteBusinessServiceImpl extends AbstractCRUDCacheServiceImpl<SiteBu
*/
@Override
protected
SiteBusinessEntity
findBefore
(
SiteBusinessEntity
params
,
PageInfo
pageInfo
,
Context
context
)
throws
AppException
{
//查询所有
pageInfo
.
setCurrPage
(
1
);
pageInfo
.
setPrePageResult
(-
1
);
if
(!
ObjectUtils
.
isEmpty
(
params
.
getIdNotList
()))
{
Set
<
Long
>
notIdSet
=
params
.
getIdNotList
().
stream
().
collect
(
Collectors
.
toSet
());
//排除掉了父级,但是子集存在,需要吧父id排除到notlist外
...
...
@@ -85,6 +91,11 @@ public class SiteBusinessServiceImpl extends AbstractCRUDCacheServiceImpl<SiteBu
@Override
protected
void
findAfter
(
SiteBusinessEntity
params
,
PageInfo
pageInfo
,
Context
context
,
List
<
SiteBusinessEntity
>
list
)
throws
AppException
{
//重新内存分页
params
.
getPage
();
params
.
getSize
();
list
=
MemoryPagination
.
pagination
(
list
,
params
.
getSize
(),
params
.
getPage
());
if
(!
ObjectUtils
.
isEmpty
(
params
.
getIdNotList
()))
{
//排除掉已经存在的ids
log
.
info
(
"idNotList:{}"
,
JSON
.
toJSONString
(
params
.
getIdNotList
()));
...
...
@@ -172,19 +183,19 @@ public class SiteBusinessServiceImpl extends AbstractCRUDCacheServiceImpl<SiteBu
SiteBusinessEntity
siteBusinessEntity
=
this
.
get
(
item
);
return
this
.
find
(
new
SiteBusinessQuery
().
parentId
(
siteBusinessEntity
.
getId
())).
stream
();
}).
collect
(
Collectors
.
toList
());
log
.
info
(
"delete childs list:{}"
,
JSON
.
toJSONString
(
childs
));
Long
[]
childIds
=
childs
.
stream
().
map
(
item
->
item
.
getId
()).
toArray
(
Long
[]::
new
);
log
.
info
(
"delete childs list:{}"
,
JSON
.
toJSONString
(
childs
));
Long
[]
childIds
=
childs
.
stream
().
map
(
item
->
item
.
getId
()).
toArray
(
Long
[]::
new
);
this
.
getDao
().
delete
(
childIds
);
Long
[]
bussinessIds
=
childs
.
stream
().
map
(
item
->
item
.
getBusinessId
()).
toArray
(
Long
[]::
new
);
log
.
info
(
"childBussinessIds:{}"
,
JSON
.
toJSONString
(
bussinessIds
));
if
(!
ObjectUtils
.
isEmpty
(
bussinessIds
))
{
businessService
.
remove
(
bussinessIds
,
context
);
Long
[]
bussinessIds
=
childs
.
stream
().
map
(
item
->
item
.
getBusinessId
()).
toArray
(
Long
[]::
new
);
log
.
info
(
"childBussinessIds:{}"
,
JSON
.
toJSONString
(
bussinessIds
));
if
(!
ObjectUtils
.
isEmpty
(
bussinessIds
))
{
businessService
.
remove
(
bussinessIds
,
context
);
}
Long
[]
mainIds
=
this
.
get
(
ids
,
context
).
stream
().
map
(
item
->
item
.
getBusinessId
()).
toArray
(
Long
[]::
new
);
if
(!
ObjectUtils
.
isEmpty
(
mainIds
))
{
if
(!
ObjectUtils
.
isEmpty
(
mainIds
))
{
//删除
businessService
.
remove
(
mainIds
,
context
);
businessService
.
remove
(
mainIds
,
context
);
}
}
...
...
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