From d4658f198bed2f67ce8af33daa361a8a43df7586 Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Fri, 19 Sep 2025 06:55:51 +0000
Subject: [PATCH] 企微通信redis锁问题修改(补充)

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java |   61 ++++++++++++++++++++++++++----
 1 files changed, 52 insertions(+), 9 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 40a3c28..efc1284 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
@@ -42,10 +42,10 @@
 import me.zhengjie.modules.treatment.repository.UserLevelWageRepository;
 import me.zhengjie.utils.QueryHelp;
 import me.zhengjie.utils.StringUtils;
-import me.zhengjie.weixin.cp.api.WxCpOaWeDocSmartsheetService;
-import me.zhengjie.weixin.cp.bean.smartsheet.field.*;
-import me.zhengjie.weixin.cp.bean.smartsheet.record.*;
-import me.zhengjie.weixin.cp.bean.smartsheet.sheet.*;
+import me.zhengjie.modules.weixin.cp.api.WxCpOaWeDocSmartsheetService;
+import me.zhengjie.modules.weixin.cp.bean.smartsheet.field.*;
+import me.zhengjie.modules.weixin.cp.bean.smartsheet.record.*;
+import me.zhengjie.modules.weixin.cp.bean.smartsheet.sheet.*;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.SerializationUtils;
 import org.springframework.data.domain.Sort;
@@ -192,7 +192,7 @@
     public void getWeComAttendanceListOfNoon(String attendDate, List attUser) throws Exception {
         try {
             // 获取企业微信Token
-            wxCpService.getAccessToken(true);
+            wxCpService.getAccessToken();
 
             // 获取参数日期类
             Calendar calAttendDate = Calendar.getInstance();
@@ -322,6 +322,9 @@
             }
         } catch (WxErrorException wxErrorException) {
             wxErrorException.printStackTrace();
+            sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" +
+                            "<div class=\"highlight\">请前往API服务查看LOG。</div>",
+                    "getWeComAttendanceListOfNoon"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
         }
     }
 
@@ -335,7 +338,7 @@
     public void getWeComAttendanceListOfNight(String attendDate, List attUser) throws Exception {
         try {
             // 获取企业微信Token
-            wxCpService.getAccessToken(true);
+            wxCpService.getAccessToken();
 
             // 获取参数日期类
             Calendar calAttendDate = Calendar.getInstance();
@@ -467,6 +470,9 @@
             }
         } catch (WxErrorException wxErrorException) {
             wxErrorException.printStackTrace();
+            sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" +
+                            "<div class=\"highlight\">请前往API服务查看LOG。</div>",
+                    "getWeComAttendanceListOfNight"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
         }
     }
 
@@ -580,6 +586,20 @@
             }
             //调用方法修改考勤打卡状态
             updateAttendanceRecord(null, attendance, Constant.ATTENDANCE_STATE_LEAVE, day, leaveStartDuration, leaveEndDuration);
+        }
+
+        // TODO:20250813修改 增加打卡时间判断,打卡时间需要闭环
+        Boolean actualTimeLoopFlag = ObjectUtils.isNotEmpty(attendance.getActualWorkStartTime()) == ObjectUtils.isNotEmpty(attendance.getActualWorkEndTime());
+        if (!actualTimeLoopFlag) {
+            List<String> editStatusList = Arrays.asList(Constant.ATTENDANCE_STATE_GOOUT, Constant.ATTENDANCE_STATE_BUSINESS, Constant.ATTENDANCE_STATE_LEAVE);
+            if (ObjectUtils.isEmpty(attendance.getActualWorkStartTime()) && editStatusList.contains(attendance.getStartClockResults())) {
+                attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED);
+                attendance.setStartLocationResults(Constant.LOCATION_RESULTS_NOTSIGNED);
+            }
+            if (ObjectUtils.isEmpty(attendance.getActualWorkEndTime()) && editStatusList.contains(attendance.getEndClockResults())) {
+                attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED);
+                attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NOTSIGNED);
+            }
         }
 
 //        // 查询考勤请假表
