最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Java對接釘釘考勤記錄的完整步驟

 更新時間:2025年10月23日 09:50:07   作者:yfs1024  
這篇文章主要介紹了Java對接釘釘考勤記錄的相關資料,需要的朋友可以參考下

一. 基礎配置

  1. 首先需要創(chuàng)建一個應用

  2. 進入應用中點擊 憑證與基礎信息獲取Client ID (原 AppKey)Client Secret (原 AppSecret)

  3. 修改權限管理中 權限范圍為全部員工, 不然獲取不到數(shù)據(jù)

二. 依賴導入及說明

        <!--
        說明: 下面的兩個釘釘依賴目前來說都需要, 因為新版并沒有完全覆蓋舊版中的功能
        (官方說明: 現(xiàn)狀:舊版服務端API和新版服務端API開放的產品能力不同,即新版服務端API未包含全部的服務端API的產品能力,請根據(jù)實際需求,選擇需要的API接入)
        資料鏈接: https://open.dingtalk.com/document/orgapp/differences-between-server-apis-and-new-server-apis?spm=ding_open_doc.document.0.0.200e2b49DAUrx4

        -->
        <!-- 釘釘新版SDK模塊 -->
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>dingtalk</artifactId>
            <version>2.2.33</version>
        </dependency>

        <!-- 釘釘舊版SDK模塊 -->
        <!--
        對于老版本依賴包目前來說還沒有辦法從中央倉庫拉取(中央倉庫版本過舊), 只能通過jar包手動的安裝到本地或者服務器maven倉庫中
        詳情請見: https://open.dingtalk.com/document/isvapp/download-the-server-side-sdk-2
        下載鏈接: https://open-dev.dingtalk.com/download/openSDK/java?spm=ding_open_doc.document.0.0.2ce83ca70MjetW
        -->
        <dependency>
            <groupId>com.taobao.sdk</groupId>
            <artifactId>taobao-sdk-java-auto</artifactId>
            <version>2025.07.17</version>
        </dependency>

        <!-- 釘釘Stream模塊 用于推送和訂閱消息 -->
        <dependency>
            <groupId>com.dingtalk.open</groupId>
            <artifactId>app-stream-client</artifactId>
            <version>1.3.6</version>
        </dependency>

三. 獲取用戶考勤情況

下面提供了兩種實現(xiàn)方案. 每日統(tǒng)計 和 考勤統(tǒng)計

每日統(tǒng)計: 需要每天上下班的數(shù)據(jù)

考勤統(tǒng)計: 需要本月的指定員工指定時間范圍的考勤統(tǒng)計

注: 對于考勤統(tǒng)計中需要的用戶信息可以參考每日統(tǒng)計

對于已有 用戶名稱只需要獲取userId的情況可以嘗試通過下方接口獲取

0. 搜索用戶userId (通過用戶姓名獲取用戶ID)

接口地址:

https://open.dingtalk.com/document/orgapp/address-book-search-user-id

調試地址:

https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.35c53ca7OHAOZj#/?devType=org&api=contact_1.0%23SearchUser

示例: 搜索姓名為午后的員工
經(jīng)測試該接口模糊匹配存在問題, 建議通過 fullMatchField = 1 精確

每日統(tǒng)計

1. 獲取部門列表

接口地址:

https://open.dingtalk.com/document/orgapp/obtain-the-department-list-v2

調試地址:

https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.7408441ceuCNWZ#/?devType=org&api=dingtalk.oapi.v2.department.listsub

2. 獲取部門的子部門列表

接口地址:

https://open.dingtalk.com/document/orgapp/obtain-a-sub-department-id-list-v2

調試地址:

https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.7408441ceuCNWZ#/?devType=org&api=dingtalk.oapi.v2.department.listsubid

3. 獲取部門用戶userid列表

接口地址:

https://open.dingtalk.com/document/orgapp/query-the-list-of-department-userids

調試地址:

https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.7408441ceuCNWZ#/?devType=org&api=dingtalk.oapi.user.listid

4. 根據(jù)系統(tǒng)中的用戶ID查詢用戶信息

接口地址:

https://open.dingtalk.com/document/orgapp/query-user-details

調試地址:

https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.35c53ca7OHAOZj#/?devType=org&api=dingtalk.oapi.v2.user.get

6. 獲取打卡結果

接口地址:

https://open.dingtalk.com/document/orgapp/open-attendance-clock-in-data

調試地址:
https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.35c53ca7OHAOZj#/?devType=org&api=dingtalk.oapi.attendance.list

7. 獲取打卡詳情

接口地址:

https://open.dingtalk.com/document/orgapp/attendance-clock-in-record-is-open

調試地址:

https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.35c53ca7OHAOZj#/?devType=org&api=dingtalk.oapi.attendance.listRecord

考勤統(tǒng)計(可指定時間范圍)

1. 獲取考勤報表列定義(用于在獲取考勤報表列值制定獲取的數(shù)據(jù)項)

接口地址:

https://open.dingtalk.com/document/orgapp/queries-the-enterprise-attendance-report-column

