Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Y
yichengstreet-be
Project
Project
Details
Activity
Releases
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
yichengstreet
yichengstreet-be
Commits
223c2e6f
Commit
223c2e6f
authored
Apr 20, 2026
by
lixuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 需求
parent
f6a66148
Pipeline
#147208
failed with stages
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
86 deletions
+122
-86
HouseResourceServiceImpl.java
...i/system/service/house/impl/HouseResourceServiceImpl.java
+122
-86
No files found.
ruoyi-system/src/main/java/com/ruoyi/system/service/house/impl/HouseResourceServiceImpl.java
View file @
223c2e6f
...
@@ -435,96 +435,132 @@ public class HouseResourceServiceImpl implements HouseResourceService {
...
@@ -435,96 +435,132 @@ public class HouseResourceServiceImpl implements HouseResourceService {
}
}
}
}
/** 行业分类固定顺序,用于并发查询各行业的年销售合计。 */
private
static
final
List
<
String
>
INDUSTRY_CLASSIFICATIONS
=
Arrays
.
asList
(
"工业"
,
"建筑业"
,
"批发"
,
"零售"
,
"住宿"
,
"餐饮"
,
"服务业"
,
"其他"
);
@Override
@Override
public
BusinessEntityStatisticsDetail
businessEntityStatistics
(
HouseResourcePageQuery
query
)
{
public
BusinessEntityStatisticsDetail
businessEntityStatistics
(
HouseResourcePageQuery
query
)
{
List
<
HouseResourcePage
>
list
=
houseResourceMapper
.
selectProfileGraph
(
query
);
List
<
HouseResourcePage
>
list
=
houseResourceMapper
.
selectProfileGraph
(
query
);
BusinessEntityStatisticsDetail
detail
=
new
BusinessEntityStatisticsDetail
();
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
new
BusinessEntityStatisticsDetail
();
return
detail
;
}
}
BusinessEntityStatisticsDetail
businessEntityStatisticsDetail
=
new
BusinessEntityStatisticsDetail
();
// 原实现起了 20+ 个 CompletableFuture 各扫一遍 list,纯内存操作没有并发收益,
CompletableFuture
<
Long
>
lyCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getType
()
==
1
).
count
(),
executor
);
// 反而让口径分散。改为单遍累加:type / 房源属性 / 房源类型 / 收入税收 / 规上统计全部一次走完。
CompletableFuture
<
Long
>
jdCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getType
()
==
4
).
count
(),
executor
);
long
lyCount
=
0
,
jdCount
=
0
,
jqCount
=
0
,
zhtCount
=
0
,
scCount
=
0
;
CompletableFuture
<
Long
>
jqCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getType
()
==
5
).
count
(),
executor
);
Set
<
String
>
sjLy
=
new
HashSet
<>();
CompletableFuture
<
Long
>
zhtCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getType
()
==
6
).
count
(),
executor
);
Set
<
String
>
sjJd
=
new
HashSet
<>();
CompletableFuture
<
Long
>
scCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getType
()
==
7
).
count
(),
executor
);
Set
<
String
>
sjJq
=
new
HashSet
<>();
Set
<
String
>
sjZht
=
new
HashSet
<>();
CompletableFuture
<
Integer
>
sjLyCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getType
()
==
1
).
collect
(
Collectors
.
groupingBy
(
HouseResourcePage:
:
getThree
)).
size
(),
executor
);
Set
<
String
>
sjSc
=
new
HashSet
<>();
CompletableFuture
<
Integer
>
sjJdCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getType
()
==
4
).
collect
(
Collectors
.
groupingBy
(
HouseResourcePage:
:
getThree
)).
size
(),
executor
);
long
zlCount
=
0
,
zyCount
=
0
,
qtCount
=
0
;
CompletableFuture
<
Integer
>
sjJqCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getType
()
==
5
).
collect
(
Collectors
.
groupingBy
(
HouseResourcePage:
:
getThree
)).
size
(),
executor
);
long
zaiyingCount
=
0
,
xzCount
=
0
,
gkCount
=
0
,
sbCount
=
0
,
zyzyCount
=
0
;
CompletableFuture
<
Integer
>
sjZhtCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getType
()
==
6
).
collect
(
Collectors
.
groupingBy
(
HouseResourcePage:
:
getThree
)).
size
(),
executor
);
BigDecimal
xsSum
=
BigDecimal
.
ZERO
;
CompletableFuture
<
Integer
>
sjScCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getType
()
==
7
).
collect
(
Collectors
.
groupingBy
(
HouseResourcePage:
:
getThree
)).
size
(),
executor
);
BigDecimal
ssSum
=
BigDecimal
.
ZERO
;
long
gsCount
=
0
;
CompletableFuture
<
Long
>
zlCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getHouseResourceAttribute
()
==
0
).
count
(),
executor
);
BigDecimal
gsSsSum
=
BigDecimal
.
ZERO
;
CompletableFuture
<
Long
>
zyCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getHouseResourceAttribute
()
==
2
).
count
(),
executor
);
BigDecimal
gsXsSum
=
BigDecimal
.
ZERO
;
CompletableFuture
<
Long
>
qtCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getHouseResourceAttribute
()
==
1
).
count
(),
executor
);
for
(
HouseResourcePage
x
:
list
)
{
CompletableFuture
<
Long
>
zaiyingCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getHouseResourceType
()
==
0
).
count
(),
executor
);
String
three
=
x
.
getThree
();
CompletableFuture
<
Long
>
xzCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getHouseResourceType
()
==
1
).
count
(),
executor
);
switch
(
x
.
getType
())
{
CompletableFuture
<
Long
>
gkCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getHouseResourceType
()
==
2
).
count
(),
executor
);
case
1
:
lyCount
++;
sjLy
.
add
(
three
);
break
;
CompletableFuture
<
Long
>
sbCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getHouseResourceType
()
==
3
).
count
(),
executor
);
case
4
:
jdCount
++;
sjJd
.
add
(
three
);
break
;
CompletableFuture
<
Long
>
zyzyCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
x
.
getHouseResourceType
()
==
4
).
count
(),
executor
);
case
5
:
jqCount
++;
sjJq
.
add
(
three
);
break
;
case
6
:
zhtCount
++;
sjZht
.
add
(
three
);
break
;
CompletableFuture
<
BigDecimal
>
xsCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
map
(
HouseResourcePage:
:
getIncome
).
filter
(
Objects:
:
nonNull
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
),
executor
);
case
7
:
scCount
++;
sjSc
.
add
(
three
);
break
;
CompletableFuture
<
BigDecimal
>
ssCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
map
(
HouseResourcePage:
:
getTaxCount
).
filter
(
Objects:
:
nonNull
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
),
executor
);
default
:
break
;
CompletableFuture
<
Long
>
gsCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
Objects
.
nonNull
(
x
.
getGs
())
&&
x
.
getGs
().
equals
(
Boolean
.
TRUE
)).
count
(),
executor
);
}
CompletableFuture
<
BigDecimal
>
gsSsCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
Objects
.
nonNull
(
x
.
getGs
())
&&
x
.
getGs
().
equals
(
Boolean
.
TRUE
)).
map
(
HouseResourcePage:
:
getTaxCount
).
filter
(
Objects:
:
nonNull
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
),
executor
);
CompletableFuture
<
BigDecimal
>
gsXsCountFuture
=
CompletableFuture
.
supplyAsync
(()
->
list
.
stream
().
filter
(
x
->
Objects
.
nonNull
(
x
.
getGs
())
&&
x
.
getGs
().
equals
(
Boolean
.
TRUE
)).
map
(
HouseResourcePage:
:
getIncome
).
filter
(
Objects:
:
nonNull
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
),
executor
);
switch
(
x
.
getHouseResourceAttribute
())
{
case
0
:
zlCount
++;
break
;
List
<
BusinessEntityInfo
>
businessEntityInfos
=
businessEntityInfoMapper
.
selectByIdList
(
list
.
stream
().
map
(
HouseResourcePage:
:
getBusinessEntityInfoId
).
collect
(
Collectors
.
toList
()));
case
1
:
qtCount
++;
break
;
businessEntityStatisticsDetail
.
setZtCount
(
businessEntityInfos
.
size
());
case
2
:
zyCount
++;
break
;
default
:
break
;
List
<
String
>
industries
=
Arrays
.
asList
(
"工业"
,
"建筑业"
,
"批发"
,
"零售"
,
"住宿"
,
"餐饮"
,
"服务业"
,
"其他"
);
}
Map
<
String
,
CompletableFuture
<
BigDecimal
>>
industrySellFutures
=
industries
.
stream
()
.
collect
(
Collectors
.
toMap
(
industry
->
industry
,
switch
(
x
.
getHouseResourceType
())
{
industry
->
CompletableFuture
.
supplyAsync
(()
->
getIndustrySellCount
(
businessEntityInfos
,
industry
,
businessEntitySellMapper
),
executor
)));
case
0
:
zaiyingCount
++;
break
;
case
1
:
xzCount
++;
break
;
businessEntityStatisticsDetail
.
setLyCount
(
lyCountFuture
.
join
());
case
2
:
gkCount
++;
break
;
businessEntityStatisticsDetail
.
setJdCount
(
jdCountFuture
.
join
());
case
3
:
sbCount
++;
break
;
businessEntityStatisticsDetail
.
setJqCount
(
jqCountFuture
.
join
());
case
4
:
zyzyCount
++;
break
;
businessEntityStatisticsDetail
.
setZhtCount
(
zhtCountFuture
.
join
());
default
:
break
;
businessEntityStatisticsDetail
.
setScCount
(
scCountFuture
.
join
());
}
businessEntityStatisticsDetail
.
setSjLyCount
(
sjLyCountFuture
.
join
());
if
(
x
.
getIncome
()
!=
null
)
xsSum
=
xsSum
.
add
(
x
.
getIncome
());
businessEntityStatisticsDetail
.
setSjJdCount
(
sjJdCountFuture
.
join
());
if
(
x
.
getTaxCount
()
!=
null
)
ssSum
=
ssSum
.
add
(
x
.
getTaxCount
());
businessEntityStatisticsDetail
.
setSjJqCount
(
sjJqCountFuture
.
join
());
businessEntityStatisticsDetail
.
setSjZhtCount
(
sjZhtCountFuture
.
join
());
if
(
Boolean
.
TRUE
.
equals
(
x
.
getGs
()))
{
businessEntityStatisticsDetail
.
setSjScCount
(
sjScCountFuture
.
join
());
gsCount
++;
if
(
x
.
getTaxCount
()
!=
null
)
gsSsSum
=
gsSsSum
.
add
(
x
.
getTaxCount
());
businessEntityStatisticsDetail
.
setZlCount
(
zlCountFuture
.
join
());
if
(
x
.
getIncome
()
!=
null
)
gsXsSum
=
gsXsSum
.
add
(
x
.
getIncome
());
businessEntityStatisticsDetail
.
setZyCount
(
zyCountFuture
.
join
());
}
businessEntityStatisticsDetail
.
setQtCount
(
qtCountFuture
.
join
());
}
businessEntityStatisticsDetail
.
setZaiyingCount
(
zaiyingCountFuture
.
join
());
detail
.
setLyCount
(
lyCount
);
businessEntityStatisticsDetail
.
setXzCount
(
xzCountFuture
.
join
());
detail
.
setJdCount
(
jdCount
);
businessEntityStatisticsDetail
.
setGkCount
(
gkCountFuture
.
join
());
detail
.
setJqCount
(
jqCount
);
businessEntityStatisticsDetail
.
setSbCount
(
sbCountFuture
.
join
());
detail
.
setZhtCount
(
zhtCount
);
businessEntityStatisticsDetail
.
setZyzyCount
(
zyzyCountFuture
.
join
());
detail
.
setScCount
(
scCount
);
businessEntityStatisticsDetail
.
setXsCount
(
xsCountFuture
.
join
());
detail
.
setSjLyCount
(
sjLy
.
size
());
businessEntityStatisticsDetail
.
setSsCount
(
ssCountFuture
.
join
());
detail
.
setSjJdCount
(
sjJd
.
size
());
businessEntityStatisticsDetail
.
setGsCount
(
gsCountFuture
.
join
());
detail
.
setSjJqCount
(
sjJq
.
size
());
businessEntityStatisticsDetail
.
setGsSsCount
(
gsSsCountFuture
.
join
());
detail
.
setSjZhtCount
(
sjZht
.
size
());
businessEntityStatisticsDetail
.
setGsXsCount
(
gsXsCountFuture
.
join
());
detail
.
setSjScCount
(
sjSc
.
size
());
businessEntityStatisticsDetail
.
setGyCount
(
industrySellFutures
.
get
(
"工业"
).
join
());
detail
.
setZlCount
(
zlCount
);
businessEntityStatisticsDetail
.
setJzyCount
(
industrySellFutures
.
get
(
"建筑业"
).
join
());
detail
.
setZyCount
(
zyCount
);
businessEntityStatisticsDetail
.
setPfCount
(
industrySellFutures
.
get
(
"批发"
).
join
());
detail
.
setQtCount
(
qtCount
);
businessEntityStatisticsDetail
.
setLsCount
(
industrySellFutures
.
get
(
"零售"
).
join
());
businessEntityStatisticsDetail
.
setZsCount
(
industrySellFutures
.
get
(
"住宿"
).
join
());
detail
.
setZaiyingCount
(
zaiyingCount
);
businessEntityStatisticsDetail
.
setCyCount
(
industrySellFutures
.
get
(
"餐饮"
).
join
());
detail
.
setXzCount
(
xzCount
);
businessEntityStatisticsDetail
.
setFwyCount
(
industrySellFutures
.
get
(
"服务业"
).
join
());
detail
.
setGkCount
(
gkCount
);
businessEntityStatisticsDetail
.
setQtjjfzCount
(
industrySellFutures
.
get
(
"其他"
).
join
());
detail
.
setSbCount
(
sbCount
);
detail
.
setZyzyCount
(
zyzyCount
);
businessEntityStatisticsDetail
.
setJjzl
(
businessEntityStatisticsDetail
.
getGyCount
()
.
add
(
businessEntityStatisticsDetail
.
getJzyCount
())
detail
.
setXsCount
(
xsSum
);
.
add
(
businessEntityStatisticsDetail
.
getPfCount
())
detail
.
setSsCount
(
ssSum
);
.
add
(
businessEntityStatisticsDetail
.
getLsCount
())
detail
.
setGsCount
(
gsCount
);
.
add
(
businessEntityStatisticsDetail
.
getZsCount
())
detail
.
setGsSsCount
(
gsSsSum
);
.
add
(
businessEntityStatisticsDetail
.
getCyCount
())
detail
.
setGsXsCount
(
gsXsSum
);
.
add
(
businessEntityStatisticsDetail
.
getFwyCount
())
.
add
(
businessEntityStatisticsDetail
.
getQtjjfzCount
()));
// 主体数量
return
businessEntityStatisticsDetail
;
List
<
String
>
entityIds
=
list
.
stream
()
.
map
(
HouseResourcePage:
:
getBusinessEntityInfoId
)
.
collect
(
Collectors
.
toList
());
List
<
BusinessEntityInfo
>
businessEntityInfos
=
businessEntityInfoMapper
.
selectByIdList
(
entityIds
);
detail
.
setZtCount
(
businessEntityInfos
.
size
());
// 行业销售:每个行业是一次独立的 DB 查询,保留并发
Map
<
String
,
BigDecimal
>
industrySums
=
computeIndustrySells
(
businessEntityInfos
);
detail
.
setGyCount
(
industrySums
.
getOrDefault
(
"工业"
,
BigDecimal
.
ZERO
));
detail
.
setJzyCount
(
industrySums
.
getOrDefault
(
"建筑业"
,
BigDecimal
.
ZERO
));
detail
.
setPfCount
(
industrySums
.
getOrDefault
(
"批发"
,
BigDecimal
.
ZERO
));
detail
.
setLsCount
(
industrySums
.
getOrDefault
(
"零售"
,
BigDecimal
.
ZERO
));
detail
.
setZsCount
(
industrySums
.
getOrDefault
(
"住宿"
,
BigDecimal
.
ZERO
));
detail
.
setCyCount
(
industrySums
.
getOrDefault
(
"餐饮"
,
BigDecimal
.
ZERO
));
detail
.
setFwyCount
(
industrySums
.
getOrDefault
(
"服务业"
,
BigDecimal
.
ZERO
));
detail
.
setQtjjfzCount
(
industrySums
.
getOrDefault
(
"其他"
,
BigDecimal
.
ZERO
));
detail
.
setJjzl
(
industrySums
.
values
().
stream
().
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
));
return
detail
;
}
/** 按行业并发查询每个分类下的年销售合计。 */
private
Map
<
String
,
BigDecimal
>
computeIndustrySells
(
List
<
BusinessEntityInfo
>
infos
)
{
Map
<
String
,
CompletableFuture
<
BigDecimal
>>
futures
=
INDUSTRY_CLASSIFICATIONS
.
stream
()
.
collect
(
Collectors
.
toMap
(
Function
.
identity
(),
industry
->
CompletableFuture
.
supplyAsync
(
()
->
getIndustrySellCount
(
infos
,
industry
,
businessEntitySellMapper
),
executor
)));
Map
<
String
,
BigDecimal
>
result
=
new
LinkedHashMap
<>();
futures
.
forEach
((
k
,
f
)
->
result
.
put
(
k
,
f
.
join
()));
return
result
;
}
}
@Override
@Override
...
...
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