Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-operate-sys-cscec
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fulixin
dsk-operate-sys-cscec
Commits
7ca90fa8
Commit
7ca90fa8
authored
Jan 08, 2024
by
chenyuefang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
工程类型
parent
a2255d2f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
1 deletion
+136
-1
DProjectTypeController.java
...java/com/dsk/cscec/controller/DProjectTypeController.java
+24
-1
DProjectType.java
...-api/src/main/java/com/dsk/cscec/domain/DProjectType.java
+6
-0
TreeSelect.java
...iz-api/src/main/java/com/dsk/cscec/domain/TreeSelect.java
+6
-0
DProjectTypeService.java
.../main/java/com/dsk/cscec/service/DProjectTypeService.java
+11
-0
DProjectTypeServiceImpl.java
...a/com/dsk/cscec/service/impl/DProjectTypeServiceImpl.java
+89
-0
No files found.
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/controller/DProjectTypeController.java
View file @
7ca90fa8
package
com
.
dsk
.
cscec
.
controller
;
import
com.dsk.common.core.domain.R
;
import
com.dsk.cscec.domain.DProjectType
;
import
com.dsk.cscec.domain.TreeSelect
;
import
com.dsk.cscec.service.DProjectTypeService
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* 维表:工程类型,源于IPM(DProjectType)表控制层
...
...
@@ -13,7 +18,7 @@ import javax.annotation.Resource;
* @since 2024-01-05 11:45:43
*/
@RestController
@RequestMapping
(
"dProjectType"
)
@RequestMapping
(
"
/
dProjectType"
)
public
class
DProjectTypeController
{
/**
* 服务对象
...
...
@@ -21,6 +26,24 @@ public class DProjectTypeController {
@Resource
private
DProjectTypeService
dProjectTypeService
;
/**
* 获取所有工程类型
* @param
* @return
*/
@GetMapping
(
"/getAll"
)
public
R
<
List
<
TreeSelect
>>
selectList
()
{
return
R
.
ok
(
dProjectTypeService
.
getList
(
new
DProjectType
()));
}
/**
* 根据工程类型id获取子级
* @param projectTypeId
* @return
*/
@GetMapping
(
"/getChildren"
)
public
R
<
List
<
DProjectType
>>
getChildren
(
String
projectTypeId
)
{
return
R
.
ok
(
dProjectTypeService
.
getChildren
(
projectTypeId
));
}
}
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/domain/DProjectType.java
View file @
7ca90fa8
package
com
.
dsk
.
cscec
.
domain
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 维表:工程类型,源于IPM(DProjectType)实体类
...
...
@@ -62,4 +65,7 @@ public class DProjectType implements Serializable {
* 数据加载时间
*/
private
Date
loadTime
;
@TableField
(
exist
=
false
)
private
List
<
DProjectType
>
children
=
new
ArrayList
<
DProjectType
>();
}
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/domain/TreeSelect.java
View file @
7ca90fa8
...
...
@@ -43,4 +43,10 @@ public class TreeSelect implements Serializable {
this
.
children
=
dept
.
getChildren
().
stream
().
map
(
TreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
public
TreeSelect
(
DProjectType
type
)
{
this
.
id
=
type
.
getProjectTypeId
();
this
.
label
=
type
.
getProjectTypeName
();
this
.
children
=
type
.
getChildren
().
stream
().
map
(
TreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
}
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/service/DProjectTypeService.java
View file @
7ca90fa8
...
...
@@ -2,6 +2,9 @@ package com.dsk.cscec.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.dsk.cscec.domain.DProjectType
;
import
com.dsk.cscec.domain.TreeSelect
;
import
java.util.List
;
/**
* 维表:工程类型,源于IPM(DProjectType)表服务接口
...
...
@@ -11,5 +14,13 @@ import com.dsk.cscec.domain.DProjectType;
*/
public
interface
DProjectTypeService
extends
IService
<
DProjectType
>
{
List
<
TreeSelect
>
getList
(
DProjectType
type
);
/**
* 根据工程类型id获取下一级
*
* @param projectTypeId
* @return
*/
List
<
DProjectType
>
getChildren
(
String
projectTypeId
);
}
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/service/impl/DProjectTypeServiceImpl.java
View file @
7ca90fa8
package
com
.
dsk
.
cscec
.
service
.
impl
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.dsk.cscec.domain.DProjectType
;
import
com.dsk.cscec.domain.TreeSelect
;
import
com.dsk.cscec.mapper.DProjectTypeMapper
;
import
com.dsk.cscec.service.DProjectTypeService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 维表:工程类型,源于IPM(DProjectType)表服务实现类
...
...
@@ -19,4 +27,85 @@ public class DProjectTypeServiceImpl extends ServiceImpl<DProjectTypeMapper, DPr
@Resource
private
DProjectTypeMapper
baseMapper
;
@Override
public
List
<
TreeSelect
>
getList
(
DProjectType
bo
)
{
return
buildTree
(
baseMapper
.
selectList
(
buildQueryWrapper
(
bo
))).
stream
().
map
(
TreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
@Override
public
List
<
DProjectType
>
getChildren
(
String
projectTypeId
)
{
DProjectType
bo
=
new
DProjectType
();
if
(
StringUtils
.
isNotBlank
(
projectTypeId
))
{
bo
.
setParentId
(
projectTypeId
);
}
else
{
bo
.
setLevelNo
(
1
l
);
}
return
baseMapper
.
selectList
(
buildQueryWrapper
(
bo
));
}
private
LambdaQueryWrapper
<
DProjectType
>
buildQueryWrapper
(
DProjectType
bo
)
{
LambdaQueryWrapper
<
DProjectType
>
lqw
=
Wrappers
.
lambdaQuery
();
lqw
.
eq
(
ObjectUtil
.
isNotNull
(
bo
.
getProjectTypeKey
()),
DProjectType:
:
getProjectTypeKey
,
bo
.
getProjectTypeKey
());
// lqw.like(StringUtils.isNotBlank(bo.getProjectTypeName()), DProjectType::getProjectTypeName, bo.getProjectTypeName());
lqw
.
eq
(
ObjectUtil
.
isNotNull
(
bo
.
getLevelNo
()),
DProjectType:
:
getLevelNo
,
bo
.
getLevelNo
());
lqw
.
eq
(
StringUtils
.
isNotBlank
(
bo
.
getProjectTypeId
()),
DProjectType:
:
getProjectTypeId
,
bo
.
getProjectTypeId
());
lqw
.
eq
(
StringUtils
.
isNotBlank
(
bo
.
getParentId
()),
DProjectType:
:
getParentId
,
bo
.
getParentId
());
return
lqw
;
}
public
List
<
DProjectType
>
buildTree
(
List
<
DProjectType
>
types
)
{
List
<
DProjectType
>
returnList
=
new
ArrayList
<
DProjectType
>();
List
<
String
>
tempList
=
new
ArrayList
<
String
>();
for
(
DProjectType
type
:
types
)
{
tempList
.
add
(
type
.
getProjectTypeId
());
}
for
(
DProjectType
type
:
types
)
{
// 如果是顶级节点, 遍历该父节点的所有子节点
if
(!
tempList
.
contains
(
type
.
getParentId
()))
{
recursionFn
(
types
,
type
);
returnList
.
add
(
type
);
}
}
if
(
returnList
.
isEmpty
())
{
returnList
=
types
;
}
return
returnList
;
}
/**
* 递归列表
*/
private
void
recursionFn
(
List
<
DProjectType
>
list
,
DProjectType
t
)
{
// 得到子节点列表
List
<
DProjectType
>
childList
=
getChildList
(
list
,
t
);
t
.
setChildren
(
childList
);
for
(
DProjectType
tChild
:
childList
)
{
if
(
hasChild
(
list
,
tChild
))
{
recursionFn
(
list
,
tChild
);
}
}
}
/**
* 得到子节点列表
*/
private
List
<
DProjectType
>
getChildList
(
List
<
DProjectType
>
list
,
DProjectType
t
)
{
List
<
DProjectType
>
tlist
=
new
ArrayList
<
DProjectType
>();
for
(
DProjectType
n
:
list
)
{
if
(
ObjectUtil
.
isNotNull
(
n
.
getParentId
())
&&
n
.
getParentId
().
equals
(
t
.
getProjectTypeId
()))
{
tlist
.
add
(
n
);
}
}
return
tlist
;
}
/**
* 判断是否有子节点
*/
private
boolean
hasChild
(
List
<
DProjectType
>
list
,
DProjectType
t
)
{
return
getChildList
(
list
,
t
).
size
()
>
0
;
}
}
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