新增场地展位管理功能,包括展位图查询、保存、预定及调换功能,新增相关数据模型及数据库表结构
This commit is contained in:
@@ -1,15 +1,30 @@
|
|||||||
package com.ruoyi.cms.controller.cms;
|
package com.ruoyi.cms.controller.cms;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
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.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.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.cms.service.IVenueInfoService;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
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.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
@@ -17,6 +32,7 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -41,6 +57,18 @@ public class VenueInfoController extends BaseController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IVenueInfoService venueInfoService;
|
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()));
|
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)
|
private void fillHandleFields(VenueInfo venueInfo)
|
||||||
{
|
{
|
||||||
if (venueInfo.getHandleDate() == null) {
|
if (venueInfo.getHandleDate() == null) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.ruoyi.cms.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class VenueBoothSwapRequest
|
||||||
|
{
|
||||||
|
private Long firstBoothId;
|
||||||
|
private Long secondBoothId;
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
86
sql/cms_venue_booth_map.sql
Normal file
86
sql/cms_venue_booth_map.sql
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
-- 场地展位图与户外招聘会展位预定
|
||||||
|
-- 瀚高数据库 / PostgreSQL 兼容
|
||||||
|
|
||||||
|
CREATE SEQUENCE IF NOT EXISTS "cms_venue_booth_id_seq" START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
|
||||||
|
CREATE TABLE IF NOT EXISTS "cms_venue_booth" (
|
||||||
|
"id" BIGINT NOT NULL DEFAULT nextval('"cms_venue_booth_id_seq"') PRIMARY KEY,
|
||||||
|
"venue_id" BIGINT NOT NULL,
|
||||||
|
"booth_number" VARCHAR(50) NOT NULL,
|
||||||
|
"position_x" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"position_y" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"create_by" VARCHAR(64) DEFAULT '',
|
||||||
|
"create_time" TIMESTAMP(0),
|
||||||
|
"update_by" VARCHAR(64) DEFAULT '',
|
||||||
|
"update_time" TIMESTAMP(0),
|
||||||
|
"remark" VARCHAR(500),
|
||||||
|
"del_flag" CHAR(1) DEFAULT '0'
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMENT ON TABLE "cms_venue_booth" IS '场地展位图';
|
||||||
|
COMMENT ON COLUMN "cms_venue_booth"."venue_id" IS '场地ID';
|
||||||
|
COMMENT ON COLUMN "cms_venue_booth"."booth_number" IS '展位号';
|
||||||
|
COMMENT ON COLUMN "cms_venue_booth"."position_x" IS 'X坐标';
|
||||||
|
COMMENT ON COLUMN "cms_venue_booth"."position_y" IS 'Y坐标';
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS "uk_cms_venue_booth_number" ON "cms_venue_booth" ("venue_id", "booth_number");
|
||||||
|
CREATE INDEX IF NOT EXISTS "idx_cms_venue_booth_venue" ON "cms_venue_booth" ("venue_id");
|
||||||
|
|
||||||
|
CREATE SEQUENCE IF NOT EXISTS "cms_outdoor_fair_booth_booking_id_seq" START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
|
||||||
|
CREATE TABLE IF NOT EXISTS "cms_outdoor_fair_booth_booking" (
|
||||||
|
"id" BIGINT NOT NULL DEFAULT nextval('"cms_outdoor_fair_booth_booking_id_seq"') PRIMARY KEY,
|
||||||
|
"fair_id" BIGINT NOT NULL,
|
||||||
|
"booth_id" BIGINT NOT NULL,
|
||||||
|
"booth_number" VARCHAR(50) NOT NULL,
|
||||||
|
"company_id" BIGINT,
|
||||||
|
"company_name" VARCHAR(200),
|
||||||
|
"status" VARCHAR(30) DEFAULT 'reserved',
|
||||||
|
"create_by" VARCHAR(64) DEFAULT '',
|
||||||
|
"create_time" TIMESTAMP(0),
|
||||||
|
"update_by" VARCHAR(64) DEFAULT '',
|
||||||
|
"update_time" TIMESTAMP(0),
|
||||||
|
"remark" VARCHAR(500),
|
||||||
|
"del_flag" CHAR(1) DEFAULT '0'
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMENT ON TABLE "cms_outdoor_fair_booth_booking" IS '户外招聘会展位预定';
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS "uk_cms_outdoor_fair_booth_booking" ON "cms_outdoor_fair_booth_booking" ("fair_id", "booth_id");
|
||||||
|
CREATE INDEX IF NOT EXISTS "idx_cms_outdoor_fair_booth_booking_fair" ON "cms_outdoor_fair_booth_booking" ("fair_id");
|
||||||
|
|
||||||
|
WITH target_venue AS (
|
||||||
|
SELECT "id" AS venue_id
|
||||||
|
FROM "cms_venue_info"
|
||||||
|
WHERE "venue_name" = '石河子市人民广场户外招聘区'
|
||||||
|
LIMIT 1
|
||||||
|
),
|
||||||
|
seed AS (
|
||||||
|
SELECT
|
||||||
|
target_venue.venue_id,
|
||||||
|
'KJ' || LPAD(gs::text, 2, '0') AS booth_number,
|
||||||
|
40 + ((gs - 1) % 20) * 54 AS position_x,
|
||||||
|
40 + ((gs - 1) / 20) * 54 AS position_y
|
||||||
|
FROM target_venue
|
||||||
|
CROSS JOIN generate_series(1, 80) gs
|
||||||
|
)
|
||||||
|
INSERT INTO "cms_venue_booth" ("venue_id", "booth_number", "position_x", "position_y", "create_by", "create_time", "del_flag")
|
||||||
|
SELECT seed.venue_id, seed.booth_number, seed.position_x, seed.position_y, 'system', NOW(), '0'
|
||||||
|
FROM seed
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM "cms_venue_booth" existing
|
||||||
|
WHERE existing."venue_id" = seed.venue_id
|
||||||
|
AND existing."booth_number" = seed.booth_number
|
||||||
|
);
|
||||||
|
|
||||||
|
UPDATE "cms_venue_info" venue
|
||||||
|
SET "floor_count" = booth_counts.total
|
||||||
|
FROM (
|
||||||
|
SELECT "venue_id", COUNT(*) AS total
|
||||||
|
FROM "cms_venue_booth"
|
||||||
|
GROUP BY "venue_id"
|
||||||
|
) booth_counts
|
||||||
|
WHERE venue."id" = booth_counts."venue_id";
|
||||||
|
|
||||||
|
UPDATE "cms_outdoor_fair" fair
|
||||||
|
SET "booth_count" = venue."floor_count"
|
||||||
|
FROM "cms_venue_info" venue
|
||||||
|
WHERE fair."venue_id" = venue."id";
|
||||||
Reference in New Issue
Block a user