|
@@ -1660,22 +1660,15 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
setting.setContentType("17");
|
|
setting.setContentType("17");
|
|
|
break;
|
|
break;
|
|
|
case "19" :
|
|
case "19" :
|
|
|
- Long notionWatchLogId = addNotionWatchLog(sopLogs.getSopId(), videoId, courseId,
|
|
|
|
|
- sopLogs.getFsUserId(), qwUserId, companyUserId, companyId,
|
|
|
|
|
- Long.valueOf(externalId), sopLogs.getSendTime(), logVo.getStartTime());
|
|
|
|
|
- createNotionH5Link(setting, sopLogs.getCorpId(), new Date(), courseId, videoId, qwUserId, companyUserId, companyId, Long.valueOf(externalId), config);
|
|
|
|
|
|
|
+ //1.添加待看课记录
|
|
|
|
|
+ addWatchLogIfNeeded(sopLogs, videoId, courseId, sendTime, qwUserId, companyUserId, companyId, externalId, logVo);
|
|
|
|
|
+ //2.创建课程短链
|
|
|
|
|
+ createNotionLinkByMiniApp(setting, sopLogs.getCorpId(), sendTime, courseId, videoId,
|
|
|
|
|
+ qwUserId, companyUserId, companyId, Long.valueOf(externalId), cachedCourseConfig);
|
|
|
String url = redisCache.getCacheObject("notion_course:" + videoId + "_" + externalId + "_" + qwUserId);
|
|
String url = redisCache.getCacheObject("notion_course:" + videoId + "_" + externalId + "_" + qwUserId);
|
|
|
if (StringUtils.isNotEmpty(url)) {
|
|
if (StringUtils.isNotEmpty(url)) {
|
|
|
log.info("notion缓存命中");
|
|
log.info("notion缓存命中");
|
|
|
}
|
|
}
|
|
|
- if (StringUtils.isEmpty(url)) {
|
|
|
|
|
- log.info("未命中notion缓存");
|
|
|
|
|
- NotionPageRequest request = new NotionPageRequest();
|
|
|
|
|
- request.setTitle(setting.getLinkDescribe());
|
|
|
|
|
- request.setIframeUrl(notionLink + notionWatchLogId);
|
|
|
|
|
- NotionPageResponse page = notionService.createPage(request);
|
|
|
|
|
- url = page.getPublicUrl();
|
|
|
|
|
- }
|
|
|
|
|
if (StringUtils.isEmpty(url)) {
|
|
if (StringUtils.isEmpty(url)) {
|
|
|
url ="";
|
|
url ="";
|
|
|
}
|
|
}
|
|
@@ -1810,6 +1803,9 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
Long notionWatchLogId = addNotionWatchLog(sopLogs.getSopId(), videoId, courseId,
|
|
Long notionWatchLogId = addNotionWatchLog(sopLogs.getSopId(), videoId, courseId,
|
|
|
sopLogs.getFsUserId(), qwUserId, companyUserId, companyId,
|
|
sopLogs.getFsUserId(), qwUserId, companyUserId, companyId,
|
|
|
Long.valueOf(externalId), sopLogs.getSendTime(), logVo.getStartTime());
|
|
Long.valueOf(externalId), sopLogs.getSendTime(), logVo.getStartTime());
|
|
|
|
|
+ //2.创建课程短链
|
|
|
|
|
+ createNotionLinkByMiniApp(setting, sopLogs.getCorpId(), sendTime, courseId, videoId,
|
|
|
|
|
+ qwUserId, companyUserId, companyId, Long.valueOf(externalId), cachedCourseConfig);
|
|
|
NotionPageRequest request = new NotionPageRequest();
|
|
NotionPageRequest request = new NotionPageRequest();
|
|
|
request.setTitle(setting.getLinkDescribe());
|
|
request.setTitle(setting.getLinkDescribe());
|
|
|
request.setIframeUrl(notionLink + notionWatchLogId);
|
|
request.setIframeUrl(notionLink + notionWatchLogId);
|
|
@@ -2310,6 +2306,18 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
? config.getVideoLinkExpireDate()
|
|
? config.getVideoLinkExpireDate()
|
|
|
: setting.getExpiresDays();
|
|
: setting.getExpiresDays();
|
|
|
|
|
|
|
|
|
|
+// 使用 Java 8 时间 API 计算过期时间
|
|
|
|
|
+ LocalDateTime sendDateTime = sendTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
|
|
+ LocalDateTime expireDateTime = sendDateTime.plusDays(expireDays-1);
|
|
|
|
|
+ expireDateTime = expireDateTime.toLocalDate().atTime(23, 59, 59);
|
|
|
|
|
+ Date updateTime = Date.from(expireDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
|
|
+
|
|
|
|
|
+ return updateTime;
|
|
|
|
|
+ }
|
|
|
|
|
+ private Date createUpdateTime1(QwSopTempSetting.Content.Setting setting,Date sendTime,CourseConfig config){
|
|
|
|
|
+
|
|
|
|
|
+ int expireDays = 3;
|
|
|
|
|
+
|
|
|
// 使用 Java 8 时间 API 计算过期时间
|
|
// 使用 Java 8 时间 API 计算过期时间
|
|
|
LocalDateTime sendDateTime = sendTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
LocalDateTime sendDateTime = sendTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
LocalDateTime expireDateTime = sendDateTime.plusDays(expireDays-1);
|
|
LocalDateTime expireDateTime = sendDateTime.plusDays(expireDays-1);
|
|
@@ -3135,6 +3143,35 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
result.put("link", link.getLink());
|
|
result.put("link", link.getLink());
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private Map<String, String> createNotionLinkByMiniApp(QwSopTempSetting.Content.Setting setting, String corpId, Date sendTime,
|
|
|
|
|
+ Long courseId, Long videoId, String qwUserId,
|
|
|
|
|
+ String companyUserId, String companyId, Long externalId, CourseConfig config) {
|
|
|
|
|
+
|
|
|
|
|
+ FsCourseLink link = createFsCourseLink(corpId, sendTime, courseId, videoId, qwUserId,
|
|
|
|
|
+ companyUserId, companyId, externalId.toString(), 3);
|
|
|
|
|
+
|
|
|
|
|
+ FsCourseRealLink courseMap = new FsCourseRealLink();
|
|
|
|
|
+ BeanUtils.copyProperties(link, courseMap);
|
|
|
|
|
+
|
|
|
|
|
+ String courseJson = JSON.toJSONString(courseMap);
|
|
|
|
|
+
|
|
|
|
|
+ String realLinkFull = feishuMiniappLink + courseJson;
|
|
|
|
|
+ if (StringUtils.isNotEmpty(config.getRealLinkGjDomainName())) {
|
|
|
|
|
+ realLinkFull = config.getRealLinkGjDomainName() + realLinkFull;
|
|
|
|
|
+ }
|
|
|
|
|
+ link.setRealLink(realLinkFull);
|
|
|
|
|
+
|
|
|
|
|
+ Date updateTime = createUpdateTime1(setting, sendTime, config);
|
|
|
|
|
+
|
|
|
|
|
+ link.setUpdateTime(updateTime);
|
|
|
|
|
+ //存短链-
|
|
|
|
|
+ fsCourseLinkMapper.insertFsCourseLink(link);
|
|
|
|
|
+ Map<String, String> result = new HashMap<>();
|
|
|
|
|
+ result.put("url", link.getRealLink());
|
|
|
|
|
+ result.put("link", link.getLink());
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
public String createActivityLinkByMiniApp(QwSopTempSetting.Content.Setting st, QwSopLogs sopLogs, String corpId, Date sendTime, Long courseId, Long videoId, String qwUserId, String companyUserId, String companyId, CourseConfig config, String chatId) {
|
|
public String createActivityLinkByMiniApp(QwSopTempSetting.Content.Setting st, QwSopLogs sopLogs, String corpId, Date sendTime, Long courseId, Long videoId, String qwUserId, String companyUserId, String companyId, CourseConfig config, String chatId) {
|
|
|
|
|
|
|
|
FsCourseLink link = createActivityByLink(corpId, sendTime, courseId, videoId, qwUserId.toString(),
|
|
FsCourseLink link = createActivityByLink(corpId, sendTime, courseId, videoId, qwUserId.toString(),
|
|
@@ -3191,23 +3228,6 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
enqueueCourseLink(link);
|
|
enqueueCourseLink(link);
|
|
|
return link.getRealLink();
|
|
return link.getRealLink();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- private void createNotionH5Link(QwSopTempSetting.Content.Setting setting, String corpId, Date sendTime,
|
|
|
|
|
- Long courseId, Long videoId, String qwUserId,
|
|
|
|
|
- String companyUserId, String companyId, Long externalId, CourseConfig config){
|
|
|
|
|
- FsCourseLink link = createFsCourseLink(corpId, sendTime, courseId, videoId, qwUserId,
|
|
|
|
|
- companyUserId, companyId, externalId.toString(), 3);
|
|
|
|
|
- FsCourseRealLink courseMap = new FsCourseRealLink();
|
|
|
|
|
- BeanUtils.copyProperties(link, courseMap);
|
|
|
|
|
-
|
|
|
|
|
- String courseJson = JSON.toJSONString(courseMap);
|
|
|
|
|
- String realLinkFull = REAL_LINK_PREFIX + courseJson;
|
|
|
|
|
-
|
|
|
|
|
- link.setRealLink(realLinkFull);
|
|
|
|
|
- link.setUpdateTime(createUpdateTime(setting, sendTime, config));
|
|
|
|
|
- fsCourseLinkMapper.insertFsCourseLink(link);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private Long addNotionWatchLog(String sopId, Long videoId, Long courseId,
|
|
private Long addNotionWatchLog(String sopId, Long videoId, Long courseId,
|
|
|
Long fsUserId, String qwUserId, String companyUserId,
|
|
Long fsUserId, String qwUserId, String companyUserId,
|
|
|
String companyId, Long externalId, String startTime,String createTime) {
|
|
String companyId, Long externalId, String startTime,String createTime) {
|