|
|
|
@ -3,10 +3,15 @@ package com.supervision.manage.service.impl;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.util.CoordinateUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.supervision.manage.service.PhysicalLocationManageService;
|
|
|
|
|
import com.supervision.model.ConfigPhysicalLocation;
|
|
|
|
|
import com.supervision.model.ConfigPhysicalTool;
|
|
|
|
|
import com.supervision.model.DefaultPhysicalIndicator;
|
|
|
|
|
import com.supervision.service.ConfigPhysicalLocationService;
|
|
|
|
|
import com.supervision.service.ConfigPhysicalToolService;
|
|
|
|
|
import com.supervision.service.DefaultPhysicalIndicatorService;
|
|
|
|
|
import com.supervision.vo.manage.PhysicalLocationNode;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -20,6 +25,9 @@ import java.util.stream.Collectors;
|
|
|
|
|
public class PhysicalLocationManageServiceImpl implements PhysicalLocationManageService {
|
|
|
|
|
|
|
|
|
|
private final ConfigPhysicalLocationService configPhysicalLocationService;
|
|
|
|
|
|
|
|
|
|
private final DefaultPhysicalIndicatorService defaultPhysicalIndicatorService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<PhysicalLocationNode> queryTree() {
|
|
|
|
|
|
|
|
|
@ -30,7 +38,7 @@ public class PhysicalLocationManageServiceImpl implements PhysicalLocationManage
|
|
|
|
|
|
|
|
|
|
Map<String, PhysicalLocationNode> map = list.stream().collect(
|
|
|
|
|
Collectors.toMap(ConfigPhysicalLocation::getId, p -> BeanUtil.toBean(p, PhysicalLocationNode.class)));
|
|
|
|
|
|
|
|
|
|
// 这里只支持2层
|
|
|
|
|
for (Map.Entry<String, PhysicalLocationNode> entry : map.entrySet()) {
|
|
|
|
|
PhysicalLocationNode value = entry.getValue();
|
|
|
|
|
if (StrUtil.isNotEmpty(value.getParentId())) {
|
|
|
|
@ -48,4 +56,33 @@ public class PhysicalLocationManageServiceImpl implements PhysicalLocationManage
|
|
|
|
|
|
|
|
|
|
return map.values().stream().filter(n -> StrUtil.isEmpty(n.getParentId())).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<PhysicalLocationNode> queryLocationTreeForPhysicalConfig(String physicalId) {
|
|
|
|
|
// 首先构建位置树
|
|
|
|
|
List<PhysicalLocationNode> physicalLocationNodes = queryTree();
|
|
|
|
|
// 查询体格检查项目已经配置的部位
|
|
|
|
|
if (StrUtil.isNotEmpty(physicalId)) {
|
|
|
|
|
List<DefaultPhysicalIndicator> defaultPhysicalIndicatorList = defaultPhysicalIndicatorService.lambdaQuery().eq(DefaultPhysicalIndicator::getItemId, physicalId).list();
|
|
|
|
|
if (CollUtil.isNotEmpty(defaultPhysicalIndicatorList)) {
|
|
|
|
|
Set<String> itemIdSet = defaultPhysicalIndicatorList.stream().map(DefaultPhysicalIndicator::getLocationId).collect(Collectors.toSet());
|
|
|
|
|
if (CollUtil.isNotEmpty(itemIdSet)) {
|
|
|
|
|
// 现在只有2层,遍历2次就可以了
|
|
|
|
|
for (PhysicalLocationNode physicalLocationNode : physicalLocationNodes) {
|
|
|
|
|
if (itemIdSet.contains(physicalLocationNode.getId())) {
|
|
|
|
|
physicalLocationNode.setChoose(1);
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(physicalLocationNode.getChild())) {
|
|
|
|
|
for (PhysicalLocationNode child : physicalLocationNode.getChild()) {
|
|
|
|
|
if (itemIdSet.contains(child.getId())) {
|
|
|
|
|
child.setChoose(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return physicalLocationNodes;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|