Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
ops
Commits
26cf382b
Commit
26cf382b
authored
Mar 03, 2025
by
wujipeng
Browse files
定时任务获取数据优化
parent
0e39c57d
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/ruzhoukj/sms/controller/DingAttendanceController.java
View file @
26cf382b
...
...
@@ -13,6 +13,7 @@ import com.ruzhoukj.sms.common.Result;
import
com.ruzhoukj.sms.ding.PermissionConfig
;
import
com.ruzhoukj.sms.model.vo.DingAttendanceDTO
;
import
com.ruzhoukj.sms.model.vo.DingAttendanceVO
;
import
com.ruzhoukj.sms.model.vo.DingUserVO
;
import
com.ruzhoukj.sms.service.DingAttendanceService
;
import
com.taobao.api.ApiException
;
import
com.taobao.api.internal.util.StringUtils
;
...
...
@@ -38,6 +39,8 @@ public class DingAttendanceController {
private
PermissionConfig
permissionConfig
;
@Resource
private
DingAttendanceService
dingAttendanceService
;
@Resource
private
DingEmployeeController
dingEmployeeController
;
@ApiOperation
(
value
=
"获取打卡时间区间数据"
)
@PostMapping
(
"/radius"
)
...
...
@@ -50,7 +53,8 @@ public class DingAttendanceController {
req
.
setCheckDateFrom
(
dingAttendanceDTO
.
getCheckDateFrom
());
req
.
setCheckDateTo
(
dingAttendanceDTO
.
getCheckDateTo
());
req
.
setIsI18n
(
dingAttendanceDTO
.
getIsI18n
());
req
.
setUserIds
(
dingAttendanceDTO
.
getUserIds
());
List
<
String
>
userIds
=
dingAttendanceDTO
.
getUserIds
();
req
.
setUserIds
(
userIds
);
OapiAttendanceListRecordResponse
rsp
=
client
.
execute
(
req
,
accessToken
);
List
<
DingAttendanceVO
>
data
=
Lists
.
newArrayList
();
rsp
.
getRecordresult
().
forEach
(
recordresult
->
{
...
...
@@ -58,12 +62,33 @@ public class DingAttendanceController {
.
userId
(
recordresult
.
getUserId
())
.
userAddress
(
recordresult
.
getUserAddress
())
.
userCheckTime
(
recordresult
.
getUserCheckTime
())
.
date
(
StringUtils
.
parseDateTime
(
dingAttendanceDTO
.
getCheckDateFrom
()))
.
timeResult
(
recordresult
.
getTimeResult
())
.
checkType
(
recordresult
.
getCheckType
())
.
sourceType
(
recordresult
.
getSourceType
())
.
build
());
});
//userIds中有data中没有的,添加一条空数据
for
(
String
userId
:
userIds
)
{
boolean
flag
=
false
;
for
(
DingAttendanceVO
dingAttendanceVO
:
data
)
{
if
(
userId
.
equals
(
dingAttendanceVO
.
getUserId
()))
{
flag
=
true
;
break
;
}
}
if
(!
flag
)
{
DingUserVO
employeeDetail
=
dingEmployeeController
.
getEmployeeDetail
(
userId
);
data
.
add
(
DingAttendanceVO
.
builder
()
.
name
(
employeeDetail
.
getName
())
.
userId
(
userId
)
.
date
(
StringUtils
.
parseDateTime
(
dingAttendanceDTO
.
getCheckDateFrom
()))
.
build
());
}
}
return
data
;
}
catch
(
ApiException
e
)
{
throw
new
RuntimeException
(
e
);
...
...
src/main/java/com/ruzhoukj/sms/entity/DingAttendanceEntity.java
View file @
26cf382b
...
...
@@ -39,6 +39,11 @@ public class DingAttendanceEntity {
@TableField
(
value
=
"user_check_time"
)
private
Date
userCheckTime
;
@ApiModelProperty
(
value
=
"时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
@TableField
(
value
=
"date"
)
private
Date
date
;
@ApiModelProperty
(
value
=
"打卡地点,打卡设备"
)
@TableField
(
value
=
"user_address"
)
private
String
userAddress
;
...
...
src/main/java/com/ruzhoukj/sms/model/vo/DingAttendanceVO.java
View file @
26cf382b
package
com.ruzhoukj.sms.model.vo
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
...
...
@@ -37,6 +37,11 @@ public class DingAttendanceVO {
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
userCheckTime
;
@ApiModelProperty
(
value
=
"时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
@TableField
(
value
=
"date"
)
private
Date
date
;
@ApiModelProperty
(
value
=
"打卡结果 Normal:正常 Early:早退 Late:迟到 SeriousLate:严重迟到 Absenteeism:旷工迟到 NotSigned:未打卡"
)
private
String
timeResult
;
...
...
src/main/java/com/ruzhoukj/sms/task/DingTask.java
View file @
26cf382b
...
...
@@ -77,14 +77,9 @@ public class DingTask {
// 获取当前日期
Date
currentDate
=
new
Date
();
System
.
out
.
println
(
"当前日期: "
+
currentDate
);
// 将 Date 转换为 LocalDate
LocalDate
localDate
=
currentDate
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
();
// 减去一天
LocalDate
previousDate
=
localDate
.
minusDays
(
1
);
// 将 LocalDate 转换回 Date
Date
previousDateAsDate
=
Date
.
from
(
previousDate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
...
...
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