|
|
@@ -89,6 +89,9 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
private static final String appActivitlLink = "/pages_course/activity.html?link=";
|
|
|
// 注册
|
|
|
private static final String registeredRealLink = "/pages_course/register.html?link=";
|
|
|
+ private static final String h5LiveShortLink = "/pages_course/livingInvite.html?s=";
|
|
|
+
|
|
|
+ private static final String h5miniappLink = "/pages_course/shortLink.html?s=";
|
|
|
|
|
|
// private static final String miniappRealLink = "/pages/index/index?course=";
|
|
|
|
|
|
@@ -1281,6 +1284,58 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
+ //直播h5跳转卡片
|
|
|
+ case "18":
|
|
|
+ //直播h5跳转短链
|
|
|
+ case "19":
|
|
|
+ String corpId = logVo.getCorpId();
|
|
|
+ String shortH5Link = createH5LiveShortLink(setting, corpId,
|
|
|
+ qwUserId, companyUserId, companyId);
|
|
|
+ shortH5Link = shortH5Link.substring(0, shortH5Link.length() - 1);
|
|
|
+
|
|
|
+ sopLogs.setSendType(Integer.valueOf(setting.getContentType()));
|
|
|
+ clonedContent.setLiveId(setting.getLiveId());
|
|
|
+ json = configService.selectConfigByKey("his.config");
|
|
|
+ sysConfig= JSON.parseObject(json,FSSysConfig.class);
|
|
|
+
|
|
|
+ if(isGroupChat){
|
|
|
+ try{
|
|
|
+ groupChat.getChatUserList().stream().filter(e -> e.getUserList() != null && !e.getUserList().isEmpty()).forEach(e -> {
|
|
|
+ Map<String, GroupUserExternalVo> userMap = PubFun.listToMapByGroupObject(e.getUserList(), GroupUserExternalVo::getUserId);
|
|
|
+ GroupUserExternalVo vo = userMap.get(groupChat.getOwner());
|
|
|
+ if (vo != null && vo.getId() != null) {
|
|
|
+ sopLogs.setFsUserId(vo.getFsUserId());
|
|
|
+ //写入直播待看课记录
|
|
|
+ createLiveWatchLogAndEnQueue(companyId,companyUserId,vo.getId().toString(), setting.getLiveId(),sysConfig.getAppId(),2,qwUserId,logVo.getCorpId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ shortH5Link += ",\"chatId\":\"" + groupChat.getChatId() + "\"";
|
|
|
+ }catch(Exception e){
|
|
|
+ log.error("直播H5群聊新增报错,{}", e.getMessage(),e);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ try{
|
|
|
+ createLiveWatchLogAndEnQueue(companyId,companyUserId,externalId, setting.getLiveId(),sysConfig.getAppId(),1,qwUserId,logVo.getCorpId());
|
|
|
+ shortH5Link += ",\"externalId\":\"" + externalId + "\"";
|
|
|
+ }catch(Exception e){
|
|
|
+ log.error("直播H5个人新增报错,{}", e.getMessage(),e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ shortH5Link += "}";
|
|
|
+ miniprogramLiveTitle = setting.getMiniprogramTitle();
|
|
|
+ maxLiveLength = 17;
|
|
|
+ setting.setMiniprogramTitle(miniprogramLiveTitle.length() > maxLiveLength ? miniprogramLiveTitle.substring(0, maxLiveLength) + "..." : miniprogramLiveTitle);
|
|
|
+ setting.setMiniprogramAppid(sysConfig.getAppId());
|
|
|
+ setting.setMiniprogramPage(shortH5Link);
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ setting.setMiniprogramPicUrl(StringUtil.strIsNullOrEmpty(setting.getMiniprogramPicUrl()) ? "https://cos.his.cdwjyyh.com/fs/20250331/ec2b4e73be8048afbd526124a655ad56.png" : setting.getMiniprogramPicUrl());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("赋值-小程序封面地址失败-" + e);
|
|
|
+ }
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
@@ -1413,8 +1468,8 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
/**
|
|
|
* 处理直播消息
|
|
|
*/
|
|
|
- public void handleLiveMessage(QwSopLogs sopLogs, QwSopTempSetting.Content content, String companyUserId, String companyId,
|
|
|
- boolean isGroupChat, String qwUserId, QwGroupChat groupChat, String externalId, SopUserLogsVo logVo, Long liveId) {
|
|
|
+ public void handleLiveMessage(QwSopLogs sopLogs,QwSopTempSetting.Content content, String companyUserId, String companyId,
|
|
|
+ boolean isGroupChat,String qwUserId,QwGroupChat groupChat,String externalId,SopUserLogsVo logVo,Long liveId){
|
|
|
// 深拷贝 Content 对象,避免使用 JSON
|
|
|
QwSopTempSetting.Content clonedContent = deepCopyContent(content);
|
|
|
if (clonedContent == null) {
|
|
|
@@ -1477,6 +1532,55 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
log.error("赋值-小程序封面地址失败-" + e);
|
|
|
}
|
|
|
|
|
|
+ break;
|
|
|
+ //直播h5跳转卡片
|
|
|
+ case "18":
|
|
|
+ //直播h5跳转短链
|
|
|
+ case "19":
|
|
|
+ String corpId = logVo.getCorpId();
|
|
|
+ String shortH5Link = createH5LiveShortLink(setting, corpId,
|
|
|
+ qwUserId, companyUserId, companyId);
|
|
|
+
|
|
|
+ sopLogs.setSendType(Integer.valueOf(setting.getContentType()));
|
|
|
+ clonedContent.setLiveId(setting.getLiveId());
|
|
|
+ json = configService.selectConfigByKey("his.config");
|
|
|
+ sysConfig= JSON.parseObject(json,FSSysConfig.class);
|
|
|
+
|
|
|
+ if(isGroupChat){
|
|
|
+ try{
|
|
|
+ groupChat.getChatUserList().stream().filter(e -> e.getUserList() != null && !e.getUserList().isEmpty()).forEach(e -> {
|
|
|
+ Map<String, GroupUserExternalVo> userMap = PubFun.listToMapByGroupObject(e.getUserList(), GroupUserExternalVo::getUserId);
|
|
|
+ GroupUserExternalVo vo = userMap.get(groupChat.getOwner());
|
|
|
+ if (vo != null && vo.getId() != null) {
|
|
|
+ sopLogs.setFsUserId(vo.getFsUserId());
|
|
|
+ //写入直播待看课记录
|
|
|
+ createLiveWatchLogAndEnQueue(companyId,companyUserId,vo.getId().toString(), setting.getLiveId(),sysConfig.getAppId(),2,qwUserId,logVo.getCorpId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ shortH5Link += "&chatId=" + groupChat.getChatId();
|
|
|
+ }catch(Exception e){
|
|
|
+ log.error("直播小程序群聊新增报错,{}", e.getMessage(),e);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ try{
|
|
|
+ createLiveWatchLogAndEnQueue(companyId,companyUserId,externalId, setting.getLiveId(),sysConfig.getAppId(),1,qwUserId,logVo.getCorpId());
|
|
|
+ shortH5Link += "&externalId=" + externalId;
|
|
|
+ }catch(Exception e){
|
|
|
+ log.error("直播小程序个人新增报错,{}", e.getMessage(),e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ miniprogramLiveTitle = setting.getMiniprogramTitle();
|
|
|
+ maxLiveLength = 17;
|
|
|
+ setting.setMiniprogramTitle(miniprogramLiveTitle.length() > maxLiveLength ? miniprogramLiveTitle.substring(0, maxLiveLength) + "..." : miniprogramLiveTitle);
|
|
|
+ setting.setMiniprogramAppid(sysConfig.getAppId());
|
|
|
+ setting.setMiniprogramPage(shortH5Link);
|
|
|
+
|
|
|
+ try {
|
|
|
+ setting.setMiniprogramPicUrl(StringUtil.strIsNullOrEmpty(setting.getMiniprogramPicUrl()) ? "https://cos.his.cdwjyyh.com/fs/20250331/ec2b4e73be8048afbd526124a655ad56.png" : setting.getMiniprogramPicUrl());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("赋值-小程序封面地址失败-" + e);
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -1741,6 +1845,44 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
case "15": //app文本
|
|
|
case "16": //app语音
|
|
|
sopLogs.setAppSendStatus(0);
|
|
|
+ break;
|
|
|
+ case "17":
|
|
|
+ try {
|
|
|
+ String sroth5link;
|
|
|
+ addWatchLogIfNeeded(sopLogs, videoId, courseId, sendTime, qwUserId, companyUserId, companyId, externalId, logVo,2);
|
|
|
+
|
|
|
+ sroth5link = createH5LinkByMiniApp(setting, logVo, sendTime, courseId, videoId,
|
|
|
+ qwUserId, companyUserId, companyId, externalId, isOfficial, sopLogs.getFsUserId());
|
|
|
+
|
|
|
+ if(sopLogs.getSendType()==1){
|
|
|
+ setting.setMiniprogramAppid(miniAppId);
|
|
|
+ }else {
|
|
|
+ int miniType = getLevel(grade);
|
|
|
+ //算主备小程序
|
|
|
+ String finalAppId = getAppIdFromMiniMap(miniMap, companyId, sendMsgType, grade);
|
|
|
+
|
|
|
+ if (StringUtil.strIsNullOrEmpty(finalAppId)) {
|
|
|
+ finalAppId = miniAppId;
|
|
|
+ }
|
|
|
+
|
|
|
+ setting.setMiniType(miniType);
|
|
|
+ if (!StringUtil.strIsNullOrEmpty(finalAppId)) {
|
|
|
+ setting.setMiniprogramAppid(finalAppId);
|
|
|
+ } else {
|
|
|
+ log.error("公司的小程序id为空:采用了前端传的固定值" + sopLogs.getSopId());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ setting.setMiniprogramTitle("邀请链接");
|
|
|
+ setting.setMiniprogramPage(sroth5link);
|
|
|
+
|
|
|
+ setting.setMiniprogramPicUrl(StringUtil.strIsNullOrEmpty(setting.getMiniprogramPicUrl()) ? "https://cos.his.cdwjyyh.com/fs/20250331/ec2b4e73be8048afbd526124a655ad56.png" : setting.getMiniprogramPicUrl());
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("浏览器看课模板解析失败:" + e);
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -1920,7 +2062,99 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
|
|
|
return record;
|
|
|
}
|
|
|
+ private String createH5LinkByMiniApp(QwSopTempSetting.Content.Setting setting, SopUserLogsVo logVo, Date sendTime,
|
|
|
+ Long courseId, Long videoId, String qwUserId,
|
|
|
+ String companyUserId, String companyId, String externalId, String isOfficial, Long fsUserId) {
|
|
|
+ // 获取缓存的配置
|
|
|
+ CourseConfig config;
|
|
|
+ synchronized (configLock) {
|
|
|
+ config = cachedCourseConfig;
|
|
|
+ }
|
|
|
|
|
|
+ if (config == null) {
|
|
|
+ log.error("CourseConfig is not loaded.");
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+// if (StringUtils.isEmpty(config.getMiniprogramPage())){
|
|
|
+// log.error("miniprogramPage is not loaded.");
|
|
|
+// return "";
|
|
|
+// }
|
|
|
+
|
|
|
+ // 手动创建 FsCourseLink 对象,避免使用 BeanUtils.copyProperties
|
|
|
+ FsCourseLink link = new FsCourseLink();
|
|
|
+ link.setCompanyId(Long.parseLong(companyId));
|
|
|
+ link.setQwUserId(Long.valueOf(qwUserId));
|
|
|
+ link.setCompanyUserId(Long.parseLong(companyUserId));
|
|
|
+ link.setVideoId(videoId.longValue());
|
|
|
+ link.setCorpId(logVo.getCorpId());
|
|
|
+ link.setCourseId(courseId.longValue());
|
|
|
+ link.setQwExternalId(Long.parseLong(externalId));
|
|
|
+ link.setUNo(UUID.randomUUID().toString());
|
|
|
+
|
|
|
+
|
|
|
+ String randomString = generateRandomStringWithLock();
|
|
|
+ if (StringUtil.strIsNullOrEmpty(randomString)) {
|
|
|
+ link.setLink(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+ } else {
|
|
|
+ link.setLink(randomString);
|
|
|
+ }
|
|
|
+
|
|
|
+ link.setCreateTime(sendTime);
|
|
|
+
|
|
|
+ FsCourseRealLink courseMap = new FsCourseRealLink();
|
|
|
+ BeanUtils.copyProperties(link, courseMap);
|
|
|
+
|
|
|
+ String courseJson = JSON.toJSONString(courseMap);
|
|
|
+ String realLinkFull = h5miniappLink + courseJson;
|
|
|
+ link.setRealLink(realLinkFull);
|
|
|
+
|
|
|
+
|
|
|
+ Integer expireDays = (setting.getExpiresDays() == null || setting.getExpiresDays() == 0)
|
|
|
+ ? config.getVideoLinkExpireDate()
|
|
|
+ : 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());
|
|
|
+ link.setUpdateTime(updateTime);
|
|
|
+
|
|
|
+ //存短链-
|
|
|
+ enqueueCourseLink(link);
|
|
|
+ return link.getRealLink();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String createH5LiveShortLink(QwSopTempSetting.Content.Setting setting, String corpId, String qwUserId, String companyUserId, String companyId) {
|
|
|
+
|
|
|
+ // 手动创建 FsCourseLink 对象,避免使用 BeanUtils.copyProperties
|
|
|
+ FsCourseLink link = new FsCourseLink();
|
|
|
+ link.setCompanyId(Long.parseLong(companyId));
|
|
|
+ link.setQwUserId(Long.valueOf(qwUserId));
|
|
|
+ link.setCompanyUserId(Long.parseLong(companyUserId));
|
|
|
+ link.setLiveId(setting.getLiveId());
|
|
|
+ link.setCorpId(corpId);
|
|
|
+ link.setUNo(UUID.randomUUID().toString());
|
|
|
+
|
|
|
+ String randomString = generateRandomStringWithLock();
|
|
|
+ if (StringUtil.strIsNullOrEmpty(randomString)) {
|
|
|
+ link.setLink(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+ } else {
|
|
|
+ link.setLink(randomString);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*FsCourseRealLink courseMap = new FsCourseRealLink();
|
|
|
+ BeanUtils.copyProperties(link, courseMap);*/
|
|
|
+
|
|
|
+ String courseJson = JSON.toJSONString(link);
|
|
|
+ String realLinkFull = h5LiveShortLink + courseJson;
|
|
|
+ link.setRealLink(realLinkFull);
|
|
|
+
|
|
|
+ //存短链-
|
|
|
+ enqueueCourseLink(link);
|
|
|
+ return link.getRealLink();
|
|
|
+
|
|
|
+ }
|
|
|
private String getAppIdFromMiniMap(Map<Long, Map<Integer, List<CompanyMiniapp>>> miniMap,
|
|
|
String companyId,
|
|
|
int sendMsgType,
|