From f1aff5ff7f21c266f394140e2cbafa5779ad1fb6 Mon Sep 17 00:00:00 2001 From: DengMin <16679070171@qq.com> Date: Wed, 3 Aug 2022 14:46:50 +0800 Subject: [PATCH] websocket发送班级配置 --- src/main/java/com/subsidy/controller/CompanyDictController.java | 21 +++++++++++++++++++++ src/main/java/com/subsidy/mapper/ClassDictMapper.java | 4 ++++ src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java | 2 ++ src/main/java/com/subsidy/util/websocket/WebSocketUtil.java | 11 +++++++++++ src/main/java/com/subsidy/vo/classdict/ClassSettingsVO.java | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/resources/mapper/ClassDictMapper.xml | 16 ++++++++++++++++ 6 files changed, 126 insertions(+) create mode 100644 src/main/java/com/subsidy/vo/classdict/ClassSettingsVO.java diff --git a/src/main/java/com/subsidy/controller/CompanyDictController.java b/src/main/java/com/subsidy/controller/CompanyDictController.java index 17182ce..d38a194 100644 --- a/src/main/java/com/subsidy/controller/CompanyDictController.java +++ b/src/main/java/com/subsidy/controller/CompanyDictController.java @@ -84,4 +84,25 @@ public class CompanyDictController { return ResponseData.generateCreatedResponse(0,companyDictService.memberSummary(getCompanyMembersDTO)); } + @PostMapping(value = "getCompanyDataOverview") + @ApiOperation("数据统计") + @LoginRequired + public ResponseVO getCompanyDataOverview() { + return ResponseData.generateCreatedResponse(0, companyDictService.getCompanyDataOverview()); + } + + @PostMapping(value = "getCDNBandwidthStatDetails") + @ApiOperation("带宽使用情况") + @LoginRequired + public ResponseVO getCDNBandwidthStatDetails() { + return ResponseData.generateCreatedResponse(0, companyDictService.getCDNBandwidthStatDetails()); + } + + @PostMapping(value = "getCDNFluxStatDetails") + @ApiOperation("流量使用情况") + @LoginRequired + public ResponseVO getCDNFluxStatDetails() { + return ResponseData.generateCreatedResponse(0, companyDictService.getCDNFluxStatDetails()); + } + } diff --git a/src/main/java/com/subsidy/mapper/ClassDictMapper.java b/src/main/java/com/subsidy/mapper/ClassDictMapper.java index 32d2680..2c0a764 100644 --- a/src/main/java/com/subsidy/mapper/ClassDictMapper.java +++ b/src/main/java/com/subsidy/mapper/ClassDictMapper.java @@ -6,8 +6,10 @@ import com.subsidy.model.ClassDictDO; import com.subsidy.model.MemberDO; import com.subsidy.model.VodDictDO; import com.subsidy.vo.classdict.ClassAndCompanyInfoVO; +import com.subsidy.vo.classdict.ClassSettingsVO; import com.subsidy.vo.classdict.GetAllClassesVO; import com.subsidy.vo.classdict.GetClassBaseInfoVO; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -55,4 +57,6 @@ public interface ClassDictMapper extends BaseMapper { ClassAndCompanyInfoVO getClassAndCompanyInfoVO(Long classId); Integer getClassCount(); + + List getClassSettings(@Param("userId") Long userId); } diff --git a/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java b/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java index caf6104..a280e56 100644 --- a/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java @@ -364,6 +364,7 @@ public class CompanyDictServiceImpl extends ServiceImpl data = new ArrayList<>(); if(EhCacheUtil.getEhCache(VodConstant.CDN_STAT_DETAILS_CACHE_NAME, VodConstant.BANDWIDTH_CACHE_KEY) != null) { @@ -392,6 +393,7 @@ public class CompanyDictServiceImpl extends ServiceImpl data = new ArrayList<>(); if(EhCacheUtil.getEhCache(VodConstant.CDN_STAT_DETAILS_CACHE_NAME, VodConstant.FLUX_CACHE_KEY) != null) { diff --git a/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java b/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java index ca5b097..63ee8bc 100644 --- a/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java +++ b/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java @@ -3,11 +3,14 @@ package com.subsidy.util.websocket; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.subsidy.common.ResponseData; +import com.subsidy.mapper.ClassDictMapper; import com.subsidy.mapper.OprMemDictMapper; import com.subsidy.model.OprMemDictDO; import com.subsidy.util.DateFormatUtil; +import com.subsidy.vo.classdict.ClassSettingsVO; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.socket.CloseStatus; @@ -40,6 +43,9 @@ public class WebSocketUtil implements WebSocketHandler { @Autowired private OprMemDictMapper oprMemDictMapper; + @Autowired + private ClassDictMapper classDictMapper; + private int heartbeatMin = 1; // 断连最小心跳次数 private int heartbeatMax = 3; // 断连最大心跳次数 private int reconnectionSeconds = 60; //每次断连间隔重新连接秒 @@ -93,6 +99,11 @@ public class WebSocketUtil implements WebSocketHandler { } webSocketMap.put(id, session); + List list = classDictMapper.getClassSettings(id); + if(CollectionUtils.isNotEmpty(list)) { + webSocketMap.get(id).sendMessage(new TextMessage(JSONObject.toJSONString(ResponseData.generateCreatedResponse(0, list)))); + } + String httpSessionId = session.getId(); String host = session.getUri().getHost(); String query = session.getUri().getQuery(); diff --git a/src/main/java/com/subsidy/vo/classdict/ClassSettingsVO.java b/src/main/java/com/subsidy/vo/classdict/ClassSettingsVO.java new file mode 100644 index 0000000..97b294b --- /dev/null +++ b/src/main/java/com/subsidy/vo/classdict/ClassSettingsVO.java @@ -0,0 +1,72 @@ +package com.subsidy.vo.classdict; + +import lombok.Data; + +@Data +public class ClassSettingsVO { + + /** + * 是否按照顺序播放 + */ + private Integer isOrder; + + /** + * 是否允许快进 + */ + private Integer isFastPlay; + + /** + * 测试规则 + */ + private Integer testRule; + + /** + * 学习上限时长 + */ + private Integer limitHour; + + /** + * 首次进入班级时人脸验证 + */ + private Integer imageClassCheck; + + /** + * 测试前人脸识别验证 + */ + private Integer imageTestCheck; + + /** + * 活跃度检测开启/关闭 + */ + private Integer activityDetection; + + /** + * 活跃度检测方式 + */ + private Integer activityDetectionMethod; + + /** + * 首次播放允许拖曳 + */ + private Integer firstDragAllowed; + + /** + * 首次播放允许倍速 + */ + private Integer firstSpeedAllowed; + + /** + * 课时抓拍 + */ + private Integer playSnap; + + /** + * + */ + private Integer ipAddressRecord; + + /** + * + */ + private Integer deviceNoRecord; +} diff --git a/src/main/resources/mapper/ClassDictMapper.xml b/src/main/resources/mapper/ClassDictMapper.xml index c4599b6..6b4b8e8 100644 --- a/src/main/resources/mapper/ClassDictMapper.xml +++ b/src/main/resources/mapper/ClassDictMapper.xml @@ -181,4 +181,20 @@ AND t1.delete_date IS NULL AND t2.delete_date IS NULL + + -- libgit2 0.25.0