Commit eda1c5ab by 杨伟程

几个天从path的地方

parent 8ee6f7cb
package com.makeit.utils.data.convert; package com.makeit.utils.data.convert;
import com.makeit.enums.id.TreeConst; import com.makeit.enums.id.TreeConst;
import com.makeit.utils.old.StringUtils;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
...@@ -85,4 +84,21 @@ public class TreeUtil { ...@@ -85,4 +84,21 @@ public class TreeUtil {
} }
} }
public static String path(String path, List<String> idList) {
// if(StringUtils.isBlank(path)){
// return path;
// }
LinkedHashSet<String> list = new LinkedHashSet<>();
if (StringUtils.isNotBlank(path)) {
list = new LinkedHashSet<>(Arrays.asList(path.split(",")));
}
list.addAll(idList);
return StreamUtil.join(new ArrayList<>(list), Function.identity());
}
} }
...@@ -33,7 +33,6 @@ public class PlatUserVO implements Serializable { ...@@ -33,7 +33,6 @@ public class PlatUserVO implements Serializable {
private String orgPath; private String orgPath;
public PlatUserVO() { public PlatUserVO() {
} }
...@@ -49,27 +48,25 @@ public class PlatUserVO implements Serializable { ...@@ -49,27 +48,25 @@ public class PlatUserVO implements Serializable {
} }
private boolean initFlag = false; private boolean initFlag = false;
public void init(){ public void init() {
if(initFlag){ if (initFlag) {
return; return;
} }
if(StringUtils.isBlank(orgPath)){ if (StringUtils.isBlank(orgPath)) {
return; return;
} }
List<BiConsumer<PlatUserVO,String>> list = Arrays.asList( List<BiConsumer<PlatUserVO, String>> list = Arrays.asList(
PlatUserVO::setCityOrgId, PlatUserVO::setCityOrgId,
PlatUserVO::setDistrictOrgId, PlatUserVO::setDistrictOrgId,
PlatUserVO::setStreetOrgId PlatUserVO::setStreetOrgId
); );
String[] split = orgPath.split(","); String[] split = orgPath.split(",");
for (int i = 1; i < split.length; i++) { for (int i = 1; i < split.length; i++) {
BiConsumer<PlatUserVO, String> e = list.get(i-1); BiConsumer<PlatUserVO, String> e = list.get(i - 1);
e.accept(this,split[i]); e.accept(this, split[i]);
} }
this.initFlag = true; this.initFlag = true;
} }
......
package com.makeit.dto.platform.space;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PlatSpaceSplitDTO {
@ApiModelProperty(value = "空间id")
private String spaceId;
@ApiModelProperty(value = "小区/社区/街道空间id")
private String streetSpaceId;
@ApiModelProperty(value = "楼栋空间id")
private String buildingSpaceId;
@ApiModelProperty(value = "单元空间id")
private String unitSpaceId;
@ApiModelProperty(value = "楼层id")
private String floorSpaceId;
@ApiModelProperty(value = "房间id")
private String roomId;
@ApiModelProperty(value = "床位id")
private String bedId;
@ApiModelProperty(value = "空间-房间-床位路径")
private String spacePath;
}
...@@ -14,6 +14,7 @@ import com.makeit.dto.platform.elder.PlatElderCheckOutDTO; ...@@ -14,6 +14,7 @@ import com.makeit.dto.platform.elder.PlatElderCheckOutDTO;
import com.makeit.dto.platform.elder.PlatElderImportDTO; import com.makeit.dto.platform.elder.PlatElderImportDTO;
import com.makeit.dto.platform.elder.PlatElderQueryDTO; import com.makeit.dto.platform.elder.PlatElderQueryDTO;
import com.makeit.dto.platform.elder.add.*; import com.makeit.dto.platform.elder.add.*;
import com.makeit.dto.platform.space.PlatSpaceSplitDTO;
import com.makeit.dto.platform.space.TreeDTOVO; import com.makeit.dto.platform.space.TreeDTOVO;
import com.makeit.entity.platform.auth.PlatOrg; import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
...@@ -29,7 +30,6 @@ import com.makeit.enums.CommonEnum; ...@@ -29,7 +30,6 @@ import com.makeit.enums.CommonEnum;
import com.makeit.enums.FileSuffixEnum; import com.makeit.enums.FileSuffixEnum;
import com.makeit.enums.id.TreeConst; import com.makeit.enums.id.TreeConst;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.mapper.platform.elder.PlatElderMapper; import com.makeit.mapper.platform.elder.PlatElderMapper;
import com.makeit.service.platform.auth.PlatOrgService; import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.elder.*; import com.makeit.service.platform.elder.*;
...@@ -457,6 +457,20 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -457,6 +457,20 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
if (errorVoList.isEmpty()) { if (errorVoList.isEmpty()) {
List<PlatElder> platElderList = BeanDtoVoUtils.listVo(list, PlatElder.class); List<PlatElder> platElderList = BeanDtoVoUtils.listVo(list, PlatElder.class);
platElderList.forEach(e -> {
List<String> spaceIdList = new ArrayList<>(Arrays.asList(e.getStreetSpaceId(), e.getBuildingSpaceId(), e.getUnitSpaceId(), e.getFloorSpaceId()));
List<String> newSpaceIdList = new ArrayList<>(spaceIdList);
Collections.reverse(newSpaceIdList);
e.setSpaceId(newSpaceIdList.stream().filter(StringUtils::isNotBlank).findFirst().orElse(null));
spaceIdList.add(e.getRoomId());
spaceIdList.add(e.getBedId());
e.setSpacePath(spaceIdList.stream().filter(StringUtils::isNotBlank).collect(Collectors.joining(",")));
});
PlatUserVO platUserVO = PlatUserUtil.getUserVO(); PlatUserVO platUserVO = PlatUserUtil.getUserVO();
platElderList.forEach(e -> { platElderList.forEach(e -> {
...@@ -492,6 +506,25 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -492,6 +506,25 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
} }
private void fillSpace(PlatElder platElder) {
if (StringUtils.isBlank(platElder.getBedId())) {
return;
}
PlatSpaceSplitDTO platSpaceSplitDTO = platSpaceService.getSpaceSplitVO(platElder.getBedId());
platElder.setSpaceId(platSpaceSplitDTO.getSpaceId());
platElder.setStreetSpaceId(platSpaceSplitDTO.getStreetSpaceId());
platElder.setBuildingSpaceId(platSpaceSplitDTO.getBuildingSpaceId());
platElder.setUnitSpaceId(platSpaceSplitDTO.getUnitSpaceId());
platElder.setFloorSpaceId(platSpaceSplitDTO.getFloorSpaceId());
platElder.setRoomId(platSpaceSplitDTO.getRoomId());
//platElder.setBedId();
platElder.setSpacePath(platSpaceSplitDTO.getSpacePath());
}
@Override @Override
@Transactional @Transactional
public void add(PlatElderAddDTO dto) { public void add(PlatElderAddDTO dto) {
...@@ -500,6 +533,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -500,6 +533,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class); PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class);
fillSpace(platElder);
PlatUserVO userVO = PlatUserUtil.getUserVO(); PlatUserVO userVO = PlatUserUtil.getUserVO();
platElder.setOrgId(userVO.getOrgId()); platElder.setOrgId(userVO.getOrgId());
...@@ -523,6 +558,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -523,6 +558,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class); PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class);
fillSpace(platElder);
PlatUserVO userVO = PlatUserUtil.getUserVO(); PlatUserVO userVO = PlatUserUtil.getUserVO();
platElder.setOrgId(userVO.getOrgId()); platElder.setOrgId(userVO.getOrgId());
...@@ -602,6 +639,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -602,6 +639,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class); PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class);
fillSpace(platElder);
updateById(platElder); updateById(platElder);
addOrEditExt(dto); addOrEditExt(dto);
......
...@@ -5,6 +5,7 @@ import com.makeit.common.dto.BaseIdDTO; ...@@ -5,6 +5,7 @@ import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.vo.ExcelImportVo; import com.makeit.common.vo.ExcelImportVo;
import com.makeit.dto.platform.space.PlatSpaceAddDTO; import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO; import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.dto.platform.space.PlatSpaceSplitDTO;
import com.makeit.dto.platform.space.PlatSpaceVO; import com.makeit.dto.platform.space.PlatSpaceVO;
import com.makeit.entity.platform.space.PlatSpace; import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO; import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
...@@ -61,6 +62,8 @@ public interface PlatSpaceService extends IService<PlatSpace> { ...@@ -61,6 +62,8 @@ public interface PlatSpaceService extends IService<PlatSpace> {
*/ */
List<PlatSpaceVO> treeByBed(PlatSpaceQueryDTO dto); List<PlatSpaceVO> treeByBed(PlatSpaceQueryDTO dto);
PlatSpaceSplitDTO getSpaceSplitVO(String bedId);
List<PlatSpace> listChild(List<String> spaceIds); List<PlatSpace> listChild(List<String> spaceIds);
List<PlatSpaceAddDTO> oneLevelList(BaseIdDTO dto); List<PlatSpaceAddDTO> oneLevelList(BaseIdDTO dto);
......
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.dto.BaseIdDTO; import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.vo.ExcelErrorVo; import com.makeit.common.vo.ExcelErrorVo;
import com.makeit.common.vo.ExcelImportVo; import com.makeit.common.vo.ExcelImportVo;
import com.makeit.dto.platform.auth.PlatOrgSplitDTO;
import com.makeit.dto.platform.space.*; import com.makeit.dto.platform.space.*;
import com.makeit.entity.platform.auth.PlatOrg; import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.space.PlatBed; import com.makeit.entity.platform.space.PlatBed;
...@@ -21,7 +22,9 @@ import com.makeit.service.platform.space.PlatBedService; ...@@ -21,7 +22,9 @@ import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomService; import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.platform.space.PlatSpaceService; import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.TreeUtil;
import com.makeit.utils.data.excel.ExcelUtil; import com.makeit.utils.data.excel.ExcelUtil;
import com.makeit.utils.old.StringUtils;
import com.makeit.utils.user.TokenUtil; import com.makeit.utils.user.TokenUtil;
import com.makeit.utils.user.plat.PlatUserUtil; import com.makeit.utils.user.plat.PlatUserUtil;
import com.makeit.utils.user.plat.PlatUserVO; import com.makeit.utils.user.plat.PlatUserVO;
...@@ -32,10 +35,8 @@ import org.springframework.stereotype.Service; ...@@ -32,10 +35,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays; import java.util.function.BiConsumer;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -53,18 +54,18 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -53,18 +54,18 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
@Autowired @Autowired
private PlatOrgService platOrgService; private PlatOrgService platOrgService;
private void check(PlatSpaceAddDTO dto){ private void check(PlatSpaceAddDTO dto) {
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatSpace::getName,dto.getName()); queryWrapper.eq(PlatSpace::getName, dto.getName());
queryWrapper.ne(StringUtil.isNotEmpty(dto.getId()), PlatSpace::getId,dto.getId()); queryWrapper.ne(StringUtil.isNotEmpty(dto.getId()), PlatSpace::getId, dto.getId());
if(StringUtil.isEmpty(dto.getParentId())){ if (StringUtil.isEmpty(dto.getParentId())) {
queryWrapper.isNull(PlatSpace::getParentId); queryWrapper.isNull(PlatSpace::getParentId);
}else{ } else {
queryWrapper.eq(PlatSpace::getParentId,dto.getParentId()); queryWrapper.eq(PlatSpace::getParentId, dto.getParentId());
} }
if(this.count(queryWrapper) > 0){ if (this.count(queryWrapper) > 0) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NAME_DUPLICATE); throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NAME_DUPLICATE);
} }
} }
...@@ -75,17 +76,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -75,17 +76,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
public void add(PlatSpaceAddDTO dto) { public void add(PlatSpaceAddDTO dto) {
check(dto); check(dto);
PlatSpace space = BeanDtoVoUtils.convert(dto, PlatSpace.class); PlatSpace space = BeanDtoVoUtils.convert(dto, PlatSpace.class);
if(StringUtil.isEmpty(dto.getParentId())){ if (StringUtil.isEmpty(dto.getParentId())) {
PlatUserVO userVO = PlatUserUtil.getUserVOCanNull(); PlatUserVO userVO = PlatUserUtil.getUserVOCanNull();
if(StringUtil.isEmpty(userVO.getOrgId())){ if (StringUtil.isEmpty(userVO.getOrgId())) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_USER_NOT_ADD); throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_USER_NOT_ADD);
} }
space.setOrgId(userVO.getOrgId()); space.setOrgId(userVO.getOrgId());
PlatOrg org = platOrgService.getById(space.getOrgId()); PlatOrg org = platOrgService.getById(space.getOrgId());
if(org!=null){ if (org != null) {
space.setAttribute(org.getType()); space.setAttribute(org.getType());
} }
}else { } else {
//上级空间 //上级空间
PlatSpace parentSpace = getById(dto.getParentId()); PlatSpace parentSpace = getById(dto.getParentId());
space.setOrgId(parentSpace.getOrgId()); space.setOrgId(parentSpace.getOrgId());
...@@ -111,7 +112,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -111,7 +112,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
//上级空间 //上级空间
PlatSpace parentSpace = this.getById(dto.getParentId()); PlatSpace parentSpace = this.getById(dto.getParentId());
if(parentSpace.getParentPath().contains(dto.getId())){ if (parentSpace.getParentPath().contains(dto.getId())) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL); throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL);
} }
...@@ -123,14 +124,14 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -123,14 +124,14 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
public void del(String id) { public void del(String id) {
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatSpace::getParentId,id); queryWrapper.eq(PlatSpace::getParentId, id);
if(count(queryWrapper) > 0){ if (count(queryWrapper) > 0) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL); throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL);
} }
LambdaQueryWrapper<PlatRoom> queryWrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatRoom> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(PlatRoom::getSpaceId,id); queryWrapper1.eq(PlatRoom::getSpaceId, id);
if(platRoomService.count(queryWrapper1) > 0){ if (platRoomService.count(queryWrapper1) > 0) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL); throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL);
} }
...@@ -141,26 +142,26 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -141,26 +142,26 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
public List<PlatSpaceVO> tree(PlatSpaceQueryDTO dto) { public List<PlatSpaceVO> tree(PlatSpaceQueryDTO dto) {
//查询用户权限组织id //查询用户权限组织id
List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg()); List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg());
if(orgs.isEmpty()){ if (orgs.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList()); List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()),PlatSpace::getName,dto.getName()); queryWrapper.like(StringUtil.isNotEmpty(dto.getName()), PlatSpace::getName, dto.getName());
queryWrapper.in(PlatSpace::getOrgId, orgIds); queryWrapper.in(PlatSpace::getOrgId, orgIds);
List<PlatSpace> list = this.list(queryWrapper); List<PlatSpace> list = this.list(queryWrapper);
//父级 //父级
List<PlatSpace> listParent = list.stream().filter(item->StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList()); List<PlatSpace> listParent = list.stream().filter(item -> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
//子集 //子集
List<PlatSpace> listChild = list.stream().filter(item->item.getParentId() != null).collect(Collectors.toList()); List<PlatSpace> listChild = list.stream().filter(item -> item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpace>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpace::getParentId)); Map<String, List<PlatSpace>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpace::getParentId));
List<PlatSpaceVO> data = new ArrayList<>(); List<PlatSpaceVO> data = new ArrayList<>();
for(PlatSpace space:listParent){ for (PlatSpace space : listParent) {
PlatSpaceVO vo = convertToVO(space); PlatSpaceVO vo = convertToVO(space);
vo = child(vo,map); vo = child(vo, map);
data.add(vo); data.add(vo);
} }
return data; return data;
...@@ -169,7 +170,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -169,7 +170,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
@Override @Override
public PlatSpaceAddDTO view(String id) { public PlatSpaceAddDTO view(String id) {
PlatSpace space = getById(id); PlatSpace space = getById(id);
PlatSpaceAddDTO data = BeanDtoVoUtils.convert(space,PlatSpaceAddDTO.class); PlatSpaceAddDTO data = BeanDtoVoUtils.convert(space, PlatSpaceAddDTO.class);
return data; return data;
} }
...@@ -190,10 +191,10 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -190,10 +191,10 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
LambdaQueryWrapper<PlatBed> queryWrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatBed> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(PlatBed::getStatus, CommonEnum.YES.getValue()); queryWrapper1.eq(PlatBed::getStatus, CommonEnum.YES.getValue());
List<PlatBed> listBeds = platBedService.list(queryWrapper1); List<PlatBed> listBeds = platBedService.list(queryWrapper1);
Map<String,List<PlatBed>> mapBed = listBeds.stream().collect(Collectors.groupingBy(PlatBed::getRoomId)); Map<String, List<PlatBed>> mapBed = listBeds.stream().collect(Collectors.groupingBy(PlatBed::getRoomId));
List<PlatSpaceVO> listRoomVo = new ArrayList<>(); List<PlatSpaceVO> listRoomVo = new ArrayList<>();
listRoom.forEach(item->{ listRoom.forEach(item -> {
PlatSpaceVO vo = new PlatSpaceVO(); PlatSpaceVO vo = new PlatSpaceVO();
vo.setId(item.getId()); vo.setId(item.getId());
vo.setName(item.getName()); vo.setName(item.getName());
...@@ -201,7 +202,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -201,7 +202,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
listRoomVo.add(vo); listRoomVo.add(vo);
}); });
listBeds.forEach(item->{ listBeds.forEach(item -> {
PlatSpaceVO vo = new PlatSpaceVO(); PlatSpaceVO vo = new PlatSpaceVO();
vo.setId(item.getId()); vo.setId(item.getId());
vo.setName(item.getName()); vo.setName(item.getName());
...@@ -210,25 +211,25 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -210,25 +211,25 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}); });
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()),PlatSpace::getName,dto.getName()); queryWrapper.like(StringUtil.isNotEmpty(dto.getName()), PlatSpace::getName, dto.getName());
queryWrapper.eq(StringUtil.isNotEmpty(userVO.getOrgId()),PlatSpace::getOrgId,userVO.getOrgId()); queryWrapper.eq(StringUtil.isNotEmpty(userVO.getOrgId()), PlatSpace::getOrgId, userVO.getOrgId());
List<PlatSpace> list = this.list(queryWrapper); List<PlatSpace> list = this.list(queryWrapper);
List<PlatSpaceVO> listSpaceVo = BeanDtoVoUtils.listVo(list,PlatSpaceVO.class); List<PlatSpaceVO> listSpaceVo = BeanDtoVoUtils.listVo(list, PlatSpaceVO.class);
listSpaceVo.addAll(listRoomVo); listSpaceVo.addAll(listRoomVo);
//父级 //父级
List<PlatSpaceVO> listParent = listSpaceVo.stream().filter(item->StringUtil.isEmpty(item.getParentId())). List<PlatSpaceVO> listParent = listSpaceVo.stream().filter(item -> StringUtil.isEmpty(item.getParentId())).
collect(Collectors.toList()); collect(Collectors.toList());
//子集 //子集
List<PlatSpaceVO> listChild = listSpaceVo.stream().filter(item->item.getParentId() != null).collect(Collectors.toList()); List<PlatSpaceVO> listChild = listSpaceVo.stream().filter(item -> item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpaceVO>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpaceVO::getParentId)); Map<String, List<PlatSpaceVO>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpaceVO::getParentId));
List<PlatSpaceVO> data = new ArrayList<>(); List<PlatSpaceVO> data = new ArrayList<>();
for(PlatSpaceVO space:listParent){ for (PlatSpaceVO space : listParent) {
space = childVo(space,map); space = childVo(space, map);
data.add(space); data.add(space);
} }
return data; return data;
...@@ -236,6 +237,39 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -236,6 +237,39 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
} }
@Override @Override
public PlatSpaceSplitDTO getSpaceSplitVO(String bedId) {
PlatBed platBed = platBedService.getById(bedId);
PlatRoom platRoom = platRoomService.getById(platBed.getRoomId());
PlatSpace platSpace = getById(platRoom.getSpaceId());
PlatSpaceSplitDTO platSpaceSplitDTO = new PlatSpaceSplitDTO();
platSpaceSplitDTO.setSpaceId(platSpace.getId());
List<BiConsumer<PlatSpaceSplitDTO, String>> list = Arrays.asList(
PlatSpaceSplitDTO::setStreetSpaceId,
PlatSpaceSplitDTO::setBuildingSpaceId,
PlatSpaceSplitDTO::setUnitSpaceId,
PlatSpaceSplitDTO::setFloorSpaceId
);
String[] split = TreeUtil.path(platSpace.getParentPath(), Arrays.asList(platSpace.getId())).split(",");
for (int i = 0; i < split.length; i++) {
BiConsumer<PlatSpaceSplitDTO, String> e = list.get(i);
e.accept(platSpaceSplitDTO, split[i]);
}
platSpaceSplitDTO.setRoomId(platRoom.getId());
platSpaceSplitDTO.setBedId(platBed.getId());
platSpaceSplitDTO.setSpacePath(TreeUtil.path(platSpace.getParentPath(), Arrays.asList(
platSpace.getId(),
platRoom.getId(),
platBed.getId()
)));
return platSpaceSplitDTO;
}
@Override
public List<PlatSpace> listChild(List<String> spaceIds) { public List<PlatSpace> listChild(List<String> spaceIds) {
return baseMapper.listChild(spaceIds); return baseMapper.listChild(spaceIds);
...@@ -250,7 +284,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -250,7 +284,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return BeanDtoVoUtils.listVo(spaces, PlatSpaceAddDTO.class); return BeanDtoVoUtils.listVo(spaces, PlatSpaceAddDTO.class);
} }
private PlatSpaceVO childVo(PlatSpaceVO vo,Map<String,List<PlatSpaceVO>> map) { private PlatSpaceVO childVo(PlatSpaceVO vo, Map<String, List<PlatSpaceVO>> map) {
if (!map.containsKey(vo.getId())) { if (!map.containsKey(vo.getId())) {
return vo; return vo;
...@@ -268,17 +302,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -268,17 +302,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
@Override @Override
public PlatSpaceVO child(PlatSpaceVO vo,Map<String,List<PlatSpace>> map){ public PlatSpaceVO child(PlatSpaceVO vo, Map<String, List<PlatSpace>> map) {
if(!map.containsKey(vo.getId())){ if (!map.containsKey(vo.getId())) {
return vo; return vo;
} }
List<PlatSpace> list = map.get(vo.getId()); List<PlatSpace> list = map.get(vo.getId());
List<PlatSpaceVO> listChild = new ArrayList<>(); List<PlatSpaceVO> listChild = new ArrayList<>();
for(PlatSpace item:list){ for (PlatSpace item : list) {
PlatSpaceVO dto = convertToVO(item); PlatSpaceVO dto = convertToVO(item);
this.child(dto,map); this.child(dto, map);
listChild.add(dto); listChild.add(dto);
} }
vo.setChildren(listChild); vo.setChildren(listChild);
...@@ -286,7 +320,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -286,7 +320,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
} }
@Override @Override
public PlatSpaceVO convertToVO(PlatSpace space){ public PlatSpaceVO convertToVO(PlatSpace space) {
PlatSpaceVO vo = new PlatSpaceVO(); PlatSpaceVO vo = new PlatSpaceVO();
vo.setName(space.getName()); vo.setName(space.getName());
...@@ -305,18 +339,18 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -305,18 +339,18 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
try { try {
List<PlatSpace> listPlatSpace = list(new LambdaQueryWrapper<>()); 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 -> item.getParentId() == null).collect(Collectors.toList());
Map<String,String> firstSpaceNameMap = firstSpace.stream().collect(Collectors.toMap(PlatSpace::getName,PlatSpace::getId,(k1,k2)->k1)); 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 -> item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpace>> childrenMap = listChildren.stream().collect(Collectors.groupingBy(PlatSpace::getParentId)); 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<PlatSpaceImportDTO> list = ExcelUtil.importExcel(null,3,excelFile,PlatSpaceImportDTO.class); List<PlatSpaceImportDTO> list = ExcelUtil.importExcel(null, 3, excelFile, PlatSpaceImportDTO.class);
List<ExcelErrorVo> errorVoList = new ArrayList<>(10); List<ExcelErrorVo> errorVoList = new ArrayList<>(10);
List<String> excelField = Arrays.asList("一级*","二级","三级","四级","房间名*","床位数量"); List<String> excelField = Arrays.asList("一级*", "二级", "三级", "四级", "房间名*", "床位数量");
int startRow = 3; int startRow = 3;
...@@ -331,75 +365,75 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -331,75 +365,75 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
Integer errorCount = 0; Integer errorCount = 0;
Integer successCount = 0; Integer successCount = 0;
boolean errorFlag = false; boolean errorFlag = false;
for(int i=0;i<list.size();i++){ for (int i = 0; i < list.size(); i++) {
PlatSpaceImportDTO item = list.get(i); PlatSpaceImportDTO item = list.get(i);
if(StringUtil.isEmpty(item.getCommunity())){ if (StringUtil.isEmpty(item.getCommunity())) {
errorVoList.add(new ExcelErrorVo(i+3,excelField.get(0),"第一层级必填")); errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(0), "第一层级必填"));
errorFlag = true; errorFlag = true;
} }
if(StringUtil.isEmpty(item.getFloor())){ if (StringUtil.isEmpty(item.getFloor())) {
errorVoList.add(new ExcelErrorVo(i+3,excelField.get(4),"房间名必填")); errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(4), "房间名必填"));
errorFlag = true; errorFlag = true;
} }
String key = item.getCommunity(); String key = item.getCommunity();
//第二层级 //第二层级
if(StringUtil.isNotEmpty(item.getBuilding())){ if (StringUtil.isNotEmpty(item.getBuilding())) {
key = key + "-" + item.getBuilding(); key = key + "-" + item.getBuilding();
} }
//第三层级 //第三层级
if(StringUtil.isNotEmpty(item.getUnit())){ if (StringUtil.isNotEmpty(item.getUnit())) {
key = key + "-" + item.getUnit(); key = key + "-" + item.getUnit();
} }
//第四层级 //第四层级
if(StringUtil.isNotEmpty(item.getFloor())){ if (StringUtil.isNotEmpty(item.getFloor())) {
key = key + "-" + item.getFloor(); key = key + "-" + item.getFloor();
} }
if(listKey.contains(key)){ if (listKey.contains(key)) {
errorVoList.add(new ExcelErrorVo(i+3,excelField.get(0),"该空间下,房间名已存在")); errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(0), "该空间下,房间名已存在"));
errorFlag = true; errorFlag = true;
} }
if(errorFlag){ if (errorFlag) {
errorCount++; errorCount++;
}else{ } else {
successCount++; successCount++;
} }
} }
String orgId = TokenUtil.getTntUserDetail().getOrgId(); String orgId = TokenUtil.getTntUserDetail().getOrgId();
if(errorVoList.isEmpty()){ if (errorVoList.isEmpty()) {
for(int i=0;i<list.size();i++){ for (int i = 0; i < list.size(); i++) {
PlatSpaceImportDTO item = list.get(i); PlatSpaceImportDTO item = list.get(i);
//第一层级 //第一层级
String firstId = null; String firstId = null;
if(!firstSpaceNameMap.containsKey(item.getCommunity())){ if (!firstSpaceNameMap.containsKey(item.getCommunity())) {
PlatSpace platSpace = new PlatSpace(); PlatSpace platSpace = new PlatSpace();
platSpace.setName(item.getCommunity()); platSpace.setName(item.getCommunity());
platSpace.setType(PlatSpaceEnum.TypeEnum.COMMUNITY.getValue()); platSpace.setType(PlatSpaceEnum.TypeEnum.COMMUNITY.getValue());
platSpace.setOrgId(orgId); platSpace.setOrgId(orgId);
save(platSpace); save(platSpace);
firstSpaceNameMap.put(platSpace.getName(),platSpace.getId()); firstSpaceNameMap.put(platSpace.getName(), platSpace.getId());
firstId = platSpace.getId(); firstId = platSpace.getId();
}else{ } else {
firstId = firstSpaceNameMap.get(item.getCommunity()); firstId = firstSpaceNameMap.get(item.getCommunity());
} }
//第二层级 //第二层级
String secondId = null; String secondId = null;
if(StringUtil.isNotEmpty(item.getBuilding())){ if (StringUtil.isNotEmpty(item.getBuilding())) {
String secondKey = firstId + "-" + item.getBuilding(); String secondKey = firstId + "-" + item.getBuilding();
if(!childrenIdMap.containsKey(secondKey)){ if (!childrenIdMap.containsKey(secondKey)) {
PlatSpace platSpace = new PlatSpace(); PlatSpace platSpace = new PlatSpace();
platSpace.setName(item.getBuilding()); platSpace.setName(item.getBuilding());
platSpace.setType(PlatSpaceEnum.TypeEnum.BUILDING.getValue()); platSpace.setType(PlatSpaceEnum.TypeEnum.BUILDING.getValue());
...@@ -407,49 +441,49 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -407,49 +441,49 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
platSpace.setParentId(firstId); platSpace.setParentId(firstId);
platSpace.setParentPath(firstId); platSpace.setParentPath(firstId);
save(platSpace); save(platSpace);
childrenIdMap.put(secondKey,platSpace.getId()); childrenIdMap.put(secondKey, platSpace.getId());
secondId = platSpace.getId(); secondId = platSpace.getId();
}else{ } else {
secondId = childrenIdMap.get(secondKey); secondId = childrenIdMap.get(secondKey);
} }
} }
//第三级 //第三级
String threeId = null; String threeId = null;
if(StringUtil.isNotEmpty(item.getUnit())){ if (StringUtil.isNotEmpty(item.getUnit())) {
String threeKey = secondId + "-" + item.getUnit(); String threeKey = secondId + "-" + item.getUnit();
if(!childrenIdMap.containsKey(threeKey)){ if (!childrenIdMap.containsKey(threeKey)) {
PlatSpace platSpace = new PlatSpace(); PlatSpace platSpace = new PlatSpace();
platSpace.setName(item.getBuilding()); platSpace.setName(item.getBuilding());
platSpace.setType(PlatSpaceEnum.TypeEnum.UNIT.getValue()); platSpace.setType(PlatSpaceEnum.TypeEnum.UNIT.getValue());
platSpace.setOrgId(orgId); platSpace.setOrgId(orgId);
platSpace.setParentId(secondId); platSpace.setParentId(secondId);
platSpace.setParentPath(firstId+","+secondId); platSpace.setParentPath(firstId + "," + secondId);
save(platSpace); save(platSpace);
childrenIdMap.put(threeKey,platSpace.getId()); childrenIdMap.put(threeKey, platSpace.getId());
threeId = platSpace.getId(); threeId = platSpace.getId();
}else{ } else {
threeId = childrenIdMap.get(threeKey); threeId = childrenIdMap.get(threeKey);
} }
} }
//第四级 //第四级
String fourId = null; String fourId = null;
if(StringUtil.isNotEmpty(item.getFloor())){ if (StringUtil.isNotEmpty(item.getFloor())) {
String fourKey = threeId + "-" + item.getFloor(); String fourKey = threeId + "-" + item.getFloor();
if(!childrenIdMap.containsKey(fourKey)){ if (!childrenIdMap.containsKey(fourKey)) {
PlatSpace platSpace = new PlatSpace(); PlatSpace platSpace = new PlatSpace();
platSpace.setName(item.getBuilding()); platSpace.setName(item.getBuilding());
platSpace.setType(PlatSpaceEnum.TypeEnum.FLOOR.getValue()); platSpace.setType(PlatSpaceEnum.TypeEnum.FLOOR.getValue());
platSpace.setOrgId(orgId); platSpace.setOrgId(orgId);
platSpace.setParentId(threeId); platSpace.setParentId(threeId);
platSpace.setParentPath(firstId+","+secondId + "," + threeId); platSpace.setParentPath(firstId + "," + secondId + "," + threeId);
save(platSpace); save(platSpace);
childrenIdMap.put(fourKey,platSpace.getId()); childrenIdMap.put(fourKey, platSpace.getId());
fourId = platSpace.getId(); fourId = platSpace.getId();
}else{ } else {
fourId = childrenIdMap.get(fourKey); fourId = childrenIdMap.get(fourKey);
} }
} }
...@@ -459,13 +493,13 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -459,13 +493,13 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
platRoomDTO.setName(item.getRoomName()); platRoomDTO.setName(item.getRoomName());
platRoomDTO.setBedNumber(item.getBedNumber()); platRoomDTO.setBedNumber(item.getBedNumber());
String spaceId = null; String spaceId = null;
if(firstId != null){ if (firstId != null) {
spaceId = firstId; spaceId = firstId;
}else if(secondId != null){ } else if (secondId != null) {
spaceId = secondId; spaceId = secondId;
}else if(threeId != null){ } else if (threeId != null) {
spaceId = threeId; spaceId = threeId;
}else if(fourId != null){ } else if (fourId != null) {
spaceId = fourId; spaceId = fourId;
} }
platRoomDTO.setSpaceId(spaceId); platRoomDTO.setSpaceId(spaceId);
...@@ -477,7 +511,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -477,7 +511,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
excelImportVo.setSuccessCount(successCount); excelImportVo.setSuccessCount(successCount);
excelImportVo.setList(errorVoList); excelImportVo.setList(errorVoList);
return excelImportVo; return excelImportVo;
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -488,7 +522,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -488,7 +522,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
public List<PlatSpaceVO> parentListTree(PlatSpaceQueryDTO dto) { public List<PlatSpaceVO> parentListTree(PlatSpaceQueryDTO dto) {
//查询用户权限组织id //查询用户权限组织id
List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg()); List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg());
if(orgs.isEmpty()){ if (orgs.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
//房间 //房间
...@@ -497,27 +531,27 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -497,27 +531,27 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList()); List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()),PlatSpace::getName,dto.getName()); queryWrapper.like(StringUtil.isNotEmpty(dto.getName()), PlatSpace::getName, dto.getName());
queryWrapper.in(PlatSpace::getOrgId, orgIds); queryWrapper.in(PlatSpace::getOrgId, orgIds);
if(!spaceIds.isEmpty()){ if (!spaceIds.isEmpty()) {
queryWrapper.notIn(PlatSpace::getId, spaceIds); queryWrapper.notIn(PlatSpace::getId, spaceIds);
} }
List<PlatSpace> list = this.list(queryWrapper); List<PlatSpace> list = this.list(queryWrapper);
list = list.stream() list = list.stream()
.filter(s->(StringUtil.isNotEmpty(s.getParentPath()) && s.getParentPath().split(",").length < 3) .filter(s -> (StringUtil.isNotEmpty(s.getParentPath()) && s.getParentPath().split(",").length < 3)
|| StringUtil.isEmpty(s.getParentPath())) || StringUtil.isEmpty(s.getParentPath()))
.collect(Collectors.toList()); .collect(Collectors.toList());
//父级 //父级
List<PlatSpace> listParent = list.stream().filter(item->StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList()); List<PlatSpace> listParent = list.stream().filter(item -> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
//子集 //子集
List<PlatSpace> listChild = list.stream().filter(item->item.getParentId() != null).collect(Collectors.toList()); List<PlatSpace> listChild = list.stream().filter(item -> item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpace>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpace::getParentId)); Map<String, List<PlatSpace>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpace::getParentId));
List<PlatSpaceVO> data = new ArrayList<>(); List<PlatSpaceVO> data = new ArrayList<>();
for(PlatSpace space:listParent){ for (PlatSpace space : listParent) {
PlatSpaceVO vo = convertToVO(space); PlatSpaceVO vo = convertToVO(space);
vo = child(vo,map); vo = child(vo, map);
data.add(vo); data.add(vo);
} }
return data; return data;
......
package com.makeit.service.wechat.impl; package com.makeit.service.wechat.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.dto.platform.auth.PlatOrgSplitDTO;
import com.makeit.entity.platform.elder.PlatElderChildrenInfo; import com.makeit.entity.platform.elder.PlatElderChildrenInfo;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.elder.PlatElderChildrenInfoService; import com.makeit.service.platform.elder.PlatElderChildrenInfoService;
import com.makeit.service.wechat.PlatElderChildrenInfoUserLoginWechatService; import com.makeit.service.wechat.PlatElderChildrenInfoUserLoginWechatService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
...@@ -24,6 +26,9 @@ public class PlatElderChildrenInfoUserLoginWechatServiceImpl implements PlatElde ...@@ -24,6 +26,9 @@ public class PlatElderChildrenInfoUserLoginWechatServiceImpl implements PlatElde
@Autowired @Autowired
private PlatElderChildrenInfoService platElderChildrenInfoService; private PlatElderChildrenInfoService platElderChildrenInfoService;
@Autowired
private PlatOrgService platOrgService;
@Override @Override
@Transactional @Transactional
public WechatUserInfo login(WechatLoginPhoneDTO dto) { public WechatUserInfo login(WechatLoginPhoneDTO dto) {
...@@ -34,8 +39,19 @@ public class PlatElderChildrenInfoUserLoginWechatServiceImpl implements PlatElde ...@@ -34,8 +39,19 @@ public class PlatElderChildrenInfoUserLoginWechatServiceImpl implements PlatElde
.eq(PlatElderChildrenInfo::getOpenid, userInfo.getOpenId())); .eq(PlatElderChildrenInfo::getOpenid, userInfo.getOpenId()));
if (childrenInfo == null) { if (childrenInfo == null) {
childrenInfo = new PlatElderChildrenInfo(); childrenInfo = new PlatElderChildrenInfo();
childrenInfo.setOpenid(userInfo.getOpenId()); childrenInfo.setOpenid(userInfo.getOpenId());
childrenInfo.setName(userInfo.getNickName()); childrenInfo.setName(userInfo.getNickName());
PlatOrgSplitDTO vo = platOrgService.getOrgSplitVO(dto.getOrgId());
childrenInfo = new PlatElderChildrenInfo();
childrenInfo.setCityOrgId(vo.getCityOrgId());
childrenInfo.setDistrictOrgId(vo.getDistrictOrgId());
childrenInfo.setStreetOrgId(vo.getStreetOrgId());
childrenInfo.setOrgPath(vo.getOrgPath());
} }
childrenInfo.setPhone(userInfo.getPhoneNumber()); childrenInfo.setPhone(userInfo.getPhoneNumber());
......
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