Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
attendance-performance-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
attendance-performance-platform
Commits
432fd2bf
Commit
432fd2bf
authored
Jan 15, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加请假等异常考勤计算
parent
ab109295
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
19 deletions
+138
-19
attendance-performance-manager/src/main/java/com/mortals/xhx/common/utils/AddAttendThread.java
...in/java/com/mortals/xhx/common/utils/AddAttendThread.java
+29
-0
attendance-performance-manager/src/main/java/com/mortals/xhx/module/attendance/service/impl/AttendanceLeaveRecordServiceImpl.java
...ndance/service/impl/AttendanceLeaveRecordServiceImpl.java
+52
-3
attendance-performance-manager/src/main/java/com/mortals/xhx/module/attendance/service/work/FixWorkOtherAttendance.java
...odule/attendance/service/work/FixWorkOtherAttendance.java
+57
-16
No files found.
attendance-performance-manager/src/main/java/com/mortals/xhx/common/utils/AddAttendThread.java
View file @
432fd2bf
...
@@ -4,12 +4,19 @@ import cn.hutool.core.date.DateTime;
...
@@ -4,12 +4,19 @@ import cn.hutool.core.date.DateTime;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity
;
import
com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity
;
import
com.mortals.xhx.module.attendance.model.vo.AttendanceSummaryQuery
;
import
com.mortals.xhx.module.attendance.service.AttendanceRecordHikService
;
import
com.mortals.xhx.module.attendance.service.AttendanceRecordHikService
;
import
com.mortals.xhx.utils.SpringUtils
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StopWatch
;
import
org.springframework.util.StopWatch
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
RedisKey
.
KEY_ATTENDANCE_STAT_CACHE
;
@AllArgsConstructor
@AllArgsConstructor
@Slf4j
@Slf4j
...
@@ -22,6 +29,19 @@ public class AddAttendThread implements Runnable {
...
@@ -22,6 +29,19 @@ public class AddAttendThread implements Runnable {
private
Context
context
;
private
Context
context
;
private
ICacheService
cacheService
;
public
AddAttendThread
(
AttendanceRecordHikService
hikService
,
AttendanceRecordHikEntity
hikEntity
,
Context
context
)
{
this
.
hikService
=
hikService
;
this
.
hikEntity
=
hikEntity
;
this
.
context
=
context
;
this
.
cacheService
=
SpringUtils
.
getBean
(
ICacheService
.
class
);
}
public
AddAttendThread
()
{
this
.
cacheService
=
SpringUtils
.
getBean
(
ICacheService
.
class
);
}
@Override
@Override
public
void
run
()
{
public
void
run
()
{
...
@@ -43,6 +63,15 @@ public class AddAttendThread implements Runnable {
...
@@ -43,6 +63,15 @@ public class AddAttendThread implements Runnable {
stopWatch
.
stop
();
stopWatch
.
stop
();
log
.
info
(
"考勤计算日期:{} 完成,耗时:{}ms"
,
curDate
.
toDateStr
(),
stopWatch
.
getLastTaskTimeMillis
());
log
.
info
(
"考勤计算日期:{} 完成,耗时:{}ms"
,
curDate
.
toDateStr
(),
stopWatch
.
getLastTaskTimeMillis
());
}
}
//生成汇总信息
log
.
info
(
"生成考勤汇总消息开始。。。"
);
AttendanceSummaryQuery
query
=
new
AttendanceSummaryQuery
();
if
(!
ObjectUtils
.
isEmpty
(
hikEntity
.
getStaffId
())){
query
.
setStaffId
(
hikEntity
.
getStaffId
());
}
query
.
setSummaryTimeStart
(
attendStart
.
toDateStr
());
query
.
setSummaryTimeEnd
(
attendEnd
.
toDateStr
());
cacheService
.
lpush
(
KEY_ATTENDANCE_STAT_CACHE
,
query
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"考勤计算失败!"
,
e
);
log
.
error
(
"考勤计算失败!"
,
e
);
}
}
...
...
attendance-performance-manager/src/main/java/com/mortals/xhx/module/attendance/service/impl/AttendanceLeaveRecordServiceImpl.java
View file @
432fd2bf
package
com.mortals.xhx.module.attendance.service.impl
;
package
com.mortals.xhx.module.attendance.service.impl
;
import
cn.hutool.core.date.DateUtil
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.ThreadPool
;
import
com.mortals.framework.util.ThreadPool
;
import
com.mortals.xhx.common.code.AuditStatusEnum
;
import
com.mortals.xhx.common.utils.AddAttendThread
;
import
com.mortals.xhx.common.utils.AttendSummaryThread
;
import
com.mortals.xhx.common.utils.AttendSummaryThread
;
import
com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordQuery
;
import
com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordQuery
;
import
com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity
;
import
com.mortals.xhx.module.attendance.model.AttendanceRecordHikQuery
;
import
com.mortals.xhx.module.attendance.model.vo.AttendanceSummaryQuery
;
import
com.mortals.xhx.module.attendance.model.vo.AttendanceSummaryQuery
;
import
com.mortals.xhx.module.attendance.service.AttendanceRecordHikService
;
import
com.mortals.xhx.module.attendance.service.AttendanceStatService
;
import
com.mortals.xhx.module.attendance.service.AttendanceStatService
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -36,17 +42,22 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
...
@@ -36,17 +42,22 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
@Autowired
@Autowired
private
ICacheService
cacheService
;
private
ICacheService
cacheService
;
@Autowired
private
AttendanceRecordHikService
hikService
;
@Override
@Override
protected
void
updateAfter
(
AttendanceLeaveRecordEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
updateAfter
(
AttendanceLeaveRecordEntity
entity
,
Context
context
)
throws
AppException
{
super
.
updateAfter
(
entity
,
context
);
super
.
updateAfter
(
entity
,
context
);
//context!=null时表示页面调用的修改,自动执行处理任务调用时context为null,无需立即汇总
/*
//context!=null时表示页面调用的修改,自动执行处理任务调用时context为null,无需立即汇总
if
(
entity
.
getAuditResult
()
==
1
&&
context
!=
null
)
{
if (entity.getAuditResult() == 1 && context
!=
null) {
AttendanceSummaryQuery query = new AttendanceSummaryQuery();
AttendanceSummaryQuery query = new AttendanceSummaryQuery();
query.setStaffId(entity.getLeavePersonId());
query.setStaffId(entity.getLeavePersonId());
query.setSummaryTimeStart(DateUtils.getStrDate(entity.getStartTime()));
query.setSummaryTimeStart(DateUtils.getStrDate(entity.getStartTime()));
query.setSummaryTimeEnd(DateUtils.getStrDate(entity.getEndTime()));
query.setSummaryTimeEnd(DateUtils.getStrDate(entity.getEndTime()));
cacheService.lpush(KEY_ATTENDANCE_STAT_CACHE, query);
cacheService.lpush(KEY_ATTENDANCE_STAT_CACHE, query);
}
}*/
doUpdateRecordAndSummary
(
entity
,
context
);
}
}
@Override
@Override
...
@@ -67,6 +78,44 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
...
@@ -67,6 +78,44 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
}
}
return
leaveRecordEntity
;
return
leaveRecordEntity
;
}
}
}
@Override
protected
void
saveAfter
(
AttendanceLeaveRecordEntity
entity
,
Context
context
)
throws
AppException
{
super
.
saveAfter
(
entity
,
context
);
doUpdateRecordAndSummary
(
entity
,
context
);
}
/**
* 更新汇总信息
* @param entity
* @param context
*/
private
void
doUpdateRecordAndSummary
(
AttendanceLeaveRecordEntity
entity
,
Context
context
)
{
//请假是未来 不做处理
int
compare
=
DateUtil
.
compare
(
entity
.
getStartTime
(),
new
Date
());
if
(
compare
>
0
)
{
//请假未来 不做处理
return
;
}
//更新考勤记录与异常记录
if
(
AuditStatusEnum
.
通过
.
getValue
()
==
entity
.
getAuditResult
())
{
AttendanceRecordHikQuery
attendanceRecordHikQuery
=
new
AttendanceRecordHikQuery
();
attendanceRecordHikQuery
.
setStaffId
(
entity
.
getLeavePersonId
());
//判断请假的开始日期与结束日期
boolean
in
=
DateUtil
.
isIn
(
new
Date
(),
entity
.
getEndTime
(),
new
Date
());
if
(
in
)
{
//当前日期在请假期间,计算考勤结束时间为当前时间;
attendanceRecordHikQuery
.
setAttendanceDateStart
(
DateUtil
.
formatDate
(
entity
.
getStartTime
()));
attendanceRecordHikQuery
.
setAttendanceDateEnd
(
DateUtil
.
today
());
}
else
{
attendanceRecordHikQuery
.
setAttendanceDateStart
(
DateUtil
.
formatDate
(
entity
.
getStartTime
()));
attendanceRecordHikQuery
.
setAttendanceDateEnd
(
DateUtil
.
formatDate
(
entity
.
getEndTime
()));
}
AddAttendThread
addAttendThread
=
new
AddAttendThread
(
hikService
,
attendanceRecordHikQuery
,
context
);
ThreadPool
.
getInstance
().
execute
(
addAttendThread
);
}
}
}
}
}
\ No newline at end of file
attendance-performance-manager/src/main/java/com/mortals/xhx/module/attendance/service/work/FixWorkOtherAttendance.java
View file @
432fd2bf
...
@@ -45,6 +45,10 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
...
@@ -45,6 +45,10 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
private
HolidayService
holidayService
;
private
HolidayService
holidayService
;
private
AttendanceLeaveRecordService
attendanceLeaveRecordService
;
private
AttendanceRecordDetailService
attendanceRecordDetailService
;
public
FixWorkOtherAttendance
(
int
type
)
{
public
FixWorkOtherAttendance
(
int
type
)
{
super
(
type
);
super
(
type
);
...
@@ -56,6 +60,8 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
...
@@ -56,6 +60,8 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
this
.
attendanceClassDetailService
=
SpringUtils
.
getBean
(
AttendanceClassDetailService
.
class
);
this
.
attendanceClassDetailService
=
SpringUtils
.
getBean
(
AttendanceClassDetailService
.
class
);
this
.
errorService
=
SpringUtils
.
getBean
(
AttendanceRecordErrorService
.
class
);
this
.
errorService
=
SpringUtils
.
getBean
(
AttendanceRecordErrorService
.
class
);
this
.
holidayService
=
SpringUtils
.
getBean
(
HolidayService
.
class
);
this
.
holidayService
=
SpringUtils
.
getBean
(
HolidayService
.
class
);
this
.
attendanceLeaveRecordService
=
SpringUtils
.
getBean
(
AttendanceLeaveRecordService
.
class
);
this
.
attendanceRecordDetailService
=
SpringUtils
.
getBean
(
AttendanceRecordDetailService
.
class
);
}
}
@Override
@Override
...
@@ -78,9 +84,6 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
...
@@ -78,9 +84,6 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
}
}
//判断当前考勤日期为周几
//判断当前考勤日期为周几
String
week
=
super
.
getWeek
(
DateUtil
.
parseDate
(
commonData
.
getDateStr
()));
String
week
=
super
.
getWeek
(
DateUtil
.
parseDate
(
commonData
.
getDateStr
()));
//log.info("week:{}", week);
//通过考勤日期的星期拿到班次id.
//获取当前日期的详细班次
//获取当前日期的详细班次
Long
weekClassId
=
this
.
getWeekClassId
(
attendanceGroupFixedworkEntity
,
week
);
Long
weekClassId
=
this
.
getWeekClassId
(
attendanceGroupFixedworkEntity
,
week
);
//log.info("weekClassId:{}", weekClassId);
//log.info("weekClassId:{}", weekClassId);
...
@@ -100,6 +103,40 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
...
@@ -100,6 +103,40 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
return
;
return
;
}
}
}
}
//判断当天是否请假
AttendanceLeaveRecordQuery
leaveRecordQuery
=
new
AttendanceLeaveRecordQuery
();
leaveRecordQuery
.
setLeavePersonId
(
commonData
.
getStaffId
());
leaveRecordQuery
.
setAuditResult
(
AuditStatusEnum
.
通过
.
getValue
());
leaveRecordQuery
.
setStartTimeStart
(
commonData
.
getDateStr
());
leaveRecordQuery
.
setStartTimeEnd
(
commonData
.
getDateStr
());
AttendanceLeaveRecordEntity
attendanceLeaveRecordEntity
=
attendanceLeaveRecordService
.
selectOne
(
leaveRecordQuery
);
if
(!
ObjectUtils
.
isEmpty
(
attendanceLeaveRecordEntity
))
{
log
.
info
(
"当天员工请假,不做考勤处理!staffId:{},name:{}"
,
commonData
.
getStaffId
(),
attendanceLeaveRecordEntity
.
getLeavePerson
());
//删除当日考勤记录与详细
AttendanceRecordQuery
attendanceRecordQuery
=
new
AttendanceRecordQuery
();
attendanceRecordQuery
.
setStaffId
(
commonData
.
getStaffId
());
attendanceRecordQuery
.
setAttendanceDateStart
(
commonData
.
getDateStr
());
attendanceRecordQuery
.
setAttendanceDateEnd
(
commonData
.
getDateStr
());
List
<
AttendanceRecordEntity
>
attendanceRecordEntities
=
attendanceRecordService
.
find
(
attendanceRecordQuery
);
if
(!
ObjectUtils
.
isEmpty
(
attendanceRecordEntities
))
{
//删除
Long
[]
delIds
=
attendanceRecordEntities
.
stream
().
map
(
AttendanceRecordEntity:
:
getId
).
toArray
(
Long
[]::
new
);
attendanceRecordService
.
remove
(
delIds
,
commonData
.
getContext
());
AttendanceRecordDetailQuery
detailQuery
=
new
AttendanceRecordDetailQuery
();
detailQuery
.
setRecordIdList
(
Arrays
.
asList
(
delIds
));
List
<
AttendanceRecordDetailEntity
>
detailEntities
=
attendanceRecordDetailService
.
find
(
detailQuery
);
if
(!
ObjectUtils
.
isEmpty
(
detailEntities
))
{
attendanceRecordDetailService
.
remove
(
detailEntities
.
stream
().
map
(
AttendanceRecordDetailEntity:
:
getId
).
toArray
(
Long
[]::
new
),
commonData
.
getContext
());
}
}
//删除当天该员工的异常记录与打卡考勤记录
deleteErrorRecord
(
commonData
.
getDateStr
(),
commonData
.
getStaffId
(),
commonData
.
getContext
());
return
;
}
/* if (weekClassId == -1L) {
/* if (weekClassId == -1L) {
//跳过本次循环
//跳过本次循环
return;
return;
...
@@ -330,6 +367,19 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
...
@@ -330,6 +367,19 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
}
}
private
void
deleteErrorRecord
(
String
dateStr
,
Long
staffId
,
Context
context
)
{
//删除当前员工当日未处理的异常后,重新添加
AttendanceRecordErrorQuery
errorQuery
=
new
AttendanceRecordErrorQuery
();
errorQuery
.
setErrorDateTimeStart
(
dateStr
);
errorQuery
.
setErrorDateTimeEnd
(
dateStr
);
errorQuery
.
setStaffId
(
staffId
);
errorQuery
.
setProcessStatus
(
YesNoEnum
.
NO
.
getValue
());
Long
[]
errorIds
=
errorService
.
find
(
errorQuery
).
stream
().
map
(
i
->
i
.
getId
()).
toArray
(
Long
[]::
new
);
if
(!
ObjectUtils
.
isEmpty
(
errorIds
))
{
errorService
.
remove
(
errorIds
,
context
);
}
}
public
void
genErrorAttendRecord
(
Context
context
,
String
dateStr
,
AttendanceRecordEntity
attendanceRecordEntity
,
List
<
AttendanceRecordDetailEntity
>
detailEntityList
)
{
public
void
genErrorAttendRecord
(
Context
context
,
String
dateStr
,
AttendanceRecordEntity
attendanceRecordEntity
,
List
<
AttendanceRecordDetailEntity
>
detailEntityList
)
{
//处理异常打卡,所以异常打卡的 都新增一条记录
//处理异常打卡,所以异常打卡的 都新增一条记录
...
@@ -382,7 +432,7 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
...
@@ -382,7 +432,7 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
errorEntity
.
setShiftsName
(
recordDetailEntity
.
getShiftsName
());
errorEntity
.
setShiftsName
(
recordDetailEntity
.
getShiftsName
());
errorEntity
.
setProcessStatus
(
YesNoEnum
.
NO
.
getValue
());
errorEntity
.
setProcessStatus
(
YesNoEnum
.
NO
.
getValue
());
errorEntity
.
setCreateTime
(
new
Date
());
errorEntity
.
setCreateTime
(
new
Date
());
errorEntity
.
setCreateUserId
(
context
==
null
?
1L
:
context
.
getUser
().
getId
());
errorEntity
.
setCreateUserId
(
context
==
null
?
1L
:
context
.
getUser
().
getId
());
Date
offWorkDate
=
attendanceClassDetailEntity
.
getOffWorkDate
();
Date
offWorkDate
=
attendanceClassDetailEntity
.
getOffWorkDate
();
errorEntity
.
setGoOffDateTime
(
DateUtil
.
parseDateTime
(
dateStr
+
" "
+
DateUtil
.
formatTime
(
offWorkDate
)).
toJdkDate
());
errorEntity
.
setGoOffDateTime
(
DateUtil
.
parseDateTime
(
dateStr
+
" "
+
DateUtil
.
formatTime
(
offWorkDate
)).
toJdkDate
());
if
(!
ObjectUtils
.
isEmpty
(
recordDetailEntity
.
getOffWorkDate
()))
{
if
(!
ObjectUtils
.
isEmpty
(
recordDetailEntity
.
getOffWorkDate
()))
{
...
@@ -405,17 +455,8 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
...
@@ -405,17 +455,8 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
}
}
}
}
//删除当前员工当日未处理的异常后,重新添加
//删除当前员工当日未处理的异常后,重新添加
AttendanceRecordErrorQuery
errorQuery
=
new
AttendanceRecordErrorQuery
();
deleteErrorRecord
(
dateStr
,
attendanceRecordEntity
.
getStaffId
(),
context
);
errorQuery
.
setErrorDateTimeStart
(
dateStr
);
AttendanceRecordErrorQuery
errorQuery
;
errorQuery
.
setErrorDateTimeEnd
(
dateStr
);
errorQuery
.
setStaffId
(
attendanceRecordEntity
.
getStaffId
());
errorQuery
.
setProcessStatus
(
YesNoEnum
.
NO
.
getValue
());
Long
[]
errorIds
=
errorService
.
find
(
errorQuery
).
stream
().
map
(
i
->
i
.
getId
()).
toArray
(
Long
[]::
new
);
if
(!
ObjectUtils
.
isEmpty
(
errorIds
))
{
errorService
.
remove
(
errorIds
,
context
);
}
if
(!
ObjectUtils
.
isEmpty
(
errorEntityList
))
{
if
(!
ObjectUtils
.
isEmpty
(
errorEntityList
))
{
for
(
AttendanceRecordErrorEntity
errorEntity
:
errorEntityList
)
{
for
(
AttendanceRecordErrorEntity
errorEntity
:
errorEntityList
)
{
...
...
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