wjj hai 3 días
pai
achega
5662ca0a89

+ 113 - 4
fs-admin/src/main/java/com/fs/his/task/Task.java

@@ -43,6 +43,9 @@ import com.fs.jd.dto.CarrierInfoDTO;
 import com.fs.jd.dto.SoQueryRequestDTO;
 import com.fs.jd.dto.SoQueryResponseDTO;
 import com.fs.jd.http.IJdHttpService;
+import com.fs.notion.dto.NotionPageRequest;
+import com.fs.notion.dto.NotionPageResponse;
+import com.fs.notion.service.INotionService;
 import com.fs.qw.domain.QwExternalContact;
 import com.fs.qw.domain.QwUser;
 import com.fs.qw.mapper.FsSopCompanyUserTaskMapper;
@@ -120,11 +123,13 @@ import com.fs.wx.mapper.FsWxExpressTaskMapper;
 import com.fs.wx.service.ShippingService;
 import com.fs.xiaoshouyi.dto.TokenResponse;
 import com.fs.xiaoshouyi.service.XiaoShouYiOAuthService;
+import com.google.common.collect.Maps;
 import com.google.gson.Gson;
 import com.lark.oapi.Client;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.apache.commons.lang3.StringUtils;
+import org.checkerframework.checker.units.qual.A;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -134,10 +139,7 @@ import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.time.LocalDateTime;
-import java.time.OffsetDateTime;
-import java.time.ZoneId;
-import java.time.ZoneOffset;
+import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.*;
@@ -3534,4 +3536,111 @@ public class Task {
        }
     }
 
+    private static final String notionLink = "https://notion.hcdyfa.top/pages_course/videoDetail?logId=";
+    private static final String REAL_LINK_PREFIX = "/courseH5/pages/course/learning?course=";
+    @Autowired
+    private INotionService notionService;
+
+    public void testAA(){
+        List<Long> videoIds = Arrays.asList(1706L, 1707L);
+        Long qw_user_id = 45061L;
+        long companyId = 1L;
+        long companyUserId = 1L;
+        long courseId = 247L;
+        String sopId ="a58580678d73b996f042594e46245191";
+        String cropId ="ww7aa878854aaf6ca9";
+        Date createTime = DateUtils.getNowDate();
+        String startTime = DateUtils.parseDateToStr( DateUtils.YYYY_MM_DD, DateUtils.getNowDate());
+        List<Long> qwExIds = Arrays.asList(6814188L,6779783L,6745870L,6729776L,6728306L,6703887L,6746954L);
+        HashMap<String, Long> map = Maps.newHashMap();
+        for (Long videoId : videoIds) {
+            for (Long qwExId : qwExIds) {
+                Long fsUserId = null;
+                if (qwExId.equals(6703887L)) {
+                    fsUserId = 16L;
+
+                } else if (qwExId.equals(6746954L)) {
+
+                } else if (qwExId.equals(6728306L)) {
+                    fsUserId = 99661L;
+
+                } else if (qwExId.equals(6729776L)) {
+                    fsUserId = 110087L;
+
+                } else if (qwExId.equals(6745870L)) {
+                    fsUserId = 1L;
+
+                } else if (qwExId.equals(6779783L)) {
+                    fsUserId = 20L;
+
+                } else if (qwExId.equals(6814188L)) {
+                    fsUserId = 3L;
+                }
+                Long notionWatchLogId = addNotionWatchLog(sopId, videoId.intValue(), (int) courseId,
+                        fsUserId, String.valueOf(qw_user_id), Long.toString(companyUserId), Long.toString(companyId),
+                        qwExId, startTime, createTime);
+                NotionPageRequest request = new NotionPageRequest();
+                request.setTitle("测试notion");
+                request.setIframeUrl(notionLink + notionWatchLogId);
+
+                NotionPageResponse page = notionService.createPage(request);
+                redisCache.setCacheObject("notion_course:"+videoId+"_"+qwExId+"_"+qw_user_id,page.getPublicUrl(),1,TimeUnit.DAYS);
+            }
+        }
+
+    }
+
+    private Long addNotionWatchLog(String sopId, Integer videoId, Integer courseId,
+                                   Long fsUserId, String qwUserId, String companyUserId,
+                                   String companyId, Long externalId, String startTime,Date createTime) {
+        try {
+            FsCourseWatchLog watchLog = new FsCourseWatchLog();
+            watchLog.setVideoId(videoId != null ? videoId.longValue() : null);
+            watchLog.setQwExternalContactId(externalId);
+            watchLog.setSendType(2);
+            watchLog.setQwUserId(Long.valueOf(qwUserId));
+            watchLog.setSopId(sopId);
+            watchLog.setDuration(0L);
+            watchLog.setCourseId(courseId != null ? courseId.longValue() : null);
+            watchLog.setCompanyUserId(companyUserId != null ? Long.valueOf(companyUserId) : null);
+            watchLog.setCompanyId(companyId != null ? Long.valueOf(companyId) : null);
+            watchLog.setCreateTime(createTime);
+            watchLog.setUpdateTime(createTime);
+            watchLog.setLogType(3);
+            watchLog.setUserId(fsUserId);
+            watchLog.setCampPeriodTime(convertStringToDate(startTime,"yyyy-MM-dd"));
+
+            //存看课记录
+            watchLogMapper.insertOrUpdateFsCourseWatchLog(watchLog);
+            return watchLog.getLogId();
+        }catch (Exception e){
+            log.error("一键群发失败-插入观看记录失败:"+e.getMessage());
+        }
+        return null;
+    }
+
+    /**
+     * 时间字符串转Date时间
+     * @param dateString
+     * @return
+     */
+    public static Date convertStringToDate(String dateString,String pattern) {
+        if (dateString == null || dateString.isEmpty()) {
+            return null;
+        }
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
+        LocalDateTime localDateTime;
+        LocalDate localDate;
+        // 先解析成 LocalDate(只含年月日)
+        if (pattern.equals("yyyy-MM-dd")){
+            // 先解析成 LocalDate(只含年月日)
+            localDate = LocalDate.parse(dateString, formatter);
+            // 将 LocalDate 转为当天 00:00:00 的 LocalDateTime
+            localDateTime = localDate.atStartOfDay();
+        }else {
+            localDateTime = LocalDateTime.parse(dateString, formatter);
+        }
+        return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
+    }
+
 }

+ 6 - 0
fs-ipad-task/src/main/java/com/fs/app/service/IpadSendServer.java

@@ -337,6 +337,12 @@ public class IpadSendServer {
         }else if ("20".equals(content.getContentType())){
             // 新飞书逻辑
             completeFeishuCourseLink(vo, content,qwSopLogs, externalId,qwUserId);
+        } else if ("19".equals(content.getContentType())){
+            String linkUrl = content.getLinkUrl();
+            if (linkUrl == null || StringUtils.isEmpty(linkUrl)) {
+                linkUrl = redisCache.getCacheObject("notion_course:"+content.getVideoId()+"_"+externalId+"_"+qwUserId);
+                content.setLinkUrl(linkUrl);
+            }
         }
         // 文本
         LinkVo linkVo = LinkVo.builder()

+ 1 - 0
fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -494,6 +494,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="project != null">project = #{project},</if>
             <if test="answerSendStatus != null"> answer_send_status = #{answerSendStatus},</if>
             <if test="redPacketStatus != null"> red_packet_status = #{redPacketStatus},</if>
+            <if test="clickCount != null">click_count = #{clickCount},</if>
         </trim>
         where log_id = #{logId}
     </update>