Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rpc-staff
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 b970bda1
authored
Jun 22, 2026
by
谢海旭
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
招聘管理:去处理接口调整
1 parent
90206707
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
928 additions
and
10 deletions
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/recruitment/RecruitmentProcessResultDTO.java
rpc-dj-staff/pom.xml
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/config/dubbo/SmartCarLifeDubboConfig.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/constant/KafkaTopicConstants.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mq/TrialOnboardingApprovedConsumer.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mq/TrialOnboardingCreatedConsumer.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mq/TrialProcessedConsumer.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/remote/RecruitmentDemandRemoteImpl.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/recruitment/RecruitmentDemandService.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/recruitment/RecruitmentTrialOnboardingService.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/recruitment/RecruitmentProcessResultDTO.java
View file @
b970bda
...
...
@@ -3,6 +3,8 @@ package cn.com.glsx.dj.staff.dto.recruitment;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
/**
* 招聘需求处理结果DTO
* 用于收集处理过程中的简历变更信息
...
...
@@ -28,4 +30,16 @@ public class RecruitmentProcessResultDTO {
@ApiModelProperty
(
notes
=
"是否有面试结果变更"
)
private
boolean
hasInterviewResult
=
false
;
/**
* 新创建的试岗记录ID列表(用于自动审批后开通驻店账号)
*/
@ApiModelProperty
(
notes
=
"新创建的试岗记录ID列表"
)
private
List
<
Integer
>
newTrialOnboardingIds
;
/**
* 被处理(processResult被赋值)的试岗记录ID列表
*/
@ApiModelProperty
(
notes
=
"被处理的试岗记录ID列表"
)
private
List
<
Integer
>
processedTrialOnboardingIds
;
}
rpc-dj-staff/pom.xml
View file @
b970bda
...
...
@@ -12,6 +12,10 @@
<packaging>
war
</packaging>
<dependencies>
<dependency>
<groupId>
org.oreframework
</groupId>
<artifactId>
ore-jms
</artifactId>
</dependency>
<dependency>
<groupId>
cn.com.glsx.dj
</groupId>
<artifactId>
rpc-dj-staff-api
</artifactId>
<version>
5.8.3-SNAPSHOT
</version>
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/config/dubbo/SmartCarLifeDubboConfig.java
View file @
b970bda
...
...
@@ -14,6 +14,16 @@ public class SmartCarLifeDubboConfig extends DubboConfig {
}
@Bean
public
SceneMerchantRefRemote
sceneMerchantRefRemote
()
{
return
factory
.
builder
(
SceneMerchantRefRemote
.
class
).
check
(
check
).
timeout
(
timeout
).
version
(
"1.0.0"
).
build
();
}
@Bean
public
SceneRemote
sceneRemote
()
{
return
factory
.
builder
(
SceneRemote
.
class
).
check
(
check
).
timeout
(
timeout
).
version
(
"1.0.0"
).
build
();
}
@Bean
public
MerchantDailyReportHuaweiRemote
merchantDailyReportHuaweiRemote
()
{
return
factory
.
builder
(
MerchantDailyReportHuaweiRemote
.
class
).
check
(
check
).
timeout
(
timeout
).
version
(
"1.0.0"
).
build
();
}
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/constant/KafkaTopicConstants.java
0 → 100644
View file @
b970bda
package
cn
.
com
.
glsx
.
dj
.
staff
.
constant
;
/**
* Kafka Topic 常量
*/
public
class
KafkaTopicConstants
{
/**
* 试岗审批通过后开通驻店账号
*/
public
static
final
String
TRIAL_ONBOARDING_APPROVED
=
"TRIAL_ONBOARDING_APPROVED"
;
/**
* 试岗处理(不通过)后禁用账户中心账号
*/
public
static
final
String
TRIAL_ONBOARDING_PROCESSED
=
"TRIAL_ONBOARDING_PROCESSED"
;
/**
* 新增试岗后推送企微通知给区域运营和线上运营
*/
public
static
final
String
TRIAL_ONBOARDING_CREATED
=
"TRIAL_ONBOARDING_CREATED"
;
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mq/TrialOnboardingApprovedConsumer.java
0 → 100644
View file @
b970bda
package
cn
.
com
.
glsx
.
dj
.
staff
.
mq
;
import
cn.com.glsx.dj.staff.constant.KafkaTopicConstants
;
import
cn.com.glsx.dj.staff.service.recruitment.RecruitmentTrialOnboardingService
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.oreframework.jms.kafka.consumer.KafkaConsumer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* 试岗审批通过后开通驻店账号 消费者
*/
@Slf4j
@Component
public
class
TrialOnboardingApprovedConsumer
extends
KafkaConsumer
{
@Autowired
private
RecruitmentTrialOnboardingService
recruitmentTrialOnboardingService
;
public
TrialOnboardingApprovedConsumer
()
{
super
(
KafkaTopicConstants
.
TRIAL_ONBOARDING_APPROVED
,
false
);
}
@Override
public
void
processMessage
(
Object
o
)
{
try
{
String
msg
=
new
String
(
getMessage
());
log
.
info
(
"试岗审批通过Kafka消费,处理开始,msg:{}"
,
msg
);
Integer
trialOnboardingId
=
Integer
.
parseInt
(
msg
);
recruitmentTrialOnboardingService
.
processTrialApproval
(
trialOnboardingId
);
}
catch
(
Exception
e
)
{
log
.
error
(
"试岗审批通过Kafka消费异常: "
,
e
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
e
.
getMessage
());
}
}
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mq/TrialOnboardingCreatedConsumer.java
0 → 100644
View file @
b970bda
package
cn
.
com
.
glsx
.
dj
.
staff
.
mq
;
import
cn.com.glsx.dj.staff.constant.KafkaTopicConstants
;
import
cn.com.glsx.dj.staff.service.recruitment.RecruitmentDemandService
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.oreframework.jms.kafka.consumer.KafkaConsumer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* 新增试岗后推送企微通知给区域运营和线上运营 消费者
*/
@Slf4j
@Component
public
class
TrialOnboardingCreatedConsumer
extends
KafkaConsumer
{
@Autowired
private
RecruitmentDemandService
recruitmentDemandService
;
public
TrialOnboardingCreatedConsumer
()
{
super
(
KafkaTopicConstants
.
TRIAL_ONBOARDING_CREATED
,
false
);
}
@Override
public
void
processMessage
(
Object
o
)
{
try
{
String
msg
=
new
String
(
getMessage
());
log
.
info
(
"新增试岗Kafka消费,处理开始,msg:{}"
,
msg
);
Integer
trialOnboardingId
=
Integer
.
parseInt
(
msg
);
// 推送企微消息给区域运营和线上运营
recruitmentDemandService
.
sendTrialCreatedRegionOperationMessage
(
trialOnboardingId
);
recruitmentDemandService
.
sendTrialCreatedOnlineOperationMessage
(
trialOnboardingId
);
}
catch
(
Exception
e
)
{
log
.
error
(
"新增试岗Kafka消费异常: "
,
e
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
e
.
getMessage
());
}
}
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mq/TrialProcessedConsumer.java
0 → 100644
View file @
b970bda
package
cn
.
com
.
glsx
.
dj
.
staff
.
mq
;
import
cn.com.glsx.dj.smartcarlife.enums.StaffStatusEnum
;
import
cn.com.glsx.dj.staff.constant.KafkaTopicConstants
;
import
cn.com.glsx.dj.staff.mapper.RecruitmentTrialOnboardingMapper
;
import
cn.com.glsx.dj.staff.model.RecruitmentTrialOnboarding
;
import
cn.com.glsx.dj.staff.service.recruitment.RecruitmentDemandService
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.merchants.model.request.StaffBatchRequest
;
import
cn.com.glsx.merchants.remote.MerchantStaffRemote
;
import
lombok.extern.slf4j.Slf4j
;
import
org.oreframework.jms.kafka.consumer.KafkaConsumer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Objects
;
/**
* 试岗处理(不通过)后禁用账户中心账号 消费者
*/
@Slf4j
@Component
public
class
TrialProcessedConsumer
extends
KafkaConsumer
{
@Autowired
private
RecruitmentTrialOnboardingMapper
recruitmentTrialOnboardingMapper
;
@Autowired
private
MerchantStaffRemote
merchantStaffRemote
;
@Autowired
private
RecruitmentDemandService
recruitmentDemandService
;
public
TrialProcessedConsumer
()
{
super
(
KafkaTopicConstants
.
TRIAL_ONBOARDING_PROCESSED
,
false
);
}
@Override
public
void
processMessage
(
Object
o
)
{
try
{
String
msg
=
new
String
(
getMessage
());
log
.
info
(
"试岗处理Kafka消费,处理开始,msg:{}"
,
msg
);
Integer
trialOnboardingId
=
Integer
.
parseInt
(
msg
);
// 1. 推送企微消息给区域运营和线上运营(只要处理了就推送)
recruitmentDemandService
.
sendTrialProcessedRegionOperationMessage
(
trialOnboardingId
);
recruitmentDemandService
.
sendTrialProcessedOnlineOperationMessage
(
trialOnboardingId
);
// 2. 如果处理结果为不通过,禁用账户中心账号
processTrialRejected
(
trialOnboardingId
);
}
catch
(
Exception
e
)
{
log
.
error
(
"试岗处理Kafka消费异常: "
,
e
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
e
.
getMessage
());
}
}
/**
* 处理试岗不通过逻辑:禁用账户中心账号
*/
private
void
processTrialRejected
(
Integer
trialId
)
{
// 1. 查询试岗记录
RecruitmentTrialOnboarding
trial
=
recruitmentTrialOnboardingMapper
.
selectByPrimaryKey
(
trialId
);
if
(
trial
==
null
)
{
log
.
warn
(
"试岗记录不存在,trialId:{}"
,
trialId
);
return
;
}
if
(!
Objects
.
equals
(
trial
.
getProcessResult
(),
0
))
{
log
.
info
(
"试岗记录处理结果不为不通过,跳过禁用,trialId:{},processResult:{}"
,
trialId
,
trial
.
getProcessResult
());
return
;
}
if
(
trial
.
getPhoneNumber
()
==
null
)
{
log
.
warn
(
"试岗记录手机号为空,trialId:{}"
,
trialId
);
return
;
}
// 2. 调用账户中心接口,将该手机号对应的全部账号禁用
StaffBatchRequest
staffBatchRequest
=
new
StaffBatchRequest
();
staffBatchRequest
.
setStaffPhone
(
trial
.
getPhoneNumber
());
staffBatchRequest
.
setStatus
(
StaffStatusEnum
.
INVALID
.
getValue
());
log
.
info
(
"调用账户中心禁用账号,phone:{}, trialId:{}"
,
trial
.
getPhoneNumber
(),
trialId
);
RpcResponse
<
Boolean
>
response
=
merchantStaffRemote
.
updateStaffStatusByPhone
(
staffBatchRequest
);
if
(
response
.
hasResult
())
{
log
.
info
(
"账户中心禁用账号成功,phone:{}, trialId:{}"
,
trial
.
getPhoneNumber
(),
trialId
);
}
else
{
log
.
error
(
"账户中心禁用账号失败,phone:{}, trialId:{}, msg:{}"
,
trial
.
getPhoneNumber
(),
trialId
,
response
.
getMessage
());
}
}
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/remote/RecruitmentDemandRemoteImpl.java
View file @
b970bda
package
cn
.
com
.
glsx
.
dj
.
staff
.
remote
;
import
cn.com.glsx.dj.staff.constant.KafkaTopicConstants
;
import
cn.com.glsx.dj.staff.dto.recruitment.*
;
import
cn.com.glsx.dj.staff.enums.RecruitmentDemandStatusEnum
;
import
cn.com.glsx.dj.staff.enums.recruitment.RecruitmentDemandBusinessTypeEnum
;
...
...
@@ -16,6 +17,7 @@ import com.github.pagehelper.Page;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.dubbo.config.annotation.DubboService
;
import
org.oreframework.jms.kafka.producer.KafkaProducer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.ArrayList
;
...
...
@@ -30,6 +32,9 @@ public class RecruitmentDemandRemoteImpl implements RecruitmentDemandRemote{
@Autowired
private
RecruitmentDemandService
recruitmentDemandService
;
@Autowired
private
KafkaProducer
kafkaProducer
;
@Override
public
RpcResponse
<
RecruitmentDemandDTO
>
statRecruitmentDemand
(
RecruitmentDemandDTO
dto
)
{
try
{
...
...
@@ -160,6 +165,47 @@ public class RecruitmentDemandRemoteImpl implements RecruitmentDemandRemote{
);
}
}
// 新增试岗记录默认审批通过,发送Kafka触发开通驻店账号
if
(
CollectionUtils
.
isNotEmpty
(
processResult
.
getNewTrialOnboardingIds
()))
{
for
(
Integer
trialId
:
processResult
.
getNewTrialOnboardingIds
())
{
CompletableFuture
.
runAsync
(()
->
{
try
{
kafkaProducer
.
send
(
KafkaTopicConstants
.
TRIAL_ONBOARDING_APPROVED
,
String
.
valueOf
(
trialId
).
getBytes
());
log
.
info
(
"新增试岗发送Kafka消息(开通账号),trialId:{}"
,
trialId
);
}
catch
(
Exception
e
)
{
log
.
error
(
"新增试岗发送Kafka消息异常(开通账号),trialId:{}"
,
trialId
,
e
);
}
});
// 新增试岗后推送企微通知给区域运营和线上运营
CompletableFuture
.
runAsync
(()
->
{
try
{
kafkaProducer
.
send
(
KafkaTopicConstants
.
TRIAL_ONBOARDING_CREATED
,
String
.
valueOf
(
trialId
).
getBytes
());
log
.
info
(
"新增试岗发送Kafka消息(企微通知),trialId:{}"
,
trialId
);
}
catch
(
Exception
e
)
{
log
.
error
(
"新增试岗发送Kafka消息异常(企微通知),trialId:{}"
,
trialId
,
e
);
}
});
}
}
// 试岗处理为不通过,发送Kafka触发禁用账户中心账号
if
(
CollectionUtils
.
isNotEmpty
(
processResult
.
getProcessedTrialOnboardingIds
()))
{
for
(
Integer
trialId
:
processResult
.
getProcessedTrialOnboardingIds
())
{
CompletableFuture
.
runAsync
(()
->
{
try
{
kafkaProducer
.
send
(
KafkaTopicConstants
.
TRIAL_ONBOARDING_PROCESSED
,
String
.
valueOf
(
trialId
).
getBytes
());
log
.
info
(
"试岗处理发送Kafka消息,trialId:{}"
,
trialId
);
}
catch
(
Exception
e
)
{
log
.
error
(
"试岗处理发送Kafka消息异常,trialId:{}"
,
trialId
,
e
);
}
});
}
}
return
RpcResponse
.
success
(
"success"
);
}
catch
(
RpcServiceException
e
){
log
.
error
(
e
.
getMessage
(),
e
);
...
...
@@ -354,6 +400,19 @@ public class RecruitmentDemandRemoteImpl implements RecruitmentDemandRemote{
CompletableFuture
.
runAsync
(()
->
recruitmentDemandService
.
sendTrialApprovalOnlineOperationMessage
(
result
.
getId
()));
// 审批通过后发送Kafka消息,触发开通驻店账号
if
(
result
!=
null
&&
Objects
.
equals
(
result
.
getApprovalResult
(),
1
))
{
CompletableFuture
.
runAsync
(()
->
{
try
{
kafkaProducer
.
send
(
KafkaTopicConstants
.
TRIAL_ONBOARDING_APPROVED
,
String
.
valueOf
(
result
.
getId
()).
getBytes
());
log
.
info
(
"试岗审批通过发送Kafka消息,trialId:{}"
,
result
.
getId
());
}
catch
(
Exception
e
)
{
log
.
error
(
"试岗审批通过发送Kafka消息异常,trialId:{}"
,
result
.
getId
(),
e
);
}
});
}
return
RpcResponse
.
success
(
result
);
}
catch
(
RpcServiceException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/recruitment/RecruitmentDemandService.java
View file @
b970bda
...
...
@@ -871,7 +871,7 @@ public class RecruitmentDemandService {
recruitmentResumeService
.
processResumes
(
dto
,
processResult
);
recruitmentOnboardingPlanService
.
processPlans
(
dto
);
recruitmentTrialOnboardingService
.
processTrials
(
dto
);
recruitmentTrialOnboardingService
.
processTrials
(
dto
,
processResult
);
RecruitmentDemandOperationLog
log
=
new
RecruitmentDemandOperationLog
();
log
.
setDemandId
(
dto
.
getId
());
...
...
@@ -2636,4 +2636,435 @@ public class RecruitmentDemandService {
log
.
error
(
"试岗审批通知推送异常,demandId:{}"
,
dto
.
getDemandId
(),
e
);
}
}
/**
* 试岗处理结果通知区域运营
*
* @param trialOnboardingId 试岗记录ID
*/
@Async
public
void
sendTrialProcessedRegionOperationMessage
(
Integer
trialOnboardingId
)
{
try
{
RecruitmentTrialOnboarding
trial
=
recruitmentTrialOnboardingMapper
.
selectByPrimaryKey
(
trialOnboardingId
);
if
(
trial
==
null
)
{
log
.
error
(
"试岗处理通知 - 试岗记录不存在,id:{}"
,
trialOnboardingId
);
return
;
}
// 获取招聘需求,取招聘负责人(HRBP)姓名
RecruitmentDemand
demand
=
recruitmentDemandMapper
.
selectByPrimaryKey
(
trial
.
getDemandId
());
if
(
demand
==
null
)
{
log
.
error
(
"试岗处理通知 - 招聘需求不存在,demandId:{}"
,
trial
.
getDemandId
());
return
;
}
// 业务类型过滤
if
(!
RecruitmentDemandBusinessTypeEnum
.
needsRegionOperationMessage
(
demand
.
getBusinessType
()))
{
log
.
info
(
"试岗处理通知 - 业务类型不在推送范围内,demandId:{}, businessType:{}"
,
demand
.
getId
(),
demand
.
getBusinessType
());
return
;
}
String
hrbpName
=
demand
.
getRecruiterName
();
// 解析业务场景名称
String
sceneNameStr
=
""
;
if
(
StringUtils
.
isNotBlank
(
trial
.
getBizSceneInfo
()))
{
JSONArray
sceneArray
=
JSON
.
parseArray
(
trial
.
getBizSceneInfo
());
List
<
String
>
sceneNames
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
sceneArray
.
size
();
i
++)
{
JSONObject
obj
=
sceneArray
.
getJSONObject
(
i
);
if
(
obj
!=
null
&&
StringUtils
.
isNotBlank
(
obj
.
getString
(
"sceneName"
)))
{
sceneNames
.
add
(
obj
.
getString
(
"sceneName"
));
}
}
sceneNameStr
=
String
.
join
(
"、"
,
sceneNames
);
}
// 构建通知内容
boolean
isPassed
=
Objects
.
equals
(
trial
.
getProcessResult
(),
1
);
String
resultText
=
isPassed
?
"通过"
:
"不通过"
;
String
title
=
"试岗结果通知"
;
// 跳转链接与招聘需求一致
String
url
=
env
.
getProperty
(
"recruitment.new.resume.qw.message.url"
,
String
.
class
);
if
(
StringUtils
.
isNotEmpty
(
url
))
{
url
=
url
.
replace
(
"{ID}"
,
demand
.
getId
().
toString
());
}
// 区域运营消息模板有查看详情链接
String
description
=
String
.
format
(
"你好,%s已对你发起的%s在%s%s,试岗结果为:%s\n👉点击此处可查看详情: %s"
,
hrbpName
,
trial
.
getPersonName
(),
trial
.
getStoreName
(),
sceneNameStr
,
resultText
,
url
);
String
logDesc
=
"试岗处理通知区域运营"
;
// 复用通用推送方法(带URL)
sendRegionOperationQWMessage
(
trial
.
getDemandId
(),
title
,
description
,
logDesc
,
url
);
}
catch
(
Exception
e
)
{
log
.
error
(
"试岗处理通知区域运营异常,trialId:{}"
,
trialOnboardingId
,
e
);
}
}
/**
* 试岗处理结果通知线上运营
*
* @param trialOnboardingId 试岗记录ID
*/
@Async
public
void
sendTrialProcessedOnlineOperationMessage
(
Integer
trialOnboardingId
)
{
try
{
RecruitmentTrialOnboarding
trial
=
recruitmentTrialOnboardingMapper
.
selectByPrimaryKey
(
trialOnboardingId
);
if
(
trial
==
null
)
{
log
.
error
(
"试岗处理通知线上运营 - 试岗记录不存在,id:{}"
,
trialOnboardingId
);
return
;
}
// 获取招聘需求
RecruitmentDemand
demand
=
recruitmentDemandMapper
.
selectByPrimaryKey
(
trial
.
getDemandId
());
if
(
demand
==
null
)
{
log
.
error
(
"试岗处理通知线上运营 - 招聘需求不存在,demandId:{}"
,
trial
.
getDemandId
());
return
;
}
// 业务类型过滤 TODO 通知线上运营是否也有业务类型过滤
if
(!
RecruitmentDemandBusinessTypeEnum
.
needsRegionOperationMessage
(
demand
.
getBusinessType
()))
{
log
.
info
(
"试岗处理通知线上运营 - 业务类型不在推送范围内,demandId:{}, businessType:{}"
,
demand
.
getId
(),
demand
.
getBusinessType
());
return
;
}
// 从 bizSceneInfo 提取 sceneCode 列表
if
(
StringUtils
.
isBlank
(
trial
.
getBizSceneInfo
()))
{
log
.
info
(
"试岗处理通知线上运营 - 业务场景信息为空,trialId:{}"
,
trialOnboardingId
);
return
;
}
JSONArray
sceneArray
=
JSON
.
parseArray
(
trial
.
getBizSceneInfo
());
List
<
String
>
sceneCodes
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
sceneArray
.
size
();
i
++)
{
JSONObject
obj
=
sceneArray
.
getJSONObject
(
i
);
if
(
obj
!=
null
&&
StringUtils
.
isNotBlank
(
obj
.
getString
(
"sceneCode"
)))
{
sceneCodes
.
add
(
obj
.
getString
(
"sceneCode"
));
}
}
if
(
CollectionUtils
.
isEmpty
(
sceneCodes
))
{
log
.
info
(
"试岗处理通知线上运营 - sceneCode列表为空,trialId:{}"
,
trialOnboardingId
);
return
;
}
// 查询场景详细信息,获取 sceneType
SceneQueryFilterDTO
sceneQuery
=
new
SceneQueryFilterDTO
();
sceneQuery
.
setBaseSceneCodeList
(
sceneCodes
);
RpcResponse
<
List
<
SceneDTO
>>
sceneResp
=
sceneRemote
.
getScenesByParams
(
sceneQuery
);
if
(!
sceneResp
.
hasResult
()
||
CollectionUtils
.
isEmpty
(
sceneResp
.
getResult
()))
{
log
.
info
(
"试岗处理通知线上运营 - 场景信息不存在,sceneCodes:{}"
,
sceneCodes
);
return
;
}
// 过滤 sceneType=0或1,映射 DirectorType
List
<
Byte
>
directorTypes
=
new
ArrayList
<>();
String
sceneNameStr
=
""
;
for
(
SceneDTO
scene
:
sceneResp
.
getResult
())
{
Integer
sceneType
=
scene
.
getSceneType
();
if
(
sceneType
==
null
)
{
continue
;
}
if
(
sceneType
==
1
)
{
directorTypes
.
add
(
DirectorTypeEnum
.
DF_DIRECTOR
.
getValue
());
}
else
if
(
sceneType
==
0
)
{
directorTypes
.
add
(
DirectorTypeEnum
.
DF_DIRECTOR_2_1
.
getValue
());
}
}
if
(
CollectionUtils
.
isEmpty
(
directorTypes
))
{
log
.
info
(
"试岗处理通知线上运营 - 无可推送的场景类型,trialId:{}"
,
trialOnboardingId
);
return
;
}
directorTypes
=
directorTypes
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
// 场景名称拼接
sceneNameStr
=
sceneResp
.
getResult
().
stream
()
.
filter
(
s
->
s
.
getSceneType
()
!=
null
&&
(
s
.
getSceneType
()
==
0
||
s
.
getSceneType
()
==
1
))
.
map
(
SceneDTO:
:
getName
)
.
filter
(
StringUtils:
:
isNotBlank
)
.
distinct
()
.
collect
(
Collectors
.
joining
(
"、"
));
// 查询门店线上运营负责人
ShopMerchantDirectorConfigDTO
configQuery
=
ShopMerchantDirectorConfigDTO
.
builder
()
.
directorTypes
(
directorTypes
)
.
merchantId
(
Integer
.
valueOf
(
trial
.
getStoreNo
()))
.
build
();
RpcResponse
<
List
<
ShopMerchantDirectorConfigDTO
>>
configResp
=
shopMerchantDirectorConfigRemote
.
list
(
configQuery
);
if
(!
configResp
.
hasResult
()
||
CollectionUtils
.
isEmpty
(
configResp
.
getResult
()))
{
log
.
info
(
"试岗处理通知线上运营 - 无匹配的线上运营负责人,merchantId:{}, directorTypes:{}"
,
trial
.
getStoreNo
(),
directorTypes
);
return
;
}
// 根据手机号去重线上运营列表
List
<
ShopMerchantDirectorConfigDTO
>
staffList
=
configResp
.
getResult
().
stream
()
.
filter
(
c
->
StringUtils
.
isNotBlank
(
c
.
getDirectorPhone
()))
.
collect
(
Collectors
.
collectingAndThen
(
Collectors
.
toMap
(
ShopMerchantDirectorConfigDTO:
:
getDirectorPhone
,
c
->
c
,
(
c1
,
c2
)
->
c1
),
m
->
new
ArrayList
<>(
m
.
values
())));
if
(
CollectionUtils
.
isEmpty
(
staffList
))
{
log
.
info
(
"试岗处理通知线上运营 - 去重后线上运营列表为空"
);
return
;
}
// 构建通知内容
boolean
isPassed
=
Objects
.
equals
(
trial
.
getProcessResult
(),
1
);
String
resultText
=
isPassed
?
"通过"
:
"不通过"
;
String
hrbpName
=
demand
.
getRecruiterName
();
String
regionOperationName
=
demand
.
getRegionOperationName
();
String
title
=
"试岗结果通知"
;
// 线上运营消息模板无查看详情链接
String
content
=
String
.
format
(
"%s\n你好,%s已对%s发起的%s在%s%s,试岗结果为:%s"
,
title
,
hrbpName
,
regionOperationName
,
trial
.
getPersonName
(),
trial
.
getStoreName
(),
sceneNameStr
,
resultText
);
String
logDesc
=
"试岗处理通知线上运营"
;
// 批量推送企微文本消息(多人用'|'分隔)
Map
<
String
,
String
>
sendUserIds
=
getSendUserIds
();
if
(
sendUserIds
==
null
||
sendUserIds
.
isEmpty
())
{
log
.
error
(
"试岗处理通知线上运营 - 获取企微用户映射为空"
);
return
;
}
List
<
String
>
qwUserIds
=
new
ArrayList
<>();
for
(
ShopMerchantDirectorConfigDTO
staff
:
staffList
)
{
String
qwUserId
=
sendUserIds
.
get
(
staff
.
getDirectorPhone
());
if
(
StringUtils
.
isBlank
(
qwUserId
))
{
log
.
warn
(
"试岗处理通知线上运营 - 手机号未找到企微用户,phone:{}, name:{}"
,
staff
.
getDirectorPhone
(),
staff
.
getDirectorName
());
continue
;
}
qwUserIds
.
add
(
qwUserId
);
}
if
(
CollectionUtils
.
isEmpty
(
qwUserIds
))
{
log
.
warn
(
"试岗处理通知线上运营 - 无可推送的企微用户"
);
return
;
}
String
toUser
=
String
.
join
(
"|"
,
qwUserIds
);
boolean
success
=
sendDJCloudWechatTextMessage
(
toUser
,
content
,
logDesc
);
if
(
success
)
{
log
.
info
(
"{} - 推送成功,qwUserIds:{}"
,
logDesc
,
toUser
);
}
else
{
log
.
error
(
"{} - 推送失败,qwUserIds:{}"
,
logDesc
,
toUser
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"试岗处理通知线上运营异常,trialId:{}"
,
trialOnboardingId
,
e
);
}
}
/**
* 新增试岗计划通知区域运营
*
* @param trialOnboardingId 试岗记录ID
*/
@Async
public
void
sendTrialCreatedRegionOperationMessage
(
Integer
trialOnboardingId
)
{
try
{
RecruitmentTrialOnboarding
trial
=
recruitmentTrialOnboardingMapper
.
selectByPrimaryKey
(
trialOnboardingId
);
if
(
trial
==
null
)
{
log
.
error
(
"新增试岗通知 - 试岗记录不存在,id:{}"
,
trialOnboardingId
);
return
;
}
// 获取招聘需求,取招聘负责人(HRBP)姓名
RecruitmentDemand
demand
=
recruitmentDemandMapper
.
selectByPrimaryKey
(
trial
.
getDemandId
());
if
(
demand
==
null
)
{
log
.
error
(
"新增试岗通知 - 招聘需求不存在,demandId:{}"
,
trial
.
getDemandId
());
return
;
}
// 业务类型过滤
if
(!
RecruitmentDemandBusinessTypeEnum
.
needsRegionOperationMessage
(
demand
.
getBusinessType
()))
{
log
.
info
(
"新增试岗通知 - 业务类型不在推送范围内,demandId:{}, businessType:{}"
,
demand
.
getId
(),
demand
.
getBusinessType
());
return
;
}
String
hrbpName
=
demand
.
getRecruiterName
();
// 解析业务场景名称
String
sceneNameStr
=
""
;
if
(
StringUtils
.
isNotBlank
(
trial
.
getBizSceneInfo
()))
{
JSONArray
sceneArray
=
JSON
.
parseArray
(
trial
.
getBizSceneInfo
());
List
<
String
>
sceneNames
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
sceneArray
.
size
();
i
++)
{
JSONObject
obj
=
sceneArray
.
getJSONObject
(
i
);
if
(
obj
!=
null
&&
StringUtils
.
isNotBlank
(
obj
.
getString
(
"sceneName"
)))
{
sceneNames
.
add
(
obj
.
getString
(
"sceneName"
));
}
}
sceneNameStr
=
String
.
join
(
"、"
,
sceneNames
);
}
// 构建通知内容
String
title
=
"新建试岗计划通知"
;
// 跳转链接与招聘需求一致
String
url
=
env
.
getProperty
(
"recruitment.new.resume.qw.message.url"
,
String
.
class
);
if
(
StringUtils
.
isNotEmpty
(
url
))
{
url
=
url
.
replace
(
"{ID}"
,
demand
.
getId
().
toString
());
}
// 区域运营消息模板有查看详情链接
String
description
=
String
.
format
(
"你好,%s已新建%s在%s%s试岗计划。\n👉点击此处可查看详情: %s"
,
hrbpName
,
trial
.
getPersonName
(),
trial
.
getStoreName
(),
sceneNameStr
,
url
);
String
logDesc
=
"新增试岗通知区域运营"
;
// 复用通用推送方法(带URL)
sendRegionOperationQWMessage
(
trial
.
getDemandId
(),
title
,
description
,
logDesc
,
url
);
}
catch
(
Exception
e
)
{
log
.
error
(
"新增试岗通知区域运营异常,trialId:{}"
,
trialOnboardingId
,
e
);
}
}
/**
* 新增试岗计划通知线上运营
*
* @param trialOnboardingId 试岗记录ID
*/
@Async
public
void
sendTrialCreatedOnlineOperationMessage
(
Integer
trialOnboardingId
)
{
try
{
RecruitmentTrialOnboarding
trial
=
recruitmentTrialOnboardingMapper
.
selectByPrimaryKey
(
trialOnboardingId
);
if
(
trial
==
null
)
{
log
.
error
(
"新增试岗通知线上运营 - 试岗记录不存在,id:{}"
,
trialOnboardingId
);
return
;
}
// 获取招聘需求
RecruitmentDemand
demand
=
recruitmentDemandMapper
.
selectByPrimaryKey
(
trial
.
getDemandId
());
if
(
demand
==
null
)
{
log
.
error
(
"新增试岗通知线上运营 - 招聘需求不存在,demandId:{}"
,
trial
.
getDemandId
());
return
;
}
// 业务类型过滤
if
(!
RecruitmentDemandBusinessTypeEnum
.
needsRegionOperationMessage
(
demand
.
getBusinessType
()))
{
log
.
info
(
"新增试岗通知线上运营 - 业务类型不在推送范围内,demandId:{}, businessType:{}"
,
demand
.
getId
(),
demand
.
getBusinessType
());
return
;
}
// 从 bizSceneInfo 提取 sceneCode 列表
if
(
StringUtils
.
isBlank
(
trial
.
getBizSceneInfo
()))
{
log
.
info
(
"新增试岗通知线上运营 - 业务场景信息为空,trialId:{}"
,
trialOnboardingId
);
return
;
}
JSONArray
sceneArray
=
JSON
.
parseArray
(
trial
.
getBizSceneInfo
());
List
<
String
>
sceneCodes
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
sceneArray
.
size
();
i
++)
{
JSONObject
obj
=
sceneArray
.
getJSONObject
(
i
);
if
(
obj
!=
null
&&
StringUtils
.
isNotBlank
(
obj
.
getString
(
"sceneCode"
)))
{
sceneCodes
.
add
(
obj
.
getString
(
"sceneCode"
));
}
}
if
(
CollectionUtils
.
isEmpty
(
sceneCodes
))
{
log
.
info
(
"新增试岗通知线上运营 - sceneCode列表为空,trialId:{}"
,
trialOnboardingId
);
return
;
}
// 查询场景详细信息,获取 sceneType
SceneQueryFilterDTO
sceneQuery
=
new
SceneQueryFilterDTO
();
sceneQuery
.
setBaseSceneCodeList
(
sceneCodes
);
RpcResponse
<
List
<
SceneDTO
>>
sceneResp
=
sceneRemote
.
getScenesByParams
(
sceneQuery
);
if
(!
sceneResp
.
hasResult
()
||
CollectionUtils
.
isEmpty
(
sceneResp
.
getResult
()))
{
log
.
info
(
"新增试岗通知线上运营 - 场景信息不存在,sceneCodes:{}"
,
sceneCodes
);
return
;
}
// 过滤 sceneType=0或1,映射 DirectorType
List
<
Byte
>
directorTypes
=
new
ArrayList
<>();
String
sceneNameStr
=
""
;
for
(
SceneDTO
scene
:
sceneResp
.
getResult
())
{
Integer
sceneType
=
scene
.
getSceneType
();
if
(
sceneType
==
null
)
{
continue
;
}
if
(
sceneType
==
1
)
{
directorTypes
.
add
(
DirectorTypeEnum
.
DF_DIRECTOR
.
getValue
());
}
else
if
(
sceneType
==
0
)
{
directorTypes
.
add
(
DirectorTypeEnum
.
DF_DIRECTOR_2_1
.
getValue
());
}
}
if
(
CollectionUtils
.
isEmpty
(
directorTypes
))
{
log
.
info
(
"新增试岗通知线上运营 - 无可推送的场景类型,trialId:{}"
,
trialOnboardingId
);
return
;
}
directorTypes
=
directorTypes
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
// 场景名称拼接
sceneNameStr
=
sceneResp
.
getResult
().
stream
()
.
filter
(
s
->
s
.
getSceneType
()
!=
null
&&
(
s
.
getSceneType
()
==
0
||
s
.
getSceneType
()
==
1
))
.
map
(
SceneDTO:
:
getName
)
.
filter
(
StringUtils:
:
isNotBlank
)
.
distinct
()
.
collect
(
Collectors
.
joining
(
"、"
));
// 查询门店线上运营负责人
ShopMerchantDirectorConfigDTO
configQuery
=
ShopMerchantDirectorConfigDTO
.
builder
()
.
directorTypes
(
directorTypes
)
.
merchantId
(
Integer
.
valueOf
(
trial
.
getStoreNo
()))
.
build
();
RpcResponse
<
List
<
ShopMerchantDirectorConfigDTO
>>
configResp
=
shopMerchantDirectorConfigRemote
.
list
(
configQuery
);
if
(!
configResp
.
hasResult
()
||
CollectionUtils
.
isEmpty
(
configResp
.
getResult
()))
{
log
.
info
(
"新增试岗通知线上运营 - 无匹配的线上运营负责人,merchantId:{}, directorTypes:{}"
,
trial
.
getStoreNo
(),
directorTypes
);
return
;
}
// 根据手机号去重线上运营列表
List
<
ShopMerchantDirectorConfigDTO
>
staffList
=
configResp
.
getResult
().
stream
()
.
filter
(
c
->
StringUtils
.
isNotBlank
(
c
.
getDirectorPhone
()))
.
collect
(
Collectors
.
collectingAndThen
(
Collectors
.
toMap
(
ShopMerchantDirectorConfigDTO:
:
getDirectorPhone
,
c
->
c
,
(
c1
,
c2
)
->
c1
),
m
->
new
ArrayList
<>(
m
.
values
())));
if
(
CollectionUtils
.
isEmpty
(
staffList
))
{
log
.
info
(
"新增试岗通知线上运营 - 去重后线上运营列表为空"
);
return
;
}
// 构建通知内容
String
hrbpName
=
demand
.
getRecruiterName
();
String
title
=
"新建试岗计划通知"
;
// 线上运营消息模板无查看详情链接
String
content
=
String
.
format
(
"%s\n你好,%s已新建%s在%s%s试岗计划。"
,
title
,
hrbpName
,
trial
.
getPersonName
(),
trial
.
getStoreName
(),
sceneNameStr
);
String
logDesc
=
"新增试岗通知线上运营"
;
// 批量推送企微文本消息(多人用'|'分隔)
Map
<
String
,
String
>
sendUserIds
=
getSendUserIds
();
if
(
sendUserIds
==
null
||
sendUserIds
.
isEmpty
())
{
log
.
error
(
"新增试岗通知线上运营 - 获取企微用户映射为空"
);
return
;
}
List
<
String
>
qwUserIds
=
new
ArrayList
<>();
for
(
ShopMerchantDirectorConfigDTO
staff
:
staffList
)
{
String
qwUserId
=
sendUserIds
.
get
(
staff
.
getDirectorPhone
());
if
(
StringUtils
.
isBlank
(
qwUserId
))
{
log
.
warn
(
"新增试岗通知线上运营 - 手机号未找到企微用户,phone:{}, name:{}"
,
staff
.
getDirectorPhone
(),
staff
.
getDirectorName
());
continue
;
}
qwUserIds
.
add
(
qwUserId
);
}
if
(
CollectionUtils
.
isEmpty
(
qwUserIds
))
{
log
.
warn
(
"新增试岗通知线上运营 - 无可推送的企微用户"
);
return
;
}
String
toUser
=
String
.
join
(
"|"
,
qwUserIds
);
boolean
success
=
sendDJCloudWechatTextMessage
(
toUser
,
content
,
logDesc
);
if
(
success
)
{
log
.
info
(
"{} - 推送成功,qwUserIds:{}"
,
logDesc
,
toUser
);
}
else
{
log
.
error
(
"{} - 推送失败,qwUserIds:{}"
,
logDesc
,
toUser
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"新增试岗通知线上运营异常,trialId:{}"
,
trialOnboardingId
,
e
);
}
}
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/recruitment/RecruitmentTrialOnboardingService.java
View file @
b970bda
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
.
recruitment
;
import
cn.com.glsx.dj.smartcarlife.dto.NewMerchantSceneDTO
;
import
cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.AssignStaffMerchantV2DTO
;
import
cn.com.glsx.dj.smartcarlife.dto.scene.SceneDTO
;
import
cn.com.glsx.dj.smartcarlife.dto.scene.SceneQueryFilterDTO
;
import
cn.com.glsx.dj.smartcarlife.model.ServiceMerchant
;
import
cn.com.glsx.dj.smartcarlife.remote.SceneMerchantRefRemote
;
import
cn.com.glsx.dj.smartcarlife.remote.SceneRemote
;
import
cn.com.glsx.dj.smartcarlife.remote.StaffBaseInfoRemote
;
import
cn.com.glsx.dj.staff.dto.recruitment.RecruitmentDemandDetailDTO
;
import
cn.com.glsx.dj.staff.dto.recruitment.RecruitmentProcessResultDTO
;
import
cn.com.glsx.dj.staff.dto.recruitment.RecruitmentTrialOnboardingDTO
;
import
cn.com.glsx.dj.staff.enums.RpcErrorEnum
;
import
cn.com.glsx.dj.staff.mapper.RecruitmentTrialOnboardingMapper
;
import
cn.com.glsx.dj.staff.model.RecruitmentTrialOnboarding
;
import
cn.com.glsx.framework.core.beans.BaseModel
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.framework.core.util.RpcAssert
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
...
...
@@ -27,13 +41,23 @@ public class RecruitmentTrialOnboardingService {
@Autowired
private
RecruitmentTrialOnboardingMapper
recruitmentTrialOnboardingMapper
;
@Autowired
private
SceneMerchantRefRemote
sceneMerchantRefRemote
;
@Autowired
private
SceneRemote
sceneRemote
;
@Autowired
private
StaffBaseInfoRemote
staffBaseInfoRemote
;
/**
* 处理试岗人员List
*
* @param dto
* @param processResult 处理结果收集器,用于收集新创建的试岗记录ID
*/
@Transactional
public
void
processTrials
(
RecruitmentDemandDetailDTO
dto
)
{
public
void
processTrials
(
RecruitmentDemandDetailDTO
dto
,
RecruitmentProcessResultDTO
processResult
)
{
Integer
demandId
=
dto
.
getId
();
List
<
RecruitmentTrialOnboarding
>
trialsAll
=
dto
.
getTrialOnboardings
();
if
(
CollectionUtils
.
isEmpty
(
trialsAll
))
{
...
...
@@ -83,13 +107,21 @@ public class RecruitmentTrialOnboardingService {
recruitmentTrialOnboardingMapper
.
updateByExampleSelective
(
trialToDelete
,
trialExampleToDel
);
if
(
CollectionUtils
.
isNotEmpty
(
trialsAdd
))
{
List
<
Integer
>
newTrialIds
=
new
ArrayList
<>();
List
<
Integer
>
processedTrialIdsFromAdd
=
new
ArrayList
<>();
for
(
RecruitmentTrialOnboarding
trial
:
trialsAdd
)
{
trial
.
setDemandId
(
demandId
);
trial
.
setCreatedBy
(
dto
.
getUpdatedBy
());
trial
.
setCreatedDate
(
new
Date
());
trial
.
setUpdatedBy
(
dto
.
getUpdatedBy
());
trial
.
setUpdatedDate
(
new
Date
());
if
(
Objects
.
nonNull
(
trial
.
getProcessResult
()))
{
// 新增试岗记录默认审批通过
trial
.
setApprovalResult
(
1
);
trial
.
setApprovalRemark
(
"默认审批通过"
);
boolean
hasProcessResult
=
Objects
.
nonNull
(
trial
.
getProcessResult
());
if
(
hasProcessResult
)
{
trial
.
setProcessTime
(
new
Date
());
trial
.
setProcessorName
(
dto
.
getUpdatedBy
());
}
else
{
...
...
@@ -100,6 +132,23 @@ public class RecruitmentTrialOnboardingService {
}
recruitmentTrialOnboardingMapper
.
insertSelective
(
trial
);
newTrialIds
.
add
(
trial
.
getId
());
// 新增试岗并同时处理了,收集到processedTrialOnboardingIds用于推送企微通知(插入后才有ID)
if
(
hasProcessResult
)
{
processedTrialIdsFromAdd
.
add
(
trial
.
getId
());
}
}
if
(
processResult
!=
null
&&
CollectionUtils
.
isNotEmpty
(
newTrialIds
))
{
processResult
.
setNewTrialOnboardingIds
(
newTrialIds
);
}
// 新增试岗并同时处理了的,也收集到processedTrialOnboardingIds
if
(
processResult
!=
null
&&
CollectionUtils
.
isNotEmpty
(
processedTrialIdsFromAdd
))
{
List
<
Integer
>
existingProcessedIds
=
processResult
.
getProcessedTrialOnboardingIds
();
if
(
existingProcessedIds
==
null
)
{
existingProcessedIds
=
new
ArrayList
<>();
}
existingProcessedIds
.
addAll
(
processedTrialIdsFromAdd
);
processResult
.
setProcessedTrialOnboardingIds
(
existingProcessedIds
);
}
}
if
(
CollectionUtils
.
isNotEmpty
(
trialsEdit
))
{
...
...
@@ -115,6 +164,7 @@ public class RecruitmentTrialOnboardingService {
}
Map
<
Integer
,
RecruitmentTrialOnboarding
>
editOldListMap
=
editOldList
.
stream
().
collect
(
Collectors
.
toMap
(
RecruitmentTrialOnboarding:
:
getId
,
trial
->
trial
));
List
<
Integer
>
processedTrialIds
=
new
ArrayList
<>();
for
(
RecruitmentTrialOnboarding
trial
:
trialsEdit
)
{
RecruitmentTrialOnboarding
oldTrial
=
editOldListMap
.
get
(
trial
.
getId
());
if
(
Objects
.
isNull
(
oldTrial
))
{
...
...
@@ -139,6 +189,8 @@ public class RecruitmentTrialOnboardingService {
if
(
Objects
.
nonNull
(
trial
.
getProcessResult
()))
{
trial
.
setProcessTime
(
new
Date
());
trial
.
setProcessorName
(
dto
.
getUpdatedBy
());
// 收集被处理的试岗记录ID(只要processResult被赋值就收集)
processedTrialIds
.
add
(
trial
.
getId
());
}
else
{
trial
.
setProcessTime
(
null
);
trial
.
setProcessorName
(
null
);
...
...
@@ -148,11 +200,14 @@ public class RecruitmentTrialOnboardingService {
recruitmentTrialOnboardingMapper
.
updateByPrimaryKeySelective
(
trial
);
}
if
(
processResult
!=
null
&&
CollectionUtils
.
isNotEmpty
(
processedTrialIds
))
{
processResult
.
setProcessedTrialOnboardingIds
(
processedTrialIds
);
}
}
}
public
RecruitmentTrialOnboardingDTO
statRecruitmentTrialOnboarding
(
RecruitmentTrialOnboardingDTO
dto
)
{
try
{
try
{
return
recruitmentTrialOnboardingMapper
.
statRecruitmentTrialOnboarding
(
dto
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
...
...
@@ -161,7 +216,7 @@ public class RecruitmentTrialOnboardingService {
}
public
List
<
RecruitmentTrialOnboardingDTO
>
listRecruitmentTrialOnboarding
(
RecruitmentTrialOnboardingDTO
dto
)
{
try
{
try
{
return
recruitmentTrialOnboardingMapper
.
listRecruitmentTrialOnboarding
(
dto
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
...
...
@@ -169,16 +224,166 @@ public class RecruitmentTrialOnboardingService {
}
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
public
void
updateConfirmFlagToConfirmed
(
RecruitmentTrialOnboardingDTO
trialOnboardingDTO
)
{
RpcAssert
.
assertNotNull
(
trialOnboardingDTO
,
DefaultErrorEnum
.
DATA_NULL
,
"trialOnboardingDTO not be null"
);
RpcAssert
.
assertNotNull
(
trialOnboardingDTO
.
getDemandId
(),
DefaultErrorEnum
.
DATA_NULL
,
"trialOnboardingDTO.getDemandId() not be null"
);
RpcAssert
.
assertNotEmpty
(
trialOnboardingDTO
.
getUpdatedBy
(),
DefaultErrorEnum
.
DATA_NULL
,
"trialOnboardingDTO.getUpdatedBy() not be empty"
);
try
{
RpcAssert
.
assertNotNull
(
trialOnboardingDTO
,
DefaultErrorEnum
.
DATA_NULL
,
"trialOnboardingDTO not be null"
);
RpcAssert
.
assertNotNull
(
trialOnboardingDTO
.
getDemandId
(),
DefaultErrorEnum
.
DATA_NULL
,
"trialOnboardingDTO.getDemandId() not be null"
);
RpcAssert
.
assertNotEmpty
(
trialOnboardingDTO
.
getUpdatedBy
(),
DefaultErrorEnum
.
DATA_NULL
,
"trialOnboardingDTO.getUpdatedBy() not be empty"
);
try
{
recruitmentTrialOnboardingMapper
.
updateConfirmFlagToConfirmed
(
trialOnboardingDTO
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATABASE_ERROR
);
}
}
/**
* 试岗审批通过后开通驻店账号
* 1) 查试岗记录
* 2) 查门店场景,过滤匹配场景
* 3) 组装DTO,调initTrialStaff RPC
*
* @param trialId 试岗记录ID
*/
public
void
processTrialApproval
(
Integer
trialId
)
{
// 1. 查询试岗记录
RecruitmentTrialOnboarding
trial
=
recruitmentTrialOnboardingMapper
.
selectByPrimaryKey
(
trialId
);
if
(
trial
==
null
)
{
log
.
warn
(
"试岗记录不存在,trialId:{}"
,
trialId
);
return
;
}
if
(
trial
.
getApprovalResult
()
==
null
||
!
Objects
.
equals
(
trial
.
getApprovalResult
(),
1
))
{
log
.
info
(
"试岗记录未通过审批或已处理,trialId:{},approvalResult:{}"
,
trialId
,
trial
.
getApprovalResult
());
return
;
}
if
(
StringUtils
.
isBlank
(
trial
.
getBizSceneInfo
()))
{
log
.
warn
(
"试岗记录业务场景信息为空,trialId:{}"
,
trialId
);
return
;
}
if
(
StringUtils
.
isBlank
(
trial
.
getStoreNo
()))
{
log
.
warn
(
"试岗记录门店商户号为空,trialId:{}"
,
trialId
);
return
;
}
// 2. 解析bizSceneInfo,获取试岗分配的场景编码列表
JSONArray
sceneArray
=
JSON
.
parseArray
(
trial
.
getBizSceneInfo
());
Set
<
String
>
trialSceneCodes
=
new
HashSet
<>();
for
(
int
i
=
0
;
i
<
sceneArray
.
size
();
i
++)
{
JSONObject
obj
=
sceneArray
.
getJSONObject
(
i
);
if
(
obj
!=
null
&&
StringUtils
.
isNotBlank
(
obj
.
getString
(
"sceneCode"
)))
{
trialSceneCodes
.
add
(
obj
.
getString
(
"sceneCode"
));
}
}
if
(
trialSceneCodes
.
isEmpty
())
{
log
.
warn
(
"试岗记录业务场景编码为空,trialId:{}"
,
trialId
);
return
;
}
// 3. 根据门店查询已上架的场景及对应的园区店
Integer
merchantId
=
Integer
.
parseInt
(
trial
.
getStoreNo
());
RpcResponse
<
List
<
NewMerchantSceneDTO
>>
sceneResp
=
sceneMerchantRefRemote
.
findAllSceneByMerchantId
(
merchantId
);
if
(!
sceneResp
.
hasResult
()
||
CollectionUtils
.
isEmpty
(
sceneResp
.
getResult
()))
{
log
.
warn
(
"门店无可上架场景,merchantId:{}, trialId:{}"
,
merchantId
,
trialId
);
return
;
}
// 4. 过滤:只保留试岗记录中分配的场景
List
<
NewMerchantSceneDTO
>
matchedScenes
=
sceneResp
.
getResult
().
stream
()
.
filter
(
s
->
s
.
getBaseSceneCode
()
!=
null
&&
trialSceneCodes
.
contains
(
s
.
getBaseSceneCode
()))
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
matchedScenes
))
{
log
.
warn
(
"过滤后无匹配场景,merchantId:{}, trialId:{}"
,
merchantId
,
trialId
);
return
;
}
// 5. 按园区店聚合:同一个园区店下的场景合并
Map
<
Integer
,
YqMerchantSceneGroup
>
yqGroupMap
=
new
LinkedHashMap
<>();
for
(
NewMerchantSceneDTO
scene
:
matchedScenes
)
{
if
(
CollectionUtils
.
isEmpty
(
scene
.
getServiceList
()))
{
continue
;
}
for
(
ServiceMerchant
yq
:
scene
.
getServiceList
())
{
if
(
yq
==
null
||
yq
.
getMerchantId
()
==
null
)
{
continue
;
}
YqMerchantSceneGroup
group
=
yqGroupMap
.
computeIfAbsent
(
yq
.
getMerchantId
(),
k
->
new
YqMerchantSceneGroup
());
group
.
yqMerchantName
=
yq
.
getMerchantName
();
group
.
sceneCodes
.
add
(
scene
.
getBaseSceneCode
());
}
}
if
(
yqGroupMap
.
isEmpty
())
{
log
.
warn
(
"过滤后无匹配园区店,merchantId:{}, trialId:{}"
,
merchantId
,
trialId
);
return
;
}
// 6. 查场景明细,获取baseSceneCode→sceneType映射
SceneQueryFilterDTO
sceneQuery
=
new
SceneQueryFilterDTO
();
sceneQuery
.
setBaseSceneCodeList
(
new
ArrayList
<>(
trialSceneCodes
));
RpcResponse
<
List
<
SceneDTO
>>
sceneDetailResp
=
sceneRemote
.
getScenesByParams
(
sceneQuery
);
Map
<
String
,
Integer
>
sceneTypeMap
=
new
HashMap
<>();
if
(
sceneDetailResp
.
hasResult
()
&&
CollectionUtils
.
isNotEmpty
(
sceneDetailResp
.
getResult
()))
{
for
(
SceneDTO
s
:
sceneDetailResp
.
getResult
())
{
if
(
s
.
getBaseSceneCode
()
!=
null
&&
s
.
getSceneType
()
!=
null
)
{
sceneTypeMap
.
put
(
s
.
getBaseSceneCode
(),
s
.
getSceneType
());
}
}
}
// 7. 驻店类型映射: residentType=1→门店常驻(1), residentType=2→临时调动支援(2)
byte
stationType
;
if
(
"2"
.
equals
(
trial
.
getResidentType
()))
{
stationType
=
(
byte
)
2
;
}
else
{
stationType
=
(
byte
)
1
;
}
// 8. 组装 AssignStaffMerchantV2DTO
AssignStaffMerchantV2DTO
dto
=
new
AssignStaffMerchantV2DTO
();
dto
.
setStaffPhone
(
trial
.
getPhoneNumber
());
dto
.
setStaffName
(
trial
.
getPersonName
());
dto
.
setOperatorBy
(
trial
.
getUpdatedBy
());
dto
.
setEditFlag
(
false
);
List
<
AssignStaffMerchantV2DTO
.
ShopItem
>
shopItemList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
Integer
,
YqMerchantSceneGroup
>
entry
:
yqGroupMap
.
entrySet
())
{
AssignStaffMerchantV2DTO
.
ShopItem
shopItem
=
new
AssignStaffMerchantV2DTO
.
ShopItem
();
shopItem
.
setYqMerchantId
(
entry
.
getKey
());
shopItem
.
setYqMerchantName
(
entry
.
getValue
().
yqMerchantName
);
AssignStaffMerchantV2DTO
.
FourSShopItem
fourSShopItem
=
new
AssignStaffMerchantV2DTO
.
FourSShopItem
();
fourSShopItem
.
setMerchantId
(
merchantId
);
fourSShopItem
.
setMerchantName
(
trial
.
getStoreName
());
fourSShopItem
.
setStationType
(
stationType
);
List
<
AssignStaffMerchantV2DTO
.
SceneItem
>
sceneItemList
=
entry
.
getValue
().
sceneCodes
.
stream
()
.
map
(
code
->
{
AssignStaffMerchantV2DTO
.
SceneItem
sceneItem
=
new
AssignStaffMerchantV2DTO
.
SceneItem
();
sceneItem
.
setBaseSceneCode
(
code
);
sceneItem
.
setSceneType
(
sceneTypeMap
.
get
(
code
).
byteValue
());
return
sceneItem
;
}).
collect
(
Collectors
.
toList
());
fourSShopItem
.
setSceneList
(
sceneItemList
);
shopItem
.
setFourSShopList
(
Collections
.
singletonList
(
fourSShopItem
));
shopItemList
.
add
(
shopItem
);
}
dto
.
setShopItemList
(
shopItemList
);
// 9. 调用RPC开通驻店账号(幂等逻辑在内)
RpcResponse
<
String
>
response
=
staffBaseInfoRemote
.
initTrialStaff
(
dto
);
if
(
response
.
isSuccess
())
{
log
.
info
(
"试岗审批通过开通驻店账号成功,trialId:{},phone:{}"
,
trialId
,
trial
.
getPhoneNumber
());
}
else
{
log
.
error
(
"试岗审批通过开通驻店账号失败,trialId:{},phone:{},msg:{}"
,
trialId
,
trial
.
getPhoneNumber
(),
response
.
getMessage
());
}
}
/**
* 园区店场景分组
*/
private
static
class
YqMerchantSceneGroup
{
private
String
yqMerchantName
;
private
final
List
<
String
>
sceneCodes
=
new
ArrayList
<>();
}
}
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