Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
usedCarAuction
/
aus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0ac170ca
authored
Apr 23, 2026
by
杨卫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:添加账户统计接口
1 parent
32e589f0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
24 deletions
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/service/VrUserService.java
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/vo/VrAuditOrderDetailRespVO.java
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/vo/VrAuditRespVO.java
aus-vr/src/main/java/com/glsx/usedcar/controller/VrUserController.java
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/service/VrUserService.java
View file @
0ac170c
...
@@ -21,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -21,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
...
@@ -35,6 +36,7 @@ import java.time.LocalDate;
...
@@ -35,6 +36,7 @@ import java.time.LocalDate;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -56,6 +58,7 @@ public class VrUserService {
...
@@ -56,6 +58,7 @@ public class VrUserService {
private
final
PasswordEncoder
passwordEncoder
;
private
final
PasswordEncoder
passwordEncoder
;
private
final
RedisTokenUtil
redisTokenUtil
;
private
final
RedisTokenUtil
redisTokenUtil
;
private
final
RedisCacheUtil
redisCacheUtil
;
private
final
RedisCacheUtil
redisCacheUtil
;
private
final
ThreadPoolTaskExecutor
ioIntensiveExecutor
;
private
static
final
String
VR_USER_ADD_LOCK_KEY
=
"simpleLock:vrUser:add:{0}"
;
private
static
final
String
VR_USER_ADD_LOCK_KEY
=
"simpleLock:vrUser:add:{0}"
;
...
@@ -303,20 +306,17 @@ public class VrUserService {
...
@@ -303,20 +306,17 @@ public class VrUserService {
}
}
/**
/**
* 分页查询用户(使用 JPA 关联查询)
* 构建用户查询公共过滤条件
* <p>供分页查询和统计复用,包含删除标识、手机号、姓名、角色、集团等筛选条件</p>
*
* @param pagination 分页对象
* @param queryVO 查询参数
*/
*/
public
Page
<
VrUserPageRespVO
>
pageUsers
(
VrUserPageQueryVO
queryVO
)
{
private
void
applyUserFilters
(
Pagination
<
VrUser
>
pagination
,
VrUserPageQueryVO
queryVO
)
{
// 构建分页参数(page从1开始)
int
page
=
queryVO
.
getPage
()
==
null
||
queryVO
.
getPage
()
<
1
?
1
:
queryVO
.
getPage
();
int
size
=
queryVO
.
getSize
()
==
null
||
queryVO
.
getSize
()
<
1
?
20
:
queryVO
.
getSize
();
Pagination
<
VrUser
>
pagination
=
new
Pagination
<>((
page
-
1
)
*
size
,
size
);
pagination
.
setSort
(
LambdaUtil
.
getFieldName
(
AuditingTimeEntity:
:
getCreateTime
));
pagination
.
setOrder
(
CommonConsts
.
DESC
);
// 强制过滤已删除数据
// 强制过滤已删除数据
pagination
.
addFilter
(
VrUser_
.
DELETE_FLAG
,
DeleteFlag
.
NOT_DELETED
.
getCode
(),
org
.
summerframework
.
orm
.
paging
.
Operator
.
eq
);
pagination
.
addFilter
(
VrUser_
.
DELETE_FLAG
,
DeleteFlag
.
NOT_DELETED
.
getCode
(),
org
.
summerframework
.
orm
.
paging
.
Operator
.
eq
);
// 手机号
精确
查询
// 手机号
模糊
查询
if
(
StrUtil
.
isNotBlank
(
queryVO
.
getPhone
()))
{
if
(
StrUtil
.
isNotBlank
(
queryVO
.
getPhone
()))
{
pagination
.
addFilter
(
VrUser_
.
PHONE
,
queryVO
.
getPhone
(),
org
.
summerframework
.
orm
.
paging
.
Operator
.
like
);
pagination
.
addFilter
(
VrUser_
.
PHONE
,
queryVO
.
getPhone
(),
org
.
summerframework
.
orm
.
paging
.
Operator
.
like
);
}
}
...
@@ -367,6 +367,53 @@ public class VrUserService {
...
@@ -367,6 +367,53 @@ public class VrUserService {
return
builder
.
exists
(
subquery
);
return
builder
.
exists
(
subquery
);
});
});
}
}
}
/**
* 复制 Pagination 查询条件(用于异步 count 查询)
*
* @param source 源 Pagination 对象
* @return 复制后的 Pagination 对象
*/
@SuppressWarnings
(
"unchecked"
)
private
Pagination
<
VrUser
>
copyPagination
(
Pagination
<
VrUser
>
source
)
{
Pagination
<
VrUser
>
copy
=
new
Pagination
<>(
0
,
1
);
if
(
source
.
getFilters
()
!=
null
)
{
copy
.
setFilters
(
new
ArrayList
<>(
source
.
getFilters
()));
}
try
{
java
.
lang
.
reflect
.
Field
logicField
=
Pagination
.
class
.
getDeclaredField
(
"logic"
);
logicField
.
setAccessible
(
true
);
Object
logic
=
logicField
.
get
(
source
);
if
(
logic
!=
null
)
{
logicField
.
set
(
copy
,
logic
);
}
java
.
lang
.
reflect
.
Field
conditionsField
=
Pagination
.
class
.
getDeclaredField
(
"conditions"
);
conditionsField
.
setAccessible
(
true
);
List
<
org
.
summerframework
.
orm
.
paging
.
FilterDescriptor
<?>>
conditions
=
(
List
<
org
.
summerframework
.
orm
.
paging
.
FilterDescriptor
<?>>)
conditionsField
.
get
(
source
);
if
(
conditions
!=
null
)
{
conditionsField
.
set
(
copy
,
new
ArrayList
<>(
conditions
));
}
}
catch
(
Exception
e
)
{
log
.
warn
(
"复制Pagination条件失败"
,
e
);
}
return
copy
;
}
/**
* 分页查询用户(使用 JPA 关联查询)
*/
public
Page
<
VrUserPageRespVO
>
pageUsers
(
VrUserPageQueryVO
queryVO
)
{
// 构建分页参数(page从1开始)
int
page
=
queryVO
.
getPage
()
==
null
||
queryVO
.
getPage
()
<
1
?
1
:
queryVO
.
getPage
();
int
size
=
queryVO
.
getSize
()
==
null
||
queryVO
.
getSize
()
<
1
?
20
:
queryVO
.
getSize
();
Pagination
<
VrUser
>
pagination
=
new
Pagination
<>((
page
-
1
)
*
size
,
size
);
pagination
.
setSort
(
LambdaUtil
.
getFieldName
(
AuditingTimeEntity:
:
getCreateTime
));
pagination
.
setOrder
(
CommonConsts
.
DESC
);
applyUserFilters
(
pagination
,
queryVO
);
PageRequest
pageRequest
=
pagination
.
getPageRequest
();
PageRequest
pageRequest
=
pagination
.
getPageRequest
();
Page
<
VrUser
>
userPage
=
vrUserRepository
.
findAll
(
pagination
,
pageRequest
);
Page
<
VrUser
>
userPage
=
vrUserRepository
.
findAll
(
pagination
,
pageRequest
);
...
@@ -478,13 +525,37 @@ public class VrUserService {
...
@@ -478,13 +525,37 @@ public class VrUserService {
/**
/**
* 统计: 正常/停用数量
* 统计: 正常/停用数量
* <p>查询条件与分页列表保持一致,使用线程池异步并发查询各状态数量</p>
*
* @param queryVO 查询参数
* @return 用户统计响应VO
*/
*/
public
Map
<
String
,
Long
>
summary
()
{
public
VrUserSummaryRespVO
summary
(
VrUserPageQueryVO
queryVO
)
{
Map
<
String
,
Long
>
map
=
new
LinkedHashMap
<>();
Pagination
<
VrUser
>
pagination
=
new
Pagination
<>(
0
,
1
);
map
.
put
(
"total"
,
vrUserRepository
.
countAllActive
());
applyUserFilters
(
pagination
,
queryVO
);
map
.
put
(
"normal"
,
vrUserRepository
.
countByStatusAndDeleteFlag
(
1
,
DeleteFlag
.
NOT_DELETED
.
getCode
()));
map
.
put
(
"disabled"
,
vrUserRepository
.
countByStatusAndDeleteFlag
(
0
,
DeleteFlag
.
NOT_DELETED
.
getCode
()));
CompletableFuture
<
Long
>
totalFuture
=
CompletableFuture
.
supplyAsync
(
return
map
;
()
->
vrUserRepository
.
count
(
copyPagination
(
pagination
)),
ioIntensiveExecutor
);
CompletableFuture
<
Long
>
normalFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
Pagination
<
VrUser
>
p
=
copyPagination
(
pagination
);
p
.
addFilter
(
VrUser_
.
STATUS
,
1
,
org
.
summerframework
.
orm
.
paging
.
Operator
.
eq
);
return
vrUserRepository
.
count
(
p
);
},
ioIntensiveExecutor
);
CompletableFuture
<
Long
>
disabledFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
Pagination
<
VrUser
>
p
=
copyPagination
(
pagination
);
p
.
addFilter
(
VrUser_
.
STATUS
,
0
,
org
.
summerframework
.
orm
.
paging
.
Operator
.
eq
);
return
vrUserRepository
.
count
(
p
);
},
ioIntensiveExecutor
);
CompletableFuture
.
allOf
(
totalFuture
,
normalFuture
,
disabledFuture
).
join
();
return
VrUserSummaryRespVO
.
builder
()
.
total
(
totalFuture
.
join
())
.
normal
(
normalFuture
.
join
())
.
disabled
(
disabledFuture
.
join
())
.
build
();
}
}
/**
/**
...
...
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/vo/VrAuditOrderDetailRespVO.java
View file @
0ac170c
...
@@ -72,13 +72,13 @@ public class VrAuditOrderDetailRespVO {
...
@@ -72,13 +72,13 @@ public class VrAuditOrderDetailRespVO {
@Schema
(
description
=
"排量"
)
@Schema
(
description
=
"排量"
)
private
String
displacement
;
private
String
displacement
;
@Schema
(
description
=
"变速箱类型
1:手动 2:自动
"
)
@Schema
(
description
=
"变速箱类型
(1:手动/2:自动/3:双离合/4:手自一体)
"
)
private
Integer
transmissionType
;
private
Integer
transmissionType
;
@Schema
(
description
=
"变速箱类型名称"
)
@Schema
(
description
=
"变速箱类型名称"
)
private
String
transmissionTypeName
;
private
String
transmissionTypeName
;
@Schema
(
description
=
"燃料类型 1:汽油 2:柴油 3:
电动
4:混动"
)
@Schema
(
description
=
"燃料类型 1:汽油 2:柴油 3:
纯电
4:混动"
)
private
Integer
fuelType
;
private
Integer
fuelType
;
@Schema
(
description
=
"燃料类型名称"
)
@Schema
(
description
=
"燃料类型名称"
)
...
@@ -101,7 +101,7 @@ public class VrAuditOrderDetailRespVO {
...
@@ -101,7 +101,7 @@ public class VrAuditOrderDetailRespVO {
@Schema
(
description
=
"过户次数"
)
@Schema
(
description
=
"过户次数"
)
private
Integer
transferCount
;
private
Integer
transferCount
;
@Schema
(
description
=
"车辆性质
1:非营运 2:营运
"
)
@Schema
(
description
=
"车辆性质
(1:非营运/2:营运/3:盈转非)
"
)
private
Integer
vehicleNature
;
private
Integer
vehicleNature
;
@Schema
(
description
=
"车辆性质名称"
)
@Schema
(
description
=
"车辆性质名称"
)
...
...
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/vo/VrAuditRespVO.java
View file @
0ac170c
...
@@ -127,7 +127,7 @@ public class VrAuditRespVO {
...
@@ -127,7 +127,7 @@ public class VrAuditRespVO {
@Schema
(
description
=
"车辆性质(1:非营运/2:营运/3:盈转非)"
)
@Schema
(
description
=
"车辆性质(1:非营运/2:营运/3:盈转非)"
)
private
Integer
vehicleNature
;
private
Integer
vehicleNature
;
@Schema
(
description
=
"燃料类型
(1:汽油/2:柴油/3:纯电/4:混动)
"
)
@Schema
(
description
=
"燃料类型
1:汽油 2:柴油 3:纯电 4:混动
"
)
private
Integer
fuelType
;
private
Integer
fuelType
;
@Schema
(
description
=
"提交审核时间"
)
@Schema
(
description
=
"提交审核时间"
)
...
...
aus-vr/src/main/java/com/glsx/usedcar/controller/VrUserController.java
View file @
0ac170c
...
@@ -6,6 +6,7 @@ import com.glsx.usedcar.module.vrsystem.util.PasswordStrengthUtil;
...
@@ -6,6 +6,7 @@ import com.glsx.usedcar.module.vrsystem.util.PasswordStrengthUtil;
import
com.glsx.usedcar.module.vrsystem.vo.*
;
import
com.glsx.usedcar.module.vrsystem.vo.*
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.util.UserContext
;
import
com.glsx.usedcar.util.UserContext
;
import
com.google.common.cache.CacheBuilder
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
...
@@ -97,10 +98,10 @@ public class VrUserController {
...
@@ -97,10 +98,10 @@ public class VrUserController {
return
BaseResp
.
success
();
return
BaseResp
.
success
();
}
}
@
Ge
tMapping
(
"/summary"
)
@
Pos
tMapping
(
"/summary"
)
@Operation
(
summary
=
"用户统计"
,
description
=
"统计正常和停用用户数量"
)
@Operation
(
summary
=
"用户统计"
,
description
=
"统计正常和停用用户数量
,查询条件与分页列表一致
"
)
public
BaseResp
<
Map
<
String
,
Long
>>
summary
(
)
{
public
BaseResp
<
VrUserSummaryRespVO
>
summary
(
@RequestBody
VrUserPageQueryVO
queryVO
)
{
return
BaseResp
.
success
(
vrUserService
.
summary
());
return
BaseResp
.
success
(
vrUserService
.
summary
(
queryVO
));
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment