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 5ed5079d
authored
Jan 26, 2026
by
林冲
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/v5.6.0' into v5.6.0
2 parents
74ee3da1
a5692043
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
16 deletions
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/job/AttendanceDataCleansingJob.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/perfSalary/AttendanceDataCleansingService.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/job/AttendanceDataCleansingJob.java
View file @
5ed5079
...
@@ -9,7 +9,7 @@ import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
...
@@ -9,7 +9,7 @@ import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
@Slf4j
@Slf4j
@ElasticJobConf
(
name
=
"AttendanceDataCleansing"
,
cron
=
"0 0 6 1 * ? "
,
description
=
"考勤数据清洗"
,
overwrite
=
false
)
@ElasticJobConf
(
name
=
"AttendanceDataCleansing"
,
cron
=
"0 0 6 1 * ? "
,
description
=
"考勤数据清洗
-可配参数格式(yyyy-MM-dd)
"
,
overwrite
=
false
)
public
class
AttendanceDataCleansingJob
implements
SimpleJob
{
public
class
AttendanceDataCleansingJob
implements
SimpleJob
{
@Resource
@Resource
...
@@ -20,7 +20,7 @@ public class AttendanceDataCleansingJob implements SimpleJob {
...
@@ -20,7 +20,7 @@ public class AttendanceDataCleansingJob implements SimpleJob {
public
void
execute
(
ShardingContext
shardingContext
)
{
public
void
execute
(
ShardingContext
shardingContext
)
{
log
.
info
(
"----------------考勤数据清洗开始-----------------"
);
log
.
info
(
"----------------考勤数据清洗开始-----------------"
);
try
{
try
{
attendanceDataCleansingService
.
attendanceDataCleansing
();
attendanceDataCleansingService
.
attendanceDataCleansing
(
shardingContext
.
getJobParameter
()
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
}
}
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/perfSalary/AttendanceDataCleansingService.java
View file @
5ed5079
...
@@ -107,7 +107,7 @@ public class AttendanceDataCleansingService {
...
@@ -107,7 +107,7 @@ public class AttendanceDataCleansingService {
* 5. 优化内存管理,避免内存溢出
* 5. 优化内存管理,避免内存溢出
* 6. 使用数据库唯一索引实现幂等性
* 6. 使用数据库唯一索引实现幂等性
*/
*/
public
void
attendanceDataCleansing
()
{
public
void
attendanceDataCleansing
(
String
statDate
)
{
long
startTime
=
System
.
currentTimeMillis
();
long
startTime
=
System
.
currentTimeMillis
();
try
{
try
{
// 1. 初始化考勤打卡门店清单
// 1. 初始化考勤打卡门店清单
...
@@ -119,15 +119,16 @@ public class AttendanceDataCleansingService {
...
@@ -119,15 +119,16 @@ public class AttendanceDataCleansingService {
// 2. 获取上月在职或当月离职的员工数据
// 2. 获取上月在职或当月离职的员工数据
Example
staffBeisenBaseExample
=
new
Example
(
StaffBeisenBaseInfo
.
class
);
Example
staffBeisenBaseExample
=
new
Example
(
StaffBeisenBaseInfo
.
class
);
// 上个月
// 上个月
DateTime
lastMonthDate
=
DateUtil
.
offsetMonth
(
new
Date
(),
-
1
);
DateTime
monthDate
=
StrUtil
.
isNotBlank
(
statDate
)
?
DateUtil
.
parse
(
statDate
)
:
DateUtil
.
offsetMonth
(
new
Date
(),
-
1
);
DateTime
lastMonthYMD
=
DateUtil
.
beginOfMonth
(
lastMonthDate
);
DateTime
MonthYMD
=
DateUtil
.
beginOfMonth
(
monthDate
);
String
lastMonth
=
DateUtil
.
format
(
lastMonthDate
,
DatePattern
.
NORM_MONTH_PATTERN
);
// yyyy-MM
log
.
info
(
"开始处理考勤数据,时间范围:{}"
,
lastMonth
);
String
month
=
DateUtil
.
format
(
monthDate
,
DatePattern
.
NORM_MONTH_PATTERN
);
log
.
info
(
"开始处理考勤数据,时间范围:{}"
,
month
);
String
staffBeisenBaseCondition1
=
"(DATE_FORMAT(last_work_date, '%Y-%m') = '{}' or last_work_date is null)"
;
String
staffBeisenBaseCondition1
=
"(DATE_FORMAT(last_work_date, '%Y-%m') = '{}' or last_work_date is null)"
;
staffBeisenBaseCondition1
=
StrUtil
.
format
(
staffBeisenBaseCondition1
,
lastM
onth
);
staffBeisenBaseCondition1
=
StrUtil
.
format
(
staffBeisenBaseCondition1
,
m
onth
);
String
staffBeisenBaseCondition2
=
"DATE_FORMAT(entry_date, '%Y-%m') <= '{}'"
;
String
staffBeisenBaseCondition2
=
"DATE_FORMAT(entry_date, '%Y-%m') <= '{}'"
;
staffBeisenBaseCondition2
=
StrUtil
.
format
(
staffBeisenBaseCondition2
,
lastM
onth
);
staffBeisenBaseCondition2
=
StrUtil
.
format
(
staffBeisenBaseCondition2
,
m
onth
);
staffBeisenBaseExample
.
createCriteria
().
andEqualTo
(
"deletedFlag"
,
'N'
)
staffBeisenBaseExample
.
createCriteria
().
andEqualTo
(
"deletedFlag"
,
'N'
)
.
andCondition
(
staffBeisenBaseCondition1
).
andCondition
(
staffBeisenBaseCondition2
);
.
andCondition
(
staffBeisenBaseCondition1
).
andCondition
(
staffBeisenBaseCondition2
);
List
<
StaffBeisenBaseInfo
>
staffBeiSenBaseInfos
=
staffBeisenBaseInfoMapper
.
selectByExample
(
staffBeisenBaseExample
);
List
<
StaffBeisenBaseInfo
>
staffBeiSenBaseInfos
=
staffBeisenBaseInfoMapper
.
selectByExample
(
staffBeisenBaseExample
);
...
@@ -150,12 +151,12 @@ public class AttendanceDataCleansingService {
...
@@ -150,12 +151,12 @@ public class AttendanceDataCleansingService {
for
(
List
<
StaffBeisenBaseInfo
>
batch
:
employeeBatches
)
{
for
(
List
<
StaffBeisenBaseInfo
>
batch
:
employeeBatches
)
{
CompletableFuture
<
Void
>
future
=
CompletableFuture
.
runAsync
(()
->
{
CompletableFuture
<
Void
>
future
=
CompletableFuture
.
runAsync
(()
->
{
try
{
try
{
processEmployeeBatch
(
batch
,
last
MonthYMD
);
processEmployeeBatch
(
batch
,
MonthYMD
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"处理员工批次失败"
,
e
);
log
.
error
(
"处理员工批次失败"
,
e
);
// 记录失败到失败列表
// 记录失败到失败列表
batch
.
forEach
(
employee
->
{
batch
.
forEach
(
employee
->
{
recordFailure
(
employee
.
getStaffPhone
(),
lastM
onth
,
e
.
getMessage
());
recordFailure
(
employee
.
getStaffPhone
(),
m
onth
,
e
.
getMessage
());
});
});
}
}
},
taskExecutor
);
},
taskExecutor
);
...
@@ -172,7 +173,7 @@ public class AttendanceDataCleansingService {
...
@@ -172,7 +173,7 @@ public class AttendanceDataCleansingService {
}
else
{
}
else
{
log
.
info
(
"使用串行处理考勤数据,批处理大小: {}"
,
EMPLOYEE_BATCH_SIZE
);
log
.
info
(
"使用串行处理考勤数据,批处理大小: {}"
,
EMPLOYEE_BATCH_SIZE
);
for
(
List
<
StaffBeisenBaseInfo
>
batch
:
employeeBatches
)
{
for
(
List
<
StaffBeisenBaseInfo
>
batch
:
employeeBatches
)
{
processEmployeeBatch
(
batch
,
last
MonthYMD
);
processEmployeeBatch
(
batch
,
MonthYMD
);
}
}
}
}
...
@@ -194,12 +195,12 @@ public class AttendanceDataCleansingService {
...
@@ -194,12 +195,12 @@ public class AttendanceDataCleansingService {
/**
/**
* 处理单个员工批次
* 处理单个员工批次
*/
*/
private
void
processEmployeeBatch
(
List
<
StaffBeisenBaseInfo
>
employeeList
,
DateTime
lastM
onthYMD
)
{
private
void
processEmployeeBatch
(
List
<
StaffBeisenBaseInfo
>
employeeList
,
DateTime
m
onthYMD
)
{
// 1. 根据手机号查询当月考勤数据
// 1. 根据手机号查询当月考勤数据
List
<
String
>
mobilePhones
=
employeeList
.
stream
().
map
(
StaffBeisenBaseInfo:
:
getStaffPhone
).
collect
(
Collectors
.
toList
());
List
<
String
>
mobilePhones
=
employeeList
.
stream
().
map
(
StaffBeisenBaseInfo:
:
getStaffPhone
).
collect
(
Collectors
.
toList
());
Example
staffQwClockInInfoExample
=
new
Example
(
StaffQwClockClean
.
class
);
Example
staffQwClockInInfoExample
=
new
Example
(
StaffQwClockClean
.
class
);
String
staffQwClockInInfoCondition
=
"(DATE_FORMAT(clock_in_date, '%Y-%m') = '{}')"
;
String
staffQwClockInInfoCondition
=
"(DATE_FORMAT(clock_in_date, '%Y-%m') = '{}')"
;
staffQwClockInInfoCondition
=
StrUtil
.
format
(
staffQwClockInInfoCondition
,
DateUtil
.
format
(
lastM
onthYMD
,
DatePattern
.
NORM_MONTH_PATTERN
));
staffQwClockInInfoCondition
=
StrUtil
.
format
(
staffQwClockInInfoCondition
,
DateUtil
.
format
(
m
onthYMD
,
DatePattern
.
NORM_MONTH_PATTERN
));
staffQwClockInInfoExample
.
createCriteria
().
andIn
(
"staffPhone"
,
mobilePhones
).
andCondition
(
staffQwClockInInfoCondition
).
andEqualTo
(
"deletedFlag"
,
'N'
);
staffQwClockInInfoExample
.
createCriteria
().
andIn
(
"staffPhone"
,
mobilePhones
).
andCondition
(
staffQwClockInInfoCondition
).
andEqualTo
(
"deletedFlag"
,
'N'
);
List
<
StaffQwClockClean
>
staffQwClockCleans
=
staffQwClockCleanMapper
.
selectByExample
(
staffQwClockInInfoExample
);
List
<
StaffQwClockClean
>
staffQwClockCleans
=
staffQwClockCleanMapper
.
selectByExample
(
staffQwClockInInfoExample
);
log
.
info
(
"获取到 {} 条员工考勤数据"
,
staffQwClockCleans
.
size
());
log
.
info
(
"获取到 {} 条员工考勤数据"
,
staffQwClockCleans
.
size
());
...
@@ -213,11 +214,11 @@ public class AttendanceDataCleansingService {
...
@@ -213,11 +214,11 @@ public class AttendanceDataCleansingService {
for
(
StaffBeisenBaseInfo
employee
:
employeeList
)
{
for
(
StaffBeisenBaseInfo
employee
:
employeeList
)
{
try
{
try
{
// 4. 生成考勤摘要记录
// 4. 生成考勤摘要记录
AttendanceSummary
attendanceSummary
=
createAttendanceSummary
(
employee
,
staffQwClockCleanMap
,
lastM
onthYMD
);
AttendanceSummary
attendanceSummary
=
createAttendanceSummary
(
employee
,
staffQwClockCleanMap
,
m
onthYMD
);
attendanceSummariesInsert
.
add
(
attendanceSummary
);
attendanceSummariesInsert
.
add
(
attendanceSummary
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"处理员工 {} ({}) 考勤数据失败"
,
employee
.
getStaffName
(),
employee
.
getStaffPhone
(),
e
);
log
.
error
(
"处理员工 {} ({}) 考勤数据失败"
,
employee
.
getStaffName
(),
employee
.
getStaffPhone
(),
e
);
recordFailure
(
employee
.
getStaffPhone
(),
DateUtil
.
format
(
lastM
onthYMD
,
DatePattern
.
NORM_MONTH_PATTERN
),
e
.
getMessage
());
recordFailure
(
employee
.
getStaffPhone
(),
DateUtil
.
format
(
m
onthYMD
,
DatePattern
.
NORM_MONTH_PATTERN
),
e
.
getMessage
());
}
}
}
}
...
...
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