REM:
1. 修正areaCode判断不正确导致找不到设备问题
This commit is contained in:
HuangXin 2020-11-02 17:43:40 +08:00
parent c68a20d106
commit cc170e79b3
7 changed files with 38 additions and 32 deletions

View File

@ -50,17 +50,18 @@ public interface DisposeDeviceManager {
Integer pageSize); Integer pageSize);
/** /**
* Gets all dispose devices. * Gets all normal dispose devices.
* *
* @return the all dispose devices * @return the all normal dispose devices
*/ */
List<DisposeDevice> getAllNormalDisposeDevices(); List<DisposeDevice> 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 * @return the dispose devices
*/ */
List<DisposeDevice> getDisposeDevices(Integer areaCode); List<DisposeDevice> getDisposeDevices(Long devId, Integer areaCode);
} }

View File

@ -115,7 +115,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
fdDest.setAccessible(true); fdDest.setAccessible(true);
if (!obj.equals(fdDest.get(destDev))) { if (!obj.equals(fdDest.get(destDev))) {
log.debug("Upgrade field [{}] value form [{}] to [{}]", fdSrc.getName(), fdDest.get(destDev), log.debug("Upgrade field [{}] value form [{}] to [{}]", fdSrc.getName(), fdDest.get(destDev),
obj); obj);
fdDest.set(destDev, obj); fdDest.set(destDev, obj);
} }
fdDest.setAccessible(false); fdDest.setAccessible(false);
@ -143,11 +143,11 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
// HTTP 默认端口 // HTTP 默认端口
if (dev.getUrlType() == HttpType.HTTP) { if (dev.getUrlType() == HttpType.HTTP) {
tDev = disposeDeviceMapper.getDeviceByAddress(dev.getIpAddr(), tDev = disposeDeviceMapper.getDeviceByAddress(dev.getIpAddr(),
HttpType.getDefaultPort(HttpType.HTTP)); HttpType.getDefaultPort(HttpType.HTTP));
} else if (dev.getUrlType() == HttpType.HTTPS) { } else if (dev.getUrlType() == HttpType.HTTPS) {
// HTTPS 默认端口 // HTTPS 默认端口
tDev = disposeDeviceMapper.getDeviceByAddress(dev.getIpAddr(), 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 @Override
public List<DisposeDevice> getAllNormalDisposeDevices() { public List<DisposeDevice> getAllNormalDisposeDevices() {
@ -277,13 +277,14 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
/** /**
* Gets dispose devices by areaCode. * Gets dispose devices.
* *
* @param areaCode the areaCode * @param devId the dev id
* @return the dispose devices by areaCode. * @param areaCode the area code
* @return the dispose devices
*/ */
@Override @Override
public List<DisposeDevice> getDisposeDevices(Integer areaCode) { public List<DisposeDevice> getDisposeDevices(Long devId, Integer areaCode) {
return disposeDeviceMapper.getDeviceByAreaCode(areaCode); return disposeDeviceMapper.getDeviceByAreaCode(devId, areaCode);
} }
} }

View File

@ -101,6 +101,6 @@ public interface DisposeDeviceMapper {
* @param areaCode the areaCode * @param areaCode the areaCode
* @return the list * @return the list
*/ */
List<DisposeDevice> getDeviceByAreaCode(@Param("areaCode") Integer areaCode); List<DisposeDevice> getDeviceByAreaCode(@Param("id") Long id, @Param("areaCode") Integer areaCode);
} }

View File

@ -57,10 +57,11 @@ public interface DisposeDeviceManagerService {
List<DisposeDevice> getAllDisposeDevice(); List<DisposeDevice> getAllDisposeDevice();
/** /**
* Gets dispose device by areaCode. * Gets dispose device by area code.
* *
* @param areaCode the areaCode * @param devId the dev id
* @return the all dispose device * @param areaCode the area code
* @return the dispose device by area code
*/ */
List<DisposeDevice> getDisposeDeviceByAreaCode(Integer areaCode); List<DisposeDevice> getDisposeDeviceByAreaCode(Long devId, Integer areaCode);
} }

View File

@ -130,14 +130,15 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
} }
/** /**
* Gets dispose device by areaCode. * Gets dispose device by area code.
* *
* @param areaCode the areaCode * @param devId the dev id
* @return the all dispose device by areaCode * @param areaCode the area code
* @return the dispose device by area code
*/ */
@Override @Override
public List<DisposeDevice> getDisposeDeviceByAreaCode(Integer areaCode) { public List<DisposeDevice> getDisposeDeviceByAreaCode(Long devId, Integer areaCode) {
List<DisposeDevice> disposeDevices = disposeDeviceManager.getDisposeDevices(areaCode); List<DisposeDevice> disposeDevices = disposeDeviceManager.getDisposeDevices(devId, areaCode);
if (disposeDevices == null) { if (disposeDevices == null) {
return new ArrayList<>(); return new ArrayList<>();

View File

@ -14,7 +14,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* The type Dispose task service. * The type Dispose task service.
@ -65,12 +64,10 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
} }
//areaCode获取对应的deviceId //areaCode获取对应的deviceId
List<DisposeDevice> devices = disposeDeviceManagerService.getDisposeDeviceByAreaCode(task.getAreaCode()); List<DisposeDevice> devices = disposeDeviceManagerService.getDisposeDeviceByAreaCode(task.getDeviceId(),
task.getAreaCode());
// 获取请求id列表 if (devices.size() == 0) {
List<Long> deviceIds = devices.stream().map(DisposeDevice::getId).distinct().collect(Collectors.toList());
if (deviceIds.size() == 0 || !deviceIds.contains(task.getDeviceId())) {
return new MulReturnType<>(ErrorCode.ERR_NODEVICE_AREACODE, task); return new MulReturnType<>(ErrorCode.ERR_NODEVICE_AREACODE, task);
} else { } else {
return new MulReturnType<>(disposeTaskManager.addDisposeTask(task), return new MulReturnType<>(disposeTaskManager.addDisposeTask(task),

View File

@ -141,6 +141,11 @@
c.reserveNetflow reserveNetflow c.reserveNetflow reserveNetflow
FROM dispose_device d FROM dispose_device d
LEFT JOIN dispose_capacity c ON d.id = c.deviceId LEFT JOIN dispose_capacity c ON d.id = c.deviceId
WHERE d.areaCode = #{areaCode} <if test="areaCode != -1">
WHERE d.areaCode = #{areaCode}
<if test="id != -1">
AND d.id = #{id}
</if>
</if>
</select> </select>
</mapper> </mapper>