REM:
1. 修正添加设备时,设备已经存在的问题
2. 修正单元测试不通过问题
This commit is contained in:
HuangXin 2021-02-03 14:22:57 +08:00
parent 1aef6bf19e
commit c34b9ecb3d
2 changed files with 14 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package com.dispose.manager.impl;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.common.Helper; import com.dispose.common.Helper;
import com.dispose.common.HttpType;
import com.dispose.common.IpAddrType; import com.dispose.common.IpAddrType;
import com.dispose.common.ObjectStatus; import com.dispose.common.ObjectStatus;
import com.dispose.manager.DisposeDeviceManager; import com.dispose.manager.DisposeDeviceManager;
@ -55,6 +56,16 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
*/ */
@Override @Override
public MulReturnType<ErrorCode, Long> addDisposeDevice(DisposeDevice dev) { public MulReturnType<ErrorCode, Long> addDisposeDevice(DisposeDevice dev) {
List<DisposeDevice> tmpDev = disposeDeviceMapper.getDeviceByIpAndType(dev.getIpAddr(),
dev.getDeviceType().getValue());
for (DisposeDevice v : tmpDev) {
if (dev.getIpPort().equals(HttpType.getDefaultPort(v.getUrlType())) || dev.getIpPort()
.equals(v.getIpPort())) {
return new MulReturnType<>(ErrorCode.ERR_DEVICEEXISTS, v.getId());
}
}
// 看看系统中有没有存在相同IP+端口地址的设备有的话返回失败 // 看看系统中有没有存在相同IP+端口地址的设备有的话返回失败
DisposeDevice tDev = disposeDeviceMapper.getDeviceByAddrAndType(dev.getIpAddr(), dev.getIpPort(), DisposeDevice tDev = disposeDeviceMapper.getDeviceByAddrAndType(dev.getIpAddr(), dev.getIpPort(),
dev.getDeviceType().getValue()); dev.getDeviceType().getValue());

View File

@ -797,7 +797,8 @@ public class P2DeviceAdd {
Assert.assertNotNull(k.getDevId()); Assert.assertNotNull(k.getDevId());
}); });
DisposeDevice dev = c.getDisposeDeviceMapper().getDeviceByAddrAndType("10.88.77.15", "", DisposeDeviceType.DPTECH_UMC DisposeDevice dev = c.getDisposeDeviceMapper().getDeviceByAddrAndType("10.88.77.15", "80",
DisposeDeviceType.DPTECH_UMC
.getValue()); .getValue());
Assert.assertNotNull(dev); Assert.assertNotNull(dev);