Commit 65d46f7a by xuwenhao

新增获取钉钉用户打卡请假记录

parent 251a8886
......@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.StringUtils;
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.dingUser.DingUserController;
......@@ -21,6 +22,8 @@ public class RyTask
DdDeptController ddDeptController;
@Autowired
DingUserController dingUserController;
@Autowired
DingClockController dingClockController;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
{
......@@ -57,4 +60,14 @@ public class RyTask
dingUserController.syncDdUser();
}
//获取钉钉用户一周内打卡记录
public void getListRecord(){
dingClockController.getListRecord();
}
//获取钉钉用户一周内请假记录
public void getTeacherLeave(){
dingClockController.getTeacherLeave();
}
}
......@@ -140,9 +140,11 @@ public class SchoolTeacherLeaveController extends BaseController {
SchoolTeacherLeave leave = schoolTeacherLeaveService.getById(id);
TeacherLeaveVO vo = new TeacherLeaveVO();
BeanUtils.copyProperties(leave, vo);
if(!leave.getApplyType().equals(TYPE)){
String dayCourse = HolidayDateUtil.dayCourse(leave.getTotalTime());
vo.setDayCourse(dayCourse);
if (StringUtils.isNotEmpty(leave.getApplyType())){
if(!leave.getApplyType().equals(TYPE)){
String dayCourse = HolidayDateUtil.dayCourse(leave.getTotalTime());
vo.setDayCourse(dayCourse);
}
}
return AjaxResult.success(vo);
}
......
......@@ -124,4 +124,9 @@ public interface SchoolTeacherMapper extends BaseMapper<SchoolTeacher>{
* 根据userId 查询 unionId
*/
String getUnionIdByUserId(Long userId);
/**
* 获取打卡教师列表
*/
List<SchoolTeacher> selectClockTeacher();
}
......@@ -129,6 +129,10 @@ public class SchoolTeacherLeaveServiceImpl extends ServiceImpl<SchoolTeacherLeav
} else {
leave.setTaskName("未启动");
}
//判断是否是从钉钉获取到的请假申请(钉钉获取的请假申请没有请假原因)
if (StringUtils.isEmpty(leave.getReasonForLeave())){
leave.setTaskName("已结束");
}
}
return teacherLeaveVO;
}
......
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());
}
}
package yangtz.cs.liu.dingding.service.dingClock;
public interface IDingClockService {
String getListRecord();
String getTeacherLeave();
}
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();
}
}
......@@ -58,10 +58,10 @@
<![CDATA[and date_format( start_time,'%Y-%m-%d') <= date_format( #{entity.endTime},'%Y-%m-%d')]]>
</if>
<if test="submitState == 0">
and instance_id is null
and instance_id is not null
</if>
<if test="submitState == 1">
and instance_id is not null
and instance_id is null
</if>
and del_flag = '0'
</where>
......
......@@ -47,6 +47,13 @@
from school_teacher
</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 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment