Commit 82ea76f3 by 王力

Merge branch 'dev_bussiness_layer0726' into 'develop'

Dev bussiness layer0726

See merge request !279
2 parents 6231f07a f28bb7de
......@@ -48,6 +48,10 @@ public class TimeUtils {
return LocalDateTime.parse(s, DateTimeFormatter.ofPattern(DATE_TIME_FORMAT));
}
public static final String IsoLocalDateTime2String(LocalDateTime localDateTime) {
return localDateTime.format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT));
}
public static final String IsoLocalDate2String(LocalDate localDate) {
return localDate.format(DateTimeFormatter.ofPattern(DATE_GAP_FORMAT));
}
......
package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.service.BusinessBlockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
@Controller
@RequestMapping("/pea-order")
public class BusinessBlockController {
@Autowired
private BusinessBlockService businessBlockService;
/**
* 获取服务区块列表
*
* @param levelType 组织层级类型
* @param levelValue 组织层级值
* @param page 分页-页数
* @param size 分页-页大小
* @param layerId 图层ID(筛选项)
* @param teamId 小队ID(筛选项)
* @return
*/
@GetMapping("/business/service/block/list")
public Result<?> businessSeverBlocks() {
// 服务范围列表
return null;
public Result<?> businessSeverBlocks(@RequestParam String levelType, @RequestParam String levelValue,
@RequestParam int page, @RequestParam int size,
@RequestParam(required = false) String layerId,
@RequestParam(required = false) String teamId) {
Result<?> res=null;
try{
res = businessBlockService.businessServerBlocks(levelType, levelValue, page, size, layerId, teamId);
} catch (BusinessException e){
return Result.failed(e.getMessage());
}
return res;
}
/**
* 新增服务区块
*
* @param layerId 图层ID
* @param teamId 小队ID
* @return
*/
@PostMapping("/business/service/block/add")
public Result<?> businessServiceBlockAdd() {
public Result<?> businessServiceBlockAdd(@RequestParam String layerId, @RequestParam String teamId) {
// 新增服务范围
return null;
Result<?> res = null;
try{
res = businessBlockService.businessServiceBlockAdd(layerId, teamId);
} catch (BusinessException e){
return Result.failed(e.getMessage());
}
return res;
}
/**
* 新增服务区块
*
* @param id 服务区块ID
* @return
*/
@PostMapping("/business/service/block/delete")
public Result<?> businessServiceBlockDelete() {
public Result<?> businessServiceBlockDelete(@RequestParam String id) {
// 删除服务范围
return null;
Result<?> res = null;
try{
res = businessBlockService.businessServiceBlockDelete(id);
} catch (BusinessException e){
return Result.failed(e.getMessage());
}
return res;
}
/**
* 获取跳转saas绘制服务返回的url
*
* @param id 服务区块ID
* @return
*/
@GetMapping("/saas/baseData/layer/getUrl")
public Result<?> saasBaseDataLayerUrl() {
return null;
public Result<?> saasBaseDataLayerUrl(@RequestParam String id) {
Result<?> res=null;
try{
res = businessBlockService.saasBaseDataLayerUrl(id);
} catch (BusinessException e){
return Result.failed(e.getMessage());
}
return res;
}
}
package com.dituhui.pea.order.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dituhui.pea.order.entity.MapBlockInfo;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MapBlockInfoMPDao extends BaseMapper<MapBlockInfo> {
}
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.OrgGroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
......@@ -15,4 +16,8 @@ public interface OrgGroupMPDao extends BaseMapper<OrgGroup> {
@Select("select * from org_group where group_id = #{groupId}")
List<OrgGroup> selectByGroupId(String groupId);
@Select("select * from org_group where group_id in " +
"<foreach item='groupId' index='index' collection='groupIds' open='(' separator=',' close=')'>#{groupId}</foreach></script>")
List<OrgGroup> selectByGroupIds(@Param("groupIds") List<String> groupIds);
}
package com.dituhui.pea.order.dto;
import lombok.Data;
import java.util.List;
@Data
public class BusinessServerBlocksRespDTO {
private long total;
private long pages;
private long pageCurrent;
private long pageSize;
private String tip;
private List<Block> content;
@Data
public static class Block {
private String id;
private String groupId;
private String groupName;
private String layerId;
private String layerName;
private String teamId;
private String teamName;
private String area;
private String updateTime;
}
}
package com.dituhui.pea.order.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.HashMap;
@Data
public class MapBlockInfo {
private Integer id;
private String blockId;
private String blockName;
private String subsectionId;
private String groupId;
private String cityCode;
private Integer area;
@TableField(typeHandler = JacksonTypeHandler.class)
private HashMap<String, Object> areaData;
private Integer kind;
private String teamId;
private String layerId;
private String layer;
private Integer status;
private String memo;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}
package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
public interface BusinessBlockService {
......@@ -10,7 +8,7 @@ public interface BusinessBlockService {
Result<?> businessServiceBlockAdd(String layerId, String teamId);
Result<?> businessServiceBlockDelete(String id);
Result<?> businessServiceBlockDelete(String blockId);
Result<?> saasBaseDataLayerUrl(String id);
Result<?> saasBaseDataLayerUrl(String blockId);
}
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!