|
@@ -11,6 +11,7 @@ import com.dingtalk.api.response.OapiAttendanceListResponse;
|
|
import com.dingtalk.api.response.OapiGettokenResponse;
|
|
import com.dingtalk.api.response.OapiGettokenResponse;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.jeeplus.logging.annotation.ApiLog;
|
|
import com.jeeplus.logging.annotation.ApiLog;
|
|
|
|
+import com.jeeplus.utils.StringUtils;
|
|
import com.taobao.api.ApiException;
|
|
import com.taobao.api.ApiException;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -64,30 +65,34 @@ public class DingdingController {
|
|
throw new RuntimeException("Error converting JSON to Object: " + e.getMessage(), e);
|
|
throw new RuntimeException("Error converting JSON to Object: " + e.getMessage(), e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- @ApiLog("获取考勤列表")
|
|
|
|
- @ApiOperation(value = "获取考勤列表")
|
|
|
|
|
|
+ @ApiLog("获取考勤结果列表")
|
|
|
|
+ @ApiOperation(value = "获取考勤结果列表")
|
|
@GetMapping("getWorkListCord")
|
|
@GetMapping("getWorkListCord")
|
|
- public ResponseEntity getWorkListCord(String userId) {
|
|
|
|
|
|
+ public ResponseEntity getWorkListCord(String userId,String workDateFrom,String workDateTo) {
|
|
// 获取access_token
|
|
// 获取access_token
|
|
String access_token = getToken();
|
|
String access_token = getToken();
|
|
// 通过调用接口获取考勤打卡结果
|
|
// 通过调用接口获取考勤打卡结果
|
|
DingTalkClient clientDingTalkClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/list");
|
|
DingTalkClient clientDingTalkClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/list");
|
|
OapiAttendanceListRequest requestAttendanceListRequest = new OapiAttendanceListRequest();
|
|
OapiAttendanceListRequest requestAttendanceListRequest = new OapiAttendanceListRequest();
|
|
- // 查询考勤打卡记录的起始工作日
|
|
|
|
- LocalDate today = LocalDate.now();
|
|
|
|
|
|
+ if (StringUtils.isBlank(workDateFrom) && StringUtils.isBlank(workDateTo)){
|
|
|
|
+ // 查询考勤打卡记录的起始工作日
|
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
|
|
|
- // 获取上午9点的时间
|
|
|
|
- LocalDateTime morning9 = today.atTime(LocalTime.of(9, 0));
|
|
|
|
|
|
+ // 获取上午9点的时间
|
|
|
|
+ LocalDateTime morning9 = today.atTime(LocalTime.of(9, 0));
|
|
|
|
|
|
- // 获取下午6点的时间
|
|
|
|
- LocalDateTime afternoon6 = today.atTime(LocalTime.of(18, 0));
|
|
|
|
|
|
+ // 获取下午6点的时间
|
|
|
|
+ LocalDateTime afternoon6 = today.atTime(LocalTime.of(18, 0));
|
|
|
|
|
|
- // 定义日期时间格式化器
|
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
+ // 定义日期时间格式化器
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ workDateFrom = morning9.format(formatter);
|
|
|
|
+ workDateTo = afternoon6.format(formatter);
|
|
|
|
+ }
|
|
|
|
|
|
- requestAttendanceListRequest.setWorkDateFrom(morning9.format(formatter));
|
|
|
|
|
|
+ requestAttendanceListRequest.setWorkDateFrom(workDateFrom);
|
|
// 查询考勤打卡记录的结束工作日
|
|
// 查询考勤打卡记录的结束工作日
|
|
- requestAttendanceListRequest.setWorkDateTo(afternoon6.format(formatter));
|
|
|
|
|
|
+ requestAttendanceListRequest.setWorkDateTo(workDateTo);
|
|
// 员工在企业内的userid列表,最多不能超过50个。
|
|
// 员工在企业内的userid列表,最多不能超过50个。
|
|
requestAttendanceListRequest.setUserIdList(Arrays.asList(userId));
|
|
requestAttendanceListRequest.setUserIdList(Arrays.asList(userId));
|
|
// 表示获取考勤数据的起始点
|
|
// 表示获取考勤数据的起始点
|
|
@@ -105,8 +110,8 @@ public class DingdingController {
|
|
return ResponseEntity.ok(response);
|
|
return ResponseEntity.ok(response);
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiLog("获取个人考勤列表")
|
|
|
|
- @ApiOperation(value = "获取个人考勤列表")
|
|
|
|
|
|
+ @ApiLog("获取个人考勤详情")
|
|
|
|
+ @ApiOperation(value = "获取个人考勤详情")
|
|
@GetMapping("getByUserId")
|
|
@GetMapping("getByUserId")
|
|
public ResponseEntity getByUserId(String userId) throws ApiException {
|
|
public ResponseEntity getByUserId(String userId) throws ApiException {
|
|
String access_token = getToken();
|
|
String access_token = getToken();
|