From 013fa6206753c2e75427a87f17be060a44182aa2 Mon Sep 17 00:00:00 2001 From: pnoker Date: Wed, 2 Jun 2021 11:14:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=20NotifyServiceImpl=20?= =?UTF-8?q?=E6=A8=A1=E7=89=88=E5=92=8C=E4=BD=8D=E5=8F=B7=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E9=80=9A=E7=9F=A5=E5=88=B0=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E5=85=B3=E8=81=94=E7=9A=84=E9=A9=B1=E5=8A=A8=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/NotifyServiceImpl.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/dc3-center/dc3-manager/src/main/java/com/dc3/center/manager/service/impl/NotifyServiceImpl.java b/dc3-center/dc3-manager/src/main/java/com/dc3/center/manager/service/impl/NotifyServiceImpl.java index 2c049150d..863536685 100644 --- a/dc3-center/dc3-manager/src/main/java/com/dc3/center/manager/service/impl/NotifyServiceImpl.java +++ b/dc3-center/dc3-manager/src/main/java/com/dc3/center/manager/service/impl/NotifyServiceImpl.java @@ -23,6 +23,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.List; /** * NotifyService Impl @@ -40,16 +41,18 @@ public class NotifyServiceImpl implements NotifyService { @Override public void notifyDriverProfile(String command, Profile profile) { - Driver driver = driverService.selectByProfileId(profile.getId()); - if (null != driver) { - DriverConfiguration operation = new DriverConfiguration().setType(Common.Driver.Type.PROFILE).setCommand(command).setContent(profile); - notifyDriver(driver, operation); + List drivers = driverService.selectByProfileId(profile.getId()); + if (null != drivers) { + drivers.forEach(driver -> { + DriverConfiguration operation = new DriverConfiguration().setType(Common.Driver.Type.PROFILE).setCommand(command).setContent(profile); + notifyDriver(driver, operation); + }); } } @Override public void notifyDriverDevice(String command, Device device) { - Driver driver = driverService.selectByProfileId(device.getProfileId()); + Driver driver = driverService.selectById(device.getDriverId()); if (null != driver) { DriverConfiguration operation = new DriverConfiguration().setType(Common.Driver.Type.DEVICE).setCommand(command).setContent(device); notifyDriver(driver, operation); @@ -58,17 +61,19 @@ public class NotifyServiceImpl implements NotifyService { @Override public void notifyDriverPoint(String command, Point point) { - Driver driver = driverService.selectByProfileId(point.getProfileId()); - if (null != driver) { - DriverConfiguration operation = new DriverConfiguration().setType(Common.Driver.Type.POINT).setCommand(command).setContent(point); - notifyDriver(driver, operation); + List drivers = driverService.selectByProfileId(point.getProfileId()); + if (null != drivers) { + drivers.forEach(driver -> { + DriverConfiguration operation = new DriverConfiguration().setType(Common.Driver.Type.POINT).setCommand(command).setContent(point); + notifyDriver(driver, operation); + }); } } @Override public void notifyDriverDriverInfo(String command, DriverInfo driverInfo) { - Driver driver = driverService.selectByProfileId(driverInfo.getProfileId()); + Driver driver = driverService.selectByDeviceId(driverInfo.getDeviceId()); if (null != driver) { DriverConfiguration operation = new DriverConfiguration().setType(Common.Driver.Type.DRIVER_INFO).setCommand(command).setContent(driverInfo); notifyDriver(driver, operation); @@ -87,7 +92,7 @@ public class NotifyServiceImpl implements NotifyService { /** * notify driver * - * @param driver Driver + * @param driver Driver * @param driverConfiguration DriverConfiguration */ private void notifyDriver(Driver driver, DriverConfiguration driverConfiguration) {