調試地址:
https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.35c53ca7OHAOZj#/?devType=org&api=dingtalk.oapi.attendance.getattcolumns

2. 獲取考勤報表列值

接口地址:

https://open.dingtalk.com/document/orgapp/queries-the-column-value-of-the-attendance-report

調試地址:

https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.35c53ca7OHAOZj#/?devType=org&api=dingtalk.oapi.attendance.getcolumnval

測試用例

/**
 * @author : Cookie
 * date : 2025/8/8
 */
public class DingDingAPITest {

    private final String appKey = "dingxw1111111kgdb";
    private final String appSecret = "2hN-XXSu7BwpLUSRbvGdeNvEMrfKHjy_1111111111111ThLwYqHFLrL";


    /**
     * 通過appKey和appSecret獲取access_token
     */
    @Test
    public void getAccessTokenTest() {
        try {
            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
            OapiGettokenRequest req = new OapiGettokenRequest();
            req.setAppkey(appKey);
            req.setAppsecret(appSecret);
            req.setHttpMethod("GET");
            OapiGettokenResponse rsp = client.execute(req);
            System.out.println(rsp.getBody());
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }


    /**
     * 獲取部門列表
     */
    @Test
    public void getDepartmentListTest() {
        try {
            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");
            OapiV2DepartmentListsubRequest req = new OapiV2DepartmentListsubRequest();
            OapiV2DepartmentListsubResponse rsp = client.execute(req, "6d5bd176e2fd3e111111149ae4d104");
            System.out.println(rsp.getBody());
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }

    /**
     * 獲取部門的子部門列表
     */
    @Test
    public void getMessageTest() {
        try {
            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsubid");
            OapiV2DepartmentListsubidRequest req = new OapiV2DepartmentListsubidRequest();
            req.setDeptId(664446160L);
            OapiV2DepartmentListsubidResponse rsp = client.execute(req, "6d5bd176e2fd3e111111149ae4d104");
            System.out.println(rsp.getBody());
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }

    /**
     * 獲取部門用戶userid列表
     */
    @Test
    public void userIdList() {
        try {
            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/user/listid");
            OapiUserListidRequest req = new OapiUserListidRequest();
            req.setDeptId(664286346L);
            OapiUserListidResponse rsp = client.execute(req, "6d5bd176e2fd3e111111149ae4d104");
            System.out.println(rsp.getBody());
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }

    /**
     * 根據(jù)系統(tǒng)中的用戶ID查詢用戶信息
     */
    @Test
    public void getUserInfoTest() {
        try {
            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
            OapiV2UserGetRequest req = new OapiV2UserGetRequest();
            req.setUserid("1912096523433372683");
            OapiV2UserGetResponse rsp = client.execute(req, "6d5bd176e2fd3e111111149ae4d104");
            System.out.println(rsp.getBody());
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }

    /**
     * 獲取企業(yè)考勤報表列
     */
    @Test
    public void getAttendanceColumnsTest() {
        try {
            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/getattcolumns");
            OapiAttendanceGetattcolumnsRequest req = new OapiAttendanceGetattcolumnsRequest();
            OapiAttendanceGetattcolumnsResponse rsp = client.execute(req, "6d5bd176e2fd3e111111149ae4d104");
            System.out.println(rsp.getBody());
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }

    /**
     * 獲取考勤報表列定義
     */
    @Test
    public void getAttendanceRecordColumnsTest() {
        try {
            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/getattcolumns");
            OapiAttendanceGetattcolumnsRequest req = new OapiAttendanceGetattcolumnsRequest();
            OapiAttendanceGetattcolumnsResponse rsp = client.execute(req, "6d5bd176e2fd3e111111149ae4d104");
            System.out.println(rsp.getBody());
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }

    /**
     * 指定用戶考勤查詢
     */
    @Test
    public void getAttendanceRecordTest() {
        try {
            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/getcolumnval");
            OapiAttendanceGetcolumnvalRequest req = new OapiAttendanceGetcolumnvalRequest();
            req.setUserid("022762312345635565");
            req.setColumnIdList("281432955,281432956,281432958,281432961");
            req.setFromDate(StringUtils.parseDateTime("2025-07-01 08:00:00"));
            req.setToDate(StringUtils.parseDateTime("2025-07-31 20:00:00"));
            OapiAttendanceGetcolumnvalResponse rsp = client.execute(req, "6d5bd176e2fd3e111111149ae4d104");
            System.out.println(rsp.getBody());
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }

    /**
     * 獲取打卡詳情
     */
    @Test
    public void getCheckinRecordTest() {
        try {
            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/listRecord");
            OapiAttendanceListRecordRequest req = new OapiAttendanceListRecordRequest();
            req.setUserIds(Arrays.asList("4952111165934", "0227623222235565", "0225373333171716"));
            req.setCheckDateFrom("2025-08-14 08:00:00");
            req.setCheckDateTo("2025-08-20 08:00:00");
            OapiAttendanceListRecordResponse rsp = client.execute(req, "6d5bd176e2fd3e111111149ae4d104");
            System.out.println(rsp.getBody());
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }

    /**
     * 釘釘Stream模塊測試
     */
    public static void main(String[] args) throws Exception {

        OpenDingTalkStreamClientBuilder
                .custom()
                .credential(new AuthClientCredential("dingxw1111111kgdb", "2hN-XXSu7BwpLUSRbvGdeNvEMrfKHjy_1111111111111ThLwYqHFLrL"))
                //注冊事件監(jiān)聽
                .registerAllEventListener(new GenericEventListener() {
                    public EventAckStatus onEvent(GenericOpenDingTalkEvent event) {
                        try {
                            //事件唯一Id
                            String eventId = event.getEventId();
                            //事件類型
                            String eventType = event.getEventType();
                            //事件產生時間
                            Long bornTime = event.getEventBornTime();
                            //獲取事件體
                            JSONObject bizData = event.getData();
                            //處理事件
//                                process(bizData);
                            System.out.println(bizData);
                            //消費成功
                            return EventAckStatus.SUCCESS;
                        } catch (Exception e) {
                            //消費失敗
                            return EventAckStatus.LATER;
                        }
                    }
                })
                .build().start();
    }
}

總結 

到此這篇關于Java對接釘釘考勤記錄的文章就介紹到這了,更多相關Java對接釘釘考勤記錄內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • MyBatis圖文并茂講解注解開發(fā)一對一查詢

    MyBatis圖文并茂講解注解開發(fā)一對一查詢

    這篇文章主要介紹了SpringBoot中Mybatis注解一對一查詢的實現(xiàn)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-07-07
  • Java實現(xiàn)經(jīng)典游戲黃金礦工的示例代碼

    Java實現(xiàn)經(jīng)典游戲黃金礦工的示例代碼

    《黃金礦工》游戲是一個經(jīng)典的抓金子小游戲,它可以鍛煉人的反應能力。本文將用Java實現(xiàn)這一經(jīng)典的游戲,感興趣的小伙伴可以了解一下
    2022-02-02
  • Java并發(fā)編程——volatile關鍵字

    Java并發(fā)編程——volatile關鍵字

    這篇文章主要介紹了Java并發(fā)編程——volatile關鍵字的相關資料,幫助大家更好的理解和學習Java并發(fā)編程,感興趣的朋友可以了解下
    2020-10-10
  • 深度解析Spring Bean生命周期以及LomBok插件

    深度解析Spring Bean生命周期以及LomBok插件

    本文詳細介紹了Spring框架中Bean的生命周期,包括核心差異、完整階段拆解、回調方法實現(xiàn)方式及優(yōu)先級,Bean后置處理器的關鍵知識點,并通過實戰(zhàn)測試驗證了整個生命周期流程,感興趣的朋友跟隨小編一起看看吧
    2026-01-01
  • Java實現(xiàn)UTF-8編碼與解碼方式

    Java實現(xiàn)UTF-8編碼與解碼方式

    這篇文章主要介紹了Java實現(xiàn)UTF-8編碼與解碼方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • Jasypt的StandardPBEByteEncryptor使用源碼解析

    Jasypt的StandardPBEByteEncryptor使用源碼解析

    這篇文章主要介紹了Jasypt的StandardPBEByteEncryptor使用源碼解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-09-09
  • Java將json對象轉換為map鍵值對案例詳解

    Java將json對象轉換為map鍵值對案例詳解

    這篇文章主要介紹了Java將json對象轉換為map鍵值對案例詳解,本篇文章通過簡要的案例,講解了該項技術的了解與使用,以下就是詳細內容,需要的朋友可以參考下
    2021-09-09
  • 淺談java反射和自定義注解的綜合應用實例

    淺談java反射和自定義注解的綜合應用實例

    本篇文章主要介紹了java反射和自定義注解的綜合應用,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-09-09
  • Spring AOP之@Around,@AfterReturning使用、切不進去的解決方案

    Spring AOP之@Around,@AfterReturning使用、切不進去的解決方案

    這篇文章主要介紹了Spring AOP之@Around,@AfterReturning使用、切不進去的解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • 深入淺出MappedByteBuffer(推薦)

    深入淺出MappedByteBuffer(推薦)

    MappedByteBuffer使用虛擬內存,因此分配(map)的內存大小不受JVM的-Xmx參數(shù)限制,但是也是有大小限制的,這篇文章主要介紹了MappedByteBuffer的基本知識,需要的朋友可以參考下
    2022-12-12

最新評論

布尔津县| 菏泽市| 舞阳县| 黄大仙区| 孙吴县| 田阳县| 海淀区| 依安县| 宜章县| 马山县| 当雄县| 台北县| 集安市| 勃利县| 含山县| 邵武市| 洛川县| 大同县| 庆安县| 澜沧| 海城市| 桦南县| 金乡县| 喜德县| 武安市| 比如县| 宜都市| 呼图壁县| 太湖县| 鄂伦春自治旗| 红原县| 罗山县| 锡林浩特市| 三河市| 礼泉县| 上杭县| 宁蒗| 新邵县| 阳江市| 明水县| 潼南县|