添加从国标通道同步的方法
parent
43fe078723
commit
a730fc904b
|
@ -1,6 +1,7 @@
|
|||
package com.genersoft.iot.vmp.service;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,6 +11,8 @@ public interface ICommonGbChannelService {
|
|||
|
||||
int add(CommonGbChannel channel);
|
||||
|
||||
int addFromGbChannel(DeviceChannel channel);
|
||||
|
||||
int delete(String channelId);
|
||||
|
||||
int update(CommonGbChannel channel);
|
||||
|
|
|
@ -6,6 +6,8 @@ import com.genersoft.iot.vmp.service.ICommonGbChannelService;
|
|||
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -18,6 +20,8 @@ import java.util.List;
|
|||
@Service
|
||||
public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(CommonGbChannelServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private CommonGbChannelMapper commonGbChannelMapper;
|
||||
|
||||
|
@ -41,6 +45,18 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
|||
return commonGbChannelMapper.add(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addFromGbChannel(DeviceChannel channel) {
|
||||
CommonGbChannel commonGbChannel = commonGbChannelMapper.queryByDeviceID(channel.getChannelId());
|
||||
logger.info("[添加通用通道]来自国标通道,国标编号: {}, 同步所有字段", channel.getChannelId());
|
||||
if (commonGbChannel != null) {
|
||||
logger.info("[添加通用通道]来自国标通道,失败,已存在。国标编号: {}", channel.getChannelId());
|
||||
return 0;
|
||||
}
|
||||
CommonGbChannel commonChannelFromDeviceChannel = getCommonChannelFromDeviceChannel(channel, null);
|
||||
return commonGbChannelMapper.add(commonChannelFromDeviceChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(String channelId) {
|
||||
return commonGbChannelMapper.deleteByDeviceID(channelId);
|
||||
|
@ -58,6 +74,7 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
|||
|
||||
@Override
|
||||
public boolean SyncChannelFromGb28181Device(String gbDeviceId, List<String> syncKeys) {
|
||||
logger.info("同步通用通道]来自国标设备,国标编号: {}", gbDeviceId);
|
||||
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryAllChannels(gbDeviceId);
|
||||
if (deviceChannels.isEmpty()) {
|
||||
return false;
|
||||
|
@ -92,11 +109,40 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
|||
}
|
||||
|
||||
private CommonGbChannel getCommonChannelFromDeviceChannel(DeviceChannel deviceChannel, List<String> syncKeys) {
|
||||
if (deviceChannel == null || syncKeys == null || syncKeys.isEmpty()) {
|
||||
if (deviceChannel == null) {
|
||||
return null;
|
||||
}
|
||||
CommonGbChannel commonGbChannel = new CommonGbChannel();
|
||||
commonGbChannel.setCommonGbDeviceID(deviceChannel.getChannelId());
|
||||
if (syncKeys == null || syncKeys.isEmpty()) {
|
||||
commonGbChannel.setCommonGbName(deviceChannel.getName());
|
||||
commonGbChannel.setCommonGbManufacturer(deviceChannel.getManufacture());
|
||||
commonGbChannel.setCommonGbModel(deviceChannel.getModel());
|
||||
commonGbChannel.setCommonGbOwner(deviceChannel.getOwner());
|
||||
commonGbChannel.setCommonGbCivilCode(deviceChannel.getCivilCode());
|
||||
commonGbChannel.setCommonGbBlock(deviceChannel.getBlock());
|
||||
commonGbChannel.setCommonGbAddress(deviceChannel.getAddress());
|
||||
commonGbChannel.setCommonGbParental(deviceChannel.getParental());
|
||||
commonGbChannel.setCommonGbParentID(deviceChannel.getParentId());
|
||||
commonGbChannel.setCommonGbSafetyWay(deviceChannel.getSafetyWay());
|
||||
commonGbChannel.setCommonGbRegisterWay(deviceChannel.getRegisterWay());
|
||||
commonGbChannel.setCommonGbCertNum(deviceChannel.getCertNum());
|
||||
commonGbChannel.setCommonGbCertifiable(deviceChannel.getCertifiable());
|
||||
commonGbChannel.setCommonGbErrCode(deviceChannel.getErrCode());
|
||||
commonGbChannel.setCommonGbEndTime(deviceChannel.getEndTime());
|
||||
if (NumberUtils.isParsable(deviceChannel.getSecrecy())) {
|
||||
commonGbChannel.setCommonGbSecrecy(Integer.parseInt(deviceChannel.getSecrecy()));
|
||||
}
|
||||
commonGbChannel.setCommonGbIPAddress(deviceChannel.getIpAddress());
|
||||
commonGbChannel.setCommonGbPort(deviceChannel.getPort());
|
||||
commonGbChannel.setCommonGbPassword(deviceChannel.getPassword());
|
||||
commonGbChannel.setCommonGbStatus(deviceChannel.isStatus());
|
||||
commonGbChannel.setCommonGbLongitude(deviceChannel.getLongitude());
|
||||
commonGbChannel.setCommonGbLatitude(deviceChannel.getLatitude());
|
||||
commonGbChannel.setCommonGbPtzType(deviceChannel.getPTZType());
|
||||
commonGbChannel.setCommonGbPositionType(deviceChannel.getCommonGbPositionType());
|
||||
commonGbChannel.setCommonGbBusinessGroupID(deviceChannel.getBusinessGroupId());
|
||||
} else {
|
||||
for (String key : syncKeys) {
|
||||
switch (key) {
|
||||
case "commonGbName":
|
||||
|
@ -193,6 +239,8 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return commonGbChannel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,13 +10,13 @@ import java.util.List;
|
|||
@Repository
|
||||
public interface BusinessGroupMapper {
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
@Select(value = " <script>" +
|
||||
" select * from wvp_common_business_group " +
|
||||
" WHERE 1=1 " +
|
||||
" <if test='parentId != null' > AND common_business_group_parent_id = #{parentId}</if>" +
|
||||
" <if test='parentId == null' > AND common_business_group_parent_id is null </if>" +
|
||||
" order by common_business_group_id ASC " +
|
||||
" </script>"})
|
||||
" </script>")
|
||||
List<BusinessGroup> getNodes(String parentId);
|
||||
|
||||
@Select(" select * from wvp_common_business_group " +
|
||||
|
|
Loading…
Reference in New Issue