|
|
@@ -1,177 +0,0 @@
|
|
|
-package com.malk.shunfeng.service.impl;
|
|
|
-
|
|
|
-import com.malk.server.common.McException;
|
|
|
-import com.malk.server.common.McR;
|
|
|
-import com.malk.shunfeng.server.txmeeting.TxMeetingR;
|
|
|
-import com.malk.shunfeng.server.zoom.ZoomR;
|
|
|
-import com.malk.shunfeng.service.MeetingService;
|
|
|
-import com.malk.shunfeng.service.TxMeetingClient;
|
|
|
-import com.malk.shunfeng.service.ZoomClient;
|
|
|
-import com.malk.service.dingtalk.DDClient;
|
|
|
-import com.malk.service.dingtalk.DDClient_Schedule;
|
|
|
-import com.malk.utils.UtilMap;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-/**
|
|
|
- * 会议统一服务实现
|
|
|
- * -
|
|
|
- * 路由 TX(腾讯会议) / ZOOM
|
|
|
- * 成功后调 DDClient_Schedule.eventsSchedule() 同步钉钉日程(失败不阻断主流程)
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@Service
|
|
|
-public class MeetingServiceImpl implements MeetingService {
|
|
|
-
|
|
|
- /** 平台常量 */
|
|
|
- private static final String PLATFORM_TX = "TX";
|
|
|
- private static final String PLATFORM_ZOOM = "ZOOM";
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TxMeetingClient txMeetingClient;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ZoomClient zoomClient;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private DDClient ddClient;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private DDClient_Schedule ddClient_Schedule;
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建会议
|
|
|
- * 成功后同步钉钉日程(失败不影响主流程)
|
|
|
- */
|
|
|
- @Override
|
|
|
- public McR createMeeting(String platform, String userId, String dingtalkUserId, Map body) {
|
|
|
- assertPlatform(platform);
|
|
|
- if (PLATFORM_TX.equalsIgnoreCase(platform)) {
|
|
|
- TxMeetingR r = txMeetingClient.createMeeting(userId, body);
|
|
|
- // ppExt: 创建成功后同步钉钉日程,失败仅记录日志
|
|
|
- syncDingtalkSchedule(r, dingtalkUserId, body);
|
|
|
- return McR.success(r);
|
|
|
- }
|
|
|
- // ZOOM
|
|
|
- ZoomR r = zoomClient.createMeeting(body);
|
|
|
- syncDingtalkScheduleZoom(r, dingtalkUserId, body);
|
|
|
- return McR.success(r);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新会议
|
|
|
- */
|
|
|
- @Override
|
|
|
- public McR updateMeeting(String platform, String meetingId, String userId, Map body) {
|
|
|
- assertPlatform(platform);
|
|
|
- if (PLATFORM_TX.equalsIgnoreCase(platform)) {
|
|
|
- TxMeetingR r = txMeetingClient.updateMeeting(meetingId, userId, body);
|
|
|
- return McR.success(r);
|
|
|
- }
|
|
|
- zoomClient.updateMeeting(meetingId, body);
|
|
|
- return McR.success();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 取消/删除会议
|
|
|
- */
|
|
|
- @Override
|
|
|
- public McR cancelMeeting(String platform, String meetingId, String userId) {
|
|
|
- assertPlatform(platform);
|
|
|
- if (PLATFORM_TX.equalsIgnoreCase(platform)) {
|
|
|
- TxMeetingR r = txMeetingClient.cancelMeeting(meetingId, userId);
|
|
|
- return McR.success(r);
|
|
|
- }
|
|
|
- zoomClient.deleteMeeting(meetingId);
|
|
|
- return McR.success();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询会议详情
|
|
|
- */
|
|
|
- @Override
|
|
|
- public McR getMeeting(String platform, String meetingId, String userId) {
|
|
|
- assertPlatform(platform);
|
|
|
- if (PLATFORM_TX.equalsIgnoreCase(platform)) {
|
|
|
- TxMeetingR r = txMeetingClient.getMeeting(meetingId, userId);
|
|
|
- return McR.success(r);
|
|
|
- }
|
|
|
- ZoomR r = zoomClient.getMeeting(meetingId);
|
|
|
- return McR.success(r);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建腾讯会议后同步钉钉日程
|
|
|
- * fixme: meetingInfoList 第一条即为新创建的会议,取 start_time/end_time 同步钉钉日程
|
|
|
- */
|
|
|
- private void syncDingtalkSchedule(TxMeetingR txR, String dingtalkUserId, Map body) {
|
|
|
- try {
|
|
|
- if (StringUtils.isBlank(dingtalkUserId)) return;
|
|
|
- List<Map<String, Object>> infoList = txR.getMeetingInfoList();
|
|
|
- if (infoList == null || infoList.isEmpty()) return;
|
|
|
- Map<String, Object> meetingInfo = infoList.get(0);
|
|
|
- Map scheduleBody = buildScheduleBody(meetingInfo, body);
|
|
|
- String accessToken = ddClient.getAccessToken();
|
|
|
- ddClient_Schedule.eventsSchedule(accessToken, dingtalkUserId, scheduleBody);
|
|
|
- log.info("[SF] 腾讯会议同步钉钉日程成功, dingtalkUserId={}", dingtalkUserId);
|
|
|
- } catch (Exception e) {
|
|
|
- // ppExt: 同步钉钉日程失败不阻断会议创建结果
|
|
|
- log.error("[SF] 同步钉钉日程失败(腾讯会议), error={}", e.getMessage(), e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建 Zoom 会议后同步钉钉日程
|
|
|
- */
|
|
|
- private void syncDingtalkScheduleZoom(ZoomR zoomR, String dingtalkUserId, Map body) {
|
|
|
- try {
|
|
|
- if (StringUtils.isBlank(dingtalkUserId)) return;
|
|
|
- Map scheduleBody = buildScheduleBodyZoom(zoomR, body);
|
|
|
- String accessToken = ddClient.getAccessToken();
|
|
|
- ddClient_Schedule.eventsSchedule(accessToken, dingtalkUserId, scheduleBody);
|
|
|
- log.info("[SF] Zoom 会议同步钉钉日程成功, dingtalkUserId={}", dingtalkUserId);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("[SF] 同步钉钉日程失败(Zoom), error={}", e.getMessage(), e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 构建腾讯会议 → 钉钉日程参数
|
|
|
- * fixme: startTime/endTime 需为 ISO-8601 格式,钉钉日程要求 timeZone 字段
|
|
|
- */
|
|
|
- private Map buildScheduleBody(Map<String, Object> meetingInfo, Map body) {
|
|
|
- String subject = String.valueOf(meetingInfo.getOrDefault("subject", body.getOrDefault("subject", "会议")));
|
|
|
- // ppExt: 腾讯会议时间戳为秒,需转为 ISO-8601 格式(如 2024-01-01T10:00:00+08:00)
|
|
|
- Object startTimeRaw = meetingInfo.getOrDefault("start_time", body.get("start_time"));
|
|
|
- Object endTimeRaw = meetingInfo.getOrDefault("end_time", body.get("end_time"));
|
|
|
- Map start = UtilMap.map("dateTime, timeZone", String.valueOf(startTimeRaw), "Asia/Shanghai");
|
|
|
- Map end = UtilMap.map("dateTime, timeZone", String.valueOf(endTimeRaw), "Asia/Shanghai");
|
|
|
- // cast 首参为 Object 以选 varargs 版 UtilMap.map(String, Object...) 避免命中 void 重载
|
|
|
- return UtilMap.map("summary, start, end", (Object) subject, start, end);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 构建 Zoom → 钉钉日程参数
|
|
|
- * fixme: Zoom start_time 已为 ISO-8601 格式
|
|
|
- */
|
|
|
- private Map buildScheduleBodyZoom(ZoomR zoomR, Map body) {
|
|
|
- String subject = zoomR.getTopic() != null ? zoomR.getTopic() : String.valueOf(body.getOrDefault("topic", "Zoom 会议"));
|
|
|
- String startTime = StringUtils.isNotBlank(zoomR.getStart_time()) ? zoomR.getStart_time() : String.valueOf(body.get("start_time"));
|
|
|
- Map start = UtilMap.map("dateTime, timeZone", startTime, "Asia/Shanghai");
|
|
|
- // fixme: Zoom 无 end_time,通过 start_time + duration(分钟)推算
|
|
|
- Map end = UtilMap.map("dateTime, timeZone", startTime, "Asia/Shanghai");
|
|
|
- return UtilMap.map("summary, start, end", (Object) subject, start, end);
|
|
|
- }
|
|
|
-
|
|
|
- private void assertPlatform(String platform) {
|
|
|
- McException.assertParamException(
|
|
|
- !PLATFORM_TX.equalsIgnoreCase(platform) && !PLATFORM_ZOOM.equalsIgnoreCase(platform),
|
|
|
- "platform 参数非法,支持 TX / ZOOM"
|
|
|
- );
|
|
|
- }
|
|
|
-}
|