|
@@ -65,13 +65,44 @@ public class WebSocketConteoller extends BaseController {
|
|
|
return projectName;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * app 登陆时查询 未登陆时推送的消息 重新推送
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @GetMapping("/getMessageApp")
|
|
|
+ public Map publishApp() {
|
|
|
+ String userId = getUserId();
|
|
|
+ List<MsgAppPush> msgAppPushList = msgAppPushService.getByUserId(userId);
|
|
|
+ for (MsgAppPush msgAppPush : msgAppPushList) {
|
|
|
+ String remark = msgAppPush.getRemark();
|
|
|
+ MsgAlarmResp msgAlarmResp = JSONObject.parseObject(remark, MsgAlarmResp.class);
|
|
|
+ Date alarmTime = msgAlarmResp.getAlarmTime();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String formatDate = sdf.format(alarmTime != null ? alarmTime : new Date());
|
|
|
+ List<String> userList = new ArrayList<>();
|
|
|
+ userList.add(userId);
|
|
|
+ JPushUtil.sendToRegistrationId(
|
|
|
+ userList,
|
|
|
+ "报警通知!", msgAlarmResp.getRailwayName() != null ? msgAlarmResp.getRailwayName() : "",
|
|
|
+ // content,
|
|
|
+ formatDate + " " + (msgAlarmResp.getAlarmType() == 1 ? "泥石流" : msgAlarmResp.getAlarmType()) + " " + msgAlarmResp.getLineDir() + " " + msgAlarmResp.getAlarmMile() + " " + msgAlarmResp.getBeginMile(),
|
|
|
+ remark);
|
|
|
+ msgAppPush.setOnline("1");
|
|
|
+ msgAppPushService.updateById(msgAppPush);
|
|
|
+ }
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("code", 200);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* web 登陆时查询 未登陆时推送的消息 重新推送
|
|
|
* @return
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@GetMapping("/getMessage")
|
|
|
- public Map publish() {
|
|
|
+ public Map publishWeb() {
|
|
|
String userId = getUserId();
|
|
|
List<MsgWebPush> msgWebPushList = msgWebPushService.getByUserId(userId);
|
|
|
for (MsgWebPush msgWebPush : msgWebPushList) {
|
|
@@ -199,16 +230,26 @@ public class WebSocketConteoller extends BaseController {
|
|
|
String formatDate = sdf.format(alarmTime != null ? alarmTime : new Date());
|
|
|
log.info("APPcontent-----" + content);
|
|
|
log.info("APPuserid-----" + userRegistrationid.getUserId());
|
|
|
- List<String> userList = new ArrayList<>();
|
|
|
- userList.add(userRegistrationid.getRegistrationId());
|
|
|
- JPushUtil.sendToRegistrationId(
|
|
|
- userList,
|
|
|
- "报警通知!", cameraName != null ? cameraName : "",
|
|
|
- // content,
|
|
|
- formatDate + " " + (msgAlarmResp.getAlarmType() == 1 ? "泥石流" : msgAlarmResp.getAlarmType()) + " " + (baseCameraManagement.getLineDir() == 1 ? "上行" : "下行") + " " + mile + " " + endMile,
|
|
|
- content);
|
|
|
// 存入数据
|
|
|
MsgAppPush msgAppPush = new MsgAppPush();
|
|
|
+ // 推送消息reqMsgAlarmVo
|
|
|
+ boolean userOnline = webSocketServer.userOnline(userRegistrationid.getUserId());
|
|
|
+ log.info("userOnline-userOnline-userOnline-userOnline-----::::::" + userOnline);
|
|
|
+ if (userOnline) {
|
|
|
+ List<String> userList = new ArrayList<>();
|
|
|
+ userList.add(userRegistrationid.getRegistrationId());
|
|
|
+ JPushUtil.sendToRegistrationId(
|
|
|
+ userList,
|
|
|
+ "报警通知!", cameraName != null ? cameraName : "",
|
|
|
+ // content,
|
|
|
+ formatDate + " " + (msgAlarmResp.getAlarmType() == 1 ? "泥石流" : msgAlarmResp.getAlarmType()) + " " + (baseCameraManagement.getLineDir() == 1 ? "上行" : "下行") + " " + mile + " " + endMile,
|
|
|
+ content);
|
|
|
+ msgAppPush.setOnline("1");
|
|
|
+ } else {
|
|
|
+ // online 是否推送,1:推送,2:未推
|
|
|
+ msgAppPush.setOnline("2");
|
|
|
+ }
|
|
|
+ msgAppPush.setRemark(content);
|
|
|
// 状态:1未读;2已读
|
|
|
msgAppPush.setStatus(1);
|
|
|
msgAppPush.setPushId(pushId);
|