Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangxinjiang
yifu-mvp
Commits
945047cb
Commit
945047cb
authored
Apr 03, 2026
by
hongguangwu
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/MVP1.7.21' into MVP1.7.21
parents
4418c5f6
92161033
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
4 deletions
+52
-4
ScheduleService.java
.../cloud/plus/v1/yifu/archives/service/ScheduleService.java
+2
-0
EmployeeRegistrationPreServiceImpl.java
...ives/service/impl/EmployeeRegistrationPreServiceImpl.java
+18
-2
ScheduleServiceImpl.java
...us/v1/yifu/archives/service/impl/ScheduleServiceImpl.java
+32
-2
No files found.
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/ScheduleService.java
View file @
945047cb
...
@@ -7,4 +7,6 @@ public interface ScheduleService {
...
@@ -7,4 +7,6 @@ public interface ScheduleService {
void
scheduleTask
(
EmployeeRegistrationPre
record
);
void
scheduleTask
(
EmployeeRegistrationPre
record
);
void
executeTask
(
String
aId
);
void
executeTask
(
String
aId
);
void
removeTask
(
String
aId
);
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/EmployeeRegistrationPreServiceImpl.java
View file @
945047cb
...
@@ -1039,6 +1039,16 @@ public class EmployeeRegistrationPreServiceImpl extends ServiceImpl<EmployeeRegi
...
@@ -1039,6 +1039,16 @@ public class EmployeeRegistrationPreServiceImpl extends ServiceImpl<EmployeeRegi
return
R
.
other
(
CommonConstants
.
TWO_INT
,
null
,
errorTemp
.
toString
());
return
R
.
other
(
CommonConstants
.
TWO_INT
,
null
,
errorTemp
.
toString
());
}
}
// 判断预计收集时间是否改变
boolean
expectedCollectionTimeChanged
=
false
;
if
(
employeeRegistrationPre
.
getExpectedCollectionTime
()
!=
null
&&
!
employeeRegistrationPre
.
getExpectedCollectionTime
().
equals
(
comparePre
.
getExpectedCollectionTime
()))
{
expectedCollectionTimeChanged
=
true
;
}
else
if
(
employeeRegistrationPre
.
getExpectedCollectionTime
()
==
null
&&
comparePre
.
getExpectedCollectionTime
()
!=
null
)
{
expectedCollectionTimeChanged
=
true
;
}
//操作记录中字典值的转化
//操作记录中字典值的转化
String
natureItemBefore
=
null
;
String
natureItemBefore
=
null
;
String
natureItemAfter
=
null
;
String
natureItemAfter
=
null
;
...
@@ -1114,6 +1124,12 @@ public class EmployeeRegistrationPreServiceImpl extends ServiceImpl<EmployeeRegi
...
@@ -1114,6 +1124,12 @@ public class EmployeeRegistrationPreServiceImpl extends ServiceImpl<EmployeeRegi
}
}
try
{
try
{
baseMapper
.
updateById
(
employeeRegistrationPre
);
baseMapper
.
updateById
(
employeeRegistrationPre
);
// 如果预计收集时间改变且新的时间不为空,添加新的定时任务
if
(
expectedCollectionTimeChanged
&&
employeeRegistrationPre
.
getExpectedCollectionTime
()
!=
null
)
{
log
.
info
(
"员工预入职 ID: {} 按新预计收集时间:{} 添加定时任务"
,
employeeRegistrationPre
.
getId
(),
employeeRegistrationPre
.
getExpectedCollectionTime
());
scheduleService
.
scheduleTask
(
employeeRegistrationPre
);
}
if
(
null
!=
natureItemBefore
)
{
if
(
null
!=
natureItemBefore
)
{
comparePre
.
setEmpNature
(
natureItemBefore
);
comparePre
.
setEmpNature
(
natureItemBefore
);
}
}
...
@@ -1132,10 +1148,10 @@ public class EmployeeRegistrationPreServiceImpl extends ServiceImpl<EmployeeRegi
...
@@ -1132,10 +1148,10 @@ public class EmployeeRegistrationPreServiceImpl extends ServiceImpl<EmployeeRegi
if
(
null
!=
contractXfAfter
)
{
if
(
null
!=
contractXfAfter
)
{
employeeRegistrationPre
.
setContractSubName
(
contractXfAfter
);
employeeRegistrationPre
.
setContractSubName
(
contractXfAfter
);
}
}
// 添加日志并修改商险list
// 添加日志并修改商险
list
tEmployeePreLogService
.
saveModifyAndUpdateInsurance
(
employeeRegistrationPre
.
getId
(),
comparePre
tEmployeePreLogService
.
saveModifyAndUpdateInsurance
(
employeeRegistrationPre
.
getId
(),
comparePre
,
employeeRegistrationPre
,
user
,
oldMap
,
contractOld
);
,
employeeRegistrationPre
,
user
,
oldMap
,
contractOld
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"生成入职待确认信息修改操作日志异常"
,
e
);
log
.
error
(
"生成入职待确认信息修改操作日志异常"
,
e
);
}
}
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/ScheduleServiceImpl.java
View file @
945047cb
...
@@ -8,6 +8,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.SendMessageUpdateVo;
...
@@ -8,6 +8,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.SendMessageUpdateVo;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.TaskScheduler
;
import
org.springframework.scheduling.TaskScheduler
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.support.TransactionTemplate
;
import
org.springframework.transaction.support.TransactionTemplate
;
...
@@ -17,6 +18,9 @@ import java.time.LocalDateTime;
...
@@ -17,6 +18,9 @@ import java.time.LocalDateTime;
import
java.time.ZoneId
;
import
java.time.ZoneId
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ScheduledFuture
;
@Service
@Service
public
class
ScheduleServiceImpl
implements
ScheduleService
{
public
class
ScheduleServiceImpl
implements
ScheduleService
{
...
@@ -24,10 +28,13 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -24,10 +28,13 @@ public class ScheduleServiceImpl implements ScheduleService {
@Autowired
@Autowired
private
EmployeeRegistrationPreService
registrationPreService
;
private
EmployeeRegistrationPreService
registrationPreService
;
@Autowired
@Autowired
private
TaskScheduler
taskScheduler
;
private
T
hreadPoolT
askScheduler
taskScheduler
;
@Autowired
@Autowired
private
TransactionTemplate
transactionTemplate
;
private
TransactionTemplate
transactionTemplate
;
// 用于存储任务 ID 和 ScheduledFuture 的映射关系
private
final
Map
<
String
,
ScheduledFuture
<?>>
scheduledTasks
=
new
ConcurrentHashMap
<>();
// 应用启动时初始化未处理的任务
// 应用启动时初始化未处理的任务
@PostConstruct
@PostConstruct
public
void
initSchedule
()
{
public
void
initSchedule
()
{
...
@@ -41,7 +48,14 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -41,7 +48,14 @@ public class ScheduleServiceImpl implements ScheduleService {
@Override
@Override
public
void
scheduleTask
(
EmployeeRegistrationPre
record
)
{
public
void
scheduleTask
(
EmployeeRegistrationPre
record
)
{
Instant
triggerTime
=
record
.
getExpectedCollectionTime
().
atZone
(
ZoneId
.
systemDefault
()).
toInstant
();
Instant
triggerTime
=
record
.
getExpectedCollectionTime
().
atZone
(
ZoneId
.
systemDefault
()).
toInstant
();
taskScheduler
.
schedule
(()
->
executeTask
(
record
.
getId
()),
triggerTime
);
String
taskId
=
record
.
getId
();
// 如果任务已存在,先取消旧任务
removeTask
(
taskId
);
// 创建新任务并保存引用
ScheduledFuture
<?>
future
=
taskScheduler
.
schedule
(()
->
executeTask
(
taskId
),
triggerTime
);
scheduledTasks
.
put
(
taskId
,
future
);
}
}
// 执行发送短信操作(事务内处理)
// 执行发送短信操作(事务内处理)
...
@@ -57,4 +71,20 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -57,4 +71,20 @@ public class ScheduleServiceImpl implements ScheduleService {
});
});
}
}
/**
* @Author fxj
* @Description 删除已经存在的任务
* @Date 14:17 2026/4/3
* @Param
* @return
**/
@Override
public
void
removeTask
(
String
aId
)
{
// 从调度器中取消任务
ScheduledFuture
<?>
future
=
scheduledTasks
.
remove
(
aId
);
if
(
future
!=
null
)
{
future
.
cancel
(
false
);
// false 表示不中断正在执行的任务
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment