|
@@ -43,6 +43,9 @@ import com.fs.jd.dto.CarrierInfoDTO;
|
|
|
import com.fs.jd.dto.SoQueryRequestDTO;
|
|
import com.fs.jd.dto.SoQueryRequestDTO;
|
|
|
import com.fs.jd.dto.SoQueryResponseDTO;
|
|
import com.fs.jd.dto.SoQueryResponseDTO;
|
|
|
import com.fs.jd.http.IJdHttpService;
|
|
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.QwExternalContact;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
import com.fs.qw.domain.QwUser;
|
|
|
import com.fs.qw.mapper.FsSopCompanyUserTaskMapper;
|
|
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.wx.service.ShippingService;
|
|
|
import com.fs.xiaoshouyi.dto.TokenResponse;
|
|
import com.fs.xiaoshouyi.dto.TokenResponse;
|
|
|
import com.fs.xiaoshouyi.service.XiaoShouYiOAuthService;
|
|
import com.fs.xiaoshouyi.service.XiaoShouYiOAuthService;
|
|
|
|
|
+import com.google.common.collect.Maps;
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
import com.lark.oapi.Client;
|
|
import com.lark.oapi.Client;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -134,10 +139,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
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.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.*;
|
|
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());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|