648540858
2022-05-12 a030d00c8819612de2c280b75abdc90573eb52ce
修复代码
7个文件已修改
172 ■■■■■ 已修改文件
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java
@@ -10,6 +10,7 @@
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.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import org.dom4j.DocumentException;
@@ -56,6 +57,9 @@
    @Autowired
    private EventPublisher publisher;
    @Autowired
    private IDeviceService deviceService;
    @Override
    public void afterPropertiesSet() throws Exception {
        responseMessageHandler.addHandler(cmdType, this);
@@ -82,7 +86,8 @@
            if (StringUtils.isEmpty(device.getStreamMode())) {
                device.setStreamMode("UDP");
            }
            storager.updateDevice(device);
            deviceService.updateDevice(device);
//            storager.updateDevice(device);
            RequestMessage msg = new RequestMessage();
            msg.setKey(key);
src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java
@@ -104,4 +104,10 @@
     * @return 设备信息
     */
    Device getDeviceByHostAndPort(String host, int port);
    /**
     * 更新设备
     * @param device 设备信息
     */
    void updateDevice(Device device);
}
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
@@ -21,6 +21,7 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.sip.DialogState;
import javax.sip.TimeoutEvent;
@@ -248,4 +249,61 @@
    public Device getDeviceByHostAndPort(String host, int port) {
        return deviceMapper.getDeviceByHostAndPort(host, port);
    }
    @Override
    public void updateDevice(Device device) {
        Device deviceInStore = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
        if (deviceInStore == null) {
            logger.warn("更新设备时未找到设备信息");
            return;
        }
        if (!StringUtils.isEmpty(device.getName())) {
            deviceInStore.setName(device.getName());
        }
        if (!StringUtils.isEmpty(device.getCharset())) {
            deviceInStore.setCharset(device.getCharset());
        }
        if (!StringUtils.isEmpty(device.getMediaServerId())) {
            deviceInStore.setMediaServerId(device.getMediaServerId());
        }
        //  目录订阅相关的信息
        if (device.getSubscribeCycleForCatalog() > 0) {
            if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
                deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
                // 开启订阅
                addCatalogSubscribe(deviceInStore);
            }
        }else if (device.getSubscribeCycleForCatalog() == 0) {
            if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
                deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
                // 取消订阅
                removeCatalogSubscribe(deviceInStore);
            }
        }
        // 移动位置订阅相关的信息
        if (device.getSubscribeCycleForMobilePosition() > 0) {
            if (deviceInStore.getSubscribeCycleForMobilePosition() == 0 || deviceInStore.getSubscribeCycleForMobilePosition() != device.getSubscribeCycleForMobilePosition()) {
                deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
                deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
                // 开启订阅
                addMobilePositionSubscribe(deviceInStore);
            }
        }else if (device.getSubscribeCycleForMobilePosition() == 0) {
            if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) {
                // 取消订阅
                removeMobilePositionSubscribe(deviceInStore);
            }
        }
        String now = DateUtil.getNow();
        device.setUpdateTime(now);
        device.setCharset(device.getCharset().toUpperCase());
        device.setUpdateTime(DateUtil.getNow());
        if (deviceMapper.update(device) > 0) {
            redisCatchStorage.updateDevice(device);
        }
    }
}
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
@@ -25,22 +25,6 @@
     * @return true:存在  false:不存在
     */
    public boolean exists(String deviceId);
    /**
     * 视频设备创建
     *
     * @param device 设备对象
     * @return true:创建成功  false:创建失败
     */
    public boolean create(Device device);
    /**
     * 视频设备更新
     *
     * @param device 设备对象
     * @return true:创建成功  false:创建失败
     */
    public boolean updateDevice(Device device);
    /**
     * 添加设备通道
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
@@ -102,43 +102,6 @@
        return deviceMapper.getDeviceByDeviceId(deviceId) != null;
    }
    /**
     * 视频设备创建
     *
     * @param device 设备对象
     * @return true:创建成功  false:创建失败
     */
    @Override
    public synchronized boolean create(Device device) {
        redisCatchStorage.updateDevice(device);
        return deviceMapper.add(device) > 0;
    }
    /**
     * 视频设备更新
     *
     * @param device 设备对象
     * @return true:更新成功  false:更新失败
     */
    @Override
    public synchronized boolean updateDevice(Device device) {
        String now = DateUtil.getNow();
        device.setUpdateTime(now);
        Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
        device.setCharset(device.getCharset().toUpperCase());
        if (deviceByDeviceId == null) {
            device.setCreateTime(now);
            redisCatchStorage.updateDevice(device);
            return deviceMapper.add(device) > 0;
        }else {
            redisCatchStorage.updateDevice(device);
            return deviceMapper.update(device) > 0;
        }
    }
    @Override
    public synchronized void updateChannel(String deviceId, DeviceChannel channel) {
        String channelId = channel.getChannelId();
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java
@@ -169,7 +169,7 @@
        Device device = storager.queryVideoDevice(deviceId);
        device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires));
        device.setMobilePositionSubmissionInterval(Integer.parseInt(interval));
        storager.updateDevice(device);
        deviceService.updateDevice(device);
        String result = msg;
        if (deviceService.removeMobilePositionSubscribe(device)) {
            result += ",成功";
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
@@ -288,7 +288,8 @@
    public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
        Device device = storager.queryVideoDevice(deviceId);
        device.setStreamMode(streamMode);
        storager.updateDevice(device);
//        storager.updateDevice(device);
        deviceService.updateDevice(device);
        return new ResponseEntity<>(null,HttpStatus.OK);
    }
@@ -305,51 +306,12 @@
    public ResponseEntity<WVPResult<String>> updateDevice(Device device){
        if (device != null && device.getDeviceId() != null) {
            Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
            if (!StringUtils.isEmpty(device.getName())) {
                deviceInStore.setName(device.getName());
            }
            if (!StringUtils.isEmpty(device.getCharset())) {
                deviceInStore.setCharset(device.getCharset());
            }
            if (!StringUtils.isEmpty(device.getMediaServerId())) {
                deviceInStore.setMediaServerId(device.getMediaServerId());
            }
            //  目录订阅相关的信息
            if (device.getSubscribeCycleForCatalog() > 0) {
                if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
                    deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
                    // 开启订阅
                    deviceService.addCatalogSubscribe(deviceInStore);
                }
            }else if (device.getSubscribeCycleForCatalog() == 0) {
                if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
                    deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
                    // 取消订阅
                    deviceService.removeCatalogSubscribe(deviceInStore);
                }
            }
            // 移动位置订阅相关的信息
            if (device.getSubscribeCycleForMobilePosition() > 0) {
                if (deviceInStore.getSubscribeCycleForMobilePosition() == 0 || deviceInStore.getSubscribeCycleForMobilePosition() != device.getSubscribeCycleForMobilePosition()) {
                    deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
                    deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
                    // 开启订阅
                    deviceService.addMobilePositionSubscribe(deviceInStore);
                }
            }else if (device.getSubscribeCycleForMobilePosition() == 0) {
                if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) {
                    // 取消订阅
                    deviceService.removeMobilePositionSubscribe(deviceInStore);
                }
            }
            // TODO 报警订阅相关的信息
            storager.updateDevice(device);
            cmder.deviceInfoQuery(device);
            deviceService.updateDevice(device);
//            cmder.deviceInfoQuery(device);
        }
        WVPResult<String> result = new WVPResult<>();
        result.setCode(0);