修复更新通道是更新各个坐标系德位置信息

pull/751/head
648540858 2023-02-15 18:30:35 +08:00
parent 2c7ed82b3e
commit 7be636f8b8
7 changed files with 99 additions and 16 deletions

View File

@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.session.CatalogDataCatch;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import gov.nist.javax.sip.message.SIPRequest;
@ -107,6 +108,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
continue;
}
DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice, device, null);
deviceChannel = SipUtils.updateGps(deviceChannel, device.getGeoCoordSys());
deviceChannel.setDeviceId(take.getDevice().getDeviceId());
channelList.add(deviceChannel);

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.utils;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo;
import com.genersoft.iot.vmp.utils.GitUtil;
import gov.nist.javax.sip.address.AddressImpl;
@ -148,4 +149,37 @@ public class SipUtils {
return new RemoteAddressInfo(remoteAddress, remotePort);
}
public static DeviceChannel updateGps(DeviceChannel deviceChannel, String geoCoordSys) {
if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) {
if (geoCoordSys == null) {
geoCoordSys = "WGS84";
}
if ("WGS84".equals(geoCoordSys)) {
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude());
deviceChannel.setLongitudeGcj02(position[0]);
deviceChannel.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(geoCoordSys)) {
deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
deviceChannel.setLongitudeWgs84(position[0]);
deviceChannel.setLatitudeWgs84(position[1]);
}else {
deviceChannel.setLongitudeGcj02(0.00);
deviceChannel.setLatitudeGcj02(0.00);
deviceChannel.setLongitudeWgs84(0.00);
deviceChannel.setLatitudeWgs84(0.00);
}
}else {
deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
}
return deviceChannel;
}
}

View File

@ -1,11 +1,9 @@
package com.genersoft.iot.vmp.gb28181.utils;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.TreeType;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.utils.DateUtil;
import org.dom4j.Attribute;
@ -400,6 +398,7 @@ public class XmlUtil {
} else {
deviceChannel.setLatitude(0.00);
}
deviceChannel.setGpsTime(DateUtil.getNow());
@ -414,6 +413,7 @@ public class XmlUtil {
} else {
deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType")));
}
return deviceChannel;
}

View File

@ -46,4 +46,9 @@ public interface IDeviceChannelService {
* @return
*/
List<ChannelReduce> queryAllChannelList(String platformId);
/**
*
*/
boolean updateAllGps(Device device);
}

View File

@ -176,5 +176,29 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
return channelMapper.queryChannelListInAll(null, null, null, platformId, null);
}
@Override
public boolean updateAllGps(Device device) {
List<DeviceChannel> deviceChannels = channelMapper.getChannelsWithoutTransform(device.getDeviceId());
List<DeviceChannel> result = new ArrayList<>();
if (deviceChannels.size() == 0) {
return true;
}
deviceChannels.parallelStream().forEach(deviceChannel -> {
result.add(updateGps(deviceChannel, device));
});
int limitCount = 300;
if (result.size() > limitCount) {
for (int i = 0; i < result.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > result.size()) {
toIndex = result.size();
}
channelMapper.batchUpdate(result.subList(i, toIndex));
}
}else {
channelMapper.batchUpdate(result);
}
return true;
}
}

View File

@ -357,4 +357,8 @@ public interface DeviceChannelMapper {
@Select("select count(1) as total, sum(status) as online from device_channel")
ResourceBaceInfo getOverview();
@Select("select * from device_channel where deviceId = #{deviceId} " +
"and latitude * longitude > 0 and latitudeGcj02 * latitudeWgs84 * longitudeWgs84 * longitudeGcj02 = 0")
List<DeviceChannel> getChannelsWithoutTransform(String deviceId);
}

View File

@ -1,39 +1,30 @@
package com.genersoft.iot.vmp.vmanager.gb28181.MobilePosition;
import java.text.ParseException;
import java.util.List;
import java.util.UUID;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.util.StringUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
import java.util.List;
import java.util.UUID;
/**
*
@ -58,6 +49,9 @@ public class MobilePositionController {
@Autowired
private IDeviceService deviceService;
@Autowired
private IDeviceChannelService deviceChannelService;
/**
*
* @param deviceId ID
@ -162,4 +156,24 @@ public class MobilePositionController {
throw new ControllerException(ErrorCode.ERROR100);
}
}
/**
*
* @param deviceId ID
* @return true =
*/
@Operation(summary = "数据位置信息格式处理")
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@GetMapping("/transform/{deviceId}")
public void positionTransform(@PathVariable String deviceId) {
Device device = deviceService.getDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到设备: " + deviceId);
}
boolean result = deviceChannelService.updateAllGps(device);
if (!result) {
throw new ControllerException(ErrorCode.ERROR100);
}
}
}