1、增加倾角计数据解析和界面

This commit is contained in:
weidong 2025-09-29 07:55:32 +08:00
parent 2f8e8bb446
commit d7067dbe88
15 changed files with 505 additions and 81 deletions

View File

@ -0,0 +1,72 @@
package com.imdroid.secapi.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;
/**
* GNSS状态消息每个工作周期开始时上报一次
*
* @author LiGang
*/
@Data
@TableName(value = "surface_incline_data")
public class SurfaceInclineData {
@TableId(value = "id", type = IdType.AUTO)
@ExcelIgnore
Long id;
@ExcelProperty("租户id")
Integer tenantid;
@ExcelProperty("上报时间")
LocalDateTime createtime;
@ExcelProperty("设备编号")
String deviceid;
@ExcelProperty("传感器号")
Short sensorid;
@ExcelProperty("倾角X")
Float anglex;
@ExcelProperty("倾角Y")
Float angley;
@ExcelProperty("倾角Z")
Float anglez;
@ExcelProperty("加速度X")
Float accx;
@ExcelProperty("加速度Y")
Float accy;
@ExcelProperty("加速度Z")
Float accz;
@ExcelProperty("MaxX")
Float maxaccx;
@ExcelProperty("MaxY")
Float maxaccy;
@ExcelProperty("MaxZ")
Float maxaccz;
@ExcelProperty("MinX")
Float minaccx;
@ExcelProperty("MinY")
Float minaccy;
@ExcelProperty("MinZ")
Float minaccz;
}

View File

@ -0,0 +1,10 @@
package com.imdroid.secapi.dto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SurfaceInclineDataMapper extends BaseMapper<SurfaceInclineData> {
}

View File

@ -0,0 +1,51 @@
package com.imdroid.sideslope.executor;
import com.imdroid.common.util.ThreadManager;
import com.imdroid.secapi.dto.*;
import com.imdroid.sideslope.message.D350SurfaceInclineMessage;
import com.imdroid.sideslope.service.DataPersistService;
import com.imdroid.sideslope.service.Device;
import com.imdroid.sideslope.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author Layton
* @date 2023/2/2 20:40
* 1回ACK以便终端判断是否连接上服务器后台
* 2同步参数
* 3判断是否发冷启动指令
* 4保存状态信息判断是否有低电压等告警清除离线告警
*/
@Component
public class D350SurfaceInclineMessageExecutor implements Executor<D350SurfaceInclineMessage, Void> {
@Autowired
private DataPersistService dataPersistService;
@Autowired
SurfaceInclineDataMapper dataMapper;
@Autowired
private DeviceService deviceService;
@Override
public Void execute(D350SurfaceInclineMessage message) {
Device device = deviceService.findByDeviceId(message.getId());
if(device == null) return null;
// 补齐tenantId
message.setTenantId(device.getTenantId());
ThreadManager.getFixedThreadPool().submit(() -> {
//保存状态信息判断是否有低电压等告警清除离线告警
dataMapper.insert(message.getInclineData());
});
return null;
}
@Override
public Class<?> getMessageType() {
return D350SurfaceInclineMessage.class;
}
}

View File

@ -1,32 +0,0 @@
package com.imdroid.sideslope.executor;
import com.imdroid.sideslope.message.D350TestMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
* @author Layton
* @date 2023/2/2 20:40
*/
@Component
public class D350TestMessageExecutor implements Executor<D350TestMessage, Void> {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public Void execute(D350TestMessage message) {
if (logger.isDebugEnabled()) {
logger.debug("device {} max acc(g) in 1s: x={},y={},z={}",message.getId(),
message.getAccX(),message.getAccY(),message.getAccZ());
}
return null;
}
@Override
public Class<?> getMessageType() {
return D350TestMessage.class;
}
}

View File

@ -36,7 +36,7 @@ public class MessageParser {
types.put((short)0xd31A, D31xConfigAckMessage.class);//DTU配置应答 types.put((short)0xd31A, D31xConfigAckMessage.class);//DTU配置应答
types.put((short)0xd31B, D31xConfigAckMessage.class);//LORA配置应答 types.put((short)0xd31B, D31xConfigAckMessage.class);//LORA配置应答
types.put((short)0xd320, D31xConfigAckMessage.class);//v3.2 DTU配置应答 types.put((short)0xd320, D31xConfigAckMessage.class);//v3.2 DTU配置应答
types.put((short)0xd350, D350TestMessage.class);//ACC上报 types.put((short)0xd350, D350SurfaceInclineMessage.class);//ACC上报
types.put((short)0xd314, D314PingMessage.class);//ping types.put((short)0xd314, D314PingMessage.class);//ping
} }

