Commit 76f759b4 by 朱淼

fix bug

parent b1c74864
......@@ -97,7 +97,7 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
PlatSpaceDeviceQueryDTO dto = pageReqDTO.getData();
LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.select(PlatRoomBedDevice::getDeviceId);
// queryWrapper1.select(PlatRoomBedDevice::getDeviceId);
List<PlatRoomBedDevice> list = list(queryWrapper1);
List<PlatRoomBedDevice> list1 = new ArrayList<>();
......
......@@ -107,12 +107,16 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
space.setAddress(dto.getAddress());
space.setLatitude(dto.getLatitude());
space.setLongitude(dto.getLongitude());
space.setParentId(dto.getParentId());
if(StringUtil.isEmpty(dto.getParentPath())){
space.setParentPath(null);
}else {
space.setParentPath(dto.getParentPath());
}
if(StringUtil.isEmpty(dto.getParentId())){
space.setParentId(null);
}else {
space.setParentId(dto.getParentId());
}
//上级空间
PlatSpace parentSpace = this.getById(dto.getParentId());
......@@ -374,12 +378,15 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
try {
List<PlatSpace> listPlatSpace = list(new LambdaQueryWrapper<>());
List<PlatSpace> firstSpace = listPlatSpace.stream().filter(item -> item.getParentId() == null).collect(Collectors.toList());
List<PlatSpace> firstSpace = listPlatSpace.stream().filter(item -> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
Map<String, String> firstSpaceNameMap = firstSpace.stream().collect(Collectors.toMap(PlatSpace::getName, PlatSpace::getId, (k1, k2) -> k1));
List<PlatSpace> listChildren = listPlatSpace.stream().filter(item -> item.getParentId() != null).collect(Collectors.toList());
List<PlatSpace> listChildren = listPlatSpace.stream().filter(item -> StringUtil.isNotEmpty(item.getParentId())).collect(Collectors.toList());
Map<String, List<PlatSpace>> childrenMap = listChildren.stream().collect(Collectors.groupingBy(PlatSpace::getParentId));
Map<String, String> childrenIdMap = listChildren.stream().collect(Collectors.toMap(item -> item.getParentId() + item.getName(), item -> item.getId(), (k1, k2) -> k1));
Map<String, String> childrenIdMap = listChildren.stream().collect(Collectors.toMap(item -> item.getParentId() + "-"+item.getName(), item -> item.getId(), (k1, k2) -> k1));
List<PlatRoom> rooms = platRoomService.list();
Map<String,List<PlatRoom>> roomMap = rooms.stream().collect(Collectors.groupingBy(PlatRoom::getSpaceId));
List<PlatSpaceImportDTO> list = ExcelUtil.importExcel(null, 3, excelFile, PlatSpaceImportDTO.class);
......@@ -430,10 +437,11 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
key = key + "-" + item.getFloor();
}
if (listKey.contains(key)) {
if (listKey.contains(key+"-"+item.getRoomName())) {
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(0), "该空间下,房间名已存在"));
errorFlag = true;
}
listKey.add(key+"-"+item.getRoomName());
if (errorFlag) {
errorCount++;
......@@ -534,20 +542,49 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
platRoomDTO.setName(item.getRoomName());
platRoomDTO.setBedNumber(item.getBedNumber());
String spaceId = null;
if (firstId != null) {
spaceId = firstId;
} else if (secondId != null) {
spaceId = secondId;
} else if (threeId != null) {
spaceId = threeId;
} else if (fourId != null) {
int j = 0;
if (fourId != null){
spaceId = fourId;
j = 3;
} else if (threeId !=null){
spaceId = threeId;
j = 2;
} else if (secondId !=null){
spaceId = secondId;
j = 1;
} else if (firstId !=null){
spaceId = firstId;
}
//判断该层级是否最后一级
List<PlatSpace> childSpaes = list(new QueryWrapper<PlatSpace>().lambda()
.eq(PlatSpace::getParentId, spaceId));
if(!childSpaes.isEmpty()){
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(j), "该空间存在下级空间,不允许添加房间"));
successCount--;
errorCount++;
continue;
}
platRoomDTO.setSpaceId(spaceId);
platRoomDTO.setSpacePath(spacePath);
platRoomService.add(platRoomDTO);
PlatRoom platRoom = BeanDtoVoUtils.convert(platRoomDTO, PlatRoom.class);
if(roomMap.get(spaceId)!=null ){
List<PlatRoom> roomList = roomMap.get(spaceId);
List<String> roomNames = roomList.stream().map(PlatRoom::getName).collect(Collectors.toList());
if(roomNames.contains(platRoom.getName())){
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(0), "该空间下,房间名已存在"));
successCount--;
errorCount++;
continue;
}
}
platRoomService.save(platRoom);
platBedService.add(platRoom);
}
}
if(!errorVoList.isEmpty()){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
excelImportVo.setTotalCount(list.size());
excelImportVo.setErrorCount(errorCount);
excelImportVo.setSuccessCount(successCount);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment