添加功能
This commit is contained in:
parent
09f34cbada
commit
4f4277599c
|
@ -1,36 +1,45 @@
|
|||
package org.jeecg.modules.tencent.utils;
|
||||
|
||||
import com.tencentcloudapi.wemeet.client.MeetingClient;
|
||||
import com.tencentcloudapi.wemeet.common.constants.InstanceEnum;
|
||||
import com.tencentcloudapi.wemeet.common.exception.WemeetSdkException;
|
||||
import com.tencentcloudapi.wemeet.models.MeetingSetting;
|
||||
import com.tencentcloudapi.wemeet.models.User;
|
||||
import com.tencentcloudapi.wemeet.models.meeting.CreateMeetingRequest;
|
||||
import com.tencentcloudapi.wemeet.models.meeting.QueryMeetingDetailResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.tencentcloudapi.wemeet.client.UserClient;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.squareup.okhttp.Interceptor;
|
||||
import com.squareup.okhttp.Response;
|
||||
import com.tencentcloudapi.wemeet.client.MeetingClient;
|
||||
import com.tencentcloudapi.wemeet.client.UserClient;
|
||||
import com.tencentcloudapi.wemeet.common.RequestSender;
|
||||
import com.tencentcloudapi.wemeet.common.constants.InstanceEnum;
|
||||
import com.tencentcloudapi.wemeet.common.exception.WemeetSdkException;
|
||||
import com.tencentcloudapi.wemeet.common.profile.HttpProfile;
|
||||
import com.tencentcloudapi.wemeet.models.MeetingSetting;
|
||||
import com.tencentcloudapi.wemeet.models.User;
|
||||
import com.tencentcloudapi.wemeet.models.meeting.CreateMeetingRequest;
|
||||
import com.tencentcloudapi.wemeet.models.meeting.QueryMeetingDetailResponse;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.kc.ktgl.entity.KcKetangbiao;
|
||||
import org.jeecg.modules.kc.ktgl.service.IKcKetangbiaoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class TencentUtils {
|
||||
@RestController
|
||||
@RequestMapping("/tencentUtil")
|
||||
public class TencentUtils extends JeecgController<KcKetangbiao, IKcKetangbiaoService> {
|
||||
@Autowired
|
||||
private IKcKetangbiaoService kcKetangbiaoService;
|
||||
|
||||
private static final Log log = LogFactory.getLog(TencentUtils.class);
|
||||
// 初始化全局client
|
||||
/**
|
||||
|
@ -115,4 +124,83 @@ public class TencentUtils {
|
|||
log.info(mettingCode);
|
||||
log.info(GSON.toJson(response));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value="生成腾讯会议", notes="生成腾讯会议")
|
||||
@PostMapping(value = "/addTencent")
|
||||
public Result<String> addTencent(@RequestBody KcKetangbiao kcKetangbiao,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<KcKetangbiao> queryWrapper = QueryGenerator.initQueryWrapper(kcKetangbiao, req.getParameterMap());
|
||||
queryWrapper.ge(StringUtils.isNotBlank(kcKetangbiao.getStartTime()),"skrq",kcKetangbiao.getStartTime());
|
||||
queryWrapper.le(StringUtils.isNotBlank(kcKetangbiao.getEndTime()),"skrq",kcKetangbiao.getEndTime());
|
||||
// queryWrapper.apply("limit 10");
|
||||
// queryWrapper.last("limit 1");
|
||||
List<KcKetangbiao> pageList = kcKetangbiaoService.list(queryWrapper);
|
||||
int successNum = 0;
|
||||
int errorNum = 0;
|
||||
String errorTitle = "";
|
||||
for(int i=0;i<pageList.size();i++){
|
||||
KcKetangbiao kcKetangbiaoPar = pageList.get(i);
|
||||
try {
|
||||
|
||||
CreateMeetingRequest request = new CreateMeetingRequest();
|
||||
request.setInstanceId(InstanceEnum.INSTANCE_MAC.getInstanceID());
|
||||
request.setUserId(kcKetangbiaoPar.getJgh());
|
||||
request.setSubject(kcKetangbiaoPar.getSkjs()+" - "+kcKetangbiaoPar.getKcmc());
|
||||
request.setType(0);
|
||||
String skrq = kcKetangbiaoPar.getSkrq();
|
||||
String hhks = kcKetangbiaoPar.getHhks();
|
||||
String hhjs = kcKetangbiaoPar.getHhjs();
|
||||
String startTime = skrq+" "+hhks.substring(0,2)+":"+hhks.substring(2)+":00";
|
||||
String endTime = skrq+" "+hhjs.substring(0,2)+":"+hhjs.substring(2)+":00";
|
||||
Date ks = DateUtils.parseDate(startTime,"yyyy-MM-dd HH:mm:ss");
|
||||
Date js = DateUtils.parseDate(endTime,"yyyy-MM-dd HH:mm:ss");
|
||||
String kspar = (ks.getTime()+"").substring(0,10);
|
||||
String jspar = (js.getTime()+"").substring(0,10);
|
||||
request.setStartTime(kspar);
|
||||
request.setEndTime(jspar);
|
||||
MeetingSetting meetingSetting = new MeetingSetting();
|
||||
meetingSetting.setMuteEnableJoin(true);
|
||||
meetingSetting.setAllowUnmuteSelf(false);
|
||||
meetingSetting.setMuteAll(false);
|
||||
meetingSetting.setPlayIvrOnLeave(false);
|
||||
meetingSetting.setPlayIvrOnJoin(false);
|
||||
meetingSetting.setAllowInBeforeHost(true);
|
||||
meetingSetting.setAutoInWaitingRoom(false);
|
||||
meetingSetting.setAllowScreenSharedWatermark(false);
|
||||
meetingSetting.setOnlyEnterpriseUserAllowed(false);
|
||||
request.setSettings(meetingSetting);
|
||||
request.setMeetingType(0);
|
||||
List<User> userList = new ArrayList<>();
|
||||
User user = new User();
|
||||
user.setUserId(kcKetangbiaoPar.getJgh());
|
||||
userList.add(user);
|
||||
request.setHosts(userList);
|
||||
QueryMeetingDetailResponse response = MEETING_CLIENT.createMeeting(request);
|
||||
String mettingId = response.getMeetingInfoList().get(0).getMeetingId();
|
||||
String joinUrl = response.getMeetingInfoList().get(0).getJoinUrl();
|
||||
String mettingCode = response.getMeetingInfoList().get(0).getMeetingCode();
|
||||
log.info(mettingId);
|
||||
log.info(joinUrl);
|
||||
log.info(mettingCode);
|
||||
log.info(GSON.toJson(response));
|
||||
kcKetangbiaoPar.setKclj(joinUrl);
|
||||
kcKetangbiaoPar.setHyid(mettingId);
|
||||
kcKetangbiaoPar.setHyh(mettingCode);
|
||||
kcKetangbiaoService.updateById(kcKetangbiaoPar);
|
||||
|
||||
// errorTitle += "会议id:"+mettingId+";链接地址:"+joinUrl+";开始时间:"+kspar+";结束时间:"+jspar+"<br/>";
|
||||
successNum++;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
errorTitle += kcKetangbiaoPar.getSkjs()+" - "+kcKetangbiaoPar.getKcmc()+";表id:"+kcKetangbiaoPar.getId()+"<br/>";
|
||||
errorNum ++;
|
||||
}
|
||||
}
|
||||
if(StringUtils.isEmpty(errorTitle)){
|
||||
errorTitle = "无";
|
||||
}
|
||||
String resMessage = "成功:"+successNum+"条,失败:"+errorNum+"条;失败课程:<br/>"+errorTitle;
|
||||
return Result.OK(resMessage);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue