Commit f28bb7de by wangli

实现获取区块列表

1 parent 40795dcb
package com.dituhui.pea.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.ListUtils;
import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.MapBlockInfoMPDao;
import com.dituhui.pea.order.dao.OrgGroupMPDao;
import com.dituhui.pea.order.dao.OrgTeamMPDao;
import com.dituhui.pea.order.dto.BusinessServerBlocksRespDTO;
import com.dituhui.pea.order.entity.MapBlockInfo;
import com.dituhui.pea.order.entity.OrgGroup;
import com.dituhui.pea.order.entity.OrgTeam;
import com.dituhui.pea.order.service.BusinessBlockService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
public class BusinessBlockServiceImpl implements BusinessBlockService {
@Autowired
private OrgTeamMPDao orgTeamMPDao;
@Autowired
private MapBlockInfoMPDao mapBlockInfoMPDao;
@Autowired
private OrgGroupMPDao orgGroupMPDao;
@Override
public Result<?> businessServerBlocks(String levelType, String levelValue, int page, int size, String layerId, String teamId) {
BusinessServerBlocksRespDTO resp = new BusinessServerBlocksRespDTO();
LambdaQueryWrapper<OrgTeam> lqwTeam = new LambdaQueryWrapper<>();
lqwTeam.eq(levelType.equals("cluster"), OrgTeam::getClusterId, levelValue);
lqwTeam.eq(levelType.equals("branch"), OrgTeam::getBranchId, levelValue);
lqwTeam.eq(levelType.equals("group"), OrgTeam::getGroupId, levelValue);
lqwTeam.eq(StringUtils.isNotEmpty(teamId), OrgTeam::getTeamId, teamId);
List<OrgTeam> teams = orgTeamMPDao.selectList(lqwTeam);
if (ListUtils.isEmpty(teams)) {
resp.setTotal(0);
resp.setPages(1);
resp.setPageCurrent(1);
resp.setPageSize(size);
resp.setTip("");
resp.setContent(new ArrayList<>());
return Result.success(null);
}
// 获得teamId与team的映射
Map<String, OrgTeam> teamMapping = new HashMap<>();
for(OrgTeam t: teams){
teamMapping.put(t.getTeamId(), t);
}
// teamId列表
List<String> teamIds = teams.stream().map(OrgTeam::getTeamId).collect(Collectors.toList());
// 获取groupId集合
Set<String> groupIds = teams.stream().map(OrgTeam::getGroupId).collect(Collectors.toSet());
List<OrgGroup> groups = orgGroupMPDao.selectByGroupIds(new ArrayList<>(groupIds));
Map<String, String> groupMapping = groups.stream().collect(Collectors.toMap(OrgGroup::getGroupId, OrgGroup::getGroupName));
Page<MapBlockInfo> pg = new Page<>(page, size);
LambdaQueryWrapper<MapBlockInfo> lqwBlock = new LambdaQueryWrapper<>();
lqwBlock.in(MapBlockInfo::getTeamId, teamIds);
lqwBlock.eq(StringUtils.isNotEmpty(layerId), MapBlockInfo::getLayerId, layerId);
lqwBlock.orderByAsc(MapBlockInfo::getTeamId);
mapBlockInfoMPDao.selectPage(pg, lqwBlock);
List<BusinessServerBlocksRespDTO.Block> blocks = new ArrayList<>();
for(MapBlockInfo b: pg.getRecords()){
BusinessServerBlocksRespDTO.Block block = new BusinessServerBlocksRespDTO.Block();
OrgTeam team = teamMapping.get(b.getTeamId());
String groupId = team.getGroupId();
String groupName = groupMapping.get(groupId);
block.setId(b.getBlockId());
block.setGroupId(groupId);
block.setGroupName(groupName);
block.setLayerId(b.getLayerId());
block.setLayerName(b.getLayer());
block.setTeamId(b.getTeamId());
block.setTeamName(team.getTeamName());
block.setArea(b.getArea().toString());
block.setUpdateTime(TimeUtils.IsoLocalDateTime2String(b.getUpdateTime()));
blocks.add(block);
}
resp.setTotal(pg.getTotal());
resp.setPages(pg.getPages());
resp.setPageCurrent(pg.getCurrent());
resp.setPageSize(pg.getSize());
resp.setTip("");
resp.setContent(blocks);
return null;
}
......@@ -19,12 +112,12 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
}
@Override
public Result<?> businessServiceBlockDelete(String id) {
public Result<?> businessServiceBlockDelete(String blockId) {
return null;
}
@Override
public Result<?> saasBaseDataLayerUrl(String id) {
public Result<?> saasBaseDataLayerUrl(String blockId) {
return null;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!