新增场地展位管理功能,包括展位图查询、保存、预定及调换功能,新增相关数据模型及数据库表结构

This commit is contained in:
2026-06-25 14:42:10 +08:00
parent d1319c6a7c
commit 7f10e9f311
7 changed files with 396 additions and 0 deletions

View File

@@ -1,15 +1,30 @@
package com.ruoyi.cms.controller.cms;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.cms.domain.VenueInfo;
import com.ruoyi.cms.domain.OutdoorFair;
import com.ruoyi.cms.domain.OutdoorFairBoothBooking;
import com.ruoyi.cms.domain.VenueBooth;
import com.ruoyi.cms.domain.VenueInfoDictDataRequest;
import com.ruoyi.cms.domain.VenueBoothSwapRequest;
import com.ruoyi.cms.mapper.CompanyMapper;
import com.ruoyi.cms.mapper.OutdoorFairBoothBookingMapper;
import com.ruoyi.cms.mapper.OutdoorFairMapper;
import com.ruoyi.cms.mapper.VenueBoothMapper;
import com.ruoyi.cms.service.IVenueInfoService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.Company;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
@@ -17,6 +32,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@@ -41,6 +57,18 @@ public class VenueInfoController extends BaseController
@Autowired
private IVenueInfoService venueInfoService;
@Autowired
private VenueBoothMapper venueBoothMapper;
@Autowired
private OutdoorFairMapper outdoorFairMapper;
@Autowired
private OutdoorFairBoothBookingMapper outdoorFairBoothBookingMapper;
@Autowired
private CompanyMapper companyMapper;
/**
* 查询场地信息列表
*/
@@ -115,6 +143,176 @@ public class VenueInfoController extends BaseController
return toAjax(venueInfoService.insertVenueInfoDictData(request.getDictType(), request.getDictLabel(), getUsername()));
}
@ApiOperation("查询场地展位图")
@PreAuthorize("@ss.hasAnyPermi('cms:venueInfo:query,cms:outdoorFair:query')")
@GetMapping("/{venueId}/booths")
public AjaxResult listBooths(@PathVariable Long venueId)
{
List<VenueBooth> list = venueBoothMapper.selectList(new LambdaQueryWrapper<VenueBooth>()
.eq(VenueBooth::getVenueId, venueId)
.orderByAsc(VenueBooth::getPositionY)
.orderByAsc(VenueBooth::getPositionX)
.orderByAsc(VenueBooth::getBoothNumber));
return success(list);
}
@ApiOperation("保存场地展位图")
@PreAuthorize("@ss.hasPermi('cms:venueInfo:edit')")
@Transactional(rollbackFor = Exception.class)
@PostMapping("/{venueId}/booths")
public AjaxResult saveBooths(@PathVariable Long venueId, @RequestBody List<VenueBooth> booths)
{
venueBoothMapper.physicalDeleteDeletedByVenueId(venueId);
List<VenueBooth> existingBooths = venueBoothMapper.selectList(new LambdaQueryWrapper<VenueBooth>()
.eq(VenueBooth::getVenueId, venueId));
Map<Long, VenueBooth> existingById = existingBooths.stream()
.filter(item -> item.getId() != null)
.collect(Collectors.toMap(VenueBooth::getId, item -> item, (a, b) -> a));
Map<String, VenueBooth> existingByNumber = existingBooths.stream()
.filter(item -> StringUtils.isNotBlank(item.getBoothNumber()))
.collect(Collectors.toMap(VenueBooth::getBoothNumber, item -> item, (a, b) -> a));
Set<String> boothNumbers = new HashSet<>();
Set<Long> savedIds = new HashSet<>();
if (booths != null) {
for (VenueBooth booth : booths) {
if (StringUtils.isBlank(booth.getBoothNumber())) {
return AjaxResult.error("展位号不能为空");
}
if (!boothNumbers.add(booth.getBoothNumber())) {
return AjaxResult.error("展位号不能重复:" + booth.getBoothNumber());
}
}
for (VenueBooth booth : booths) {
VenueBooth existing = booth.getId() == null ? null : existingById.get(booth.getId());
if (existing == null) {
existing = existingByNumber.get(booth.getBoothNumber());
}
booth.setVenueId(venueId);
if (existing == null) {
booth.setId(null);
venueBoothMapper.insert(booth);
} else {
booth.setId(existing.getId());
venueBoothMapper.updateById(booth);
}
if (booth.getId() != null) {
savedIds.add(booth.getId());
}
}
VenueInfo venueInfo = venueInfoService.getById(venueId);
if (venueInfo != null) {
venueInfo.setFloorCount(booths.size());
venueInfoService.updateById(venueInfo);
}
}
List<Long> removedIds = existingBooths.stream()
.map(VenueBooth::getId)
.filter(id -> id != null && !savedIds.contains(id))
.collect(Collectors.toList());
if (!removedIds.isEmpty()) {
venueBoothMapper.physicalDeleteByVenueIdAndIds(venueId, removedIds);
}
return success();
}
@ApiOperation("查询户外招聘会展位图")
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:query')")
@GetMapping("/fair/{fairId}/booth-map")
public AjaxResult fairBoothMap(@PathVariable Long fairId)
{
OutdoorFair fair = outdoorFairMapper.selectById(fairId);
if (fair == null || fair.getVenueId() == null) {
return success(new ArrayList<>());
}
List<VenueBooth> booths = venueBoothMapper.selectList(new LambdaQueryWrapper<VenueBooth>()
.eq(VenueBooth::getVenueId, fair.getVenueId())
.orderByAsc(VenueBooth::getPositionY)
.orderByAsc(VenueBooth::getPositionX)
.orderByAsc(VenueBooth::getBoothNumber));
List<OutdoorFairBoothBooking> bookings = outdoorFairBoothBookingMapper.selectList(new LambdaQueryWrapper<OutdoorFairBoothBooking>()
.eq(OutdoorFairBoothBooking::getFairId, fairId));
Map<Long, OutdoorFairBoothBooking> bookingMap = bookings.stream().collect(Collectors.toMap(OutdoorFairBoothBooking::getBoothId, item -> item, (a, b) -> a));
List<Map<String, Object>> result = new ArrayList<>();
for (VenueBooth booth : booths) {
OutdoorFairBoothBooking booking = bookingMap.get(booth.getId());
Map<String, Object> row = new java.util.HashMap<>();
row.put("id", booth.getId());
row.put("boothId", booth.getId());
row.put("boothNumber", booth.getBoothNumber());
row.put("positionX", booth.getPositionX());
row.put("positionY", booth.getPositionY());
row.put("bookingId", booking == null ? null : booking.getId());
row.put("companyId", booking == null ? null : booking.getCompanyId());
row.put("companyName", booking == null ? null : booking.getCompanyName());
row.put("status", booking == null ? "available" : booking.getStatus());
result.add(row);
}
return success(result);
}
@ApiOperation("预定户外招聘会展位")
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:edit')")
@PostMapping("/fair/{fairId}/booth-booking")
public AjaxResult bookBooth(@PathVariable Long fairId, @RequestBody OutdoorFairBoothBooking booking)
{
if (booking.getCompanyId() == null) {
return AjaxResult.error("请选择预定单位");
}
Company company = companyMapper.selectById(booking.getCompanyId());
if (company == null || company.getStatus() == null || company.getStatus() != 1) {
return AjaxResult.error("只能预定审核通过的企业");
}
VenueBooth booth = venueBoothMapper.selectById(booking.getBoothId());
booking.setFairId(fairId);
booking.setBoothNumber(booth == null ? booking.getBoothNumber() : booth.getBoothNumber());
booking.setCompanyName(company.getName());
booking.setStatus(StringUtils.isBlank(booking.getStatus()) ? "reserved" : booking.getStatus());
OutdoorFairBoothBooking existing = outdoorFairBoothBookingMapper.selectOne(new LambdaQueryWrapper<OutdoorFairBoothBooking>()
.eq(OutdoorFairBoothBooking::getFairId, fairId)
.eq(OutdoorFairBoothBooking::getBoothId, booking.getBoothId())
.last("limit 1"));
if (existing == null) {
return toAjax(outdoorFairBoothBookingMapper.insert(booking));
}
booking.setId(existing.getId());
return toAjax(outdoorFairBoothBookingMapper.updateById(booking));
}
@ApiOperation("取消户外招聘会展位预定")
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:edit')")
@DeleteMapping("/fair/{fairId}/booth-booking/{boothId}")
public AjaxResult cancelBooth(@PathVariable Long fairId, @PathVariable Long boothId)
{
return toAjax(outdoorFairBoothBookingMapper.delete(new LambdaQueryWrapper<OutdoorFairBoothBooking>()
.eq(OutdoorFairBoothBooking::getFairId, fairId)
.eq(OutdoorFairBoothBooking::getBoothId, boothId)));
}
@ApiOperation("调换户外招聘会展位")
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:edit')")
@PostMapping("/fair/{fairId}/booth-swap")
public AjaxResult swapBooth(@PathVariable Long fairId, @RequestBody VenueBoothSwapRequest request)
{
OutdoorFairBoothBooking first = outdoorFairBoothBookingMapper.selectOne(new LambdaQueryWrapper<OutdoorFairBoothBooking>()
.eq(OutdoorFairBoothBooking::getFairId, fairId)
.eq(OutdoorFairBoothBooking::getBoothId, request.getFirstBoothId()).last("limit 1"));
OutdoorFairBoothBooking second = outdoorFairBoothBookingMapper.selectOne(new LambdaQueryWrapper<OutdoorFairBoothBooking>()
.eq(OutdoorFairBoothBooking::getFairId, fairId)
.eq(OutdoorFairBoothBooking::getBoothId, request.getSecondBoothId()).last("limit 1"));
if (first == null || second == null) {
return AjaxResult.error("请选择两个已预定展位");
}
Long companyId = first.getCompanyId();
String companyName = first.getCompanyName();
first.setCompanyId(second.getCompanyId());
first.setCompanyName(second.getCompanyName());
second.setCompanyId(companyId);
second.setCompanyName(companyName);
outdoorFairBoothBookingMapper.updateById(first);
outdoorFairBoothBookingMapper.updateById(second);
return success();
}
private void fillHandleFields(VenueInfo venueInfo)
{
if (venueInfo.getHandleDate() == null) {

View File

@@ -0,0 +1,38 @@
package com.ruoyi.cms.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("户外招聘会展位预定")
@TableName("cms_outdoor_fair_booth_booking")
public class OutdoorFairBoothBooking extends BaseEntity
{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("招聘会ID")
private Long fairId;
@ApiModelProperty("场地展位ID")
private Long boothId;
@ApiModelProperty("展位号")
private String boothNumber;
@ApiModelProperty("企业ID")
private Long companyId;
@ApiModelProperty("企业名称")
private String companyName;
@ApiModelProperty("预定状态")
private String status;
}

View File

@@ -0,0 +1,32 @@
package com.ruoyi.cms.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("场地展位")
@TableName("cms_venue_booth")
public class VenueBooth extends BaseEntity
{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("场地ID")
private Long venueId;
@ApiModelProperty("展位号")
private String boothNumber;
@ApiModelProperty("X坐标")
private Integer positionX;
@ApiModelProperty("Y坐标")
private Integer positionY;
}

View File

@@ -0,0 +1,10 @@
package com.ruoyi.cms.domain;
import lombok.Data;
@Data
public class VenueBoothSwapRequest
{
private Long firstBoothId;
private Long secondBoothId;
}

View File

@@ -0,0 +1,8 @@
package com.ruoyi.cms.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.cms.domain.OutdoorFairBoothBooking;
public interface OutdoorFairBoothBookingMapper extends BaseMapper<OutdoorFairBoothBooking>
{
}

View File

@@ -0,0 +1,24 @@
package com.ruoyi.cms.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.cms.domain.VenueBooth;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface VenueBoothMapper extends BaseMapper<VenueBooth>
{
@Delete("DELETE FROM cms_venue_booth WHERE venue_id = #{venueId} AND del_flag <> '0'")
int physicalDeleteDeletedByVenueId(@Param("venueId") Long venueId);
@Delete({
"<script>",
"DELETE FROM cms_venue_booth WHERE venue_id = #{venueId} AND id IN",
"<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
"#{id}",
"</foreach>",
"</script>"
})
int physicalDeleteByVenueIdAndIds(@Param("venueId") Long venueId, @Param("ids") List<Long> ids);
}