Commit fa1eaee7 by wangli

新增获取图层列表接口

1 parent 13c90b45
......@@ -30,15 +30,16 @@ public class BusinessBlockController {
@RequestParam long page, @RequestParam long size,
@RequestParam(required = false) String layerId,
@RequestParam(required = false) String teamId) {
Result<?> res=null;
try{
Result<?> res = null;
try {
res = businessBlockService.businessServerBlocks(levelType, levelValue, page, size, layerId, teamId);
} catch (BusinessException e){
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
/**
* 新增服务区块
*
......@@ -50,9 +51,9 @@ public class BusinessBlockController {
public Result<?> businessServiceBlockAdd(@RequestParam String layerId, @RequestParam String teamId) {
// 新增服务范围
Result<?> res = null;
try{
try {
res = businessBlockService.businessServiceBlockAdd(layerId, teamId);
} catch (BusinessException e){
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
......@@ -68,9 +69,9 @@ public class BusinessBlockController {
public Result<?> businessServiceBlockRemove(@RequestParam String id) {
// 删除服务范围
Result<?> res = null;
try{
try {
res = businessBlockService.businessServiceBlockRemove(id);
} catch (BusinessException e){
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
......@@ -84,12 +85,32 @@ public class BusinessBlockController {
*/
@GetMapping("/saas/baseData/layer/getUrl")
public Result<?> saasBaseDataLayerUrl(@RequestParam String id) {
Result<?> res=null;
try{
Result<?> res = null;
try {
res = businessBlockService.saasBaseDataLayerUrl(id);
} catch (BusinessException e){
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
/**
* 获取图层列表
*
* @param levelType 组织层级类型
* @param levelValue 组织层级值
* @return
*/
@GetMapping("/business/layer/list")
public Result<?> businessSeverLayers(@RequestParam String levelType, @RequestParam String levelValue) {
Result<?> res = null;
try {
res = businessBlockService.businessServerLayers(levelType, levelValue);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
}
......@@ -11,4 +11,6 @@ public interface BusinessBlockService {
Result<?> businessServiceBlockRemove(String blockId);
Result<?> saasBaseDataLayerUrl(String blockId);
Result<?> businessServerLayers(String levelType, String levelValue);
}
......@@ -6,13 +6,9 @@ import com.dituhui.pea.common.BusinessException;
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.dao.*;
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.entity.*;
import com.dituhui.pea.order.service.BusinessBlockService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -35,6 +31,12 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
@Autowired
private OrgGroupMPDao orgGroupMPDao;
@Autowired
private MapLayerMPDao mapLayerMPDao;
@Autowired
private MapLayerCustomizeMPDao mapLayerCustomizeMPDao;
@Override
public Result<?> businessServerBlocks(String levelType, String levelValue, long page, long size, String layerId, String teamId) {
BusinessServerBlocksRespDTO resp = new BusinessServerBlocksRespDTO();
......@@ -57,7 +59,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
// 获得teamId与team的映射
Map<String, OrgTeam> teamMapping = new HashMap<>();
for(OrgTeam t: teams){
for (OrgTeam t : teams) {
teamMapping.put(t.getTeamId(), t);
}
......@@ -78,7 +80,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
mapBlockInfoMPDao.selectPage(pg, lqwBlock);
List<BusinessServerBlocksRespDTO.Block> blocks = new ArrayList<>();
for(MapBlockInfo b: pg.getRecords()){
for (MapBlockInfo b : pg.getRecords()) {
BusinessServerBlocksRespDTO.Block block = new BusinessServerBlocksRespDTO.Block();
OrgTeam team = teamMapping.get(b.getTeamId());
......@@ -109,14 +111,34 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
}
@Override
public Result<?> businessServiceBlockAdd(String layerId, String teamId) {
return null;
public Result<?> businessServiceBlockAdd(String layerId, String teamId) throws BusinessException {
MapLayerCustomize layer = mapLayerCustomizeMPDao.getByLayerId(layerId);
if (layer == null) {
throw new BusinessException("图层标签不存在");
}
OrgTeam team = orgTeamMPDao.getByTeamId(teamId);
if (team == null) {
throw new BusinessException("关联小队不存在");
}
MapBlockInfo block = new MapBlockInfo();
block.setBlockId(UUID.randomUUID().toString().replace("-", ""));
block.setBlockName(team.getTeamName()); //默认使用team name;
block.setBranchId(team.getBranchId());
block.setGroupId(team.getGroupId());
block.setTeamId(teamId);
block.setLayer(layerId);
block.setLayer(layer.getLayer());
block.setStatus(1);
mapBlockInfoMPDao.insert(block);
return Result.success(null);
}
@Override
public Result<?> businessServiceBlockRemove(String blockId) throws BusinessException{
public Result<?> businessServiceBlockRemove(String blockId) throws BusinessException {
MapBlockInfo block = mapBlockInfoMPDao.getByBlockId(blockId);
if(block == null) {
if (block == null) {
throw new BusinessException("区块不存在");
}
block.setStatus(0);
......@@ -125,9 +147,9 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
}
@Override
public Result<?> saasBaseDataLayerUrl(String blockId) throws BusinessException{
public Result<?> saasBaseDataLayerUrl(String blockId) throws BusinessException {
MapBlockInfo block = mapBlockInfoMPDao.getByBlockId(blockId);
if(block == null) {
if (block == null) {
throw new BusinessException("区块不存在");
}
// 跳转规则: TODO
......@@ -135,4 +157,40 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
res.put("url", "https://pea-test.bshg.com.cn/mlAutoLogin?userAccount=WVyjhzcOeIUc5rl74hdaqw==&password=qjOHxpQPXLnJP+Jq1CZGBQ==&jump=basedata&navHidden=true");
return Result.success(res);
}
@Override
public Result<?> businessServerLayers(String levelType, String levelValue) {
List<Map<String, String>> items = new ArrayList<>();
// 获取通用图层
List<MapLayer> layers = mapLayerMPDao.selectList(null);
for(MapLayer r: layers){
Map<String, String> m = new HashMap<>();
m.put("layerId", r.getLayerId());
m.put("layerName", r.getLayer());
items.add(m);
}
// 获取自定义图层(只有branch才能创建自定义图层)
LambdaQueryWrapper<OrgGroup> lqw = new LambdaQueryWrapper<>();
lqw.eq(levelType.equals("cluster"), OrgGroup::getClusterId, levelValue);
lqw.eq(levelType.equals("branch"), OrgGroup::getBranchId, levelValue);
lqw.eq(levelType.equals("group"), OrgGroup::getGroupId, levelValue);
Set<String> branchIds = orgGroupMPDao.selectList(lqw).stream().map(OrgGroup::getBranchId).collect(Collectors.toSet());
if (branchIds.isEmpty()) {
return Result.success(items);
}
LambdaQueryWrapper<MapLayerCustomize> lqwLayer = new LambdaQueryWrapper<>();
lqwLayer.eq(MapLayerCustomize::getDisabled, 1);
lqwLayer.in(MapLayerCustomize::getBranchId, new ArrayList<>(branchIds));
List<MapLayerCustomize> layerCustomizes = mapLayerCustomizeMPDao.selectList(lqwLayer);
for(MapLayerCustomize r: layerCustomizes) {
Map<String, String> m = new HashMap<>();
m.put("layerId", r.getLayerId());
m.put("layerName", r.getLayer());
items.add(m);
}
return Result.success(items);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!