Commit 10629dd5 by lzy

空间管理

parent 25e385c5
CREATE TABLE `plat_space`
(
`id` VARCHAR(64) NOT NULL COMMENT 'id',
`name` VARCHAR(128) NOT NULL COMMENT '名称',
`parent_id` VARCHAR(64) DEFAULT NULL COMMENT '上级空间',
`type` VARCHAR(4) NOT NULL COMMENT '空间类型 1:小区/社区/街道 2:楼栋 3:单元 4 楼层',
`address` VARCHAR(256) DEFAULT NULL COMMENT '地址',
`longitude` VARCHAR(64) DEFAULT NULL COMMENT '经度',
`latitude` VARCHAR(64) DEFAULT NULL COMMENT '纬度',
`province` VARCHAR(64) DEFAULT NULL COMMENT '省(预留字段)',
`city` VARCHAR(64) DEFAULT NULL COMMENT '市(预留字段)',
`district` VARCHAR(64) DEFAULT NULL COMMENT '区(预留字段)',
`parent_path` VARCHAR(64) DEFAULT NULL COMMENT '父级全路径',
`create_by` VARCHAR(64) DEFAULT NULL COMMENT '创建者',
`create_date` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` VARCHAR(64) DEFAULT NULL COMMENT '更新者',
`update_date` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` INT(1) DEFAULT '0' COMMENT '删除标记',
`tenant_id` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ' 租户id ',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = INNODB
DEFAULT CHARSET = utf8mb4 COMMENT = '空间管理';
CREATE TABLE `plat_room`
(
`id` VARCHAR(64) NOT NULL COMMENT 'id',
`name` VARCHAR(128) NOT NULL COMMENT '名称',
`space_id` VARCHAR(64) NOT NULL COMMENT '空间id',
`space_path` VARCHAR(512) NOT NULL COMMENT '空间全路径',
`space_path_name` VARCHAR(512) NOT NULL COMMENT '空间全路径名称',
`bed_number` INT(4) NOT NULL COMMENT '床位数量',
`description` VARCHAR(1024) DEFAULT NULL COMMENT '床位描述',
`create_by` VARCHAR(64) DEFAULT NULL COMMENT '创建者',
`create_date` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` VARCHAR(64) DEFAULT NULL COMMENT '更新者',
`update_date` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` INT(1) DEFAULT '0' COMMENT '删除标记',
`tenant_id` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ' 租户id ',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = INNODB
DEFAULT CHARSET = utf8mb4 COMMENT = '房间管理';
CREATE TABLE `plat_bed`
(
`id` varchar(64) NOT NULL COMMENT 'id',
`name` varchar(128) NOT NULL COMMENT '床位名称 床位1,床位2',
`room_id` varchar(64) NOT NULL COMMENT '房间id',
`space_id` varchar(64) NOT NULL COMMENT '空间id',
`equipment_id` varchar(64) DEFAULT NULL COMMENT '设备id',
`status` char(1) DEFAULT 1 COMMENT '是否空闲 1 是 0 否 ',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建者',
`create_date` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新者',
`update_date` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int(1) DEFAULT '0' COMMENT '删除标记',
`tenant_id` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ' 租户id ',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='床位管理';
-- 待完善 区域设置表
CREATE TABLE `plat_region_setting`
(
`id` varchar(64) NOT NULL COMMENT 'id',
`name` varchar(128) NOT NULL COMMENT '区域名称',
`room_id` varchar(64) NOT NULL COMMENT '房间id',
`range_map` varchar(1024) NOT NULL COMMENT '区域地图 json',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建者',
`create_date` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新者',
`update_date` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int(1) DEFAULT '0' COMMENT '删除标记',
`tenant_id` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ' 租户id ',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='区域设置';
CREATE TABLE `plat_region_setting_location`
(
`id` varchar(64) NOT NULL COMMENT 'id',
`region_setting_id` varchar(64) NOT NULL COMMENT '区域设置Id',
`install_type` char(1) NOT NULL COMMENT '安装方式 0-顶装 1-侧装',
`toward` char(1) NOT NULL COMMENT '设备朝向 0-上 1-下 2-左 3-右',
`region_name` varchar(64) DEFAULT NULL COMMENT '区域名称',
`region_range` varchar(128) DEFAULT NULL COMMENT '区域定位',
`room_range` varchar(128) DEFAULT NULL COMMENT '房间门定位',
`equipment_range` varchar(128) DEFAULT NULL COMMENT '设备定位',
`equipment_id` varchar(64) DEFAULT NULL COMMENT '设备Id',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建者',
`create_date` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新者',
`update_date` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int(1) DEFAULT '0' COMMENT '删除标记',
`tenant_id` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ' 租户id ',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='区域设置定位';
package com.makeit.module.controller.space;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.dto.platform.space.PlatSpaceVO;
import com.makeit.service.platform.space.PlatSpaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -13,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Author:lzy
* @Date:2023/9/4 16:52
......@@ -33,5 +38,39 @@ public class PlatSpaceController {
return ApiResponseUtils.success();
}
@ApiOperation("编辑")
@PostMapping("edit")
public ApiResponseEntity<?> edit(@Validated @RequestBody PlatSpaceAddDTO dto) {
spaceService.edit(dto);
return ApiResponseUtils.success();
}
@ApiOperation("详情")
@PostMapping("view")
public ApiResponseEntity<PlatSpaceAddDTO> view(@RequestBody BaseIdDTO baseIdDTO) {
PlatSpaceAddDTO data = spaceService.view(baseIdDTO.getId());
return ApiResponseUtils.success(data);
}
@ApiOperation("删除")
@PostMapping("del")
public ApiResponseEntity<?> del(@RequestBody BaseIdDTO baseIdDTO) {
spaceService.del(baseIdDTO.getId());
return ApiResponseUtils.success();
}
@ApiOperation("树")
@PostMapping("tree")
public ApiResponseEntity<List<PlatSpaceVO>> tree(@RequestBody PlatSpaceQueryDTO dto) {
List<PlatSpaceVO> data = spaceService.tree(dto);
return ApiResponseUtils.success(data);
}
@ApiOperation("树-无权限")
@PostMapping("listTreeAuthIgnore")
public ApiResponseEntity<List<PlatSpaceVO>> listTreeAuthIgnore(@RequestBody PlatSpaceQueryDTO dto) {
List<PlatSpaceVO> data = spaceService.tree(dto);
return ApiResponseUtils.success(data);
}
}
package com.makeit.dto.platform.space;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.dto.BaseTenantDTO;
import com.makeit.enums.platform.space.PlatSpaceEnum;
import com.makeit.global.validator.DictEnum;
......@@ -19,15 +20,15 @@ import javax.validation.constraints.Size;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "PlatSpaceAddDTO对象", description = "空间添加")
public class PlatSpaceAddDTO extends BaseTenantDTO {
public class PlatSpaceAddDTO extends BaseIdDTO {
@NotBlank(message = "空间名称不能为空")
@Size(max = 50, message = "空间名称最长为50个字符")
@ApiModelProperty(value = "空间名称")
@ApiModelProperty(value = "空间名称",required = true)
private String name;
@DictEnum(em = PlatSpaceEnum.TypeEnum.class, message = "空间类型可选值为{m}")
@ApiModelProperty(value = "空间类型 数据字典 1:小区/社区/街道 2:楼栋 3:单元 4 楼层")
@ApiModelProperty(value = "空间类型 数据字典 1:小区/社区/街道 2:楼栋 3:单元 4 楼层",required = true)
private String type;
@ApiModelProperty(value = "上级空间")
......@@ -42,4 +43,7 @@ public class PlatSpaceAddDTO extends BaseTenantDTO {
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "上级全路径",required = true)
private String parentPath;
}
package com.makeit.dto.platform.space;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author:lzy
* @Date:2023/9/5 11:45
* @Describe:
*/
@Data
@ApiModel("PlatSpaceQueryDTO参数")
public class PlatSpaceQueryDTO {
@ApiModelProperty("空间名称")
private String name;
}
package com.makeit.dto.platform.space;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @Author:lzy
* @Date:2023/9/5 11:41
* @Describe:
*/
@Data
@ApiModel("PlatSpaceVO参数")
public class PlatSpaceVO extends BaseIdDTO {
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("父级Id")
private String parentId;
@ApiModelProperty("子集")
private List<PlatSpaceVO> child;
}
......@@ -43,5 +43,8 @@ public class PlatSpace extends BaseBusEntity {
@ApiModelProperty(value = "区")
private String district;
@ApiModelProperty(value = "上级全路径")
private String parentPath;
}
......@@ -364,7 +364,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
/**
* 校验机场
*/
checkUserOrg(platUser);
//checkUserOrg(platUser);
PlatUserLoginVO userLoginVO = BeanDtoVoUtils.convert(platUser, PlatUserLoginVO.class);
......
......@@ -2,8 +2,12 @@ package com.makeit.service.platform.space;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.dto.platform.space.PlatSpaceVO;
import com.makeit.entity.platform.space.PlatSpace;
import java.util.List;
/**
* @Author:lzy
* @Date:2023/8/31 16:17
......@@ -28,4 +32,18 @@ public interface PlatSpaceService extends IService<PlatSpace> {
* @param id
*/
void del(String id);
/**
* 树结构
* @param dto
* @return
*/
List<PlatSpaceVO> tree(PlatSpaceQueryDTO dto);
/**
* 详情
* @param id
* @return
*/
PlatSpaceAddDTO view(String id);
}
......@@ -3,6 +3,8 @@ package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.dto.platform.space.PlatSpaceVO;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException;
......@@ -13,6 +15,11 @@ import jodd.util.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author:lzy
* @Date:2023/8/31 16:17
......@@ -24,9 +31,15 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
private void check(PlatSpaceAddDTO dto){
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatSpace::getParentId,dto.getParentId());
queryWrapper.eq(PlatSpace::getName,dto.getName());
queryWrapper.ne(StringUtil.isNotEmpty(dto.getId()), PlatSpace::getId,dto.getId());
if(StringUtil.isEmpty(dto.getParentId())){
queryWrapper.isNull(PlatSpace::getParentId);
}else{
queryWrapper.eq(PlatSpace::getParentId,dto.getParentId());
}
if(this.count(queryWrapper) > 0){
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NAME_DUPLICATE);
}
......@@ -53,6 +66,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
space.setLatitude(dto.getLatitude());
space.setLongitude(dto.getLongitude());
space.setParentId(dto.getParentId());
space.setParentPath(dto.getParentPath());
this.updateById(space);
}
......@@ -62,4 +76,61 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
this.removeById(id);
}
@Override
public List<PlatSpaceVO> tree(PlatSpaceQueryDTO dto) {
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()),PlatSpace::getName,dto.getName());
List<PlatSpace> list = this.list(queryWrapper);
//父级
List<PlatSpace> listParent = list.stream().filter(item->StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
//子集
List<PlatSpace> listChild = list.stream().filter(item->item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpace>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpace::getParentId));
List<PlatSpaceVO> data = new ArrayList<>();
for(PlatSpace space:listParent){
PlatSpaceVO vo = convertToVO(space);
vo = child(vo,map);
data.add(vo);
}
return data;
}
@Override
public PlatSpaceAddDTO view(String id) {
PlatSpace space = getById(id);
PlatSpaceAddDTO data = BeanDtoVoUtils.convert(space,PlatSpaceAddDTO.class);
return data;
}
private PlatSpaceVO child(PlatSpaceVO vo,Map<String,List<PlatSpace>> map){
if(!map.containsKey(vo.getId())){
return vo;
}
List<PlatSpace> list = map.get(vo.getId());
List<PlatSpaceVO> listChild = new ArrayList<>();
for(PlatSpace item:list){
PlatSpaceVO dto = convertToVO(item);
this.child(dto,map);
listChild.add(dto);
}
vo.setChild(listChild);
return vo;
}
private PlatSpaceVO convertToVO(PlatSpace space){
PlatSpaceVO vo = new PlatSpaceVO();
vo.setName(space.getName());
vo.setParentId(space.getId());
vo.setId(space.getId());
return vo;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment