REM:
1. 解决空指针异常错误
This commit is contained in:
chenlinghy 2021-04-25 11:04:39 +08:00
parent d3271ef065
commit 1dd48cd195
2 changed files with 42 additions and 34 deletions

View File

@ -4,6 +4,7 @@ import com.dispose.common.DisposeCapacityType;
import com.dispose.common.ObjectStatus; import com.dispose.common.ObjectStatus;
import com.dispose.pojo.entity.DisposeCapacity; import com.dispose.pojo.entity.DisposeCapacity;
import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.pojo.po.AbilityInfo;
import com.dispose.service.AreaCodeManagerService; import com.dispose.service.AreaCodeManagerService;
import com.dispose.service.DisposeAbilityRouterService; import com.dispose.service.DisposeAbilityRouterService;
import com.dispose.service.DisposeDeviceManagerService; import com.dispose.service.DisposeDeviceManagerService;
@ -11,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@ -76,13 +78,20 @@ public class AreaCodeManagerServiceImpl implements AreaCodeManagerService {
*/ */
@Override @Override
public int getAreaCodeOnlineDeviceNum(Integer areaCode) { public int getAreaCodeOnlineDeviceNum(Integer areaCode) {
List<AbilityInfo> devs = new ArrayList<>();
List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice(); List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice();
return (int) disposeDevices.stream()
List<DisposeDevice> disDevs = disposeDevices.stream()
.filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL) .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL)
.filter(k -> disposeAbilityRouterService.getAbilityDevice(k.getId()) .collect(Collectors.toList());
.getDb()
.getDeviceLinkStatus()) disDevs.forEach(v -> {
.count(); if (disposeAbilityRouterService.getAbilityDevice(v.getId()) != null) {
devs.add(disposeAbilityRouterService.getAbilityDevice(v.getId()));
}
});
return (int) devs.stream().filter(v -> v.getDb().getDeviceLinkStatus()).count();
} }
/** /**

View File

@ -107,7 +107,7 @@ public class JsonTestCaseRun extends CommonRestfulJson implements TestCaseRun {
.filter(k -> k.getCaseJsonValue() != null && k.getCaseJsonValue().length() > 0) .filter(k -> k.getCaseJsonValue() != null && k.getCaseJsonValue().length() > 0)
.filter(k -> usedId.size() == 0 || usedId.stream().anyMatch(v -> Objects.equals(v, k.getId()))) .filter(k -> usedId.size() == 0 || usedId.stream().anyMatch(v -> Objects.equals(v, k.getId())))
.filter(k -> Arrays.stream(CommonEnvironment.commonPriorityFilter).anyMatch(v -> k.getPriority() == v)) .filter(k -> Arrays.stream(CommonEnvironment.commonPriorityFilter).anyMatch(v -> k.getPriority() == v))
//.filter(k -> k.getId() >= 1300) //.filter(k -> k.getId() == 700)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@ -130,8 +130,7 @@ public class JsonTestCaseRun extends CommonRestfulJson implements TestCaseRun {
rspObject.getUrlPath(), rspObject.getUrlPath(),
rspObject.getRspClass(), rspObject.getRspClass(),
rspObject.getRspCode(), rspObject.getRspCode(),
rspObject.getAutoLogin() ? getLoginToken() : rspObject.getAutoLogin() ? getLoginToken() : "",
"",
true, true,
rspObject.getMethod()); rspObject.getMethod());