diff --git a/zc-business/src/main/java/com/zc/business/controller/VideoController.java b/zc-business/src/main/java/com/zc/business/controller/VideoController.java index 99a2af28..d4544c30 100644 --- a/zc-business/src/main/java/com/zc/business/controller/VideoController.java +++ b/zc-business/src/main/java/com/zc/business/controller/VideoController.java @@ -9,6 +9,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.redis.RedisCache; import com.zc.business.domain.DcDevice; import com.zc.business.service.IDcDeviceService; +import com.zc.business.service.IMiddleDatabaseService; import com.zc.common.core.httpclient.OkHttp; import com.zc.common.core.httpclient.exception.HttpException; import com.zc.common.core.httpclient.request.RequestParams; @@ -59,6 +60,9 @@ public class VideoController extends BaseController { @Resource private IDcDeviceService iDcDeviceService; + @Resource + private IMiddleDatabaseService middleDatabaseService; + /** * 查询附近相机 */ @@ -137,6 +141,10 @@ public class VideoController extends BaseController { } iDcDeviceService.batchUpdate(list); + + //更新中间库的设备状态 + middleDatabaseService.updateMiddleDatabaseDeviceByList(list); + logger.debug("执行:同步数据平台视频设备的设备状态成功!!"); } @@ -153,6 +161,10 @@ public class VideoController extends BaseController { dcDevices.add(dcDevice); } iDcDeviceService.batchUpdate(dcDevices); + + //更新中间库的设备状态 + middleDatabaseService.updateMiddleDatabaseDeviceByList(dcDevices); + logger.debug("执行:同步物联平台设备的设备状态成功!!"); } @@ -168,6 +180,9 @@ public class VideoController extends BaseController { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(DcDevice::getIotDeviceId, dcDevice.getIotDeviceId()); iDcDeviceService.update(dcDevice, queryWrapper); + + //更新中间库的设备状态 + middleDatabaseService.updateMiddleDatabaseDevice(dcDevice); } logger.debug("执行:同步广播设备的设备状态成功!!"); diff --git a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java index 9ab3e5c4..b5d775b0 100644 --- a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java +++ b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java @@ -71,7 +71,7 @@ public class DeviceMessageHandler { dcDeviceService.batchUpdate(dcDevices); // 批量更新中间库设备状态 - middleDatabaseService.updateMiddleDatabaseDevice(dcDevices); + middleDatabaseService.updateMiddleDatabaseDeviceByList(dcDevices); } /** diff --git a/zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java b/zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java index 8da12edf..926a56e0 100644 --- a/zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java +++ b/zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java @@ -25,11 +25,19 @@ public interface IMiddleDatabaseService boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData); /** - * 更新中间库设备 + * 批量更新中间库设备 * * @param listDevice 设备列表 * @return 结果 */ - boolean updateMiddleDatabaseDevice(List listDevice); + boolean updateMiddleDatabaseDeviceByList(List listDevice); + + /** + * 更新中间库设备 + * + * @param device 设备 + * @return 结果 + */ + boolean updateMiddleDatabaseDevice(DcDevice device); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java index 616c2c63..0e47d6f5 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java @@ -40,18 +40,32 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService { /** - * 更新中间库设备 + * 批量更新中间库设备 * * @param listDevice 设备列表 * @return 结果 */ @DataSource(value = DataSourceType.SLAVE)//切换数据源 @Override - public boolean updateMiddleDatabaseDevice(List listDevice) + public boolean updateMiddleDatabaseDeviceByList(List listDevice) { for (DcDevice dcDevice : listDevice) { middleDatabaseMapper.updateMiddleDatabaseDevice(dcDevice); } return true; } + + + /** + * 更新中间库设备 + * + * @param device 设备 + * @return 结果 + */ + @DataSource(value = DataSourceType.SLAVE)//切换数据源 + @Override + public boolean updateMiddleDatabaseDevice(DcDevice device) + { + return middleDatabaseMapper.updateMiddleDatabaseDevice(device); + } }