From e555df52d3391a65ba874e5fc692ba223bd62df4 Mon Sep 17 00:00:00 2001
From: lin <648540858@qq.com>
Date: Wed, 6 Aug 2025 06:38:37 +0800
Subject: [PATCH] =?UTF-8?q?[1078]=20=E9=80=9A=E7=94=A8=E9=80=9A=E9=81=93?=
=?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BD=8D=E7=BD=AE=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../gb28181/dao/CommonGBChannelMapper.java | 14 +++++++
.../gb28181/service/IGbChannelService.java | 1 +
.../service/impl/GbChannelServiceImpl.java | 17 +++++++++
.../service/impl/jt1078ServiceImpl.java | 37 +++++++++++++++++++
4 files changed, 69 insertions(+)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java
index 05873fa53..3f21f7e38 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java
@@ -583,4 +583,18 @@ public interface CommonGBChannelMapper {
@Update("UPDATE wvp_device_channel SET stream_id = #{stream} where id = #{gbId}")
void updateStream(int gbId, String stream);
+
+ @Update("")
+ void updateGps(List commonGBChannels);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java
index 4e7497bc3..4fd1cbe3a 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java
@@ -96,4 +96,5 @@ public interface IGbChannelService {
void updateGPSFromGPSMsgInfo(List gpsMsgInfoList);
+ void updateGPS(List channelList);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java
index ef3fbcf5f..3e99d18a6 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java
@@ -771,4 +771,21 @@ public class GbChannelServiceImpl implements IGbChannelService {
}
commonGBChannelMapper.updateGpsByDeviceId(gpsMsgInfoList);
}
+
+ @Transactional
+ @Override
+ public void updateGPS(List commonGBChannels) {
+ int limitCount = 1000;
+ if (commonGBChannels.size() > limitCount) {
+ for (int i = 0; i < commonGBChannels.size(); i += limitCount) {
+ int toIndex = i + limitCount;
+ if (i + limitCount > commonGBChannels.size()) {
+ toIndex = commonGBChannels.size();
+ }
+ commonGBChannelMapper.updateGps(commonGBChannels.subList(i, toIndex));
+ }
+ } else {
+ commonGBChannelMapper.updateGps(commonGBChannels);
+ }
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java
index cde0d4126..4600ae39f 100644
--- a/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java
@@ -164,7 +164,44 @@ public class jt1078ServiceImpl implements Ijt1078Service {
@Async("taskExecutor")
@EventListener
public void onApplicationEvent(JTPositionEvent event) {
+ if (event.getPhoneNumber() == null || event.getPositionInfo() == null
+ || event.getPositionInfo().getLongitude() == null || event.getPositionInfo().getLatitude() == null) {
+ return;
+ }
+ JTDevice device = getDevice(event.getPhoneNumber());
+ if (device == null) {
+ return;
+ }
+ device.setLongitude(event.getPositionInfo().getLongitude());
+ device.setLatitude(event.getPositionInfo().getLatitude());
+ updateDevice(device);
+ // 通道发送状态变化通知
+ List jtChannels = jtChannelMapper.selectAll(device.getId(), null);
+ List channelList = new ArrayList<>();
+ for (JTChannel jtChannel : jtChannels) {
+ if (jtChannel.getGbId() > 0) {
+ jtChannel.setGbLongitude(event.getPositionInfo().getLongitude());
+ jtChannel.setGbLatitude(event.getPositionInfo().getLatitude());
+ if (event.getPositionInfo().getAltitude() != null) {
+ jtChannel.setGpsAltitude((double) event.getPositionInfo().getAltitude());
+ }else {
+ jtChannel.setGpsAltitude(0d);
+ }
+ if (event.getPositionInfo().getDirection() != null) {
+ jtChannel.setGpsDirection((double) event.getPositionInfo().getDirection());
+ }else {
+ jtChannel.setGpsDirection(0d);
+ }
+ if (event.getPositionInfo().getTime() != null) {
+ jtChannel.setGpsTime(event.getPositionInfo().getTime());
+ }else {
+ jtChannel.setGpsTime(DateUtil.getNow());
+ }
+ channelList.add(jtChannel);
+ }
+ }
+ channelService.updateGPS(channelList);
}