mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-24 22:17:49 +08:00
[1078] 通用通道支持位置更新
This commit is contained in:
parent
c90836261a
commit
e555df52d3
@ -583,4 +583,18 @@ public interface CommonGBChannelMapper {
|
|||||||
|
|
||||||
@Update("UPDATE wvp_device_channel SET stream_id = #{stream} where id = #{gbId}")
|
@Update("UPDATE wvp_device_channel SET stream_id = #{stream} where id = #{gbId}")
|
||||||
void updateStream(int gbId, String stream);
|
void updateStream(int gbId, String stream);
|
||||||
|
|
||||||
|
@Update("<script> " +
|
||||||
|
"<foreach collection='commonGBChannels' index='index' item='item' separator=';'> " +
|
||||||
|
"UPDATE wvp_device_channel " +
|
||||||
|
" SET gb_longitude=#{item.gbLongitude}" +
|
||||||
|
", gb_latitude=#{item.gbLatitude} " +
|
||||||
|
", gps_speed=#{item.gpsSpeed} " +
|
||||||
|
", gps_altitude=#{item.gpsAltitude} " +
|
||||||
|
", gps_direction=#{item.gpsDirection} " +
|
||||||
|
", gps_time=#{item.gpsTime} " +
|
||||||
|
"WHERE id = #{item.gbId}" +
|
||||||
|
"</foreach> " +
|
||||||
|
"</script>")
|
||||||
|
void updateGps(List<CommonGBChannel> commonGBChannels);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -96,4 +96,5 @@ public interface IGbChannelService {
|
|||||||
|
|
||||||
void updateGPSFromGPSMsgInfo(List<GPSMsgInfo> gpsMsgInfoList);
|
void updateGPSFromGPSMsgInfo(List<GPSMsgInfo> gpsMsgInfoList);
|
||||||
|
|
||||||
|
void updateGPS(List<CommonGBChannel> channelList);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -771,4 +771,21 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
|||||||
}
|
}
|
||||||
commonGBChannelMapper.updateGpsByDeviceId(gpsMsgInfoList);
|
commonGBChannelMapper.updateGpsByDeviceId(gpsMsgInfoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void updateGPS(List<CommonGBChannel> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -164,7 +164,44 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
@Async("taskExecutor")
|
@Async("taskExecutor")
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onApplicationEvent(JTPositionEvent event) {
|
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<JTChannel> jtChannels = jtChannelMapper.selectAll(device.getId(), null);
|
||||||
|
List<CommonGBChannel> 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user