| | |
| | | package com.panzhihua.service_property.config; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.websocket.*; |
| | | |
| | | import cn.hutool.extra.spring.SpringUtil; |
| | | import com.alibaba.fastjson.JSONObject;; |
| | | import com.panzhihua.service_property.dao.ComPropertyAlarmDao; |
| | | import com.panzhihua.service_property.dto.DeviceDto; |
| | | import com.panzhihua.service_property.entity.ComPropertyAlarm; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_property.dao.ComPropertyAlarmDao; |
| | | import com.panzhihua.service_property.dto.DeviceDto; |
| | | import com.panzhihua.service_property.entity.ComPropertyAlarm; |
| | | |
| | | import cn.hutool.extra.spring.SpringUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | | import javax.websocket.*; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 应用模块名称 |
| | |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(WebSocketClient.class); |
| | | |
| | | /** 保存报警记录服务 */ |
| | | /** |
| | | * 保存报警记录服务 |
| | | */ |
| | | @Resource |
| | | private ComPropertyAlarmDao comPropertyAlarmDao; |
| | | /** |
| | |
| | | public void onMessage(String message, Session session) { |
| | | // 提取数据 |
| | | logger.info("收到的原始数据:{}", message); |
| | | dealData(message); |
| | | dealNewData(message); |
| | | } |
| | | |
| | | @Deprecated |
| | | @Async |
| | | void dealNewData(String message) { |
| | | comPropertyAlarmDao = SpringUtil.getBean(ComPropertyAlarmDao.class); |
| | |
| | | comPropertyAlarmDao = SpringUtil.getBean(ComPropertyAlarmDao.class); |
| | | DeviceDto deviceInfo = JSONObject.parseObject(message, DeviceDto.class); |
| | | boolean checkFlag = |
| | | "RINGING".equals(deviceInfo.getCallstatus()) && StringUtils.isNotEmpty(deviceInfo.getOri_number()); |
| | | "RINGING".equals(deviceInfo.getCallstatus()) && StringUtils.isNotEmpty(deviceInfo.getOri_number()); |
| | | if (checkFlag) { |
| | | logger.info("收到设备报警信息:{}", message); |
| | | ComPropertyAlarm comPropertyAlarm = new ComPropertyAlarm(); |
| | |
| | | /** |
| | | * <异步发送message> |
| | | * |
| | | * @param message |
| | | * message @throws |
| | | * @param message message @throws |
| | | */ |
| | | public void send(String message) { |
| | | this.session.getAsyncRemote().sendText(message); |
| | |
| | | /** |
| | | * <发送message> |
| | | * |
| | | * @param message |
| | | * message @throws |
| | | * @param message message @throws |
| | | */ |
| | | public void sendMessage(String message) { |
| | | try { |