融合服务修改

This commit is contained in:
Koi-tsk 2022-08-26 10:37:20 +08:00
parent 2d403dcc9e
commit 1336f6d5e4
3 changed files with 38 additions and 10 deletions

View File

@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
@ -61,6 +62,13 @@ public class FuseController {
return new Result<TbFuseDTO>().ok(tbFuseService.getFuseById(id));
}
@GetMapping("getDataResource")
@ApiOperation("获取资源数据")
@LogOperation("获取资源数据")
public Result<List<Map>> getDataResource() {
return new Result().ok(tbFuseService.getDataResource());
}
@PostMapping
@ApiOperation("保存")
@LogOperation("保存")

View File

@ -4,6 +4,7 @@ import io.renren.common.service.CrudService;
import io.renren.modules.fuse.dto.TbFuseDTO;
import io.renren.modules.fuse.entity.TbFuseEntity;
import java.util.List;
import java.util.Map;
/**
@ -15,6 +16,8 @@ public interface TbFuseService extends CrudService<TbFuseEntity, TbFuseDTO> {
TbFuseDTO getFuseById(Long id);
List<Map> getDataResource();
Integer addFuse(TbFuseDTO dto);
Integer updateFuse(TbFuseDTO dto);

View File

@ -154,35 +154,52 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
}).collect(Collectors.toList());
}
private Map<String, Map<String, Object>> getDataResource() {
Map<String, Map<String, Object>> result = new HashMap<>();
public List<Map> getDataResource() {
int pageNum=0;
int pageSize=getDataResourceCount();
List<Map> result = new ArrayList<>();
Optional<AbstractDataResourceService> factory = DataResourceFactory.build();
if (factory.isPresent()) {
GetDataResourceListDto dto = new GetDataResourceListDto().setPageNum(0).setPageSize(30);
GetDataResourceListDto dto = new GetDataResourceListDto().setPageNum(pageNum).setPageSize(pageSize);
Map<String, Object> dataMap = (Map<String, Object>) factory.get().getDataResource(dto);
if (dataMap != null) {
List<Map<String, Object>> list = (List<Map<String, Object>>) dataMap.get("data");
list.forEach(map -> {
list.forEach(map -> result.add(new HashMap() {{
if (map.containsKey("zyname")) {
result.put(map.get("guid").toString(), map);
put("id", map.get("guid"));
put("name", map.get("zyname"));
} else {
result.put(map.get("serviceId").toString(), map);
put("id", map.get("serviceId"));
put("name", map.get("serviceName"));
}
});
}}));
}
}
return result;
}
private int getDataResourceCount() {
int count=30;
Optional<AbstractDataResourceService> factory = DataResourceFactory.build();
if (factory.isPresent()) {
GetDataResourceListDto dto = new GetDataResourceListDto().setPageNum(0).setPageSize(30);
Map<String, Object> dataMap = (Map<String, Object>) factory.get().getDataResource(dto);
if (dataMap != null) {
count=Integer.parseInt(dataMap.get("rows").toString());
}
}
return count;
}
private List<TbFuseResourceDTO> getFuseResourceByFuseId(Long fuseId) {
Map<String, Map<String, Object>> dataResourceMap = new HashMap<>();
List<Map> dataResourceMap = new ArrayList<>();
List<TbFuseResourceDTO> result = new ArrayList();
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("fuse_id", fuseId);
List<TbFuseResourceEntity> list = fuseResourceDao.selectList(wrapper);
Map<String, List<TbFuseResourceEntity>> resourceMap = list.stream().filter(index -> index.getType() != null).collect(Collectors.groupingBy(TbFuseResourceEntity::getType));
if (resourceMap.containsKey("数据资源")) {
dataResourceMap.putAll(getDataResource());
dataResourceMap.addAll(getDataResource());
}
resourceMap.forEach((type, value) -> {
if ("组件服务".equals(type)) {
@ -198,7 +215,7 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
result.addAll(value.stream().map(attr -> {
TbFuseResourceDTO dto = new TbFuseResourceDTO();
BeanUtils.copyProperties(attr, dto);
dto.setResource(dataResourceMap.get(dto.getResourceId()));
dto.setResource(dataResourceMap.stream().filter(it->it.get("id").equals(dto.getResourceId())).findFirst());
return dto;
}).collect(Collectors.toList()));
} else if ("基础设施".equals(type)) {