Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rpc-smartcarlife
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 7aaa86b5
authored
May 20, 2026
by
杨卫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:账户分配场景精确到4s店维度
1 parent
1c542695
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
472 additions
and
129 deletions
rpc-dj-smartcarlife-api/src/main/java/cn/com/glsx/dj/smartcarlife/dto/merchantPerformanceConfig/AssignStaffMerchantV2DTO.java
rpc-dj-smartcarlife-api/src/main/java/cn/com/glsx/dj/smartcarlife/dto/merchantPerformanceConfig/StaffAccountRecordDetailDTO.java
rpc-dj-smartcarlife-api/src/main/java/cn/com/glsx/dj/smartcarlife/dto/merchantPerformanceConfig/YqMerchant4sSceneDTO.java
rpc-dj-smartcarlife-api/src/main/java/cn/com/glsx/dj/smartcarlife/remote/StaffBaseInfoRemote.java
rpc-dj-smartcarlife/pom.xml
rpc-dj-smartcarlife/src/main/java/cn/com/glsx/dj/smartcarlife/remote/StaffBaseInfoRemoteImpl.java
rpc-dj-smartcarlife/src/main/java/cn/com/glsx/dj/smartcarlife/service/SceneMerchantRefService.java
rpc-dj-smartcarlife/src/main/java/cn/com/glsx/dj/smartcarlife/service/merchantPerformanceConfig/StaffAccountRecordService.java
rpc-dj-smartcarlife/src/main/java/cn/com/glsx/dj/smartcarlife/service/merchantPerformanceConfig/StaffBaseInfoService.java
rpc-dj-smartcarlife-api/src/main/java/cn/com/glsx/dj/smartcarlife/dto/merchantPerformanceConfig/AssignStaffMerchantV2DTO.java
View file @
7aaa86b
...
...
@@ -35,8 +35,11 @@ public class AssignStaffMerchantV2DTO implements Serializable {
@ApiModelProperty
(
notes
=
"园区店列表"
)
private
List
<
ShopItem
>
shopItemList
;
@ApiModelProperty
(
notes
=
"是否编辑标识(true:编辑, false:新增)"
)
private
Boolean
editFlag
;
/**
* 园区店项(园区店+
驻店类型+
4s店列表)
* 园区店项(园区店+4s店列表)
*/
@Data
@ToString
...
...
@@ -49,15 +52,12 @@ public class AssignStaffMerchantV2DTO implements Serializable {
@ApiModelProperty
(
notes
=
"园区店名称"
)
private
String
yqMerchantName
;
@ApiModelProperty
(
notes
=
"驻店类型(1:门店常驻, 2:临时调动支援)"
)
private
Byte
stationType
;
@ApiModelProperty
(
notes
=
"4s店列表"
)
private
List
<
FourSShopItem
>
fourSShopList
;
}
/**
* 4s店项(4s店+场景列表)
* 4s店项(4s店+
驻店类型+
场景列表)
*/
@Data
@ToString
...
...
@@ -70,7 +70,25 @@ public class AssignStaffMerchantV2DTO implements Serializable {
@ApiModelProperty
(
notes
=
"4s店名称"
)
private
String
merchantName
;
@ApiModelProperty
(
notes
=
"业务场景标识列表"
)
private
List
<
String
>
baseSceneCodeList
;
@ApiModelProperty
(
notes
=
"驻店类型(1:门店常驻, 2:临时调动支援)"
)
private
Byte
stationType
;
@ApiModelProperty
(
notes
=
"业务场景列表"
)
private
List
<
SceneItem
>
sceneList
;
}
/**
* 场景项(场景标识+原来的场景)
*/
@Data
@ToString
public
static
class
SceneItem
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
notes
=
"场景标识"
,
required
=
true
)
private
String
baseSceneCode
;
@ApiModelProperty
(
notes
=
"原来的场景(scene_type)"
)
private
Byte
sceneType
;
}
}
rpc-dj-smartcarlife-api/src/main/java/cn/com/glsx/dj/smartcarlife/dto/merchantPerformanceConfig/StaffAccountRecordDetailDTO.java
View file @
7aaa86b
...
...
@@ -12,7 +12,7 @@ import cn.com.glsx.dj.smartcarlife.dto.scene.SceneDTO;
/**
* @ClassName StaffAccountRecordDetailDTO
* @Description 编辑园区店数据回显 DTO
* @Description 编辑园区店数据回显 DTO
(园区店维度聚合:园区店→4s店列表→场景列表)
*/
@Data
@ToString
...
...
@@ -20,36 +20,49 @@ public class StaffAccountRecordDetailDTO implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
notes
=
"账号记录id"
)
private
Integer
id
;
@ApiModelProperty
(
notes
=
"员工手机号"
)
private
String
staffPhone
;
@ApiModelProperty
(
notes
=
"4s店商户号"
)
private
Integer
merchantId
;
@ApiModelProperty
(
notes
=
"4s店名称"
)
private
String
merchantName
;
@ApiModelProperty
(
notes
=
"园区店商户号"
)
private
Integer
yqMerchantId
;
@ApiModelProperty
(
notes
=
"园区店名称"
)
private
String
yqMerchantName
;
@ApiModelProperty
(
notes
=
"驻店类型(1:门店常驻, 2:临时调动支援)"
)
private
Byte
stationType
;
@ApiModelProperty
(
notes
=
"4s店列表"
)
private
List
<
FourSShopDetailItem
>
fourSShopList
;
/**
* 4s店详情项(4s店+驻店类型+场景列表)
*/
@Data
@ToString
public
static
class
FourSShopDetailItem
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
notes
=
"账号记录id"
)
private
Integer
accountRecordId
;
@ApiModelProperty
(
notes
=
"4s店商户号"
)
private
Integer
merchantId
;
@ApiModelProperty
(
notes
=
"4s店名称"
)
private
String
merchantName
;
@ApiModelProperty
(
notes
=
"驻店类型(1:门店常驻, 2:临时调动支援)"
)
private
Byte
stationType
;
@ApiModelProperty
(
notes
=
"业务场景列表"
)
private
List
<
SceneDTO
>
sceneList
;
@ApiModelProperty
(
notes
=
"业务场景列表"
)
private
List
<
SceneDTO
>
sceneList
;
@ApiModelProperty
(
notes
=
"创建时间"
)
private
Date
createdDate
;
@ApiModelProperty
(
notes
=
"创建时间"
)
private
Date
createdDate
;
@ApiModelProperty
(
notes
=
"创建人"
)
private
String
createdBy
;
@ApiModelProperty
(
notes
=
"创建人"
)
private
String
createdBy
;
@ApiModelProperty
(
notes
=
"删除标识"
)
private
String
deletedFlag
;
}
@ApiModelProperty
(
notes
=
"删除标识"
)
private
String
deletedFlag
;
}
}
\ No newline at end of file
rpc-dj-smartcarlife-api/src/main/java/cn/com/glsx/dj/smartcarlife/dto/merchantPerformanceConfig/YqMerchant4sSceneDTO.java
View file @
7aaa86b
...
...
@@ -61,6 +61,9 @@ public class YqMerchant4sSceneDTO implements Serializable {
@ApiModelProperty
(
notes
=
"场景名称"
)
private
String
sceneName
;
@ApiModelProperty
(
notes
=
"原来的场景(scene_type)"
)
private
Byte
sceneType
;
@ApiModelProperty
(
notes
=
"所属园区店商户号"
)
private
Integer
yqMerchantId
;
...
...
rpc-dj-smartcarlife-api/src/main/java/cn/com/glsx/dj/smartcarlife/remote/StaffBaseInfoRemote.java
View file @
7aaa86b
...
...
@@ -223,8 +223,8 @@ public interface StaffBaseInfoRemote {
@ApiMethod
(
"查询驻店员工门店账号列表"
)
@ApiParam
(
name
=
"condition"
,
notes
=
"查询条件"
,
dataType
=
ApiParam
.
DataTypeEnum
.
OBJECT
,
required
=
true
)
@ApiResponse
(
"门店账号列表"
)
RpcResponse
<
List
<
StaffAccountRecordDTO
>>
listStaffAccountRecords
(
StaffAccountRecordDTO
condition
);
@ApiResponse
(
"门店账号列表
(园区店维度聚合)
"
)
RpcResponse
<
List
<
StaffAccountRecordD
etailD
TO
>>
listStaffAccountRecords
(
StaffAccountRecordDTO
condition
);
@ApiMethod
(
"编辑园区店数据回显"
)
@ApiParam
(
name
=
"accountRecordId"
,
notes
=
"账号记录id"
,
dataType
=
ApiParam
.
DataTypeEnum
.
INTEGER
,
required
=
true
)
...
...
rpc-dj-smartcarlife/pom.xml
View file @
7aaa86b
...
...
@@ -179,12 +179,6 @@
<version>
4.54.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
cn.com.glsx
</groupId>
<artifactId>
rpc-dj-mindworkplate-api
</artifactId>
<version>
5.6.1-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
cn.com.glsx.dj
</groupId>
<artifactId>
rpc-dj-sale-api
</artifactId>
<version>
${sale.api.version}
</version>
...
...
rpc-dj-smartcarlife/src/main/java/cn/com/glsx/dj/smartcarlife/remote/StaffBaseInfoRemoteImpl.java
View file @
7aaa86b
...
...
@@ -462,7 +462,7 @@ public class StaffBaseInfoRemoteImpl implements StaffBaseInfoRemote {
return
RpcResponse
.
success
(
"分配成功"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"员工基础账号分配门店V2异常: {}"
,
e
.
getMessage
(),
e
);
return
RpcResponse
.
fail
(
e
.
getMessage
()
);
return
RpcResponse
.
error
(
e
);
}
}
...
...
@@ -474,9 +474,12 @@ public class StaffBaseInfoRemoteImpl implements StaffBaseInfoRemote {
try
{
staffAccountRecordService
.
disableStaffAccountV2
(
condition
);
return
RpcResponse
.
success
(
"操作成功"
);
}
catch
(
RpcServiceException
e
)
{
log
.
error
(
"禁用或启用员工园区店账号V2异常: "
,
e
);
return
RpcResponse
.
error
(
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"禁用或启用员工园区店账号V2异常:
{}"
,
e
.
getMessage
()
,
e
);
return
RpcResponse
.
fail
(
e
.
getMessage
()
);
log
.
error
(
"禁用或启用员工园区店账号V2异常:
"
,
e
);
return
RpcResponse
.
error
(
e
);
}
}
...
...
@@ -488,23 +491,29 @@ public class StaffBaseInfoRemoteImpl implements StaffBaseInfoRemote {
try
{
List
<
YqMerchant4sSceneDTO
>
result
=
sceneMerchantRefService
.
query4sByYqMerchantList
(
yqMerchantIdList
);
return
RpcResponse
.
success
(
result
);
}
catch
(
RpcServiceException
e
)
{
log
.
error
(
"查询园区店下4s店及业务场景异常: "
,
e
);
return
RpcResponse
.
error
(
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"查询园区店下4s店及业务场景异常:
{}"
,
e
.
getMessage
()
,
e
);
return
RpcResponse
.
fail
(
e
.
getMessage
()
);
log
.
error
(
"查询园区店下4s店及业务场景异常:
"
,
e
);
return
RpcResponse
.
error
(
e
);
}
}
@ApiMethod
(
"查询驻店员工门店账号列表"
)
@ApiParam
(
name
=
"condition"
,
notes
=
"查询条件"
,
dataType
=
ApiParam
.
DataTypeEnum
.
OBJECT
,
required
=
true
)
@ApiResponse
(
"门店账号列表"
)
@ApiResponse
(
"门店账号列表
(园区店维度聚合)
"
)
@Override
public
RpcResponse
<
List
<
StaffAccountRecordDTO
>>
listStaffAccountRecords
(
StaffAccountRecordDTO
condition
)
{
public
RpcResponse
<
List
<
StaffAccountRecordD
etailD
TO
>>
listStaffAccountRecords
(
StaffAccountRecordDTO
condition
)
{
try
{
List
<
StaffAccountRecordD
TO
>
result
=
staffAccountRecordService
.
listStaffAccountRecords
(
condition
);
List
<
StaffAccountRecordD
etailDTO
>
result
=
staffAccountRecordService
.
listStaffAccountRecordsGrouped
(
condition
);
return
RpcResponse
.
success
(
result
);
}
catch
(
RpcServiceException
e
)
{
log
.
error
(
"查询驻店员工门店账号列表异常: "
,
e
);
return
RpcResponse
.
error
(
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"查询驻店员工门店账号列表异常:
{}"
,
e
.
getMessage
()
,
e
);
return
RpcResponse
.
fail
(
e
.
getMessage
()
);
log
.
error
(
"查询驻店员工门店账号列表异常:
"
,
e
);
return
RpcResponse
.
error
(
e
);
}
}
...
...
@@ -516,9 +525,12 @@ public class StaffBaseInfoRemoteImpl implements StaffBaseInfoRemote {
try
{
StaffAccountRecordDetailDTO
result
=
staffAccountRecordService
.
getStaffAccountRecordDetail
(
accountRecordId
);
return
RpcResponse
.
success
(
result
);
}
catch
(
RpcServiceException
e
)
{
log
.
error
(
"编辑园区店数据回显异常: "
,
e
);
return
RpcResponse
.
error
(
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"编辑园区店数据回显异常:
{}"
,
e
.
getMessage
()
,
e
);
return
RpcResponse
.
fail
(
e
.
getMessage
()
);
log
.
error
(
"编辑园区店数据回显异常:
"
,
e
);
return
RpcResponse
.
error
(
e
);
}
}
...
...
@@ -529,9 +541,12 @@ public class StaffBaseInfoRemoteImpl implements StaffBaseInfoRemote {
try
{
int
count
=
staffAccountRecordService
.
cleanInvalidAccountScene
();
return
RpcResponse
.
success
(
count
);
}
catch
(
RpcServiceException
e
)
{
log
.
error
(
"清理无效账户场景数据异常: "
,
e
);
return
RpcResponse
.
error
(
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"
清理无效账户场景数据异常: {}"
,
e
.
getMessage
(),
e
);
return
RpcResponse
.
fail
(
e
.
getMessage
()
);
log
.
error
(
"
系统异常: "
,
e
);
return
RpcResponse
.
error
(
e
);
}
}
}
rpc-dj-smartcarlife/src/main/java/cn/com/glsx/dj/smartcarlife/service/SceneMerchantRefService.java
View file @
7aaa86b
...
...
@@ -2163,11 +2163,13 @@ public class SceneMerchantRefService {
// 4s店名称取第一条
shopDto
.
setShopMerchantName
(
shopItems
.
get
(
0
).
getMainMerchantName
());
// 场景列表
Map
<
String
,
String
>
finalSceneNameMap
=
sceneNameMap
;
List
<
YqMerchant4sSceneDTO
.
SceneDetailDTO
>
sceneList
=
shopItems
.
stream
().
map
(
item
->
{
YqMerchant4sSceneDTO
.
SceneDetailDTO
sceneDto
=
new
YqMerchant4sSceneDTO
.
SceneDetailDTO
();
sceneDto
.
setBaseSceneCode
(
item
.
getBaseSceneCode
());
sceneDto
.
setScene
(
item
.
getScene
()
!=
null
?
String
.
valueOf
(
item
.
getScene
())
:
null
);
sceneDto
.
setSceneName
(
sceneNameMap
.
getOrDefault
(
item
.
getBaseSceneCode
(),
item
.
getBaseSceneCode
()));
sceneDto
.
setSceneName
(
finalSceneNameMap
.
getOrDefault
(
item
.
getBaseSceneCode
(),
item
.
getBaseSceneCode
()));
sceneDto
.
setSceneType
(
item
.
getScene
()
!=
null
?
item
.
getScene
().
byteValue
()
:
null
);
sceneDto
.
setYqMerchantId
(
item
.
getSubMerchantId
());
sceneDto
.
setYqMerchantName
(
item
.
getSubMerchantName
());
return
sceneDto
;
...
...
rpc-dj-smartcarlife/src/main/java/cn/com/glsx/dj/smartcarlife/service/merchantPerformanceConfig/StaffAccountRecordService.java
View file @
7aaa86b
...
...
@@ -515,7 +515,7 @@ public class StaffAccountRecordService {
List
<
SceneDTO
>
scenes
=
sceneService
.
getScenesByParams
(
sceneQueryFilterDTO
);
if
(
CollectionUtils
.
isNotEmpty
(
scenes
))
{
String
sceneStr
=
scenes
.
stream
()
.
map
(
SceneDTO:
:
get
BaseScene
Name
)
.
map
(
SceneDTO:
:
getName
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
joining
(
"、"
));
record
.
setAccountSceneStr
(
sceneStr
);
...
...
@@ -533,53 +533,144 @@ public class StaffAccountRecordService {
}
/**
* 编辑数据回显
* 查询驻店员工门店账号列表(按园区店维度聚合)
* 返回三级结构:园区店列表→4s店列表→场景列表
*
* @param accountRecordId 账号记录id
* @return 详情DTO
* @param staffAccountRecordDTO 查询条件
* @return 园区店维度聚合的账号列表
*/
public
List
<
StaffAccountRecordDetailDTO
>
listStaffAccountRecordsGrouped
(
StaffAccountRecordDTO
staffAccountRecordDTO
)
{
try
{
List
<
StaffAccountRecordDTO
>
records
=
staffAccountRecordMapper
.
listStaffAccountRecord
(
staffAccountRecordDTO
);
if
(
CollectionUtils
.
isEmpty
(
records
))
{
return
Collections
.
emptyList
();
}
// 按yqMerchantId分组
Map
<
Integer
,
List
<
StaffAccountRecordDTO
>>
yqMerchantMap
=
records
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
StaffAccountRecordDTO:
:
getYqMerchantId
,
LinkedHashMap:
:
new
,
Collectors
.
toList
()));
List
<
StaffAccountRecordDetailDTO
>
resultList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
Integer
,
List
<
StaffAccountRecordDTO
>>
entry
:
yqMerchantMap
.
entrySet
())
{
List
<
StaffAccountRecordDTO
>
yqRecords
=
entry
.
getValue
();
StaffAccountRecordDTO
firstRecord
=
yqRecords
.
get
(
0
);
StaffAccountRecordDetailDTO
yqItem
=
new
StaffAccountRecordDetailDTO
();
yqItem
.
setStaffPhone
(
firstRecord
.
getStaffPhone
());
yqItem
.
setYqMerchantId
(
firstRecord
.
getYqMerchantId
());
yqItem
.
setYqMerchantName
(
firstRecord
.
getYqMerchantName
());
// 组装4s店列表
List
<
StaffAccountRecordDetailDTO
.
FourSShopDetailItem
>
fourSShopList
=
new
ArrayList
<>();
for
(
StaffAccountRecordDTO
record
:
yqRecords
)
{
StaffAccountRecordDetailDTO
.
FourSShopDetailItem
shopItem
=
new
StaffAccountRecordDetailDTO
.
FourSShopDetailItem
();
shopItem
.
setAccountRecordId
(
record
.
getId
());
shopItem
.
setMerchantId
(
record
.
getMerchantId
());
shopItem
.
setMerchantName
(
record
.
getMerchantName
());
shopItem
.
setStationType
(
record
.
getStationType
());
shopItem
.
setCreatedDate
(
record
.
getCreatedDate
());
shopItem
.
setCreatedBy
(
record
.
getCreatedBy
());
shopItem
.
setDeletedFlag
(
record
.
getDeletedFlag
());
// 查询该4s店关联的场景
StaffAccountScene
sceneQuery
=
new
StaffAccountScene
();
sceneQuery
.
setAccountRecordId
(
record
.
getId
());
sceneQuery
.
setDeletedFlag
(
BaseModel
.
DeletedFlagEnum
.
N
.
name
());
List
<
StaffAccountScene
>
accountScenes
=
staffAccountSceneMapper
.
select
(
sceneQuery
);
List
<
SceneDTO
>
sceneList
=
Collections
.
emptyList
();
if
(
CollectionUtils
.
isNotEmpty
(
accountScenes
))
{
List
<
String
>
baseSceneCodes
=
accountScenes
.
stream
()
.
map
(
StaffAccountScene:
:
getBaseSceneCode
)
.
filter
(
Objects:
:
nonNull
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
baseSceneCodes
))
{
SceneQueryFilterDTO
sceneQueryFilterDTO
=
new
SceneQueryFilterDTO
();
sceneQueryFilterDTO
.
setBaseSceneCodeList
(
baseSceneCodes
);
sceneList
=
sceneService
.
getScenesByParams
(
sceneQueryFilterDTO
);
}
}
shopItem
.
setSceneList
(
sceneList
);
fourSShopList
.
add
(
shopItem
);
}
yqItem
.
setFourSShopList
(
fourSShopList
);
resultList
.
add
(
yqItem
);
}
return
resultList
;
}
catch
(
Exception
e
)
{
log
.
error
(
"查询驻店员工门店账号列表异常"
,
e
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATABASE_ERROR
,
e
.
getMessage
());
}
}
/**
* 编辑数据回显(园区店维度聚合)
* 返回员工在某园区店下配置的所有4s店列表,4s店内含场景列表
*
* @param accountRecordId 账号记录id(通过该记录定位园区店和员工)
* @return 详情DTO(三级结构:园区店→4s店列表→场景列表)
*/
public
StaffAccountRecordDetailDTO
getStaffAccountRecordDetail
(
Integer
accountRecordId
)
{
try
{
//
查询StaffAccountRecord主表
//
通过accountRecordId定位到该记录,获取yqMerchantId和staffPhone
StaffAccountRecord
accountRecord
=
staffAccountRecordMapper
.
selectByPrimaryKey
(
accountRecordId
);
if
(
accountRecord
==
null
)
{
throw
new
RpcServiceException
(
"员工账号记录不存在"
);
}
// 查询关联的StaffAccountScene列表
StaffAccountScene
sceneQuery
=
new
StaffAccountScene
();
sceneQuery
.
setAccountRecordId
(
accountRecordId
);
sceneQuery
.
setDeletedFlag
(
BaseModel
.
DeletedFlagEnum
.
N
.
name
());
List
<
StaffAccountScene
>
accountScenes
=
staffAccountSceneMapper
.
select
(
sceneQuery
);
// 通过baseSceneCode列表查询SceneDTO详情
List
<
SceneDTO
>
sceneList
=
Collections
.
emptyList
();
if
(
CollectionUtils
.
isNotEmpty
(
accountScenes
))
{
List
<
String
>
baseSceneCodes
=
accountScenes
.
stream
()
.
map
(
StaffAccountScene:
:
getBaseSceneCode
)
.
filter
(
Objects:
:
nonNull
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
baseSceneCodes
))
{
SceneQueryFilterDTO
sceneQueryFilterDTO
=
new
SceneQueryFilterDTO
();
sceneQueryFilterDTO
.
setBaseSceneCodeList
(
baseSceneCodes
);
sceneList
=
sceneService
.
getScenesByParams
(
sceneQueryFilterDTO
);
String
staffPhone
=
accountRecord
.
getStaffPhone
();
Integer
yqMerchantId
=
accountRecord
.
getYqMerchantId
();
// 查询该员工在该园区店下所有未删除的4s店记录
StaffAccountRecordDTO
recordQuery
=
StaffAccountRecordDTO
.
builder
()
.
staffPhone
(
staffPhone
)
.
yqMerchantId
(
yqMerchantId
)
.
deletedFlagList
(
Arrays
.
asList
(
StaffStatusEnum
.
NOT_DELETED
.
getName
(),
StaffStatusEnum
.
INVALID
.
getName
()))
.
build
();
List
<
StaffAccountRecordDTO
>
allRecords
=
staffAccountRecordMapper
.
listStaffAccountRecord
(
recordQuery
);
// 按每个4s店记录组装4s店详情项
List
<
StaffAccountRecordDetailDTO
.
FourSShopDetailItem
>
fourSShopList
=
new
ArrayList
<>();
for
(
StaffAccountRecordDTO
record
:
allRecords
)
{
StaffAccountRecordDetailDTO
.
FourSShopDetailItem
shopItem
=
new
StaffAccountRecordDetailDTO
.
FourSShopDetailItem
();
shopItem
.
setAccountRecordId
(
record
.
getId
());
shopItem
.
setMerchantId
(
record
.
getMerchantId
());
shopItem
.
setMerchantName
(
record
.
getMerchantName
());
shopItem
.
setStationType
(
record
.
getStationType
());
shopItem
.
setCreatedDate
(
record
.
getCreatedDate
());
shopItem
.
setCreatedBy
(
record
.
getCreatedBy
());
shopItem
.
setDeletedFlag
(
record
.
getDeletedFlag
());
// 查询该4s店关联的场景
StaffAccountScene
sceneQuery
=
new
StaffAccountScene
();
sceneQuery
.
setAccountRecordId
(
record
.
getId
());
sceneQuery
.
setDeletedFlag
(
BaseModel
.
DeletedFlagEnum
.
N
.
name
());
List
<
StaffAccountScene
>
accountScenes
=
staffAccountSceneMapper
.
select
(
sceneQuery
);
List
<
SceneDTO
>
sceneList
=
Collections
.
emptyList
();
if
(
CollectionUtils
.
isNotEmpty
(
accountScenes
))
{
List
<
String
>
baseSceneCodes
=
accountScenes
.
stream
()
.
map
(
StaffAccountScene:
:
getBaseSceneCode
)
.
filter
(
Objects:
:
nonNull
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
baseSceneCodes
))
{
SceneQueryFilterDTO
sceneQueryFilterDTO
=
new
SceneQueryFilterDTO
();
sceneQueryFilterDTO
.
setBaseSceneCodeList
(
baseSceneCodes
);
sceneList
=
sceneService
.
getScenesByParams
(
sceneQueryFilterDTO
);
}
}
shopItem
.
setSceneList
(
sceneList
);
fourSShopList
.
add
(
shopItem
);
}
// 组装
StaffAccountRecordDetailDTO返回
// 组装
园区店维度的返回DTO
StaffAccountRecordDetailDTO
detailDTO
=
new
StaffAccountRecordDetailDTO
();
detailDTO
.
setId
(
accountRecord
.
getId
());
detailDTO
.
setStaffPhone
(
accountRecord
.
getStaffPhone
());
detailDTO
.
setMerchantId
(
accountRecord
.
getMerchantId
());
detailDTO
.
setMerchantName
(
accountRecord
.
getMerchantName
());
detailDTO
.
setYqMerchantId
(
accountRecord
.
getYqMerchantId
());
detailDTO
.
setStaffPhone
(
staffPhone
);
detailDTO
.
setYqMerchantId
(
yqMerchantId
);
detailDTO
.
setYqMerchantName
(
accountRecord
.
getYqMerchantName
());
detailDTO
.
setStationType
(
accountRecord
.
getStationType
());
detailDTO
.
setDeletedFlag
(
accountRecord
.
getDeletedFlag
());
detailDTO
.
setCreatedDate
(
accountRecord
.
getCreatedDate
());
detailDTO
.
setCreatedBy
(
accountRecord
.
getCreatedBy
());
detailDTO
.
setSceneList
(
sceneList
);
detailDTO
.
setFourSShopList
(
fourSShopList
);
return
detailDTO
;
}
catch
(
RpcServiceException
e
)
{
throw
e
;
...
...
rpc-dj-smartcarlife/src/main/java/cn/com/glsx/dj/smartcarlife/service/merchantPerformanceConfig/StaffBaseInfoService.java
View file @
7aaa86b
...
...
@@ -10,6 +10,7 @@ import cn.com.glsx.dj.smartcarlife.dto.scene.SceneDTO;
import
cn.com.glsx.dj.smartcarlife.dto.scene.SceneQueryFilterDTO
;
import
cn.com.glsx.dj.smartcarlife.dto.staff.*
;
import
cn.com.glsx.dj.smartcarlife.enums.*
;
import
cn.com.glsx.dj.smartcarlife.executor.ComputeThreadPoolExecutor
;
import
cn.com.glsx.dj.smartcarlife.mapper.*
;
import
cn.com.glsx.dj.smartcarlife.model.*
;
import
cn.com.glsx.dj.smartcarlife.request.clockin.StaffClockInInfoRequest
;
...
...
@@ -61,6 +62,7 @@ import tk.mybatis.mapper.entity.Example;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.stream.Collectors
;
@Slf4j
...
...
@@ -124,6 +126,9 @@ public class StaffBaseInfoService {
@Autowired
private
SceneMerchantRefNewMapper
sceneMerchantRefNewMapper
;
@Resource
private
ComputeThreadPoolExecutor
processThreadPoolTaskExecutor
;
public
Page
<
StaffBaseInfoDTO
>
listWithPage
(
RpcPagination
<
StaffBaseInfoDTO
>
pagination
)
{
RpcAssert
.
assertNotNull
(
pagination
,
DefaultErrorEnum
.
DATA_NULL
,
"RpcPagination not be null"
);
try
{
...
...
@@ -2266,38 +2271,53 @@ public class StaffBaseInfoService {
@GlsxDistributeLockable
(
name
=
"'StaffBaseInfoService_assignStaffMerchantV2_' + #dto.staffId"
,
time
=
2
,
timeoutException
=
RpcServiceException
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
Boolean
assignStaffMerchantV2
(
AssignStaffMerchantV2DTO
dto
)
{
StaffBaseInfo
staffBaseInfo
=
staffBaseInfoMapper
.
selectByPrimaryKey
(
dto
.
getStaffId
());
if
(
staffBaseInfo
==
null
||
DeleteFlagEnum
.
D
.
getValue
().
equals
(
staffBaseInfo
.
getDeletedFlag
()))
{
throw
new
RpcServiceException
(
RpcErrorEnum
.
DATA_INVALID_WITH_SPECIFIC_MSG
,
"员工信息不存在或已被删除"
);
}
if
(
WorkingStatusEnum
.
DIMISSION
.
getValue
()
==
staffBaseInfo
.
getWorkingStatus
())
{
throw
new
RpcServiceException
(
RpcErrorEnum
.
DATA_INVALID_WITH_SPECIFIC_MSG
,
"员工已离职,不允许分配"
);
}
StaffBaseInfo
staffBaseInfo
=
validateAndGetStaffBaseInfo
(
dto
);
String
staffPhone
=
staffBaseInfo
.
getStaffPhone
();
if
(
CollectionUtils
.
isEmpty
(
dto
.
getShopItemList
()))
{
throw
new
RpcServiceException
(
RpcErrorEnum
.
DATA_INVALID_WITH_SPECIFIC_MSG
,
"门店列表不能为空"
);
}
// 遍历园区店 → 4s店 → 场景,按(yqMerchantId+merchantId)维度处理
for
(
AssignStaffMerchantV2DTO
.
ShopItem
yqItem
:
dto
.
getShopItemList
())
{
if
(
Objects
.
isNull
(
yqItem
.
getYqMerchantId
())
||
StringUtils
.
isBlank
(
yqItem
.
getYqMerchantName
()))
{
throw
new
RpcServiceException
(
RpcErrorEnum
.
DATA_INVALID_WITH_SPECIFIC_MSG
,
"园区店信息不能为空"
);
}
if
(
Objects
.
isNull
(
yqItem
.
getStationType
()))
{
throw
new
RpcServiceException
(
RpcErrorEnum
.
DATA_INVALID_WITH_SPECIFIC_MSG
,
"驻店类型不能为空"
);
}
if
(
CollectionUtils
.
isEmpty
(
yqItem
.
getFourSShopList
()))
{
continue
;
}
// ---- 提前查询:一次性查出该园区店下所有已有记录(yqMerchantId+merchantId 为唯一组合) ----
List
<
StaffAccountRecordDTO
>
allExistingRecords
=
preQueryExistingRecords
(
staffPhone
,
yqItem
.
getYqMerchantId
());
Map
<
String
,
StaffAccountRecordDTO
>
existRecordMap
=
buildExistRecordMap
(
allExistingRecords
);
// ---- 提前查询:一次性查出所有已有场景 ----
Map
<
Integer
,
List
<
StaffAccountScene
>>
existSceneMap
=
preQueryExistingScenes
(
allExistingRecords
);
// ---- 收集待写入数据 ----
List
<
Long
>
sceneIdsToDelete
=
new
ArrayList
<>();
List
<
StaffAccountScene
>
scenesToInsert
=
new
ArrayList
<>();
List
<
StaffAccountRecord
>
recordsToUpdate
=
new
ArrayList
<>();
List
<
Integer
>
processedMerchantIds
=
new
ArrayList
<>();
// 账户中心同步:同一园区店只调用一次
boolean
accountCenterSynced
=
false
;
// 预查询该园区店下所有4s店支持的场景配置(避免循环查DB)
List
<
Integer
>
merchantIdList
=
yqItem
.
getFourSShopList
().
stream
()
.
map
(
AssignStaffMerchantV2DTO
.
FourSShopItem
::
getMerchantId
)
.
filter
(
Objects:
:
nonNull
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
Map
<
Integer
,
Set
<
String
>>
merchantSupportedSceneMap
=
preQuerySupportedSceneCodesBatch
(
merchantIdList
);
for
(
AssignStaffMerchantV2DTO
.
FourSShopItem
shopItem
:
yqItem
.
getFourSShopList
())
{
Integer
merchantId
=
shopItem
.
getMerchantId
();
String
merchantName
=
shopItem
.
getMerchantName
();
List
<
String
>
baseSceneCodes
=
shopItem
.
getBaseSceneCodeList
();
Byte
stationType
=
shopItem
.
getStationType
();
if
(
Objects
.
isNull
(
stationType
))
{
throw
new
RpcServiceException
(
RpcErrorEnum
.
DATA_INVALID_WITH_SPECIFIC_MSG
,
"驻店类型不能为空"
);
}
processedMerchantIds
.
add
(
merchantId
);
List
<
String
>
baseSceneCodes
=
shopItem
.
getSceneList
()
!=
null
?
shopItem
.
getSceneList
().
stream
().
map
(
AssignStaffMerchantV2DTO
.
SceneItem
::
getBaseSceneCode
).
collect
(
Collectors
.
toList
())
:
Collections
.
emptyList
();
List
<
SceneDTO
>
scenes
=
getSceneDTOS
(
baseSceneCodes
);
if
(
CollectionUtils
.
isEmpty
(
scenes
))
{
log
.
warn
(
"4s店[merchantId={}]场景信息不存在,跳过"
,
merchantId
);
...
...
@@ -2306,46 +2326,47 @@ public class StaffBaseInfoService {
String
sceneTypes
=
scenes
.
stream
().
map
(
SceneDTO:
:
getSceneType
).
filter
(
Objects:
:
nonNull
).
map
(
String:
:
valueOf
).
distinct
().
sorted
().
collect
(
Collectors
.
joining
(
","
));
// 按(staffPhone, merchantId, yqMerchantId)查询是否已存在
StaffAccountRecordDTO
recordQuery
=
StaffAccountRecordDTO
.
builder
()
.
staffPhone
(
staffPhone
)
.
merchantId
(
merchantId
)
.
yqMerchantId
(
yqItem
.
getYqMerchantId
())
.
deletedFlagList
(
Arrays
.
asList
(
StaffStatusEnum
.
NOT_DELETED
.
getName
(),
StaffStatusEnum
.
INVALID
.
getName
()))
.
build
();
List
<
StaffAccountRecordDTO
>
existAccountList
=
staffAccountRecordService
.
listStaffAccountRecord
(
recordQuery
);
// 从预查询结果中获取该4s店支持的场景配置
Set
<
String
>
supportedSceneCodes
=
merchantSupportedSceneMap
.
getOrDefault
(
merchantId
,
Collections
.
emptySet
());
if
(
CollectionUtils
.
isNotEmpty
(
existAccountList
))
{
// 已存在:场景覆盖(先删后插)+ 更新stationType/staffSceneLabel
StaffAccountRecordDTO
existRecord
=
existAccountList
.
get
(
0
);
StaffAccountRecordDTO
existRecord
=
existRecordMap
.
get
(
yqItem
.
getYqMerchantId
()
+
"_"
+
merchantId
);
if
(
existRecord
!=
null
)
{
// 已存在:收集场景删除 + 场景插入 + 记录更新
Integer
accountRecordId
=
existRecord
.
getId
();
// 删除旧的场景记录
StaffAccountScene
deleteCondition
=
new
StaffAccountScene
();
deleteCondition
.
setAccountRecordId
(
accountRecordId
);
List
<
StaffAccountScene
>
oldScenes
=
staffAccountSceneMapper
.
select
(
deleteCondition
);
// 收集旧场景ID用于批量删除
List
<
StaffAccountScene
>
oldScenes
=
existSceneMap
.
getOrDefault
(
accountRecordId
,
Collections
.
emptyList
());
for
(
StaffAccountScene
oldScene
:
oldScenes
)
{
StaffAccountScene
deleteScene
=
new
StaffAccountScene
();
deleteScene
.
setId
(
oldScene
.
getId
());
deleteScene
.
setDeletedFlag
(
DeleteFlagEnum
.
D
.
getValue
());
staffAccountSceneMapper
.
updateByPrimaryKeySelective
(
deleteScene
);
sceneIdsToDelete
.
add
(
oldScene
.
getId
());
}
// 重新插入新场景(带4s店场景校验)
batchInsertAccountSceneWithValidation
(
scenes
,
accountRecordId
,
merchantId
);
// 收集新场景用于批量插入(带校验)
for
(
SceneDTO
sceneItem
:
scenes
)
{
if
(
merchantId
!=
null
&&
!
supportedSceneCodes
.
contains
(
sceneItem
.
getBaseSceneCode
()))
{
log
.
warn
(
"4s店[merchantId={}]不支持场景[baseSceneCode={}],跳过插入"
,
merchantId
,
sceneItem
.
getBaseSceneCode
());
continue
;
}
Integer
sceneType
=
sceneItem
.
getSceneType
();
scenesToInsert
.
add
(
StaffAccountScene
.
builder
()
.
accountRecordId
(
accountRecordId
)
.
baseSceneCode
(
sceneItem
.
getBaseSceneCode
())
.
sceneType
(
Objects
.
isNull
(
sceneType
)
?
null
:
sceneType
.
byteValue
())
.
build
());
}
//
更新 accountRecord
//
收集记录更新
StaffAccountRecord
updateRecord
=
new
StaffAccountRecord
();
updateRecord
.
setId
(
accountRecordId
);
updateRecord
.
setStaffSceneLabel
(
sceneTypes
);
updateRecord
.
setStationType
(
yqItem
.
getStationType
()
);
updateRecord
.
setStationType
(
stationType
);
updateRecord
.
setUpdatedBy
(
dto
.
getOperatorBy
());
updateRecord
.
setUpdatedDate
(
new
Date
());
staffAccountRecordService
.
updateByPrimaryKeySelective
(
updateRecord
);
recordsToUpdate
.
add
(
updateRecord
);
log
.
info
(
"V2场景覆盖
更新
完成,accountRecordId:{}"
,
accountRecordId
);
log
.
info
(
"V2场景覆盖
收集
完成,accountRecordId:{}"
,
accountRecordId
);
}
else
{
// 不存在:新增
// 不存在:新增
记录 + 场景
StaffAccountRecord
accountRecord
=
new
StaffAccountRecord
();
accountRecord
.
setStaffUuid
(
"temp_uuid"
);
accountRecord
.
setStaffPhone
(
staffPhone
);
...
...
@@ -2361,11 +2382,24 @@ public class StaffBaseInfoService {
accountRecord
.
setUpdatedDate
(
new
Date
());
accountRecord
.
setDeletedFlag
(
DeleteFlagEnum
.
N
.
getValue
());
accountRecord
.
setCreatedSource
(
dto
.
getCreatedSource
());
accountRecord
.
setStationType
(
yqItem
.
getStationType
()
);
accountRecord
.
setStationType
(
stationType
);
staffAccountRecordService
.
insertStaffAccountRecord
(
accountRecord
);
Integer
accountRecordId
=
accountRecord
.
getId
();
batchInsertAccountSceneWithValidation
(
scenes
,
accountRecordId
,
merchantId
);
// 收集场景用于批量插入(带校验)
for
(
SceneDTO
sceneItem
:
scenes
)
{
if
(
merchantId
!=
null
&&
!
supportedSceneCodes
.
contains
(
sceneItem
.
getBaseSceneCode
()))
{
log
.
warn
(
"4s店[merchantId={}]不支持场景[baseSceneCode={}],跳过插入"
,
merchantId
,
sceneItem
.
getBaseSceneCode
());
continue
;
}
Integer
sceneType
=
sceneItem
.
getSceneType
();
scenesToInsert
.
add
(
StaffAccountScene
.
builder
()
.
accountRecordId
(
accountRecordId
)
.
baseSceneCode
(
sceneItem
.
getBaseSceneCode
())
.
sceneType
(
Objects
.
isNull
(
sceneType
)
?
null
:
sceneType
.
byteValue
())
.
build
());
}
// 首次分配/增量分配
Byte
workingStatus
=
staffBaseInfo
.
getWorkingStatus
();
...
...
@@ -2422,11 +2456,184 @@ public class StaffBaseInfoService {
}
}
}
// ---- 批量执行写入:场景删除、场景插入、记录更新 ----
batchExecuteWrites
(
sceneIdsToDelete
,
scenesToInsert
,
recordsToUpdate
);
// ---- 编辑场景:删除该园区店下请求中不存在的4s店记录及场景(仅编辑时执行) ----
if
(
Boolean
.
TRUE
.
equals
(
dto
.
getEditFlag
()))
{
deleteMissingFourShopRecords
(
dto
,
allExistingRecords
,
processedMerchantIds
);
}
}
return
Boolean
.
TRUE
;
}
/**
* 验证参数并获取员工基础信息
*/
private
StaffBaseInfo
validateAndGetStaffBaseInfo
(
AssignStaffMerchantV2DTO
dto
)
{
StaffBaseInfo
staffBaseInfo
=
staffBaseInfoMapper
.
selectByPrimaryKey
(
dto
.
getStaffId
());
if
(
staffBaseInfo
==
null
||
DeleteFlagEnum
.
D
.
getValue
().
equals
(
staffBaseInfo
.
getDeletedFlag
()))
{
throw
new
RpcServiceException
(
RpcErrorEnum
.
DATA_INVALID_WITH_SPECIFIC_MSG
,
"员工信息不存在或已被删除"
);
}
if
(
WorkingStatusEnum
.
DIMISSION
.
getValue
()
==
staffBaseInfo
.
getWorkingStatus
())
{
throw
new
RpcServiceException
(
RpcErrorEnum
.
DATA_INVALID_WITH_SPECIFIC_MSG
,
"员工已离职,不允许分配"
);
}
if
(
CollectionUtils
.
isEmpty
(
dto
.
getShopItemList
()))
{
throw
new
RpcServiceException
(
RpcErrorEnum
.
DATA_INVALID_WITH_SPECIFIC_MSG
,
"门店列表不能为空"
);
}
return
staffBaseInfo
;
}
/**
* 预查询该园区店下已有记录
*/
private
List
<
StaffAccountRecordDTO
>
preQueryExistingRecords
(
String
staffPhone
,
Integer
yqMerchantId
)
{
StaffAccountRecordDTO
allRecordsQuery
=
StaffAccountRecordDTO
.
builder
()
.
staffPhone
(
staffPhone
)
.
yqMerchantId
(
yqMerchantId
)
.
deletedFlagList
(
Arrays
.
asList
(
StaffStatusEnum
.
NOT_DELETED
.
getName
(),
StaffStatusEnum
.
INVALID
.
getName
()))
.
build
();
return
staffAccountRecordService
.
listStaffAccountRecord
(
allRecordsQuery
);
}
/**
* 构建existRecordMap(key: yqMerchantId_merchantId)
*/
private
Map
<
String
,
StaffAccountRecordDTO
>
buildExistRecordMap
(
List
<
StaffAccountRecordDTO
>
allExistingRecords
)
{
return
allExistingRecords
.
stream
()
.
filter
(
r
->
ObjectUtil
.
isNotNull
(
r
.
getMerchantId
())
&&
ObjectUtil
.
isNotNull
(
r
.
getYqMerchantId
()))
.
collect
(
Collectors
.
toMap
(
r
->
r
.
getYqMerchantId
()
+
"_"
+
r
.
getMerchantId
(),
r
->
r
,
(
a
,
b
)
->
a
));
}
/**
* 预查询已有场景(按accountRecordId分组)
*/
private
Map
<
Integer
,
List
<
StaffAccountScene
>>
preQueryExistingScenes
(
List
<
StaffAccountRecordDTO
>
allExistingRecords
)
{
List
<
Integer
>
existRecordIds
=
allExistingRecords
.
stream
().
map
(
StaffAccountRecordDTO:
:
getId
).
collect
(
Collectors
.
toList
());
Map
<
Integer
,
List
<
StaffAccountScene
>>
existSceneMap
=
new
HashMap
<>();
if
(
CollectionUtils
.
isNotEmpty
(
existRecordIds
))
{
Example
sceneExample
=
new
Example
(
StaffAccountScene
.
class
);
sceneExample
.
createCriteria
()
.
andIn
(
"accountRecordId"
,
existRecordIds
)
.
andEqualTo
(
"deletedFlag"
,
BaseModel
.
DeletedFlagEnum
.
N
.
name
());
List
<
StaffAccountScene
>
allScenes
=
staffAccountSceneMapper
.
selectByExample
(
sceneExample
);
existSceneMap
=
allScenes
.
stream
().
collect
(
Collectors
.
groupingBy
(
StaffAccountScene:
:
getAccountRecordId
));
}
return
existSceneMap
;
}
/**
* 预查询4s店支持的所有场景配置
*/
private
Set
<
String
>
preQuerySupportedSceneCodes
(
Integer
merchantId
)
{
if
(
merchantId
==
null
)
{
return
Collections
.
emptySet
();
}
List
<
SceneMerchantRefNew
>
allRefs
=
sceneMerchantRefNewMapper
.
findByMerchantId
(
merchantId
);
return
allRefs
.
stream
()
.
filter
(
ref
->
ref
.
getStatus
()
!=
null
&&
ref
.
getStatus
()
==
1
)
.
map
(
SceneMerchantRefNew:
:
getBaseSceneCode
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toSet
());
}
/**
* 批量预查询多个4s店支持的所有场景配置
*/
private
Map
<
Integer
,
Set
<
String
>>
preQuerySupportedSceneCodesBatch
(
List
<
Integer
>
merchantIdList
)
{
Map
<
Integer
,
Set
<
String
>>
resultMap
=
new
HashMap
<>();
if
(
CollectionUtils
.
isEmpty
(
merchantIdList
))
{
return
resultMap
;
}
Example
example
=
new
Example
(
SceneMerchantRefNew
.
class
);
example
.
createCriteria
()
.
andIn
(
"mainMerchantId"
,
merchantIdList
)
.
andEqualTo
(
"mainMerchantType"
,
"2"
)
.
andEqualTo
(
"deletedFlag"
,
"N"
);
List
<
SceneMerchantRefNew
>
allRefs
=
sceneMerchantRefNewMapper
.
selectByExample
(
example
);
for
(
SceneMerchantRefNew
ref
:
allRefs
)
{
if
(
ref
.
getStatus
()
!=
null
&&
ref
.
getStatus
()
==
1
&&
ref
.
getBaseSceneCode
()
!=
null
)
{
resultMap
.
computeIfAbsent
(
ref
.
getMainMerchantId
(),
k
->
new
HashSet
<>()).
add
(
ref
.
getBaseSceneCode
());
}
}
return
resultMap
;
}
/**
* 批量执行写入:场景删除、场景插入、记录更新
*/
private
void
batchExecuteWrites
(
List
<
Long
>
sceneIdsToDelete
,
List
<
StaffAccountScene
>
scenesToInsert
,
List
<
StaffAccountRecord
>
recordsToUpdate
)
{
// 场景删除
if
(
CollectionUtils
.
isNotEmpty
(
sceneIdsToDelete
))
{
for
(
Long
sceneId
:
sceneIdsToDelete
)
{
StaffAccountScene
deleteScene
=
new
StaffAccountScene
();
deleteScene
.
setId
(
sceneId
);
deleteScene
.
setDeletedFlag
(
DeleteFlagEnum
.
D
.
getValue
());
staffAccountSceneMapper
.
updateByPrimaryKeySelective
(
deleteScene
);
}
}
// 场景插入(线程池异步)
if
(
CollectionUtils
.
isNotEmpty
(
scenesToInsert
))
{
CompletableFuture
.
allOf
(
scenesToInsert
.
stream
()
.
map
(
scene
->
CompletableFuture
.
runAsync
(()
->
staffAccountSceneMapper
.
insertSelective
(
scene
),
processThreadPoolTaskExecutor
)).
toArray
(
CompletableFuture
[]::
new
))
.
join
();
}
// 记录更新(线程池异步)
if
(
CollectionUtils
.
isNotEmpty
(
recordsToUpdate
))
{
CompletableFuture
.
allOf
(
recordsToUpdate
.
stream
()
.
map
(
record
->
CompletableFuture
.
runAsync
(()
->
staffAccountRecordService
.
updateByPrimaryKeySelective
(
record
),
processThreadPoolTaskExecutor
)).
toArray
(
CompletableFuture
[]::
new
))
.
join
();
}
}
/**
* 删除该园区店下请求中不存在的4s店记录及场景
*/
private
void
deleteMissingFourShopRecords
(
AssignStaffMerchantV2DTO
dto
,
List
<
StaffAccountRecordDTO
>
allExistingRecords
,
List
<
Integer
>
processedMerchantIds
)
{
List
<
CompletableFuture
<
Void
>>
deleteFutures
=
new
ArrayList
<>();
for
(
StaffAccountRecordDTO
existingRecord
:
allExistingRecords
)
{
if
(!
processedMerchantIds
.
contains
(
existingRecord
.
getMerchantId
()))
{
deleteFutures
.
add
(
CompletableFuture
.
runAsync
(()
->
{
// 逻辑删除该4s店关联的场景记录
StaffAccountScene
sceneQuery
=
new
StaffAccountScene
();
sceneQuery
.
setAccountRecordId
(
existingRecord
.
getId
());
sceneQuery
.
setDeletedFlag
(
BaseModel
.
DeletedFlagEnum
.
N
.
name
());
List
<
StaffAccountScene
>
oldScenes
=
staffAccountSceneMapper
.
select
(
sceneQuery
);
for
(
StaffAccountScene
oldScene
:
oldScenes
)
{
StaffAccountScene
deleteScene
=
new
StaffAccountScene
();
deleteScene
.
setId
(
oldScene
.
getId
());
deleteScene
.
setDeletedFlag
(
DeleteFlagEnum
.
D
.
getValue
());
staffAccountSceneMapper
.
updateByPrimaryKeySelective
(
deleteScene
);
}
// 逻辑删除该4s店账号记录
StaffAccountRecord
deleteRecord
=
new
StaffAccountRecord
();
deleteRecord
.
setId
(
existingRecord
.
getId
());
deleteRecord
.
setDeletedFlag
(
DeleteFlagEnum
.
D
.
getValue
());
deleteRecord
.
setUpdatedBy
(
dto
.
getOperatorBy
());
deleteRecord
.
setUpdatedDate
(
new
Date
());
staffAccountRecordService
.
updateByPrimaryKeySelective
(
deleteRecord
);
log
.
info
(
"V2编辑删除4s店记录,accountRecordId={},merchantId={}"
,
existingRecord
.
getId
(),
existingRecord
.
getMerchantId
());
},
processThreadPoolTaskExecutor
));
}
}
if
(
CollectionUtils
.
isNotEmpty
(
deleteFutures
))
{
CompletableFuture
.
allOf
(
deleteFutures
.
toArray
(
new
CompletableFuture
[
0
])).
join
();
}
}
/**
* 带场景校验的批量插入(V2专用)
* 插入前校验4s店是否支持该场景,不支持则跳过
*/
...
...
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