|
|
|
|
@@ -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) {
|
|
|
|
|
|