Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
EncryptedFileSystem
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhangshuang
EncryptedFileSystem
Commits
33947361
提交
33947361
authored
4月 17, 2020
作者:
xc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xc
上级
bb5333b1
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
288 行增加
和
9 行删除
+288
-9
pom.xml
efs-bus/pom.xml
+5
-0
ReddotDao.java
efs-bus/src/main/java/com/zjty/efs/bus/Dao/ReddotDao.java
+8
-0
NoticeController.java
...in/java/com/zjty/efs/bus/controller/NoticeController.java
+0
-1
RedDot.java
efs-bus/src/main/java/com/zjty/efs/bus/entity/RedDot.java
+43
-0
AttentionService.java
.../main/java/com/zjty/efs/bus/service/AttentionService.java
+6
-0
ReddotService.java
...src/main/java/com/zjty/efs/bus/service/ReddotService.java
+8
-0
AttentionServiceImpl.java
...a/com/zjty/efs/bus/service/impl/AttentionServiceImpl.java
+26
-0
NoticeServiceImpl.java
...java/com/zjty/efs/bus/service/impl/NoticeServiceImpl.java
+27
-7
ReddotServiceImpl.java
...java/com/zjty/efs/bus/service/impl/ReddotServiceImpl.java
+24
-0
Job.java
efs-bus/src/main/java/com/zjty/efs/bus/util/Job.java
+3
-1
WebSocketConfig.java
...main/java/com/zjty/efs/bus/websocket/WebSocketConfig.java
+12
-0
WebSocketServer.java
...main/java/com/zjty/efs/bus/websocket/WebSocketServer.java
+126
-0
没有找到文件。
efs-bus/pom.xml
浏览文件 @
33947361
...
...
@@ -79,6 +79,11 @@
<artifactId>
efs-ftp
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-websocket
</artifactId>
<version>
2.2.5.RELEASE
</version>
</dependency>
</dependencies>
...
...
efs-bus/src/main/java/com/zjty/efs/bus/Dao/ReddotDao.java
0 → 100644
浏览文件 @
33947361
package
com
.
zjty
.
efs
.
bus
.
Dao
;
import
com.zjty.efs.bus.entity.RedDot
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
ReddotDao
extends
JpaRepository
<
RedDot
,
String
>
{
}
efs-bus/src/main/java/com/zjty/efs/bus/controller/NoticeController.java
浏览文件 @
33947361
...
...
@@ -77,7 +77,6 @@ public class NoticeController {
}
else
{
data
=
noticeService
.
getListByStatus
(
user
,
status
,
pageNum
,
pageSize
,
type
);
}
return
ResponseEntity
.
ok
(
data
);
}
...
...
efs-bus/src/main/java/com/zjty/efs/bus/entity/RedDot.java
0 → 100644
浏览文件 @
33947361
package
com
.
zjty
.
efs
.
bus
.
entity
;
import
com.zjty.efs.misc.config.AutoDocument
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.persistence.*
;
@AutoDocument
//@ApiModel(value = "通知", description = "通知实体类")
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table
(
name
=
"reddot"
)
public
class
RedDot
{
/**
* id
*/
@ApiModelProperty
(
value
=
"id"
,
example
=
"1"
)
@Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column
(
name
=
"id"
)
private
String
id
;
/**
* 标题
*/
@ApiModelProperty
(
value
=
"notice"
,
example
=
"验收通知"
,
dataType
=
"int"
,
name
=
"标题"
)
@Column
(
name
=
"notice"
)
private
int
notice
;
/**
* 收件人列表
*/
@ApiModelProperty
(
value
=
"attention"
,
example
=
"1"
,
dataType
=
"int"
,
name
=
"收件人"
)
@Column
(
name
=
"attention"
)
private
int
attention
;
}
efs-bus/src/main/java/com/zjty/efs/bus/service/AttentionService.java
浏览文件 @
33947361
...
...
@@ -35,4 +35,10 @@ public interface AttentionService {
* @return
*/
int
getRedDot
(
String
userId
);
/**
* websokect发送信息
* @param userId 用户编号
*/
void
sendMessage
(
String
userId
);
}
efs-bus/src/main/java/com/zjty/efs/bus/service/ReddotService.java
0 → 100644
浏览文件 @
33947361
package
com
.
zjty
.
efs
.
bus
.
service
;
import
com.zjty.efs.bus.entity.RedDot
;
public
interface
ReddotService
{
RedDot
findByUserId
(
String
userId
);
boolean
addReddot
(
RedDot
redDot
);
}
efs-bus/src/main/java/com/zjty/efs/bus/service/impl/AttentionServiceImpl.java
浏览文件 @
33947361
package
com
.
zjty
.
efs
.
bus
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zjty.efs.bus.Dao.AttentionDao
;
import
com.zjty.efs.bus.entity.Attention
;
import
com.zjty.efs.bus.entity.Paging
;
import
com.zjty.efs.bus.entity.RedDot
;
import
com.zjty.efs.bus.service.AttentionService
;
import
com.zjty.efs.bus.service.NoticeService
;
import
com.zjty.efs.bus.service.ReddotService
;
import
com.zjty.efs.bus.websocket.WebSocketServer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
...
...
@@ -18,6 +23,11 @@ import java.util.List;
public
class
AttentionServiceImpl
implements
AttentionService
{
@Autowired
AttentionDao
attentionDao
;
@Autowired
WebSocketServer
webSocketServer
;
@Autowired
ReddotService
reddotService
;
@Override
public
Paging
<
Attention
>
getAttentionList
(
String
userId
,
int
pageNum
,
int
pageSize
,
int
staus
)
{
try
{
...
...
@@ -48,6 +58,7 @@ public class AttentionServiceImpl implements AttentionService {
public
boolean
addAttention
(
Attention
attention
)
{
try
{
attentionDao
.
save
(
attention
);
sendMessage
(
attention
.
getUserId
());
return
true
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
...
...
@@ -59,10 +70,13 @@ public class AttentionServiceImpl implements AttentionService {
@Transactional
public
boolean
updateStatus
(
List
<
Attention
>
attentions
)
{
try
{
String
userId
=
""
;
for
(
Attention
attention:
attentions
){
userId
=
attention
.
getUserId
();
attention
.
setStatus
(
1
);
attentionDao
.
save
(
attention
);
}
sendMessage
(
userId
);
return
true
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
...
...
@@ -77,4 +91,16 @@ public class AttentionServiceImpl implements AttentionService {
return
attentions
.
size
();
}
@Override
public
void
sendMessage
(
String
userId
){
int
attentionNum
=
attentionDao
.
findOutByUserIdAndStatus
(
userId
,
0
).
size
();
RedDot
redDot1
=
reddotService
.
findByUserId
(
userId
);
if
(
redDot1
==
null
){
redDot1
=
new
RedDot
();
}
redDot1
.
setAttention
(
attentionNum
);
reddotService
.
addReddot
(
redDot1
);
webSocketServer
.
sendData
(
userId
,
JSONObject
.
toJSONString
(
redDot1
));
}
}
efs-bus/src/main/java/com/zjty/efs/bus/service/impl/NoticeServiceImpl.java
浏览文件 @
33947361
...
...
@@ -4,12 +4,11 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.databind.JsonSerializer
;
import
com.zjty.efs.bus.Dao.NoticeDao
;
import
com.zjty.efs.bus.entity.Addressee
;
import
com.zjty.efs.bus.entity.Attention
;
import
com.zjty.efs.bus.entity.Notice
;
import
com.zjty.efs.bus.entity.Paging
;
import
com.zjty.efs.bus.entity.*
;
import
com.zjty.efs.bus.service.AttentionService
;
import
com.zjty.efs.bus.service.NoticeService
;
import
com.zjty.efs.bus.service.ReddotService
;
import
com.zjty.efs.bus.websocket.WebSocketServer
;
import
com.zjty.efs.log.subject.entity.EfsLog
;
import
com.zjty.efs.log.tool.EfsLogUtil
;
import
com.zjty.efs.user.subject.entity.UserDo
;
...
...
@@ -22,6 +21,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.websocket.Session
;
import
java.lang.reflect.Array
;
import
java.util.*
;
...
...
@@ -36,6 +36,10 @@ public class NoticeServiceImpl implements NoticeService {
UserService
userService
;
@Autowired
AttentionService
attentionService
;
@Autowired
ReddotService
reddotService
;
@Override
@Transactional
...
...
@@ -52,8 +56,6 @@ public class NoticeServiceImpl implements NoticeService {
notice
.
setName
(
userDo
.
getName
());
notice
.
setLabel
(
0
);
if
(
notice
.
getType
()
==
2
){
//保存为草稿、、、
List
<
Addressee
>
addresseeList
=
new
ArrayList
<>();
...
...
@@ -122,8 +124,14 @@ public class NoticeServiceImpl implements NoticeService {
attention
.
setData
(
data2
);
attention
.
setUserId
(
add
.
getId
());
attention
.
setNoticeId
(
notice2
.
getId
());
attentionService
.
addAttention
(
attention
);
int
noticeNum
=
noticeDao
.
findOutByReceiverAndStatus
(
add
.
getId
(),
0
).
size
();
System
.
out
.
println
(
"-------------------------"
+
noticeNum
);
RedDot
redDot
=
new
RedDot
();
redDot
.
setId
(
add
.
getId
());
redDot
.
setNotice
(
noticeNum
);
reddotService
.
addReddot
(
redDot
);
attentionService
.
addAttention
(
attention
);
}
notice
.
setAddressee
(
add2
);
...
...
@@ -198,6 +206,12 @@ public class NoticeServiceImpl implements NoticeService {
String
data
=
"["
+
userDo
.
getUnit
()
+
"_"
+
userDo
.
getName
()
+
"]查看了《"
+
notice
.
getTitle
()
+
"》"
;
efsLogUtil
.
addLog
(
new
EfsLog
(
null
,
userDo
.
getId
(),
data
,
new
Date
()));
int
noticeNum
=
noticeDao
.
findOutByReceiverAndStatus
(
userId
,
0
).
size
();
RedDot
redDot
=
new
RedDot
();
redDot
.
setId
(
userId
);
redDot
.
setNotice
(
noticeNum
);
reddotService
.
addReddot
(
redDot
);
attentionService
.
sendMessage
(
userId
);
return
notice
;
}
catch
(
Exception
e
){
...
...
@@ -253,7 +267,13 @@ public class NoticeServiceImpl implements NoticeService {
}
data
=
data
+
"为已读"
;
int
noticeNum
=
noticeDao
.
findOutByReceiverAndStatus
(
userId
,
0
).
size
();
RedDot
redDot
=
new
RedDot
();
redDot
.
setId
(
userId
);
redDot
.
setNotice
(
noticeNum
);
reddotService
.
addReddot
(
redDot
);
attentionService
.
sendMessage
(
userId
);
efsLogUtil
.
addLog
(
new
EfsLog
(
null
,
userDo
.
getId
(),
data
,
new
Date
()));
return
true
;
}
catch
(
Exception
e
){
...
...
efs-bus/src/main/java/com/zjty/efs/bus/service/impl/ReddotServiceImpl.java
0 → 100644
浏览文件 @
33947361
package
com
.
zjty
.
efs
.
bus
.
service
.
impl
;
import
com.zjty.efs.bus.Dao.ReddotDao
;
import
com.zjty.efs.bus.entity.RedDot
;
import
com.zjty.efs.bus.service.ReddotService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Service
public
class
ReddotServiceImpl
implements
ReddotService
{
@Autowired
ReddotDao
reddotDao
;
@Override
public
RedDot
findByUserId
(
String
userId
)
{
RedDot
redDot
=
reddotDao
.
findById
(
userId
).
get
();
return
redDot
;
}
@Override
public
boolean
addReddot
(
RedDot
redDot
)
{
reddotDao
.
save
(
redDot
);
return
true
;
}
}
efs-bus/src/main/java/com/zjty/efs/bus/util/Job.java
浏览文件 @
33947361
...
...
@@ -4,10 +4,10 @@ import com.zjty.efs.bus.entity.Attention;
import
com.zjty.efs.bus.entity.Notice
;
import
com.zjty.efs.bus.service.AttentionService
;
import
com.zjty.efs.bus.service.NoticeService
;
import
com.zjty.efs.bus.websocket.WebSocketServer
;
import
com.zjty.efs.ftp.entity.DownLoadCount
;
import
com.zjty.efs.ftp.entity.DownLoadRequest
;
import
com.zjty.efs.ftp.service.DownLoadService
;
import
lombok.extern.log4j.Log4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
...
...
@@ -119,4 +119,6 @@ public class Job {
noticeService
.
saveNotice
(
notice
);
}
}
efs-bus/src/main/java/com/zjty/efs/bus/websocket/WebSocketConfig.java
0 → 100644
浏览文件 @
33947361
package
com
.
zjty
.
efs
.
bus
.
websocket
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.socket.server.standard.ServerEndpointExporter
;
@Component
public
class
WebSocketConfig
{
@Bean
public
ServerEndpointExporter
serverEndpointExporter
()
{
return
new
ServerEndpointExporter
();
}
}
efs-bus/src/main/java/com/zjty/efs/bus/websocket/WebSocketServer.java
0 → 100644
浏览文件 @
33947361
package
com
.
zjty
.
efs
.
bus
.
websocket
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
javax.websocket.*
;
import
javax.websocket.server.PathParam
;
import
javax.websocket.server.ServerEndpoint
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.CopyOnWriteArraySet
;
import
java.util.concurrent.atomic.AtomicInteger
;
@ServerEndpoint
(
value
=
"/webServer/{userId}"
)
@Component
@Slf4j
public
class
WebSocketServer
{
@PostConstruct
public
void
init
()
{
log
.
info
(
"websocket 加载"
);
}
private
static
final
AtomicInteger
OnlineCount
=
new
AtomicInteger
(
0
);
private
static
Map
<
Session
,
String
>
map
=
new
HashMap
<>();
/**
* 连接建立成功调用的方法
*/
@OnOpen
public
void
onOpen
(
Session
session
,
@PathParam
(
"userId"
)
String
userId
)
{
map
.
put
(
session
,
userId
);
int
cnt
=
OnlineCount
.
incrementAndGet
();
// 在线数加1
log
.
info
(
"有连接加入,当前连接数为:{}"
,
cnt
);
SendMessage
(
session
,
"连接成功"
);
}
/**
* 连接关闭调用的方法
*/
@OnClose
public
void
onClose
(
Session
session
)
{
map
.
remove
(
session
);
int
cnt
=
OnlineCount
.
decrementAndGet
();
log
.
info
(
"有连接关闭,当前连接数为:{}"
,
cnt
);
}
/**
* 收到客户端消息后调用的方法
*
* @param message
* 客户端发送过来的消息
*/
@OnMessage
public
void
onMessage
(
String
message
,
Session
session
)
{
log
.
info
(
"来自客户端的消息:{}"
,
message
);
SendMessage
(
session
,
"收到消息,消息内容:"
+
message
);
}
/**
* 出现错误
* @param session
* @param error
*/
@OnError
public
void
onError
(
Session
session
,
Throwable
error
)
{
log
.
error
(
"发生错误:{},Session ID: {}"
,
error
.
getMessage
(),
session
.
getId
());
error
.
printStackTrace
();
}
/**
* 发送消息,实践表明,每次浏览器刷新,session会发生变化。
* @param session
* @param message
*/
private
static
void
SendMessage
(
Session
session
,
String
message
)
{
try
{
session
.
getBasicRemote
().
sendText
(
String
.
format
(
"%s (From Server,Session ID=%s)"
,
message
,
session
.
getId
()));
}
catch
(
IOException
e
)
{
log
.
error
(
"发送消息出错:{}"
,
e
.
getMessage
());
e
.
printStackTrace
();
}
}
/**
* 给所有的Session推送信息
* @param message 需要往客户端推送的信息
* @param userId 客户端登录用户的编号
*/
public
void
sendData
(
String
userId
,
String
message
){
log
.
info
(
"websocket推送信息: "
+
message
);
List
<
Session
>
list
=
getKey
(
map
,
userId
);
if
(!
list
.
isEmpty
()){
for
(
Session
session:
list
){
if
(
session
.
isOpen
()){
SendMessage
(
session
,
message
);
}
}
}
}
//根据map的value获取map的key
private
static
List
<
Session
>
getKey
(
Map
<
Session
,
String
>
map
,
String
value
){
List
<
Session
>
sessionList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
Session
,
String
>
entry
:
map
.
entrySet
())
{
if
(
value
.
equals
(
entry
.
getValue
())){
sessionList
.
add
(
entry
.
getKey
());
}
}
return
sessionList
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论