|
|
@@ -1,15 +1,15 @@
|
|
|
package com.xunmei.system.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.xunmei.common.core.domain.mediator.domain.IotAlarmData;
|
|
|
import com.xunmei.common.core.domain.notice.WebsocketNoticeLog;
|
|
|
import com.xunmei.common.core.vo.notice.WebSocketNoticeVo;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
import com.xunmei.common.websocket.utils.WebSocketUtils;
|
|
|
-import com.xunmei.system.api.domain.iot.IotAlarmData;
|
|
|
import com.xunmei.system.api.vo.WebSocketSendVo;
|
|
|
import com.xunmei.system.dto.notice.NoticeDealDto;
|
|
|
import com.xunmei.system.mapper.NoticeLogMapper;
|
|
|
@@ -53,9 +53,9 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeLogMapper, WebsocketNot
|
|
|
//消除其他人的通知
|
|
|
String userIds = websocketNoticeLog.getUserIds();
|
|
|
if(ObjectUtil.isNotEmpty(userIds)){
|
|
|
- WebSocketNoticeVo noticeVo = new WebSocketNoticeVo();
|
|
|
- noticeVo.setIotAlarmDataId(noticeDealDto.getIotAlarmDataId());
|
|
|
- noticeVo.setIsDo(1);
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
+ content.set("isDo",1);
|
|
|
+ content.set("iotAlarmDataId",noticeDealDto.getIotAlarmDataId().toString());
|
|
|
|
|
|
String[] split = userIds.split(",");
|
|
|
List<WebSocketSendVo> list = new ArrayList<>();
|
|
|
@@ -66,7 +66,7 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeLogMapper, WebsocketNot
|
|
|
WebSocketSendVo sendVo = new WebSocketSendVo();
|
|
|
sendVo.setUserId(Long.valueOf(userId));
|
|
|
sendVo.setOrgId(websocketNoticeLog.getOrgId());
|
|
|
- sendVo.setContent(noticeVo);
|
|
|
+ sendVo.setContent(content);
|
|
|
list.add(sendVo);
|
|
|
}
|
|
|
this.sendMessage(list);
|
|
|
@@ -82,13 +82,23 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeLogMapper, WebsocketNot
|
|
|
//创建发送记录
|
|
|
WebsocketNoticeLog noticeLog = new WebsocketNoticeLog();
|
|
|
noticeLog.setId(IdWorker.getId());
|
|
|
- JSONObject object = JSONObject.parseObject(list.get(0).getContent().toString());
|
|
|
- noticeLog.setIotAlarmId(object.getLong("iotAlarmDataId"));
|
|
|
+ JSONObject object = new JSONObject(list.get(0).getContent());
|
|
|
+ WebSocketNoticeVo noticeVo = object.toBean(WebSocketNoticeVo.class);
|
|
|
+ noticeLog.setIotAlarmId(noticeVo.getIotAlarmDataId());
|
|
|
+
|
|
|
noticeLog.setOrgId(list.get(0).getOrgId());
|
|
|
noticeLog.setIsDo(0);
|
|
|
noticeLog.setCreateTime(new Date());
|
|
|
noticeLog.setUserIds(this.handStr(list));
|
|
|
- baseMapper.insert(noticeLog);
|
|
|
+ QueryWrapper<WebsocketNoticeLog> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.lambda().eq(WebsocketNoticeLog::getIotAlarmId,noticeVo.getIotAlarmDataId());
|
|
|
+ WebsocketNoticeLog websocketNoticeLog = baseMapper.selectOne(wrapper);
|
|
|
+ if (websocketNoticeLog != null){
|
|
|
+ noticeLog.setId(websocketNoticeLog.getId());
|
|
|
+ baseMapper.updateById(noticeLog);
|
|
|
+ }else {
|
|
|
+ baseMapper.insert(noticeLog);
|
|
|
+ }
|
|
|
|
|
|
this.sendMessage(list);
|
|
|
}
|
|
|
@@ -99,8 +109,9 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeLogMapper, WebsocketNot
|
|
|
public void endNotice(List<WebSocketSendVo> list) {
|
|
|
if (list != null && list.size() > 0){
|
|
|
//修改发送记录(为主机结束报警)
|
|
|
- JSONObject object = JSONObject.parseObject(list.get(0).getContent().toString());
|
|
|
- Long iotAlarmDataId = object.getLong("iotAlarmDataId");
|
|
|
+ JSONObject object = new JSONObject(list.get(0).getContent());
|
|
|
+ WebSocketNoticeVo noticeVo = object.toBean(WebSocketNoticeVo.class);
|
|
|
+ Long iotAlarmDataId = noticeVo.getIotAlarmDataId();
|
|
|
|
|
|
QueryWrapper<WebsocketNoticeLog> wrapper = new QueryWrapper<>();
|
|
|
wrapper.lambda().eq(WebsocketNoticeLog::getIotAlarmId,iotAlarmDataId);
|
|
|
@@ -120,7 +131,8 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeLogMapper, WebsocketNot
|
|
|
public void sendMessage(List<WebSocketSendVo> list) {
|
|
|
for (WebSocketSendVo webSocketSendVo : list) {
|
|
|
Long userId = webSocketSendVo.getUserId();
|
|
|
- WebSocketUtils.sendMessage(userId, JSONObject.toJSONString(webSocketSendVo.getContent()));
|
|
|
+ JSONObject object = new JSONObject(webSocketSendVo.getContent());
|
|
|
+ WebSocketUtils.sendMessage(userId, object.toString());
|
|
|
}
|
|
|
}
|
|
|
|