|
@@ -7,12 +7,12 @@ import com.ozs.common.utils.AppendUtils;
|
|
|
import com.ozs.common.utils.StringUtils;
|
|
|
import com.ozs.service.entity.BaseCameraManagement;
|
|
|
import com.ozs.service.entity.MsgAlarm;
|
|
|
+import com.ozs.service.entity.MsgAppPush;
|
|
|
+import com.ozs.service.entity.MsgWebPush;
|
|
|
import com.ozs.service.entity.vo.MsgAlarmResp;
|
|
|
-import com.ozs.service.service.BaseCameraManagementService;
|
|
|
-import com.ozs.service.service.BaseRailwayManagementService;
|
|
|
-import com.ozs.service.service.BaseUserService;
|
|
|
-import com.ozs.service.service.UserRegistrationidService;
|
|
|
+import com.ozs.service.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
@@ -42,6 +42,10 @@ public class WebSocketConteoller extends BaseController {
|
|
|
private BaseCameraManagementService baseCameraManagementService;
|
|
|
@Autowired
|
|
|
private UserRegistrationidService userRegistrationidService;
|
|
|
+ @Autowired
|
|
|
+ private MsgWebPushService msgWebPushService;
|
|
|
+ @Autowired
|
|
|
+ private MsgAppPushService msgAppPushService;
|
|
|
|
|
|
@ResponseBody
|
|
|
@PostMapping("/publish")
|
|
@@ -54,6 +58,7 @@ public class WebSocketConteoller extends BaseController {
|
|
|
// 获取推送人ID列表
|
|
|
Set<String> set = baseUserService.getUserIdList(baseCameraManagement.getCreateBy(), baseCameraManagement.getDeptId());
|
|
|
String[] list = set.toArray(new String[set.size()]);
|
|
|
+ List<String> userIdList = new ArrayList<>(set);
|
|
|
MsgAlarmResp msgAlarmResp = new MsgAlarmResp();
|
|
|
String begin = AppendUtils.stringAppend(baseCameraManagement.getBeginMile());
|
|
|
String end = AppendUtils.stringAppend(baseCameraManagement.getEndMile());
|
|
@@ -69,9 +74,7 @@ public class WebSocketConteoller extends BaseController {
|
|
|
msgAlarmResp.setAlarmTime(msgAlarm.getAlarmTime() != null ? msgAlarm.getAlarmTime() : new Date());
|
|
|
// 推送消息reqMsgAlarmVo
|
|
|
webSocketServer.sendMoreMessage(list, objStr(msgAlarmResp));
|
|
|
-
|
|
|
// app 消息推送
|
|
|
- List<String> userIdList = new ArrayList<>(set);
|
|
|
List<String> alias = userRegistrationidService.selectRegistrationID(userIdList);
|
|
|
// List<String> alias = new ArrayList<String>();
|
|
|
// alias.add("sunhh");
|
|
@@ -83,6 +86,26 @@ public class WebSocketConteoller extends BaseController {
|
|
|
"报警通知!", cameraName != null ? cameraName : "",
|
|
|
formatDate + " " + (msgAlarmResp.getAlarmType() == 1 ? "泥石流" : msgAlarmResp.getAlarmType()) + " " + (baseCameraManagement.getLineDir() == 1 ? "上行" : "下行") + " " + mile + " " + endMile,
|
|
|
"");
|
|
|
+ // 存入数据
|
|
|
+ if (!StringUtils.isEmpty(msgAlarm.getAlarmId()) || !StringUtils.isEmpty(userIdList)) {
|
|
|
+ String userIdLogin = 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);
|
|
|
+ MsgAppPush msgAppPush = new MsgAppPush();
|
|
|
+ BeanUtils.copyProperties(msgWebPush, msgAppPush);
|
|
|
+ msgAppPushService.save(msgAppPush);
|
|
|
+ }
|
|
|
+ }
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
map.put("code", 200);
|
|
|
return map;
|