Explorar o código

修改定时生成飞书docId缓存

wjj hai 3 días
pai
achega
942af07a0e
Modificáronse 1 ficheiros con 43 adicións e 1 borrados
  1. 43 1
      fs-admin/src/main/java/com/fs/his/task/Task.java

+ 43 - 1
fs-admin/src/main/java/com/fs/his/task/Task.java

@@ -3260,6 +3260,48 @@ public class Task {
         }
     }
 
+    public void generateFeiShuRedisCacheFixed(){
+        List<FsUserCourseVideo> list = new ArrayList<>();
+        FsUserCourseVideo courseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(1672L);
+        list.add(courseVideo);
+        FsUserCourseVideo courseVideo1 = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(1680L);
+        list.add(courseVideo1);
+        if (CollectionUtils.isEmpty(list)) {
+            logger.error("未查询到小节数据");
+            return;
+        }
+
+        //营期中企业外部联系人
+        List<Long> externalIds = sopUserLogsInfoMapper.selectExternalIds();
+        if (CollectionUtils.isEmpty(externalIds)) {
+            logger.error("未查询到营期中企业外部联系人");
+            return;
+        }
+
+        //外部联系人数据
+        List<QwExternalContact> contacts = qwExternalContactMapper.selectQwExternalContactByIds(externalIds);
+        if (CollectionUtils.isEmpty(contacts)) {
+            logger.error("未查询到外部联系人数据");
+            return;
+        }
+        for (QwExternalContact contact : contacts) {
+            for (FsUserCourseVideo video : list) {
+                try {
+                    String key = "fei_shu_doc_id:" + contact.getId() + "_" + video.getVideoId();
+                    String feiShuDocId = redisCache.getCacheObject(key);
+                    if (StringUtils.isNotBlank(feiShuDocId)) {
+                        continue;
+                    }
+                    feiShuDocId = getFeiShuDocId(video, contact.getCompanyId(), contact.getCompanyUserId());
+                    if (StringUtils.isNotBlank(feiShuDocId)) {
+                        redisCache.setCacheObject("fei_shu_doc_id:" + contact.getId() + "_" + video.getVideoId(), feiShuDocId);
+                    }
+                } catch (Exception e) {
+                    logger.error("生成飞书文档失败, 课程id: {}, 外部联系人id: {}, 错误信息: {}", video.getCourseId(), contact.getExternalUserId(), e.getMessage());
+                }
+            }
+        }
+    }
     public List<FeishuAccount> getFeiShuAccountCompanyUser(Long companyId, Long companyUserId) {
         String cacheKey = FEISHU_COMPANY_USER_KEY + companyId + ":" + companyUserId;
         String cached = redisCache.getCacheObject(cacheKey);
@@ -3357,7 +3399,7 @@ public class Task {
             FeishuAccount account = wrapper.getAccount();
             try {
                 String docId = docApiService.createDocument(client, video.getTitle() + "-注册");
-                redisCache.setCacheObject("fei_shu_client:" + docId, client);
+                redisCache.setCacheObject("fei_shu_client:" + docId, account);
                 return docId;
 
             } catch (CustomException e) {