View File

@ -0,0 +1,50 @@
package com.imdroid.sideslope.message;
import com.imdroid.secapi.dto.SurfaceInclineData;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 自检消息
*
* @author Layton
* @date 2023/2/2 20:38
*/
@EqualsAndHashCode(callSuper=true)
@Data
public class D350SurfaceInclineMessage extends BaseMessage {
SurfaceInclineData inclineData = new SurfaceInclineData();
@Override
public void decodeBody(ByteBuf src) {
// d3 50 length(2bytes) device_id(4bytes) seq(2bytes) data
this.len = src.readableBytes(); // total length
this.header = src.readUnsignedShort();// flag
src.readUnsignedShort();// d342 length
this.id = String.valueOf(src.readUnsignedInt());//id
this.seq = src.readUnsignedShort();
inclineData.setDeviceid(getId());
inclineData.setCreatetime(createTime);
inclineData.setSensorid(src.readUnsignedByte());
inclineData.setAnglex(src.readFloat());
inclineData.setAngley(src.readFloat());
inclineData.setAnglez(src.readFloat());
inclineData.setAccx(src.readFloat());
inclineData.setAccy(src.readFloat());
inclineData.setAccz(src.readFloat());
inclineData.setMaxaccx(src.readFloat());
inclineData.setMaxaccy(src.readFloat());
inclineData.setMaxaccz(src.readFloat());
inclineData.setMinaccx(src.readFloat());
inclineData.setMinaccy(src.readFloat());
inclineData.setMinaccz(src.readFloat());
}
@Override
public boolean shouldDecodeHeader() {
return false;
}
}

View File

@ -1,25 +0,0 @@
package com.imdroid.sideslope.message;
import com.imdroid.sideslope.bd.Gga;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author Layton
* @date 2023/2/2 20:50
*/
@Data
@EqualsAndHashCode(callSuper=true)
public class D350TestMessage extends BaseMessage {
double accX;
double accY;
double accZ;
Gga gga;
@Override
public void decodeBody(ByteBuf src) {
accX = src.readFloat();
accY = src.readFloat();
accZ = src.readFloat();
}
}

View File

@ -0,0 +1,75 @@
package com.imdroid.beidou.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.imdroid.beidou.service.CommonExcelService;
import com.imdroid.secapi.dto.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* 状态消息 控制器
*
* @author LiGang
* @date 2024/1/6 14:37
*/
@Controller
@RequiredArgsConstructor
public class SurfaceInclineController extends BasicController implements CommonExcelService<SurfaceInclineData, SurfaceInclineData> {
@Autowired
SurfaceInclineDataMapper dataMapper;
@RequestMapping("/page/surface_incline_data")
public String surfaceInclineData(Model m, HttpSession session) {
initModel(m, session);
return "/page/surface_incline_data";
}
@RequestMapping("/surface_incline/data/list")
@ResponseBody
public JSONObject listData(HttpSession session, Integer page, Integer limit, String searchParams) {
return this.pageList(session, page, limit, searchParams);
}
/**
* 导出excel
*
* @param session HttpSession
* @param request HttpServletRequest
* @param response HttpServletResponse
* @throws Exception
*/
@RequestMapping("/surface_incline/data/export")
@ResponseBody
public void exportData(HttpSession session, HttpServletRequest request, HttpServletResponse response) throws Exception {
this.export(session, request, response);
}
/**
* 获取实体类的class
*
* @return 实体类的class
*/
@Override
public Class<SurfaceInclineData> getEntityClass() {
return SurfaceInclineData.class;
}
/**
* 获取实体类对应的mybatis mapper
*
* @return 实体类对应的mybatis mapper
*/
@Override
public BaseMapper<SurfaceInclineData> getMapper() {
return dataMapper;
}
}

View File

