|
@@ -96,108 +96,82 @@ public class WebSocketConteoller extends BaseController {
|
|
|
userIdLogin = user.getUserId();
|
|
|
}
|
|
|
String alarmId = msgAlarm.getAlarmId();
|
|
|
- for (String userid : list) {
|
|
|
- String pushId = UUID.randomUUID().toString();
|
|
|
- msgAlarmResp.setPushId(pushId);
|
|
|
- String content = objStr(msgAlarmResp);
|
|
|
- log.info("WEBcontent-----" + content);
|
|
|
- log.info("WEBuserid-----" + userid);
|
|
|
- // 推送消息reqMsgAlarmVo
|
|
|
- webSocketServer.sendOneMessage(userid, content);
|
|
|
|
|
|
- // 存入数据
|
|
|
- MsgWebPush msgWebPush = new MsgWebPush();
|
|
|
- // 状态:1未读;2已读
|
|
|
- msgWebPush.setStatus(1);
|
|
|
- msgWebPush.setPushId(pushId);
|
|
|
- msgWebPush.setAlarmId(alarmId);
|
|
|
- msgWebPush.setReceiveBy(userid);
|
|
|
- msgWebPush.setCreateBy(userIdLogin);
|
|
|
- msgWebPush.setCreateTime(new Date());
|
|
|
- msgWebPush.setUpdateBy(userIdLogin);
|
|
|
- msgWebPush.setUpdateTime(new Date());
|
|
|
- msgWebPushService.save(msgWebPush);
|
|
|
- }
|
|
|
-// String content = objStr(msgAlarmResp);
|
|
|
-// // 推送消息reqMsgAlarmVo
|
|
|
-// webSocketServer.sendMoreMessage(list, content);
|
|
|
- // app 消息推送
|
|
|
- List<String> alias = new ArrayList<>();
|
|
|
- if (!StringUtils.isEmpty(userIdList) || userIdList.size() > 0) {
|
|
|
- alias = userRegistrationidService.selectRegistrationID(userIdList);
|
|
|
+ LambdaQueryWrapper<MsgWebPush> lwMsgWebPush = new LambdaQueryWrapper<MsgWebPush>();
|
|
|
+ if (!ObjectUtils.isEmpty(msgAlarm.getCameraCode())) {
|
|
|
+ lwMsgWebPush.eq(MsgWebPush::getAlarmId, msgAlarm.getAlarmId());
|
|
|
}
|
|
|
- // List<String> alias = new ArrayList<String>();
|
|
|
- // alias.add("sunhh");
|
|
|
- // list去重
|
|
|
- List<String> listString = distinct(alias);
|
|
|
- if (!StringUtils.isEmpty(listString) || listString.size() > 0) {
|
|
|
- for (String userid : listString) {
|
|
|
+ List<MsgWebPush> msgWebPushList = msgWebPushService.list(lwMsgWebPush);
|
|
|
+ if (StringUtils.isEmpty(msgWebPushList) || msgWebPushList.size() == 0) {
|
|
|
+ for (String userid : list) {
|
|
|
String pushId = UUID.randomUUID().toString();
|
|
|
- msgAlarmResp.setPushId(UUID.randomUUID().toString());
|
|
|
+ msgAlarmResp.setPushId(pushId);
|
|
|
String content = objStr(msgAlarmResp);
|
|
|
- Date alarmTime = msgAlarm.getAlarmTime();
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- String formatDate = sdf.format(alarmTime != null ? alarmTime : new Date());
|
|
|
- log.info("APPcontent-----" + content);
|
|
|
- log.info("APPuserid-----" + userid);
|
|
|
- List<String> userList = new ArrayList<>();
|
|
|
- userList.add(userid);
|
|
|
- JPushUtil.sendToRegistrationId(
|
|
|
- userList,
|
|
|
- "报警通知!", cameraName != null ? cameraName : "",
|
|
|
- // content,
|
|
|
- formatDate + " " + (msgAlarmResp.getAlarmType() == 1 ? "泥石流" : msgAlarmResp.getAlarmType()) + " " + (baseCameraManagement.getLineDir() == 1 ? "上行" : "下行") + " " + mile + " " + endMile,
|
|
|
- content);
|
|
|
+ log.info("WEBcontent-----" + content);
|
|
|
+ log.info("WEBuserid-----" + userid);
|
|
|
+ // 推送消息reqMsgAlarmVo
|
|
|
+ webSocketServer.sendOneMessage(userid, content);
|
|
|
|
|
|
// 存入数据
|
|
|
- MsgAppPush msgAppPush = new MsgAppPush();
|
|
|
+ MsgWebPush msgWebPush = new MsgWebPush();
|
|
|
// 状态:1未读;2已读
|
|
|
- msgAppPush.setStatus(1);
|
|
|
- msgAppPush.setPushId(pushId);
|
|
|
- msgAppPush.setAlarmId(alarmId);
|
|
|
- msgAppPush.setReceiveBy(userid);
|
|
|
- msgAppPush.setCreateBy(userIdLogin);
|
|
|
- msgAppPush.setCreateTime(new Date());
|
|
|
- msgAppPush.setUpdateBy(userIdLogin);
|
|
|
- msgAppPush.setUpdateTime(new Date());
|
|
|
- msgAppPushService.save(msgAppPush);
|
|
|
+ msgWebPush.setStatus(1);
|
|
|
+ msgWebPush.setPushId(pushId);
|
|
|
+ msgWebPush.setAlarmId(alarmId);
|
|
|
+ msgWebPush.setReceiveBy(userid);
|
|
|
+ msgWebPush.setCreateBy(userIdLogin);
|
|
|
+ msgWebPush.setCreateTime(new Date());
|
|
|
+ msgWebPush.setUpdateBy(userIdLogin);
|
|
|
+ msgWebPush.setUpdateTime(new Date());
|
|
|
+ msgWebPushService.save(msgWebPush);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // app 消息推送
|
|
|
+ LambdaQueryWrapper<MsgAppPush> lwMsgAppPush = new LambdaQueryWrapper<MsgAppPush>();
|
|
|
+ if (!ObjectUtils.isEmpty(msgAlarm.getCameraCode())) {
|
|
|
+ lwMsgAppPush.eq(MsgAppPush::getAlarmId, msgAlarm.getAlarmId());
|
|
|
+ }
|
|
|
+ List<MsgAppPush> msgAppPushList = msgAppPushService.list(lwMsgAppPush);
|
|
|
+ if (StringUtils.isEmpty(msgAppPushList) || msgAppPushList.size() == 0) {
|
|
|
+ List<String> alias = new ArrayList<>();
|
|
|
+ if (!StringUtils.isEmpty(userIdList) || userIdList.size() > 0) {
|
|
|
+ alias = userRegistrationidService.selectRegistrationID(userIdList);
|
|
|
+ }
|
|
|
+ List<String> listString = distinct(alias);
|
|
|
+ if (!StringUtils.isEmpty(listString) || listString.size() > 0) {
|
|
|
+ for (String userid : listString) {
|
|
|
+ String pushId = UUID.randomUUID().toString();
|
|
|
+ msgAlarmResp.setPushId(UUID.randomUUID().toString());
|
|
|
+ String content = objStr(msgAlarmResp);
|
|
|
+ Date alarmTime = msgAlarm.getAlarmTime();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String formatDate = sdf.format(alarmTime != null ? alarmTime : new Date());
|
|
|
+ log.info("APPcontent-----" + content);
|
|
|
+ log.info("APPuserid-----" + userid);
|
|
|
+ List<String> userList = new ArrayList<>();
|
|
|
+ userList.add(userid);
|
|
|
+ JPushUtil.sendToRegistrationId(
|
|
|
+ userList,
|
|
|
+ "报警通知!", cameraName != null ? cameraName : "",
|
|
|
+ // content,
|
|
|
+ formatDate + " " + (msgAlarmResp.getAlarmType() == 1 ? "泥石流" : msgAlarmResp.getAlarmType()) + " " + (baseCameraManagement.getLineDir() == 1 ? "上行" : "下行") + " " + mile + " " + endMile,
|
|
|
+ content);
|
|
|
+ // 存入数据
|
|
|
+ MsgAppPush msgAppPush = new MsgAppPush();
|
|
|
+ // 状态:1未读;2已读
|
|
|
+ msgAppPush.setStatus(1);
|
|
|
+ msgAppPush.setPushId(pushId);
|
|
|
+ msgAppPush.setAlarmId(alarmId);
|
|
|
+ msgAppPush.setReceiveBy(userid);
|
|
|
+ msgAppPush.setCreateBy(userIdLogin);
|
|
|
+ msgAppPush.setCreateTime(new Date());
|
|
|
+ msgAppPush.setUpdateBy(userIdLogin);
|
|
|
+ msgAppPush.setUpdateTime(new Date());
|
|
|
+ msgAppPushService.save(msgAppPush);
|
|
|
+ }
|
|
|
}
|
|
|
-// Date alarmTime = msgAlarm.getAlarmTime();
|
|
|
-// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
-// String formatDate = sdf.format(alarmTime != null ? alarmTime : new Date());
|
|
|
-// JPushUtil.sendToRegistrationId(
|
|
|
-// listString,
|
|
|
-// "报警通知!", cameraName != null ? cameraName : "",
|
|
|
-// // content,
|
|
|
-// formatDate + " " + (msgAlarmResp.getAlarmType() == 1 ? "泥石流" : msgAlarmResp.getAlarmType()) + " " + (baseCameraManagement.getLineDir() == 1 ? "上行" : "下行") + " " + mile + " " + endMile,
|
|
|
-// content);
|
|
|
}
|
|
|
-// // 存入数据
|
|
|
-// if (!StringUtils.isEmpty(msgAlarm.getAlarmId()) || !StringUtils.isEmpty(userIdList)) {
|
|
|
-// String userIdLogin = "admin编码";
|
|
|
-// SysUser user = userService.selectUserById(1L);
|
|
|
-// if (!ObjectUtils.isEmpty(user)) {
|
|
|
-// userIdLogin = user.getUserId();
|
|
|
-// }
|
|
|
-// String alarmId = msgAlarm.getAlarmId();
|
|
|
-// for (String userId : userIdList) {
|
|
|
-// MsgWebPush msgWebPush = new MsgWebPush();
|
|
|
-// // 状态:1未读;2已读
|
|
|
-// msgWebPush.setStatus(1);
|
|
|
-// msgWebPush.setAlarmId(alarmId);
|
|
|
-// msgWebPush.setReceiveBy(userId);
|
|
|
-// msgWebPush.setCreateBy(userIdLogin);
|
|
|
-// msgWebPush.setCreateTime(new Date());
|
|
|
-// msgWebPush.setUpdateBy(userIdLogin);
|
|
|
-// msgWebPush.setUpdateTime(new Date());
|
|
|
-// msgWebPushService.save(msgWebPush);
|
|
|
-// if (!StringUtils.isEmpty(alias) || alias.size() > 0) {
|
|
|
-// MsgAppPush msgAppPush = new MsgAppPush();
|
|
|
-// BeanUtils.copyProperties(msgWebPush, msgAppPush);
|
|
|
-// msgAppPushService.save(msgAppPush);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
map.put("code", 200);
|
|
|
return map;
|