Forráskód Böngészése

更新并迁移 shennongshi 项目

zhangkan 3 hete%!(EXTRA string=óta)
szülő
commit
d3ab9e67a1

+ 2 - 0
.gitignore

@@ -3,6 +3,8 @@
 *.iml
 out
 gen
+.DS_Store
+target/
 ### Java template
 # Compiled class file
 *.class

+ 3 - 0
pom.xml

@@ -45,6 +45,9 @@
     </repositories>
 
     <dependencies>
+<!--        用友NC-->
+
+
         <dependency>
             <groupId>com.auth0</groupId>
             <artifactId>java-jwt</artifactId>

+ 24 - 1
src/main/java/com/muzhi/shennongshi/controller/AccessTokenController.java

@@ -1,6 +1,7 @@
 package com.muzhi.shennongshi.controller;
 
 import com.muzhi.shennongshi.service.AccessTokenService;
+import com.muzhi.shennongshi.service.impl.AccessTokenServiceImpl;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -9,6 +10,10 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+
 /**
  * @Author ZhangKan
  * @Data 15:03
@@ -23,7 +28,7 @@ public class AccessTokenController {
     @Autowired
     private AccessTokenService AccessTokenService;
 
-    //获取钉钉中的access_token(美犀架构)
+    //获取钉钉中的access_token(神农氏架构)
     @ApiOperation(value = "获取钉钉中的access_token")
     @GetMapping("getAccessToken")
     public String getAccessToken(){
@@ -31,4 +36,22 @@ public class AccessTokenController {
         String accessToken = AccessTokenService.getAccessToken();
         return accessToken;
     }
+
+    //获取access_token的方法(鸿欢接口)
+    @ApiOperation(value = "获取鸿欢接口的access_token")
+    @GetMapping("getHonghuanAccessToken")
+    public String getHonghuanAccessToken(){
+
+        String honghuanAccessToken = AccessTokenService.getHonghuanAccessToken();
+        return honghuanAccessToken;
+    }
+
+    //获取用友NCC的access_token的方法(蓝云)
+    @ApiOperation(value = "获取用友NCC的access_token的方法(蓝云)")
+    @GetMapping("getYYNCCtoken")
+    public String getYYNCCtoken() throws IOException, InvalidKeyException, NoSuchAlgorithmException {
+
+        String yyncCtoken = AccessTokenService.getYYNCCtoken();
+        return yyncCtoken;
+    }
 }

+ 64 - 7
src/main/java/com/muzhi/shennongshi/controller/DingOaController.java

@@ -26,23 +26,31 @@ public class DingOaController {
      */
     @ApiOperation(value = "表单打开时加载(所属主体:改为合同公司)")
     @GetMapping("getSuoshuzhuti")
-//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
-//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
-//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
     public Map getSuoshuzhuti(String userid){
 
         Map suoshuzhuti = dingOaService.getSuoshuzhuti(userid);
         return suoshuzhuti;
     }
 
+    /**
+     * 表单打开时加载(所属公司)
+     */
+    @ApiOperation(value = "表单打开时加载(所属公司)")
+    @GetMapping("getSuoshugongsi")
+    public List getSuoshugongsi(){
+
+        List suoshugongsi = dingOaService.getSuoshugongsi();
+        return suoshugongsi;
+    }
+
     /**
      * 提交审批单后将生效日期等信息写入数据库
      */
     @ApiOperation(value = "提交审批单后将生效日期等信息写入数据库")
     @PostMapping("dateToMySQL")
