资源管理优化

This commit is contained in:
zhongchangyuyu 2025-04-25 09:12:09 +08:00
parent fde29b7072
commit b8959cbaac
158 changed files with 2036 additions and 3157 deletions

1
.idea/compiler.xml generated
View File

@ -2,6 +2,7 @@
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />

View File

@ -1,11 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="rdc-releases" />
<option name="name" value="rdc-releases" />
<option name="url" value="http://mirrors.cloud.tencent.com/nexus/repository/maven-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="edas-oss-central" />
<option name="name" value="taobao mirror central" />
<option name="url" value="https://maven.aliyun.com/repository/public" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="rdc-snapshots" />
<option name="name" value="rdc-snapshots" />
<option name="url" value="http://mirrors.cloud.tencent.com/nexus/repository/maven-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="public" />
<option name="name" value="public" />
<option name="url" value="https://maven.aliyun.com/repository/public" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
@ -16,5 +36,10 @@
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://maven.aliyun.com/repository/public" />
</remote-repository>
</component>
</project>

10
pom.xml
View File

@ -186,6 +186,16 @@
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies>
<dependencyManagement>

View File

@ -10,34 +10,35 @@ public enum BusinessStatusEnum {
/** 不招商 */
NO_BUSINESS("2","不招商");
private final String key;
private final String value;
public String getKey() {
return key;
}
private final String key;
public String getValue() {
return value;
}
BusinessStatusEnum(String key, String value) {
this.value = value;
this.key = key;
}
public String getValue() {
return value;
}
/**
* 根据值获取枚举
*
* @param value 枚举值
* @return 枚举
*/
public static BusinessStatusEnum getByValue(String value) {
public static String getByValue(String value) {
for (BusinessStatusEnum status : values()) {
if (status.getKey().equals(value)) {
return status;
if (status.getValue().equals(value)) {
return status.getKey();
}
}
return null;
@ -59,10 +60,15 @@ public enum BusinessStatusEnum {
/**
* 校验枚举值是否有效
*
* @param value 枚举值
* @param key 枚举值
* @return 是否有效
*/
public static boolean isValid(String value) {
return getByValue(value) != null;
public static boolean isValid(String key) {
for (BusinessStatusEnum status : values()) {
if (status.getKey().equals(key)) {
return true;
}
}
return false;
}
}

View File

@ -19,6 +19,8 @@ public enum DecorationStatusEnum {
/** 豪装 */
LUXURY("5","豪装");
private final String key;
private final String value;
@ -26,27 +28,25 @@ public enum DecorationStatusEnum {
return key;
}
private final String key;
public String getValue() {
return value;
}
DecorationStatusEnum(String key, String value) {
this.value = value;
this.key = key;
}
public String getValue() {
return value;
}
/**
* 根据值获取枚举
*
* @param value 枚举值
* @return 枚举
*/
public static DecorationStatusEnum getByValue(String value) {
public static String getByValue(String value) {
for (DecorationStatusEnum status : values()) {
if (status.getKey().equals(value)) {
return status;
if (status.getValue().equals(value)) {
return status.getKey();
}
}
return null;
@ -68,10 +68,15 @@ public enum DecorationStatusEnum {
/**
* 校验枚举值是否有效
*
* @param value 枚举值
* @param key 枚举值
* @return 是否有效
*/
public static boolean isValid(String value) {
return getByValue(value) != null;
public static boolean isValid(String key) {
for (DecorationStatusEnum status : values()) {
if (status.getKey().equals(key)) {
return true;
}
}
return false;
}
}

View File

@ -10,46 +10,65 @@ public enum ImageTypeEnum {
/** 户型图 */
FLOOR_PLAN("2","户型图");
private final String key;
private final String value;
public String getKey() {
return key;
}
private final String key;
public String getValue() {
return value;
}
ImageTypeEnum(String key, String value) {
this.value = value;
this.key = key;
}
public String getValue() {
return value;
}
/**
* 根据值获取枚举
*
* @param value 枚举值
* @return 枚举
*/
public static ImageTypeEnum getByValue(String value) {
for (ImageTypeEnum type : values()) {
if (type.getKey().equals(value)) {
return type;
public static String getByValue(String value) {
for (ImageTypeEnum status : values()) {
if (status.getValue().equals(value)) {
return status.getKey();
}
}
return null;
}
/**
* 根据枚举获取值
*
* @param key
* @return 枚举
*/
public static String getValue(String key) {
for (ImageTypeEnum status : values()) {
if (status.getKey().equals(key)) {
return status.getValue();
}
}
return null;
}
/**
* 校验枚举值是否有效
*
* @param value 枚举值
* @param key 枚举值
* @return 是否有效
*/
public static boolean isValid(String value) {
return getByValue(value) != null;
public static boolean isValid(String key) {
for (ImageTypeEnum status : values()) {
if (status.getKey().equals(key)) {
return true;
}
}
return false;
}
}

View File

@ -5,42 +5,43 @@ package com.eden.room.common.enums;
*/
public enum PriceUnitEnum {
/** 元/㎡/天 */
PRICE_UNIT_ENUM_1("1","元/㎡/"),
/** 元/㎡·天 */
PRICE_UNIT_ENUM_1("1","元/m²·"),
/** 元/㎡/月 */
PRICE_UNIT_ENUM_2("2","元/㎡/"),
/** 元/㎡·月 */
PRICE_UNIT_ENUM_2("2","元/m²·"),
PRICE_UNIT_ENUM_3("3","元/月"),
PRICE_UNIT_ENUM_4("4","元/天"),
PRICE_UNIT_ENUM_5("5","元/年");
private final String key;
private final String value;
public String getKey() {
return key;
}
private final String key;
public String getValue() {
return value;
}
PriceUnitEnum(String key, String value) {
this.value = value;
this.key = key;
}
public String getValue() {
return value;
}
/**
* 根据值获取枚举
*
* @param value 枚举值
* @return 枚举
*/
public static PriceUnitEnum getByValue(String value) {
public static String getByValue(String value) {
for (PriceUnitEnum status : values()) {
if (status.getValue().equals(value)) {
return status;
return status.getKey();
}
}
return null;
@ -62,10 +63,15 @@ public enum PriceUnitEnum {
/**
* 校验枚举值是否有效
*
* @param value 枚举值
* @param key 枚举值
* @return 是否有效
*/
public static boolean isValid(String value) {
return getByValue(value) != null;
public static boolean isValid(String key) {
for (PriceUnitEnum status : values()) {
if (status.getKey().equals(key)) {
return true;
}
}
return false;
}
}

View File

@ -13,46 +13,65 @@ public enum PropertyNatureEnum {
/** 自持+承租 */
MIXED("3","自持+承租");
private final String key;
private final String value;
public String getKey() {
return key;
}
private final String key;
public String getValue() {
return value;
}
PropertyNatureEnum(String key, String value) {
this.value = value;
this.key = key;
}
public String getValue() {
return value;
}
/**
* 根据值获取枚举
*
* @param value 枚举值
* @return 枚举
*/
public static PropertyNatureEnum getByValue(String value) {
for (PropertyNatureEnum nature : values()) {
if (nature.getKey().equals(value)) {
return nature;
public static String getByValue(String value) {
for (PropertyNatureEnum status : values()) {
if (status.getValue().equals(value)) {
return status.getKey();
}
}
return null;
}
/**
* 根据枚举获取值
*
* @param key
* @return 枚举
*/
public static String getValue(String key) {
for (PropertyNatureEnum status : values()) {
if (status.getKey().equals(key)) {
return status.getValue();
}
}
return null;
}
/**
* 校验枚举值是否有效
*
* @param value 枚举值
* @param key 枚举值
* @return 是否有效
*/
public static boolean isValid(String value) {
return getByValue(value) != null;
public static boolean isValid(String key) {
for (PropertyNatureEnum status : values()) {
if (status.getKey().equals(key)) {
return true;
}
}
return false;
}
}

View File

@ -13,34 +13,34 @@ public enum RentalStatusEnum {
/** 下架 */
private final String key;
private final String value;
public String getKey() {
return key;
}
private final String key;
public String getValue() {
return value;
}
RentalStatusEnum(String key, String value) {
this.value = value;
this.key = key;
}
public String getValue() {
return value;
}
/**
* 根据值获取枚举
*
* @param value 枚举值
* @return 枚举
*/
public static RentalStatusEnum getByValue(String value) {
public static String getByValue(String value) {
for (RentalStatusEnum status : values()) {
if (status.getKey().equals(value)) {
return status;
if (status.getValue().equals(value)) {
return status.getKey();
}
}
return null;
@ -62,10 +62,15 @@ public enum RentalStatusEnum {
/**
* 校验枚举值是否有效
*
* @param value 枚举值
* @param key 枚举值
* @return 是否有效
*/
public static boolean isValid(String value) {
return getByValue(value) != null;
public static boolean isValid(String key) {
for (RentalStatusEnum status : values()) {
if (status.getKey().equals(key)) {
return true;
}
}
return false;
}
}

View File

@ -13,48 +13,65 @@ public enum RoomStatusEnum {
/** 私密 */
PRIVATE("3","私密");
;
private final String key;
private final String value;
public String getKey() {
return key;
}
private final String key;
RoomStatusEnum(String key,String value) {
this.key = key;
this.value = value;
}
public String getValue() {
return value;
}
RoomStatusEnum(String key, String value) {
this.value = value;
this.key = key;
}
/**
* 根据值获取枚举
*
* @param value 枚举值
* @return 枚举
*/
public static RoomStatusEnum getByValue(String value) {
public static String getByValue(String value) {
for (RoomStatusEnum status : values()) {
if (status.getKey().equals(value)) {
return status;
if (status.getValue().equals(value)) {
return status.getKey();
}
}
return null;
}
/**
* 根据枚举获取值
*
* @param key
* @return 枚举
*/
public static String getValue(String key) {
for (RoomStatusEnum status : values()) {
if (status.getKey().equals(key)) {
return status.getValue();
}
}
return null;
}
/**
* 校验枚举值是否有效
*
* @param value 枚举值
* @param key 枚举值
* @return 是否有效
*/
public static boolean isValid(String value) {
return getByValue(value) != null;
public static boolean isValid(String key) {
for (RoomStatusEnum status : values()) {
if (status.getKey().equals(key)) {
return true;
}
}
return false;
}
}

View File

@ -28,45 +28,65 @@ public enum RoomTypeEnum {
/** 其他 */
OTHER("8","其他");
private final String value;
private final String key;
private final String value;
public String getKey() {
return key;
}
public String getValue() {
return value;
}
RoomTypeEnum(String key, String value) {
this.value = value;
this.key = key;
}
public String getValue() {
return value;
}
/**
* 根据值获取枚举
*
* @param value 枚举值
* @return 枚举
*/
public static RoomTypeEnum getByValue(String value) {
for (RoomTypeEnum type : values()) {
if (type.getKey().equals(value)) {
return type;
public static String getByValue(String value) {
for (RoomTypeEnum status : values()) {
if (status.getValue().equals(value)) {
return status.getKey();
}
}
return null;
}
/**
* 根据枚举获取值
*
* @param key
* @return 枚举
*/
public static String getValue(String key) {
for (RoomTypeEnum status : values()) {
if (status.getKey().equals(key)) {
return status.getValue();
}
}
return null;
}
/**
* 校验枚举值是否有效
*
* @param value 枚举值
* @param key 枚举值
* @return 是否有效
*/
public static boolean isValid(String value) {
return getByValue(value) != null;
public static boolean isValid(String key) {
for (RoomTypeEnum status : values()) {
if (status.getKey().equals(key)) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,71 @@
package com.eden.room.common.enums;
public enum VirtualFlagEnum {
/** 是 */
YES("1",""),
/** 否 */
NO("0","");
private final String key;
private final String value;
public String getKey() {
return key;
}
public String getValue() {
return value;
}
VirtualFlagEnum(String key, String value) {
this.value = value;
this.key = key;
}
/**
* 根据值获取枚举
*
* @param value 枚举值
* @return 枚举
*/
public static String getByValue(String value) {
for (VirtualFlagEnum status : values()) {
if (status.getValue().equals(value)) {
return status.getKey();
}
}
return null;
}
/**
* 根据枚举获取值
*
* @param key
* @return 枚举
*/
public static String getValue(String key) {
for (VirtualFlagEnum status : values()) {
if (status.getKey().equals(key)) {
return status.getValue();
}
}
return null;
}
/**
* 校验枚举值是否有效
*
* @param key 枚举值
* @return 是否有效
*/
public static boolean isValid(String key) {
for (VirtualFlagEnum status : values()) {
if (status.getKey().equals(key)) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,71 @@
package com.eden.room.common.enums;
public enum WholeFloorFlagEnum {
/** 是 */
YES("1",""),
/** 否 */
NO("0","");
private final String key;
private final String value;
public String getKey() {
return key;
}
public String getValue() {
return value;
}
WholeFloorFlagEnum(String key, String value) {
this.value = value;
this.key = key;
}
/**
* 根据值获取枚举
*
* @param value 枚举值
* @return 枚举
*/
public static String getByValue(String value) {
for (WholeFloorFlagEnum status : values()) {
if (status.getValue().equals(value)) {
return status.getKey();
}
}
return null;
}
/**
* 根据枚举获取值
*
* @param key
* @return 枚举
*/
public static String getValue(String key) {
for (WholeFloorFlagEnum status : values()) {
if (status.getKey().equals(key)) {
return status.getValue();
}
}
return null;
}
/**
* 校验枚举值是否有效
*
* @param key 枚举值
* @return 是否有效
*/
public static boolean isValid(String key) {
for (WholeFloorFlagEnum status : values()) {
if (status.getKey().equals(key)) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,32 @@
package com.eden.room.constant;
/**
* 房源相关常量
*/
public class RoomConstants {
// Excel相关常量
public static final String EXCEL_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
public static final String UTF8 = "utf-8";
public static final String EXCEL_EXTENSION = ".xlsx";
public static final int EXCEL_DEFAULT_COLUMN_WIDTH = 15;
public static final String EXCEL_DATE_FORMAT = "yyyy-MM-dd";
public static final int EXCEL_HEADER_ROW_NUMBER = 1;
public static final long MAX_FILE_SIZE = 1024 * 1024; // 1MB
public static final String CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
public static final String CHARSET = "utf-8";
private static final String EXPORT_FILE_PREFIX = "房源信息_";
// 文件相关常量
public static final String ROOM_IMPORT_TEMPLATE = "room_import.xlsx";
public static final String ROOM_IMPORT_RESULT = "room_import_result.xlsx";
// 业务相关常量
public static final String DEL_FLAG_NORMAL = "0";
public static final String DEFAULT_USERNAME = "admin";
public static final int BATCH_SIZE = 500;
public static final int IMPORT_HEADER_ROW_INDEX = 2;
}

View File

@ -53,7 +53,7 @@ public class BuildingController extends BaseController {
/**
* 新增楼宇信息
*/
@PostMapping
@PostMapping("/add")
public Result<Integer> add(@RequestBody Building building) {
if (buildingService.checkBuildingNameExists(building)) {
return error("新增楼宇'" + building.getBuildingName() + "'失败,楼宇名称已存在");
@ -65,7 +65,7 @@ public class BuildingController extends BaseController {
/**
* 修改楼宇信息
*/
@PutMapping
@PostMapping("/edit")
public Result<Integer> edit(@RequestBody Building building) {
int rows = buildingService.updateBuilding(building);
return toResult(rows);
@ -74,14 +74,10 @@ public class BuildingController extends BaseController {
/**
* 删除楼宇信息
*/
@DeleteMapping("/{ids}")
public Result<Integer> remove(@PathVariable String[] ids) {
try {
int rows = buildingService.deleteBuildingByIds(ids);
return toResult(rows);
} catch (RuntimeException e) {
return error(e.getMessage());
}
@PostMapping("/remove/{ids}")
public Result<Integer> remove(@PathVariable List<Long> ids) {
int rows = buildingService.deleteBuildingByIds(ids);
return toResult(rows);
}
/**
* 查询楼宇信息列表

View File

@ -50,7 +50,7 @@ public class FloorController extends BaseController {
/**
* 新增楼层信息
*/
@PostMapping
@PostMapping("/add")
public Result<Integer> add(@RequestBody Floor floor) {
int rows = floorService.insertFloor(floor);
return toResult(rows);
@ -59,7 +59,7 @@ public class FloorController extends BaseController {
/**
* 修改楼层信息
*/
@PutMapping
@PostMapping("/edit")
public Result<Integer> edit(@RequestBody Floor floor) {
int rows = floorService.updateFloor(floor);
return toResult(rows);
@ -68,14 +68,10 @@ public class FloorController extends BaseController {
/**
* 删除楼层信息
*/
@DeleteMapping("/{ids}")
public Result<Integer> remove(@PathVariable String[] ids) {
try {
int rows = floorService.deleteFloorByIds(ids);
return toResult(rows);
} catch (RuntimeException e) {
return error(e.getMessage());
}
@PostMapping("/remove/{ids}")
public Result<Integer> remove(@PathVariable List<Long> ids) {
int rows = floorService.deleteFloorByIds(ids);
return toResult(rows);
}
/**

View File

@ -50,7 +50,7 @@ public class ProjectController extends BaseController {
/**
* 新增项目信息
*/
@PostMapping
@PostMapping("/add")
public Result<Integer> add(@RequestBody Project project) {
// 校验项目名称是否唯一
if (projectService.checkProjectNameExists(project)) {
@ -63,12 +63,12 @@ public class ProjectController extends BaseController {
/**
* 修改项目信息
*/
@PutMapping
@PostMapping("/edit")
public Result<Integer> edit(@RequestBody Project project) {
// // 校验项目名称是否唯一
// if (projectService.checkProjectNameExists(project)) {
// return error("修改项目'" + project.getProjectName() + "'失败,项目名称已存在");
// }
// 校验项目名称是否唯一
if (projectService.checkProjectNameExists(project)) {
return error("修改项目'" + project.getProjectName() + "'失败,项目名称已存在");
}
int rows = projectService.updateProject(project);
return toResult(rows);
}
@ -76,7 +76,7 @@ public class ProjectController extends BaseController {
/**
* 删除项目信息
*/
@DeleteMapping("/{ids}")
@PostMapping("/remove/{ids}")
public Result<Integer> remove(@PathVariable String[] ids) {
try {
int rows = projectService.deleteProjectByIds(ids);

View File

@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.List;
import java.util.Map;
@ -42,25 +43,8 @@ public class RoomController {
public Result<PageInfo<Room>> list(RoomQueryDTO queryDTO,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize) {
Room room = new Room();
if (queryDTO != null) {
// 设置查询条件
room.setRoomNumber(queryDTO.getRoomNumber());
room.setProjectId(queryDTO.getProjectId());
room.setBuildingId(queryDTO.getBuildingId());
room.setFloorId(queryDTO.getFloorId());
room.setRoomType(queryDTO.getRoomType());
room.setIsVirtual(queryDTO.getIsVirtual());
room.setBusinessStatus(queryDTO.getBusinessStatus());
// 校验枚举值
if (StringUtils.isNotEmpty(queryDTO.getRoomType()) && !RoomTypeEnum.isValid(queryDTO.getRoomType())) {
return Result.error("无效的房源类型");
}
}
PageHelper.startPage(pageNum, pageSize);
List<Room> list = roomService.selectRoomList(room);
List<Room> list = roomService.selectRoomList(queryDTO);
return Result.success(new PageInfo<>(list));
}
@ -68,7 +52,7 @@ public class RoomController {
* 获取房源详情
*/
@GetMapping("/{id}")
public Result<RoomDTO> getInfo(@PathVariable("id") @NotBlank(message = "房源ID不能为空") Long id) {
public Result<RoomDTO> getInfo(@PathVariable("id") @NotNull(message = "房源ID不能为空") Long id) {
RoomDTO roomDTO = roomService.selectRoomDetailById(id);
return Result.success(roomDTO);
}
@ -76,42 +60,15 @@ public class RoomController {
/**
* 新增房源
*/
@PostMapping
@PostMapping("/add")
public Result<Integer> add(@RequestBody @Valid RoomDTO roomDTO) {
// 校验枚举值
if (StringUtils.isNotEmpty(roomDTO.getRoomType()) && !RoomTypeEnum.isValid(roomDTO.getRoomType())) {
return Result.error("无效的房源类型");
}
if (StringUtils.isNotEmpty(roomDTO.getRoomStatus()) && !RoomStatusEnum.isValid(roomDTO.getRoomStatus())) {
return Result.error("无效的房源状态");
}
if (StringUtils.isNotEmpty(roomDTO.getPropertyNature()) && !PropertyNatureEnum.isValid(roomDTO.getPropertyNature())) {
return Result.error("无效的产权性质");
}
// 校验招商信息枚举值
if (roomDTO.getBusinessInfo() != null) {
if (StringUtils.isNotEmpty(roomDTO.getBusinessInfo().getRentalStatus()) &&
!RentalStatusEnum.isValid(roomDTO.getBusinessInfo().getRentalStatus())) {
return Result.error("无效的租赁状态");
}
if (StringUtils.isNotEmpty(roomDTO.getBusinessInfo().getBusinessStatus()) &&
!BusinessStatusEnum.isValid(roomDTO.getBusinessInfo().getBusinessStatus())) {
return Result.error("无效的招商状态");
}
if (StringUtils.isNotEmpty(roomDTO.getBusinessInfo().getDecorationStatus()) &&
!DecorationStatusEnum.isValid(roomDTO.getBusinessInfo().getDecorationStatus())) {
return Result.error("无效的装修情况");
}
}
return Result.success(roomService.insertRoom(roomDTO));
}
/**
* 修改房源
*/
@PutMapping
@PostMapping("/edit")
public Result<Integer> edit(@RequestBody @Valid RoomDTO roomDTO) {
if (roomDTO.getId() == null) {
return Result.error("房源ID不能为空");
@ -125,8 +82,8 @@ public class RoomController {
/**
* 删除房源
*/
@DeleteMapping("/{id}")
public Result<Integer> remove(@PathVariable("id") @NotBlank(message = "房源ID不能为空") Long id) {
@PostMapping("/remove/{id}")
public Result<Integer> remove(@PathVariable("id") @NotNull(message = "房源ID不能为空") Long id) {
try {
return Result.success(roomService.deleteRoomById(id));
} catch (Exception e) {
@ -134,22 +91,10 @@ public class RoomController {
}
}
/**
* 批量删除房源,无这个功能
*/
@DeleteMapping("/batch")
public Result<Integer> removeBatch(@RequestBody @NotEmpty(message = "房源ID列表不能为空") String[] ids) {
try {
return Result.success(roomService.deleteRoomByIds(ids));
} catch (Exception e) {
return Result.error(e.getMessage());
}
}
/**
* 修改房源租赁状态
*/
@PutMapping("/status/{id}/{rentalStatus}")
@PostMapping("/status/{id}/{rentalStatus}")
public Result<Integer> updateRentalStatus(
@PathVariable("id") @NotBlank(message = "房源ID不能为空") Long id,
@PathVariable("rentalStatus") @NotBlank(message = "租赁状态不能为空") String rentalStatus) {
@ -179,7 +124,7 @@ public class RoomController {
try {
roomService.updateRoomRentalStatus(id, rentalStatus);
return Result.success("修改成功", "000000");
return Result.success();
} catch (Exception e) {
return Result.error(e.getMessage(), "1");
}

View File

@ -1,34 +1,37 @@
package com.eden.room.controller;
import com.eden.room.common.Result;
import com.eden.room.domain.RoomExport;
import com.alibaba.excel.EasyExcel;
import com.eden.room.constant.RoomConstants;
import com.eden.room.domain.dto.RoomExportDTO;
import com.eden.room.domain.dto.RoomImportDTO;
import com.eden.room.domain.dto.RoomQueryDTO;
import com.eden.room.service.IBuildingService;
import com.eden.room.service.IFloorService;
import com.eden.room.service.IProjectService;
import com.eden.room.service.IRoomService;
import com.eden.room.service.RoomTemplateService;
import com.eden.room.utils.ExcelUtil;
import com.eden.room.utils.excel.BigDecimalConverter;
import com.eden.room.utils.excel.ExcelImportListener;
import com.eden.room.utils.excel.RoomImportListener;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import org.springframework.validation.Validator;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
/**
* 房源模板下载控制器
@ -37,15 +40,24 @@ import java.util.Map;
@RestController
@RequestMapping("/room/template")
public class RoomTemplateController {
private static final Logger log = LoggerFactory.getLogger(RoomTemplateController.class);
@Autowired
private RoomTemplateService roomTemplateService;
@Autowired
private IRoomService roomService;
@Autowired
private IProjectService projectService;
@Autowired
private IBuildingService buildingService;
@Autowired
private IFloorService floorService;
@Autowired
private Validator validator;
/**
* 下载房源导入模板
*
@ -56,18 +68,18 @@ public class RoomTemplateController {
public void downloadTemplate(HttpServletResponse response) throws IOException {
try {
// 设置要下载的文件的名称
String fileName = "room_import.xlsx";
String fileName = RoomConstants.ROOM_IMPORT_TEMPLATE;
// 设置响应头
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setContentType(RoomConstants.CONTENT_TYPE);
response.setCharacterEncoding(RoomConstants.CHARSET);
String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
response.setHeader(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=" + encodedFileName + ";filename*=utf-8''" + encodedFileName);
// 获取模板文件资源
ClassPathResource resource = new ClassPathResource("templates/excel/" + fileName);
// 将文件内容写入响应流
try (InputStream inputStream = resource.getInputStream();
OutputStream outputStream = response.getOutputStream()) {
@ -82,7 +94,7 @@ public class RoomTemplateController {
// 如果发生异常写入错误响应
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.setCharacterEncoding(RoomConstants.CHARSET);
response.getWriter().write("{\"code\":\"1\",\"message\":\"下载模板文件失败: " + e.getMessage() + "\"}");
}
}
@ -90,45 +102,35 @@ public class RoomTemplateController {
/**
* 批量导出房源信息
*
* @param ids 房源ID数组
*
* @param queryDTO 房源ID数组
* @param response HTTP响应对象
*/
@ApiOperation(value = "批量导出房源", notes = "根据房源ID数组批量导出房源详细信息为Excel文件")
@ApiImplicitParam(name = "ids", value = "房源ID数组", required = true, dataType = "List")
@ApiOperation(value = "批量导出房源", notes = "根据查询条件批量导出房源详细信息为Excel文件")
@ApiImplicitParam(name = "queryDTO", value = "queryDTO", required = true, dataType = "List")
@PostMapping("/export/batch")
public void exportRoomBatch(@RequestBody List<String> ids, HttpServletResponse response) {
public void exportRoomBatch(@RequestBody RoomQueryDTO queryDTO, HttpServletResponse response) {
try {
if (ids == null || ids.isEmpty()) {
throw new IllegalArgumentException("房源ID不能为空");
}
// 将List<String>转换为String[]
String[] idArray = ids.toArray(new String[0]);
// 根据ID列表查询房源列表
List<RoomExportDTO> list = roomService.exportRoomByIds(idArray);
List<RoomExportDTO> list = roomService.exportRoom(queryDTO);
if (list.isEmpty()) {
throw new IllegalArgumentException("未找到指定的房源信息");
}
// 设置要下载的文件名称
String fileName = "房源信息_" + System.currentTimeMillis() + ".xlsx";
// 转换为符合导出模板的数据结构
List<RoomExport> exportData = roomTemplateService.convertToRoomImportList(list);
// 设置响应头
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
response.setHeader(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=" + encodedFileName + ";filename*=utf-8''" + encodedFileName);
// 导出Excel
ExcelUtil<RoomExport> excelUtil = new ExcelUtil<>(RoomExport.class);
excelUtil.exportExcel(exportData, "房源信息", response.getOutputStream());
ExcelUtil<RoomExportDTO> excelUtil = new ExcelUtil<>(RoomExportDTO.class);
excelUtil.exportExcel(list, "房源信息", response.getOutputStream());
} catch (Exception e) {
log.error("批量导出房源信息失败", e);
@ -146,7 +148,7 @@ public class RoomTemplateController {
/**
* 批量导入房源数据
*
*
* @param file 导入房源的Excel文件必须遵循指定的模板格式
* @param response HTTP响应对象
*/
@ -154,47 +156,62 @@ public class RoomTemplateController {
@ApiImplicitParam(name = "file", value = "Excel文件", required = true, dataType = "MultipartFile")
@PostMapping("/import")
public void importRoom(@RequestParam("file") MultipartFile file, HttpServletResponse response) throws IOException {
if (file.isEmpty()) {
// 校验文件
validateFile(file);
log.info("开始导入Excel文件: {}, 大小: {} bytes", file.getOriginalFilename(), file.getSize());
// 创建导入监听器
RoomImportListener listener = new RoomImportListener(validator, roomService, projectService, buildingService, floorService);
// 读取Excel文件添加自定义转换器
EasyExcel.read(file.getInputStream(), RoomImportDTO.class, listener)
.registerConverter(new BigDecimalConverter())
.headRowNumber(1)
.sheet()
.doRead();
// 获取错误信息
Boolean successFlag = listener.getSuccessFlag();
if (successFlag) {
// 如果没有错误直接返回成功
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.getWriter().write("{\"code\":\"0\",\"message\":\"导入成功\"}");
return;
}
// 如果有错误生成带错误信息的Excel文件
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String encodedFileName = URLEncoder.encode("room_import_result.xlsx", StandardCharsets.UTF_8.toString());
response.setHeader("Content-Disposition", "attachment;filename=" + encodedFileName);
// 写入带错误信息的Excel文件
EasyExcel.write(response.getOutputStream(), RoomImportDTO.class)
.sheet("导入结果")
.doWrite(listener.getDataList());
}
/**
* 校验文件
*/
private void validateFile(MultipartFile file) {
if (file == null || file.isEmpty()) {
throw new RuntimeException("请选择要上传的文件");
}
// 校验文件大小
if (file.getSize() > RoomConstants.MAX_FILE_SIZE) {
throw new RuntimeException("文件大小不能超过1MB");
}
// 校验文件格式
String filename = file.getOriginalFilename();
if (filename == null || !(filename.toLowerCase().endsWith(".xls") || filename.toLowerCase().endsWith(".xlsx"))) {
throw new RuntimeException("文件格式不正确请上传Excel文件");
}
log.info("开始导入Excel文件: {}, 大小: {} bytes", filename, file.getSize());
try {
// 检查文件大小10MB限制
if (file.getSize() > 10 * 1024 * 1024) {
throw new RuntimeException("文件过大请控制在10MB以内");
}
Map<String, Object> result = roomService.importRoom(file);
// 获取Excel数据流
byte[] excelBytes = (byte[]) result.get("excelBytes");
if (excelBytes != null && excelBytes.length > 0) {
// 设置响应头
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String encodedFileName = URLEncoder.encode("room_import_result.xlsx", StandardCharsets.UTF_8.toString());
response.setHeader(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=" + encodedFileName + ";filename*=utf-8''" + encodedFileName);
// 将数据流写入响应
try (OutputStream outputStream = response.getOutputStream()) {
outputStream.write(excelBytes);
outputStream.flush();
}
} else {
throw new RuntimeException("生成结果文件失败");
}
} catch (Exception e) {
log.error("导入房源失败", e);
throw new RuntimeException("导入失败:" + e.getMessage());
}
}
}

View File

@ -16,7 +16,7 @@ import javax.persistence.Id;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Table(name = "TB_BUILDING")
@Table(name = "TB_RES_BUILDING")
public class Building extends BaseEntity {
private static final long serialVersionUID = 1L;
@ -25,10 +25,6 @@ public class Building extends BaseEntity {
@Column(name = "id")
private Long id;
/** 租户ID */
@Column(name = "tenant_id")
//@NotBlank(message = "租户ID不能为空")
private String tenantId;
/** 所属项目ID */
@Column(name = "project_id")
@ -179,13 +175,7 @@ public class Building extends BaseEntity {
this.id = id;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public String getProjectId() {
return projectId;

View File

@ -13,7 +13,7 @@ import javax.persistence.Id;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Table(name = "TB_FLOOR")
@Table(name = "TB_RES_FLOOR")
public class Floor extends BaseEntity {
private static final long serialVersionUID = 1L;
@ -22,10 +22,6 @@ public class Floor extends BaseEntity {
@Column(name = "id")
private Long id;
/** 租户ID */
@Column(name = "tenant_id")
private String tenantId;
/** 所属楼宇ID */
@Column(name = "building_id")
@NotBlank(message = "所属楼宇ID不能为空")

View File

@ -13,11 +13,11 @@ import javax.persistence.Id;
/**
* 项目信息实体类
* 对应数据库表: TB_PROJECT
* 对应数据库表: TB_RES_PROJECT
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Table(name = "TB_PROJECT")
@Table(name = "TB_RES_PROJECT")
public class Project extends BaseEntity {
private static final long serialVersionUID = 1L;
@ -27,10 +27,6 @@ public class Project extends BaseEntity {
@NotBlank(message = "项目ID不能为空")
private String id;
/** 租户ID */
@Column(name = "tenant_id")
private String tenantId;
/**
* 项目类型写字楼产业园区商场联合办公公寓小区社区养老
*/
@ -99,13 +95,7 @@ public class Project extends BaseEntity {
this.id = id;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public String getProjectType() {
return projectType;

View File

@ -12,8 +12,8 @@ import org.springframework.format.annotation.DateTimeFormat;
/**
* 房源基本信息实体类 TB_ROOM
*
* 房源基本信息实体类 TB_RES_ROOM
*
* @author eden
* @date 2023-08-01
*/
@ -27,7 +27,7 @@ public class Room extends BaseEntity
/** 项目ID */
@Excel(name = "项目ID")
private String projectId;
/** 项目名称 */
@Excel(name = "项目名称")
private String projectName;
@ -35,7 +35,7 @@ public class Room extends BaseEntity
/** 楼宇ID */
@Excel(name = "楼宇ID")
private Long buildingId;
/** 楼宇名称 */
@Excel(name = "楼宇名称")
private String buildingName;
@ -43,7 +43,7 @@ public class Room extends BaseEntity
/** 楼层ID */
@Excel(name = "楼层ID")
private Long floorId;
/** 楼层名称 */
@Excel(name = "楼层名称")
private String floorName;
@ -55,7 +55,7 @@ public class Room extends BaseEntity
/** 房源数字编号 */
@Excel(name = "房间数字编号")
private String roomDigitalNumber;
/** 房源管理编号 */
@Excel(name = "房源管理编号")
private String roomManageNumber;
@ -65,7 +65,7 @@ public class Room extends BaseEntity
private String roomName;
/** 房源类型 */
@Excel(name = "房源类型", readConverterExp = "1=办公,2=商业,3=仓储,4=厂房,5=多经,6=公寓,7=住宅,8=其他")
@Excel(name = "房源类型")
private String roomType;
/** 楼层 */
@ -73,52 +73,52 @@ public class Room extends BaseEntity
private String floor;
/** 是否整层 */
@Excel(name = "是否整层", readConverterExp = "0=否,1=是")
@Excel(name = "是否整层")
private String isWholeFloor;
/** 建筑面积 */
@Excel(name = "建筑面积")
private BigDecimal buildingArea;
/** 计租面积 */
@Excel(name = "计租面积")
private BigDecimal rentalArea;
/** 计费面积 */
@Excel(name = "计费面积")
private BigDecimal billingArea;
/** 套内面积 */
@Excel(name = "套内面积")
private BigDecimal innerArea;
/** 是否虚拟房源 */
@Excel(name = "是否虚拟房源", readConverterExp = "0=否,1=是")
@Excel(name = "是否虚拟房源")
private String isVirtual;
/** 房源交付时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "房源交付时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date deliveryTime;
/** 绑定业主ID */
@Excel(name = "绑定业主ID")
private Long ownerId;
/** 产权性质 */
@Excel(name = "产权性质", readConverterExp = "1=自持,2=承租,3=自持+承租")
@Excel(name = "产权性质")
private String propertyNature;
/** 层高(米) */
@Excel(name = "层高(米)")
private BigDecimal height;
/** 荷载值 */
@Excel(name = "荷载值")
private BigDecimal loadValue;
/** 房源状态 */
@Excel(name = "房源状态", readConverterExp = "1=公开,2=关闭,3=私密")
@Excel(name = "房源状态")
private String roomStatus;
/** 房源面积 */
@ -128,6 +128,29 @@ public class Room extends BaseEntity
@Excel(name = "报价")
private BigDecimal price;
/** 报价单位 */
@Excel(name = "priceUnit")
private String priceUnit;
/** 租赁状态 */
@Excel(name = "租赁状态")
private String rentalStatus;
/** 可租日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date availableDate;
/** 出租状态 */
@Excel(name = "招商状态")
private String businessStatus;
/** 装修情况 */
@Excel(name = "装修情况")
private String decorationStatus;
/** 标签 */
@Excel(name = "标签")
private String tags;
public String getPriceUnit() {
return priceUnit;
}
@ -136,12 +159,9 @@ public class Room extends BaseEntity
this.priceUnit = priceUnit;
}
/** 报价单位 */
@Excel(name = "priceUnit")
private String priceUnit;
public String getPrice() {
return (price==null? "":price.toString()) + PriceUnitEnum.getValue(getPriceUnit());
return (price==null? "":price )+
(priceUnit==null?"":PriceUnitEnum.getValue(priceUnit));
}
public void setPrice(BigDecimal price) {
@ -165,21 +185,6 @@ public class Room extends BaseEntity
this.decorationStatus = decorationStatus;
}
/** 租赁状态 */
@Excel(name = "租赁状态")
private String rentalStatus;
/** 可租日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date availableDate;
/** 出租状态 */
@Excel(name = "招商状态", readConverterExp = "1=招商,2=不招商")
private String businessStatus;
/** 装修情况 */
@Excel(name = "装修情况")
private String decorationStatus;
public void setId(Long id)
{
this.id = id;
@ -190,22 +195,22 @@ public class Room extends BaseEntity
return id;
}
public void setProjectId(String projectId)
public void setProjectId(String projectId)
{
this.projectId = projectId;
}
public String getProjectId()
public String getProjectId()
{
return projectId;
}
public void setProjectName(String projectName)
public void setProjectName(String projectName)
{
this.projectName = projectName;
}
public String getProjectName()
public String getProjectName()
{
return projectName;
}
@ -219,13 +224,13 @@ public class Room extends BaseEntity
{
return buildingId;
}
public void setBuildingName(String buildingName)
public void setBuildingName(String buildingName)
{
this.buildingName = buildingName;
}
public String getBuildingName()
public String getBuildingName()
{
return buildingName;
}
@ -239,83 +244,83 @@ public class Room extends BaseEntity
{
return floorId;
}
public void setFloorName(String floorName)
public void setFloorName(String floorName)
{
this.floorName = floorName;
}
public String getFloorName()
public String getFloorName()
{
return floorName;
}
public void setRoomNumber(String roomNumber)
public void setRoomNumber(String roomNumber)
{
this.roomNumber = roomNumber;
}
public String getRoomNumber()
public String getRoomNumber()
{
return roomNumber;
}
public void setRoomDigitalNumber(String roomDigitalNumber)
public void setRoomDigitalNumber(String roomDigitalNumber)
{
this.roomDigitalNumber = roomDigitalNumber;
}
public String getRoomDigitalNumber()
public String getRoomDigitalNumber()
{
return roomDigitalNumber;
}
public void setRoomManageNumber(String roomManageNumber)
public void setRoomManageNumber(String roomManageNumber)
{
this.roomManageNumber = roomManageNumber;
}
public String getRoomManageNumber()
public String getRoomManageNumber()
{
return roomManageNumber;
}
public void setRoomName(String roomName)
public void setRoomName(String roomName)
{
this.roomName = roomName;
}
public String getRoomName()
public String getRoomName()
{
return roomName;
}
public void setRoomType(String roomType)
public void setRoomType(String roomType)
{
this.roomType = roomType;
}
public String getRoomType()
public String getRoomType()
{
return roomType;
}
public void setFloor(String floor)
public void setFloor(String floor)
{
this.floor = floor;
}
public String getFloor()
public String getFloor()
{
return floor;
}
public void setIsWholeFloor(String isWholeFloor)
public void setIsWholeFloor(String isWholeFloor)
{
this.isWholeFloor = isWholeFloor;
}
public String getIsWholeFloor()
public String getIsWholeFloor()
{
return isWholeFloor;
}
@ -329,7 +334,7 @@ public class Room extends BaseEntity
{
return buildingArea;
}
public void setRentalArea(BigDecimal rentalArea)
{
this.rentalArea = rentalArea;
@ -339,7 +344,7 @@ public class Room extends BaseEntity
{
return rentalArea;
}
public void setBillingArea(BigDecimal billingArea)
{
this.billingArea = billingArea;
@ -349,7 +354,7 @@ public class Room extends BaseEntity
{
return billingArea;
}
public void setInnerArea(BigDecimal innerArea)
{
this.innerArea = innerArea;
@ -359,27 +364,27 @@ public class Room extends BaseEntity
{
return innerArea;
}
public void setIsVirtual(String isVirtual)
public void setIsVirtual(String isVirtual)
{
this.isVirtual = isVirtual;
}
public String getIsVirtual()
public String getIsVirtual()
{
return isVirtual;
}
public void setDeliveryTime(Date deliveryTime)
public void setDeliveryTime(Date deliveryTime)
{
this.deliveryTime = deliveryTime;
}
public Date getDeliveryTime()
public Date getDeliveryTime()
{
return deliveryTime;
}
public void setOwnerId(Long ownerId)
{
this.ownerId = ownerId;
@ -389,17 +394,17 @@ public class Room extends BaseEntity
{
return ownerId;
}
public void setPropertyNature(String propertyNature)
public void setPropertyNature(String propertyNature)
{
this.propertyNature = propertyNature;
}
public String getPropertyNature()
public String getPropertyNature()
{
return propertyNature;
}
public void setHeight(BigDecimal height)
{
this.height = height;
@ -409,7 +414,7 @@ public class Room extends BaseEntity
{
return height;
}
public void setLoadValue(BigDecimal loadValue)
{
this.loadValue = loadValue;
@ -419,13 +424,13 @@ public class Room extends BaseEntity
{
return loadValue;
}
public void setRoomStatus(String roomStatus)
public void setRoomStatus(String roomStatus)
{
this.roomStatus = roomStatus;
}
public String getRoomStatus()
public String getRoomStatus()
{
return roomStatus;
}
@ -440,45 +445,61 @@ public class Room extends BaseEntity
return roomArea;
}
public void setRentalStatus(String rentalStatus)
public void setRentalStatus(String rentalStatus)
{
this.rentalStatus = rentalStatus;
}
public String getRentalStatus()
public String getRentalStatus()
{
return rentalStatus;
}
public void setAvailableDate(Date availableDate) {
this.availableDate = availableDate;
}
public Date getAvailableDate() {
return availableDate;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("tenantId", getTenantId())
.append("projectId", getProjectId())
.append("buildingId", getBuildingId())
.append("floorId", getFloorId())
.append("roomNumber", getRoomNumber())
.append("roomDigitalNumber", getRoomDigitalNumber())
.append("roomManageNumber", getRoomManageNumber())
.append("buildingArea", getBuildingArea())
.append("rentalArea", getRentalArea())
.append("billingArea", getBillingArea())
.append("innerArea", getInnerArea())
.append("isVirtual", getIsVirtual())
.append("deliveryTime", getDeliveryTime())
.append("ownerId", getOwnerId())
.append("propertyNature", getPropertyNature())
.append("height", getHeight())
.append("loadValue", getLoadValue())
.append("roomStatus", getRoomStatus())
.append("roomType", getRoomType())
.append("createTime", getCreateTime())
.append("lastModTime", getLastModTime())
.append("createUserId", getCreateUserId())
.append("lastModUserId", getLastModUserId())
.append("delFlag", getDelFlag())
.append("remark", getRemark())
.toString();
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("tenantId", getTenantId())
.append("projectId", getProjectId())
.append("buildingId", getBuildingId())
.append("floorId", getFloorId())
.append("roomNumber", getRoomNumber())
.append("roomDigitalNumber", getRoomDigitalNumber())
.append("roomManageNumber", getRoomManageNumber())
.append("buildingArea", getBuildingArea())
.append("rentalArea", getRentalArea())
.append("billingArea", getBillingArea())
.append("innerArea", getInnerArea())
.append("isVirtual", getIsVirtual())
.append("deliveryTime", getDeliveryTime())
.append("ownerId", getOwnerId())
.append("propertyNature", getPropertyNature())
.append("height", getHeight())
.append("loadValue", getLoadValue())
.append("roomStatus", getRoomStatus())
.append("roomType", getRoomType())
.append("createTime", getCreateTime())
.append("lastModTime", getLastModTime())
.append("createUserId", getCreateUserId())
.append("lastModUserId", getLastModUserId())
.append("delFlag", getDelFlag())
.append("remark", getRemark())
.toString();
}
}
public String getTags() {
return tags;
}
public void setTags(String tags) {
this.tags = tags;
}
}

View File

@ -2,6 +2,9 @@ package com.eden.room.domain;
import java.util.Date;
import java.math.BigDecimal;
import com.eden.room.common.enums.*;
import com.eden.room.utils.EnumValid;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@ -13,27 +16,15 @@ import org.springframework.format.annotation.DateTimeFormat;
public class RoomBusinessInfo extends BaseEntity {
/** 招商信息ID */
private Long id;
/** 租户ID */
private String tenantId;
/** 房源ID */
private Long roomId;
/** 租赁状态:待租,已租,下架 */
private String rentalStatus;
/** 招商状态: 招商,不招商 */
private String businessStatus;
/** 可租日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date availableDate;
/** 装修情况:精装,简装,毛坯,标准交付,豪装 */
private String decorationStatus;
/** 报价 */
private BigDecimal price;
@ -72,6 +63,15 @@ public class RoomBusinessInfo extends BaseEntity {
/** 备注 */
private String remark;
@EnumValid(value = RentalStatusEnum.class, message = "无效的租赁状态")
private String rentalStatus;
@EnumValid(value = BusinessStatusEnum.class, message = "无效的招商状态")
private String businessStatus;
@EnumValid(value = DecorationStatusEnum.class, message = "无效的装修情况")
private String decorationStatus;
public Long getId() {
return id;
}
@ -80,13 +80,7 @@ public class RoomBusinessInfo extends BaseEntity {
this.id = id;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public Long getRoomId() {
return roomId;
@ -226,7 +220,7 @@ public class RoomBusinessInfo extends BaseEntity {
@Override
public String toString() {
return "RoomBusinessInfo [id=" + id + ", tenantId=" + tenantId + ", roomId=" + roomId + ", rentalStatus="
return "RoomBusinessInfo [id=" + id + ", tenantId=" + getTenantId() + ", roomId=" + roomId + ", rentalStatus="
+ rentalStatus + ", businessStatus=" + businessStatus + ", availableDate=" + availableDate
+ ", decorationStatus=" + decorationStatus + ", price=" + price + ", priceUnit=" + priceUnit
+ ", floorPrice=" + floorPrice + ", floorPriceUnit=" + floorPriceUnit + ", businessNumber="

View File

@ -11,9 +11,7 @@ import lombok.Data;
public class RoomExtendInfo extends BaseEntity {
/** 拓展信息ID */
private Long id;
/** 租户ID */
private String tenantId;
/** 房源ID */
private Long roomId;
@ -76,13 +74,7 @@ public class RoomExtendInfo extends BaseEntity {
this.id = id;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public Long getRoomId() {
return roomId;
@ -222,7 +214,7 @@ public class RoomExtendInfo extends BaseEntity {
@Override
public String toString() {
return "RoomExtendInfo [id=" + id + ", tenantId=" + tenantId + ", roomId=" + roomId + ", roomRecordNumber="
return "RoomExtendInfo [id=" + id + ", tenantId=" + getTenantId() + ", roomId=" + roomId + ", roomRecordNumber="
+ roomRecordNumber + ", usageRate=" + usageRate + ", officeLayout=" + officeLayout
+ ", windowOrientation=" + windowOrientation + ", rentFreePeriod=" + rentFreePeriod + ", minLeaseTerm="
+ minLeaseTerm + ", workstationMin=" + workstationMin + ", workstationMax=" + workstationMax

View File

@ -10,9 +10,6 @@ public class RoomImage extends BaseEntity {
/** 图片ID */
private Long id;
/** 租户ID */
private String tenantId;
/** 房源ID */
private Long roomId;
@ -50,13 +47,7 @@ public class RoomImage extends BaseEntity {
this.id = id;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public Long getRoomId() {
return roomId;
@ -132,7 +123,7 @@ public class RoomImage extends BaseEntity {
@Override
public String toString() {
return "RoomImage [id=" + id + ", tenantId=" + tenantId + ", roomId=" + roomId + ", imageUrl=" + imageUrl
return "RoomImage [id=" + id + ", tenantId=" + getTenantId() + ", roomId=" + roomId + ", imageUrl=" + imageUrl
+ ", imageType=" + imageType + ", sortOrder=" + sortOrder + ", createTime=" + createTime
+ ", updateTime=" + updateTime + ", delFlag=" + delFlag + "]";
}

View File

@ -1,14 +1,24 @@
package com.eden.room.domain.dto;
import com.eden.room.common.enums.BusinessStatusEnum;
import com.eden.room.common.enums.DecorationStatusEnum;
import com.eden.room.common.enums.PropertyNatureEnum;
import com.eden.room.common.enums.RentalStatusEnum;
import com.eden.room.common.enums.RoomStatusEnum;
import com.eden.room.common.enums.RoomTypeEnum;
import com.eden.room.domain.Room;
import com.eden.room.domain.RoomBusinessInfo;
import com.eden.room.domain.RoomExtendInfo;
import com.eden.room.domain.RoomImage;
import com.eden.room.utils.EnumValid;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
/**
* 房源信息DTO包含基础信息招商信息和拓展信息
*/
@ -19,6 +29,7 @@ public class RoomDTO extends Room {
private static final long serialVersionUID = 1L;
/** 招商信息 */
@Valid
private RoomBusinessInfo businessInfo;
/** 拓展信息 */
@ -45,6 +56,15 @@ public class RoomDTO extends Room {
/** 标签列表 */
private String tags;
@EnumValid(value = RoomTypeEnum.class, message = "无效的房源类型")
private String roomType;
@EnumValid(value = RoomStatusEnum.class, message = "无效的房源状态")
private String roomStatus;
@EnumValid(value = PropertyNatureEnum.class, message = "无效的产权性质")
private String propertyNature;
public RoomBusinessInfo getBusinessInfo() {
return businessInfo;
}

View File

@ -2,6 +2,10 @@ package com.eden.room.domain.dto;
import java.math.BigDecimal;
import java.util.Date;
import com.eden.room.common.enums.*;
import com.eden.room.utils.EnumConvert;
import com.eden.room.utils.excel.Excel;
import lombok.Data;
/**
@ -9,6 +13,99 @@ import lombok.Data;
*/
@Data
public class RoomExportDTO {
/**
* 项目名称
*/
@Excel(name = "项目名称", required = true, sort = 1)
private String projectName;
/**
* 楼宇名称
*/
@Excel(name = "楼宇名称", required = true, sort = 2)
private String buildingName;
/**
* 楼层
*/
@Excel(name = "楼层", required = true, sort = 3)
private String floorName;
/**
* 房源编号
*/
@Excel(name = "房号", required = true, sort = 4)
private String roomNumber;
/**
* 计租面积
*/
@Excel(name = "计租面积", required = true, sort = 5)
private BigDecimal rentalArea;
/**
* 报价+单位
*/
@Excel(name = "报价", required = true, sort = 6)
private String priceAndUnit;
/**
* 租赁状态
*/
@Excel(name = "租赁状态", required = true, sort = 7)
@EnumConvert(RentalStatusEnum.class)
private String rentalStatus;
/**
* 可租日期
*/
@Excel(name = "可租日期", required = true, sort = 8)
private Date availableDate;
/**
* 房源标签
*/
@Excel(name = "房源标签", required = true, sort = 9)
private String tags;
/**
* 虚拟房源
*/
@Excel(name = "虚拟房源", sort =10)
@EnumConvert(VirtualFlagEnum.class)
private String isVirtual;
/**
* 招商状态
*/
@Excel(name = "招商状态", sort = 11)
@EnumConvert(BusinessStatusEnum.class)
private String businessStatus;
/**
* 装修情况
*/
@Excel(name = "装修情况", sort = 12)
@EnumConvert(DecorationStatusEnum.class)
private String decorationStatus;
/**
* 房源交付时间
*/
@Excel(name = "房源交付时间", sort = 13)
private Date deliveryTime;
/**
* 创建时间
*/
@Excel(name = "创建时间", sort = 14)
private Date createTime;
/**
* 房源类型
* 使用EnumConverter将枚举类型的key转换为对应的value
*/
@Excel(name = "房源类型", sort = 15)
@EnumConvert(RoomTypeEnum.class)
private String roomType;
/**
* 房源ID
@ -19,37 +116,19 @@ public class RoomExportDTO {
* 项目ID
*/
private String projectId;
/**
* 项目名称
*/
private String projectName;
/**
* 楼宇ID
*/
private Long buildingId;
/**
* 楼宇名称
*/
private String buildingName;
/**
* 楼层ID
*/
private Long floorId;
/**
* 楼层名称
*/
private String floorName;
/**
* 房源编号
*/
private String roomNumber;
/**
* 房源数字编号
*/
@ -64,31 +143,16 @@ public class RoomExportDTO {
* 房源名称
*/
private String roomName;
/**
* 房源类型
*/
private String roomType;
/**
* 楼层
*/
private String floor;
/**
* 是否整层
*/
private String isWholeFloor;
/**
* 建筑面积
*/
private BigDecimal buildingArea;
/**
* 计租面积
*/
private BigDecimal rentalArea;
/**
* 计费面积
@ -100,16 +164,6 @@ public class RoomExportDTO {
*/
private BigDecimal innerArea;
/**
* 是否虚拟房源
*/
private String isVirtual;
/**
* 房源交付时间
*/
private Date deliveryTime;
/**
* 绑定业主ID
*/
@ -145,43 +199,13 @@ public class RoomExportDTO {
*/
private String roomStatus;
/**
* 租赁状态
*/
private String rentalStatus;
/**
* 业务状态
*/
private String businessStatus;
/**
* 装修状态
*/
private String decorationStatus;
/**
* 价格
*/
private BigDecimal price;
private String price;
/**
* 价格单位
*/
private String priceUnit;
/**
* 可租日期
*/
private Date availableDate;
/**
* 房源标签
*/
private String tags;
/**
* 创建时间
*/
private Date createTime;
}

View File

@ -1,82 +1,81 @@
package com.eden.room.domain.dto;
import com.eden.room.utils.excel.Excel;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.io.Serializable;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
/**
* 房源导入DTO
*/
@Data
public class RoomImportDTO implements Serializable {
private static final long serialVersionUID = 1L;
/** 项目 */
@Excel(name = "项目", sort = 1, required = true,cellType = Excel.ColumnType.STRING)
public class RoomImportDTO {
@ExcelProperty("项目")
@NotBlank(message = "项目名称不能为空。")
private String projectName;
/** 楼宇 */
@Excel(name = "楼宇", sort = 2, required = true,cellType = Excel.ColumnType.STRING)
@ExcelProperty("楼宇")
@NotBlank(message = "楼宇名称不能为空。")
private String buildingName;
/** 楼层 */
@Excel(name = "楼层", sort = 3, required = true,cellType = Excel.ColumnType.STRING)
@ExcelProperty("楼层")
@NotBlank(message = "楼层名称不能为空。")
private String floorName;
/** 房号 */
@Excel(name = "房号", sort = 4, required = true,cellType = Excel.ColumnType.STRING)
@ExcelProperty("房号")
@NotBlank(message = "房号不能为空。")
private String roomNumber;
/** 房间数字编号 */
@Excel(name = "房间数字编号", sort = 5, required = true,cellType = Excel.ColumnType.STRING)
@ExcelProperty("房间数字编号")
private String roomDigitalNumber;
/** 计租面积 */
@Excel(name = "计租面积", sort = 6, suffix = "", cellType = Excel.ColumnType.NUMERIC)
@ExcelProperty("计租面积")
private BigDecimal rentalArea;
/** 计费面积 */
@Excel(name = "计费面积", sort = 7, suffix = "", cellType = Excel.ColumnType.NUMERIC)
@ExcelProperty("计费面积")
private BigDecimal billingArea;
/** 建筑面积 */
@Excel(name = "建筑面积", sort = 8, suffix = "", cellType = Excel.ColumnType.NUMERIC)
@ExcelProperty("建筑面积")
private BigDecimal buildingArea;
/** 层高 */
@Excel(name = "层高m", sort = 9, suffix = "m", cellType = Excel.ColumnType.NUMERIC)
@ExcelProperty("层高m")
private BigDecimal height;
/** 报价 */
@Excel(name = "报价", sort = 10, cellType = Excel.ColumnType.NUMERIC)
@ExcelProperty("报价")
private BigDecimal price;
/** 底价 */
@Excel(name = "底价", sort = 11, cellType = Excel.ColumnType.NUMERIC)
@ExcelProperty("底价")
private BigDecimal floorPrice;
/** 单位 */
@Excel(name = "单位", sort = 12,cellType = Excel.ColumnType.STRING)
@ExcelProperty("单位")
private String priceUnit;
/** 房源备案号 */
@Excel(name = "房源备案号", sort = 13, cellType = Excel.ColumnType.STRING)
@ExcelProperty("房源备案号")
private String roomRecordNumber;
/** 标签 */
@Excel(name = "标签", sort = 14,cellType = Excel.ColumnType.STRING)
@ExcelProperty("标签")
private String tags;
/** 房源管理编号 */
@Excel(name = "房源管理编号", sort = 15,cellType = Excel.ColumnType.STRING)
@ExcelProperty("房源管理编号")
private String roomManageNumber;
/** 导入结果说明 */
@Excel(name = "导入结果说明", sort = 16,cellType = Excel.ColumnType.STRING)
private String importResult;
@ExcelProperty("导入结果说明")
private String importResult="";
public String getProjectName() {

View File

@ -3,6 +3,7 @@ package com.eden.room.domain.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Set;
/**
* 房源查询条件DTO
@ -48,6 +49,13 @@ public class RoomQueryDTO implements Serializable {
/** 截止创建时间 */
private String endCreateTime;
/** 房源状态 */
private String roomStatus;
/** 房号 */
private Set<String> RoomNumbers;
public String getRoomNumber() {
return roomNumber;
}

View File

@ -1,139 +0,0 @@
//package com.eden.room.interceptor;
//
//import java.util.Properties;
//import java.util.Set;
//import java.util.HashSet;
//
//import org.apache.ibatis.cache.CacheKey;
//import org.apache.ibatis.executor.Executor;
//import org.apache.ibatis.mapping.BoundSql;
//import org.apache.ibatis.mapping.MappedStatement;
//import org.apache.ibatis.mapping.SqlCommandType;
//import org.apache.ibatis.plugin.Interceptor;
//import org.apache.ibatis.plugin.Intercepts;
//import org.apache.ibatis.plugin.Invocation;
//import org.apache.ibatis.plugin.Plugin;
//import org.apache.ibatis.plugin.Signature;
//import org.apache.ibatis.session.ResultHandler;
//import org.apache.ibatis.session.RowBounds;
//
//import com.eden.room.common.ContextUser;
//
///**
// * 租户拦截器
// */
//@Intercepts({
// @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
// @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}),
// @Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})
//})
//public class TenantInterceptor implements Interceptor {
//
// // 需要添加租户条件的表名集合
// private static final Set<String> TENANT_TABLES = new HashSet<>();
// static {
// TENANT_TABLES.add("TB_ROOM_BASE");
// TENANT_TABLES.add("TB_ROOM_BUSINESS");
// TENANT_TABLES.add("TB_ROOM_EXTEND");
// TENANT_TABLES.add("TB_ROOM_IMAGE");
// TENANT_TABLES.add("TB_PROJECT");
// TENANT_TABLES.add("TB_BUILDING");
// TENANT_TABLES.add("TB_FLOOR");
// }
//
// @Override
// public Object intercept(Invocation invocation) throws Throwable {
// Object[] args = invocation.getArgs();
// MappedStatement ms = (MappedStatement) args[0];
// Object parameter = args[1];
//
// // 获取当前用户信息
// ContextUser user = ContextUser.getCurrentUser();
// if (user == null || user.getTenantId() == null) {
// return invocation.proceed();
// }
//
// // 获取SQL类型
// SqlCommandType sqlCommandType = ms.getSqlCommandType();
//
// // 获取SQL语句
// BoundSql boundSql = ms.getBoundSql(parameter);
// String sql = boundSql.getSql().toUpperCase();
//
// // 判断是否需要添加租户条件
// if (needTenant(sql)) {
// // 添加租户条件
// String tenantSql = addTenantCondition(sql, user.getTenantId());
// // 创建新的BoundSql
// BoundSql newBoundSql = new BoundSql(ms.getConfiguration(), tenantSql, boundSql.getParameterMappings(), parameter);
// // 创建新的MappedStatement
// MappedStatement newMs = copyMappedStatement(ms, newBoundSql);
// // 替换参数
// args[0] = newMs;
// }
//
// return invocation.proceed();
// }
//
// /**
// * 判断是否需要添加租户条件
// */
// private boolean needTenant(String sql) {
// // 排除不需要添加租户条件的SQL
// if (sql.contains("COUNT(*)") || sql.contains("MAX(") || sql.contains("MIN(") ||
// sql.contains("SUM(") || sql.contains("AVG(")) {
// return false;
// }
//
// // 检查SQL中是否包含需要添加租户条件的表
// for (String table : TENANT_TABLES) {
// if (sql.contains(table)) {
// return true;
// }
// }
//
// return false;
// }
//
// /**
// * 添加租户条件
// */
// private String addTenantCondition(String sql, String tenantId) {
// // 使用参数化查询防止SQL注入
// String tenantCondition = " tenant_id = #{tenantId} AND ";
// if (sql.contains("WHERE")) {
// return sql.replaceFirst("(?i)WHERE", "WHERE " + tenantCondition);
// } else {
// return sql.replaceFirst("(?i)FROM", "FROM WHERE " + tenantCondition);
// }
// }
//
// /**
// * 复制MappedStatement
// */
// private MappedStatement copyMappedStatement(MappedStatement ms, BoundSql boundSql) {
// MappedStatement.Builder builder = new MappedStatement.Builder(ms.getConfiguration(), ms.getId(),
// boundSql, ms.getSqlCommandType());
// builder.resource(ms.getResource());
// builder.fetchSize(ms.getFetchSize());
// builder.statementType(ms.getStatementType());
// builder.keyGenerator(ms.getKeyGenerator());
// builder.timeout(ms.getTimeout());
// builder.parameterMap(ms.getParameterMap());
// builder.resultMaps(ms.getResultMaps());
// builder.resultSetType(ms.getResultSetType());
// builder.cache(ms.getCache());
// builder.flushCacheRequired(ms.isFlushCacheRequired());
// builder.useCache(ms.isUseCache());
// return builder.build();
// }
//
// @Override
// public Object plugin(Object target) {
// return Plugin.wrap(target, this);
// }
//
// @Override
// public void setProperties(Properties properties) {
// }
//}

View File

@ -1,69 +0,0 @@
//package com.eden.room.interceptor;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//import com.eden.room.common.ContextUser;
//
///**
// * 用户上下文拦截器
// */
//public class UserContextInterceptor implements HandlerInterceptor {
//
// private static final Logger logger = LoggerFactory.getLogger(UserContextInterceptor.class);
//
// @Override
// public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
// try {
// // 从请求头或token中获取用户信息
// String tenantId = request.getHeader("X-Tenant-ID");
// String userId = request.getHeader("X-User-ID");
// String username = request.getHeader("X-Username");
//
// // 参数校验
// if (tenantId == null || tenantId.trim().isEmpty()) {
// logger.warn("Missing tenant ID in request headers");
// response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
// return false;
// }
//
// if (userId == null || userId.trim().isEmpty()) {
// logger.warn("Missing user ID in request headers");
// response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
// return false;
// }
//
// // 设置用户上下文
// ContextUser user = new ContextUser();
// user.setTenantId(tenantId.trim());
// user.setUserId(userId.trim());
// user.setUsername(username != null ? username.trim() : null);
// ContextUser.setCurrentUser(user);
//
// logger.debug("Set user context: tenantId={}, userId={}, username={}",
// tenantId, userId, username);
//
// return true;
//
// } catch (Exception e) {
// logger.error("Error setting user context", e);
// response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
// return false;
// }
// }
//
// @Override
// public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
// try {
// // 清理用户上下文
// ContextUser.clear();
// logger.debug("Cleared user context");
// } catch (Exception e) {
// logger.error("Error clearing user context", e);
// }
// }
//}

View File

@ -1,7 +1,9 @@
package com.eden.room.mapper;
import java.util.List;
import java.util.Set;
import com.eden.room.domain.Building;
import org.apache.ibatis.annotations.Param;
/**
* 楼宇信息数据访问层
@ -45,7 +47,7 @@ public interface BuildingMapper {
* @param ids 需要删除的楼宇ID数组
* @return 结果
*/
int deleteBuildingByIds(String[] ids);
int deleteBuildingByIds(List<Long> ids);
/**
* 删除楼宇信息
@ -97,4 +99,13 @@ public interface BuildingMapper {
boolean checkBuildingHasFloors(Long id);
List<Building> getBuildByIds(List<String> ids);
/**
* 根据项目ID和楼栋名称列表查询楼栋列表
*
* @param projectId 项目ID
* @param buildingNames 楼栋名称列表
* @return 楼栋列表
*/
List<Building> selectBuildingListByNames(@Param("projectId") String projectId, @Param("buildingNames") Set<String> buildingNames);
}

View File

@ -1,7 +1,9 @@
package com.eden.room.mapper;
import java.util.List;
import java.util.Set;
import com.eden.room.domain.Floor;
import org.apache.ibatis.annotations.Param;
/**
* 楼层信息数据访问层
@ -45,7 +47,7 @@ public interface FloorMapper {
* @param ids 需要删除的楼层ID数组
* @return 结果
*/
int deleteFloorByIds(String[] ids);
int deleteFloorByIds(List<Long> ids);
/**
* 删除楼层信息
@ -95,4 +97,13 @@ public interface FloorMapper {
* @return 结果
*/
int checkFloorHasRooms(Long id);
/**
* 根据楼栋ID和楼层名称列表查询楼层列表
*
* @param buildingId 楼栋ID
* @param floorNames 楼层名称列表
* @return 楼层列表
*/
List<Floor> selectFloorListByNames(@Param("buildingId") Long buildingId, @Param("floorNames") Set<String> floorNames);
}

View File

@ -1,7 +1,9 @@
package com.eden.room.mapper;
import java.util.List;
import java.util.Set;
import com.eden.room.domain.Project;
import org.apache.ibatis.annotations.Param;
/**
* 项目信息Mapper接口
@ -88,4 +90,12 @@ public interface ProjectMapper {
public Integer checkProjectShortNameExists(Project project);
List<Project> selectProjectListByIds(List<String> ids);
/**
* 根据项目名称列表查询项目列表
*
* @param projectNames 项目名称列表
* @return 项目列表
*/
List<Project> selectProjectListByNames(@Param("projectNames") Set<String> projectNames);
}

View File

@ -35,14 +35,14 @@ public interface RoomBusinessInfoMapper {
* @return 房源招商信息
*/
RoomBusinessInfo selectRoomBusinessInfoByRoomId(@Param("roomId") Long roomId);
/**
* 新增房源招商信息
* 批量插入房源招商信息
*
* @param businessInfo 房源招商信息
* @return 结果
* @param businessInfos 房源招商信息列表
* @return 插入结果
*/
int insertRoomBusinessInfo(RoomBusinessInfo businessInfo);
int batchInsertBusinessInfos(@Param("list") List<RoomBusinessInfo> businessInfos);
/**
* 修改房源招商信息
@ -67,20 +67,5 @@ public interface RoomBusinessInfoMapper {
* @return 结果
*/
int deleteRoomBusinessInfoByRoomId(@Param("roomId") Long roomId);
/**
* 批量删除房源招商信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
int deleteRoomBusinessInfoByIds(@Param("ids") String[] ids);
/**
* 批量删除房源招商信息根据房源ID
*
* @param roomIds 房源ID数组
* @return 结果
*/
int deleteRoomBusinessInfoByRoomIds(@Param("roomIds") String[] roomIds);
}

View File

@ -35,15 +35,14 @@ public interface RoomExtendInfoMapper {
* @return 房源拓展信息
*/
RoomExtendInfo selectRoomExtendInfoByRoomId(@Param("roomId") Long roomId);
/**
* 新增房源拓展信息
* 批量插入房源扩展信息
*
* @param extendInfo 房源拓展信息
* @return 结果
* @param extendInfos 房源扩展信息列表
* @return 插入结果
*/
int insertRoomExtendInfo(RoomExtendInfo extendInfo);
int batchInsertExtendInfos(List<RoomExtendInfo> extendInfos);
/**
* 修改房源拓展信息
*
@ -67,20 +66,5 @@ public interface RoomExtendInfoMapper {
* @return 结果
*/
int deleteRoomExtendInfoByRoomId(@Param("roomId") Long roomId);
/**
* 批量删除房源拓展信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
int deleteRoomExtendInfoByIds(@Param("ids") String[] ids);
/**
* 批量删除房源拓展信息根据房源ID
*
* @param roomIds 房源ID数组
* @return 结果
*/
int deleteRoomExtendInfoByRoomIds(@Param("roomIds") String[] roomIds);
}

View File

@ -83,7 +83,7 @@ public interface RoomImageMapper {
* @param ids 需要删除的数据ID
* @return 结果
*/
int deleteRoomImageByIds(@Param("ids") String[] ids);
int deleteRoomImageByIds(@Param("ids") List<Long> ids);
/**
* 批量删除房源图片根据房源ID
@ -91,5 +91,5 @@ public interface RoomImageMapper {
* @param roomIds 房源ID数组
* @return 结果
*/
int deleteRoomImagesByRoomIds(@Param("roomIds") String[] roomIds);
int deleteRoomImagesByRoomIds(@Param("roomIds") List<Long> roomIds);
}

View File

@ -1,6 +1,9 @@
package com.eden.room.mapper;
import java.util.List;
import java.util.Set;
import com.eden.room.domain.dto.RoomQueryDTO;
import org.apache.ibatis.annotations.Param;
import com.eden.room.domain.Room;
import org.apache.ibatis.annotations.Mapper;
@ -13,10 +16,10 @@ public interface RoomMapper {
/**
* 查询房源列表
*
* @param room 房源信息
* @param queryDTO 房源信息
* @return 房源列表
*/
List<Room> selectRoomList(Room room);
List<Room> selectRoomList( RoomQueryDTO queryDTO);
/**
* 根据ID查询房源
@ -25,15 +28,7 @@ public interface RoomMapper {
* @return 房源信息
*/
Room selectRoomById(@Param("id") Long id);
/**
* 新增房源
*
* @param room 房源信息
* @return 结果
*/
int insertRoom(Room room);
/**
* 修改房源
*
@ -56,7 +51,7 @@ public interface RoomMapper {
* @param ids 房源ID数组
* @return 结果
*/
int deleteRoomByIds(@Param("ids") String[] ids);
int deleteRoomByIds(@Param("ids") List<Long> ids);
/**
* 检查房号是否已存在
@ -69,9 +64,9 @@ public interface RoomMapper {
*/
boolean checkRoomNumberExist(@Param("roomNumber") String roomNumber,
@Param("projectId") String projectId,
@Param("buildingId") String buildingId,
@Param("floorId") String floorId);
@Param("buildingId") Long buildingId,
@Param("floorId") Long floorId);
/**
* 检查房间数字编号是否已存在
*
@ -81,16 +76,26 @@ public interface RoomMapper {
* @param floorId 楼层ID
* @return 是否存在
*/
boolean checkRoomDigitalNumberExist(@Param("roomDigitalNumber") String roomDigitalNumber,
@Param("projectId") String projectId,
@Param("buildingId") String buildingId,
@Param("floorId") String floorId);
boolean checkRoomDigitalNumberExist(@Param("roomDigitalNumber") String roomDigitalNumber,
@Param("projectId") String projectId,
@Param("buildingId") Long buildingId,
@Param("floorId") Long floorId);
/**
* 根据ID数组查询房源列表
* 批量插入房源信息
*
* @param ids 房源ID数组
* @return 房源列表
* @param rooms 房源信息列表
* @return 插入结果
*/
List<Room> selectRoomByIds(@Param("ids") String[] ids);
int batchInsertRooms(@Param("list") List<Room> rooms);
/**
* 获取指定项目下已存在的房间号
*
* @param projectId 项目ID
* @param roomNumbers 待检查的房间号列表
* @return 已存在的房间号集合
*/
Set<String> getExistingRoomNumbers(@Param("projectId") String projectId, @Param("roomNumbers") Set<String> roomNumbers);
}

View File

@ -1,6 +1,9 @@
package com.eden.room.service;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.eden.room.domain.Building;
import com.eden.room.domain.Project;
@ -46,7 +49,7 @@ public interface IBuildingService {
* @param ids 需要删除的楼宇ID数组
* @return 结果
*/
int deleteBuildingByIds(String[] ids);
int deleteBuildingByIds(List<Long> ids);
/**
* 删除楼宇信息
@ -67,4 +70,13 @@ public interface IBuildingService {
boolean checkBuildingNameExists(Building building);
List<Building> getBuildByIds(List<String> ids);
/**
* 根据楼宇名称列表获取楼宇ID映射
*
* @param projectId 项目ID
* @param buildingNames 楼宇名称列表
* @return 楼宇名称到ID的映射
*/
Map<String, Long> getBuildingIdsByNames(String projectId, Set<String> buildingNames);
}

View File

@ -1,6 +1,9 @@
package com.eden.room.service;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.eden.room.domain.Floor;
/**
@ -45,7 +48,7 @@ public interface IFloorService {
* @param ids 需要删除的楼层ID数组
* @return 结果
*/
int deleteFloorByIds(String[] ids);
int deleteFloorByIds(List<Long> ids);
/**
* 删除楼层信息
@ -62,4 +65,13 @@ public interface IFloorService {
* @return 楼层列表
*/
List<Floor> selectFloorListByBuildingId(Long buildingId);
/**
* 根据楼层名称列表获取楼层ID映射
*
* @param buildingId 楼宇ID
* @param floorNames 楼层名称列表
* @return 楼层名称到ID的映射
*/
Map<String, Long> getFloorIdsByNames(Long buildingId, Set<String> floorNames);
}

View File

@ -1,6 +1,9 @@
package com.eden.room.service;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.eden.room.domain.Project;
/**
@ -74,4 +77,12 @@ public interface IProjectService {
List<Project> selectProjectListByIds(List<String> ids);
List<Project> selectProjectListByName(String name);
/**
* 根据项目名称列表获取项目ID映射
*
* @param projectNames 项目名称列表
* @return 项目名称到ID的映射
*/
Map<String, String> getProjectIdsByNames(Set<String> projectNames);
}

View File

@ -3,13 +3,14 @@ package com.eden.room.service;
import com.eden.room.domain.Room;
import com.eden.room.domain.RoomBusinessInfo;
import com.eden.room.domain.RoomExtendInfo;
import com.eden.room.domain.RoomImage;
import com.eden.room.domain.dto.RoomDTO;
import com.eden.room.domain.dto.RoomExportDTO;
import com.eden.room.domain.dto.RoomQueryDTO;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 房源服务接口
@ -19,10 +20,10 @@ public interface IRoomService {
/**
* 查询房源列表
*
* @param room 房源信息
* @param queryDTO 房源信息
* @return 房源列表
*/
List<Room> selectRoomList(Room room);
List<Room> selectRoomList(RoomQueryDTO queryDTO);
/**
* 根据ID查询房源
@ -64,23 +65,15 @@ public interface IRoomService {
*/
int deleteRoomById(Long id);
/**
* 批量删除房源信息
*
* @param ids 房源ID数组
* @return 结果
*/
int deleteRoomByIds(String[] ids);
/**
* 导出房源信息
*
* @param room 查询条件
* @param queryDTO 查询条件
* @return 房源信息列表
*/
List<RoomExportDTO> exportRoom(Room room);
List<RoomExportDTO> exportRoom( RoomQueryDTO queryDTO);
/**
* 修改房源租赁状态
@ -100,18 +93,18 @@ public interface IRoomService {
boolean checkRoomContract(Long id);
/**
* 根据ID列表导出房源信息
*
* @param ids 房源ID数组
* @return 房源信息列表
* 批量插入房源信息
* @param rooms
* @param businessInfos
* @param extendInfos
*/
List<RoomExportDTO> exportRoomByIds(String[] ids);
void batchInsertRooms(List<Room> rooms, List<RoomBusinessInfo> businessInfos, List<RoomExtendInfo> extendInfos);
/**
* 批量导入房源信息
*
* @param file 导入文件
* @return 导入结果
* 获取项目下已存在的房源编号
* @param projectId
* @param roomNumbers
* @return
*/
Map<String, Object> importRoom(MultipartFile file) throws Exception;
}
Set<String> getExistingRoomNumbers(String projectId, Set<String> roomNumbers);
}

View File

@ -1,57 +0,0 @@
package com.eden.room.service;
import com.eden.room.common.enums.BusinessStatusEnum;
import com.eden.room.common.enums.DecorationStatusEnum;
import com.eden.room.common.enums.PriceUnitEnum;
import com.eden.room.common.enums.RentalStatusEnum;
import com.eden.room.domain.RoomExport;
import com.eden.room.domain.dto.RoomExportDTO;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 房源模板服务
*/
@Service
public class RoomTemplateService {
/**
* 将房源导出DTO数据转换为房源导入模板格式
*
* @param roomList 房源数据列表
* @return 转换后的数据列表
*/
public List<RoomExport> convertToRoomImportList(List<RoomExportDTO> roomList) {
List<RoomExport> result = new ArrayList<>();
if (roomList == null || roomList.isEmpty()) {
return result;
}
for (RoomExportDTO roomDTO : roomList) {
RoomExport roomExport = new RoomExport();
// 设置基本信息
roomExport.setProjectName(roomDTO.getProjectName());
roomExport.setBuildingName(roomDTO.getBuildingName());
roomExport.setFloorName(roomDTO.getFloorName());
roomExport.setRoomNumber(roomDTO.getRoomNumber()); // 使用管理编号作为房源编号
roomExport.setRentalArea(roomDTO.getRentalArea());
roomExport.setPriceAndUnit((roomDTO.getPrice()==null?"":roomDTO.getPrice().toString()) + PriceUnitEnum.getValue(roomDTO.getPriceUnit()));
roomExport.setRentalStatus(RentalStatusEnum.getValue(roomDTO.getRentalStatus()));
roomExport.setAvailableDate(roomDTO.getAvailableDate());
//TODO 根据tags 调接口去查对应的tagName
roomExport.setTags(roomDTO.getTags());
roomExport.setIsVirtual("1".equals(roomDTO.getIsVirtual())? "":"");
roomExport.setBusinessStatus(BusinessStatusEnum.getValue(roomDTO.getBusinessStatus()));
roomExport.setDecorationStatus(DecorationStatusEnum.getValue(roomDTO.getDecorationStatus()));
roomExport.setDeliveryTime(roomDTO.getDeliveryTime());
roomExport.setCreateTime(roomDTO.getCreateTime());
result.add(roomExport);
}
return result;
}
}

View File

@ -1,6 +1,10 @@
package com.eden.room.service.impl;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Collections;
import java.util.stream.Collectors;
import com.eden.room.domain.Project;
import org.springframework.beans.factory.annotation.Autowired;
@ -90,9 +94,9 @@ public class BuildingServiceImpl implements IBuildingService {
* @return 结果
*/
@Override
public int deleteBuildingByIds(String[] ids) {
for (String id : ids) {
if (buildingMapper.checkBuildingHasFloors(Long.valueOf(id))) {
public int deleteBuildingByIds(List<Long> ids) {
for (Long id : ids) {
if (buildingMapper.checkBuildingHasFloors(id)) {
throw new ServiceException("楼宇下存在楼层信息,不允许删除");
}
}
@ -148,4 +152,19 @@ public class BuildingServiceImpl implements IBuildingService {
private boolean checkBuildingCodeExists(Building building) {
return buildingMapper.checkBuildingCodeExists(building) > 0;
}
@Override
public Map<String, Long> getBuildingIdsByNames(String projectId, Set<String> buildingNames) {
if (projectId == null || buildingNames == null || buildingNames.isEmpty()) {
return Collections.emptyMap();
}
List<Building> buildings = buildingMapper.selectBuildingListByNames(projectId, buildingNames);
return buildings.stream()
.collect(Collectors.toMap(
Building::getBuildingName,
Building::getId,
(existing, replacement) -> existing
));
}
}

View File

@ -1,6 +1,10 @@
package com.eden.room.service.impl;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Collections;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -81,11 +85,11 @@ public class FloorServiceImpl implements IFloorService {
*/
@Override
@Transactional
public int deleteFloorByIds(String[] ids) {
for (String id : ids) {
public int deleteFloorByIds(List<Long> ids) {
for (Long id : ids) {
// 检查楼层是否有关联的房源
if (floorMapper.checkFloorHasRooms(Long.valueOf(id)) > 0) {
Floor floor = floorMapper.selectFloorById(Long.valueOf(id));
if (floorMapper.checkFloorHasRooms(id) > 0) {
Floor floor = floorMapper.selectFloorById(id);
throw new ServiceException(String.format("楼层'%s'已分配房源,不能删除", floor.getFloorName()));
}
}
@ -115,4 +119,19 @@ public class FloorServiceImpl implements IFloorService {
floor.setBuildingId(buildingId);
return floorMapper.selectFloorList(floor);
}
@Override
public Map<String, Long> getFloorIdsByNames(Long buildingId, Set<String> floorNames) {
if (buildingId == null || floorNames == null || floorNames.isEmpty()) {
return Collections.emptyMap();
}
List<Floor> floors = floorMapper.selectFloorListByNames(buildingId, floorNames);
return floors.stream()
.collect(Collectors.toMap(
Floor::getFloorName,
Floor::getId,
(existing, replacement) -> existing
));
}
}

View File

@ -1,6 +1,10 @@
package com.eden.room.service.impl;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Collections;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.eden.room.mapper.ProjectMapper;
@ -114,4 +118,19 @@ public class ProjectServiceImpl implements IProjectService {
project.setProjectName(name);
return projectMapper.selectProjectList(project);
}
@Override
public Map<String, String> getProjectIdsByNames(Set<String> projectNames) {
if (projectNames == null || projectNames.isEmpty()) {
return Collections.emptyMap();
}
List<Project> projects = projectMapper.selectProjectListByNames(projectNames);
return projects.stream()
.collect(Collectors.toMap(
Project::getProjectName,
Project::getId,
(existing, replacement) -> existing
));
}
}

View File

@ -3,9 +3,7 @@ package com.eden.room.service.impl;
import com.eden.room.common.ContextUser;
import com.eden.room.common.UserContextHolder;
import com.eden.room.common.enums.ImageTypeEnum;
import com.eden.room.common.enums.PriceUnitEnum;
import com.eden.room.common.enums.RentalStatusEnum;
import com.eden.room.common.enums.*;
import com.eden.room.domain.*;
import com.eden.room.domain.dto.*;
import com.eden.room.feign.ContractFeignClient;
@ -19,6 +17,7 @@ import com.eden.room.mapper.RoomExtendInfoMapper;
import com.eden.room.mapper.RoomImageMapper;
import com.eden.room.mapper.RoomMapper;
import com.eden.room.service.IRoomService;
import com.eden.room.utils.EnumConverter;
import com.eden.room.utils.ExcelUtil;
import com.eden.room.utils.excel.Excel;
import lombok.extern.slf4j.Slf4j;
@ -36,6 +35,8 @@ import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
import com.eden.room.constant.RoomConstants;
/**
* 房源服务实现类
*/
@ -77,10 +78,8 @@ public class RoomServiceImpl implements IRoomService {
* 查询房源列表
*/
@Override
public List<Room> selectRoomList(Room room) {
// 设置租户ID
//setTenantId(room);
return roomMapper.selectRoomList(room);
public List<Room> selectRoomList(RoomQueryDTO queryDTO) {
return roomMapper.selectRoomList(queryDTO);
}
/**
@ -170,54 +169,59 @@ public class RoomServiceImpl implements IRoomService {
public int insertRoom(RoomDTO roomDTO) {
// 获取当前用户
ContextUser user = new ContextUser();
user.setUsername("admin");
user.setUsername(RoomConstants.DEFAULT_USERNAME);
Date now = new Date();
// 设置房源基础信息
Room room = new Room();
BeanUtils.copyProperties(roomDTO, room);
//setTenantId(room);
room.setCreateTime(now);
room.setLastModTime(now);
room.setCreateUserId(user.getUserName());
room.setLastModUserId(user.getUserName());
room.setDelFlag("0");
room.setDelFlag(RoomConstants.DEL_FLAG_NORMAL);
// todo 数据库校验
roomMapper.checkRoomDigitalNumberExist(room.getRoomDigitalNumber(), room.getProjectId(),
room.getBuildingId(), room.getFloorId());
// todo 数据库校验
roomMapper.checkRoomNumberExist(room.getRoomNumber(), room.getProjectId(),
room.getBuildingId(), room.getFloorId());
// 插入房源基础信息
int rows = roomMapper.insertRoom(room);
int rows = roomMapper.batchInsertRooms(Collections.singletonList(room));
Long roomId = room.getId();
// 设置招商信息
RoomBusinessInfo businessInfo = roomDTO.getBusinessInfo();
if (businessInfo != null) {
businessInfo.setRoomId(roomId);
//setTenantId(businessInfo);
businessInfo.setCreateTime(now);
businessInfo.setLastModTime(now);
businessInfo.setCreateUserId(user.getUserName());
businessInfo.setLastModUserId(user.getUserName());
businessInfo.setDelFlag("0");
businessInfo.setDelFlag(RoomConstants.DEL_FLAG_NORMAL);
// 默认设置为待租状态
if (StringUtils.isEmpty(businessInfo.getRentalStatus())) {
businessInfo.setRentalStatus(RentalStatusEnum.WAITING.getKey());
}
businessInfo.setPriceUnit(PriceUnitEnum.getByValue(businessInfo.getPriceUnit()).getKey());
businessInfo.setPriceUnit(businessInfo.getPriceUnit());
// 插入招商信息
businessInfoMapper.insertRoomBusinessInfo(businessInfo);
businessInfoMapper.batchInsertBusinessInfos(Collections.singletonList(businessInfo));
}
// 设置拓展信息
RoomExtendInfo extendInfo = roomDTO.getExtendInfo();
if (extendInfo != null) {
extendInfo.setRoomId(roomId);
//setTenantId(extendInfo);
extendInfo.setCreateTime(now);
extendInfo.setLastModTime(now);
extendInfo.setCreateUserId(user.getUserName());
extendInfo.setLastModUserId(user.getUserName());
extendInfo.setDelFlag("0");
extendInfo.setDelFlag(RoomConstants.DEL_FLAG_NORMAL);
// 处理标签
if (roomDTO.getTags() != null && !roomDTO.getTags().isEmpty()) {
@ -225,7 +229,7 @@ public class RoomServiceImpl implements IRoomService {
}
// 插入拓展信息
extendInfoMapper.insertRoomExtendInfo(extendInfo);
extendInfoMapper.batchInsertExtendInfos(Collections.singletonList(extendInfo));
}
// 插入房源图片
@ -245,7 +249,7 @@ public class RoomServiceImpl implements IRoomService {
public int updateRoom(RoomDTO roomDTO) {
// 获取当前用户
ContextUser user = new ContextUser();
user.setUsername("admin");
user.setUsername(RoomConstants.DEFAULT_USERNAME);
Date now = new Date();
Long roomId = roomDTO.getId();
@ -270,11 +274,10 @@ public class RoomServiceImpl implements IRoomService {
if (existBusinessInfo != null) {
businessInfoMapper.updateRoomBusinessInfo(businessInfo);
} else {
//setTenantId(businessInfo);
businessInfo.setCreateTime(now);
businessInfo.setCreateUserId(user.getUserName());
businessInfo.setDelFlag("0");
businessInfoMapper.insertRoomBusinessInfo(businessInfo);
businessInfo.setDelFlag(RoomConstants.DEL_FLAG_NORMAL);
businessInfoMapper.batchInsertBusinessInfos(Collections.singletonList(businessInfo));
}
}
@ -295,11 +298,10 @@ public class RoomServiceImpl implements IRoomService {
if (existExtendInfo != null) {
extendInfoMapper.updateRoomExtendInfo(extendInfo);
} else {
//setTenantId(extendInfo);
extendInfo.setCreateTime(now);
extendInfo.setCreateUserId(user.getUserName());
extendInfo.setDelFlag("0");
extendInfoMapper.insertRoomExtendInfo(extendInfo);
extendInfo.setDelFlag(RoomConstants.DEL_FLAG_NORMAL);
extendInfoMapper.batchInsertExtendInfos(Collections.singletonList(extendInfo));
}
}
@ -344,94 +346,67 @@ public class RoomServiceImpl implements IRoomService {
return rows;
}
/**
* 批量删除房源信息
*/
@Override
@Transactional
public int deleteRoomByIds(String[] ids) {
// 检查房源是否有正在执行的合同
for (String id : ids) {
if (checkRoomContract(Long.valueOf(id))) {
throw new RuntimeException("房源ID为" + id + "的房源有正在执行的合同,不能删除");
}
}
// 批量删除房源基础信息
int rows = roomMapper.deleteRoomByIds(ids);
// 批量删除招商信息
businessInfoMapper.deleteRoomBusinessInfoByRoomIds(ids);
// 批量删除拓展信息
extendInfoMapper.deleteRoomExtendInfoByRoomIds(ids);
// 批量删除图片信息
imageMapper.deleteRoomImagesByRoomIds(ids);
return rows;
}
/**
* 导出房源信息
*/
@Override
public List<RoomExportDTO> exportRoom(Room room) {
// 设置租户ID
//setTenantId(room);
public List<RoomExportDTO> exportRoom(RoomQueryDTO queryDTO) {
// 查询房源信息
List<Room> roomList = roomMapper.selectRoomList(room);
List<Room> roomList = roomMapper.selectRoomList(queryDTO);
if (roomList == null || roomList.isEmpty()) {
return new ArrayList<>();
}
// 转换为导出DTO
List<RoomExportDTO> exportList = new ArrayList<>();
if (roomList.isEmpty()) {
return exportList;
}
// 转换为导出DTO
for (Room r : roomList) {
RoomExportDTO exportDTO = new RoomExportDTO();
// 设置项目名称
if (StringUtils.isNotEmpty(r.getProjectId())) {
exportDTO.setProjectName(projectMapper.selectProjectById(r.getProjectId()).getProjectName());
}
// 设置楼宇名称
if (r.getBuildingId()!=null) {
exportDTO.setBuildingName(buildingMapper.selectBuildingById(r.getBuildingId()).getBuildingName());
}
// 设置楼层名称
if (r.getFloorId()!=null) {
exportDTO.setFloorName(floorMapper.selectFloorById(r.getFloorId()).getFloorName());
}
// 设置基础信息
// 复制基本信息
exportDTO.setId(r.getId());
exportDTO.setProjectId(r.getProjectId());
exportDTO.setProjectName(r.getProjectName());
exportDTO.setBuildingId(r.getBuildingId());
exportDTO.setBuildingName(r.getBuildingName());
exportDTO.setFloorId(r.getFloorId());
exportDTO.setFloorName(r.getFloorName());
exportDTO.setRoomNumber(r.getRoomNumber());
exportDTO.setRoomDigitalNumber(r.getRoomDigitalNumber());
exportDTO.setRoomManageNumber(r.getRoomManageNumber());
exportDTO.setRoomName(r.getRoomName());
exportDTO.setRoomType(r.getRoomType());
exportDTO.setFloor(r.getFloor());
exportDTO.setBuildingArea(r.getBuildingArea());
exportDTO.setRentalArea(r.getRentalArea());
exportDTO.setBillingArea(r.getBillingArea());
exportDTO.setBuildingArea(r.getBuildingArea());
exportDTO.setInnerArea(r.getInnerArea());
exportDTO.setRoomManageNumber(r.getRoomManageNumber());
exportDTO.setIsVirtual(r.getIsVirtual());
exportDTO.setDeliveryTime(r.getDeliveryTime());
exportDTO.setOwnerId(r.getOwnerId());
exportDTO.setPropertyNature(r.getPropertyNature());
exportDTO.setHeight(r.getHeight());
exportDTO.setLoadValue(r.getLoadValue());
exportDTO.setRoomStatus(r.getRoomStatus());
exportDTO.setCreateTime(r.getCreateTime());
exportDTO.setPrice(r.getPrice());
exportDTO.setPriceUnit(r.getPriceUnit());
exportDTO.setRentalStatus(r.getRentalStatus());
exportDTO.setAvailableDate(r.getAvailableDate());
exportDTO.setBusinessStatus(r.getBusinessStatus());
exportDTO.setDecorationStatus(r.getDecorationStatus());
// todo 查询接口进行转换 注意不要在for循环里面调用
exportDTO.setTags(r.getTags());
exportDTO.setPriceAndUnit((exportDTO.getPrice()));
// 转换枚举字段
EnumConverter.convert(exportDTO);
// 查询招商信息
RoomBusinessInfo businessInfo = businessInfoMapper.selectRoomBusinessInfoByRoomId(r.getId());
if (businessInfo != null) {
exportDTO.setPrice(businessInfo.getPrice());
exportDTO.setPriceUnit(businessInfo.getPriceUnit());
exportDTO.setRentalStatus(businessInfo.getRentalStatus());
exportDTO.setAvailableDate(businessInfo.getAvailableDate());
exportDTO.setBusinessStatus(businessInfo.getBusinessStatus());
exportDTO.setDecorationStatus(businessInfo.getDecorationStatus());
}
// 查询拓展信息
RoomExtendInfo extendInfo = extendInfoMapper.selectRoomExtendInfoByRoomId(r.getId());
if (extendInfo != null) {
exportDTO.setTags(extendInfo.getTags());
}
exportList.add(exportDTO);
}
@ -470,83 +445,7 @@ public class RoomServiceImpl implements IRoomService {
// 调用合同服务接口检查房源是否有正在执行的合同
return contractFeignClient.checkRoomContract(id, null);
}
/**
* 根据ID列表导出房源信息
*
* @param ids 房源ID数组
* @return 房源信息列表
*/
@Override
public List<RoomExportDTO> exportRoomByIds(String[] ids) {
if (ids == null || ids.length == 0) {
return new ArrayList<>();
}
List<RoomExportDTO> exportList = new ArrayList<>();
// 查询指定ID的房源信息
List<Room> roomList = roomMapper.selectRoomByIds(ids);
if (roomList.isEmpty()) {
return exportList;
}
// 转换为导出DTO
for (Room r : roomList) {
RoomExportDTO exportDTO = new RoomExportDTO();
// 复制基本信息
exportDTO.setId(r.getId());
exportDTO.setProjectId(r.getProjectId());
exportDTO.setProjectName(r.getProjectName());
exportDTO.setBuildingId(r.getBuildingId());
exportDTO.setBuildingName(r.getBuildingName());
exportDTO.setFloorId(r.getFloorId());
exportDTO.setFloorName(r.getFloorName());
exportDTO.setRoomNumber(r.getRoomNumber());
exportDTO.setRoomDigitalNumber(r.getRoomDigitalNumber());
exportDTO.setRoomManageNumber(r.getRoomManageNumber());
exportDTO.setRoomName(r.getRoomName());
exportDTO.setRoomType(r.getRoomType());
exportDTO.setFloor(r.getFloor());
exportDTO.setIsWholeFloor(r.getIsWholeFloor());
exportDTO.setBuildingArea(r.getBuildingArea());
exportDTO.setRentalArea(r.getRentalArea());
exportDTO.setBillingArea(r.getBillingArea());
exportDTO.setInnerArea(r.getInnerArea());
exportDTO.setIsVirtual(r.getIsVirtual());
exportDTO.setDeliveryTime(r.getDeliveryTime());
exportDTO.setOwnerId(r.getOwnerId());
exportDTO.setPropertyNature(r.getPropertyNature());
exportDTO.setHeight(r.getHeight());
exportDTO.setLoadValue(r.getLoadValue());
exportDTO.setRoomStatus(r.getRoomStatus());
exportDTO.setCreateTime(r.getCreateTime());
// 查询招商信息
RoomBusinessInfo businessInfo = businessInfoMapper.selectRoomBusinessInfoByRoomId(r.getId());
if (businessInfo != null) {
exportDTO.setPrice(businessInfo.getPrice());
exportDTO.setPriceUnit(businessInfo.getPriceUnit());
exportDTO.setRentalStatus(businessInfo.getRentalStatus());
exportDTO.setAvailableDate(businessInfo.getAvailableDate());
exportDTO.setBusinessStatus(businessInfo.getBusinessStatus());
exportDTO.setDecorationStatus(businessInfo.getDecorationStatus());
}
// 查询拓展信息
RoomExtendInfo extendInfo = extendInfoMapper.selectRoomExtendInfoByRoomId(r.getId());
if (extendInfo != null) {
exportDTO.setTags(extendInfo.getTags());
}
exportList.add(exportDTO);
}
return exportList;
}
/**
* 插入房源图片
*
@ -564,259 +463,17 @@ public class RoomServiceImpl implements IRoomService {
image.setRoomId(roomId);
image.setImageType(imageType);
image.setSortOrder(sortOrder++);
//setTenantId(image);
image.setCreateTime(now);
image.setLastModTime(now);
image.setCreateUserId(user.getUserName());
image.setLastModUserId(user.getUserName());
image.setDelFlag("0");
image.setDelFlag(RoomConstants.DEL_FLAG_NORMAL);
imageMapper.insertRoomImage(image);
}
}
}
/**
* 设置租户ID
*
* @param obj 需要设置租户ID的对象
*/
// private void setTenantId(Object obj) {
// if (obj instanceof Room) {
// ((Room) obj).setTenantId(UserContextHolder.get().getTenantId());
// } else if (obj instanceof RoomBusinessInfo) {
// ((RoomBusinessInfo) obj).setTenantId(UserContextHolder.get().getTenantId());
// } else if (obj instanceof RoomExtendInfo) {
// ((RoomExtendInfo) obj).setTenantId(UserContextHolder.get().getTenantId());
// } else if (obj instanceof RoomImage) {
// ((RoomImage) obj).setTenantId(UserContextHolder.get().getTenantId());
// }
// }
/**
* 批量导入房源信息
*
* @param file 导入文件
* @return 导入结果信息
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> importRoom(MultipartFile file) throws Exception {
// 初始化结果
Map<String, Object> result = new HashMap<>();
int successCount = 0;
int failCount = 0;
StringBuilder failMsg = new StringBuilder();
// 解析Excel文件
ExcelUtil<RoomImportDTO> excelUtil = new ExcelUtil<>(RoomImportDTO.class);
List<RoomImportDTO> roomImportList = excelUtil.importExcel(file.getInputStream());
if (roomImportList.isEmpty()) {
throw new RuntimeException("Excel文件中没有数据");
}
// 当前用户
ContextUser user = UserContextHolder.get();
Date now = new Date();
// 处理每一行数据
for (int i = 0; i < roomImportList.size(); i++) {
RoomImportDTO roomImport = roomImportList.get(i);
try {
// 1. 查找项目
String projectId = getProjectIdByName(roomImport.getProjectName());
if (projectId == null) {
failCount++;
String errorMsg = "项目[" + roomImport.getProjectName() + "]不存在";
failMsg.append("").append(i + 2).append("行:").append(errorMsg).append("<br/>");
roomImport.setImportResult(errorMsg);
continue;
}
// 2. 查找楼宇
Long buildingId = getBuildingIdByName(projectId, roomImport.getBuildingName());
if (buildingId == null) {
failCount++;
String errorMsg = "楼宇[" + roomImport.getBuildingName() + "]不存在";
failMsg.append("").append(i + 2).append("行:").append(errorMsg).append("<br/>");
roomImport.setImportResult(errorMsg);
continue;
}
// 3. 查找楼层
Long floorId = getFloorIdByName(buildingId, roomImport.getFloorName());
if (floorId == null) {
failCount++;
String errorMsg = "楼层[" + roomImport.getFloorName() + "]不存在";
failMsg.append("").append(i + 2).append("行:").append(errorMsg).append("<br/>");
roomImport.setImportResult(errorMsg);
continue;
}
// 4. 检查房源编号是否重复
boolean roomExists = checkRoomCodeExists(roomImport.getRoomNumber(), projectId, buildingId, floorId);
if (roomExists) {
failCount++;
String errorMsg = "房源编号[" + roomImport.getRoomNumber() + "]已存在";
failMsg.append("").append(i + 2).append("行:").append(errorMsg).append("<br/>");
roomImport.setImportResult(errorMsg);
continue;
}
// 5. 保存房源基本信息
Room room = new Room();
room.setProjectId(projectId);
room.setProjectName(roomImport.getProjectName());
room.setBuildingId(buildingId);
room.setBuildingName(roomImport.getBuildingName());
room.setFloorId(floorId);
room.setFloorName(roomImport.getFloorName());
room.setRoomNumber(roomImport.getRoomNumber());
room.setRoomDigitalNumber(roomImport.getRoomDigitalNumber());
room.setRoomManageNumber(roomImport.getRoomManageNumber());
room.setBuildingArea(roomImport.getBuildingArea());
room.setRentalArea(roomImport.getRentalArea());
room.setBillingArea(roomImport.getBillingArea());
room.setHeight(roomImport.getHeight());
room.setIsVirtual("0"); // 默认非虚拟房源
room.setRoomStatus("1"); // 默认公开状态
room.setDelFlag("0");
room.setCreateTime(now);
room.setLastModTime(now);
// 插入房源基本信息
roomMapper.insertRoom(room);
// 6. 创建招商信息
RoomBusinessInfo businessInfo = new RoomBusinessInfo();
businessInfo.setRoomId(room.getId());
businessInfo.setPrice(roomImport.getPrice());
businessInfo.setFloorPrice(roomImport.getFloorPrice());
businessInfo.setPriceUnit(roomImport.getPriceUnit());
businessInfo.setRentalStatus("1"); // 默认待租状态
businessInfo.setBusinessStatus("1"); // 默认招商状态
businessInfo.setDecorationStatus("3"); // 默认毛坯状态
businessInfo.setDelFlag("0");
businessInfo.setCreateTime(now);
businessInfo.setLastModTime(now);
// 插入招商信息
businessInfoMapper.insertRoomBusinessInfo(businessInfo);
// 7. 创建拓展信息
if (StringUtils.isNotBlank(roomImport.getTags())) {
RoomExtendInfo extendInfo = new RoomExtendInfo();
extendInfo.setRoomId(room.getId());
extendInfo.setTags(roomImport.getTags());
extendInfo.setDelFlag("0");
extendInfo.setCreateTime(now);
extendInfo.setLastModTime(now);
// 插入拓展信息
extendInfoMapper.insertRoomExtendInfo(extendInfo);
}
successCount++;
roomImport.setImportResult("导入成功");
} catch (Exception e) {
failCount++;
String errorMsg = "导入失败:" + e.getMessage();
failMsg.append("").append(i + 2).append("行:").append(errorMsg).append("<br/>");
roomImport.setImportResult(errorMsg);
}
}
// 只有在有导入失败的情况下才生成Excel文件
byte[] excelBytes = null;
if (failCount > 0) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
exportToExcelWithTemplate(roomImportList, outputStream);
excelBytes = outputStream.toByteArray();
result.put("excelBytes", excelBytes);
}
result.put("successCount", successCount);
result.put("failCount", failCount);
result.put("failMsg", failMsg.toString());
result.put("allSuccess", failCount == 0);
return result;
}
/**
* 使用模板文件导出Excel
*
* @param roomList 房源数据列表
* @param outputStream 输出流
* @throws IOException IO异常
*/
public void exportToExcelWithTemplate(List<RoomImportDTO> roomList, OutputStream outputStream) throws IOException {
// 加载模板文件
ClassPathResource resource = new ClassPathResource("templates/room_import.xlsx");
InputStream inputStream = resource.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
inputStream.close();
// 获取第一个工作表
Sheet sheet = workbook.getSheetAt(0);
// 获取标题行
Row headerRow = sheet.getRow(0);
if (headerRow == null) {
throw new RuntimeException("模板文件格式错误:未找到标题行");
}
// 获取字段映射
List<Field> fields = getExcelFields(RoomExport.class);
Map<Integer, Field> columnMap = new HashMap<>();
for (int i = 0; i < headerRow.getLastCellNum(); i++) {
Cell cell = headerRow.getCell(i);
if (cell != null) {
String headerName = cell.getStringCellValue();
for (Field field : fields) {
Excel excel = field.getAnnotation(Excel.class);
if (excel != null && excel.name().equals(headerName)) {
columnMap.put(i, field);
break;
}
}
}
}
// 填充数据行
int startRow = 4; // 从第4行开始填充数据
for (RoomImportDTO room : roomList) {
Row row = sheet.getRow(startRow);
if (row == null) {
row = sheet.createRow(startRow);
}
for (Map.Entry<Integer, Field> entry : columnMap.entrySet()) {
int columnIndex = entry.getKey();
Field field = entry.getValue();
Cell cell = row.getCell(columnIndex);
if (cell == null) {
cell = row.createCell(columnIndex);
}
field.setAccessible(true);
try {
Object value = field.get(room);
if (value != null) {
cell.setCellValue(value.toString());
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
startRow++;
}
// 写入输出流
workbook.write(outputStream);
workbook.close();
}
private List<Field> getExcelFields(Class<?> clazz) {
List<Field> fields = new ArrayList<>();
Field[] declaredFields = clazz.getDeclaredFields();
@ -899,8 +556,8 @@ public class RoomServiceImpl implements IRoomService {
if (StringUtils.isBlank(roomCode)) {
return false;
}
Room param = new Room();
RoomQueryDTO param = new RoomQueryDTO();
param.setRoomNumber(roomCode);
param.setProjectId(projectId);
param.setBuildingId(buildingId);
@ -908,4 +565,84 @@ public class RoomServiceImpl implements IRoomService {
List<Room> rooms = roomMapper.selectRoomList(param);
return !rooms.isEmpty();
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void batchInsertRooms(List<Room> rooms, List<RoomBusinessInfo> businessInfos, List<RoomExtendInfo> extendInfos) {
if (rooms == null || rooms.isEmpty()) {
return;
}
// 设置批量插入的批次大小
int batchSize = RoomConstants.BATCH_SIZE;
// 分批处理房间信息
for (int i = 0; i < rooms.size(); i += batchSize) {
int end = Math.min(i + batchSize, rooms.size());
List<Room> batch = rooms.subList(i, end);
roomMapper.batchInsertRooms(batch);
}
// 获取所有插入的Room的ID
List<Long> roomIds = rooms.stream()
.map(Room::getId)
.collect(Collectors.toList());
// 设置RoomBusinessInfo和RoomExtendInfo的roomId
if (businessInfos != null && !businessInfos.isEmpty()) {
for (int i = 0; i < businessInfos.size(); i++) {
if (i < roomIds.size()) {
businessInfos.get(i).setRoomId(roomIds.get(i));
}
}
// 分批处理招商信息
for (int i = 0; i < businessInfos.size(); i += batchSize) {
int end = Math.min(i + batchSize, businessInfos.size());
List<RoomBusinessInfo> batch = businessInfos.subList(i, end);
businessInfoMapper.batchInsertBusinessInfos(batch);
}
}
// 设置RoomExtendInfo的roomId并分批处理扩展信息
if (extendInfos != null && !extendInfos.isEmpty()) {
for (int i = 0; i < extendInfos.size(); i++) {
if (i < roomIds.size()) {
extendInfos.get(i).setRoomId(roomIds.get(i));
}
}
for (int i = 0; i < extendInfos.size(); i += batchSize) {
int end = Math.min(i + batchSize, extendInfos.size());
List<RoomExtendInfo> batch = extendInfos.subList(i, end);
extendInfoMapper.batchInsertExtendInfos(batch);
}
}
}
@Override
public Set<String> getExistingRoomNumbers(String projectId, Set<String> roomNumbers) {
if (projectId == null || roomNumbers == null || roomNumbers.isEmpty()) {
return Collections.emptySet();
}
// 1. 查询数据库中已存在的房间号
Set<String> existingInDB = roomMapper.getExistingRoomNumbers(projectId, roomNumbers);
// 2. 检查当前批次中是否有重复的房间号
Set<String> duplicatesInBatch = new HashSet<>();
Set<String> seen = new HashSet<>();
for (String roomNumber : roomNumbers) {
if (!seen.add(roomNumber)) {
duplicatesInBatch.add(roomNumber);
}
}
// 3. 合并所有重复的房间号
Set<String> allDuplicates = new HashSet<>(existingInDB);
allDuplicates.addAll(duplicatesInBatch);
return allDuplicates;
}
}

View File

@ -0,0 +1,24 @@
package com.eden.room.utils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 枚举转换注解
* 用于标记需要将枚举key转换为value的字段
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface EnumConvert {
/**
* 枚举类
*/
Class<? extends Enum<?>> value();
/**
* 获取value的方法名
*/
String method() default "getValue";
}

View File

@ -0,0 +1,50 @@
package com.eden.room.utils;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
* 枚举转换工具类
*/
public class EnumConverter {
/**
* 转换对象中的枚举字段
*/
public static void convert(Object obj) {
if (obj == null) {
return;
}
Class<?> clazz = obj.getClass();
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
EnumConvert annotation = field.getAnnotation(EnumConvert.class);
if (annotation != null) {
try {
convertField(obj, field, annotation);
} catch (Exception e) {
throw new RuntimeException("枚举转换失败: " + field.getName(), e);
}
}
}
}
/**
* 转换字段值
*/
private static void convertField(Object obj, Field field, EnumConvert annotation) throws Exception {
field.setAccessible(true);
Object value = field.get(obj);
if (value != null) {
Class<? extends Enum<?>> enumClass = annotation.value();
// 获取getValue静态方法
Method getValueMethod = enumClass.getMethod(annotation.method(), String.class);
// 直接调用getValue方法获取转换后的值
Object convertedValue = getValueMethod.invoke(null, value.toString());
field.set(obj, convertedValue);
}
}
}

View File

@ -0,0 +1,32 @@
package com.eden.room.utils;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
/**
* 枚举校验注解
*/
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = EnumValidator.class)
public @interface EnumValid {
/**
* 枚举类
*/
Class<? extends Enum<?>> value();
/**
* 校验方法名
*/
String method() default "isValid";
/**
* 错误信息
*/
String message() default "无效的枚举值";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}

View File

@ -0,0 +1,34 @@
package com.eden.room.utils;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.lang.reflect.Method;
/**
* 枚举校验器
*/
public class EnumValidator implements ConstraintValidator<EnumValid, String> {
private Class<? extends Enum<?>> enumClass;
private String methodName;
@Override
public void initialize(EnumValid constraintAnnotation) {
this.enumClass = constraintAnnotation.value();
this.methodName = constraintAnnotation.method();
}
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
if (value == null || value.isEmpty()) {
return true;
}
try {
Method method = enumClass.getMethod(methodName, String.class);
return (boolean) method.invoke(null, value);
} catch (Exception e) {
return false;
}
}
}

View File

@ -11,6 +11,7 @@ import java.util.HashMap;
import java.util.Map;
import java.io.IOException;
import com.alibaba.excel.EasyExcel;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
@ -271,7 +272,6 @@ public class ExcelUtil<T> {
}
}
}
// 写入输出流
workbook.write(os);
} finally {

View File

@ -0,0 +1,42 @@
package com.eden.room.utils.excel;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.math.BigDecimal;
// 自定义转换器
public class BigDecimalConverter implements Converter<BigDecimal> {
@Override
public Class supportJavaTypeKey() {
return BigDecimal.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public BigDecimal convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
String stringValue = cellData.getStringValue();
if (stringValue == null || stringValue.trim().isEmpty()) {
return BigDecimal.ZERO;
}
try {
return new BigDecimal(stringValue.trim());
} catch (NumberFormatException e) {
return BigDecimal.ZERO;
}
}
@Override
public WriteCellData convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
return new WriteCellData(value.toString());
}
}

View File

@ -0,0 +1,62 @@
package com.eden.room.utils.excel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import org.apache.poi.ss.usermodel.*;
import org.springframework.validation.Validator;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Excel导入监听器
* @param <T> 导入数据类型
*/
public abstract class ExcelImportListener<T> extends AnalysisEventListener<T> {
protected final List<T> dataList = new ArrayList<>();
protected final Map<Integer, String> errorMap = new ConcurrentHashMap<>();
protected Boolean successFlag = true;
protected final Validator validator;
public ExcelImportListener(Validator validator) {
this.validator = validator;
}
@Override
public void invoke(T data, AnalysisContext context) {
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
// 处理剩余数据
if (!dataList.isEmpty()) {
batchProcess();
}
}
/**
* 批量处理数据
*/
protected abstract void batchProcess();
/**
* 获取错误信息
*/
public Map<Integer, String> getErrorMap() {
return errorMap;
}
public Boolean getSuccessFlag() {
return successFlag;
}
public abstract List<T> getDataList();
}

View File

@ -0,0 +1,220 @@
package com.eden.room.utils.excel;
import com.alibaba.excel.context.AnalysisContext;
import com.eden.room.common.enums.*;
import com.eden.room.domain.Room;
import com.eden.room.domain.RoomBusinessInfo;
import com.eden.room.domain.RoomExtendInfo;
import com.eden.room.domain.dto.RoomImportDTO;
import com.eden.room.service.IBuildingService;
import com.eden.room.service.IFloorService;
import com.eden.room.service.IProjectService;
import com.eden.room.service.IRoomService;
import org.springframework.validation.BeanPropertyBindingResult;
import org.springframework.validation.BindingResult;
import org.springframework.validation.Validator;
import com.eden.room.constant.RoomConstants;
import java.util.*;
import java.util.stream.Collectors;
/**
* 房源导入监听器
*/
public class RoomImportListener extends ExcelImportListener<RoomImportDTO> {
private final IRoomService roomService;
private final IProjectService projectService;
private final IBuildingService buildingService;
private final IFloorService floorService;
// 用于存储待导入的数据
private final List<Room> rooms = new ArrayList<>();
private final List<RoomBusinessInfo> businessInfos = new ArrayList<>();
private final List<RoomExtendInfo> extendInfos = new ArrayList<>();
public RoomImportListener(Validator validator, IRoomService roomService, IProjectService projectService, IBuildingService buildingService, IFloorService floorService) {
super(validator);
this.roomService = roomService;
this.projectService = projectService;
this.buildingService = buildingService;
this.floorService = floorService;
}
@Override
public void invoke(RoomImportDTO data, AnalysisContext context) {
// 获取当前行号
int rowIndex = context.readRowHolder().getRowIndex();
if (rowIndex <= RoomConstants.IMPORT_HEADER_ROW_INDEX) {
return;
}
dataList.add(data);
// 数据校验
BindingResult bindingResult = new BeanPropertyBindingResult(data, RoomImportDTO.class.getName());
validator.validate(data, bindingResult);
if (bindingResult.hasErrors()) {
// 记录错误信息
data.setImportResult(bindingResult.getAllErrors().get(0).getDefaultMessage());
successFlag = false;
}
}
@Override
protected void batchProcess() {
if (dataList.isEmpty()) {
return;
}
Date now = new Date();
// 1. 收集所有需要查询的项目楼宇楼层信息
Set<String> projectNames = dataList.stream()
.map(RoomImportDTO::getProjectName)
.collect(Collectors.toSet());
Map<String, Set<String>> projectBuildingMap = new HashMap<>();
Map<String, Set<String>> buildingFloorMap = new HashMap<>();
for (RoomImportDTO dto : dataList) {
projectBuildingMap.computeIfAbsent(dto.getProjectName(), k -> new HashSet<>())
.add(dto.getBuildingName());
buildingFloorMap.computeIfAbsent(dto.getBuildingName(), k -> new HashSet<>())
.add(dto.getFloorName());
}
// 2. 批量查询项目楼宇楼层信息
Map<String, String> projectIdMap = projectService.getProjectIdsByNames(projectNames);
Map<String, Map<String, Long>> buildingIdMap = new HashMap<>();
Map<String, Map<String, Long>> floorIdMap = new HashMap<>();
for (Map.Entry<String, Set<String>> entry : projectBuildingMap.entrySet()) {
String projectId = projectIdMap.get(entry.getKey());
if (projectId != null) {
buildingIdMap.put(projectId,
buildingService.getBuildingIdsByNames(projectId, entry.getValue()));
}
}
for (Map.Entry<String, Set<String>> entry : buildingFloorMap.entrySet()) {
for (Map<String, Long> buildingMap : buildingIdMap.values()) {
Long buildingId = buildingMap.get(entry.getKey());
if (buildingId != null) {
floorIdMap.put(buildingId.toString(),
floorService.getFloorIdsByNames(buildingId, entry.getValue()));
}
}
}
// 3. 收集所有需要检查的房间号
Map<String, Set<String>> projectRoomMap = new HashMap<>();
for (RoomImportDTO dto : dataList) {
String projectId = projectIdMap.get(dto.getProjectName());
if (projectId != null) {
projectRoomMap.computeIfAbsent(projectId, k -> new HashSet<>())
.add(dto.getRoomNumber());
}
}
// 4. 批量查询已存在的房间号
Map<String, Set<String>> existingRoomMap = new HashMap<>();
for (Map.Entry<String, Set<String>> entry : projectRoomMap.entrySet()) {
existingRoomMap.put(entry.getKey(),
roomService.getExistingRoomNumbers(entry.getKey(), entry.getValue()));
}
// 5. 处理每一行数据
for (RoomImportDTO dto : dataList) {
String projectId = projectIdMap.get(dto.getProjectName());
if (projectId == null) {
dto.setImportResult("项目不存在。");
successFlag = false;
}
Map<String, Long> buildingMap = buildingIdMap.get(projectId);
Long buildingId = buildingMap != null ? buildingMap.get(dto.getBuildingName()) : null;
if (buildingId == null) {
dto.setImportResult("楼宇不存在。");
successFlag = false;
}
Map<String, Long> floorMap = floorIdMap.get(buildingId.toString());
Long floorId = floorMap != null ? floorMap.get(dto.getFloorName()) : null;
if (floorId == null) {
dto.setImportResult("楼层不存在。");
successFlag = false;
}
// 检查房间号是否重复
Set<String> existingRooms = existingRoomMap.get(projectId);
if (existingRooms != null && existingRooms.contains(dto.getRoomNumber())) {
dto.setImportResult("房间号已存在。");
successFlag = false;
}
if (!successFlag){
continue;
}
// 创建Room对象
Room room = new Room();
room.setProjectId(projectId);
room.setProjectName(dto.getProjectName());
room.setBuildingId(buildingId);
room.setBuildingName(dto.getBuildingName());
room.setFloorId(floorId);
room.setFloorName(dto.getFloorName());
room.setRoomNumber(dto.getRoomNumber());
room.setRoomDigitalNumber(dto.getRoomDigitalNumber());
room.setRoomManageNumber(dto.getRoomManageNumber());
room.setBuildingArea(dto.getBuildingArea());
room.setRentalArea(dto.getRentalArea());
room.setBillingArea(dto.getBillingArea());
room.setHeight(dto.getHeight());
room.setIsVirtual(VirtualFlagEnum.NO.getKey());
room.setRoomStatus(RoomStatusEnum.PUBLIC.getKey());
room.setDelFlag(RoomConstants.DEL_FLAG_NORMAL);
room.setCreateTime(now);
room.setLastModTime(now);
rooms.add(room);
// 创建RoomBusinessInfo对象
RoomBusinessInfo businessInfo = new RoomBusinessInfo();
businessInfo.setPrice(dto.getPrice());
businessInfo.setFloorPrice(dto.getFloorPrice());
businessInfo.setPriceUnit(PriceUnitEnum.getByValue(dto.getPriceUnit()));
businessInfo.setRentalStatus(RentalStatusEnum.WAITING.getKey());
businessInfo.setBusinessStatus(BusinessStatusEnum.BUSINESS.getKey());
businessInfo.setDecorationStatus(DecorationStatusEnum.ROUGH.getKey());
businessInfo.setDelFlag(RoomConstants.DEL_FLAG_NORMAL);
businessInfo.setCreateTime(now);
businessInfo.setLastModTime(now);
businessInfos.add(businessInfo);
// 创建RoomExtendInfo对象
RoomExtendInfo extendInfo = new RoomExtendInfo();
extendInfo.setTags(dto.getTags());
extendInfo.setDelFlag(RoomConstants.DEL_FLAG_NORMAL);
extendInfo.setCreateTime(now);
extendInfo.setLastModTime(now);
extendInfos.add(extendInfo);
}
// 6. 批量保存数据
if (!rooms.isEmpty() && successFlag) {
roomService.batchInsertRooms(rooms, businessInfos, extendInfos);
}
}
@Override
public List<RoomImportDTO> getDataList() {
return dataList;
}
}

View File

@ -7,7 +7,7 @@
id,
project_name as projectName,
project_type as projectType
FROM tb_project
FROM TB_RES_PROJECT
WHERE del_flag = '0'
</select>
@ -16,7 +16,7 @@
id,
building_name as buildingName,
building_code as buildingCode
FROM tb_building
FROM TB_RES_BUILDING
WHERE project_id = #{projectId}
AND del_flag = '0'
</select>
@ -26,7 +26,7 @@
id,
floor_name as floorName,
floor_number as floorNumber
FROM tb_floor
FROM TB_RES_FLOOR
WHERE building_id = #{buildingId}
AND del_flag = '0'
ORDER BY floor_number
@ -40,7 +40,7 @@
room_status as roomStatus,
building_area as buildingArea,
rental_area as rentalArea
FROM tb_room
FROM TB_RES_ROOM
WHERE floor_id = #{floorId}
AND del_flag = '0'
ORDER BY room_digital_number

View File

@ -49,8 +49,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.last_mod_time, b.create_user_id, b.last_mod_user_id,
b.del_flag, b.remark, b.reserve1, b.reserve2, b.reserve3,
p.project_name
from TB_BUILDING b
left join TB_PROJECT p on b.project_id = p.id and p.del_flag = '0'
from TB_RES_BUILDING b
left join TB_RES_PROJECT p on b.project_id = p.id and p.del_flag = '0'
</sql>
<select id="selectBuildingList" parameterType="Building" resultMap="BuildingResult">
@ -82,15 +82,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by sort_order desc, create_time desc
</select>
<select id="selectBuildingById" parameterType="String" resultMap="BuildingResult">
<select id="selectBuildingById" parameterType="Long" resultMap="BuildingResult">
<include refid="selectBuildingVo"/>
where b.id = #{id} and b.del_flag = '0'
</select>
<insert id="insertBuilding" parameterType="Building" useGeneratedKeys="true" keyProperty="id">
insert into TB_BUILDING
insert into TB_RES_BUILDING
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tenantId != null">tenant_id,</if>
<if test="projectId != null">project_id,</if>
<if test="buildingCode != null">building_code,</if>
<if test="buildingName != null">building_name,</if>
@ -124,7 +123,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
last_mod_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantId != null">#{tenantId},</if>
<if test="projectId != null">#{projectId},</if>
<if test="buildingCode != null">#{buildingCode},</if>
<if test="buildingName != null">#{buildingName},</if>
@ -160,7 +158,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<update id="updateBuilding" parameterType="Building">
update TB_BUILDING
update TB_RES_BUILDING
<trim prefix="SET" suffixOverrides=",">
<if test="buildingCode != null">building_code = #{buildingCode},</if>
<if test="buildingName != null">building_name = #{buildingName},</if>
@ -193,22 +191,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} and del_flag = '0'
</update>
<delete id="deleteBuildingById" parameterType="String">
update TB_BUILDING set del_flag = '1' where id = #{id}
<delete id="deleteBuildingById" parameterType="Long">
update TB_RES_BUILDING set del_flag = '1' where id = #{id}
</delete>
<delete id="deleteBuildingByIds" parameterType="String">
update TB_BUILDING set del_flag = '1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
<delete id="deleteBuildingByIds" parameterType="java.util.List">
update TB_RES_BUILDING set del_flag = '1' where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="checkBuildingNameExists" parameterType="Building" resultType="Integer">
select count(*) from TB_BUILDING
select count(*) from TB_RES_BUILDING
where building_name = #{buildingName}
and project_id = #{projectId}
and tenant_id = #{tenantId}
and del_flag = '0'
<if test="id != null and id != ''">
and id != #{id}
@ -216,51 +213,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="checkBuildingCodeExists" parameterType="Building" resultType="Integer">
select count(*) from TB_BUILDING
select count(*) from TB_RES_BUILDING
where building_code = #{buildingCode}
and project_id = #{projectId}
and tenant_id = #{tenantId}
and del_flag = '0'
<if test="id != null and id != ''">
and id != #{id}
</if>
</select>
<select id="selectBuildingStatistics" parameterType="String" resultMap="BuildingResult">
<select id="selectBuildingStatistics" parameterType="Long" resultMap="BuildingResult">
select b.*,
(select count(*) from TB_ROOM_BASE where building_id = b.id and del_flag = '0') as total_rooms,
(select count(*) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select count(*) from TB_RES_ROOM where building_id = b.id and del_flag = '0') as total_rooms,
(select count(*) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.building_id = b.id and rb.del_flag = '0' and rbs.rental_status = '已租') as rented_rooms,
(select count(*) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select count(*) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.building_id = b.id and rb.del_flag = '0' and rbs.rental_status = '待租') as waiting_rooms,
(select COALESCE(sum(rb.building_area), 0) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select COALESCE(sum(rb.building_area), 0) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.building_id = b.id and rb.del_flag = '0' and rbs.rental_status = '已租') as rented_area,
(select COALESCE(sum(rb.building_area), 0) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select COALESCE(sum(rb.building_area), 0) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.building_id = b.id and rb.del_flag = '0' and rbs.rental_status = '待租') as waiting_area,
(select count(*) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select count(*) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.building_id = b.id and rb.del_flag = '0' and rbs.business_status = '招商') as available_rooms,
(select COALESCE(sum(rb.building_area), 0) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select COALESCE(sum(rb.building_area), 0) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.building_id = b.id and rb.del_flag = '0' and rbs.business_status = '招商') as available_area
from TB_BUILDING b
from TB_RES_BUILDING b
where b.id = #{id} and b.del_flag = '0'
</select>
<select id="selectBuildingIdByNameAndProjectId" resultType="String">
select id from TB_BUILDING
select id from TB_RES_BUILDING
where building_name = #{buildingName}
and project_id = #{projectId}
and del_flag = '0'
limit 1
</select>
<select id="checkBuildingHasFloors" parameterType="String" resultType="Boolean">
select count(1) > 0 from tb_floor where building_id = #{id}
<select id="checkBuildingHasFloors" parameterType="Long" resultType="Boolean">
select count(1) > 0 from TB_RES_FLOOR where building_id = #{id} and del_flag = '0'
</select>
<select id="getBuildByIds" parameterType="java.util.List" resultMap="BuildingResult">
<include refid="selectBuildingVo"/>
@ -268,5 +264,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
and del_flag = '0'
</select>
<select id="selectBuildingListByNames" resultMap="BuildingResult">
<include refid="selectBuildingVo"/>
where b.project_id = #{projectId}
AND b.building_name IN
<foreach collection="buildingNames" item="name" open="(" separator="," close=")">
#{name}
</foreach>
AND b.del_flag = '0'
</select>
</mapper>

View File

@ -25,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, tenant_id, building_id, floor_number, floor_name,
create_time, last_mod_time, create_user_id, last_mod_user_id,
del_flag, remark, reserve1, reserve2, reserve3
from TB_FLOOR
from TB_RES_FLOOR
</sql>
<select id="selectFloorList" parameterType="Floor" resultMap="FloorResult">
@ -45,15 +45,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by floor_number asc
</select>
<select id="selectFloorById" parameterType="String" resultMap="FloorResult">
<select id="selectFloorById" parameterType="Long" resultMap="FloorResult">
<include refid="selectFloorVo"/>
where id = #{id} and del_flag = '0'
</select>
<insert id="insertFloor" parameterType="Floor" useGeneratedKeys="true" keyProperty="id">
insert into TB_FLOOR
insert into TB_RES_FLOOR
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tenantId != null">tenant_id,</if>
<if test="buildingId != null">building_id,</if>
<if test="floorNumber != null">floor_number,</if>
<if test="floorName != null">floor_name,</if>
@ -68,7 +67,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
last_mod_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantId != null">#{tenantId},</if>
<if test="buildingId != null">#{buildingId},</if>
<if test="floorNumber != null">#{floorNumber},</if>
<if test="floorName != null">#{floorName},</if>
@ -85,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<update id="updateFloor" parameterType="Floor">
update TB_FLOOR
update TB_RES_FLOOR
<trim prefix="SET" suffixOverrides=",">
<if test="floorNumber != null">floor_number = #{floorNumber},</if>
<if test="floorName != null">floor_name = #{floorName},</if>
@ -99,22 +97,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} and del_flag = '0'
</update>
<delete id="deleteFloorById" parameterType="String">
update TB_FLOOR set del_flag = '1' where id = #{id} and del_flag = '0'
<delete id="deleteFloorById" parameterType="Long">
update TB_RES_FLOOR set del_flag = '1' where id = #{id} and del_flag = '0'
</delete>
<delete id="deleteFloorByIds" parameterType="String">
update TB_FLOOR set del_flag = '1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
<delete id="deleteFloorByIds" parameterType="java.util.List">
update TB_RES_FLOOR set del_flag = '1' where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="checkFloorNameExists" parameterType="Floor" resultType="Integer">
select count(*) from TB_FLOOR
select count(*) from TB_RES_FLOOR
where floor_name = #{floorName}
and building_id = #{buildingId}
and tenant_id = #{tenantId}
and del_flag = '0'
<if test="id != null and id != ''">
and id != #{id}
@ -122,51 +119,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="checkFloorNumberExists" parameterType="Floor" resultType="Integer">
select count(*) from TB_FLOOR
select count(*) from TB_RES_FLOOR
where floor_number = #{floorNumber}
and building_id = #{buildingId}
and tenant_id = #{tenantId}
and del_flag = '0'
<if test="id != null and id != ''">
and id != #{id}
</if>
</select>
<select id="selectFloorStatistics" parameterType="String" resultMap="FloorResult">
<select id="selectFloorStatistics" parameterType="Long" resultMap="FloorResult">
select f.*,
(select count(*) from TB_ROOM_BASE where floor_id = f.id and del_flag = '0') as total_rooms,
(select count(*) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select count(*) from TB_RES_ROOM where floor_id = f.id and del_flag = '0') as total_rooms,
(select count(*) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.rental_status = '已租') as rented_rooms,
(select count(*) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select count(*) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.rental_status = '待租') as waiting_rooms,
(select COALESCE(sum(rb.building_area), 0) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select COALESCE(sum(rb.building_area), 0) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.rental_status = '已租') as rented_area,
(select COALESCE(sum(rb.building_area), 0) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select COALESCE(sum(rb.building_area), 0) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.rental_status = '待租') as waiting_area,
(select count(*) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select count(*) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.business_status = '招商') as available_rooms,
(select COALESCE(sum(rb.building_area), 0) from TB_ROOM_BASE rb
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select COALESCE(sum(rb.building_area), 0) from TB_RES_ROOM rb
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.business_status = '招商') as available_area
from TB_FLOOR f
from TB_RES_FLOOR f
where f.id = #{id} and f.del_flag = '0'
</select>
<select id="selectFloorIdByNameAndBuildingId" resultType="String">
select id from TB_FLOOR
select id from TB_RES_FLOOR
where floor_name = #{floorName}
and building_id = #{buildingId}
and del_flag = '0'
limit 1
</select>
<select id="checkFloorHasRooms" parameterType="String" resultType="Integer">
select count(*) from TB_ROOM_BASE
<select id="checkFloorHasRooms" parameterType="Long" resultType="Integer">
select count(*) from TB_RES_ROOM
where floor_id = #{id} and del_flag = '0'
</select>
<select id="selectFloorListByNames" resultMap="FloorResult">
<include refid="selectFloorVo"/>
where building_id = #{buildingId}
AND floor_name IN
<foreach collection="floorNames" item="name" open="(" separator="," close=")">
#{name}
</foreach>
AND del_flag = '0'
</select>
</mapper>

View File

@ -32,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
address, project_tags, project_desc, project_image, manager_id, create_time,
last_mod_time, create_user_id, last_mod_user_id, del_flag, remark,
reserve1, reserve2, reserve3
from TB_PROJECT
from TB_RES_PROJECT
</sql>
<select id="selectProjectList" parameterType="Project" resultMap="ProjectResult">
@ -67,9 +67,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="insertProject" parameterType="Project" useGeneratedKeys="true" keyProperty="id">
insert into TB_PROJECT
insert into TB_RES_PROJECT
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tenantId != null">tenant_id,</if>
<if test="projectType != null">project_type,</if>
<if test="projectName != null">project_name,</if>
<if test="projectShortName != null">project_short_name,</if>
@ -90,7 +89,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
last_mod_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantId != null">#{tenantId},</if>
<if test="projectType != null">#{projectType},</if>
<if test="projectName != null">#{projectName},</if>
<if test="projectShortName != null">#{projectShortName},</if>
@ -113,7 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<update id="updateProject" parameterType="Project">
update TB_PROJECT
update TB_RES_PROJECT
<trim prefix="SET" suffixOverrides=",">
<if test="projectType != null">project_type = #{projectType},</if>
<if test="projectName != null">project_name = #{projectName},</if>
@ -135,27 +133,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteProjectById" parameterType="String">
update TB_PROJECT set del_flag = '1' where id = #{id}
update TB_RES_PROJECT set del_flag = '1' where id = #{id}
</delete>
<delete id="deleteProjectByIds" parameterType="String">
update TB_PROJECT set del_flag = '1' where id in
update TB_RES_PROJECT set del_flag = '1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectProjectIdByName" parameterType="String" resultType="String">
select id from TB_PROJECT
select id from TB_RES_PROJECT
where project_name = #{projectName}
and del_flag = '0'
limit 1
</select>
<select id="checkProjectNameExists" parameterType="Project" resultType="Integer">
select count(*) from TB_PROJECT
where project_name = #{projectName}
and tenant_id = #{tenantId}
select count(*) from TB_RES_PROJECT
where project_name = #{projectName}
and del_flag = '0'
<if test="id != null and id != ''">
and id != #{id}
@ -163,9 +160,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="checkProjectShortNameExists" parameterType="Project" resultType="Integer">
select count(*) from TB_PROJECT
where project_short_name = #{projectShortName}
and tenant_id = #{tenantId}
select count(*) from TB_RES_PROJECT
where project_short_name = #{projectShortName}
and del_flag = '0'
<if test="id != null and id != ''">
and id != #{id}
@ -174,33 +170,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectProjectStatistics" parameterType="String" resultMap="ProjectResult">
select p.*,
(select COALESCE(sum(building_area), 0) from TB_BUILDING where project_id = p.id and del_flag = '0') as total_area,
(select COALESCE(sum(building_area), 0) from TB_BUILDING b
inner join TB_ROOM_BASE rb on b.id = rb.building_id
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select COALESCE(sum(building_area), 0) from TB_RES_BUILDING where project_id = p.id and del_flag = '0') as total_area,
(select COALESCE(sum(building_area), 0) from TB_RES_BUILDING b
inner join TB_RES_ROOM rb on b.id = rb.building_id
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.business_status = '招商') as available_area,
(select count(*) from TB_BUILDING where project_id = p.id and del_flag = '0') as total_buildings,
(select count(*) from TB_BUILDING b
inner join TB_ROOM_BASE rb on b.id = rb.building_id
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select count(*) from TB_RES_BUILDING where project_id = p.id and del_flag = '0') as total_buildings,
(select count(*) from TB_RES_BUILDING b
inner join TB_RES_ROOM rb on b.id = rb.building_id
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.business_status = '招商') as available_buildings,
(select COALESCE(sum(building_area), 0) from TB_BUILDING b
inner join TB_ROOM_BASE rb on b.id = rb.building_id
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select COALESCE(sum(building_area), 0) from TB_RES_BUILDING b
inner join TB_RES_ROOM rb on b.id = rb.building_id
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.rental_status = '已租') as rented_area,
(select count(*) from TB_BUILDING b
inner join TB_ROOM_BASE rb on b.id = rb.building_id
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select count(*) from TB_RES_BUILDING b
inner join TB_RES_ROOM rb on b.id = rb.building_id
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.rental_status = '已租') as rented_buildings,
(select COALESCE(sum(building_area), 0) from TB_BUILDING b
inner join TB_ROOM_BASE rb on b.id = rb.building_id
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select COALESCE(sum(building_area), 0) from TB_RES_BUILDING b
inner join TB_RES_ROOM rb on b.id = rb.building_id
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.rental_status = '待租') as waiting_area,
(select count(*) from TB_BUILDING b
inner join TB_ROOM_BASE rb on b.id = rb.building_id
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
(select count(*) from TB_RES_BUILDING b
inner join TB_RES_ROOM rb on b.id = rb.building_id
inner join TB_RES_ROOM_BUSINESS rbs on rb.id = rbs.room_id
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.rental_status = '待租') as waiting_buildings
from TB_PROJECT p
from TB_RES_PROJECT p
where p.id = #{id} and p.del_flag = '0'
</select>
<select id="selectProjectListByIds" parameterType="java.util.List" resultMap="ProjectResult">
@ -210,4 +206,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</select>
<select id="selectProjectListByNames" resultMap="ProjectResult">
<include refid="selectProjectVo"/>
where project_name IN
<foreach collection="projectNames" item="name" open="(" separator="," close=")">
#{name}
</foreach>
AND del_flag = '0'
</select>
</mapper>

View File

@ -32,15 +32,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
floor_price_unit, business_number, business_condition,
create_time, last_mod_time, create_user_id, last_mod_user_id,
del_flag, remark
from TB_ROOM_BUSINESS_INFO
from TB_RES_ROOM_BUSINESS_INFO
</sql>
<select id="selectRoomBusinessInfoList" parameterType="RoomBusinessInfo" resultMap="RoomBusinessInfoResult">
<include refid="selectRoomBusinessInfoVo"/>
<where>
<if test="tenantId != null and tenantId != ''">
AND tenant_id = #{tenantId}
</if>
<if test="roomId != null and roomId != ''">
AND room_id = #{roomId}
</if>
@ -57,67 +54,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectRoomBusinessInfoById" parameterType="String" resultMap="RoomBusinessInfoResult">
<select id="selectRoomBusinessInfoById" parameterType="Long" resultMap="RoomBusinessInfoResult">
<include refid="selectRoomBusinessInfoVo"/>
where id = #{id} and del_flag = '0'
</select>
<select id="selectRoomBusinessInfoByRoomId" parameterType="String" resultMap="RoomBusinessInfoResult">
<select id="selectRoomBusinessInfoByRoomId" parameterType="Long" resultMap="RoomBusinessInfoResult">
<include refid="selectRoomBusinessInfoVo"/>
where room_id = #{roomId} and del_flag = '0'
</select>
<insert id="insertRoomBusinessInfo" parameterType="RoomBusinessInfo" useGeneratedKeys="true" keyProperty="id">
<selectKey keyProperty="id" resultType="String" order="BEFORE">
SELECT nextval('SEQ_ROOM_BUSINESS_INFO_1')::VARCHAR as id
</selectKey>
insert into TB_ROOM_BUSINESS_INFO
<trim prefix="(" suffix=")" suffixOverrides=",">
id,
<if test="tenantId != null">tenant_id,</if>
<if test="roomId != null">room_id,</if>
<if test="rentalStatus != null">rental_status,</if>
<if test="businessStatus != null">business_status,</if>
<if test="availableDate != null">available_date,</if>
<if test="decorationStatus != null">decoration_status,</if>
<if test="price != null">price,</if>
<if test="priceUnit != null">price_unit,</if>
<if test="floorPrice != null">floor_price,</if>
<if test="floorPriceUnit != null">floor_price_unit,</if>
<if test="businessNumber != null">business_number,</if>
<if test="businessCondition != null">business_condition,</if>
<if test="createUserId != null">create_user_id,</if>
<if test="lastModUserId != null">last_mod_user_id,</if>
<if test="delFlag != null">del_flag,</if>
<if test="remark != null">remark,</if>
create_time,
last_mod_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{id},
<if test="tenantId != null">#{tenantId},</if>
<if test="roomId != null">#{roomId},</if>
<if test="rentalStatus != null">#{rentalStatus},</if>
<if test="businessStatus != null">#{businessStatus},</if>
<if test="availableDate != null">#{availableDate},</if>
<if test="decorationStatus != null">#{decorationStatus},</if>
<if test="price != null">#{price},</if>
<if test="priceUnit != null">#{priceUnit},</if>
<if test="floorPrice != null">#{floorPrice},</if>
<if test="floorPriceUnit != null">#{floorPriceUnit},</if>
<if test="businessNumber != null">#{businessNumber},</if>
<if test="businessCondition != null">#{businessCondition},</if>
<if test="createUserId != null">#{createUserId},</if>
<if test="lastModUserId != null">#{lastModUserId},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="remark != null">#{remark},</if>
<insert id="batchInsertBusinessInfos" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
insert into TB_RES_ROOM_BUSINESS_INFO
(
id,
room_id,
rental_status,
business_status,
available_date,
decoration_status,
price,
price_unit,
floor_price,
floor_price_unit,
business_number,
business_condition,
create_user_id,
last_mod_user_id,
del_flag,
remark,
create_time,
last_mod_time
)
values
<foreach collection="list" item="item" separator=",">
(
nextval('SEQ_ROOM_BUSINESS_INFO_1'), <!-- 直接调用序列生成 ID -->
#{item.roomId},
#{item.rentalStatus},
#{item.businessStatus},
#{item.availableDate},
#{item.decorationStatus},
#{item.price},
#{item.priceUnit},
#{item.floorPrice},
#{item.floorPriceUnit},
#{item.businessNumber},
#{item.businessCondition},
#{item.createUserId},
#{item.lastModUserId},
#{item.delFlag},
#{item.remark},
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
</trim>
)
</foreach>
</insert>
<update id="updateRoomBusinessInfo" parameterType="RoomBusinessInfo">
update TB_ROOM_BUSINESS_INFO
update TB_RES_ROOM_BUSINESS_INFO
<trim prefix="SET" suffixOverrides=",">
<if test="rentalStatus != null">rental_status = #{rentalStatus},</if>
<if test="businessStatus != null">business_status = #{businessStatus},</if>
@ -136,11 +131,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where room_id = #{roomId} and del_flag = '0'
</update>
<update id="deleteRoomBusinessInfoById" parameterType="String">
update TB_ROOM_BUSINESS_INFO set del_flag = '1' where id = #{id} and del_flag = '0'
<update id="deleteRoomBusinessInfoById" parameterType="Long">
update TB_RES_ROOM_BUSINESS_INFO set del_flag = '1' where id = #{id} and del_flag = '0'
</update>
<update id="deleteRoomBusinessInfoByRoomId" parameterType="String">
update TB_ROOM_BUSINESS_INFO set del_flag = '1' where room_id = #{roomId} and del_flag = '0'
<update id="deleteRoomBusinessInfoByRoomId" parameterType="Long">
update TB_RES_ROOM_BUSINESS_INFO set del_flag = '1' where room_id = #{roomId} and del_flag = '0'
</update>
</mapper>

View File

@ -32,15 +32,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
workstation_min, workstation_max, floor_plan_desc, tags,
create_time, last_mod_time, create_user_id, last_mod_user_id,
del_flag, remark
from TB_ROOM_EXTEND_INFO
from TB_RES_ROOM_EXTEND_INFO
</sql>
<select id="selectRoomExtendInfoList" parameterType="RoomExtendInfo" resultMap="RoomExtendInfoResult">
<include refid="selectRoomExtendInfoVo"/>
<where>
<if test="tenantId != null and tenantId != ''">
AND tenant_id = #{tenantId}
</if>
<if test="roomId != null and roomId != ''">
AND room_id = #{roomId}
</if>
@ -54,67 +51,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectRoomExtendInfoById" parameterType="String" resultMap="RoomExtendInfoResult">
<select id="selectRoomExtendInfoById" parameterType="Long" resultMap="RoomExtendInfoResult">
<include refid="selectRoomExtendInfoVo"/>
where id = #{id} and del_flag = '0'
</select>
<select id="selectRoomExtendInfoByRoomId" parameterType="String" resultMap="RoomExtendInfoResult">
<select id="selectRoomExtendInfoByRoomId" parameterType="Long" resultMap="RoomExtendInfoResult">
<include refid="selectRoomExtendInfoVo"/>
where room_id = #{roomId} and del_flag = '0'
</select>
<insert id="insertRoomExtendInfo" parameterType="RoomExtendInfo" useGeneratedKeys="true" keyProperty="id">
<selectKey keyProperty="id" resultType="String" order="BEFORE">
SELECT nextval('SEQ_ROOM_EXTEND_INFO_1')::VARCHAR as id
</selectKey>
insert into TB_ROOM_EXTEND_INFO
<trim prefix="(" suffix=")" suffixOverrides=",">
id,
<if test="tenantId != null">tenant_id,</if>
<if test="roomId != null">room_id,</if>
<if test="roomRecordNumber != null">room_record_number,</if>
<if test="usageRate != null">usage_rate,</if>
<if test="officeLayout != null">office_layout,</if>
<if test="windowOrientation != null">window_orientation,</if>
<if test="rentFreePeriod != null">rent_free_period,</if>
<if test="minLeaseTerm != null">min_lease_term,</if>
<if test="workstationMin != null">workstation_min,</if>
<if test="workstationMax != null">workstation_max,</if>
<if test="floorPlanDesc != null">floor_plan_desc,</if>
<if test="tags != null">tags,</if>
<if test="createUserId != null">create_user_id,</if>
<if test="lastModUserId != null">last_mod_user_id,</if>
<if test="delFlag != null">del_flag,</if>
<if test="remark != null">remark,</if>
create_time,
last_mod_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{id},
<if test="tenantId != null">#{tenantId},</if>
<if test="roomId != null">#{roomId},</if>
<if test="roomRecordNumber != null">#{roomRecordNumber},</if>
<if test="usageRate != null">#{usageRate},</if>
<if test="officeLayout != null">#{officeLayout},</if>
<if test="windowOrientation != null">#{windowOrientation},</if>
<if test="rentFreePeriod != null">#{rentFreePeriod},</if>
<if test="minLeaseTerm != null">#{minLeaseTerm},</if>
<if test="workstationMin != null">#{workstationMin},</if>
<if test="workstationMax != null">#{workstationMax},</if>
<if test="floorPlanDesc != null">#{floorPlanDesc},</if>
<if test="tags != null">#{tags},</if>
<if test="createUserId != null">#{createUserId},</if>
<if test="lastModUserId != null">#{lastModUserId},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="remark != null">#{remark},</if>
<insert id="batchInsertExtendInfos" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
insert into TB_RES_ROOM_EXTEND_INFO
(
id,
room_id,
room_record_number,
usage_rate,
office_layout,
window_orientation,
rent_free_period,
min_lease_term,
workstation_min,
workstation_max,
floor_plan_desc,
tags,
create_user_id,
last_mod_user_id,
del_flag,
remark,
create_time,
last_mod_time
)
values
<foreach collection="list" item="item" separator=",">
(
nextval('SEQ_ROOM_EXTEND_INFO_1'), <!-- 直接调用序列生成 ID -->
#{item.roomId},
#{item.roomRecordNumber},
#{item.usageRate},
#{item.officeLayout},
#{item.windowOrientation},
#{item.rentFreePeriod},
#{item.minLeaseTerm},
#{item.workstationMin},
#{item.workstationMax},
#{item.floorPlanDesc},
#{item.tags},
#{item.createUserId},
#{item.lastModUserId},
#{item.delFlag},
#{item.remark},
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
</trim>
)
</foreach>
</insert>
<update id="updateRoomExtendInfo" parameterType="RoomExtendInfo">
update TB_ROOM_EXTEND_INFO
update TB_RES_ROOM_EXTEND_INFO
<trim prefix="SET" suffixOverrides=",">
<if test="roomRecordNumber != null">room_record_number = #{roomRecordNumber},</if>
<if test="usageRate != null">usage_rate = #{usageRate},</if>
@ -133,11 +128,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where room_id = #{roomId} and del_flag = '0'
</update>
<update id="deleteRoomExtendInfoById" parameterType="String">
update TB_ROOM_EXTEND_INFO set del_flag = '1' where id = #{id} and del_flag = '0'
<update id="deleteRoomExtendInfoById" parameterType="Long">
update TB_RES_ROOM_EXTEND_INFO set del_flag = '1' where id = #{id} and del_flag = '0'
</update>
<update id="deleteRoomExtendInfoByRoomId" parameterType="String">
update TB_ROOM_EXTEND_INFO set del_flag = '1' where room_id = #{roomId} and del_flag = '0'
<update id="deleteRoomExtendInfoByRoomId" parameterType="Long">
update TB_RES_ROOM_EXTEND_INFO set del_flag = '1' where room_id = #{roomId} and del_flag = '0'
</update>
</mapper>

View File

@ -21,15 +21,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectRoomImageVo">
select id, tenant_id, room_id, image_url, image_type, sort_order,
create_time, last_mod_time, create_user_id, last_mod_user_id, del_flag
from TB_ROOM_IMAGE
from TB_RES_ROOM_IMAGE
</sql>
<select id="selectRoomImageList" parameterType="RoomImage" resultMap="RoomImageResult">
<include refid="selectRoomImageVo"/>
<where>
<if test="tenantId != null and tenantId != ''">
AND tenant_id = #{tenantId}
</if>
<if test="roomId != null and roomId != ''">
AND room_id = #{roomId}
</if>
@ -41,12 +38,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by sort_order asc
</select>
<select id="selectRoomImageById" parameterType="String" resultMap="RoomImageResult">
<select id="selectRoomImageById" parameterType="Long" resultMap="RoomImageResult">
<include refid="selectRoomImageVo"/>
where id = #{id} and del_flag = '0'
</select>
<select id="selectRoomImagesByRoomId" parameterType="String" resultMap="RoomImageResult">
<select id="selectRoomImagesByRoomId" parameterType="Long" resultMap="RoomImageResult">
<include refid="selectRoomImageVo"/>
where room_id = #{roomId} and del_flag = '0'
order by sort_order asc
@ -59,13 +56,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="insertRoomImage" parameterType="RoomImage" useGeneratedKeys="true" keyProperty="id">
<selectKey keyProperty="id" resultType="String" order="BEFORE">
SELECT nextval('SEQ_ROOM_IMAGE_1')::VARCHAR as id
<selectKey keyProperty="id" resultType="Long" order="BEFORE">
SELECT nextval('SEQ_ROOM_IMAGE_1') as id
</selectKey>
insert into TB_ROOM_IMAGE
insert into TB_RES_ROOM_IMAGE
<trim prefix="(" suffix=")" suffixOverrides=",">
id,
<if test="tenantId != null">tenant_id,</if>
<if test="roomId != null">room_id,</if>
<if test="imageUrl != null">image_url,</if>
<if test="imageType != null">image_type,</if>
@ -78,7 +74,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{id},
<if test="tenantId != null">#{tenantId},</if>
<if test="roomId != null">#{roomId},</if>
<if test="imageUrl != null">#{imageUrl},</if>
<if test="imageType != null">#{imageType},</if>
@ -92,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<update id="updateRoomImage" parameterType="RoomImage">
update TB_ROOM_IMAGE
update TB_RES_ROOM_IMAGE
<trim prefix="SET" suffixOverrides=",">
<if test="imageUrl != null">image_url = #{imageUrl},</if>
<if test="imageType != null">image_type = #{imageType},</if>
@ -103,29 +98,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} and del_flag = '0'
</update>
<update id="deleteRoomImageById" parameterType="String">
update TB_ROOM_IMAGE set del_flag = '1' where id = #{id} and del_flag = '0'
<update id="deleteRoomImageById" parameterType="Long">
update TB_RES_ROOM_IMAGE set del_flag = '1' where id = #{id} and del_flag = '0'
</update>
<update id="deleteRoomImagesByRoomId" parameterType="String">
update TB_ROOM_IMAGE set del_flag = '1' where room_id = #{roomId} and del_flag = '0'
<update id="deleteRoomImagesByRoomId" parameterType="Long">
update TB_RES_ROOM_IMAGE set del_flag = '1' where room_id = #{roomId} and del_flag = '0'
</update>
<update id="deleteRoomImageByRoomIdAndType">
update TB_ROOM_IMAGE set del_flag = '1'
update TB_RES_ROOM_IMAGE set del_flag = '1'
where room_id = #{roomId} and image_type = #{imageType} and del_flag = '0'
</update>
<update id="deleteRoomImageByIds" parameterType="String">
update TB_ROOM_IMAGE set del_flag = '1' where id in
<update id="deleteRoomImageByIds" parameterType="java.util.List">
update TB_RES_ROOM_IMAGE set del_flag = '1' where id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
and del_flag = '0'
</update>
<update id="deleteRoomImagesByRoomIds" parameterType="String">
update TB_ROOM_IMAGE set del_flag = '1' where room_id in
<update id="deleteRoomImagesByRoomIds" parameterType="java.util.List">
update TB_RES_ROOM_IMAGE set del_flag = '1' where room_id in
<foreach collection="roomIds" item="roomId" open="(" separator="," close=")">
#{roomId}
</foreach>

View File

@ -46,23 +46,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectRoomVo">
select r.id, r.tenant_id, r.project_id, r.building_id, r.floor_id, r.room_number,
SELECT
r.id, r.tenant_id, r.project_id, r.building_id, r.floor_id, r.room_number,
r.room_digital_number, r.room_manage_number, r.building_area, r.rental_area,
r.billing_area, r.inner_area, r.is_virtual, r.delivery_time, r.owner_id,
r.property_nature, r.height, r.load_value, r.room_status, r.room_type,
r.create_time, r.last_mod_time, r.create_user_id, r.last_mod_user_id,
r.del_flag, r.remark, b.project_name, c.building_name, d.floor_name,rb.price,rb.price_unit,
rb.rental_status,rb.available_date,rb.business_status,rb.decoration_status
from TB_ROOM r, TB_PROJECT b,TB_BUILDING c,TB_FLOOR d,TB_ROOM_BUSINESS_INFO rb, TB_ROOM_EXTEND_INFO re
where r.project_id=b.id and r.building_id=c.id and r.floor_id=d.id
and r.id = rb.room_id and r.id=re.room_id
r.del_flag, r.remark, b.project_name, c.building_name, d.floor_name,
rb.price, rb.price_unit, rb.rental_status, rb.available_date, rb.business_status,
rb.decoration_status,re.tags
FROM
TB_RES_ROOM r
LEFT JOIN TB_RES_PROJECT b ON r.project_id = b.id
LEFT JOIN TB_RES_BUILDING c ON r.building_id = c.id
LEFT JOIN TB_RES_FLOOR d ON r.floor_id = d.id
LEFT JOIN TB_RES_ROOM_BUSINESS_INFO rb ON r.id = rb.room_id
LEFT JOIN TB_RES_ROOM_EXTEND_INFO re ON r.id = re.room_id
WHERE r.del_flag = '0'
</sql>
<select id="selectRoomList" parameterType="Room" resultMap="RoomResult">
<!-- 定义动态查询部分 -->
<select id="selectRoomList" parameterType="RoomQueryDTO" resultMap="RoomResult">
<include refid="selectRoomVo"/>
<if test="tenantId != null and tenantId != ''">
AND r.tenant_id = #{tenantId}
</if>
<if test="projectId != null and projectId != ''">
AND r.project_id = #{projectId}
</if>
@ -73,10 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND r.floor_id = #{floorId}
</if>
<if test="roomNumber != null and roomNumber != ''">
AND r.room_number like concat('%', #{roomNumber}, '%')
</if>
<if test="roomDigitalNumber != null and roomDigitalNumber != ''">
AND r.room_digital_number = #{roomDigitalNumber}
AND r.room_number LIKE CONCAT('%', #{roomNumber}, '%')
</if>
<if test="isVirtual != null and isVirtual != ''">
AND r.is_virtual = #{isVirtual}
@ -87,83 +89,82 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="roomType != null and roomType != ''">
AND r.room_type = #{roomType}
</if>
<if test="businessStatus != null and businessStatus != ''">
<if test="businessStatus != null and businessStatus != ''">
AND rb.business_status = #{businessStatus}
</if>
AND r.del_flag = '0'
order by r.room_digital_number asc
<if test="tags != null and tags != ''">
AND re.tags LIKE CONCAT('%,', #{tags}, ',%')
</if>
ORDER BY r.room_digital_number ASC
</select>
<select id="selectRoomById" parameterType="String" resultMap="RoomResult">
<select id="selectRoomById" parameterType="Long" resultMap="RoomResult">
<include refid="selectRoomVo"/>
and r.id = #{id} and r.del_flag = '0'
and r.id = #{id}
</select>
<insert id="insertRoom" parameterType="Room" useGeneratedKeys="true" keyProperty="id">
<selectKey keyProperty="id" resultType="String" order="BEFORE">
SELECT nextval('SEQ_ROOM_1')::VARCHAR as id
</selectKey>
insert into TB_ROOM
<trim prefix="(" suffix=")" suffixOverrides=",">
id,
<if test="tenantId != null">tenant_id,</if>
<if test="projectId != null">project_id,</if>
<if test="buildingId != null">building_id,</if>
<if test="floorId != null">floor_id,</if>
<if test="roomNumber != null">room_number,</if>
<if test="roomDigitalNumber != null">room_digital_number,</if>
<if test="roomManageNumber != null">room_manage_number,</if>
<if test="buildingArea != null">building_area,</if>
<if test="rentalArea != null">rental_area,</if>
<if test="billingArea != null">billing_area,</if>
<if test="innerArea != null">inner_area,</if>
<if test="isVirtual != null">is_virtual,</if>
<if test="deliveryTime != null">delivery_time,</if>
<if test="ownerId != null">owner_id,</if>
<if test="propertyNature != null">property_nature,</if>
<if test="height != null">height,</if>
<if test="loadValue != null">load_value,</if>
<if test="roomStatus != null">room_status,</if>
<if test="roomType != null">room_type,</if>
<if test="createUserId != null">create_user_id,</if>
<if test="lastModUserId != null">last_mod_user_id,</if>
<if test="delFlag != null">del_flag,</if>
<if test="remark != null">remark,</if>
create_time,
last_mod_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{id},
<if test="tenantId != null">#{tenantId},</if>
<if test="projectId != null">#{projectId},</if>
<if test="buildingId != null">#{buildingId},</if>
<if test="floorId != null">#{floorId},</if>
<if test="roomNumber != null">#{roomNumber},</if>
<if test="roomDigitalNumber != null">#{roomDigitalNumber},</if>
<if test="roomManageNumber != null">#{roomManageNumber},</if>
<if test="buildingArea != null">#{buildingArea},</if>
<if test="rentalArea != null">#{rentalArea},</if>
<if test="billingArea != null">#{billingArea},</if>
<if test="innerArea != null">#{innerArea},</if>
<if test="isVirtual != null">#{isVirtual},</if>
<if test="deliveryTime != null">#{deliveryTime},</if>
<if test="ownerId != null">#{ownerId},</if>
<if test="propertyNature != null">#{propertyNature},</if>
<if test="height != null">#{height},</if>
<if test="loadValue != null">#{loadValue},</if>
<if test="roomStatus != null">#{roomStatus},</if>
<if test="roomType != null">#{roomType},</if>
<if test="createUserId != null">#{createUserId},</if>
<if test="lastModUserId != null">#{lastModUserId},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="remark != null">#{remark},</if>
<insert id="batchInsertRooms" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
insert into TB_RES_ROOM
(
id,
project_id,
building_id,
floor_id,
room_number,
room_digital_number,
room_manage_number,
building_area,
rental_area,
billing_area,
inner_area,
is_virtual,
delivery_time,
owner_id,
property_nature,
height,
load_value,
room_status,
room_type,
create_user_id,
last_mod_user_id,
del_flag,
remark,
create_time,
last_mod_time
)
values
<foreach collection="list" item="item" separator=",">
(
nextval('SEQ_ROOM_1'), <!-- 直接调用序列生成 ID -->
#{item.projectId},
#{item.buildingId},
#{item.floorId},
#{item.roomNumber},
#{item.roomDigitalNumber},
#{item.roomManageNumber},
#{item.buildingArea},
#{item.rentalArea},
#{item.billingArea},
#{item.innerArea},
#{item.isVirtual},
#{item.deliveryTime},
#{item.ownerId},
#{item.propertyNature},
#{item.height},
#{item.loadValue},
#{item.roomStatus},
#{item.roomType},
#{item.createUserId},
#{item.lastModUserId},
#{item.delFlag},
#{item.remark},
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
</trim>
)
</foreach>
</insert>
<update id="updateRoom" parameterType="Room">
update TB_ROOM
update TB_RES_ROOM
<trim prefix="SET" suffixOverrides=",">
<if test="roomNumber != null">room_number = #{roomNumber},</if>
<if test="roomDigitalNumber != null">room_digital_number = #{roomDigitalNumber},</if>
@ -187,36 +188,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} and del_flag = '0'
</update>
<update id="deleteRoomById" parameterType="String">
update TB_ROOM set del_flag = '1' where id = #{id} and del_flag = '0'
<update id="deleteRoomById" parameterType="Long">
update TB_RES_ROOM set del_flag = '1' where id = #{id} and del_flag = '0'
</update>
<update id="deleteRoomByIds" parameterType="String">
update TB_ROOM set del_flag = '1' where id in
<update id="deleteRoomByIds" parameterType="java.util.List">
update TB_RES_ROOM set del_flag = '1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<select id="selectRoomByIds" parameterType="java.util.List" resultMap="RoomResult">
<include refid="selectRoomVo"/>
AND r.id IN
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
AND r.del_flag = '0'
</select>
<select id="checkRoomNumberExists" parameterType="Room" resultType="Integer">
select count(*) from TB_ROOM
select count(*) from TB_RES_ROOM
where room_number = #{roomNumber}
and floor_id = #{floorId}
and building_id = #{buildingId}
and project_id = #{projectId}
and tenant_id = #{tenantId}
and del_flag = '0'
<if test="id != null and id != ''">
and id != #{id}
</if>
</select>
<select id="getExistingRoomNumbers" resultType="String">
SELECT DISTINCT r.room_number
FROM TB_RES_ROOM r
INNER JOIN TB_RES_BUILDING b ON r.building_id = b.id
WHERE b.project_id = #{projectId}
AND r.room_number IN
<foreach collection="roomNumbers" item="number" open="(" separator="," close=")">
#{number}
</foreach>
AND r.del_flag = '0'
AND b.del_flag = '0'
</select>
<select id="checkRoomNumberExist" resultType="boolean">
SELECT COUNT(*) > 0
FROM TB_RES_ROOM r
WHERE r.room_number = #{roomNumber}
AND r.project_id = #{projectId}
AND r.building_id = #{buildingId}
AND r.floor_id = #{floorId}
AND r.del_flag = '0'
</select>
<select id="checkRoomDigitalNumberExist" resultType="boolean">
SELECT COUNT(*) > 0
FROM TB_RES_ROOM r
WHERE r.room_digital_number = #{roomDigitalNumber}
AND r.project_id = #{projectId}
AND r.building_id = #{buildingId}
AND r.floor_id = #{floorId}
AND r.del_flag = '0'
</select>
</mapper>

View File

@ -1,89 +0,0 @@
server:
port: 8082
servlet:
context-path: /api
spring:
application:
name: room-service
# 数据库配置
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://1.14.121.39:5432/edendb?currentSchema=public&charSet=UTF-8
username: edenuser
password: edenpswd
druid:
initial-size: 5
min-idle: 5
max-active: 20
max-wait: 60000
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1
test-while-idle: true
test-on-borrow: false
test-on-return: false
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
# 启用Swagger
mvc:
pathmatch:
matching-strategy: ant_path_matcher
# Redis配置
redis:
host: 1.14.121.39
port: 6379
password: edenpswd
database: 0
timeout: 10000
lettuce:
pool:
max-active: 8
max-wait: -1
max-idle: 8
min-idle: 0
# Feign客户端配置
feign:
client:
config:
default:
connectTimeout: 5000 # 连接超时时间
readTimeout: 5000 # 读取超时时间
hystrix:
enabled: true # 启用熔断器
# 服务注册与发现配置
eureka:
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://localhost:8761/eureka/
instance:
prefer-ip-address: true
# MyBatis配置
mybatis:
mapper-locations: classpath:mapper/**/*.xml
type-aliases-package: com.eden.room.domain
configuration:
map-underscore-to-camel-case: true
cache-enabled: true
# PageHelper分页插件
pagehelper:
helper-dialect: postgresql
reasonable: true
support-methods-arguments: true
params: count=countSql
# 日志配置
logging:
level:
com.eden.room: debug
org.springframework: warn

Some files were not shown because too many files have changed in this diff Show More