@ -403,3 +403,28 @@ CREATE TABLE IF NOT EXISTS `traffic_records` (
KEY `idx_iccid` (`iccid`), KEY `idx_iccid` (`iccid`),
KEY `idx_recordtime` (`recordtime`) KEY `idx_recordtime` (`recordtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='流量使用记录表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='流量使用记录表';
/***
*/
CREATE TABLE IF NOT EXISTS `surface_incline_data` (
`id` bigint AUTO_INCREMENT,
`tenantid` int NOT NULL,
`createtime` datetime DEFAULT NULL,
`devicetime` time DEFAULT NULL,
`deviceid` varchar(20) NOT NULL,
`sensorid` smallint DEFAULT NULL,
`anglex` float DEFAULT NULL,
`angley` float DEFAULT NULL,
`anglez` float DEFAULT NULL,
`accx` float DEFAULT NULL,
`accy` float DEFAULT NULL,
`accz` float DEFAULT NULL,
`maxaccx` float DEFAULT NULL,
`maxaccy` float DEFAULT NULL,
`maxaccz` float DEFAULT NULL,
`minaccx` float DEFAULT NULL,
`minaccy` float DEFAULT NULL,
`minaccz` float DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@ -4,7 +4,7 @@
"href": "page/device_overview" "href": "page/device_overview"
}, },
"logoInfo": { "logoInfo": {
"title": "北斗管理平台", "title": "地质监测平台",
"image": "images/logo.png", "image": "images/logo.png",
"href": "" "href": ""
}, },
@ -41,12 +41,6 @@
} }
] ]
}, },
{
"title": "解算结果",
"href": "page/gnss_data_calc",
"icon": "fa fa-calculator",
"target": "_self"
},
{ {
"title": "配置管理", "title": "配置管理",
"href": "", "href": "",
@ -82,6 +76,32 @@
] ]
} }
] ]
},
{
"title": "监测数据",
"icon": "fa fa-address-book",
"href": "",
"target": "_self",
"child": [
{
"title": "北斗",
"href": "page/gnss_data_calc",
"icon": "fa fa-calculator",
"target": "_self"
},
{
"title": "倾角计",
"href": "page/surface_incline_data",
"icon": "fa fa-calculator",
"target": "_self"
},
{
"title": "测斜仪",
"href": "",
"icon": "fa fa-calculator",
"target": "_self"
}
]
} }
] ]
} }

View File

@ -4,7 +4,7 @@
"href": "page/device_overview" "href": "page/device_overview"
}, },
"logoInfo": { "logoInfo": {
"title": "北斗管理平台", "title": "地质监测平台",
"image": "images/logo.png", "image": "images/logo.png",
"href": "" "href": ""
}, },
@ -53,12 +53,6 @@
} }
] ]
}, },
{
"title": "解算结果",
"href": "page/gnss_data_calc",
"icon": "fa fa-calculator",
"target": "_self"
},
{ {
"title": "日志", "title": "日志",
"href": "page/gnss_single_data", "href": "page/gnss_single_data",
@ -177,6 +171,32 @@
} }
] ]
}, },
{
"title": "监测数据",
"icon": "fa fa-address-book",
"href": "",
"target": "_self",
"child": [
{
"title": "北斗",
"href": "page/gnss_data_calc",
"icon": "fa fa-calculator",
"target": "_self"
},
{
"title": "倾角计",
"href": "page/surface_incline_data",
"icon": "fa fa-calculator",
"target": "_self"
},
{
"title": "测斜仪",
"href": "",
"icon": "fa fa-calculator",
"target": "_self"
}
]
},
{ {
"title": "系统管理", "title": "系统管理",
"icon": "fa fa-lemon-o", "icon": "fa fa-lemon-o",

View File

@ -4,7 +4,7 @@
"href": "page/device_overview" "href": "page/device_overview"
}, },
"logoInfo": { "logoInfo": {
"title": "北斗管理平台", "title": "地质监测平台",
"image": "images/logo.png", "image": "images/logo.png",
"href": "" "href": ""
}, },
@ -47,12 +47,6 @@
} }
] ]
}, },
{
"title": "解算结果",
"href": "page/gnss_data_calc",
"icon": "fa fa-calculator",
"target": "_self"
},
{ {
"title": "配置管理", "title": "配置管理",
"href": "", "href": "",
@ -135,6 +129,32 @@
} }
] ]
}, },
{
"title": "监测数据",
"icon": "fa fa-address-book",
"href": "",
"target": "_self",
"child": [
{
"title": "北斗",
"href": "page/gnss_data_calc",
"icon": "fa fa-calculator",
"target": "_self"
},
{
"title": "倾角计",
"href": "page/surface_incline_data",
"icon": "fa fa-calculator",
"target": "_self"
},
{
"title": "测斜仪",
"href": "",
"icon": "fa fa-calculator",
"target": "_self"
}
]
},
{ {
"title": "系统管理", "title": "系统管理",
"icon": "fa fa-lemon-o", "icon": "fa fa-lemon-o",

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>北斗管理系统</title> <title>地质监测平台</title>
<meta name="renderer" content="webkit"> <meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Access-Control-Allow-Origin" content="*"> <meta http-equiv="Access-Control-Allow-Origin" content="*">

View File

@ -59,7 +59,7 @@
<div class="main-body"> <div class="main-body">
<div class="login-main"> <div class="login-main">
<div class="login-top"> <div class="login-top">
<span>北斗管理系统登录</span> <span>地质监测系统登录</span>
<span class="bg1"></span> <span class="bg1"></span>
<span class="bg2"></span> <span class="bg2"></span>
</div> </div>

View File

@ -0,0 +1,138 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>倾角计</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
<link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
<div class="layuimini-main">
<fieldset class="table-search-fieldset">
<legend>搜索信息</legend>
<div style="margin: 10px 10px 10px 10px">
<form class="layui-form layui-form-pane" action="" id="searchFrm">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">设备号</label>
<div class="layui-input-inline">
<input type="text" name="s_deviceid" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">传感器号</label>
<div class="layui-input-inline">
<input type="text" name="s_sensorid" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">范围</label>
<div class="layui-input-inline">
<input type="text" name="dgt_createtime" autocomplete="off" id="ID-laydate-start-date" class="layui-input" placeholder="开始日期">
</div>
<div class="layui-input-inline">
<input type="text" name="dlt_createtime" autocomplete="off" id="ID-laydate-end-date" class="layui-input" placeholder="结束日期">
</div>
</div>
<div class="layui-inline">
<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-export-btn"><i class="layui-icon">&#xe67d;</i>导出</button>
</div>
</div>
</form>
</div>
</fieldset>
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
</div>
</div>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script th:inline="javascript">
layui.use(['form', 'table', 'laydate'], function () {
var $ = layui.$;
var form = layui.form,
table = layui.table,
laydate = layui.laydate;
var cfg_cols = [
{field: 'deviceid', title: '设备号', width: 100, fixed: "left"},
{field: 'sensorid', title: '传感器号', width: 15, fixed: "left"},
{field: 'createtime', title: '上报时间', fixed: "left", templet: "<div>{{layui.util.toDateString(d.createtime, 'yyyy-MM-dd HH:mm:ss')}}</div>"},
{field: 'anglex', title: '倾角X', templet: "<div>{{d.anglex.toFixed(3)}}</div>"},
{field: 'angley', title: '倾角Y', templet: "<div>{{d.angley.toFixed(3)}}</div>"},
{field: 'anglez', title: '倾角Z', templet: "<div>{{d.anglez.toFixed(3)}}</div>"},
{field: 'accx', title: '加速度X', templet: "<div>{{d.accx.toFixed(3)}}</div>"},
{field: 'accy', title: '加速度Y', templet: "<div>{{d.accy.toFixed(3)}}</div>"},
{field: 'accz', title: '加速度Z', templet: "<div>{{d.accz.toFixed(3)}}</div>"},
{field: 'maxaccx', title: 'MaxX', templet: "<div>{{d.maxaccx.toFixed(3)}}</div>"},
{field: 'maxaccy', title: 'MaxY', templet: "<div>{{d.maxaccy.toFixed(3)}}</div>"},
{field: 'maxaccz', title: 'MaxZ', templet: "<div>{{d.maxaccz.toFixed(3)}}</div>"},
{field: 'minaccx', title: 'MinX', templet: "<div>{{d.minaccx.toFixed(3)}}</div>"},
{field: 'minaccy', title: 'MinY', templet: "<div>{{d.minaccy.toFixed(3)}}</div>"},
{field: 'minaccz', title: 'MinZ', templet: "<div>{{d.minaccz.toFixed(3)}}</div>"},
];
/**
* 初始化表单,要加上,不然刷新部分组件可能会不加载
*/
form.render();
laydate.render({
elem: '#ID-laydate-start-date',
type: 'datetime'
});
laydate.render({
elem: '#ID-laydate-end-date',
type: 'datetime'
});
table.render({
elem: '#currentTableId',
url: '/surface_incline/data/list',
toolbar: '#toolbarDemo',//开启头部工具栏
defaultToolbar: ['filter'],
cols: [
cfg_cols
],
limits: [10, 50, 100, 200],
limit: 10,
page: true,
skin: 'line'
});
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
var result = JSON.stringify(data.field);
//执行搜索重载
table.reload('currentTableId', {
page: {
curr: 1
}
, where: {
searchParams: result
}
}, 'data');
return false;
});
// 监听导出操作
form.on('submit(data-export-btn)', function (data) {
var result = $('#searchFrm').serialize();
var u = "/surface_incline/data/export?" + result;
window.open(u, "_blank");
return false;
});
});
</script>
</body>
</html>