From 87135fdaf0c10ec5405293c0a889da740493be2a Mon Sep 17 00:00:00 2001 From: yarnom Date: Thu, 13 Nov 2025 01:46:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BA=8B=E5=8A=A1?= =?UTF-8?q?=E5=9B=9E=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../imdroid/secapi/dto/RtkTransaction.java | 23 +++++++ .../secapi/dto/RtkTransactionMapper.java | 7 +++ .../beidou/controller/APIController.java | 1 + .../controller/RtkTransactionController.java | 43 +++++++++++++ .../beidou/service/RtkMonitorService.java | 49 +++++++++++++++ .../beidou/util/GeoCoordConverterUtil.java | 33 ++++++++++ .../static/api/init_super_admin.json | 26 +++++--- .../templates/page/rtk_transactions.html | 62 +++++++++++++++++++ 8 files changed, 235 insertions(+), 9 deletions(-) create mode 100644 sec-api/src/main/java/com/imdroid/secapi/dto/RtkTransaction.java create mode 100644 sec-api/src/main/java/com/imdroid/secapi/dto/RtkTransactionMapper.java create mode 100644 sec-beidou/src/main/java/com/imdroid/beidou/controller/RtkTransactionController.java create mode 100644 sec-beidou/src/main/java/com/imdroid/beidou/util/GeoCoordConverterUtil.java create mode 100644 sec-beidou/src/main/resources/templates/page/rtk_transactions.html diff --git a/sec-api/src/main/java/com/imdroid/secapi/dto/RtkTransaction.java b/sec-api/src/main/java/com/imdroid/secapi/dto/RtkTransaction.java new file mode 100644 index 00000000..5a0ff5e6 --- /dev/null +++ b/sec-api/src/main/java/com/imdroid/secapi/dto/RtkTransaction.java @@ -0,0 +1,23 @@ +package com.imdroid.secapi.dto; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +@Data +@TableName(value = "rtktransaction") +public class RtkTransaction { + @TableId(value = "id", type = IdType.AUTO) + Integer id; + String device_id; + Double latitude; + Double longitude; + Double altitude; + Double ecef_x; + Double ecef_y; + Double ecef_z; + Short status; + Short checked; +} + diff --git a/sec-api/src/main/java/com/imdroid/secapi/dto/RtkTransactionMapper.java b/sec-api/src/main/java/com/imdroid/secapi/dto/RtkTransactionMapper.java new file mode 100644 index 00000000..98c10522 --- /dev/null +++ b/sec-api/src/main/java/com/imdroid/secapi/dto/RtkTransactionMapper.java @@ -0,0 +1,7 @@ +package com.imdroid.secapi.dto; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface RtkTransactionMapper extends BaseMapper { +} + diff --git a/sec-beidou/src/main/java/com/imdroid/beidou/controller/APIController.java b/sec-beidou/src/main/java/com/imdroid/beidou/controller/APIController.java index 719c5dce..2473585e 100644 --- a/sec-beidou/src/main/java/com/imdroid/beidou/controller/APIController.java +++ b/sec-beidou/src/main/java/com/imdroid/beidou/controller/APIController.java @@ -412,6 +412,7 @@ public class APIController extends BasicController { } if(q >= 0){ rtkMonitorService.onSolution(deviceId, q); + try{ rtkMonitorService.onSolutionLLH(deviceId, q, lat, lon, h);}catch(Exception ignore){} } } catch (Exception e){ String msg = "RTK " + deviceId + " " + line; diff --git a/sec-beidou/src/main/java/com/imdroid/beidou/controller/RtkTransactionController.java b/sec-beidou/src/main/java/com/imdroid/beidou/controller/RtkTransactionController.java new file mode 100644 index 00000000..864a97da --- /dev/null +++ b/sec-beidou/src/main/java/com/imdroid/beidou/controller/RtkTransactionController.java @@ -0,0 +1,43 @@ +package com.imdroid.beidou.controller; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.imdroid.secapi.dto.RtkTransaction; +import com.imdroid.secapi.dto.RtkTransactionMapper; +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.HttpSession; + +@Controller +public class RtkTransactionController extends BasicController { + @Autowired + RtkTransactionMapper mapper; + + @RequestMapping("/page/rtk_transactions") + public String page(Model m, HttpSession session){ + initModel(m, session); + return "/page/rtk_transactions"; + } + + @RequestMapping("/rtk/transaction/list") + @ResponseBody + public JSONObject list(int page, int limit, String device_id){ + Page pageable = new Page<>(page, limit); + QueryWrapper qw = new QueryWrapper<>(); + if(device_id!=null && !device_id.isEmpty()) qw.eq("device_id", device_id); + IPage cs = mapper.selectPage(pageable, qw); + JSONObject json = new JSONObject(); + json.put("code",0); + json.put("msg",""); + json.put("count", cs.getTotal()); + json.put("data", cs.getRecords()); + return json; + } +} + diff --git a/sec-beidou/src/main/java/com/imdroid/beidou/service/RtkMonitorService.java b/sec-beidou/src/main/java/com/imdroid/beidou/service/RtkMonitorService.java index c479f2f9..dbbba160 100644 --- a/sec-beidou/src/main/java/com/imdroid/beidou/service/RtkMonitorService.java +++ b/sec-beidou/src/main/java/com/imdroid/beidou/service/RtkMonitorService.java @@ -12,6 +12,7 @@ import java.util.concurrent.ConcurrentHashMap; public class RtkMonitorService { private final Map consecFix = new ConcurrentHashMap<>(); private final Map running = new ConcurrentHashMap<>(); + private final Map> fixBuffer = new ConcurrentHashMap<>(); @Autowired RtkrcvClient rtkrcvClient; @@ -21,10 +22,12 @@ public class RtkMonitorService { public void onStart(String deviceId){ running.put(deviceId, true); consecFix.put(deviceId, 0); + fixBuffer.remove(deviceId); } public void onStop(String deviceId){ running.remove(deviceId); consecFix.remove(deviceId); + fixBuffer.remove(deviceId); } public void onSolution(String deviceId, int q){ if(Boolean.TRUE.equals(running.get(deviceId))){ @@ -32,9 +35,17 @@ public class RtkMonitorService { consecFix.merge(deviceId, 1, Integer::sum); } else { consecFix.put(deviceId, 0); + fixBuffer.remove(deviceId); } } } + public void onSolutionLLH(String deviceId, int q, double lat, double lon, double h){ + if(Boolean.TRUE.equals(running.get(deviceId)) && q==1){ + java.util.LinkedList buf = fixBuffer.computeIfAbsent(deviceId,k->new java.util.LinkedList<>()); + buf.add(new double[]{lat,lon,h}); + if(buf.size()>100) buf.removeFirst(); + } + } @Scheduled(fixedRate = 30000) public void check(){ @@ -44,6 +55,7 @@ public class RtkMonitorService { if(Boolean.TRUE.equals(running.get(dev)) && cnt != null && cnt >= 40){ try { rtkrcvClient.stop(dev); } catch (Exception ignore) {} running.remove(dev); + try { writeTransaction(dev); } catch (Exception ignore) {} try { com.alibaba.fastjson.JSONObject ctrl = new com.alibaba.fastjson.JSONObject(); ctrl.put("type","rtk_ctrl"); @@ -55,4 +67,41 @@ public class RtkMonitorService { } } } + + @org.springframework.beans.factory.annotation.Autowired + com.imdroid.secapi.dto.RtkTransactionMapper rtkTransactionMapper; + + private void writeTransaction(String deviceId){ + java.util.LinkedList buf = fixBuffer.get(deviceId); + if(buf==null || buf.size()<40) return; + java.util.List last = buf.subList(Math.max(buf.size()-40,0), buf.size()); + double[] latArr = new double[last.size()]; + double[] lonArr = new double[last.size()]; + double[] hArr = new double[last.size()]; + for(int i=0;i + + + + RTK事务 + + + + + + + +
+
+
+ 查询 +
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+
+
+ + + + +