Selaa lähdekoodia

国庆内容接口调整

fyz 4 viikkoa sitten
vanhempi
commit
24a72399c6
1 muutettua tiedostoa jossa 41 lisäystä ja 25 poistoa
  1. 41 25
      src/main/java/com/muzhi/lanyun/service/impl/DingOaServiceImpl.java

+ 41 - 25
src/main/java/com/muzhi/lanyun/service/impl/DingOaServiceImpl.java

@@ -2,6 +2,7 @@ package com.muzhi.lanyun.service.impl;
 
 
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -5636,31 +5637,42 @@ public class DingOaServiceImpl implements DingOaService {
 
                                 //比较数据库的离职日期和当前接口获取的最后离开组织架构时间的大小
                                 LocalDate d1 = LocalDate.parse(leaveTime1);
-                                LocalDate d2 = LocalDate.parse(lizhiriqi);
-
-                                result = d1.compareTo(d2);
-
-                                if (result < 0) {
-                                    System.out.println(leaveTime1 + " 早于 " + lizhiriqi);
-                                    System.out.println("数据库离职日期早于当前接口获取的离开组织架构时间,才会更新!");
-                                    if (lizhiriqi != null || lizhiriqi != ""){
-                                        //将年月格式转成毫秒级时间戳
-                                        // 1. 解析为 LocalDate(无时区)
-                                        LocalDate date = LocalDate.parse(lizhiriqi);
-
-                                        // 2. 转换为带时区的时间(例如:系统默认时区 或 Asia/Shanghai)
-                                        ZonedDateTime zdt = date.atStartOfDay(ZoneId.systemDefault());
-                                        // 或指定北京时间:
-                                        // ZonedDateTime zdt = date.atStartOfDay(ZoneId.of("Asia/Shanghai"));
-
-                                        // 3. 获取毫秒时间戳
-                                        lizhishijianLong = zdt.toInstant().toEpochMilli();
-                                        System.out.println("转换成毫米级时间戳:" + lizhishijianLong); // 输出示例:1759248000000
+
+                                if (ObjectUtil.isNotNull(lizhiriqi)){
+                                    LocalDate d2 = LocalDate.parse(lizhiriqi);
+
+                                    result = d1.compareTo(d2);
+                                    if (result < 0) {
+                                        System.out.println(leaveTime1 + " 早于 " + lizhiriqi);
+                                        System.out.println("数据库离职日期早于当前接口获取的离开组织架构时间,才会更新!");
+                                        if (lizhiriqi != null || lizhiriqi != ""){
+                                            //将年月格式转成毫秒级时间戳
+                                            // 1. 解析为 LocalDate(无时区)
+                                            LocalDate date = LocalDate.parse(lizhiriqi);
+
+                                            // 2. 转换为带时区的时间(例如:系统默认时区 或 Asia/Shanghai)
+                                            ZonedDateTime zdt = date.atStartOfDay(ZoneId.systemDefault());
+                                            // 或指定北京时间:
+                                            // ZonedDateTime zdt = date.atStartOfDay(ZoneId.of("Asia/Shanghai"));
+
+                                            // 3. 获取毫秒时间戳
+                                            lizhishijianLong = zdt.toInstant().toEpochMilli();
+                                            System.out.println("转换成毫米级时间戳:" + lizhishijianLong); // 输出示例:1759248000000
+                                        }
+                                    } else if (result > 0) {
+                                        System.out.println(leaveTime1 + " 晚于 " + lizhiriqi);
+                                    } else {
+                                        System.out.println("两个日期相等");
                                     }
-                                } else if (result > 0) {
-                                    System.out.println(leaveTime1 + " 晚于 " + lizhiriqi);
-                                } else {
-                                    System.out.println("两个日期相等");
+                                }else{
+
+                                    // 2. 转换为带时区的时间(例如:系统默认时区 或 Asia/Shanghai)
+                                    ZonedDateTime zdt = d1.atStartOfDay(ZoneId.systemDefault());
+                                    // 或指定北京时间:
+                                    // ZonedDateTime zdt = date.atStartOfDay(ZoneId.of("Asia/Shanghai"));
+
+                                    // 3. 获取毫秒时间戳
+                                    lizhishijianLong = zdt.toInstant().toEpochMilli();
                                 }
                             }catch (Exception e){
                                 log.info("获取当前执行月份该人员在数据库档案中的离职日期字段为空!");
@@ -5701,7 +5713,11 @@ public class DingOaServiceImpl implements DingOaService {
                             updateWrapper.eq("yuangongbianma", userId).eq("jisuannianyue", dateNowStr);
                             if (danganLanyunList.size() > 0){
                                 updateWrapper.set("yuangongzhuangtai", "已离职");
-                                if (result < 0) {//数据库离职日期早于当前接口获取的离开组织架构时间,才会更新!
+                                if (ObjectUtil.isNotNull(lizhiriqi)){
+                                    if (result < 0) {//数据库离职日期早于当前接口获取的离开组织架构时间,才会更新!
+                                        updateWrapper.set("lizhiriqi", leaveTime1);
+                                    }
+                                }else {
                                     updateWrapper.set("lizhiriqi", leaveTime1);
                                 }
                                 danganLanyunMapper.update(null, updateWrapper);