提交 19e92585 作者: 洪东保

Merge branch 'hongdongbao'

......@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.robot</groupId>
<artifactId>cmeeting </artifactId>
<artifactId>cmeeting</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
......@@ -79,7 +79,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version> 2.7.0</version>
<version>2.5.15</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
......@@ -95,15 +95,22 @@
</exclusion>
</exclusions>
</dependency>
<!-- @Test 单元测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.5.15</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.7.0</version>
<version>2.5.15</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.7.0</version> <!-- 与你的 Spring Boot 版本保持一致 -->
<version>2.5.15</version> <!-- 与你的 Spring Boot 版本保持一致 -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -344,6 +351,7 @@
<artifactId>llm-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
......
......@@ -3,11 +3,14 @@ package com.cmeeting;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@MapperScan("com.@cmeeting.mapper.primary")
@EnableScheduling
@MapperScan("com.cmeeting.mapper.primary")
public class TencentMeetingCallbackApplication {
public static void main(String[] args) {
SpringApplication.run(TencentMeetingCallbackApplication.class, args);
......
......@@ -128,7 +128,7 @@ public class CmeetingJob {
log.info("无生成纪要权限的人员");
return;
}else{
log.info("生成纪要权限人员:->{}",accessUserIds.toString());
log.info("生成纪要权限人员:->{}", accessUserIds.stream().map(UserDTO::getWid).collect(Collectors.joining(",")));
}
List<TencentMeetingVO.RecordFile> meetingFiles = tencentMeetingService.getMeetingFiles(accessUserIds,weComUserMap);
......
......@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
......@@ -21,6 +23,7 @@ import java.time.LocalDateTime;
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("cmt_meeting_info")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MeetingInfo implements Serializable {
private static final long serialVersionUID = -26238487532381000L;
......@@ -138,4 +141,7 @@ public class MeetingInfo implements Serializable {
* 转录文件知识库id
*/
private String transDocId;
@Ignore
private String userId;
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import cn.chatbot.openai.completion.chat.ChatMessage;
import cn.chatbot.openai.completion.chat.ChatMessageRole;
import cn.chatbot.openai.completion.chat.Message;
import cn.chatbot.openai.service.LLMService;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson2.JSON;
......@@ -17,12 +18,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cmeeting.ad.entity.RobotSecurityUser;
import com.cmeeting.ad.util.SecurityUtil;
import com.cmeeting.constant.RecordTemplateConstant;
import com.cmeeting.log.service.ProcessLogService;
import com.cmeeting.mapper.primary.MeetingInfoMapper;
import com.cmeeting.mapper.primary.MeetingRecordTemplateMapper;
import com.cmeeting.mapper.primary.UserIdMapper;
import com.cmeeting.pojo.MeetingInfo;
import com.cmeeting.pojo.MeetingRecordTemplate;
import com.cmeeting.pojo.UserId;
import com.cmeeting.service.MeetingInfoService;
import com.cmeeting.util.MinioUtils;
import com.cmeeting.vo.EmailPush;
......@@ -80,8 +83,6 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti
private String tencentAdminUserId;
@Value(value = "${llm.api-addr}")
private String llmApiAddr;
@Value(value = "${tencent.base-save-path}")
private String baseSavePath;
@Resource
private ProcessLogService processLogService;
@Resource
......@@ -97,16 +98,29 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti
String userId = user.getId();
//根据员工号获取腾会uid
String tid = userIdMapper.getTidByWid(userId);
if(StringUtils.isEmpty(tid)){
if(user.getRole().equals(RecordTemplateConstant.TEMPLATE_TYPE_CUSTOM) && StringUtils.isEmpty(tid)){
log.error("获取历史会议列表失败:根据员工号"+userId+"获取腾会uid失败");
return new Page<>(0,0);
}
LambdaQueryWrapper<MeetingInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(MeetingInfo::getHostUid,tid);
queryWrapper.like(StringUtils.isNotEmpty(vo.getSubject()),MeetingInfo::getSubject,vo.getSubject());
queryWrapper.between(vo.getStartTime() != null,MeetingInfo::getStartTime,vo.getStartTime(),vo.getEndTime());
IPage<MeetingInfo> resultPage = mapper.selectPage(new Page<>(vo.getCurrent(), vo.getSize()), queryWrapper);
return resultPage;
LambdaQueryWrapper<MeetingInfo> queryWrapper = new LambdaQueryWrapper<MeetingInfo>()
.eq(user.getRole().equals(RecordTemplateConstant.TEMPLATE_TYPE_CUSTOM), MeetingInfo::getHostUid, tid)
.like(StringUtils.isNotEmpty(vo.getSubject()),MeetingInfo::getSubject,vo.getSubject())
.between(vo.getStartTime() != null, MeetingInfo::getStartTime, vo.getStartTime(), vo.getEndTime())
.select(MeetingInfo::getId, MeetingInfo::getMeetingId, MeetingInfo::getSubject, MeetingInfo::getHost, MeetingInfo::getHostUid,
MeetingInfo::getStartTime, MeetingInfo::getEndTime, MeetingInfo::getIsGenerated, MeetingInfo::getIsPushed);
// TODO查询部门
Page<MeetingInfo> meetingInfoPage = mapper.selectPage(new Page<>(vo.getCurrent(), vo.getSize()), queryWrapper);
if (CollUtil.isNotEmpty(meetingInfoPage.getRecords())) {
List<MeetingInfo> records = meetingInfoPage.getRecords();
List<String> uids = records.stream().map(MeetingInfo::getHostUid).collect(Collectors.toList());
List<UserId> userIds = userIdMapper.selectList(new LambdaQueryWrapper<UserId>().in(UserId::getTid, uids).select(UserId::getTid, UserId::getWid));
Map<String, String> collect = userIds.stream().collect(Collectors.toMap(UserId::getTid, UserId::getWid));
for (MeetingInfo record : records) {
record.setUserId(collect.get(record.getHostUid()));
}
meetingInfoPage.setRecords(records);
}
return meetingInfoPage;
}
@Override
......
......@@ -14,6 +14,7 @@ import com.cmeeting.pojo.WeComUser;
import com.cmeeting.service.TencentMeetingService;
import com.cmeeting.util.RedisUtils;
import com.cmeeting.util.SignatureUtil;
import com.cmeeting.util.TencentMeetingApiUtil;
import com.cmeeting.vo.CorpRecordsVO;
import com.cmeeting.vo.TencentMeetingVO;
import com.google.gson.*;
......@@ -83,6 +84,8 @@ public class TencentMeetingServiceImpl extends ServiceImpl<TecentMeetingMapper,T
private String permissionApplicationId;
@Value(value = "${permission.tenantId}")
private String permissionTenantId;
@Resource
private TencentMeetingApiUtil tencentMeetingApiUtil;
@Override
public void batchInsert(List<TencentMeetingUser> users) {
......@@ -141,21 +144,12 @@ public class TencentMeetingServiceImpl extends ServiceImpl<TecentMeetingMapper,T
//设置总页数
if (data != null && data.getRecordMeetings() != null && !data.getRecordMeetings().isEmpty()) {
List<CorpRecordsVO.RecordMeeting> meetings = data.getRecordMeetings();
//录制状态:
//1:录制中
//2:转码中
//3:转码完成
for (CorpRecordsVO.RecordMeeting meeting : meetings) {
//录制文件未转码完成,跳过
//录制文件未转码完成,跳过 1:录制中 2:转码中 3:转码完成
if(meeting.getState() != 3){
// processLogService.log(meeting.getMeetingId(),null,"会议未结束,跳过生成");
continue;
}
log.info("【会议检索】转录文件的meetingId->{},recordFileId->{}",meeting.getMeetingId(),meeting.getMeetingRecordId());
//查询会议详情
String meetingId = meeting.getMeetingId();
String subMeetingId = null;
......@@ -274,19 +268,20 @@ public class TencentMeetingServiceImpl extends ServiceImpl<TecentMeetingMapper,T
log.info("【权限校验】主持人{}允许生成纪要",hostId);
// processLogService.log(meeting.getMeetingId(),subMeetingId,"【权限校验】主持人"+hostId+"允许生成纪要");
UserDTO userDTO = accessUserIds.stream().filter(item -> item.getTid().equals(hostId)).findFirst().get();
String email = userDTO.getEmail();
Boolean emailPushAccess = weComUserMap.containsKey(userDTO.getWid())
? weComUserMap.get(userDTO.getWid()).getEmailPushAccess() : Boolean.FALSE;
// 查询会议开始和结束时间
MeetingInfo startAndEndTimeByMeetingId = tencentMeetingApiUtil.getStartAndEndTimeByMeetingId(meetingId);
//会议基本信息保存
MeetingInfo meetingItem = MeetingInfo.builder().meetingId(meetingId).meetingCode(meeting.getMeetingCode())
.subject(meeting.getSubject())
.startTime(mediaStartTime)
// .endTime(LocalDateTime.ofInstant(Instant.ofEpochSecond(Long.valueOf(meeting.getEndTime())), ZoneId.systemDefault()))
.startTime(startAndEndTimeByMeetingId != null ? startAndEndTimeByMeetingId.getStartTime() : mediaStartTime)
.endTime(startAndEndTimeByMeetingId != null ? startAndEndTimeByMeetingId.getEndTime() : null)
.isGenerated(Boolean.FALSE).emailPushAccess(emailPushAccess).isPushed(Boolean.FALSE).syncTime(LocalDateTime.now())
.subMeetingId(subMeetingId).generateRetry(Boolean.FALSE).pushRetry(Boolean.FALSE)
.host(hostName)
......
package com.cmeeting.util;
import cn.hutool.core.collection.CollUtil;
import com.cmeeting.pojo.MeetingInfo;
import com.cmeeting.util.SignatureUtil;
import com.cmeeting.vo.CorpRecordsVO;
import com.google.gson.*;
import com.tencentcloudapi.wemeet.Client;
import com.tencentcloudapi.wemeet.core.authenticator.AuthenticatorBuilder;
import com.tencentcloudapi.wemeet.core.authenticator.JWTAuthenticator;
import com.tencentcloudapi.wemeet.core.exception.ClientException;
import com.tencentcloudapi.wemeet.core.exception.ServiceException;
import com.tencentcloudapi.wemeet.service.meetings.api.MeetingsApi;
import com.tencentcloudapi.wemeet.service.meetings.model.V1MeetingsMeetingIdGet200Response;
import com.tencentcloudapi.wemeet.service.meetings.model.V1MeetingsMeetingIdGet200ResponseMeetingInfoListInner;
import com.tencentcloudapi.wemeet.service.meetings.model.V1MeetingsMeetingIdParticipantsGet200Response;
import com.tencentcloudapi.wemeet.service.meetings.model.V1MeetingsMeetingIdParticipantsGet200ResponseParticipantsInner;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Optional;
import java.util.Random;
/**
* 腾讯会议API工具类
*/
@Slf4j
@Component
public class TencentMeetingApiUtil {
public static void main(String[] args) throws Exception {
private static String tencentAppId;
@Value("${tencent.appId}")
private String tmpAppId;
private static String tencentSdkId;
@Value("${tencent.sdkId}")
private String tmpSdkId;
private static String tencentSecretId;
@Value("${tencent.secretId}")
private String tmpSecretId;
private static String tencentSecretKey;
@Value("${tencent.secretKey}")
private String tmpSecretKey;
private static String tencentAdminUserId;
@Value("${tencent.admin.userId}")
private String tmpAdminUserId;
private static Client client;
@PostConstruct
public void init() {
tencentAppId = tmpAppId;
tencentSdkId = tmpSdkId;
tencentSecretId = tmpSecretId;
tencentSecretKey = tmpSecretKey;
tencentAdminUserId = tmpAdminUserId;
client = getClient();
}
private Client getClient() {
if (client == null) {
synchronized (TencentMeetingApiUtil.class) {
if (client == null) {
client = new Client.Builder()
.withAppId(tencentAppId)
.withSdkId(tencentSdkId)
.withSecret(tencentSecretId, tencentSecretKey)
.build();
}
}
}
return client;
}
/**
* 查询会议开始结束时间
* Api: /v1/meetings/{meeting_id}
* @param meetingId 腾讯会议id
* @return
*/
public static MeetingInfo getStartAndEndTimeByMeetingId(String meetingId) {
MeetingInfo info = new MeetingInfo();
AuthenticatorBuilder<JWTAuthenticator> participantsAuthenticatorBuilder =
new JWTAuthenticator.Builder()
.nonce(BigInteger.valueOf(Math.abs((new SecureRandom()).nextInt())))
.timestamp(String.valueOf(System.currentTimeMillis() / 1000L));
MeetingsApi.ApiV1MeetingsMeetingIdGetRequest request = new MeetingsApi.ApiV1MeetingsMeetingIdGetRequest
.Builder(meetingId).operatorId(tencentAdminUserId).operatorIdType("1").instanceid("2").build();
MeetingsApi.ApiV1MeetingsMeetingIdGetResponse response = null;
try {
response = client.meetings().v1MeetingsMeetingIdGet(request, participantsAuthenticatorBuilder);
V1MeetingsMeetingIdGet200Response data = response.getData();
List<V1MeetingsMeetingIdGet200ResponseMeetingInfoListInner> meetingInfoList = data.getMeetingInfoList();
for (V1MeetingsMeetingIdGet200ResponseMeetingInfoListInner meetingInfoListInner : meetingInfoList) {
if (meetingInfoListInner.getMeetingId().equals(meetingId)) {
info.setMeetingId(meetingId);
info.setStartTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(meetingInfoListInner.getStartTime()) * 1000), ZoneId.systemDefault()));
info.setEndTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(meetingInfoListInner.getEndTime()) * 1000), ZoneId.systemDefault()));
}
}
return info;
} catch (ClientException | ServiceException e) {
log.error("query meet start and end time error! message: {}", e.getMessage());
}
return null;
}
private void getSomething() throws Exception {
int total = 100000000;
int count = 0;
......@@ -71,7 +174,7 @@ public class TencentMeetingApiUtil {
for (CorpRecordsVO.RecordMeeting recordMeeting : corpRecords.getRecordMeetings()) {
String subject = recordMeeting.getSubject();
if (subject.contains("启动会")) {
count ++;
count++;
System.out.println("会议名: " + subject);
String meetingRecordId = recordMeeting.getMeetingRecordId();
System.out.println("meetingRecordId: " + meetingRecordId);
......@@ -92,4 +195,5 @@ public class TencentMeetingApiUtil {
}
}
}
}
......@@ -97,7 +97,8 @@ tencent:
sdkId: ${TENCENT_SDKID}
secretId: ${TENCENT_SECRETID}
secretKey: ${TENCENT_SECRETKEY}
admin.userId: ${TENCENT_ADMIN_USERID}
admin:
userId: ${TENCENT_ADMIN_USERID}
meeting:
token: QQZNb7xWQB47MpZF4C2DFAkv8
aesKey: agy6ALUePp34lljWz1uIQWa7yQq3dgxxQNmfaN9GROm
......
package test;
package com.cmeeting;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.cmeeting.pojo.MeetingInfo;
import com.cmeeting.util.TencentMeetingApiUtil;
import com.tencentcloudapi.wemeet.Client;
import com.tencentcloudapi.wemeet.core.authenticator.JWTAuthenticator;
import com.tencentcloudapi.wemeet.core.exception.ClientException;
......@@ -13,7 +15,10 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.math.BigInteger;
......@@ -21,6 +26,7 @@ import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.List;
@SpringBootTest
public class MeetingApiTest {
public static void main(String[] args) throws ServiceException, ClientException {
......@@ -89,4 +95,13 @@ public class MeetingApiTest {
throw new RuntimeException("下载文件失败", e);
}
}
@Test
public void test(){
MeetingInfo info = TencentMeetingApiUtil.getStartAndEndTimeByMeetingId("4391367006554084716");
System.out.println(info.getMeetingId());
System.out.println(info.getStartTime());
System.out.println(info.getEndTime());
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论