diff --git a/src/main/java/com/dispose/manager/DisposeDeviceManager.java b/src/main/java/com/dispose/manager/DisposeDeviceManager.java index dc6ff3b4..2dd64c04 100644 --- a/src/main/java/com/dispose/manager/DisposeDeviceManager.java +++ b/src/main/java/com/dispose/manager/DisposeDeviceManager.java @@ -50,17 +50,18 @@ public interface DisposeDeviceManager { Integer pageSize); /** - * Gets all dispose devices. + * Gets all normal dispose devices. * - * @return the all dispose devices + * @return the all normal dispose devices */ List getAllNormalDisposeDevices(); /** - * Gets all dispose devices. + * Gets dispose devices. * - * @param areaCode the areaCode + * @param devId the dev id + * @param areaCode the area code * @return the dispose devices */ - List getDisposeDevices(Integer areaCode); + List getDisposeDevices(Long devId, Integer areaCode); } diff --git a/src/main/java/com/dispose/manager/impl/DisposeDeviceManagerImpl.java b/src/main/java/com/dispose/manager/impl/DisposeDeviceManagerImpl.java index a2eb6dbc..3ec759b5 100644 --- a/src/main/java/com/dispose/manager/impl/DisposeDeviceManagerImpl.java +++ b/src/main/java/com/dispose/manager/impl/DisposeDeviceManagerImpl.java @@ -115,7 +115,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager { fdDest.setAccessible(true); if (!obj.equals(fdDest.get(destDev))) { log.debug("Upgrade field [{}] value form [{}] to [{}]", fdSrc.getName(), fdDest.get(destDev), - obj); + obj); fdDest.set(destDev, obj); } fdDest.setAccessible(false); @@ -143,11 +143,11 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager { // HTTP 默认端口 if (dev.getUrlType() == HttpType.HTTP) { tDev = disposeDeviceMapper.getDeviceByAddress(dev.getIpAddr(), - HttpType.getDefaultPort(HttpType.HTTP)); + HttpType.getDefaultPort(HttpType.HTTP)); } else if (dev.getUrlType() == HttpType.HTTPS) { // HTTPS 默认端口 tDev = disposeDeviceMapper.getDeviceByAddress(dev.getIpAddr(), - HttpType.getDefaultPort(HttpType.HTTPS)); + HttpType.getDefaultPort(HttpType.HTTPS)); } } } @@ -264,9 +264,9 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager { } /** - * Gets all dispose devices. + * Gets all normal dispose devices. * - * @return the all dispose devices + * @return the all normal dispose devices */ @Override public List getAllNormalDisposeDevices() { @@ -277,13 +277,14 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager { /** - * Gets dispose devices by areaCode. + * Gets dispose devices. * - * @param areaCode the areaCode - * @return the dispose devices by areaCode. + * @param devId the dev id + * @param areaCode the area code + * @return the dispose devices */ @Override - public List getDisposeDevices(Integer areaCode) { - return disposeDeviceMapper.getDeviceByAreaCode(areaCode); + public List getDisposeDevices(Long devId, Integer areaCode) { + return disposeDeviceMapper.getDeviceByAreaCode(devId, areaCode); } } diff --git a/src/main/java/com/dispose/mapper/DisposeDeviceMapper.java b/src/main/java/com/dispose/mapper/DisposeDeviceMapper.java index 95442c89..0766aa1b 100644 --- a/src/main/java/com/dispose/mapper/DisposeDeviceMapper.java +++ b/src/main/java/com/dispose/mapper/DisposeDeviceMapper.java @@ -101,6 +101,6 @@ public interface DisposeDeviceMapper { * @param areaCode the areaCode * @return the list */ - List getDeviceByAreaCode(@Param("areaCode") Integer areaCode); + List getDeviceByAreaCode(@Param("id") Long id, @Param("areaCode") Integer areaCode); } diff --git a/src/main/java/com/dispose/service/DisposeDeviceManagerService.java b/src/main/java/com/dispose/service/DisposeDeviceManagerService.java index 8a40e819..074a837c 100644 --- a/src/main/java/com/dispose/service/DisposeDeviceManagerService.java +++ b/src/main/java/com/dispose/service/DisposeDeviceManagerService.java @@ -57,10 +57,11 @@ public interface DisposeDeviceManagerService { List getAllDisposeDevice(); /** - * Gets dispose device by areaCode. + * Gets dispose device by area code. * - * @param areaCode the areaCode - * @return the all dispose device + * @param devId the dev id + * @param areaCode the area code + * @return the dispose device by area code */ - List getDisposeDeviceByAreaCode(Integer areaCode); + List getDisposeDeviceByAreaCode(Long devId, Integer areaCode); } diff --git a/src/main/java/com/dispose/service/impl/DisposeDeviceManagerServiceImpl.java b/src/main/java/com/dispose/service/impl/DisposeDeviceManagerServiceImpl.java index 92e94ffd..e92e62ad 100644 --- a/src/main/java/com/dispose/service/impl/DisposeDeviceManagerServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DisposeDeviceManagerServiceImpl.java @@ -130,14 +130,15 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ } /** - * Gets dispose device by areaCode. + * Gets dispose device by area code. * - * @param areaCode the areaCode - * @return the all dispose device by areaCode + * @param devId the dev id + * @param areaCode the area code + * @return the dispose device by area code */ @Override - public List getDisposeDeviceByAreaCode(Integer areaCode) { - List disposeDevices = disposeDeviceManager.getDisposeDevices(areaCode); + public List getDisposeDeviceByAreaCode(Long devId, Integer areaCode) { + List disposeDevices = disposeDeviceManager.getDisposeDevices(devId, areaCode); if (disposeDevices == null) { return new ArrayList<>(); diff --git a/src/main/java/com/dispose/service/impl/DisposeTaskServiceImpl.java b/src/main/java/com/dispose/service/impl/DisposeTaskServiceImpl.java index 23eadd56..15facbff 100644 --- a/src/main/java/com/dispose/service/impl/DisposeTaskServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DisposeTaskServiceImpl.java @@ -14,7 +14,6 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; -import java.util.stream.Collectors; /** * The type Dispose task service. @@ -65,12 +64,10 @@ public class DisposeTaskServiceImpl implements DisposeTaskService { } //areaCode获取对应的deviceId - List devices = disposeDeviceManagerService.getDisposeDeviceByAreaCode(task.getAreaCode()); + List devices = disposeDeviceManagerService.getDisposeDeviceByAreaCode(task.getDeviceId(), + task.getAreaCode()); - // 获取请求id列表 - List deviceIds = devices.stream().map(DisposeDevice::getId).distinct().collect(Collectors.toList()); - - if (deviceIds.size() == 0 || !deviceIds.contains(task.getDeviceId())) { + if (devices.size() == 0) { return new MulReturnType<>(ErrorCode.ERR_NODEVICE_AREACODE, task); } else { return new MulReturnType<>(disposeTaskManager.addDisposeTask(task), diff --git a/src/main/resources/mappers/DisposeDevice.xml b/src/main/resources/mappers/DisposeDevice.xml index eb48fdb8..de7b3b0f 100644 --- a/src/main/resources/mappers/DisposeDevice.xml +++ b/src/main/resources/mappers/DisposeDevice.xml @@ -141,6 +141,11 @@ c.reserveNetflow reserveNetflow FROM dispose_device d LEFT JOIN dispose_capacity c ON d.id = c.deviceId - WHERE d.areaCode = #{areaCode} + + WHERE d.areaCode = #{areaCode} + + AND d.id = #{id} + +