@@ -1078,7 +1098,7 @@
         if (userWeComIdList.size() > 0) {
             try {
                 // 获取企业微信Token
-                wxCpService.getAccessToken(true);
+                wxCpService.getAccessToken();
 
                 // 编辑消息
                 WxCpMessage wxCpMessage = new WxCpMessage();
@@ -1117,6 +1137,9 @@
                 wxCpService.getMessageService().send(wxCpMessage);
             } catch (WxErrorException wxErrorException) {
                 wxErrorException.printStackTrace();
+//                sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" +
+//                                "<div class=\"highlight\">请前往API服务查看LOG。</div>",
+//                        "sendNotice"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
             }
         }
     }
@@ -1194,6 +1217,20 @@
         projectQueryCriteria.setProjectStatusIn(Arrays.asList(Constant.PROJECT_STATUS_NOT_STARTED, Constant.PROJECT_STATUS_UNDER_WAY));
         List<Long> projectIds = projectRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, projectQueryCriteria, criteriaBuilder)).stream().map(p -> p.getId()).collect(Collectors.toList());
         toWeComSheetPushProjectReport(projectIds);
+
+        try {
+            // 获取企微机器人参数
+            Map<String, String> robotParamMap = dictDetailRepository.findByDictName(Constant.WECOM_ROBOT_PARAM).stream().collect(Collectors.toMap(DictDetail::getLabel, DictDetail::getValue));
+            if (robotParamMap.containsKey(Constant.REMIND_REPORT_WEBHOOK_KEY) && robotParamMap.containsKey(Constant.REMIND_REPORT_SUCCESS_MSG)) {
+                // 发送周报生成成功消息
+                WxCpDefaultConfigImpl wxCpDefaultConfig = new WxCpDefaultConfigImpl();
+                wxCpDefaultConfig.setWebhookKey(robotParamMap.get(Constant.REMIND_REPORT_WEBHOOK_KEY));
+                wxCpService.setWxCpConfigStorage(wxCpDefaultConfig);
+                wxCpService.getGroupRobotService().sendText(robotParamMap.get(Constant.REMIND_REPORT_SUCCESS_MSG), Arrays.asList("@all"), Arrays.asList());
+            }
+        } catch (WxErrorException wxErrorException) {
+            wxErrorException.printStackTrace();
+        }
     }
 
     /**
@@ -1233,7 +1270,7 @@
 
             try {
                 // 获取企业微信Token
-                wxCpService.getAccessToken(true);
+                wxCpService.getAccessToken();
 
                 // 查询现有子表信息
                 WxCpSheetQueryRequest sheetQueryRequest = new WxCpSheetQueryRequest();
@@ -1487,6 +1524,9 @@
                 }
             } catch (WxErrorException wxErrorException) {
                 wxErrorException.printStackTrace();
+                sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" +
+                                "<div class=\"highlight\">请前往API服务查看LOG。</div>",
+                        "toWecomSheetPushWeeklyReport"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
             } catch (Exception e) {
                 e.printStackTrace();
             }
@@ -1517,7 +1557,7 @@
 
             try {
                 // 获取企业微信Token
-                wxCpService.getAccessToken(true);
+                wxCpService.getAccessToken();
 
                 // 查询现有子表信息
                 WxCpSheetQueryRequest sheetQueryRequest = new WxCpSheetQueryRequest();
@@ -2022,6 +2062,9 @@
                 }
             } catch (WxErrorException wxErrorException) {
                 wxErrorException.printStackTrace();
+                sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" +
+                                "<div class=\"highlight\">请前往API服务查看LOG。</div>",
+                        "toWeComSheetPushProjectReport"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
             } catch (Exception e) {
                 e.printStackTrace();
             }

--
Gitblit v1.9.3