Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dd_school
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangqi
dd_school
Commits
65d46f7a
Commit
65d46f7a
authored
Nov 20, 2023
by
xuwenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增获取钉钉用户打卡请假记录
parent
251a8886
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
562 additions
and
5 deletions
+562
-5
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
+13
-0
smart-campus/src/main/java/yangtz/cs/liu/campus/controller/teacher/SchoolTeacherLeaveController.java
+5
-3
smart-campus/src/main/java/yangtz/cs/liu/campus/mapper/teacher/SchoolTeacherMapper.java
+5
-0
smart-campus/src/main/java/yangtz/cs/liu/campus/service/impl/teacher/SchoolTeacherLeaveServiceImpl.java
+4
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingClock/DingClockController.java
+35
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/service/dingClock/IDingClockService.java
+8
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/service/impl/dingClock/DingClockServiceImpl.java
+378
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingClockUtils.java
+105
-0
smart-campus/src/main/resources/mapper/teacher/SchoolTeacherLeaveMapper.xml
+2
-2
smart-campus/src/main/resources/mapper/teacher/SchoolTeacherMapper.xml
+7
-0
No files found.
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
View file @
65d46f7a
...
@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
yangtz.cs.liu.dingding.controller.DingJiaXiaoController
;
import
yangtz.cs.liu.dingding.controller.DingJiaXiaoController
;
import
yangtz.cs.liu.dingding.controller.dingClock.DingClockController
;
import
yangtz.cs.liu.dingding.controller.dingDept.DdDeptController
;
import
yangtz.cs.liu.dingding.controller.dingDept.DdDeptController
;
import
yangtz.cs.liu.dingding.controller.dingUser.DingUserController
;
import
yangtz.cs.liu.dingding.controller.dingUser.DingUserController
;
...
@@ -21,6 +22,8 @@ public class RyTask
...
@@ -21,6 +22,8 @@ public class RyTask
DdDeptController
ddDeptController
;
DdDeptController
ddDeptController
;
@Autowired
@Autowired
DingUserController
dingUserController
;
DingUserController
dingUserController
;
@Autowired
DingClockController
dingClockController
;
public
void
ryMultipleParams
(
String
s
,
Boolean
b
,
Long
l
,
Double
d
,
Integer
i
)
public
void
ryMultipleParams
(
String
s
,
Boolean
b
,
Long
l
,
Double
d
,
Integer
i
)
{
{
...
@@ -57,4 +60,14 @@ public class RyTask
...
@@ -57,4 +60,14 @@ public class RyTask
dingUserController
.
syncDdUser
();
dingUserController
.
syncDdUser
();
}
}
//获取钉钉用户一周内打卡记录
public
void
getListRecord
(){
dingClockController
.
getListRecord
();
}
//获取钉钉用户一周内请假记录
public
void
getTeacherLeave
(){
dingClockController
.
getTeacherLeave
();
}
}
}
smart-campus/src/main/java/yangtz/cs/liu/campus/controller/teacher/SchoolTeacherLeaveController.java
View file @
65d46f7a
...
@@ -140,9 +140,11 @@ public class SchoolTeacherLeaveController extends BaseController {
...
@@ -140,9 +140,11 @@ public class SchoolTeacherLeaveController extends BaseController {
SchoolTeacherLeave
leave
=
schoolTeacherLeaveService
.
getById
(
id
);
SchoolTeacherLeave
leave
=
schoolTeacherLeaveService
.
getById
(
id
);
TeacherLeaveVO
vo
=
new
TeacherLeaveVO
();
TeacherLeaveVO
vo
=
new
TeacherLeaveVO
();
BeanUtils
.
copyProperties
(
leave
,
vo
);
BeanUtils
.
copyProperties
(
leave
,
vo
);
if
(!
leave
.
getApplyType
().
equals
(
TYPE
)){
if
(
StringUtils
.
isNotEmpty
(
leave
.
getApplyType
())){
String
dayCourse
=
HolidayDateUtil
.
dayCourse
(
leave
.
getTotalTime
());
if
(!
leave
.
getApplyType
().
equals
(
TYPE
)){
vo
.
setDayCourse
(
dayCourse
);
String
dayCourse
=
HolidayDateUtil
.
dayCourse
(
leave
.
getTotalTime
());
vo
.
setDayCourse
(
dayCourse
);
}
}
}
return
AjaxResult
.
success
(
vo
);
return
AjaxResult
.
success
(
vo
);
}
}
...
...
smart-campus/src/main/java/yangtz/cs/liu/campus/mapper/teacher/SchoolTeacherMapper.java
View file @
65d46f7a
...
@@ -124,4 +124,9 @@ public interface SchoolTeacherMapper extends BaseMapper<SchoolTeacher>{
...
@@ -124,4 +124,9 @@ public interface SchoolTeacherMapper extends BaseMapper<SchoolTeacher>{
* 根据userId 查询 unionId
* 根据userId 查询 unionId
*/
*/
String
getUnionIdByUserId
(
Long
userId
);
String
getUnionIdByUserId
(
Long
userId
);
/**
* 获取打卡教师列表
*/
List
<
SchoolTeacher
>
selectClockTeacher
();
}
}
smart-campus/src/main/java/yangtz/cs/liu/campus/service/impl/teacher/SchoolTeacherLeaveServiceImpl.java
View file @
65d46f7a
...
@@ -129,6 +129,10 @@ public class SchoolTeacherLeaveServiceImpl extends ServiceImpl<SchoolTeacherLeav
...
@@ -129,6 +129,10 @@ public class SchoolTeacherLeaveServiceImpl extends ServiceImpl<SchoolTeacherLeav
}
else
{
}
else
{
leave
.
setTaskName
(
"未启动"
);
leave
.
setTaskName
(
"未启动"
);
}
}
//判断是否是从钉钉获取到的请假申请(钉钉获取的请假申请没有请假原因)
if
(
StringUtils
.
isEmpty
(
leave
.
getReasonForLeave
())){
leave
.
setTaskName
(
"已结束"
);
}
}
}
return
teacherLeaveVO
;
return
teacherLeaveVO
;
}
}
...
...
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingClock/DingClockController.java
0 → 100644
View file @
65d46f7a
package
yangtz
.
cs
.
liu
.
dingding
.
controller
.
dingClock
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
yangtz.cs.liu.dingding.service.dingClock.IDingClockService
;
/**
* 钉钉用户打卡记录
*/
@RestController
@RequestMapping
(
"/dd/school/clock"
)
public
class
DingClockController
{
@Autowired
private
IDingClockService
dingClockService
;
/**
* 获取全部用户一周内打卡记录
*/
@PostMapping
(
"/getListRecord"
)
public
AjaxResult
getListRecord
(){
return
AjaxResult
.
success
(
dingClockService
.
getListRecord
());
}
/**
* 获取全部用户一周内请假记
*/
@PostMapping
(
"/getTeacherLeave"
)
public
AjaxResult
getTeacherLeave
(){
return
AjaxResult
.
success
(
dingClockService
.
getTeacherLeave
());
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/service/dingClock/IDingClockService.java
0 → 100644
View file @
65d46f7a
package
yangtz
.
cs
.
liu
.
dingding
.
service
.
dingClock
;
public
interface
IDingClockService
{
String
getListRecord
();
String
getTeacherLeave
();
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/service/impl/dingClock/DingClockServiceImpl.java
0 → 100644
View file @
65d46f7a
package
yangtz
.
cs
.
liu
.
dingding
.
service
.
impl
.
dingClock
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.dingtalk.api.response.OapiAttendanceGetleavestatusResponse
;
import
com.dingtalk.api.response.OapiAttendanceListRecordResponse
;
import
com.ruoyi.common.core.domain.entity.SchoolTeacher
;
import
com.ruoyi.common.core.domain.entity.SysDept
;
import
com.ruoyi.common.core.domain.entity.SysUser
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.system.mapper.SysDeptMapper
;
import
com.ruoyi.system.mapper.SysUserMapper
;
import
com.ruoyi.system.service.ISysDeptService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
yangtz.cs.liu.campus.domain.schoolAtt.SchoolAtt
;
import
yangtz.cs.liu.campus.domain.teacher.SchoolTeacherLeave
;
import
yangtz.cs.liu.campus.mapper.schoolAtt.SchoolAttMapper
;
import
yangtz.cs.liu.campus.mapper.teacher.SchoolTeacherMapper
;
import
yangtz.cs.liu.campus.service.schoolAtt.ISchoolAttService
;
import
yangtz.cs.liu.campus.service.teacher.ISchoolTeacherLeaveService
;
import
yangtz.cs.liu.dingding.service.dingClock.IDingClockService
;
import
yangtz.cs.liu.dingding.utils.DingClockUtils
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
public
class
DingClockServiceImpl
implements
IDingClockService
{
@Autowired
private
DingClockUtils
dingClockUtils
;
@Autowired
private
SchoolTeacherMapper
teacherMapper
;
@Autowired
private
SysUserMapper
userMapper
;
@Autowired
private
ISchoolAttService
attService
;
@Autowired
private
SysDeptMapper
deptMapper
;
@Autowired
private
ISchoolTeacherLeaveService
teacherLeaveService
;
/**
* 获取全部用户一周内打卡记录
*/
@Override
@Transactional
public
String
getListRecord
(){
//查询所有教师(管理员账号除外)
List
<
SchoolTeacher
>
schoolTeachers
=
teacherMapper
.
selectClockTeacher
();
//查询所有教师用户
List
<
SysUser
>
userList
=
userMapper
.
selectUserList
(
new
SysUser
());
//查询所有部门
List
<
SysDept
>
sysDepts
=
deptMapper
.
selectDeptList
(
new
SysDept
());
//存放钉钉用户id集合
List
<
String
>
ddUserIds
=
new
ArrayList
<>();
//遍历拿出所有钉钉用户id
if
(
schoolTeachers
.
size
()
>
0
){
for
(
SchoolTeacher
schoolTeacher
:
schoolTeachers
)
{
if
(
StringUtils
.
isNotEmpty
(
schoolTeacher
.
getDdUserId
())){
ddUserIds
.
add
(
schoolTeacher
.
getDdUserId
());
}
}
}
//获取本周周一日期
Calendar
c
=
Calendar
.
getInstance
();
//设置周一为一周的第一天
c
.
setFirstDayOfWeek
(
Calendar
.
MONDAY
);
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
MONDAY
);
Date
time
=
c
.
getTime
();
//查询用户打卡详情需要的时间格式
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
//查询考勤打卡记录的起始工作日
String
checkDateFrom
=
sdf
.
format
(
time
)
+
" 00:00:00"
;
//查询考勤打卡记录的结束工作日
String
checkDateTo
=
sdf
.
format
(
new
Date
())
+
" 23:59:59"
;
//用户打卡时间转换
SimpleDateFormat
sdf1
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
//存放用户打卡记录集合
List
<
SchoolAtt
>
schoolAttList
=
new
ArrayList
<>();
//用户查询用户打卡详情,最多存放五十个钉钉用户id
List
<
String
>
userIdListResult
=
new
ArrayList
<>();
if
(
ddUserIds
.
size
()
>
50
){
for
(
int
i
=
0
;
50
*
i
<
ddUserIds
.
size
();
i
++)
{
userIdListResult
=
ddUserIds
.
subList
(
50
*
i
,
Math
.
min
(
ddUserIds
.
size
(),
50
*
(
i
+
1
)));
List
<
OapiAttendanceListRecordResponse
.
Recordresult
>
recordresults
=
dingClockUtils
.
listRecord
(
userIdListResult
,
checkDateFrom
,
checkDateTo
,
false
);
if
(
recordresults
.
size
()
>
0
){
for
(
OapiAttendanceListRecordResponse
.
Recordresult
recordresult
:
recordresults
)
{
SchoolAtt
schoolAtt
=
new
SchoolAtt
();
for
(
SchoolTeacher
schoolTeacher
:
schoolTeachers
)
{
if
(
recordresult
.
getUserId
().
equals
(
schoolTeacher
.
getDdUserId
())){
//打卡记录
schoolAtt
.
setDeviceNum
(
schoolTeacher
.
getDeviceNum
());
schoolAtt
.
setTeacherCode
(
schoolTeacher
.
getTeacherCode
());
schoolAtt
.
setUserId
(
schoolTeacher
.
getId
());
schoolAtt
.
setUserName
(
schoolTeacher
.
getTeacherName
());
for
(
SysUser
sysUser
:
userList
)
{
if
(
schoolTeacher
.
getId
().
equals
(
sysUser
.
getUserId
())){
schoolAtt
.
setOrgid
(
sysUser
.
getDeptId
());
for
(
SysDept
sysDept
:
sysDepts
)
{
if
(
sysDept
.
getDeptId
().
equals
(
sysUser
.
getDeptId
())){
schoolAtt
.
setOrgname
(
sysDept
.
getDeptName
());
}
}
}
}
//打卡日期
schoolAtt
.
setClockDate
(
recordresult
.
getUserCheckTime
());
//打卡时间
schoolAtt
.
setClockTime
(
sdf1
.
format
(
recordresult
.
getUserCheckTime
()));
//打卡状态
if
(
StringUtils
.
isNotEmpty
(
recordresult
.
getTimeResult
())){
String
workStatus
=
""
;
switch
(
recordresult
.
getTimeResult
()){
case
"Normal"
:
workStatus
=
"正常"
;
break
;
case
"Early"
:
workStatus
=
"早退"
;
break
;
case
"Late"
:
workStatus
=
"迟到"
;
break
;
case
"SeriousLate"
:
workStatus
=
"严重迟到"
;
break
;
case
"Absenteeism"
:
workStatus
=
"旷工迟到"
;
break
;
case
"NotSigned"
:
workStatus
=
"未打卡"
;
break
;
}
schoolAtt
.
setWorkStatus
(
workStatus
);
}
//备注
schoolAtt
.
setRemark
(
recordresult
.
getOutsideRemark
());
// attMapper.insertSchoolAtt(schoolAtt);
schoolAttList
.
add
(
schoolAtt
);
}
}
}
}
}
}
else
{
userIdListResult
=
ddUserIds
;
List
<
OapiAttendanceListRecordResponse
.
Recordresult
>
recordresults
=
dingClockUtils
.
listRecord
(
userIdListResult
,
checkDateFrom
,
checkDateTo
,
false
);
if
(
recordresults
.
size
()
>
0
){
for
(
OapiAttendanceListRecordResponse
.
Recordresult
recordresult
:
recordresults
)
{
SchoolAtt
schoolAtt
=
new
SchoolAtt
();
for
(
SchoolTeacher
schoolTeacher
:
schoolTeachers
)
{
if
(
recordresult
.
getUserId
().
equals
(
schoolTeacher
.
getDdUserId
())){
schoolAtt
.
setDeviceNum
(
schoolTeacher
.
getDeviceNum
());
schoolAtt
.
setTeacherCode
(
schoolTeacher
.
getTeacherCode
());
schoolAtt
.
setUserId
(
schoolTeacher
.
getId
());
schoolAtt
.
setUserName
(
schoolTeacher
.
getTeacherName
());
for
(
SysUser
sysUser
:
userList
)
{
if
(
schoolTeacher
.
getId
().
equals
(
sysUser
.
getUserId
())){
schoolAtt
.
setOrgid
(
sysUser
.
getDeptId
());
for
(
SysDept
sysDept
:
sysDepts
)
{
if
(
sysDept
.
getDeptId
().
equals
(
sysUser
.
getDeptId
())){
schoolAtt
.
setOrgname
(
sysDept
.
getDeptName
());
}
}
}
}
//打卡日期
schoolAtt
.
setClockDate
(
recordresult
.
getUserCheckTime
());
//打卡时间
schoolAtt
.
setClockTime
(
sdf1
.
format
(
recordresult
.
getUserCheckTime
()));
//打卡状态
if
(
StringUtils
.
isNotEmpty
(
recordresult
.
getTimeResult
())){
String
workStatus
=
""
;
switch
(
recordresult
.
getTimeResult
()){
case
"Normal"
:
workStatus
=
"正常"
;
break
;
case
"Early"
:
workStatus
=
"早退"
;
break
;
case
"Late"
:
workStatus
=
"迟到"
;
break
;
case
"SeriousLate"
:
workStatus
=
"严重迟到"
;
break
;
case
"Absenteeism"
:
workStatus
=
"旷工迟到"
;
break
;
case
"NotSigned"
:
workStatus
=
"未打卡"
;
break
;
}
schoolAtt
.
setWorkStatus
(
workStatus
);
}
//备注
schoolAtt
.
setRemark
(
recordresult
.
getOutsideRemark
());
// attMapper.insertSchoolAtt(schoolAtt);
schoolAttList
.
add
(
schoolAtt
);
}
}
}
}
}
//批量新增打卡记录
boolean
b
=
attService
.
saveBatch
(
schoolAttList
);
if
(
b
){
return
"操作成功"
;
}
return
"操作失败"
;
}
/**
* 获取全部用户一周内请假信息
*/
@Override
@Transactional
public
String
getTeacherLeave
(){
//查询所有教师(管理员账号除外)
List
<
SchoolTeacher
>
schoolTeachers
=
teacherMapper
.
selectClockTeacher
();
//钉钉用户id
List
<
String
>
ddUserIds
=
new
ArrayList
<>();
//遍历拿出所有钉钉用户id
if
(
schoolTeachers
.
size
()
>
0
){
for
(
SchoolTeacher
schoolTeacher
:
schoolTeachers
)
{
if
(
StringUtils
.
isNotEmpty
(
schoolTeacher
.
getDdUserId
())){
ddUserIds
.
add
(
schoolTeacher
.
getDdUserId
());
}
}
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
//获取本周周一到周日的日期日期
Calendar
c
=
Calendar
.
getInstance
();
//设置周一为一周的第一天
c
.
setFirstDayOfWeek
(
Calendar
.
MONDAY
);
//周一的日期
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
MONDAY
);
Long
monday
=
null
;
try
{
monday
=
sdf
.
parse
(
sdf
.
format
(
c
.
getTime
())).
getTime
();
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
//当前的日期
Long
sunday
=
null
;
try
{
sunday
=
sdf
.
parse
(
sdf
.
format
(
new
Date
())).
getTime
();
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
//偏移量,相当于页码
Long
offset
=
0L
;
//存放所有钉钉用户请假状态
List
<
OapiAttendanceGetleavestatusResponse
.
LeaveStatusVO
>
leaveStatus
=
new
ArrayList
<>();
//存放全部教师请假申请
List
<
SchoolTeacherLeave
>
schoolTeacherLeaveList
=
new
ArrayList
<>();
//用户查询用户打卡详情,最多存放100个钉钉用户id
List
<
String
>
userIdListResult
=
new
ArrayList
<>();
if
(
ddUserIds
.
size
()
>
100
){
for
(
int
i
=
0
;
100
*
i
<
ddUserIds
.
size
();
i
++)
{
userIdListResult
=
ddUserIds
.
subList
(
100
*
i
,
Math
.
min
(
ddUserIds
.
size
(),
100
*
(
i
+
1
)));
String
userIds
=
""
;
for
(
int
i1
=
0
;
i1
<
userIdListResult
.
size
();
i1
++)
{
if
(
i1
==
userIdListResult
.
size
()
-
1
){
userIds
+=
userIdListResult
.
get
(
i1
);
}
else
{
userIds
+=
userIdListResult
.
get
(
i1
)
+
","
;
}
}
//请求查询用户请假状态
OapiAttendanceGetleavestatusResponse
.
LeaveStatusListVO
getleavestatus
=
dingClockUtils
.
getleavestatus
(
userIds
,
monday
,
sunday
,
offset
,
20L
);
if
(
StringUtils
.
isNotNull
(
getleavestatus
.
getLeaveStatus
())
&&
getleavestatus
.
getLeaveStatus
().
size
()
>
0
){
leaveStatus
.
addAll
(
getleavestatus
.
getLeaveStatus
());
}
if
(
StringUtils
.
isNotNull
(
getleavestatus
.
getHasMore
())){
//判断是否还有数据
while
(
getleavestatus
.
getHasMore
())
{
OapiAttendanceGetleavestatusResponse
.
LeaveStatusListVO
getleavestatus1
=
dingClockUtils
.
getleavestatus
(
userIds
,
monday
,
sunday
,
offset
,
20L
);
if
(
StringUtils
.
isNotNull
(
getleavestatus1
.
getLeaveStatus
())
&&
getleavestatus1
.
getLeaveStatus
().
size
()
>
0
){
leaveStatus
.
addAll
(
getleavestatus1
.
getLeaveStatus
());
}
if
(
StringUtils
.
isNull
(
getleavestatus1
.
getHasMore
())
||
getleavestatus1
.
getHasMore
().
equals
(
false
)){
break
;
}
offset
++;
}
}
}
}
else
{
userIdListResult
=
ddUserIds
;
String
userIds
=
""
;
for
(
int
i1
=
0
;
i1
<
userIdListResult
.
size
();
i1
++)
{
if
(
i1
==
userIdListResult
.
size
()
-
1
){
userIds
+=
userIdListResult
.
get
(
i1
);
}
else
{
userIds
+=
userIdListResult
.
get
(
i1
)
+
","
;
}
}
//请求查询用户请假状态
OapiAttendanceGetleavestatusResponse
.
LeaveStatusListVO
getleavestatus
=
dingClockUtils
.
getleavestatus
(
userIds
,
monday
,
sunday
,
offset
,
20L
);
if
(
StringUtils
.
isNotNull
(
getleavestatus
.
getLeaveStatus
())
&&
getleavestatus
.
getLeaveStatus
().
size
()
>
0
){
leaveStatus
.
addAll
(
getleavestatus
.
getLeaveStatus
());
}
if
(
StringUtils
.
isNotNull
(
getleavestatus
.
getHasMore
())){
//判断是否还有数据
while
(
getleavestatus
.
getHasMore
())
{
OapiAttendanceGetleavestatusResponse
.
LeaveStatusListVO
getleavestatus1
=
dingClockUtils
.
getleavestatus
(
userIds
,
monday
,
sunday
,
offset
,
20L
);
if
(
StringUtils
.
isNotNull
(
getleavestatus1
.
getLeaveStatus
())
&&
getleavestatus1
.
getLeaveStatus
().
size
()
>
0
){
leaveStatus
.
addAll
(
getleavestatus1
.
getLeaveStatus
());
}
if
(
StringUtils
.
isNull
(
getleavestatus1
.
getHasMore
())
||
getleavestatus1
.
getHasMore
().
equals
(
false
)){
break
;
}
offset
++;
}
}
}
//循环钉钉用户请假状态,给教师请假实体对象赋值
if
(
leaveStatus
.
size
()
>
0
){
for
(
OapiAttendanceGetleavestatusResponse
.
LeaveStatusVO
status
:
leaveStatus
)
{
for
(
SchoolTeacher
schoolTeacher
:
schoolTeachers
)
{
if
(
status
.
getUserid
().
equals
(
schoolTeacher
.
getDdUserId
())){
SchoolTeacherLeave
teacherLeave
=
new
SchoolTeacherLeave
();
teacherLeave
.
setTitle
(
schoolTeacher
.
getTeacherName
()
+
"的请假申请"
);
teacherLeave
.
setTeacherId
(
schoolTeacher
.
getId
());
teacherLeave
.
setTeacherName
(
schoolTeacher
.
getTeacherName
());
teacherLeave
.
setStartTime
(
new
Date
(
status
.
getStartTime
()));
teacherLeave
.
setEndTime
(
new
Date
(
status
.
getEndTime
()));
//单位为小时,换算成天数(从钉钉获取的时长自动乘了100,存系统数据库前需手动除以100,为实际请假时长)
if
(
status
.
getDurationUnit
().
equals
(
"percent_hour"
)){
teacherLeave
.
setTotalTime
(
Double
.
parseDouble
(
String
.
format
(
"%.3f"
,
Double
.
parseDouble
(
status
.
getDurationPercent
()
+
""
)
/
24
/
100
)));
}
else
{
teacherLeave
.
setTotalTime
(
Double
.
parseDouble
(
String
.
format
(
"%.3f"
,
Double
.
parseDouble
(
status
.
getDurationPercent
()
+
""
)
/
100
)));
}
teacherLeave
.
setState
(
"0"
);
teacherLeave
.
setApplyUserId
(
schoolTeacher
.
getId
());
teacherLeave
.
setApplyUser
(
schoolTeacher
.
getTeacherName
());
schoolTeacherLeaveList
.
add
(
teacherLeave
);
}
}
}
}
//根据教师id,开始时间、结束时间去重
List
<
SchoolTeacherLeave
>
teacherLeaveList
=
schoolTeacherLeaveList
.
stream
().
collect
(
Collectors
.
collectingAndThen
(
Collectors
.
toCollection
(()
->
new
TreeSet
<>(
Comparator
.
comparing
(
o
->
o
.
getTeacherId
()
+
";"
+
o
.
getStartTime
()
+
";"
+
o
.
getEndTime
()))),
ArrayList:
:
new
));
//批量新增教师请假
boolean
b
=
teacherLeaveService
.
saveBatch
(
teacherLeaveList
);
if
(
b
){
return
"操作成功"
;
}
return
"操作失败"
;
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingClockUtils.java
0 → 100644
View file @
65d46f7a
package
yangtz
.
cs
.
liu
.
dingding
.
utils
;
import
com.dingtalk.api.DefaultDingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.OapiAttendanceGetleavestatusRequest
;
import
com.dingtalk.api.request.OapiAttendanceGetupdatedataRequest
;
import
com.dingtalk.api.request.OapiAttendanceListRecordRequest
;
import
com.dingtalk.api.response.OapiAttendanceGetleavestatusResponse
;
import
com.dingtalk.api.response.OapiAttendanceGetupdatedataResponse
;
import
com.dingtalk.api.response.OapiAttendanceListRecordResponse
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.taobao.api.ApiException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* 考勤
*/
@Component
public
class
DingClockUtils
{
@Autowired
private
AccessTokenUtils
accessTokenUtils
;
/**
* 查询打卡记录详情
* @param userIds 企业内的员工ID列表,最大值50。
* @param checkDateFrom 查询考勤打卡记录的起始工作日 格式为:yyyy-MM-dd hh:mm:ss
* @param checkDateTo 查询考勤打卡记录的结束工作日 格式为:yyyy-MM-dd hh:mm:ss
* @param isI18n 是否为海外企业使用 true:海外平台使用 false(默认):国内平台使用
* @return
*/
public
List
<
OapiAttendanceListRecordResponse
.
Recordresult
>
listRecord
(
List
<
String
>
userIds
,
String
checkDateFrom
,
String
checkDateTo
,
Boolean
isI18n
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/attendance/listRecord"
);
OapiAttendanceListRecordRequest
req
=
new
OapiAttendanceListRecordRequest
();
req
.
setUserIds
(
userIds
);
req
.
setCheckDateFrom
(
checkDateFrom
);
req
.
setCheckDateTo
(
checkDateTo
);
req
.
setIsI18n
(
isI18n
);
OapiAttendanceListRecordResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getRecordresult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
ArrayList
<>();
}
/**
* 获取用户考勤数据 获取指定用户当天的考勤数据 可获取用户的考勤数据,包括打卡流水记录、打卡结果和审批列表等
* @param userId 用户的userId
* @param workDate 查询日期
* @return
*/
public
OapiAttendanceGetupdatedataResponse
.
AtCheckInfoForOpenVo
getupdatedata
(
String
userId
,
Date
workDate
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/attendance/getupdatedata"
);
OapiAttendanceGetupdatedataRequest
req
=
new
OapiAttendanceGetupdatedataRequest
();
req
.
setUserid
(
userId
);
req
.
setWorkDate
(
workDate
);
OapiAttendanceGetupdatedataResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiAttendanceGetupdatedataResponse
.
AtCheckInfoForOpenVo
();
}
/**
* 查询请假状态 查询指定企业下指定用户在指定时间段内每天的请假状态和请假时长信息
* @param userIds 待查询用户的ID列表,每次最多100个
* @param startTime 开始时间 ,Unix时间戳,支持最多180天的查询
* @param endTime 结束时间,Unix时间戳,支持最多180天的查询
* @param offSet 支持分页查询,与size参数同时设置时才生效,此参数代表偏移量,偏移量从0开始
* @param size 支持分页查询,与offset参数同时设置时才生效,此参数代表分页大小,最大20
*/
public
OapiAttendanceGetleavestatusResponse
.
LeaveStatusListVO
getleavestatus
(
String
userIds
,
Long
startTime
,
Long
endTime
,
Long
offSet
,
Long
size
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/attendance/getleavestatus"
);
OapiAttendanceGetleavestatusRequest
req
=
new
OapiAttendanceGetleavestatusRequest
();
req
.
setUseridList
(
userIds
);
req
.
setStartTime
(
startTime
);
req
.
setEndTime
(
endTime
);
req
.
setOffset
(
offSet
);
req
.
setSize
(
size
);
OapiAttendanceGetleavestatusResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiAttendanceGetleavestatusResponse
.
LeaveStatusListVO
();
}
}
smart-campus/src/main/resources/mapper/teacher/SchoolTeacherLeaveMapper.xml
View file @
65d46f7a
...
@@ -58,10 +58,10 @@
...
@@ -58,10 +58,10 @@
<![CDATA[and date_format( start_time,'%Y-%m-%d') <= date_format( #{entity.endTime},'%Y-%m-%d')]]>
<![CDATA[and date_format( start_time,'%Y-%m-%d') <= date_format( #{entity.endTime},'%Y-%m-%d')]]>
</if>
</if>
<if
test=
"submitState == 0"
>
<if
test=
"submitState == 0"
>
and instance_id is null
and instance_id is n
ot n
ull
</if>
</if>
<if
test=
"submitState == 1"
>
<if
test=
"submitState == 1"
>
and instance_id is n
ot n
ull
and instance_id is null
</if>
</if>
and del_flag = '0'
and del_flag = '0'
</where>
</where>
...
...
smart-campus/src/main/resources/mapper/teacher/SchoolTeacherMapper.xml
View file @
65d46f7a
...
@@ -47,6 +47,13 @@
...
@@ -47,6 +47,13 @@
from school_teacher
from school_teacher
</sql>
</sql>
<select
id=
"selectClockTeacher"
resultMap=
"SchoolTeacherResult"
>
select t.id, t.device_num, t.teacher_name, t.teacher_tel, t.teacher_code, t.id_card, t.home_address, t.nation, t.pic_url,
t.birthday, t.education, t.sex, t.dd_user_id, t.union_id, t.create_by, t.create_time, t.update_by, t.update_time
from school_teacher t
where t.id != 1
</select>
<select
id=
"selectSchoolTeacherList"
resultType=
"com.ruoyi.common.core.domain.entity.SchoolTeacher"
>
<select
id=
"selectSchoolTeacherList"
resultType=
"com.ruoyi.common.core.domain.entity.SchoolTeacher"
>
select t.id,t.device_num,t.teacher_name, t.teacher_tel, t.teacher_code, t.id_card, t.home_address, t.nation, t.pic_url, t.birthday,
select t.id,t.device_num,t.teacher_name, t.teacher_tel, t.teacher_code, t.id_card, t.home_address, t.nation, t.pic_url, t.birthday,
t.education, t.sex,u.dept_id,d.dept_name,u.status,u.sign,u.avatar,u.employee_type
t.education, t.sex,u.dept_id,d.dept_name,u.status,u.sign,u.avatar,u.employee_type
...
...
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