Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
attendance-performance-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
赵啸非
attendance-performance-platform
Commits
cb473df3
Commit
cb473df3
authored
Aug 22, 2023
by
廖旭伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改花名册部门组织架构bug
parent
54265eb5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
65 deletions
+52
-65
attendance-performance-manager/src/main/java/com/mortals/xhx/module/dept/service/impl/DeptServiceImpl.java
...mortals/xhx/module/dept/service/impl/DeptServiceImpl.java
+38
-52
attendance-performance-manager/src/main/java/com/mortals/xhx/module/staff/service/impl/StaffServiceImpl.java
...rtals/xhx/module/staff/service/impl/StaffServiceImpl.java
+1
-0
attendance-performance-manager/src/main/resources/sqlmap/module/dept/DeptMapperExt.xml
...r/src/main/resources/sqlmap/module/dept/DeptMapperExt.xml
+13
-13
No files found.
attendance-performance-manager/src/main/java/com/mortals/xhx/module/dept/service/impl/DeptServiceImpl.java
View file @
cb473df3
...
...
@@ -136,64 +136,51 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
@Override
public
List
<
DeptTreeSelect
>
buildDeptTreeSelect
(
List
<
DeptEntity
>
list
)
{
List
<
DeptEntity
>
returnList
=
new
ArrayList
<>();
List
<
Long
>
tempList
=
list
.
stream
().
map
(
DeptEntity:
:
getId
).
collect
(
Collectors
.
toList
());
for
(
Iterator
<
DeptEntity
>
iterator
=
list
.
iterator
();
iterator
.
hasNext
();
)
{
DeptEntity
deptEntity
=
iterator
.
next
();
List
<
StaffEntity
>
staffEntities
=
staffService
.
find
(
new
StaffQuery
().
deptId
(
deptEntity
.
getId
()));
List
<
Map
<
String
,
Object
>>
personList
=
new
ArrayList
<>();
staffEntities
.
forEach
(
item
->
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"staffId"
,
item
.
getId
());
map
.
put
(
"staffName"
,
item
.
getName
());
map
.
put
(
"deptId"
,
item
.
getDeptId
());
personList
.
add
(
map
);
});
deptEntity
.
setPersonList
(
personList
);
if
(!
tempList
.
contains
(
deptEntity
.
getParentId
()))
{
recursionFn
(
list
,
deptEntity
);
returnList
.
add
(
deptEntity
);
}
}
if
(
returnList
.
isEmpty
())
{
returnList
=
list
;
}
//获取父节点
List
<
DeptEntity
>
returnList
=
list
.
stream
().
filter
(
t
->
t
.
getParentId
()
==
0
).
map
(
m
->
{
m
.
setChildren
(
getChildren
(
m
,
list
));
StaffEntity
query
=
new
StaffQuery
();
query
.
setDeptIdList
(
getChildrenId
(
m
,
list
));
int
count
=
staffService
.
count
(
query
,
null
);
m
.
setPersonNum
(
count
);
return
m
;
}
).
collect
(
Collectors
.
toList
());
return
returnList
.
stream
().
map
(
DeptTreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
/**
* 递归列表
* 递归查询子节点
* @param root 根节点
* @param all 所有节点
* @return 根节点信息
*/
private
void
recursionFn
(
List
<
DeptEntity
>
list
,
DeptEntity
t
)
{
// 得到子节点列表
List
<
DeptEntity
>
childList
=
getChildList
(
list
,
t
);
t
.
setChildren
(
childList
);
for
(
DeptEntity
tChild
:
childList
)
{
if
(
hasChild
(
list
,
tChild
))
{
recursionFn
(
list
,
tChild
);
}
}
}
/**
* 判断是否有子节点
*/
private
boolean
hasChild
(
List
<
DeptEntity
>
list
,
DeptEntity
t
)
{
return
getChildList
(
list
,
t
).
size
()
>
0
?
true
:
false
;
private
List
<
DeptEntity
>
getChildren
(
DeptEntity
root
,
List
<
DeptEntity
>
all
)
{
List
<
DeptEntity
>
children
=
all
.
stream
().
filter
(
t
->
{
return
Objects
.
equals
(
t
.
getParentId
(),
root
.
getId
());
}).
map
(
m
->
{
m
.
setChildren
(
getChildren
(
m
,
all
));
StaffEntity
query
=
new
StaffQuery
();
query
.
setDeptIdList
(
getChildrenId
(
m
,
all
));
int
count
=
staffService
.
count
(
query
,
null
);
m
.
setPersonNum
(
count
);
return
m
;
}
).
collect
(
Collectors
.
toList
());
return
children
;
}
/**
* 得到子节点列表
*/
private
List
<
DeptEntity
>
getChildList
(
List
<
DeptEntity
>
list
,
DeptEntity
t
)
{
return
list
.
stream
().
map
(
item
->
{
if
(!
ObjectUtils
.
isEmpty
(
item
.
getParentId
())
&&
item
.
getParentId
()
==
t
.
getId
())
{
return
item
;
private
List
<
Long
>
getChildrenId
(
DeptEntity
root
,
List
<
DeptEntity
>
all
){
List
<
Long
>
idList
=
new
ArrayList
<>();
idList
.
add
(
root
.
getId
());
all
.
forEach
(
item
->{
if
(
Objects
.
equals
(
item
.
getParentId
(),
root
.
getId
())){
idList
.
addAll
(
getChildrenId
(
item
,
all
));
}
return
null
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
())
;
})
;
return
idList
;
}
@Override
...
...
@@ -260,5 +247,4 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
return
dao
.
getAllChildrenDept
(
deptId
);
}
}
attendance-performance-manager/src/main/java/com/mortals/xhx/module/staff/service/impl/StaffServiceImpl.java
View file @
cb473df3
...
...
@@ -269,6 +269,7 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
List
<
DeptEntity
>
deptList
=
deptService
.
getAllChildrenDept
(
params
.
getDeptId
());
if
(
CollectionUtils
.
isNotEmpty
(
deptList
)){
List
<
Long
>
deptIdList
=
new
ArrayList
<>();
deptIdList
.
add
(
params
.
getDeptId
());
deptList
.
forEach
(
item
->
{
deptIdList
.
add
(
item
.
getId
());
});
...
...
attendance-performance-manager/src/main/resources/sqlmap/module/dept/DeptMapperExt.xml
View file @
cb473df3
...
...
@@ -14,18 +14,18 @@
</select>
<!--查询所有子部门-->
<select
id=
"getAllChildrenDept"
resultType=
"com.mortals.xhx.module.dept.model.DeptEntity"
>
SELECT
* FROM (
SELECT id, parentId, deptName,deptCode,deptStatus FROM mortals_xhx_dept WHERE id = #{deptId}
UNION ALL
SELECT i.id, i.parentId, i.deptName,i.deptCode,i.deptStatus
FROM mortals_xhx_dept i
INNER JOIN (
SELECT * FROM (
SELECT id, parentId, deptName,deptCode,deptStatus FROM mortals_xhx_dept WHERE id = #{deptId}
UNION ALL
SELECT id, parentId, deptName,deptCode,deptStatus FROM mortals_xhx_dept WHERE parentId = #{deptId}
) t1
) t2 ON i.parentId = t2.id
) t3
SELECT
T3.id,T3.parentId, T3.deptName,T3.deptCode,T3.deptStatus
FROM(
SELECT
@codes as _ids,
( SELECT @codes := GROUP_CONCAT(id)
FROM mortals_xhx_dept
WHERE FIND_IN_SET(parentId, @codes)
) as T1,
@l := @l+1 as level_
FROM mortals_xhx_dept, (SELECT @codes := #{deptId}, @l := 0 ) T4
WHERE @codes IS NOT NULL
) T2, mortals_xhx_dept T3
WHERE FIND_IN_SET(T3.parentId, T2._ids)
</select>
</mapper>
\ No newline at end of file
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