-    public String dateToMySQL(String userid,String htgsid,String sxrq) throws Exception{
+    public String dateToMySQL(String userid,String htgsid,String sxrq,String type) throws Exception{
 
-        String dateToMySQL = dingOaService.dateToMySQL(userid,htgsid,sxrq);
+        String dateToMySQL = dingOaService.dateToMySQL(userid,htgsid,sxrq,type);
         return dateToMySQL;
     }
 
@@ -77,9 +85,9 @@ public class DingOaController {
     //表单提交时校验(加班)
     @ApiOperation(value = "表单提交时校验(加班)")
     @GetMapping("getJBJY")
-    public Map getJBJY(String ygcj,String sfxjbf,String jbbcfs){
+    public Map getJBJY(String processInstances, String jbbcfs){
 
-        Map jbjy = dingOaService.getJBJY(ygcj,sfxjbf,jbbcfs);
+        Map jbjy = dingOaService.getJBJY(processInstances, jbbcfs);
 
         return jbjy;
     }
@@ -112,6 +120,16 @@ public class DingOaController {
         return revocationProcessInstances;
     }
 
+    //表单提交时校验(请假)
+    @ApiOperation(value = "表单提交时校验(请假)")
+    @GetMapping("getQJJY")
+    public Map getQJJY(String processInstances){
+
+        Map qjjy = dingOaService.getQJJY(processInstances);
+
+        return qjjy;
+    }
+
     //表单提交时校验(部门)
 //    @ApiOperation(value = "表单提交时校验(部门)")
 //    @GetMapping("getBMJY")
@@ -121,4 +139,43 @@ public class DingOaController {
 //
 //        return bmjy;
 //    }
+
+
+
+    //获取钉钉组织架构人员信息-同步至宜搭人员信息表
+    @ApiOperation(value = "获取钉钉组织架构人员信息-同步至宜搭人员信息表")
+    @PostMapping("getRenyuan")
+    @Scheduled(cron = "0 0 20 * * ?")//每天20:00触发(也就是凌晨20点00分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public String getRenyuan(){
+
+        String renyuan = dingOaService.getRenyuan();
+        return renyuan;
+    }
+
+    //获取宜搭人员信息表,更新宜搭人员状态
+    @ApiOperation(value = "获取宜搭人员信息表,更新宜搭人员状态")
+    @PostMapping("getRenyuanStatus")
+    @Scheduled(cron = "0 0 21 * * ?")//每天21:00触发(也就是凌晨22点30分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public String getRenyuanStatus(){
+
+        String renyuanStatus = dingOaService.getRenyuanStatus();
+        return renyuanStatus;
+    }
+
+    //计算同步考勤数据-同步至宜搭应出勤天数表单
+    @ApiOperation(value = "计算同步考勤数据-同步至宜搭应出勤天数表单")
+    @PostMapping("tongbuKaoqin")
+    @Scheduled(cron = "0 0 22 * * ?")//每天22:00触发(也就是凌晨22点00分触发)
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public String tongbuKaoqin(){
+
+        String tongbuKaoqin = dingOaService.tongbuKaoqin();
+        return tongbuKaoqin;
+    }
 }

+ 13 - 1
src/main/java/com/muzhi/shennongshi/service/AccessTokenService.java

@@ -1,11 +1,23 @@
 package com.muzhi.shennongshi.service;
 
+import com.muzhi.shennongshi.service.impl.AccessTokenServiceImpl;
+
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+
 /**
  * @Author ZhangKan
  * @Data 15:34
  */
 public interface AccessTokenService {
 
-    //获取access_token的方法(美邸艾架构)
+    //获取access_token的方法(神农氏架构)
     String getAccessToken();
+
+    //获取access_token的方法(鸿欢接口)
+    String getHonghuanAccessToken();
+
+    //获取用友NCC的access_token的方法(蓝云)
+    String getYYNCCtoken() throws IOException, InvalidKeyException, NoSuchAlgorithmException;
 }

+ 21 - 3
src/main/java/com/muzhi/shennongshi/service/DingOaService.java

@@ -16,13 +16,18 @@ public interface DingOaService {
      */
     Map getSuoshuzhuti(String userid);
 
+    /**
+     * 表单打开时加载(所属公司)
+     */
+    List getSuoshugongsi();
+
     /**
      * 提交审批单后将生效日期等信息写入数据库
      */
-    String dateToMySQL(String userid,String htgsid,String sxrq) throws Exception;
+    String dateToMySQL(String userid,String htgsid,String sxrq,String type) throws Exception;
 
     /**
-     * 表单提交审批通过后反写智能人事花名册更新(所属主体:改为合同公司)
+     * 表单提交审批通过后反写智能人事花名册更新(所属公司)
      */
     R updateSuoshuzhuti() throws Exception;
 
@@ -32,7 +37,7 @@ public interface DingOaService {
     Map getRenyuanleixing(String userid);
 
     //表单提交时校验(加班)
-    Map getJBJY(String ygcj,String sfxjbf,String jbbcfs);
+    Map getJBJY(String processInstances, String jbbcfs);
 
     /**
      * 表单打开时加载(员工假期类型)
@@ -44,6 +49,19 @@ public interface DingOaService {
      */
     R revocationProcessInstances(String processInstances, String userid);//,String ygjqlx,String userid
 
+    //表单提交时校验(请假)
+    Map getQJJY(String processInstances);
+
     //表单提交时校验(部门)
 //    Map getBMJY(String bmid);
+
+
+    //获取钉钉组织架构人员信息-同步至宜搭人员信息表
+    String getRenyuan();
+
+    //获取宜搭人员信息表,更新宜搭人员状态
+    String getRenyuanStatus();
+
+    //计算同步考勤数据-同步至宜搭应出勤天数表单
+    String tongbuKaoqin();
 }

+ 351 - 0
src/main/java/com/muzhi/shennongshi/service/impl/AccessTokenServiceImpl.java

@@ -1,12 +1,40 @@
 package com.muzhi.shennongshi.service.impl;
 
+import cn.hutool.core.lang.TypeReference;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.dingtalk.api.DefaultDingTalkClient;
 import com.dingtalk.api.request.OapiGettokenRequest;
 import com.dingtalk.api.response.OapiGettokenResponse;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import com.muzhi.shennongshi.service.AccessTokenService;
 import com.taobao.api.ApiException;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
+import org.apache.http.client.config.CookieSpecs;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.util.EntityUtils;
 import org.springframework.stereotype.Service;
 
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
 
 /**
  * @Author ZhangKan
@@ -14,6 +42,7 @@ import org.springframework.stereotype.Service;
  */
 
 @Service
+@Slf4j
 public class AccessTokenServiceImpl implements AccessTokenService {
 
     //神农氏
@@ -26,6 +55,16 @@ public class AccessTokenServiceImpl implements AccessTokenService {
     public static String accessToken = null;
 
 
+    //用友NC的应用appKey
+    private String appKey = "1b652f0abdb8452c92fe75841c6ae706";
+    //用友NC的应用密钥
+    private String appSecret = "572be129e35c57d22166f1d9d3d43db2c2ec653a";
+    //用友NC的接口访问主地址
+//    private String openApiUrl = "https://c2.yonyoucloud.com/iuap-api-auth";
+    private String openApiUrl = "http://58.246.128.122:9090/iuap-api-auth";
+//    private String openApiUrl = "http://124.71.130.205:9090/iuap-api-auth";
+
+
     //获取access_token的方法(神农氏架构)
     @Override
     public String getAccessToken() {
@@ -43,4 +82,316 @@ public class AccessTokenServiceImpl implements AccessTokenService {
         }
         return accessToken;
     }
+
+    //获取access_token的方法(鸿欢接口)
+    @Override
+    public String getHonghuanAccessToken() {
+
+        String corpId = "dinge1f03b6df74842ea";
+        String AppId = "10005";
+        String AppSecret = "dIqPwYoLdUuqRsdnKPRLljIFxesmqvcA";
+        Map map = new HashMap();
+        map.put("corpId",corpId);
+        map.put("AppId",AppId);
+        map.put("AppSecret",AppSecret);
+        String mapStr = JSON.toJSONString(map);
+        System.out.println("封装的密钥传参mapStr:" + mapStr);
+
+        int status = 0;
+        JSONObject data = null;
+        try {
+            OkHttpClient client = new OkHttpClient().newBuilder()
+                    .build();
+            MediaType mediaType = MediaType.parse("application/json");
+            RequestBody body = RequestBody.create(mediaType, mapStr);
+            Request request = new Request.Builder()
+                    .url("https://app67443.eapps.dingtalkcloud.com/topapi/open/login/get_token")
+                    .method("POST", body)
+                    .addHeader("Content-Type", "application/json")
+                    .build();
+            okhttp3.Response response = client.newCall(request).execute();
+
+            String bodyStr = response.body().string();
+            JSONObject jsonObject = JSON.parseObject(bodyStr);
+            System.out.println("返回体body:" + jsonObject);
+
+            status = jsonObject.getInteger("status");
+            System.out.println("获取鸿欢授权接口返回状态码:" + status);
+            data = jsonObject.getJSONObject("data");
+            System.out.println("获取鸿欢授权接口返回data:" + data);
+        }catch (IOException e){
+            e.printStackTrace();
+        }
+        String Honghuan_access_token = data.getString("access_token");
+        System.out.println("获取鸿欢授权接口返回的【token】:" + Honghuan_access_token);
+
+        return Honghuan_access_token;
+    }
+
+    /**
+     * 按参数名排序后依次拼接参数名称与数值,之后对该字符串使用 HmacSHA256 加签,加签结果进行 base 64 返回
+     * @param params 请求参数 map
+     * @param suiteSecret 套件密钥,用作 mac key
+     * @return 签名
+     * @throws NoSuchAlgorithmException
+     * @throws UnsupportedEncodingException
+     * @throws InvalidKeyException
+     */
+    public static String sign(Map<String, String> params, String suiteSecret) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
+        // use tree map to sort params by name
+        Map<String, String> treeMap;
+        if (params instanceof TreeMap) {
+            treeMap = params;
+        } else {
+            treeMap = new TreeMap<>(params);
+        }
+
+        StringBuilder stringBuilder = new StringBuilder();
+        for (Map.Entry<String, String> entry : treeMap.entrySet()) {
+            stringBuilder.append(entry.getKey()).append(entry.getValue());
+        }
+
+        Mac mac = Mac.getInstance("HmacSHA256");
+        mac.init(new SecretKeySpec(suiteSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
+        byte[] signData = mac.doFinal(stringBuilder.toString().getBytes(StandardCharsets.UTF_8));
+        String base64String = Base64.getEncoder().encodeToString(signData);
+        return URLEncoder.encode(base64String, "UTF-8");
+    }
+
+
+    private static final String HEADER_CONTENT_JSON = "application/json";
+
+    private static final String DEFAULT_CHARSET = "UTF-8";
+
+    private static PoolingHttpClientConnectionManager cm = null;
+
+    private static CloseableHttpClient httpClient;
+
+    /**
+     * 记录开放平台请求结果
+     */
+    public static class Response {
+        /**
+         * 该请求的 http 状态码
+         * 200 为正常的返回结果
+         */
+        private int status;
+
+        /**
+         * 请求返回消息
+         * 当 status == 200 时会返回 response body 中的字符串
+         * 当 status !== 200 时会返回具体的错误信息
+         */
+        private String result;
+
+        public int getStatus() {
+            return status;
+        }
+
+        public void setStatus(int status) {
+            this.status = status;
+        }
+
+        public String getResult() {
+            return result;
+        }
+
+        public void setResult(String result) {
+            this.result = result;
+        }
+    }
+
+    static{
+        cm = new PoolingHttpClientConnectionManager();
+        cm.setMaxTotal(500);
+        cm.setDefaultMaxPerRoute(50);
+
+        RequestConfig globalConfig = RequestConfig.custom()
+                .setConnectionRequestTimeout(1000)         // 连接池获取连接超时
+                .setConnectTimeout(1000)                   // 连接建立超时
+                .setSocketTimeout(5000)                    // 等待响应超时
+                .setCookieSpec(CookieSpecs.IGNORE_COOKIES)
+                .build();
+
+        httpClient = HttpClients.custom().setConnectionManager(cm).setDefaultRequestConfig(globalConfig).build();
+    }
+
+    private static CloseableHttpClient getHttpClient(){
+        return httpClient;
+    }
+
+    public static String doGet(String requestUrl, Map<String, String> paramMap) throws IOException {
+        CloseableHttpClient httpClient = getHttpClient();
+        StringBuilder param = new StringBuilder("?");
+        if (paramMap != null) {
+            for(Map.Entry<String, String> entry: paramMap.entrySet()) {
+                param.append(entry.getKey());
+                param.append("=");
+                param.append(entry.getValue());
+                param.append("&");
+            }
+            param.deleteCharAt(param.length() - 1);
+        }
+
+        HttpGet get = new HttpGet(requestUrl + param);
+        String responseString = httpClient.execute(get, response -> EntityUtils.toString(response.getEntity()));
+        get.releaseConnection();
+        return responseString;
+    }
+
+    public class AccessTokenResponse {
+
+        /**
+         * 获取的访问令牌 access_token
+         */
+        @JsonProperty(value = "access_token")
+        private String accessToken;
+
+        /**
+         * 访问令牌的过期时间,单位秒
+         */
+        private long expire;
+
+        public String getAccessToken() {
+            return accessToken;
+        }
+
+        public void setAccessToken(String accessToken) {
+            this.accessToken = accessToken;
+        }
+
+        public long getExpire() {
+            return expire;
+        }
+
+        public void setExpire(long expire) {
+            this.expire = expire;
+        }
+    }
+
+    /**
+     * 开放平台接口响应,
+     *
+     * json 定义:
+     *
+     * <pre>
+     * {
+     *     "code": "00000",
+     *     "message": "成功!",
+     *     "data": {}
+     * }
+     * </pre>
+     *
+     * 请根据 {@code code} 判断是否请求成功,若 {@code code} 为 {@code "00000"} 则请求成功,请求数据在 {@code data} 中;
+     * 若请求失败,{@code message} 中有详细错误信息,此时 {@code data} 字段不存在。
+     *
+     * @param <T> 具体业务数据
+     */
+    @JsonInclude(JsonInclude.Include.NON_NULL)
+    public class GenericResponse<T> {
+
+        public static final String SUCCESS_CODE = "00000";
+
+        private String code;
+
+        private String message;
+
+        private T data;
+
+        public boolean isSuccess() {
+            return SUCCESS_CODE.equals(code);
+        }
+
+        public String getCode() {
+            return code;
+        }
+
+        public void setCode(String code) {
+            this.code = code;
+        }
+
+        public String getMessage() {
+            return message;
+        }
+
+        public void setMessage(String message) {
+            this.message = message;
+        }
+
+        public T getData() {
+            return data;
+        }
+
+        public void setData(T data) {
+            this.data = data;
+        }
+    }
+
+    //获取用友NCC的access_token的方法(蓝云)
+    @Override
+    public String getYYNCCtoken() throws IOException, InvalidKeyException, NoSuchAlgorithmException {
+
+        // 封装请求参数(appKey、timestamp)
+        Map<String, String> params = new HashMap<>();
+        // 除签名外的其他参数
+        params.put("appKey", appKey);
+        params.put("timestamp", String.valueOf(System.currentTimeMillis()));
+        // 计算签名
+        String signature = sign(params, appSecret);
+        params.put("signature", signature);
+
+        String timestamp = params.get("timestamp");
+        System.out.println("timestamp时间戳:" + timestamp);
+        System.out.println("signature签名:" + signature);
+
+        // 请求/iuap-api-auth/open-auth/selfAppAuth/base/v1/getAccessToken
+//        String requestUrl = openApiUrl + "/open-auth/selfAppAuth/getAccessToken";
+        String requestUrl = openApiUrl + "/open-auth/selfAppAuth/base/v1/getAccessToken";
+        System.out.println("requestUrl授权码接口地址:" + requestUrl);
+
+        String code = null;
+        String message = null;
+        JSONObject jsonObject = null;
+        try {
+            OkHttpClient client = new OkHttpClient().newBuilder()
+                    .build();
+            MediaType mediaType = MediaType.parse("text/plain");
+            RequestBody body = RequestBody.create(mediaType, "");
+            Request request = new Request.Builder()
+                    .url(requestUrl + "?appKey=" + appKey + "&timestamp=" + timestamp + "&signature=" + signature)
+                    .method("GET", null)
+                    .addHeader("Cookie", "acw_tc=276077c717061481038585019e90abde8fe73d9ae0af556c25000830f8cbca")
+                    .build();
+            okhttp3.Response response = client.newCall(request).execute();
+            String bodyStr = response.body().string();
+            jsonObject = JSON.parseObject(bodyStr);
+            System.out.println("返回体body:" + jsonObject);
+            code = jsonObject.getString("code");
+            message = jsonObject.getString("message");
+        }catch (IOException e){
+            e.printStackTrace();
+        }
+        System.out.println("查询【用友NC授权token】,接口返回的状态码(成功返回00000):" + code + ",结果信息:" + message);
+
+        String token = null;
+        if (!code.equals("00000")){
+            System.out.println("其他异常返回结果:" + jsonObject);
+        }else {
+            System.out.println("接口正常返回:" + jsonObject);
+
+            JSONObject jsonObject1 = jsonObject.getJSONObject("data");
+            token = jsonObject1.getString("access_token");
+        }
+
+        return token;
+
+//        GenericResponse<AccessTokenResponse> response = doGet(requestUrl, params, new TypeReference<GenericResponse<AccessTokenResponse>>() {});
+//
+//        if (response.isSuccess()) {
+//            return response.getData();
+//        }
+//
+//        log.error("请求开放平台接口失败,code: {}, message: {}", response.getCode(), response.getMessage());
+//        throw new RuntimeException("请求开放平台接口失败, code: " + response.getCode() + ", message: " + response.getMessage());
+    }
 }

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1573 - 51
src/main/java/com/muzhi/shennongshi/service/impl/DingOaServiceImpl.java


+ 853 - 2
src/test/java/com/muzhi/shennongshi/APITest/Test1.java

@@ -2,16 +2,36 @@ package com.muzhi.shennongshi.APITest;
 
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.aliyun.dingtalkhrm_1_0.models.QueryHrmEmployeeDismissionInfoResponse;
+import com.aliyun.dingtalkyida_1_0.models.CreateOrUpdateFormDataResponse;
+import com.aliyun.dingtalkyida_1_0.models.SearchFormDatasResponse;
+import com.aliyun.tea.TeaException;
+import com.aliyun.teautil.models.RuntimeOptions;
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.dingtalk.api.DefaultDingTalkClient;
+import com.dingtalk.api.DingTalkClient;
+import com.dingtalk.api.request.OapiAttendanceGetcolumnvalRequest;
+import com.dingtalk.api.response.OapiAttendanceGetcolumnvalResponse;
 import com.muzhi.shennongshi.service.AccessTokenService;
+import com.taobao.api.ApiException;
+import com.taobao.api.internal.util.StringUtils;
 import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
 import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
+import javax.crypto.Mac;
+import java.io.IOException;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
+import java.util.*;
 
 @SpringBootTest
 @Slf4j
@@ -214,4 +234,835 @@ public class Test1 {
 //        //4364bbbc-3480-4cf2-a6c6-2e5a42635892
 //        //1672913268514
 //    }
+
+
+    //宜搭接口调用
+    public static com.aliyun.dingtalkyida_1_0.Client createClient2() throws Exception {
+        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
+        config.protocol = "https";
+        config.regionId = "central";
+        return new com.aliyun.dingtalkyida_1_0.Client(config);
+    }
+
+    //钉钉接口调用
+    public static com.aliyun.dingtalkhrm_1_0.Client createClient() throws Exception {
+        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
+        config.protocol = "https";
+        config.regionId = "central";
+        return new com.aliyun.dingtalkhrm_1_0.Client(config);
+    }
+
+
+    //获取宜搭表单数据【人员信息底表】
+    @Test
+    public void getYidaRenyuanxinxidibiao(){
+
+        JSONObject jsonObject = null;
+
+        int size = 100;
+        int page = 1;
+
+        List listAll = new ArrayList();
+
+        do {
+
+            //【神农氏架构】
+            try {
+                com.aliyun.dingtalkyida_1_0.Client client = createClient2();
+                com.aliyun.dingtalkyida_1_0.models.SearchFormDatasHeaders searchFormDatasHeaders = new com.aliyun.dingtalkyida_1_0.models.SearchFormDatasHeaders();
+                searchFormDatasHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
+                com.aliyun.dingtalkyida_1_0.models.SearchFormDatasRequest searchFormDatasRequest = new com.aliyun.dingtalkyida_1_0.models.SearchFormDatasRequest()
+                        .setSystemToken("LO966L91E3JG3VA0BAE2Z6F75BYV2RBPPRQPL5")
+//                        .setSearchFieldJson(mapAllStr)
+                        .setCurrentPage(page)
+                        .setPageSize(size)
+                        .setFormUuid("FORM-06C1245BFC21473690EF3528C7111F64V1YO")
+                        .setUserId("yida_pub_account")
+                        .setAppType("APP_KLB0U4PB8MELVV1R5LSX");
+
+                SearchFormDatasResponse searchFormDatasResponse = client.searchFormDatasWithOptions(searchFormDatasRequest, searchFormDatasHeaders, new RuntimeOptions());
+//                System.out.println(JSON.toJSONString(searchFormDatasResponse.getBody()));
+                String s = JSON.toJSONString(searchFormDatasResponse.getBody());
+                jsonObject = JSON.parseObject(s);
+//                System.out.println("宜搭数据高级条件查询【人员信息底表】接口object对象:" + jsonObject);
+            } catch (TeaException err) {
+                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+                }
+
+            } catch (Exception _err) {
+                TeaException err = new TeaException(_err.getMessage(), _err);
+                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+                }
+
+            }
+
+            JSONArray data = jsonObject.getJSONArray("data");
+//            System.out.println("返回的宜搭data:" + data);
+
+            if (data.isEmpty()) {
+                System.out.println("查询【人员信息底表】返回数据为空!");
+            } else {
+                for (int i = 0; i < data.size(); i++) {
+                    JSONObject formData = data.getJSONObject(i).getJSONObject("formData");
+                    Map map = new HashMap<>();
+
+                    //实例ID
+                    String shiliID = data.getJSONObject(i).getString("formInstanceId");
+                    System.out.println("实例ID===>" + shiliID);
+
+                    //钉钉userid
+                    String userid = formData.getString("textField_lkkg5ay7");
+                    System.out.println("钉钉userid===>" + userid);
+                    //人员姓名
+                    String username = formData.getString("textField_lkkdkp5m");
+                    System.out.println("人员姓名===>" + username);
+                    //主部门
+                    String zhubumen = formData.getString("textField_lm64k9gb");
+                    System.out.println("主部门===>" + zhubumen);
+
+
+                    map.put("shiliID",shiliID);
+
+                    map.put("userid",userid);
+                    map.put("username",username);
+                    map.put("zhubumen",zhubumen);
+
+                    listAll.add(map);
+                }
+            }
+
+            if (jsonObject.getFloat("totalCount") / 100 > jsonObject.getInteger("currentPage")){
+                page = page + 1;
+                System.out.println("下一次待查询分页:" + page);
+            }
+
+        }while (jsonObject.getFloat("totalCount") / 100 > jsonObject.getInteger("currentPage"));
+
+        JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(listAll));
+        System.out.println("封装【人员信息底表】明细jsonArray:" + jsonArray);
+
+//        return jsonArray;
+    }
+
+
+    @Test
+    public void time(){
+
+        //获取当前时间
+        Date Date = new Date(System.currentTimeMillis());
+        System.out.println("当前时间:" + Date);
+
+        String lastMonthNow = null;
+        //本月
+        //截取当天本月的年月
+        Calendar calendar123 = Calendar.getInstance();
+        calendar123.setTime(Date);
+        calendar123.add(Calendar.MONTH,0);
+        lastMonthNow = new SimpleDateFormat("yyyy-MM").format(calendar123.getTime());
+        System.out.println("当天本月的日期,文本格式(月)" + lastMonthNow);
+
+        //将当前月份转换成毫秒级时间戳
+        long lastMonthNowTime = 0;
+        try {
+            lastMonthNowTime = new SimpleDateFormat("yyyy-MM").parse(lastMonthNow).getTime();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        System.out.println("当前月份时间戳:" + lastMonthNowTime);
+
+    }
+
+    //获取考勤
+    @Test
+    public void getKaoqin(){
+
+        String userId = "206703181036284980";
+
+        /*计算规则*/
+        String FORMtime = null;
+        String TOtime = null;
+
+
+        //获取当前时间
+        Date Date = new Date(System.currentTimeMillis());
+        System.out.println("当前时间:" + Date);
+        /*
+         * 获取本月的第一天和最后一天的时间
+         * */
+        Calendar calendar111 = Calendar.getInstance();
+        calendar111.setTime(Date);
+        //本月第一天
+        calendar111.add(Calendar.MONTH,0);
+        calendar111.set(Calendar.DAY_OF_MONTH,1);
+        calendar111.set(Calendar.HOUR_OF_DAY,0);
+        calendar111.set(Calendar.MINUTE,0);
+        calendar111.set(Calendar.SECOND,0);
+        calendar111.set(Calendar.MILLISECOND,0);
+        FORMtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar111.getTime());
+        System.out.println("本月第一天零点:" + FORMtime);
+
+        Calendar calendar222 = Calendar.getInstance();
+//                int month222 = calendar222.get(Calendar.MONTH);
+        //本月最后一天
+        calendar222.add(Calendar.MONTH,0);
+        calendar222.set(Calendar.DAY_OF_MONTH,calendar222.getActualMaximum(Calendar.DAY_OF_MONTH));
+        calendar222.set(Calendar.HOUR_OF_DAY,0);
+        calendar222.set(Calendar.MINUTE,0);
+        calendar222.set(Calendar.SECOND,0);
+        calendar222.set(Calendar.MILLISECOND,0);
+        TOtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar222.getTime());
+        System.out.println("本月最后一天零点:" + TOtime);
+
+
+        FORMtime = "2024-03-01 00:00:00";
+        TOtime = "2024-03-31 00:00:00";
+
+
+        float chuqintianshu = 0;
+        float yingchuqintianshu = 0;
+
+        //查询上月出勤数据,统计上月应出勤天数
+        try {
+            DingTalkClient client11 = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/getcolumnval");
+            OapiAttendanceGetcolumnvalRequest req = new OapiAttendanceGetcolumnvalRequest();
+            //TODO 待查询人员的userid
+            req.setUserid(userId);
+            //考勤报表列定义查出来的工作时长的列id(固定)
+            req.setColumnIdList("140064190,140064193");
+            //TODO 查询开始时间
+            req.setFromDate(StringUtils.parseDateTime(FORMtime));
+            //TODO 查询结束时间
+            req.setToDate(StringUtils.parseDateTime(TOtime));
+            OapiAttendanceGetcolumnvalResponse rsp = client11.execute(req, accessTokenService.getAccessToken());
+            System.out.println("钉钉月度考勤报表接口返回信息:" + rsp.getBody());
+            String string = rsp.getBody();
+            JSONObject jsonObjectKaoqin = JSON.parseObject(string);
+
+            int errcode = jsonObjectKaoqin.getInteger("errcode");
+            System.out.println("考勤时间周期查询结果状态码:" + errcode);
+            String errmsg = jsonObjectKaoqin.getString("errmsg");
+            System.out.println("考勤时间周期查询结果状态信息:" + errmsg);
+
+
+            if (errcode != 0){
+                log.info("考勤时间周期查询结果反馈异常,异常状态码:" + errcode + "【"+ errmsg +"】");
+
+            }else {
+                //应出勤天数
+                JSONArray jsonArray1 = jsonObjectKaoqin.getJSONObject("result").
+                        getJSONArray("column_vals").
+                        getJSONObject(0).
+                        getJSONArray("column_vals");
+                for (int x = 0; x<jsonArray1.size(); x++){
+                    //应出勤天数
+                    String value = jsonArray1.getJSONObject(x).getString("value");
+                    System.out.println("【钉钉月度报表返回】应出勤天数:" + value);
+                    float v = Float.parseFloat(value);
+                    if (v > 0) {
+                        System.out.println("应出勤天数,进行循环统计!");
+                        yingchuqintianshu = yingchuqintianshu + 1;
+                    }
+                }
+
+                //出勤天数
+                JSONArray jsonArray = jsonObjectKaoqin.getJSONObject("result").
+                        getJSONArray("column_vals").
+                        getJSONObject(1).
+                        getJSONArray("column_vals");
+                for (int x = 0; x<jsonArray.size(); x++){
+                    //出勤天数
+                    String value = jsonArray.getJSONObject(x).getString("value");
+                    System.out.println("【钉钉月度报表返回】出勤天数:" + value);
+                    float v = Float.parseFloat(value);
+                    if (v > 0) {
+                        System.out.println("出勤天数,进行循环统计!");
+                        chuqintianshu = chuqintianshu + 1;
+                    }
+                }
+            }
+
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+
+        System.out.println("本月当前应出勤天数:" + yingchuqintianshu);
+        System.out.println("本月当前实际出勤天数:" + chuqintianshu);
+    }
+
+    //获取节假日假期表
+    @Test
+    public void getJiaqi(){
+
+//        //获取当前时间
+//        Date Date = new Date(System.currentTimeMillis());
+//        System.out.println("当前时间:" + Date);
+//        //截取当天本月的年月
+//        Calendar calendar123 = Calendar.getInstance();
+//        calendar123.setTime(Date);
+//        calendar123.add(Calendar.MONTH,0);
+//        String lastYearNow = new SimpleDateFormat("yyyy").format(calendar123.getTime());
+//        System.out.println("当天本月的日期,文本格式(月)" + lastYearNow);
+//
+//        //封装根据当前年份作为查询条件
+//        Map mapAll = new HashMap();
+//        //查询实际统计月份
+//        mapAll.put("textField_lfw815u7",lastYearNow);
+//
+//        String mapAllStr = JSON.toJSONString(mapAll);
+//        System.out.println("封装修改的字段参数:" + mapAllStr);
+
+        JSONObject jsonObject = null;
+
+        int size = 100;
+        int page = 1;
+
+        List listAll = new ArrayList();
+
+        do {
+
+            //【神农氏架构】
+            try {
+                com.aliyun.dingtalkyida_1_0.Client client = createClient2();
+                com.aliyun.dingtalkyida_1_0.models.SearchFormDatasHeaders searchFormDatasHeaders = new com.aliyun.dingtalkyida_1_0.models.SearchFormDatasHeaders();
+                searchFormDatasHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
+                com.aliyun.dingtalkyida_1_0.models.SearchFormDatasRequest searchFormDatasRequest = new com.aliyun.dingtalkyida_1_0.models.SearchFormDatasRequest()
+                        .setSystemToken("LO966L91E3JG3VA0BAE2Z6F75BYV2RBPPRQPL5")
+//                        .setSearchFieldJson(mapAllStr)
+                        .setCurrentPage(page)
+                        .setPageSize(size)
+                        .setFormUuid("FORM-4226FF0F9E164EA7A85E143CBE57172BP63G")
+                        .setUserId("yida_pub_account")
+                        .setAppType("APP_KLB0U4PB8MELVV1R5LSX");
+
+                SearchFormDatasResponse searchFormDatasResponse = client.searchFormDatasWithOptions(searchFormDatasRequest, searchFormDatasHeaders, new RuntimeOptions());
+//                System.out.println(JSON.toJSONString(searchFormDatasResponse.getBody()));
+                String s = JSON.toJSONString(searchFormDatasResponse.getBody());
+                jsonObject = JSON.parseObject(s);
+//                System.out.println("钉钉宜搭数据高级条件查询【节假日假期表】接口object对象:" + jsonObject);
+            } catch (TeaException err) {
+                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+                }
+
+            } catch (Exception _err) {
+                TeaException err = new TeaException(_err.getMessage(), _err);
+                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+                }
+
+            }
+
+            JSONArray data = jsonObject.getJSONArray("data");
+//            System.out.println("返回的宜搭data:" + data);
+
+
+            if (data.isEmpty()) {
+                System.out.println("查询【节假日假期表】返回数据为空!");
+            } else {
+                for (int i = 0; i < data.size(); i++) {
+                    JSONObject formData = data.getJSONObject(i).getJSONObject("formData");
+//                    System.out.println("循环返回的宜搭formData:" + formData);
+                    Map map = new HashMap<>();
+
+                    //实例ID
+                    String shiliID = data.getJSONObject(i).getString("formInstanceId");
+                    System.out.println("实例ID===>" + shiliID);
+
+                    //年份
+                    String year = formData.getString("dateField_lqaqhdcq");
+                    System.out.println("年份===>" + year);
+                    //假期名称
+                    String name = formData.getString("textField_lprq5uv7");
+                    System.out.println("假期名称===>" + name);
+                    //假期日期
+                    String time = formData.getString("dateField_lprq5uv8");
+                    System.out.println("假期日期===>" + time);
+
+
+                    map.put("shiliID",shiliID);
+
+                    map.put("year",year);
+                    map.put("name",name);
+                    map.put("time",time);
+
+                    System.out.println("每次封装节假日假期信息的map:" + map);
+
+                    listAll.add(map);
+                }
+            }
+
+            if (jsonObject.getFloat("totalCount") / 100 > jsonObject.getInteger("currentPage")){
+                page = page + 1;
+                System.out.println("下一次待查询分页:" + page);
+            }
+
+        }while (jsonObject.getFloat("totalCount") / 100 > jsonObject.getInteger("currentPage"));
+
+        JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(listAll));
+        System.out.println("封装【节假日假期表】明细jsonArray:" + jsonArray);
+
+        String jiabanshijian = "2024-05-04 15:39";
+        String substring = jiabanshijian.substring(0, 10);
+        System.out.println("截取后的加班时间:" + substring);
+
+        //调用封装方法,获取【节假日假期】
+//        JSONArray jiaqi = getJiaqi();
+        for (int k = 0; k < jsonArray.size(); k++) {
+            JSONObject jsonObject1 = jsonArray.getJSONObject(k);
+            String name = jsonObject1.getString("name");
+            System.out.println("循环获取的节假日假期名称:" + name);
+            long time = jsonObject1.getLong("time");
+            System.out.println("循环获取的节假日假期[long型]:" + time);
+
+            //转换成时间格式
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 设置要输出的日期时间格式
+            String formattedDateTime = sdf.format(new Date(time)); // 进行格式化操作
+            System.out.println("转换成时间格式:" + formattedDateTime);
+
+            if (formattedDateTime.equals(substring)){
+                log.info("请假日期和当前循环到的假期匹配!!!");
+            }
+        }
+
+//        return jsonArray;
+    }
+
+    //获取假期规则配置【请假规则】
+    @Test
+    public void getQingjiaGuize(){
+
+        String ygjqlx = "兼职";
+
+        //封装根据当前年份作为查询条件
+        Map mapAll = new HashMap();
+        //查询实际统计月份
+        mapAll.put("checkboxField_lqaxex6p",ygjqlx);
+
+        String mapAllStr = JSON.toJSONString(mapAll);
+        System.out.println("封装修改的字段参数:" + mapAllStr);
+
+        JSONObject jsonObject = null;
+
+        int size = 100;
+        int page = 1;
+
+        List listAll = new ArrayList();
+
+        do {
+
+            //【神农氏架构】
+            try {
+                com.aliyun.dingtalkyida_1_0.Client client = createClient2();
+                com.aliyun.dingtalkyida_1_0.models.SearchFormDatasHeaders searchFormDatasHeaders = new com.aliyun.dingtalkyida_1_0.models.SearchFormDatasHeaders();
+                searchFormDatasHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
+                com.aliyun.dingtalkyida_1_0.models.SearchFormDatasRequest searchFormDatasRequest = new com.aliyun.dingtalkyida_1_0.models.SearchFormDatasRequest()
+                        .setSystemToken("LO966L91E3JG3VA0BAE2Z6F75BYV2RBPPRQPL5")
+                        .setSearchFieldJson(mapAllStr)
+                        .setCurrentPage(page)
+                        .setPageSize(size)
+                        .setFormUuid("FORM-A0DCD4AE4645437BB4614A6B2B033BFDT9T1")
+                        .setUserId("yida_pub_account")
+                        .setAppType("APP_KLB0U4PB8MELVV1R5LSX");
+
+                SearchFormDatasResponse searchFormDatasResponse = client.searchFormDatasWithOptions(searchFormDatasRequest, searchFormDatasHeaders, new RuntimeOptions());
+//                System.out.println(JSON.toJSONString(searchFormDatasResponse.getBody()));
+                String s = JSON.toJSONString(searchFormDatasResponse.getBody());
+                jsonObject = JSON.parseObject(s);
+//                System.out.println("钉钉宜搭数据高级条件查询【请假规则表】接口object对象:" + jsonObject);
+            } catch (TeaException err) {
+                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+                }
+
+            } catch (Exception _err) {
+                TeaException err = new TeaException(_err.getMessage(), _err);
+                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+                }
+
+            }
+
+            JSONArray data = jsonObject.getJSONArray("data");
+//            System.out.println("返回的宜搭data:" + data);
+
+
+            if (data.isEmpty()) {
+                System.out.println("查询【请假规则表】返回数据为空!");
+            } else {
+                for (int i = 0; i < data.size(); i++) {
+                    JSONObject formData = data.getJSONObject(i).getJSONObject("formData");
+//                    System.out.println("循环返回的宜搭formData:" + formData);
+                    Map map = new HashMap<>();
+
+                    //实例ID
+                    String shiliID = data.getJSONObject(i).getString("formInstanceId");
+                    System.out.println("实例ID===>" + shiliID);
+
+                    //员工假期类型
+                    String yuangongjiaqileixing = formData.getString("checkboxField_lqaxex6p");
+                    System.out.println("员工假期类型===>" + yuangongjiaqileixing);
+                    //假期类型
+                    String jiaqileixing = formData.getString("checkboxField_lqaxex6s");
+                    System.out.println("假期类型===>" + jiaqileixing);
+
+
+                    map.put("shiliID",shiliID);
+
+                    map.put("yuangongjiaqileixing",yuangongjiaqileixing);
+                    map.put("jiaqileixing",jiaqileixing);
+
+                    System.out.println("每次封装请假规则信息的map:" + map);
+
+                    listAll.add(map);
+                }
+            }
+
+            if (jsonObject.getFloat("totalCount") / 100 > jsonObject.getInteger("currentPage")){
+                page = page + 1;
+                System.out.println("下一次待查询分页:" + page);
+            }
+
+        }while (jsonObject.getFloat("totalCount") / 100 > jsonObject.getInteger("currentPage"));
+
+        JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(listAll));
+        System.out.println("封装【请假规则表】明细jsonArray:" + jsonArray);
+
+        for (int i = 0; i < jsonArray.size(); i++) {
+            JSONObject jsonObject1 = jsonArray.getJSONObject(i);
+            String jiaqileixing = jsonObject1.getString("jiaqileixing");
+            JSONArray jiaqileixingArray = JSON.parseArray(jiaqileixing);
+            System.out.println("该类型员工可请假类型:" + jiaqileixingArray);
+            for (int j = 0; j < jiaqileixingArray.size(); j++) {
+                String string = jiaqileixingArray.getString(j);
+                System.out.println("循环获取请假类型:" + string);
+            }
+        }
+
+//        return jsonArray;
+    }
+
+    //批量获取离职人员信息
+    @Test
+    public void getLizhiRenyuan(){
+
+        String userId = "10412065201994340688";
+
+        JSONObject jsonObject = null;
+        try {
+            com.aliyun.dingtalkhrm_1_0.Client client = createClient();
+            com.aliyun.dingtalkhrm_1_0.models.QueryHrmEmployeeDismissionInfoHeaders queryHrmEmployeeDismissionInfoHeaders = new com.aliyun.dingtalkhrm_1_0.models.QueryHrmEmployeeDismissionInfoHeaders();
+            queryHrmEmployeeDismissionInfoHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
+            com.aliyun.dingtalkhrm_1_0.models.QueryHrmEmployeeDismissionInfoRequest queryHrmEmployeeDismissionInfoRequest = new com.aliyun.dingtalkhrm_1_0.models.QueryHrmEmployeeDismissionInfoRequest()
+                    .setUserIdList(java.util.Arrays.asList(userId));
+
+            QueryHrmEmployeeDismissionInfoResponse queryHrmEmployeeDismissionInfoResponse = client.queryHrmEmployeeDismissionInfoWithOptions(queryHrmEmployeeDismissionInfoRequest, queryHrmEmployeeDismissionInfoHeaders, new RuntimeOptions());
+            String s = JSON.toJSONString(queryHrmEmployeeDismissionInfoResponse.getBody());
+            jsonObject = JSON.parseObject(s);
+            System.out.println("批量获取离职人员信息:" + jsonObject);
+        } catch (TeaException err) {
+            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                // err 中含有 code 和 message 属性,可帮助开发定位问题
+            }
+
+        } catch (Exception _err) {
+            TeaException err = new TeaException(_err.getMessage(), _err);
+            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                // err 中含有 code 和 message 属性,可帮助开发定位问题
+            }
+
+        }
+
+        String status = "0";
+        //员工状态:1:待离职。2:已离职。3:非待离职或非已离职。4:已提交离职审批单,审批单暂未通过。
+        JSONArray jsonArray = jsonObject.getJSONArray("result");
+        if (!jsonArray.isEmpty()){
+            status = jsonArray.getJSONObject(0).getString("status");
+        }
+        System.out.println("员工状态【1:待离职。2:已离职。3:非待离职或非已离职。4:已提交离职审批单,审批单暂未通过。】:" + status);
+
+//        if (!status.equals("2")){
+//            System.out.println("该员工未离职,【更新】当前宜搭应出勤天数!");
+//        }else {
+//            System.out.println("该员工已离职,宜搭应出勤天数【不作更新】!");
+//        }
+
+        //判断宜搭人员信息表是否有当前人员userid
+        /*同步至宜搭*/
+        Map map = new HashMap();
+        //员工
+        map.put("employeeField_ljm75t23", userId);
+        //状态
+        if (status.equals("2")) {
+            log.info("该员工已离职,记录【已离职】状态!");
+            map.put("selectField_lrecgsfy","已离职");
+        }else {
+            log.info("该员工未离职,记录【在职】状态!");
+            map.put("selectField_lrecgsfy","在职");
+        }
+
+        //钉钉userid
+        map.put("textField_lkkg5ay7", userId);
+//        //姓名
+//        map.put("textField_lkkdkp5m", "");
+//        //主部门
+//        map.put("textField_lm64k9gb", "");
+
+        String mapJson = JSON.toJSONString(map);
+        System.out.println("mapJson:" + mapJson);
+
+        //宜搭表单判断查询条件
+        Map map1 = new HashMap();
+        //字段编号
+        map1.put("key", "textField_lkkg5ay7");
+        //同步类型
+        map1.put("value", userId);
+        //控件类型
+        map1.put("type", "TEXT");
+        //逻辑判断符
+        map1.put("operator", "eq");
+        //控件名称
+        map1.put("componentName", "TextField");
+
+        List list11 = new ArrayList();
+        list11.add(map1);
+
+        String listJson = JSON.toJSONString(list11);
+        System.out.println("查询条件listJson:" + listJson);
+
+
+        //新增或更新表单实例【宜搭】
+        try {
+            com.aliyun.dingtalkyida_1_0.Client client11 = createClient2();
+            com.aliyun.dingtalkyida_1_0.models.CreateOrUpdateFormDataHeaders createOrUpdateFormDataHeaders = new com.aliyun.dingtalkyida_1_0.models.CreateOrUpdateFormDataHeaders();
+            createOrUpdateFormDataHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
+            com.aliyun.dingtalkyida_1_0.models.CreateOrUpdateFormDataRequest createOrUpdateFormDataRequest = new com.aliyun.dingtalkyida_1_0.models.CreateOrUpdateFormDataRequest()
+                    //应用秘钥
+                    .setSystemToken("LO966L91E3JG3VA0BAE2Z6F75BYV2RBPPRQPL5")
+                    //表单编码
+                    .setFormUuid("FORM-06C1245BFC21473690EF3528C7111F64V1YO")
+                    .setUserId("yida_pub_account")
+                    .setSearchCondition(listJson)
+                    //应用编码
+                    .setAppType("APP_KLB0U4PB8MELVV1R5LSX")
+                    .setFormDataJson(mapJson);
+
+            CreateOrUpdateFormDataResponse orUpdateFormDataWithOptions = client11.createOrUpdateFormDataWithOptions(createOrUpdateFormDataRequest, createOrUpdateFormDataHeaders, new RuntimeOptions());
+            String s = JSON.toJSONString(orUpdateFormDataWithOptions.getBody());
+            jsonObject = JSON.parseObject(s);
+            System.out.println("【创建或更新】表单object对象:" + jsonObject);
+        } catch (TeaException err) {
+            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                // err 中含有 code 和 message 属性,可帮助开发定位问题
+            }
+
+        } catch (Exception _err) {
+            TeaException err = new TeaException(_err.getMessage(), _err);
+            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                // err 中含有 code 和 message 属性,可帮助开发定位问题
+            }
+
+        }
+    }
+
+
+
+    //用友NC的应用appKey
+    private String appKey = "d30d5088b7634543b79fbe839e0236f1";
+    //用友NC的应用密钥
+    private String appSecret = "0cbc3734343a1957d1d2161ff628babb3dfebf06";
+    //用友NC的接口访问主地址
+    private String openApiUrl = "https://c2.yonyoucloud.com/iuap-api-auth";
+
+    //获取NC接口的授权token
+    @Test
+    public void getNCtoken() throws Exception{
+
+//        Map<String, String> params = new HashMap<>();
+//        // 除签名外的其他参数
+//        params.put("appKey", appKey);
+//        params.put("timestamp", String.valueOf(System.currentTimeMillis()));
+//        System.out.println("{}," + params);
+//        // 计算签名SignHelper
+//        String signature = SignHelper.sign(params, appSecret);
+//        params.put("signature", signature);
+
+
+//        //当前系统时间的毫秒级时间戳
+//        String timestamp = String.valueOf(System.currentTimeMillis());
+//        System.out.println("当前系统时间的毫秒级时间戳:" + timestamp);
+//
+//        //待加密字符串拼接
+//        String params = "appKey" + appKey + "&timestamp=" + timestamp;
+//
+//        Mac mac = Mac.getInstance("HmacSHA256");
+//        mac.init(new SecretKeySpec(suiteSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
+//        byte[] signData = mac.doFinal(stringBuilder.toString().getBytes(StandardCharsets.UTF_8));
+//        String base64String = Base64.getEncoder().encodeToString(signData);
+//        return URLEncoder.encode(base64String, "UTF-8");
+//
+//
+//        // 请求
+//        // 示例:https://c2.yonyoucloud.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken?appKey=xxx&timestamp=xxx&signature=xxx
+//        String requestUrl = openApiUrl + "/open-auth/selfAppAuth/getAccessToken?" + "appKey=" + appKey + "&timestamp=" + timestamp + "&signature=" + signature;
+//        GenericResponse<AccessTokenResponse> response = RequestTool.doGet(requestUrl, params, new TypeReference<GenericResponse<AccessTokenResponse>>() {});
+//
+//        if (response.isSuccess()) {
+//            return response.getData();
+//        }
+//
+//        LOGGER.error("请求开放平台接口失败,code: {}, message: {}", response.getCode(), response.getMessage());
+//        throw new RuntimeException("请求开放平台接口失败, code: " + response.getCode() + ", message: " + response.getMessage());
+    }
+
+    //测试鸿欢排班接口
+//    @Test
+    public String getHonghuanToken(){
+
+        String corpId = "dinge1f03b6df74842ea";
+        String AppId = "10005";
+        String AppSecret = "dIqPwYoLdUuqRsdnKPRLljIFxesmqvcA";
+        Map map = new HashMap();
+        map.put("corpId",corpId);
+        map.put("AppId",AppId);
+        map.put("AppSecret",AppSecret);
+        String mapStr = JSON.toJSONString(map);
+        System.out.println("封装的密钥传参mapStr:" + mapStr);
+
+        int status = 0;
+        JSONObject data = null;
+        try {
+            OkHttpClient client = new OkHttpClient().newBuilder()
+                    .build();
+            MediaType mediaType = MediaType.parse("application/json");
+            RequestBody body = RequestBody.create(mediaType, mapStr);
+            Request request = new Request.Builder()
+                    .url("https://app67443.eapps.dingtalkcloud.com/topapi/open/login/get_token")
+                    .method("POST", body)
+                    .addHeader("Content-Type", "application/json")
+                    .build();
+            Response response = client.newCall(request).execute();
+
+            String bodyStr = response.body().string();
+            JSONObject jsonObject = JSON.parseObject(bodyStr);
+            System.out.println("返回体body:" + jsonObject);
+
+            status = jsonObject.getInteger("status");
+            System.out.println("获取鸿欢授权接口返回状态码:" + status);
+            data = jsonObject.getJSONObject("data");
+            System.out.println("获取鸿欢授权接口返回data:" + data);
+        }catch (IOException e){
+            e.printStackTrace();
+        }
+        String access_token = data.getString("access_token");
+        System.out.println("获取鸿欢授权接口返回的【token】:" + access_token);
+
+        return access_token;
+    }
+
+    //获取鸿欢排班信息
+    @Test
+    public void getHonghuanPaiban(){
+
+        List list = new ArrayList();
+        list.add("012725692727917145");
+
+        Map map = new HashMap();
+        //待查询人员userid
+        map.put("userIds", list);
+        //查询人userid
+        map.put("op_userid", "0319462021758313");//TODO 待查询人员userid,暂时以固定人员【封渊】
+        //查询开始日期
+        map.put("startDate", "2024-06-01");
+        //查询结束日期
+        map.put("endDate", "2024-06-30");
+        String mapStr = JSON.toJSONString(map);
+        System.out.println("封装排班查询参数:" + mapStr);
+
+        int status = 0;
+        JSONArray data = null;
+        try {
+            OkHttpClient client = new OkHttpClient().newBuilder()
+                    .build();
+            MediaType mediaType = MediaType.parse("application/json");
+            RequestBody body = RequestBody.create(mediaType, mapStr);
+            Request request = new Request.Builder()
+                    .url("https://app67443.eapps.dingtalkcloud.com/topapi/open/schedule/batch/user/query")
+                    .method("POST", body)
+                    .addHeader("Content-Type", "application/json")
+                    .addHeader("Authorization", "Bearer " + getHonghuanToken())
+                    .build();
+            Response response = client.newCall(request).execute();
+
+            String bodyStr = response.body().string();
+            JSONObject jsonObject = JSON.parseObject(bodyStr);
+            System.out.println("返回体body:" + jsonObject);
+
+            status = jsonObject.getInteger("status");
+            System.out.println("获取鸿欢排班接口返回状态码:" + status);
+            data = jsonObject.getJSONArray("data");
+            System.out.println("获取鸿欢排班接口返回data[]:" + data);
+        }catch (IOException e){
+            e.printStackTrace();
+        }
+
+        //应出勤天数(排班天数)
+        int ycqts = 0;
+        if (data == null || data.isEmpty()){
+            System.out.println("【未获取到】排班信息。。。");
+        }else {
+            System.out.println("【获取到】排班信息。。。开始循环统计排班天数。。。");
+
+            for (int i = 0; i < data.size(); i++) {
+                String isRest = data.getJSONObject(i).getString("isRest");
+                if (isRest.equals("false")){
+                    ycqts = ycqts + 1;
+                }
+            }
+        }
+        System.out.println("应出勤天数(排班天数):" + ycqts);
+
+    }
+
+    @Test
+    public void getTime(){
+
+        //获取当前时间
+        Date Date = new Date(System.currentTimeMillis());
+        System.out.println("当前时间:" + Date);
+
+        /*计算规则*/
+        String FORMtime = null;
+        String TOtime = null;
+
+        /*
+         * 获取本月的第一天和最后一天的时间
+         * */
+        Calendar calendar111 = Calendar.getInstance();
+        calendar111.setTime(Date);
+        //本月第一天
+        calendar111.add(Calendar.MONTH,0);
+        calendar111.set(Calendar.DAY_OF_MONTH,1);
+        calendar111.set(Calendar.HOUR_OF_DAY,0);
+        calendar111.set(Calendar.MINUTE,0);
+        calendar111.set(Calendar.SECOND,0);
+        calendar111.set(Calendar.MILLISECOND,0);
+//        FORMtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar111.getTime());
+        FORMtime = new SimpleDateFormat("yyyy-MM-dd").format(calendar111.getTime());
+        System.out.println("本月第一天零点:" + FORMtime);
+
+        Calendar calendar222 = Calendar.getInstance();
+//                int month222 = calendar222.get(Calendar.MONTH);
+        //本月最后一天
+        calendar222.add(Calendar.MONTH,0);
+        calendar222.set(Calendar.DAY_OF_MONTH,calendar222.getActualMaximum(Calendar.DAY_OF_MONTH));
+        calendar222.set(Calendar.HOUR_OF_DAY,0);
+        calendar222.set(Calendar.MINUTE,0);
+        calendar222.set(Calendar.SECOND,0);
+        calendar222.set(Calendar.MILLISECOND,0);
+//        TOtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar222.getTime());
+        TOtime = new SimpleDateFormat("yyyy-MM-dd").format(calendar222.getTime());
+        System.out.println("本月最后一天零点:" + TOtime);
+    }
 }