From 4fa526092b61ba33a7fc7662048288691d7bb9b0 Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Fri, 14 Mar 2025 02:46:11 +0000
Subject: [PATCH] 添加企微打卡(运行测试):空指针异常修改

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
index 9f0b176..ced418b 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
@@ -209,18 +209,19 @@
                         // 企微打卡数据
                         weComRecordResult.setCheckinTime(null);
                     }
+                    Timestamp checkInTime = unixtimeToTimestamp(weComRecordResult.getCheckinTime());
                     // 早打卡
                     if ("上班打卡".equals(weComRecordResult.getCheckinType())) {
                         // 调用验证状态方法
                         Boolean flag = getCardSupplement(attendance.getUserId(), attendance.getStartClockResults(), attendance.getActualWorkStartTime());
                         // 考勤记录
                         if (!isHoliday) {
-                            attendance.setStartClockResults(flag == true ? attendance.getStartClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), new Timestamp(weComRecordResult.getCheckinTime() * 1000), 1)));
+                            attendance.setStartClockResults(flag == true ? attendance.getStartClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), checkInTime, 1)));
                         } else {
                             attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NORMAL);
                         }
                         attendance.setStartLocationResults(flag == true ? attendance.getStartLocationResults() : setLocationResults(weComRecordResult.getExceptionType()));
-                        attendance.setActualWorkStartTime(flag == true ? attendance.getActualWorkStartTime() : new Timestamp(weComRecordResult.getCheckinTime() * 1000));
+                        attendance.setActualWorkStartTime(flag == true ? attendance.getActualWorkStartTime() : checkInTime);
                     }
                     // 晚打卡
                     if ("下班打卡".equals(weComRecordResult.getCheckinType())) {
@@ -228,12 +229,12 @@
                         Boolean flag = getCardSupplement(attendance.getUserId(), attendance.getEndClockResults(), attendance.getActualWorkEndTime());
                         // 考勤记录
                         if (!isHoliday) {
-                            attendance.setEndClockResults(flag == true ? attendance.getEndClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), new Timestamp(weComRecordResult.getCheckinTime() * 1000), 2)));
+                            attendance.setEndClockResults(flag == true ? attendance.getEndClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), checkInTime, 2)));
                         } else {
                             attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NORMAL);
                         }
                         attendance.setEndLocationResults(flag == true ? attendance.getEndLocationResults() : setLocationResults(weComRecordResult.getExceptionType()));
-                        attendance.setActualWorkEndTime(flag == true ? attendance.getActualWorkEndTime() : new Timestamp(weComRecordResult.getCheckinTime() * 1000));
+                        attendance.setActualWorkEndTime(flag == true ? attendance.getActualWorkEndTime() : checkInTime);
                     }
                 }
                 // 修改考勤打卡状态
@@ -325,18 +326,19 @@
                         // 企微打卡数据
                         weComRecordResult.setCheckinTime(null);
                     }
+                    Timestamp checkInTime = unixtimeToTimestamp(weComRecordResult.getCheckinTime());
                     // 早打卡
                     if ("上班打卡".equals(weComRecordResult.getCheckinType())) {
                         // 调用验证状态方法
                         Boolean flag = getCardSupplement(attendance.getUserId(), attendance.getStartClockResults(), attendance.getActualWorkStartTime());
                         // 考勤记录
                         if (!isHoliday) {
-                            attendance.setStartClockResults(flag == true ? attendance.getStartClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), new Timestamp(weComRecordResult.getCheckinTime() * 1000), 1)));
+                            attendance.setStartClockResults(flag == true ? attendance.getStartClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), checkInTime, 1)));
                         } else {
                             attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NORMAL);
                         }
                         attendance.setStartLocationResults(flag == true ? attendance.getStartLocationResults() : setLocationResults(weComRecordResult.getExceptionType()));
-                        attendance.setActualWorkStartTime(flag == true ? attendance.getActualWorkStartTime() : new Timestamp(weComRecordResult.getCheckinTime() * 1000));
+                        attendance.setActualWorkStartTime(flag == true ? attendance.getActualWorkStartTime() : checkInTime);
                     }
                     // 晚打卡
                     if ("下班打卡".equals(weComRecordResult.getCheckinType())) {
@@ -344,12 +346,12 @@
                         Boolean flag = getCardSupplement(attendance.getUserId(), attendance.getEndClockResults(), attendance.getActualWorkEndTime());
                         // 考勤记录
                         if (!isHoliday) {
-                            attendance.setEndClockResults(flag == true ? attendance.getEndClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), new Timestamp(weComRecordResult.getCheckinTime() * 1000), 2)));
+                            attendance.setEndClockResults(flag == true ? attendance.getEndClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), checkInTime, 2)));
                         } else {
                             attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NORMAL);
                         }
                         attendance.setEndLocationResults(flag == true ? attendance.getEndLocationResults() : setLocationResults(weComRecordResult.getExceptionType()));
-                        attendance.setActualWorkEndTime(flag == true ? attendance.getActualWorkEndTime() : new Timestamp(weComRecordResult.getCheckinTime() * 1000));
+                        attendance.setActualWorkEndTime(flag == true ? attendance.getActualWorkEndTime() : checkInTime);
                     }
                 }
                 // 修改考勤打卡状态
@@ -799,4 +801,11 @@
         }
         return duration;
     }
+
+    private Timestamp unixtimeToTimestamp(Long unixtime) {
+        if (ObjectUtils.isNotEmpty(unixtime)) {
+            return new Timestamp(unixtime * 1000);
+        }
+        return null;
+    }
 }

--
Gitblit v1.9.3