Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
涂亚平
/
subsidy
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 660ff3e9
authored
Aug 08, 2022
by
邓敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新班级WebSocket消息通知
1 parent
52d13bc2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
6 deletions
src/main/java/com/subsidy/mapper/ClassMemberMappingMapper.java
src/main/java/com/subsidy/service/ClassDictService.java
src/main/java/com/subsidy/service/impl/ClassDictServiceImpl.java
src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java
src/main/java/com/subsidy/util/websocket/WebSocketUtil.java
src/main/resources/mapper/ClassMemberMappingMapper.xml
src/main/resources/mapper/VodDictMapper.xml
src/main/java/com/subsidy/mapper/ClassMemberMappingMapper.java
View file @
660ff3e
...
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.subsidy.model.ClassDictDO
;
import
com.subsidy.model.ClassMemberMappingDO
;
import
com.subsidy.vo.administer.ClassDailyInfoVO
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
...
...
@@ -39,4 +40,6 @@ public interface ClassMemberMappingMapper extends BaseMapper<ClassMemberMappingD
* 获取学生当前有效班级
*/
long
getMemberClassCount
(
Long
memberId
);
List
<
ClassMemberMappingDO
>
getCLassMemberByCompanyId
(
@Param
(
"companyId"
)
Long
companyId
);
}
src/main/java/com/subsidy/service/ClassDictService.java
View file @
660ff3e
...
...
@@ -11,6 +11,7 @@ import com.subsidy.model.MemberDO;
import
com.subsidy.vo.classdict.GetAllClassesVO
;
import
com.subsidy.vo.classdict.GetClassBaseInfoVO
;
import
java.io.IOException
;
import
java.util.List
;
/**
...
...
src/main/java/com/subsidy/service/impl/ClassDictServiceImpl.java
View file @
660ff3e
package
com
.
subsidy
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.subsidy.common.ResponseData
;
import
com.subsidy.common.constant.CourseNotification
;
import
com.subsidy.common.exception.HttpException
;
import
com.subsidy.dto.classDict.AddClassDTO
;
...
...
@@ -33,14 +36,20 @@ import com.subsidy.util.ConstantUtils;
import
com.subsidy.util.DateFormatUtil
;
import
com.subsidy.util.QuartzUtil
;
import
com.subsidy.util.SMSUtils
;
import
com.subsidy.util.websocket.WebSocketUtil
;
import
com.subsidy.vo.classdict.ClassSettingsVO
;
import
com.subsidy.vo.classdict.GetAllClassesVO
;
import
com.subsidy.vo.classdict.GetClassBaseInfoVO
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.socket.TextMessage
;
import
org.springframework.web.socket.WebSocketSession
;
import
java.io.IOException
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
...
...
@@ -153,6 +162,24 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict
public
String
updateClass
(
ClassDictDO
classDictDO
)
{
this
.
baseMapper
.
updateById
(
classDictDO
);
List
<
ClassMemberMappingDO
>
list
=
classMemberMappingMapper
.
selectList
(
new
QueryWrapper
<
ClassMemberMappingDO
>()
.
lambda
()
.
eq
(
ClassMemberMappingDO:
:
getClassId
,
classDictDO
.
getId
()));
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
for
(
ClassMemberMappingDO
classMemberMappingDO
:
list
)
{
WebSocketSession
webSocketSession
=
WebSocketUtil
.
webSocketMap
.
get
(
classMemberMappingDO
.
getMemberId
());
if
(
null
!=
webSocketSession
&&
webSocketSession
.
isOpen
())
{
try
{
List
<
ClassSettingsVO
>
classSettings
=
this
.
baseMapper
.
getClassSettings
(
classMemberMappingDO
.
getMemberId
());
String
data
=
JSONObject
.
toJSONString
(
ResponseData
.
generateCreatedResponse
(
0
,
classSettings
),
SerializerFeature
.
WriteMapNullValue
);
webSocketSession
.
sendMessage
(
new
TextMessage
(
data
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
return
ConstantUtils
.
SET_SUCCESS
;
}
...
...
src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java
View file @
660ff3e
package
com
.
subsidy
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.subsidy.common.ResponseData
;
import
com.subsidy.common.configure.VODConfig
;
import
com.subsidy.common.constant.VodConstant
;
import
com.subsidy.common.exception.HttpException
;
...
...
@@ -33,7 +36,9 @@ import com.subsidy.util.ConstantUtils;
import
com.subsidy.util.DateFormatUtil
;
import
com.subsidy.util.EhCacheUtil
;
import
com.subsidy.util.VodUtil
;
import
com.subsidy.util.websocket.WebSocketUtil
;
import
com.subsidy.vo.administer.OperatorsVO
;
import
com.subsidy.vo.classdict.ClassSettingsVO
;
import
com.subsidy.vo.company.CDNStatDetailsVO
;
import
com.subsidy.vo.company.DataOverviewVO
;
import
com.subsidy.vo.company.GetAllCompanyVO
;
...
...
@@ -44,6 +49,9 @@ import com.subsidy.vo.company.MemberSummaryVO;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.socket.TextMessage
;
import
org.springframework.web.socket.WebSocketSession
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
...
...
@@ -105,6 +113,9 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa
private
VodPlayHistoryMapper
vodPlayHistoryMapper
;
@Autowired
private
ClassMemberMappingMapper
classMemberMappingMapper
;
@Autowired
private
VODConfig
vodConfig
;
public
IPage
<
OperatorsVO
>
operators
(
OperatorsDTO
operatorsDTO
)
{
...
...
@@ -281,6 +292,22 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa
public
String
updateCompanySettings
(
CompanyDictDO
companyDictDO
)
{
this
.
baseMapper
.
updateById
(
companyDictDO
);
List
<
ClassMemberMappingDO
>
list
=
classMemberMappingMapper
.
getCLassMemberByCompanyId
(
companyDictDO
.
getId
());
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
for
(
ClassMemberMappingDO
classMemberMappingDO
:
list
)
{
WebSocketSession
webSocketSession
=
WebSocketUtil
.
webSocketMap
.
get
(
classMemberMappingDO
.
getMemberId
());
if
(
null
!=
webSocketSession
&&
webSocketSession
.
isOpen
())
{
try
{
List
<
ClassSettingsVO
>
classSettings
=
classDictMapper
.
getClassSettings
(
classMemberMappingDO
.
getMemberId
());
String
data
=
JSONObject
.
toJSONString
(
ResponseData
.
generateCreatedResponse
(
0
,
classSettings
),
SerializerFeature
.
WriteMapNullValue
);
webSocketSession
.
sendMessage
(
new
TextMessage
(
data
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
return
ConstantUtils
.
SET_SUCCESS
;
}
...
...
src/main/java/com/subsidy/util/websocket/WebSocketUtil.java
View file @
660ff3e
package
com
.
subsidy
.
util
.
websocket
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
...
@@ -20,8 +19,6 @@ import org.springframework.web.socket.TextMessage;
import
org.springframework.web.socket.WebSocketHandler
;
import
org.springframework.web.socket.WebSocketMessage
;
import
org.springframework.web.socket.WebSocketSession
;
import
javax.websocket.OnMessage
;
import
java.io.IOException
;
import
java.util.Calendar
;
import
java.util.Date
;
...
...
@@ -51,13 +48,13 @@ public class WebSocketUtil implements WebSocketHandler {
private
ClassDictMapper
classDictMapper
;
private
int
heartbeatMin
=
1
;
// 断连最小心跳次数
private
int
heartbeatMax
=
3
;
// 断连最大心跳次数
private
int
heartbeatMax
=
2
;
// 断连最大心跳次数
private
int
reconnectionSeconds
=
60
;
//每次断连间隔重新连接秒
/**
* 存放建立连接webSocket对象
*/
p
rivate
ConcurrentHashMap
<
Long
,
WebSocketSession
>
webSocketMap
=
new
ConcurrentHashMap
();
p
ublic
static
ConcurrentHashMap
<
Long
,
WebSocketSession
>
webSocketMap
=
new
ConcurrentHashMap
();
ConcurrentHashMap
<
String
,
ScheduledFuture
>
taskMap
=
new
ConcurrentHashMap
<>(
1
);
...
...
src/main/resources/mapper/ClassMemberMappingMapper.xml
View file @
660ff3e
...
...
@@ -76,4 +76,17 @@
and t.member_id = #{memberId}
</select>
<select
id=
"getCLassMemberByCompanyId"
resultType=
"com.subsidy.model.ClassMemberMappingDO"
>
SELECT
t.*
FROM
class_member_mapping t
LEFT JOIN class_dict t1 ON t1.id = t.class_id
WHERE
t1.company_id = #{companyId}
AND t.delete_date IS NULL
AND t1.delete_date IS NULL
GROUP BY t.member_id
</select>
</mapper>
src/main/resources/mapper/VodDictMapper.xml
View file @
660ff3e
...
...
@@ -39,7 +39,7 @@
t2.content,
t.order_no,
t.vod_code,
t3.
vod_alias_name
IFNULL( t3.vod_alias_name, t.vod_name ) AS
vod_alias_name
FROM
vod_dict t
LEFT JOIN content_vod_mapping t3 ON t3.vod_id = t.id
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment