Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
tianjin-cement
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
竹天卫
tianjin-cement
Commits
7eb0d398
Commit
7eb0d398
authored
3 years ago
by
竹天卫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导出-委托单进展统计22
parent
9e5729b7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
11 deletions
+40
-11
DataStatisticsServiceImpl.java
...ment/business/service/impl/DataStatisticsServiceImpl.java
+40
-11
No files found.
cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/DataStatisticsServiceImpl.java
View file @
7eb0d398
...
...
@@ -399,15 +399,26 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
QueryWrapper
<
Sample
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
in
(
"entrust_id"
,
queryList
);
List
<
Sample
>
sampleList
=
sampleService
.
list
(
queryWrapper
);
List
<
Integer
>
sampleIdList
=
sampleList
.
stream
().
filter
(
x
->
x
.
getCementCode
().
equals
(
x
.
getParallelCode
())).
map
(
Sample:
:
getId
).
collect
(
Collectors
.
toList
());
// List<Integer> sampleIdList = sampleList.stream().filter(x -> x.getCementCode().equals(x.getParallelCode())).map(Sample::getId).collect(Collectors.toList());
//todo 查询样品表里的检测项数量 进行统计
Map
<
Integer
,
List
<
Sample
>>
groupByEntrusteId
=
sampleList
.
stream
().
filter
(
x
->
x
.
getCementCode
().
equals
(
x
.
getParallelCode
())).
collect
(
Collectors
.
groupingBy
(
Sample:
:
getEntrustId
,
Collectors
.
toList
()));
//4.查询所有的派发检测项
QueryWrapper
<
SampleDistribution
>
sdqueryWrapper
=
new
QueryWrapper
<>();
sdqueryWrapper
.
in
(
"entrust_id"
,
queryList
);
sdqueryWrapper
.
in
(
"sample_id"
,
sampleIdList
);
List
<
SampleDistribution
>
sampleDistributions
=
sampleDistributionService
.
list
(
sdqueryWrapper
);
//
QueryWrapper<SampleDistribution> sdqueryWrapper = new QueryWrapper<>();
//
sdqueryWrapper.in("entrust_id", queryList);
//
sdqueryWrapper.in("sample_id", sampleIdList);
//
List<SampleDistribution> sampleDistributions = sampleDistributionService.list(sdqueryWrapper);
//5.分组并统计
Map
<
Integer
,
List
<
SampleDistribution
>>
groupByEntrustId
=
sampleDistributions
.
stream
().
collect
(
Collectors
.
groupingBy
(
SampleDistribution:
:
getEntrustId
,
Collectors
.
toList
()));
// Map<Integer, List<SampleDistribution>> groupByEntrustId = sampleDistributions.stream().collect(Collectors.groupingBy(SampleDistribution::getEntrustId, Collectors.toList()));
//6.开始填充数据。首先填充表头
XSSFWorkbook
wb
=
new
XSSFWorkbook
();
XSSFSheet
sheet
=
wb
.
createSheet
();
...
...
@@ -452,15 +463,32 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
tempCell
.
setCellValue
(
entrust
.
get
(
infoHeader
.
get
(
i
))
==
null
?
""
:
entrust
.
get
(
infoHeader
.
get
(
i
)).
toString
());
tempCell
.
setCellStyle
(
style
);
}
}
Map
<
String
,
Integer
>
teamNumsMap
=
new
HashMap
<>();
List
<
Sample
>
sampleMainList
=
groupByEntrusteId
.
get
(
entrustId
);
for
(
Sample
s
:
sampleMainList
){
String
[]
teamIDs
=
s
.
getTeamIds
().
split
(
"、"
);
for
(
String
teamId
:
teamIDs
){
if
(
teamNumsMap
.
containsKey
(
teamId
)){
teamNumsMap
.
put
(
teamId
,
teamNumsMap
.
get
(
teamId
)+
1
);
}
else
{
teamNumsMap
.
put
(
teamId
,
1
);
}
}
}
if
(
teamNumsMap
!=
null
)
{
// Map<Integer, List<SampleDistribution>> sampleDistribuGroup = groupByEntrustId.get(entrustId).stream().collect(Collectors.groupingBy(SampleDistribution::getTeamId, Collectors.toList()));
if
(
groupByEntrustId
.
get
(
entrustId
)
!=
null
)
{
Map
<
Integer
,
List
<
SampleDistribution
>>
sampleDistribuGroup
=
groupByEntrustId
.
get
(
entrustId
).
stream
().
collect
(
Collectors
.
groupingBy
(
SampleDistribution:
:
getTeamId
,
Collectors
.
toList
()));
//处理检测项总产值表头
for
(
int
i
=
infoHeader
.
size
();
i
<
teamList
.
size
()
+
infoHeader
.
size
();
i
++)
{
XSSFCell
tempCell
=
row0
.
createCell
(
i
);
Team
team
=
teamList
.
get
(
i
-
infoHeader
.
size
());
tempCell
.
setCellValue
(
sampleDistribuGroup
.
get
(
team
.
getId
())
==
null
?
""
:
team
.
getCharge
().
multiply
(
new
BigDecimal
(
sampleDistribuGroup
.
get
(
team
.
getId
()).
size
())).
toString
());
// tempCell.setCellValue(sampleDistribuGroup.get(team.getId()) == null ? "" : team.getCharge().multiply(new BigDecimal(sampleDistribuGroup.get(team.getId()).size())).toString());
System
.
out
.
println
(
teamNumsMap
.
containsKey
(
team
.
getId
().
toString
()));
tempCell
.
setCellValue
(!
teamNumsMap
.
containsKey
(
team
.
getId
().
toString
())
?
""
:
team
.
getCharge
().
multiply
(
new
BigDecimal
(
teamNumsMap
.
get
(
team
.
getId
().
toString
()))).
toString
());
tempCell
.
setCellStyle
(
style
);
}
...
...
@@ -475,9 +503,10 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
Team
team
=
teamList
.
get
((
i
-
teamList
.
size
()
-
infoHeader
.
size
()
-
1
)
/
2
);
XSSFCell
tempCell1
=
row0
.
createCell
(
i
);
tempCell1
.
setCellStyle
(
style
);
tempCell1
.
setCellValue
(
sampleDistribuGroup
.
get
(
team
.
getId
())
==
null
?
""
:
team
.
getCharge
().
toString
());
tempCell1
.
setCellValue
(
!
teamNumsMap
.
containsKey
(
team
.
getId
().
toString
())
?
""
:
team
.
getCharge
().
toString
());
XSSFCell
tempCell2
=
row0
.
createCell
(++
i
);
tempCell2
.
setCellValue
(
sampleDistribuGroup
.
get
(
team
.
getId
())
==
null
?
""
:
sampleDistribuGroup
.
get
(
team
.
getId
()).
size
()
+
""
);
// tempCell2.setCellValue(sampleDistribuGroup.get(team.getId()) == null ? "" : sampleDistribuGroup.get(team.getId()).size() + "");
tempCell2
.
setCellValue
(!
teamNumsMap
.
containsKey
(
team
.
getId
().
toString
())
?
""
:
teamNumsMap
.
get
(
team
.
getId
().
toString
())
+
""
);
tempCell2
.
setCellStyle
(
style
);
}
}
...
...
This diff is collapsed.
Click to expand it.
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