临时提交

This commit is contained in:
panlinlin
2024-07-10 00:07:01 +08:00
parent 61b811e701
commit aa9397ca21
5 changed files with 237 additions and 360 deletions

View File

@@ -40,11 +40,6 @@ public interface IDeviceChannelService {
*/
List<ChannelReduce> queryAllChannelList(String platformId);
/**
* 数据位置信息格式处理
*/
boolean updateAllGps(Device device);
/**
* 查询通道所属的设备
*/

View File

@@ -82,7 +82,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
}else {
channelMapper.update(channel);
}
channelMapper.updateChannelSubCount(deviceId,channel.getParentId());
channelMapper.updateChannelSubCount(channel.getDeviceDbId(),channel.getParentId());
}
@Override
@@ -170,34 +170,6 @@ 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 CopyOnWriteArrayList<>();
if (deviceChannels.size() == 0) {
return true;
}
String now = DateUtil.getNow();
deviceChannels.parallelStream().forEach(deviceChannel -> {
deviceChannel.setUpdateTime(now);
result.add(deviceChannel);
});
int limitCount = 50;
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;
}
@Override
public List<Device> getDeviceByChannelId(String channelId) {
@@ -216,7 +188,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
@Override
public void online(DeviceChannel channel) {
channelMapper.online(channel.getDeviceId(), channel.getDeviceId());
channelMapper.online(channel.getId());
}
@Override
@@ -227,7 +199,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
@Override
public void offline(DeviceChannel channel) {
channelMapper.offline(channel.getDeviceId(), channel.getDeviceId());
channelMapper.offline(channel.getId());
}
@Override
@@ -267,14 +239,14 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
channelMapper.batchAdd(channels);
for (DeviceChannel channel : channels) {
if (channel.getParentId() != null) {
channelMapper.updateChannelSubCount(channel.getDeviceId(), channel.getParentId());
channelMapper.updateChannelSubCount(channel.getDeviceDbId(), channel.getParentId());
}
}
}
@Override
public void updateChannelStreamIdentification(DeviceChannel channel) {
assert !ObjectUtils.isEmpty(channel.getDeviceId());
assert !ObjectUtils.isEmpty(channel.getId());
assert !ObjectUtils.isEmpty(channel.getStreamIdentification());
if (ObjectUtils.isEmpty(channel.getStreamIdentification())) {
log.info("[重置通道码流类型] 设备: {}, 码流: {}", channel.getDeviceId(), channel.getStreamIdentification());
@@ -287,7 +259,11 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
@Override
public List<DeviceChannel> queryChaneListByDeviceId(String deviceId) {
return channelMapper.queryAllChannels(deviceId);
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到通道:" + deviceId);
}
return channelMapper.queryAllChannels(device.getId());
}
@Override
@@ -417,7 +393,11 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
if (CollectionUtils.isEmpty(deviceChannelList)) {
return false;
}
List<DeviceChannel> allChannels = channelMapper.queryAllChannels(deviceId);
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备: " +deviceId);
}
List<DeviceChannel> allChannels = channelMapper.queryAllChannels(device.getId());
Map<String,DeviceChannel> allChannelMap = new ConcurrentHashMap<>();
if (allChannels.size() > 0) {
for (DeviceChannel deviceChannel : allChannels) {

View File

@@ -171,7 +171,7 @@ public class DeviceServiceImpl implements IDeviceService {
}
}else {
if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) {
if (deviceChannelMapper.queryAllChannels(device.getId()).isEmpty()) {
log.info("[设备上线]: {}通道数为0,查询通道信息", device.getDeviceId());
sync(device);
}
@@ -402,20 +402,6 @@ public class DeviceServiceImpl implements IDeviceService {
redisCatchStorage.updateDevice(device);
}
}
/**
* 更新通道坐标系
*/
private void updateDeviceChannelGeoCoordSys(Device device) {
List<DeviceChannel> deviceChannels = deviceChannelMapper.getAllChannelWithCoordinate(device.getDeviceId());
if (!deviceChannels.isEmpty()) {
List<DeviceChannel> deviceChannelsForStore = new ArrayList<>();
deviceChannelsForStore.addAll(deviceChannels);
deviceChannelService.updateChannels(device, deviceChannelsForStore);
}
}
@Override
public List<DeviceChannel> queryVideoDeviceInTreeNode(String deviceId, String parentId) {
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
@@ -423,9 +409,9 @@ public class DeviceServiceImpl implements IDeviceService {
return null;
}
if (ObjectUtils.isEmpty(parentId) || parentId.equals(deviceId)) {
return deviceChannelMapper.getSubChannelsByDeviceId(deviceId, null, false);
return deviceChannelMapper.getSubChannelsByDeviceId(device.getId(), null, false);
}else {
return deviceChannelMapper.getSubChannelsByDeviceId(deviceId, parentId, false);
return deviceChannelMapper.getSubChannelsByDeviceId(device.getId(), parentId, false);
}
}
@@ -528,7 +514,6 @@ public class DeviceServiceImpl implements IDeviceService {
// 坐标系变化需要重新计算GCJ02坐标和WGS84坐标
if (!deviceInStore.getGeoCoordSys().equals(device.getGeoCoordSys())) {
deviceInStore.setGeoCoordSys(device.getGeoCoordSys());
updateDeviceChannelGeoCoordSys(deviceInStore);
}
}else {
deviceInStore.setGeoCoordSys("WGS84");