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
09485835
Commit
09485835
authored
Mar 01, 2024
by
chenyuefang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
9f3fb21f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
7 deletions
+35
-7
CbSummaryProjectImportListener.java
...om/dsk/cscec/listener/CbSummaryProjectImportListener.java
+12
-0
CbSummaryServiceImpl.java
...java/com/dsk/cscec/service/impl/CbSummaryServiceImpl.java
+23
-7
No files found.
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/listener/CbSummaryProjectImportListener.java
View file @
09485835
...
...
@@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Optional
;
/**
* 成本汇总-项目汇总自定义导入
...
...
@@ -83,6 +84,17 @@ public class CbSummaryProjectImportListener extends AnalysisEventListener<CbSumm
importVo
.
setLevel
(
1
);
}
else
if
(
importVo
.
getNumber
().
matches
(
"^[0-9]*[1-9][0-9]*$"
))
{
//判断是否为正整数
importVo
.
setLevel
(
Integer
.
valueOf
(
importVo
.
getNumber
()));
//判断上一条数据level是否与当前一致或为上一级
Optional
<
CbSummaryProjectImportVo
>
max
=
resultList
.
stream
().
max
(
Comparator
.
comparing
(
CbSummaryProjectImportVo:
:
getSort
));
CbSummaryProjectImportVo
preImportVo
=
null
;
if
(!
max
.
isPresent
())
{
preImportVo
=
max
.
get
();
}
else
{
throw
new
ServiceException
(
"'序号'列数据错误,无法匹配层级!"
);
}
if
(
importVo
.
getLevel
()
>
preImportVo
.
getLevel
()
&&
importVo
.
getLevel
()
!=
preImportVo
.
getLevel
()
+
1
)
{
throw
new
ServiceException
(
"'序号'列数据错误,无法匹配层级!"
);
}
}
...
...
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/service/impl/CbSummaryServiceImpl.java
View file @
09485835
...
...
@@ -149,9 +149,12 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
}
//获取父级id
Integer
parentLevel
=
cbSummary
.
getLevel
()
-
1
;
CbSummary
parent
=
cbSummaryList
.
stream
().
filter
(
summary
->
summary
.
getSort
()
<
cbSummary
.
getSort
()
&&
summary
.
getLevel
()
==
parentLevel
)
.
max
(
Comparator
.
comparing
(
CbSummary:
:
getSort
)).
get
();
CbSummary
parent
=
null
;
Optional
<
CbSummary
>
max
=
cbSummaryList
.
stream
().
filter
(
summary
->
summary
.
getSort
()
<
cbSummary
.
getSort
()
&&
summary
.
getLevel
()
==
parentLevel
)
.
max
(
Comparator
.
comparing
(
CbSummary:
:
getSort
));
if
(
max
.
isPresent
())
{
parent
=
max
.
get
();
}
if
(
ObjectUtil
.
isNull
(
parent
)){
throw
new
ServiceException
(
"'序号'列数据错误,无法匹配层级!"
);
}
...
...
@@ -223,10 +226,23 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
if
(
cbSummary
.
getLevel
()
==
0
)
{
continue
;
}
//获取父级id
Integer
parentLevel
=
cbSummary
.
getLevel
()
-
1
;
CbSummary
parent
=
cbSummaryList
.
stream
().
filter
(
summary
->
summary
.
getSort
()
<
cbSummary
.
getSort
()
&&
summary
.
getLevel
()
==
parentLevel
)
.
max
(
Comparator
.
comparing
(
CbSummary:
:
getSort
)).
get
();
CbSummary
parent
=
null
;
//通过序号获取parentId
if
(
StringUtil
.
count
(
cbSummary
.
getNumber
(),
"-"
)
>
1
)
{
String
parentNumber
=
cbSummary
.
getNumber
().
substring
(
0
,
cbSummary
.
getNumber
().
lastIndexOf
(
"-"
));
Optional
<
CbSummary
>
max
=
cbSummaryList
.
stream
().
limit
(
cbSummary
.
getSort
()).
filter
(
summary
->
summary
.
getNumber
().
equals
(
parentNumber
))
.
max
(
Comparator
.
comparing
(
CbSummary:
:
getSort
));
if
(
max
.
isPresent
())
{
parent
=
max
.
get
();
}
}
else
{
Integer
parentLevel
=
cbSummary
.
getLevel
()
-
1
;
Optional
<
CbSummary
>
max
=
cbSummaryList
.
stream
().
filter
(
summary
->
summary
.
getSort
()
<
cbSummary
.
getSort
()
&&
summary
.
getLevel
()
==
parentLevel
)
.
max
(
Comparator
.
comparing
(
CbSummary:
:
getSort
));
if
(
max
.
isPresent
())
{
parent
=
max
.
get
();
}
}
if
(
ObjectUtil
.
isNull
(
parent
)){
throw
new
ServiceException
(
"'序号'列数据错误,无法匹配层级!"
);
}
...
...
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