New file |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import com.whyc.pojo.db_fire_robot.Environment; |
| | | |
| | | public interface EnvironmentMapper extends CustomMapper<Environment>{ |
| | | } |
New file |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import com.whyc.pojo.db_fire_robot.EnvironmentThreshold; |
| | | |
| | | public interface EnvironmentThresholdMapper extends CustomMapper<EnvironmentThreshold>{ |
| | | } |
New file |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import com.whyc.pojo.db_fire_robot.IdentifyAlarm; |
| | | |
| | | public interface IdentifyAlarmMapper extends CustomMapper<IdentifyAlarm>{ |
| | | } |
New file |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import com.whyc.pojo.db_fire_robot.RobotAlarm; |
| | | |
| | | public interface RobotAlarmMapper extends CustomMapper<RobotAlarm>{ |
| | | } |
New file |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import com.whyc.pojo.db_fire_robot.RobotStatus; |
| | | |
| | | public interface RobotStatusMapper extends CustomMapper<RobotStatus>{ |
| | | } |
New file |
| | |
| | | package com.whyc.pojo.db_fire_robot; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | import org.apache.ibatis.type.Alias; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * "temperature": 25.3, // 温度,单位:℃ |
| | | * "humidity": 60.5, // 湿度,单位:% |
| | | * "co": 0.02, // CO浓度,单位:ppm |
| | | * "co2": 400, // CO2浓度,单位:ppm |
| | | * "ch4": 0.1, // CH4浓度,单位:% |
| | | * "h2": 0.01, // H2浓度,单位:% |
| | | * "smoke": 0.05 // 烟感浓度,单位:% |
| | | */ |
| | | @Data |
| | | @ToString |
| | | @TableName(schema = "db_fire_robot",value = "tb_environment") |
| | | public class Environment { |
| | | |
| | | @TableId(value = "id",type = IdType.AUTO) |
| | | private int id; |
| | | @ApiModelProperty(value = "温度") |
| | | private float temperature; |
| | | @ApiModelProperty(value = "湿度") |
| | | private float humidity; |
| | | @ApiModelProperty(value = "CO浓度") |
| | | private float co; |
| | | @ApiModelProperty(value = "CO2浓度") |
| | | private float co2; |
| | | @ApiModelProperty(value = "CH4浓度") |
| | | private float ch4; |
| | | @ApiModelProperty(value = "H2浓度") |
| | | private float h2; |
| | | @ApiModelProperty(value = "烟感浓度") |
| | | private float smoke; |
| | | |
| | | private Date recordTime; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.pojo.db_fire_robot; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 环境数据报警阈值 |
| | | * "temperature": 60.0, // 温度,单位:℃ |
| | | * "humidity": 60.0, // 湿度,单位:% |
| | | * "co": 100.0, // CO浓度,单位:ppm |
| | | * "co2": 1600, // CO2浓度,单位:ppm |
| | | * "ch4": 100.0, // CH4浓度,单位:% |
| | | * "h2": 100.0, // H2浓度,单位:% |
| | | * "smoke": 100.0 // 烟感浓度,单位:% |
| | | */ |
| | | @Data |
| | | @ToString |
| | | @TableName(schema = "db_fire_robot",value = "tb_environment_threshold") |
| | | public class EnvironmentThreshold { |
| | | |
| | | @TableId(value = "id",type = IdType.AUTO) |
| | | private int id; |
| | | @ApiModelProperty(value = "温度") |
| | | private float temperature; |
| | | @ApiModelProperty(value = "湿度") |
| | | private float humidity; |
| | | @ApiModelProperty(value = "CO浓度") |
| | | private float co; |
| | | @ApiModelProperty(value = "CO2浓度") |
| | | private float co2; |
| | | @ApiModelProperty(value = "CH4浓度") |
| | | private float ch4; |
| | | @ApiModelProperty(value = "H2浓度") |
| | | private float h2; |
| | | @ApiModelProperty(value = "烟感浓度") |
| | | private float smoke; |
| | | |
| | | private Date recordTime; |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.pojo.db_fire_robot; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 算法识别报警状态 |
| | | * "type": "identifyAlarm", |
| | | * "data": { |
| | | * "gatherTime":"2025-03-28 13:44:31", // 采集时间 |
| | | * "position": 2, // 位置 1-"右岸开关站直流第二组蓄电池", 2-"右岸开关站直流第一组蓄电池",3- |
| | | * "7-9号机组直流第二组蓄电池",4- "7-9号机组直流第一组蓄电池",5- |
| | | * "10-12号机组直流第二组蓄电池", 6-"10-12号机组直流第一组蓄电池",7- |
| | | * "右岸公用直流第二组蓄电池", 8-"右岸公用直流第一组蓄电池" |
| | | * "batteryCells": 1, // 电池节数 1-"53-56节电池本体",2- "53-56节电池接线柱",3- "101-104节电池本体", 4-"101-104节电池接线柱",5- |
| | | * "1-4节电池接线柱",6- "1-4节电池本体",7- "49-52节电池接线柱", 8-"49-52节电池本体",9- |
| | | * "57-61节电池本体", 10-"57-61节电池接线柱", 11-"96-100节电池本体",12- "96-100节电池接线柱",13- |
| | | * "5-9节电池接线柱", 14-"5-9节电池本体", 15-"44-48节电池接线柱", 16-"44-48节电池本体",17- |
| | | * "62-65节电池本体", 18-"62-65节电池接线柱", 19-"92-95节电池本体",20- "92-95节电池接线柱",21- |
| | | * "10-13节电池接线柱", 22-"10-13节电池本体", 23-"40-43节电池接线柱", 24-"40-43节电池本体" |
| | | * "identifyType": 0 , // 识别类型 0-异物识别 1-指示灯识别 2-漏液识别 3-结晶识别 4-表计识别 |
| | | * "identifyResult": True, // 识别结果 |
| | | * "imagePath": "D:\room14_3_1748337299944.jpg" // 识别结果图片路径 |
| | | */ |
| | | @Data |
| | | @ToString |
| | | @TableName(schema = "db_fire_robot",value = "tb_identify_alarm") |
| | | public class IdentifyAlarm { |
| | | |
| | | @TableId(value = "id",type = IdType.AUTO) |
| | | private int id; |
| | | @ApiModelProperty(value = "采集时间") |
| | | private Date gatherTime; |
| | | @ApiModelProperty(value = "位置") |
| | | private int position; |
| | | @ApiModelProperty(value = "电池节数") |
| | | private int batteryCells; |
| | | @ApiModelProperty(value = "识别类型") |
| | | private int identifyType; |
| | | @ApiModelProperty(value = "识别结果") |
| | | private boolean identifyResult; |
| | | @ApiModelProperty(value = "识别结果图片路径") |
| | | private String imagePath; |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.pojo.db_fire_robot; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 算法识别报警历史 |
| | | * "type": "identifyAlarm", |
| | | * "data": { |
| | | * "gatherTime":"2025-03-28 13:44:31", // 采集时间 |
| | | * "position": 2, // 位置 1-"右岸开关站直流第二组蓄电池", 2-"右岸开关站直流第一组蓄电池",3- |
| | | * "7-9号机组直流第二组蓄电池",4- "7-9号机组直流第一组蓄电池",5- |
| | | * "10-12号机组直流第二组蓄电池", 6-"10-12号机组直流第一组蓄电池",7- |
| | | * "右岸公用直流第二组蓄电池", 8-"右岸公用直流第一组蓄电池" |
| | | * "batteryCells": 1, // 电池节数 1-"53-56节电池本体",2- "53-56节电池接线柱",3- "101-104节电池本体", 4-"101-104节电池接线柱",5- |
| | | * "1-4节电池接线柱",6- "1-4节电池本体",7- "49-52节电池接线柱", 8-"49-52节电池本体",9- |
| | | * "57-61节电池本体", 10-"57-61节电池接线柱", 11-"96-100节电池本体",12- "96-100节电池接线柱",13- |
| | | * "5-9节电池接线柱", 14-"5-9节电池本体", 15-"44-48节电池接线柱", 16-"44-48节电池本体",17- |
| | | * "62-65节电池本体", 18-"62-65节电池接线柱", 19-"92-95节电池本体",20- "92-95节电池接线柱",21- |
| | | * "10-13节电池接线柱", 22-"10-13节电池本体", 23-"40-43节电池接线柱", 24-"40-43节电池本体" |
| | | * "identifyType": 0 , // 识别类型 0-异物识别 1-指示灯识别 2-漏液识别 3-结晶识别 4-表计识别 |
| | | * "identifyResult": True, // 识别结果 |
| | | * "imagePath": "D:\room14_3_1748337299944.jpg" // 识别结果图片路径 |
| | | */ |
| | | @Data |
| | | @ToString |
| | | @TableName(schema = "db_fire_robot",value = "tb_identify_alarm_his") |
| | | public class IdentifyAlarmHis { |
| | | |
| | | @TableId(value = "id",type = IdType.AUTO) |
| | | private int id; |
| | | @ApiModelProperty(value = "采集时间") |
| | | private Date gatherTime; |
| | | @ApiModelProperty(value = "位置") |
| | | private int position; |
| | | @ApiModelProperty(value = "电池节数") |
| | | private int batteryCells; |
| | | @ApiModelProperty(value = "识别类型") |
| | | private int identifyType; |
| | | @ApiModelProperty(value = "识别结果") |
| | | private boolean identifyResult; |
| | | @ApiModelProperty(value = "识别结果图片路径") |
| | | private String imagePath; |
| | | @ApiModelProperty(value = "确认时间") |
| | | private Date confirmTime; |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.pojo.db_fire_robot; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 报警状态推送 |
| | | * "pushTime":"2025-03-28 13-44-31", // 推送时间 |
| | | * "MCUConnection": "DisConnected", // 单片机连接状态 |
| | | * "armConnection": "DisConnected", // 机械臂连接状态 |
| | | * "tempStatus": 0, // 温度异常报警 |
| | | * "humidityStatus": 0, // 湿度异常报警 |
| | | * "coStatus": 0, // 一氧化碳异常报警 |
| | | * "co2Status": 0, // 二氧化碳异常报警 |
| | | * "ch4Status": 0, // 甲烷异常报警 |
| | | * "h2Status": 0, // 氢气异常报警 |
| | | * "smokeStatus": 0, // 烟感异常报警 |
| | | * "foreignRecognition": 0, //异物识别异常报警 |
| | | * "meterIdentification": 0 //温湿度表表计异常报警 |
| | | */ |
| | | @Data |
| | | @ToString |
| | | @TableName(schema = "db_fire_robot",value = "tb_robot_alarm") |
| | | public class RobotAlarm { |
| | | |
| | | @TableId(value = "id",type = IdType.AUTO) |
| | | private int id; |
| | | @ApiModelProperty(value = "推送时间") |
| | | private Date pushTime; |
| | | @ApiModelProperty(value = "单片机连接状态") |
| | | private String MCUConnection; |
| | | @ApiModelProperty(value = "机械臂连接状态") |
| | | private String armConnection; |
| | | @ApiModelProperty(value = "温度异常报警") |
| | | private int tempStatus; |
| | | @ApiModelProperty(value = "湿度异常报警") |
| | | private int humidityStatus; |
| | | @ApiModelProperty(value = "一氧化碳异常报警") |
| | | private int coStatus; |
| | | @ApiModelProperty(value = "二氧化碳异常报警") |
| | | private int co2Status; |
| | | @ApiModelProperty(value = "甲烷异常报警") |
| | | private int ch4Status; |
| | | @ApiModelProperty(value = "氢气异常报警") |
| | | private int h2Status; |
| | | @ApiModelProperty(value = "烟感异常报警") |
| | | private int smokeStatus; |
| | | @ApiModelProperty(value = "异物识别异常报警") |
| | | private int foreignRecognition; |
| | | @ApiModelProperty(value = "温湿度表表计异常报警") |
| | | private int meterIdentification; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.pojo.db_fire_robot; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * "mode": 1, // 当前巡检模式: 1-遥控、2-手动、3-自动 4 自动返回 5 指定点 6 温湿度表计 |
| | | * "position": 5, // 当前位置点位:0、1、2、3……16 |
| | | * "regposition": 5, // 当前位置区间:0-1、2-3…… |
| | | * "perposition": 56, // 当前位置区间百分比,单位:% |
| | | * "state": 0, // 当前状态:0-停车、1-前进、2-左转、3-右转、 4-倒车 |
| | | * "interval": 10, // 巡检间隔,单位:小时 |
| | | * "charging": false, // 是否充电 |
| | | * "battery": 85 // 当前电量,单位:% |
| | | */ |
| | | @Data |
| | | @ToString |
| | | @TableName(schema = "db_fire_robot",value = "tb_robot_status") |
| | | public class RobotStatus { |
| | | |
| | | @TableId(value = "id",type = IdType.AUTO) |
| | | private int id; |
| | | |
| | | @ApiModelProperty(value = "当前巡检模式: 1-遥控、2-手动、3-自动 4 自动返回 5 指定点 6 温湿度表计") |
| | | private int mode; |
| | | |
| | | @ApiModelProperty(value = "当前位置点位:0、1、2、3……16") |
| | | private int position; |
| | | |
| | | @ApiModelProperty(value = "当前位置区间:0-1、2-3……") |
| | | private int regposition; |
| | | |
| | | @ApiModelProperty(value = "当前位置区间百分比,单位:%") |
| | | private int perposition; |
| | | |
| | | @ApiModelProperty(value = "当前状态:0-停车、1-前进、2-左转、3-右转、 4-倒车") |
| | | private int state; |
| | | |
| | | @ApiModelProperty(value = "巡检间隔,单位:小时") |
| | | private int interval; |
| | | |
| | | @ApiModelProperty(value = "是否充电") |
| | | private boolean charging; |
| | | |
| | | @ApiModelProperty(value = "当前电量,单位:%") |
| | | private int battery; |
| | | |
| | | private Date recordTime; |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.mapper.EnvironmentMapper; |
| | | import com.whyc.pojo.db_fire_robot.Environment; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Service |
| | | public class EnvironmentService { |
| | | |
| | | @Resource |
| | | private EnvironmentMapper mapper; |
| | | |
| | | public void add(Environment env) { |
| | | mapper.insert(env); |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.mapper.EnvironmentThresholdMapper; |
| | | import com.whyc.pojo.db_fire_robot.EnvironmentThreshold; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Service |
| | | public class EnvironmentThresholdService { |
| | | |
| | | @Resource |
| | | private EnvironmentThresholdMapper mapper; |
| | | |
| | | public void add(EnvironmentThreshold threshold) { |
| | | mapper.insert(threshold); |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.mapper.EnvironmentMapper; |
| | | import com.whyc.mapper.IdentifyAlarmMapper; |
| | | import com.whyc.pojo.db_fire_robot.IdentifyAlarm; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Service |
| | | public class IdentifyAlarmService { |
| | | |
| | | @Resource |
| | | private IdentifyAlarmMapper mapper; |
| | | |
| | | public void add(IdentifyAlarm alarm) { |
| | | mapper.insert(alarm); |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.mapper.EnvironmentMapper; |
| | | import com.whyc.mapper.RobotAlarmMapper; |
| | | import com.whyc.pojo.db_fire_robot.RobotAlarm; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Service |
| | | public class RobotAlarmService { |
| | | |
| | | @Resource |
| | | private RobotAlarmMapper mapper; |
| | | |
| | | public void add(RobotAlarm alarm) { |
| | | mapper.insert(alarm); |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.mapper.RobotStatusMapper; |
| | | import com.whyc.pojo.db_fire_robot.RobotStatus; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Service |
| | | public class RobotStatusService { |
| | | |
| | | @Resource |
| | | private RobotStatusMapper mapper; |
| | | |
| | | public void add(RobotStatus status) { |
| | | mapper.insert(status); |
| | | } |
| | | } |
| | |
| | | package com.whyc.webSocket.receiver; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.whyc.dto.FireRobotData; |
| | | import com.whyc.pojo.db_fire_robot.*; |
| | | import com.whyc.service.*; |
| | | import com.whyc.util.JsonUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.socket.CloseStatus; |
| | | import org.springframework.web.socket.TextMessage; |
| | | import org.springframework.web.socket.WebSocketHttpHeaders; |
| | | import org.springframework.web.socket.WebSocketSession; |
| | | import org.springframework.web.socket.handler.TextWebSocketHandler; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.util.Date; |
| | | |
| | | public class ThirdPartyWebSocketHandler extends TextWebSocketHandler { |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(ThirdPartyWebSocketHandler.class); |
| | | private WebSocketSession session; |
| | | |
| | | @Autowired |
| | | private EnvironmentService environmentService; |
| | | |
| | | @Autowired |
| | | private EnvironmentThresholdService environmentThresholdService; |
| | | |
| | | @Autowired |
| | | private RobotAlarmService robotAlarmService; |
| | | |
| | | @Autowired |
| | | private RobotStatusService robotStatusService; |
| | | |
| | | @Autowired |
| | | private IdentifyAlarmService identifyAlarmService; |
| | | |
| | | @Override |
| | | public void afterConnectionEstablished(WebSocketSession session) { |
| | |
| | | log.info("Received message: {}", message.getPayload()); |
| | | // 可以在这里做业务处理,比如发布事件、存入队列等 |
| | | String jsonStr = message.getPayload(); |
| | | Gson gson = JsonUtil.getGson(); |
| | | FireRobotData fireRobotData = gson.fromJson(jsonStr, FireRobotData.class); |
| | | Date now = new Date(); |
| | | switch (fireRobotData.getType()){ |
| | | case "environment": { |
| | | FireRobotData<Environment> data = gson.fromJson(jsonStr, new TypeToken<FireRobotData<Environment>>() { |
| | | }.getType()); |
| | | Environment env = data.getData(); |
| | | env.setRecordTime(now); |
| | | //存入数据库 |
| | | environmentService.add(env); |
| | | }break; |
| | | case "status": { |
| | | FireRobotData<RobotStatus> data = gson.fromJson(jsonStr, new TypeToken<FireRobotData<RobotStatus>>() { |
| | | }.getType()); |
| | | RobotStatus status = data.getData(); |
| | | status.setRecordTime(now); |
| | | //存入数据库 |
| | | robotStatusService.add(status); |
| | | }break; |
| | | case "alarm": { |
| | | FireRobotData<RobotAlarm> data = gson.fromJson(jsonStr, new TypeToken<FireRobotData<RobotAlarm>>() { |
| | | }.getType()); |
| | | RobotAlarm alarm = data.getData(); |
| | | //存入数据库 |
| | | robotAlarmService.add(alarm); |
| | | }break; |
| | | case "threshold": { |
| | | FireRobotData<EnvironmentThreshold> data = gson.fromJson(jsonStr, new TypeToken<FireRobotData<EnvironmentThreshold>>() { |
| | | }.getType()); |
| | | EnvironmentThreshold threshold = data.getData(); |
| | | threshold.setRecordTime(now); |
| | | //存入数据库 |
| | | environmentThresholdService.add(threshold); |
| | | }break; |
| | | case "identifyAlarm": { |
| | | FireRobotData<IdentifyAlarm> data = gson.fromJson(jsonStr, new TypeToken<FireRobotData<IdentifyAlarm>>() { |
| | | }.getType()); |
| | | IdentifyAlarm alarm = data.getData(); |
| | | //存入数据库 |
| | | identifyAlarmService.add(alarm); |
| | | }break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | } |
| | | |