包厢改餐桌

This commit is contained in:
zjf committed 2025-08-13 15:42:37 +08:00
1 parent 189327bc56
commit b5aa55ca99
30 files changed
+1044 -376

No files matched your search

@@ -1,6 +1,5 @@
package com.bsd.pjcloud.canteen.dto.boxes.admin;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -8,9 +7,24 @@ import lombok.Data;
@Schema(description = "预约分页查询参数")
public class BokingPageDTO {
@Schema(description = "餐桌ID")
private Long boxesId;
@Schema(description = "用户ID")
private Long userId;
@Schema(description = "预约状态")
private Integer status;
@Schema(description = "餐次类型 1-早餐 2-中餐 3-晚餐")
private Integer mealType;
@Schema(description = "用户名称")
private String userName;
@Schema(description = "手机号")
private String mobile;
@Schema(description = "餐桌名称")
private String boxesName;
}
@@ -7,10 +7,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
/**
* 包厢可用时间段
* 餐桌可用时间段
*
* @author zjf
* @date 2024-12-17 13:59:31
@@ -18,10 +17,9 @@ import java.time.LocalTime;
@Data
@TableName("boxes_availability")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "包厢可用时间段")
@Schema(description = "餐桌可用时间段")
public class BoxesAvailabilityEntity extends Model<BoxesAvailabilityEntity> {
/**
* 主键id
*/
@@ -30,9 +28,9 @@ public class BoxesAvailabilityEntity extends Model<BoxesAvailabilityEntity> {
private Long id;
/**
* 包厢Id
* 餐桌Id
*/
@Schema(description="包厢Id")
@Schema(description="餐桌Id")
private Long boxesId;
/**
@@ -60,16 +58,16 @@ public class BoxesAvailabilityEntity extends Model<BoxesAvailabilityEntity> {
private LocalDate bxDate;
/**
* 时间
* 餐次类型 1-早餐 2-中餐 3-晚餐
*/
@Schema(description="时间")
private LocalTime hour;
@Schema(description="餐次类型")
private Integer mealType;
/**
* 时间索引(0-24)
* 餐次名称
*/
@Schema(description="时间索引(0-24)")
private Integer hourIndex;
@Schema(description="餐次名称")
private String mealName;
/**
* 创建人
@@ -7,10 +7,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
/**
* 包厢预约记录表
* 餐桌预约记录表
*
* @author zjf
* @date 2024-12-16 22:39:45
@@ -18,10 +17,9 @@ import java.time.LocalTime;
@Data
@TableName("boxes_booking")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "包厢预约记录表")
@Schema(description = "餐桌预约记录表")
public class BoxesBookingEntity extends Model<BoxesBookingEntity> {
/**
* 主键id
*/
@@ -30,53 +28,11 @@ public class BoxesBookingEntity extends Model<BoxesBookingEntity> {
private Long id;
/**
* 包厢Id
* 餐桌Id
*/
@Schema(description="包厢Id")
@Schema(description="餐桌Id")
private Long boxesId;
/**
* 开始时间
*/
@Schema(description="开始时间")
private LocalTime startTime;
/**
* 结束时间
*/
@Schema(description="结束时间")
private LocalTime endTime;
/**
* 审核人id
*/
@Schema(description="审核人id")
private Long checkUserId;
/**
* 1审核中 2通过 3驳回 4
*/
@Schema(description="1审核中 2通过 3驳回 4")
private String checkStatus;
/**
* 创建人
*/
@Schema(description="创建人")
private String creator;
/**
* 更新人
*/
@Schema(description="更新人")
private Double updater;
/**
* 是否删除
*/
@Schema(description="是否删除")
private Boolean deleted;
/**
* 预约日期
*/
@@ -92,7 +48,7 @@ public class BoxesBookingEntity extends Model<BoxesBookingEntity> {
/**
* 预约状态(0 预约成功,1预约失败 2取消预约 )
*/
@Schema(description="预约状态(0 预约成功,1预约失败 2取消预约 )")
@Schema(description="预约状态")
private Integer status;
/**
@@ -101,6 +57,24 @@ public class BoxesBookingEntity extends Model<BoxesBookingEntity> {
@Schema(description="总价单位分")
private Integer totalPrice;
/**
* 餐次类型 1-早餐 2-中餐 3-晚餐
*/
@Schema(description="餐次类型")
private Integer mealType;
/**
* 预约人数
*/
@Schema(description="预约人数")
private Integer peopleCount;
/**
* 备注信息
*/
@Schema(description="备注信息")
private String remark;
/**
* 创建时间
*/
@@ -115,17 +89,10 @@ public class BoxesBookingEntity extends Model<BoxesBookingEntity> {
@Schema(description="更新时间")
private LocalDateTime updateTime;
@Schema(description="部门id")
private Long deptId;
@Schema(description="流程实例id")
private String processInstanceId;
@Schema(description="审核原因")
private String checkReason;
@Schema(description="包厢名称")
@Schema(description="餐桌名称")
@TableField(exist = false)
private String boxesName;
@@ -8,7 +8,7 @@ import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 包厢信息
* 餐桌信息
*
* @author zjf
* @date 2024-12-16 21:13:58
@@ -16,10 +16,9 @@ import java.time.LocalDateTime;
@Data
@TableName("boxes_info")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "包厢信息")
@Schema(description = "餐桌信息")
public class BoxesInfoEntity extends Model<BoxesInfoEntity> {
/**
* 主键id
*/
@@ -28,11 +27,17 @@ public class BoxesInfoEntity extends Model<BoxesInfoEntity> {
private Long id;
/**
* 包厢名称
* 餐桌名称
*/
@Schema(description="包厢名称")
@Schema(description="餐桌名称")
private String name;
/**
* 餐桌编号
*/
@Schema(description="餐桌编号")
private String tableNumber;
/**
* 容纳人数
*/
@@ -40,35 +45,41 @@ public class BoxesInfoEntity extends Model<BoxesInfoEntity> {
private Long capacity;
/**
* 包厢描述
* 餐桌描述
*/
@Schema(description="包厢描述")
@Schema(description="餐桌描述")
private String description;
/**
* 包厢地址
* 餐桌位置
*/
@Schema(description="包厢地址")
@Schema(description="餐桌位置")
private String address;
/**
* 包厢图片
* 餐桌图片
*/
@Schema(description="包厢图片")
@Schema(description="餐桌图片")
private String images;
/**
* 包厢状态
* 餐桌状态
*/
@Schema(description="包厢状态")
@Schema(description="餐桌状态")
private Integer status;
/**
* 包厢价格单位分
* 餐桌价格单位分
*/
@Schema(description="包厢价格单位分")
@Schema(description="餐桌价格单位分")
private Integer price;
/**
* 餐桌类型 1-小桌(2-4人) 2-中桌(4-6人) 3-大桌(6-8人) 4-包间(8人以上)
*/
@Schema(description="餐桌类型")
private Integer tableType;
/**
* 商户id
*/
@@ -113,5 +124,4 @@ public class BoxesInfoEntity extends Model<BoxesInfoEntity> {
@Schema(description="部门id")
private Long deptId;
}
@@ -0,0 +1,119 @@
package com.bsd.pjcloud.canteen.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
import java.time.LocalTime;
/**
* 时间段配置
*
* @author zjf
* @date 2024-12-17 13:59:31
*/
@Data
@TableName("time_slot_config")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "时间段配置")
public class TimeSlotConfigEntity extends Model<TimeSlotConfigEntity> {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="主键id")
private Long id;
/**
* 餐次类型 1-早餐 2-中餐 3-晚餐
*/
@Schema(description="餐次类型")
private Integer mealType;
/**
* 餐次名称
*/
@Schema(description="餐次名称")
private String mealName;
/**
* 开始时间
*/
@Schema(description="开始时间")
private LocalTime startTime;
/**
* 结束时间
*/
@Schema(description="结束时间")
private LocalTime endTime;
/**
* 时间段名称
*/
@Schema(description="时间段名称")
private String timeSlotName;
/**
* 是否启用 0-禁用 1-启用
*/
@Schema(description="是否启用")
private Integer isEnabled;
/**
* 排序
*/
@Schema(description="排序")
private Integer sort;
/**
* 备注
*/
@Schema(description="备注")
private String remark;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 更新人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新人")
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新时间")
private LocalDateTime updateTime;
/**
* 是否删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="是否删除")
private String delFlag;
}
@@ -0,0 +1,33 @@
package com.bsd.pjcloud.canteen.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.canteen.dto.boxes.admin.BokingPageDTO;
import com.bsd.pjcloud.canteen.entity.BoxesBookingEntity;
import com.bsd.pjcloud.canteen.vo.AppMakeSaveReqVO;
import com.bsd.pjcloud.common.core.util.R;
/**
* 餐桌预约记录表
*
* @author zjf
* @date 2024-12-16 22:39:45
*/
public interface BoxesBookingService extends IService<BoxesBookingEntity> {
/**
* 分页查询
* @param page 分页对象
* @param bokingPageDTO 查询条件
* @return 分页结果
*/
IPage<BoxesBookingEntity> pageScope(Page<BoxesBookingEntity> page, BokingPageDTO bokingPageDTO);
/**
* 创建预约
* @param createReqVO 预约请求
* @return 预约ID
*/
R<Long> createBooking(AppMakeSaveReqVO createReqVO);
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.canteen.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.canteen.entity.TimeSlotConfigEntity;
public interface TimeSlotConfigService extends IService<TimeSlotConfigEntity> {
}
@@ -1,15 +1,14 @@
package com.bsd.pjcloud.canteen.vo;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalTime;
@Data
@Schema(description = "点餐APP- 餐桌可用时间段 Response VO")
public class APPBXAvaliabilityRespVO {
/**
@@ -17,36 +16,40 @@ public class APPBXAvaliabilityRespVO {
*/
@TableId
private Long id;
/**
* 包厢Id
* 餐桌Id
*/
private Long boxesId;
/**
* 预约id
*/
private Long bookingId;
/**
* 状态 0空闲 1 已有预约 2 部分空闲
*
*/
private Integer status;
/**
* 用户id
*/
private Long userId;
/**
* 格式为 YYYY-MM-DD
*/
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate bxDate;
/**
* 时间
* 餐次类型 1-早餐 2-中餐 3-晚餐
*/
@JsonFormat(pattern = "HH:mm")
private LocalTime hour;
private Integer mealType;
/**
* 时间索引(0-24)
* 餐次名称
*/
private Integer hourIndex;
private String mealName;
}
@@ -12,19 +12,19 @@ import java.time.LocalDateTime;
@Data
@Schema(description = "点餐APP - 我的预约包厢记录")
@Schema(description = "点餐APP - 我的预约餐桌记录")
public class APPBookingInfo {
@Schema(description = "主键id")
@ExcelProperty("主键id")
private Long id;
@Schema(description = "包厢Id")
@ExcelProperty("包厢Id")
@Schema(description = "餐桌Id")
@ExcelProperty("餐桌Id")
@JsonIgnore
private Long boxesId;
@Schema(description = "包厢名称", example = "测试包厢")
@Schema(description = "餐桌名称", example = "测试餐桌")
private String boxesName;
@Schema(description = "开始时间")
@@ -70,4 +70,12 @@ public class APPBookingInfo {
@Schema(description = "预约状态(0 预约成功,1预约失败 2取消预约 )", example = "2")
private Integer status;
@Schema(description = "餐次类型 1-早餐 2-中餐 3-晚餐")
private Integer mealType;
@Schema(description = "预约人数")
private Integer peopleCount;
@Schema(description = "备注信息")
private String remark;
}
@@ -5,16 +5,13 @@ import lombok.Data;
import java.util.List;
@Schema(description = "点餐APP- 包厢详情 Request VO")
@Schema(description = "点餐APP- 餐桌详情 Response VO")
@Data
public class AppBXDetailRespVO {
@Schema(description = "包厢状态")
@Schema(description = "餐桌状态")
private Short status;
@Schema(description = "包厢所有时间表")
@Schema(description = "餐桌所有时间表")
private List<APPBXAvaliabilityRespVO> avaliabilityRespList;
}
@@ -3,31 +3,37 @@ package com.bsd.pjcloud.canteen.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "点餐APP- 包厢详情 Request VO")
@Schema(description = "点餐APP- 餐桌详情 Request VO")
@Data
public class AppBXInfoRespVO {
@Schema(description = "包厢Id")
@Schema(description = "餐桌Id")
private Long id;
@Schema(description = "包厢名称")
@Schema(description = "餐桌名称")
private String name;
@Schema(description = "餐桌编号")
private String tableNumber;
@Schema(description = "容纳人数")
private Long capacity;
@Schema(description = "包厢描述")
@Schema(description = "餐桌描述")
private String description;
@Schema(description = "包厢地址")
@Schema(description = "餐桌位置")
private String address;
@Schema(description = "包厢背景图")
@Schema(description = "餐桌背景图")
private String images;
@Schema(description = "包厢价格/每小时")
@Schema(description = "餐桌价格/每小时")
private String price;
@Schema(description = "餐桌类型")
private Integer tableType;
@Schema(description = "餐桌状态")
private Integer status;
}
@@ -6,46 +6,54 @@ import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "点餐APP- 包厢信息 Response VO")
@Schema(description = "点餐APP- 餐桌信息 Response VO")
@Data
public class AppBoxesInfoVO {
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("主键id")
private Long id;
@Schema(description = "包厢名称")
@ExcelProperty("包厢名称")
@Schema(description = "餐桌名称")
@ExcelProperty("餐桌名称")
private String name;
@Schema(description = "餐桌编号")
@ExcelProperty("餐桌编号")
private String tableNumber;
@Schema(description = "容纳人数")
@ExcelProperty("容纳人数")
private Long capacity;
@Schema(description = "包厢状态")
@Schema(description = "餐桌状态")
private Integer status;
@Schema(description = "包厢地址")
@ExcelProperty("包厢地址")
@Schema(description = "餐桌位置")
@ExcelProperty("餐桌位置")
private String address;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "包厢背景图")
@ExcelProperty("包厢背景图")
@Schema(description = "餐桌背景图")
@ExcelProperty("餐桌背景图")
private String images;
@Schema(description = "包厢价格")
@ExcelProperty("包厢价格")
@Schema(description = "餐桌价格")
@ExcelProperty("餐桌价格")
private String price;
/**
* 包厢描述
* 餐桌描述
*/
private String description;
/**
* 餐桌类型
*/
private Integer tableType;
/**
* 商户id
*/
@@ -4,24 +4,23 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "点餐APP- 用户发起预约 Request VO")
@Schema(description = "点餐APP- 用户发起餐桌预约 Request VO")
@Data
public class AppMakeSaveReqVO {
@Schema(description = "包厢Id", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "餐桌Id", requiredMode = Schema.RequiredMode.REQUIRED)
private Long boxesId;
@Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonFormat(pattern = "HH:mm")
private String startTime;
@Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonFormat(pattern = "HH:mm")
private String endTime;
@Schema(description = "时间", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "预约日期", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonFormat(pattern = "yyyy-MM-dd")
private String bxDate;
@Schema(description = "餐次类型 1-早餐 2-中餐 3-晚餐", requiredMode = Schema.RequiredMode.REQUIRED)
private Integer mealType;
@Schema(description = "预约人数", requiredMode = Schema.RequiredMode.REQUIRED)
private Integer peopleCount;
@Schema(description = "备注信息")
private String remark;
}
@@ -23,88 +23,87 @@ import java.util.List;
import java.util.Objects;
/**
* 包厢可用时间段
* 餐桌可用时间段
*
* @author zjf
* @date 2024-12-17 13:59:31
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/boxesAvailability" )
@Tag(description = "boxesAvailability" , name = "包厢可用时间段管理" )
@RequestMapping("/boxesAvailability")
@Tag(description = "boxesAvailability", name = "餐桌可用时间段管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class BoxesAvailabilityController {
private final BoxesAvailabilityService boxesAvailabilityService;
private final BoxesAvailabilityService boxesAvailabilityService;
/**
* 分页查询
* @param page 分页对象
* @param boxesAvailability 包厢可用时间段
* @param boxesAvailability 餐桌可用时间段
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_view')" )
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_view')")
public R getBoxesAvailabilityPage(@ParameterObject Page page, @ParameterObject BoxesAvailabilityEntity boxesAvailability) {
LambdaQueryWrapper<BoxesAvailabilityEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(Objects.nonNull(boxesAvailability.getStatus()),BoxesAvailabilityEntity::getStatus,boxesAvailability.getStatus());
wrapper.eq(Objects.nonNull(boxesAvailability.getStatus()), BoxesAvailabilityEntity::getStatus, boxesAvailability.getStatus());
wrapper.eq(Objects.nonNull(boxesAvailability.getMealType()), BoxesAvailabilityEntity::getMealType, boxesAvailability.getMealType());
return R.ok(boxesAvailabilityService.page(page, wrapper));
}
/**
* 通过id查询包厢可用时间段
* 通过id查询餐桌可用时间段
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_view')" )
public R getById(@PathVariable("id" ) Long id) {
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(boxesAvailabilityService.getById(id));
}
/**
* 新增包厢可用时间段
* @param boxesAvailability 包厢可用时间段
* 新增餐桌可用时间段
* @param boxesAvailability 餐桌可用时间段
* @return R
*/
@Operation(summary = "新增包厢可用时间段" , description = "新增包厢可用时间段" )
@SysLog("新增包厢可用时间段" )
@Operation(summary = "新增餐桌可用时间段", description = "新增餐桌可用时间段")
@SysLog("新增餐桌可用时间段")
@PostMapping
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_add')" )
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_add')")
public R save(@RequestBody BoxesAvailabilityEntity boxesAvailability) {
return R.ok(boxesAvailabilityService.save(boxesAvailability));
}
/**
* 修改包厢可用时间段
* @param boxesAvailability 包厢可用时间段
* 修改餐桌可用时间段
* @param boxesAvailability 餐桌可用时间段
* @return R
*/
@Operation(summary = "修改包厢可用时间段" , description = "修改包厢可用时间段" )
@SysLog("修改包厢可用时间段" )
@Operation(summary = "修改餐桌可用时间段", description = "修改餐桌可用时间段")
@SysLog("修改餐桌可用时间段")
@PutMapping
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_edit')" )
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_edit')")
public R updateById(@RequestBody BoxesAvailabilityEntity boxesAvailability) {
return R.ok(boxesAvailabilityService.updateById(boxesAvailability));
}
/**
* 通过id删除包厢可用时间段
* 通过id删除餐桌可用时间段
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除包厢可用时间段" , description = "通过id删除包厢可用时间段" )
@SysLog("通过id删除包厢可用时间段" )
@Operation(summary = "通过id删除餐桌可用时间段", description = "通过id删除餐桌可用时间段")
@SysLog("通过id删除餐桌可用时间段")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_del')" )
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(boxesAvailabilityService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param boxesAvailability 查询条件
@@ -113,8 +112,8 @@ public class BoxesAvailabilityController {
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_export')" )
public List<BoxesAvailabilityEntity> export(BoxesAvailabilityEntity boxesAvailability,Long[] ids) {
@PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_export')")
public List<BoxesAvailabilityEntity> export(BoxesAvailabilityEntity boxesAvailability, Long[] ids) {
return boxesAvailabilityService.list(Wrappers.lambdaQuery(boxesAvailability).in(ArrayUtil.isNotEmpty(ids), BoxesAvailabilityEntity::getId, ids));
}
}
@@ -9,16 +9,19 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.canteen.dto.boxes.admin.BokingPageDTO;
import com.bsd.pjcloud.canteen.job.BoxesAvaliabilityJob;
import com.bsd.pjcloud.canteen.vo.AppMakeSaveReqVO;
import com.bsd.pjcloud.canteen.vo.APPBXAvaliabilityRespVO;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.canteen.entity.BoxesAvailabilityEntity;
import com.bsd.pjcloud.canteen.entity.BoxesBookingEntity;
import com.bsd.pjcloud.canteen.service.BoxesAvailabilityService;
import com.bsd.pjcloud.canteen.service.BoxesBookingService;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordParamDto;
import com.bsd.pjcloud.flow.task.utils.GetCheckReasonUtils;
import com.bsd.pjcloud.flow.task.vo.CheckStatusAndReasonVo;
import org.apache.seata.spring.annotation.GlobalTransactional;
// import com.bsd.pjcloud.common.security.annotation.Inner;
// import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
// import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordParamDto;
// import com.bsd.pjcloud.flow.task.utils.GetCheckReasonUtils;
// import com.bsd.pjcloud.flow.task.vo.CheckStatusAndReasonVo;
// import org.apache.seata.spring.annotation.GlobalTransactional;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -26,97 +29,98 @@ import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
/**
* 包厢预约记录表
* 餐桌预约记录表
*
* @author zjf
* @date 2024-12-16 22:39:45
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/boxesBooking" )
@Tag(description = "boxesBooking" , name = "包厢预约记录表管理" )
@RequestMapping("/boxesBooking")
@Tag(description = "boxesBooking", name = "餐桌预约记录表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class BoxesBookingController {
private final BoxesBookingService boxesBookingService;
private final BoxesBookingService boxesBookingService;
private final BoxesAvailabilityService boxesAvailabilityService;
private final BoxesAvaliabilityJob batchAvaliabilityJob;
/**
* 分页查询
* @param page 分页对象
* @param bokingPageDTO 包厢预约记录表
* @param bokingPageDTO 餐桌预约记录表
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_view')" )
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_view')")
public R getBoxesBookingPage(@ParameterObject Page page, @ParameterObject BokingPageDTO bokingPageDTO) {
return R.ok(boxesBookingService.pageScope(page, bokingPageDTO));
}
/**
* 通过id查询包厢预约记录表
* 通过id查询餐桌预约记录表
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_view')" )
public R getById(@PathVariable("id" ) Long id) {
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(boxesBookingService.getById(id));
}
/**
* 新增包厢预约记录表
* @param boxesBooking 包厢预约记录表
* 新增餐桌预约记录表
* @param boxesBooking 餐桌预约记录表
* @return R
*/
@Operation(summary = "新增包厢预约记录表" , description = "新增包厢预约记录表" )
@SysLog("新增包厢预约记录表" )
@Operation(summary = "新增餐桌预约记录表", description = "新增餐桌预约记录表")
@SysLog("新增餐桌预约记录表")
@PostMapping
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_add')" )
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_add')")
public R save(@RequestBody BoxesBookingEntity boxesBooking) {
return R.ok(boxesBookingService.save(boxesBooking));
}
/**
* 修改包厢预约记录表
* @param boxesBooking 包厢预约记录表
* 修改餐桌预约记录表
* @param boxesBooking 餐桌预约记录表
* @return R
*/
@Operation(summary = "修改包厢预约记录表" , description = "修改包厢预约记录表" )
@SysLog("修改包厢预约记录表" )
@Operation(summary = "修改餐桌预约记录表", description = "修改餐桌预约记录表")
@SysLog("修改餐桌预约记录表")
@PutMapping
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_edit')" )
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_edit')")
public R updateById(@RequestBody BoxesBookingEntity boxesBooking) {
return R.ok(boxesBookingService.updateById(boxesBooking));
}
/**
* 通过id删除包厢预约记录表
* 通过id删除餐桌预约记录表
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除包厢预约记录表" , description = "通过id删除包厢预约记录表" )
@SysLog("通过id删除包厢预约记录表" )
@Operation(summary = "通过id删除餐桌预约记录表", description = "通过id删除餐桌预约记录表")
@SysLog("删除餐桌预约记录表")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_del')" )
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(boxesBookingService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param boxesBooking 查询条件
@@ -125,22 +129,51 @@ public class BoxesBookingController {
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_export')" )
public List<BoxesBookingEntity> export(BoxesBookingEntity boxesBooking,Long[] ids) {
@PreAuthorize("@pms.hasPermission('canteen_boxesBooking_export')")
public List<BoxesBookingEntity> export(BoxesBookingEntity boxesBooking, Long[] ids) {
return boxesBookingService.list(Wrappers.lambdaQuery(boxesBooking).in(ArrayUtil.isNotEmpty(ids), BoxesBookingEntity::getId, ids));
}
@PostMapping("/create")
@Operation(summary = "新增预约")
@Transactional
@GlobalTransactional
// @GlobalTransactional
public R<Long> createBooking(@RequestBody AppMakeSaveReqVO createReqVO) {
return boxesBookingService.createBooking(createReqVO);
}
/**
* 查看当前包厢可预约的餐段
* @param boxesId 包厢ID
* @param bookingDate 预约日期
* @return 可预约的餐段列表
*/
@GetMapping("/availableMeals")
@Operation(summary = "查看当前包厢可预约的餐段", description = "根据包厢ID和预约日期查看可预约的餐段")
@Parameter(name = "boxesId", description = "包厢ID", required = true, example = "1")
@Parameter(name = "bookingDate", description = "预约日期", required = true, example = "2024-12-17")
public R<List<APPBXAvaliabilityRespVO>> getAvailableMeals(
@RequestParam("boxesId") Long boxesId,
@RequestParam("bookingDate") String bookingDate) {
try {
LocalDate date = LocalDate.parse(bookingDate);
List<APPBXAvaliabilityRespVO> availableMeals = boxesAvailabilityService.getAvailableMeals(boxesId, date);
// 如果返回空列表,说明餐桌不存在
if (availableMeals.isEmpty()) {
return R.failed("餐桌不存在或已被删除");
}
return R.ok(availableMeals);
} catch (Exception e) {
// log.error("查询可预约餐段失败,boxesId: {}, date: {}", boxesId, bookingDate, e); // Original code had this line commented out
return R.failed("查询可预约餐段失败:" + e.getMessage());
}
}
// 暂时注释掉工作流回调,不需要审批
/*
@PostMapping("/flow-callback")
@Operation(summary = "流程节点回调通知")
@Inner(value = false)
@@ -156,52 +189,15 @@ public class BoxesBookingController {
CheckStatusAndReasonVo checkReason = GetCheckReasonUtils.getCheckReason(processNodeRecordParamDto);
boxesBookingEntity.setCheckStatus(checkReason.getCheckStatus());
boxesBookingEntity.setCheckReason(checkReason.getCheckReason());
boxesBookingService.update(boxesBookingEntity,boxesBookingEntityLambdaQueryWrapper);
boxesBookingService.update(boxesBookingEntity, boxesBookingEntityLambdaQueryWrapper);
return R.ok();
}
*/
@Operation(summary = "同步包厢时间" , description = "同步包厢时间" )
@GetMapping("/anscyJob" )
@Operation(summary = "同步餐桌时间", description = "同步餐桌时间")
@GetMapping("/anscyJob")
public R getById() {
batchAvaliabilityJob.avaliabilityJobHandler();
// batchAvaliabilityJob.avaliabilityJobHandler();
return R.ok();
}
//-------------app------------------
// @GetMapping("/getMyBookingPage")
// @Operation(summary = "获得我的预约包厢信息")
// public R getBookingPage(
// @ParameterObject Page page,
// ) {
// BookingPageReqVO bookingPageReqVO = new BookingPageReqVO();
// bookingPageReqVO.setPageNo(pageNo);
// bookingPageReqVO.setPageSize(pageSize);
// bookingPageReqVO.setStatus(status);
// bookingPageReqVO.setUserId(getLoginUserId());
// PageResult<BookingDO> bookingPage = bookingService.getBookingPage(bookingPageReqVO);
// PageResult<APPBookingInfo> bean = BeanUtils.toBean(bookingPage, APPBookingInfo.class);
// if (ObjectUtil.isEmpty(bookingPage.getList())) return success(bean);
//
// List<Long> collectUserIdS = bookingPage.getList().stream().map(BookingDO::getUserId).collect(Collectors.toList());
// List<Long> collectBoxesIdS = bookingPage.getList().stream().map(BookingDO::getBoxesId).collect(Collectors.toList());
// Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(collectUserIdS);
// Map<Long, InfoRespVO> boxIdMap = infoService.getInfoMap(collectBoxesIdS);
// bean.getList().forEach(x -> {
// x.setNickName(userMap.get(x.getUserId()).getNickname());
// x.setMobile(userMap.get(x.getUserId()).getMobile());
// x.setBoxesName(boxIdMap.get(x.getBoxesId()).getName());
// });
// return success(bean);
//
// }
//
// @GetMapping("/cancel")
// @Operation(summary = "取消预约")
// public R<Long> createBooking(@RequestParam("id") Long bookId) {
// Long id = bookingService.cancelBooking(bookId);
// return success(id);
// }
}
@@ -32,7 +32,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* 包厢信息
* 餐桌信息
*
* @author zjf
* @date 2024-12-16 21:13:58
@@ -40,19 +40,19 @@ import java.util.List;
@RestController
@RequiredArgsConstructor
@RequestMapping("/boxesInfo")
@Tag(description = "boxesInfo", name = "包厢信息管理")
@Tag(description = "boxesInfo", name = "餐桌信息管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class BoxesInfoController {
private final BoxesInfoService boxesInfoService;
private final BoxesBookingService bookingService;
private final BoxesBookingService boxesBookingService;
/**
* 分页查询
*
* @param page 分页对象
* @param boxesInfo 包厢信息
* @param boxesInfo 餐桌信息
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@@ -61,12 +61,14 @@ public class BoxesInfoController {
public R getBoxesInfoPage(@ParameterObject Page page, @ParameterObject BoxesInfoEntity boxesInfo) {
LambdaQueryWrapper<BoxesInfoEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(StrUtil.isNotBlank(boxesInfo.getName()), BoxesInfoEntity::getName, boxesInfo.getName());
wrapper.eq(StrUtil.isNotBlank(boxesInfo.getTableNumber()), BoxesInfoEntity::getTableNumber, boxesInfo.getTableNumber());
wrapper.eq(ObjectUtil.isNotEmpty(boxesInfo.getStatus()), BoxesInfoEntity::getStatus, boxesInfo.getStatus());
wrapper.eq(ObjectUtil.isNotEmpty(boxesInfo.getTableType()), BoxesInfoEntity::getTableType, boxesInfo.getTableType());
return R.ok(boxesInfoService.pageScope(page, wrapper));
}
/**
* 通过id查询包厢信息
* 通过id查询餐桌信息
*
* @param id id
* @return R
@@ -79,13 +81,13 @@ public class BoxesInfoController {
}
/**
* 新增包厢信息
* 新增餐桌信息
*
* @param boxesInfo 包厢信息
* @param boxesInfo 餐桌信息
* @return R
*/
@Operation(summary = "新增包厢信息", description = "新增包厢信息")
@SysLog("新增包厢信息")
@Operation(summary = "新增餐桌信息", description = "新增餐桌信息")
@SysLog("新增餐桌信息")
@PostMapping
@PreAuthorize("@pms.hasPermission('canteen_boxesInfo_add')")
public R save(@RequestBody BoxesInfoEntity boxesInfo) {
@@ -94,13 +96,13 @@ public class BoxesInfoController {
}
/**
* 修改包厢信息
* 修改餐桌信息
*
* @param boxesInfo 包厢信息
* @param boxesInfo 餐桌信息
* @return R
*/
@Operation(summary = "修改包厢信息", description = "修改包厢信息")
@SysLog("修改包厢信息")
@Operation(summary = "修改餐桌信息", description = "修改餐桌信息")
@SysLog("修改餐桌信息")
@PutMapping
@PreAuthorize("@pms.hasPermission('canteen_boxesInfo_edit')")
public R updateById(@RequestBody BoxesInfoEntity boxesInfo) {
@@ -108,20 +110,19 @@ public class BoxesInfoController {
}
/**
* 通过id删除包厢信息
* 通过id删除餐桌信息
*
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除包厢信息", description = "通过id删除包厢信息")
@SysLog("通过id删除包厢信息")
@Operation(summary = "通过id删除餐桌信息", description = "通过id删除餐桌信息")
@SysLog("删除餐桌信息")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_boxesInfo_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(boxesInfoService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
*
@@ -136,10 +137,9 @@ public class BoxesInfoController {
return boxesInfoService.list(Wrappers.lambdaQuery(boxesInfo).in(ArrayUtil.isNotEmpty(ids), BoxesInfoEntity::getId, ids));
}
// --------------------移动端接口---------------------------
@GetMapping("/getInfo")
@Operation(summary = "获得包厢固定的基础信息")
@Operation(summary = "获得餐桌固定的基础信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public R<AppBXInfoRespVO> getInfo(@RequestParam("id") Long id) {
BoxesInfoEntity byId = boxesInfoService.getById(id);
@@ -149,7 +149,7 @@ public class BoxesInfoController {
}
@GetMapping("/get")
@Operation(summary = "根据日期动态获取包厢可预约时间信息")
@Operation(summary = "根据日期动态获取餐桌可预约时间信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public R<AppBXDetailRespVO> getInfoAvailability(@RequestParam("id") Long id,
@DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam("currentDate") LocalDate date) {
@@ -158,11 +158,12 @@ public class BoxesInfoController {
}
@GetMapping("/appPage")
@Operation(summary = "获得包厢信息分页")
@Operation(summary = "获得餐桌信息分页")
public R getInfoPage(@ParameterObject Page page, @ParameterObject BoxesInfoEntity boxesInfo) {
LambdaQueryWrapper<BoxesInfoEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(StrUtil.isNotBlank(boxesInfo.getName()), BoxesInfoEntity::getName, boxesInfo.getName());
wrapper.eq(ObjectUtil.isNotEmpty(boxesInfo.getStatus()), BoxesInfoEntity::getStatus, boxesInfo.getStatus());
wrapper.eq(ObjectUtil.isNotEmpty(boxesInfo.getTableType()), BoxesInfoEntity::getTableType, boxesInfo.getTableType());
Page pageResult = boxesInfo.selectPage(page, wrapper);
List<AppBoxesInfoVO> appInfoRespVOS = new ArrayList<>();
pageResult.getRecords().forEach(x -> {
@@ -173,4 +174,9 @@ public class BoxesInfoController {
return R.ok(pageResult);
}
@PostMapping("/createBooking")
@Operation(summary = "创建餐桌预约")
public R<Long> createBooking(@RequestBody AppMakeSaveReqVO createReqVO) {
return boxesBookingService.createBooking(createReqVO);
}
}
@@ -0,0 +1,133 @@
package com.bsd.pjcloud.canteen.controller;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.canteen.entity.TimeSlotConfigEntity;
import com.bsd.pjcloud.canteen.service.TimeSlotConfigService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* 时间段配置
*
* @author zjf
* @date 2024-12-17 13:59:31
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/timeSlotConfig")
@Tag(description = "timeSlotConfig", name = "时间段配置管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class TimeSlotConfigController {
private final TimeSlotConfigService timeSlotConfigService;
/**
* 分页查询
* @param page 分页对象
* @param timeSlotConfig 时间段配置
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('canteen_timeSlotConfig_view')")
public R getTimeSlotConfigPage(@ParameterObject Page page, @ParameterObject TimeSlotConfigEntity timeSlotConfig) {
LambdaQueryWrapper<TimeSlotConfigEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(Objects.nonNull(timeSlotConfig.getMealType()), TimeSlotConfigEntity::getMealType, timeSlotConfig.getMealType());
wrapper.eq(Objects.nonNull(timeSlotConfig.getIsEnabled()), TimeSlotConfigEntity::getIsEnabled, timeSlotConfig.getIsEnabled());
wrapper.orderByAsc(TimeSlotConfigEntity::getSort);
return R.ok(timeSlotConfigService.page(page, wrapper));
}
/**
* 通过id查询时间段配置
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('canteen_timeSlotConfig_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(timeSlotConfigService.getById(id));
}
/**
* 新增时间段配置
* @param timeSlotConfig 时间段配置
* @return R
*/
@Operation(summary = "新增时间段配置", description = "新增时间段配置")
@SysLog("新增时间段配置")
@PostMapping
@PreAuthorize("@pms.hasPermission('canteen_timeSlotConfig_add')")
public R save(@RequestBody TimeSlotConfigEntity timeSlotConfig) {
return R.ok(timeSlotConfigService.save(timeSlotConfig));
}
/**
* 修改时间段配置
* @param timeSlotConfig 时间段配置
* @return R
*/
@Operation(summary = "修改时间段配置", description = "修改时间段配置")
@SysLog("修改时间段配置")
@PutMapping
@PreAuthorize("@pms.hasPermission('canteen_timeSlotConfig_edit')")
public R updateById(@RequestBody TimeSlotConfigEntity timeSlotConfig) {
return R.ok(timeSlotConfigService.updateById(timeSlotConfig));
}
/**
* 通过id删除时间段配置
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除时间段配置", description = "通过id删除时间段配置")
@SysLog("通过id删除时间段配置")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_timeSlotConfig_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(timeSlotConfigService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param timeSlotConfig 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('canteen_timeSlotConfig_export')")
public List<TimeSlotConfigEntity> export(TimeSlotConfigEntity timeSlotConfig, Long[] ids) {
return timeSlotConfigService.list(Wrappers.lambdaQuery(timeSlotConfig).in(ArrayUtil.isNotEmpty(ids), TimeSlotConfigEntity::getId, ids));
}
/**
* 获取所有启用的时间段配置
* @return R
*/
@Operation(summary = "获取所有启用的时间段配置", description = "获取所有启用的时间段配置")
@GetMapping("/listEnabled")
public R listEnabled() {
LambdaQueryWrapper<TimeSlotConfigEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TimeSlotConfigEntity::getIsEnabled, 1);
wrapper.orderByAsc(TimeSlotConfigEntity::getSort);
return R.ok(timeSlotConfigService.list(wrapper));
}
}
@@ -0,0 +1,119 @@
package com.bsd.pjcloud.canteen.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 时间段配置表
*
* @author pjcloud
* @date 2025-08-13 12:17:22
*/
@Data
@TableName("time_slot_config")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "时间段配置表")
public class TimeSlotConfigEntity extends Model<TimeSlotConfigEntity> {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="主键id")
private Long id;
/**
* 餐次类型 1-早餐 2-中餐 3-晚餐
*/
@Schema(description="餐次类型 1-早餐 2-中餐 3-晚餐")
private Integer mealType;
/**
* 餐次名称
*/
@Schema(description="餐次名称")
private String mealName;
/**
* 开始时间
*/
@Schema(description="开始时间")
private Object startTime;
/**
* 结束时间
*/
@Schema(description="结束时间")
private Object endTime;
/**
* 时间段名称
*/
@Schema(description="时间段名称")
private String timeSlotName;
/**
* 是否启用 0-禁用 1-启用
*/
@Schema(description="是否启用 0-禁用 1-启用")
private Integer isEnabled;
/**
* 排序
*/
@Schema(description="排序")
private Integer sort;
/**
* 备注
*/
@Schema(description="备注")
private String remark;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 更新人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新人")
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新时间")
private LocalDateTime updateTime;
/**
* 是否删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="是否删除")
private String delFlag;
}
@@ -25,7 +25,7 @@ public class BoxesAvaliabilityJob {
private final BoxesAvailabilityService boxesAvailabilityService;
private final BoxesAvailabilityMapper boxesAvailabilityMapper;
@XxlJob("avaliabilityJobHandler")
/* @XxlJob("avaliabilityJobHandler")
public void avaliabilityJobHandler() {
//查询所有包厢
List<BoxesInfoEntity> rooms = boxesInfoMapper.selectList(null);
@@ -62,5 +62,5 @@ public class BoxesAvaliabilityJob {
boxesAvailabilityService.saveBatch(availabilityList);
}
XxlJobHelper.handleSuccess();
}
}*/
}
@@ -7,5 +7,4 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BoxesInfoMapper extends PjcloudBaseMapper<BoxesInfoEntity> {
}
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.canteen.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.canteen.entity.TimeSlotConfigEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TimeSlotConfigMapper extends PjcloudBaseMapper<TimeSlotConfigEntity> {
}
@@ -2,7 +2,19 @@ package com.bsd.pjcloud.canteen.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.canteen.entity.BoxesAvailabilityEntity;
import com.bsd.pjcloud.canteen.vo.APPBXAvaliabilityRespVO;
import java.time.LocalDate;
import java.util.List;
public interface BoxesAvailabilityService extends IService<BoxesAvailabilityEntity> {
/**
* 获取指定包厢在指定日期的可预约餐段
* 从预约记录中查询,返回未被预约的餐段
* @param boxesId 包厢ID
* @param date 日期
* @return 可预约的餐段列表
*/
List<APPBXAvaliabilityRespVO> getAvailableMeals(Long boxesId, LocalDate date);
}
@@ -10,28 +10,26 @@ import java.time.LocalDate;
public interface BoxesInfoService extends IService<BoxesInfoEntity> {
/**
* 分页查询当前商户的包厢数据
* @param page
* @param wrapper
* @return
* @param page 分页对象
* @param wrapper 查询条件
* @return 分页结果
*/
Object pageScope(Page page, LambdaQueryWrapper<BoxesInfoEntity> wrapper);
/**
* 新增包厢
* @param boxesInfo
* @return
* @param boxesInfo 包厢信息
* @return 包厢ID
*/
Object saveInfo(BoxesInfoEntity boxesInfo);
/**
* 根据日期动态获取包厢可预约时间信息
* @param id
* @param date
* @return
* @param id 包厢ID
* @param date 日期
* @return 包厢详情和可用时间段
*/
AppBXDetailRespVO getAppBXDetailRespVO(Long id, LocalDate date);
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.canteen.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.canteen.entity.TimeSlotConfigEntity;
public interface TimeSlotConfigService extends IService<TimeSlotConfigEntity> {
}
@@ -1,16 +1,95 @@
package com.bsd.pjcloud.canteen.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.canteen.entity.BoxesAvailabilityEntity;
import com.bsd.pjcloud.canteen.entity.BoxesInfoEntity;
import com.bsd.pjcloud.canteen.entity.BoxesBookingEntity;
import com.bsd.pjcloud.canteen.mapper.BoxesAvailabilityMapper;
import com.bsd.pjcloud.canteen.mapper.BoxesInfoMapper;
import com.bsd.pjcloud.canteen.mapper.BoxesBookingMapper;
import com.bsd.pjcloud.canteen.service.BoxesAvailabilityService;
import com.bsd.pjcloud.canteen.vo.APPBXAvaliabilityRespVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 包厢可用时间段
*
* @author zjf
* @date 2024-12-17 13:59:31
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class BoxesAvailabilityServiceImpl extends ServiceImpl<BoxesAvailabilityMapper, BoxesAvailabilityEntity> implements BoxesAvailabilityService {
private final BoxesInfoMapper boxesInfoMapper;
private final BoxesBookingMapper boxesBookingMapper;
@Override
public List<APPBXAvaliabilityRespVO> getAvailableMeals(Long boxesId, LocalDate date) {
// 1. 首先检查餐桌是否存在
BoxesInfoEntity boxesInfo = boxesInfoMapper.selectById(boxesId);
if (boxesInfo == null) {
log.warn("餐桌不存在,boxesId: {}, date: {}", boxesId, date);
return new ArrayList<>(); // 返回空列表,表示餐桌不存在
}
// 2. 定义三个餐次类型
List<Integer> mealTypes = List.of(1, 2, 3); // 1-早餐, 2-中餐, 3-晚餐
List<String> mealNames = List.of("早餐", "中餐", "晚餐");
// 3. 查询指定包厢在指定日期的所有预约记录
LambdaQueryWrapper<BoxesBookingEntity> bookingWrapper = Wrappers.lambdaQuery();
bookingWrapper.eq(BoxesBookingEntity::getBoxesId, boxesId);
bookingWrapper.eq(BoxesBookingEntity::getBookingDate, date);
List<BoxesBookingEntity> existingBookings = boxesBookingMapper.selectList(bookingWrapper);
// 4. 获取已被预约的餐次类型
List<Integer> bookedMealTypes = existingBookings.stream()
.map(BoxesBookingEntity::getMealType)
.collect(Collectors.toList());
// 5. 构建可预约餐段列表
List<APPBXAvaliabilityRespVO> availableMeals = new ArrayList<>();
for (int i = 0; i < mealTypes.size(); i++) {
Integer mealType = mealTypes.get(i);
String mealName = mealNames.get(i);
APPBXAvaliabilityRespVO meal = new APPBXAvaliabilityRespVO();
meal.setBoxesId(boxesId);
meal.setBxDate(date);
meal.setMealType(mealType);
meal.setMealName(mealName);
// 如果该餐次已被预约,状态设为1(已预约),否则设为0(可预约)
if (bookedMealTypes.contains(mealType)) {
meal.setStatus(1); // 已预约
// 找到对应的预约记录,填充预约信息
BoxesBookingEntity booking = existingBookings.stream()
.filter(b -> b.getMealType().equals(mealType))
.findFirst()
.orElse(null);
if (booking != null) {
meal.setBookingId(booking.getId());
meal.setUserId(booking.getUserId());
}
} else {
meal.setStatus(0); // 可预约
}
availableMeals.add(meal);
}
return availableMeals;
}
}
@@ -1,37 +1,35 @@
package com.bsd.pjcloud.canteen.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.canteen.constant.CanteenFlowConstant;
import com.bsd.pjcloud.canteen.dto.boxes.admin.BokingPageDTO;
import com.bsd.pjcloud.canteen.dto.flow.BxMarkingFlowDto;
import com.bsd.pjcloud.canteen.entity.BoxesBookingEntity;
import com.bsd.pjcloud.canteen.entity.BoxesInfoEntity;
import com.bsd.pjcloud.canteen.mapper.BoxesAvailabilityMapper;
import com.bsd.pjcloud.canteen.mapper.BoxesBookingMapper;
import com.bsd.pjcloud.canteen.entity.BoxesBookingEntity;
import com.bsd.pjcloud.canteen.entity.BoxesAvailabilityEntity;
import com.bsd.pjcloud.canteen.mapper.BoxesInfoMapper;
import com.bsd.pjcloud.canteen.mapper.BoxesBookingMapper;
import com.bsd.pjcloud.canteen.service.BoxesAvailabilityService;
import com.bsd.pjcloud.canteen.service.BoxesBookingService;
import com.bsd.pjcloud.canteen.vo.AppMakeSaveReqVO;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.resolver.ParamResolver;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.flow.task.api.feign.RemoteFlowApiFlowService;
import com.bsd.pjcloud.flow.task.dto.ProcessInstanceParamDto;
import com.bsd.pjcloud.flow.task.entity.Process;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.beans.beancontext.BeanContext;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
@@ -45,6 +43,7 @@ import java.util.stream.Collectors;
* @author zjf
* @date 2024-12-16 22:39:45
*/
@Slf4j
@Service
@AllArgsConstructor
public class BoxesBookingServiceImpl extends ServiceImpl<BoxesBookingMapper, BoxesBookingEntity> implements BoxesBookingService {
@@ -53,57 +52,12 @@ public class BoxesBookingServiceImpl extends ServiceImpl<BoxesBookingMapper, Box
private final BoxesBookingMapper bookingMapper;
private final BoxesAvailabilityMapper bookingAvailabilityMapper;
private final RemoteUserService remoteUserService;
private final RemoteFlowApiFlowService remoteFlowApiFlowService;
private final RemoteUserService remoteUserService ;
private final BoxesAvailabilityService boxesAvailabilityService;
@Override
public R createBooking(AppMakeSaveReqVO createReqVO) {
BoxesInfoEntity infoDO = boxesInfoMapper.selectById(createReqVO.getBoxesId());
if (infoDO == null) {
return R.failed("包厢不存在");
}
// 验证预约的时间段是否已有预约
int useCount=bookingAvailabilityMapper.isMakeTime(createReqVO.getBxDate(), createReqVO.getStartTime(), createReqVO.getEndTime());
if (useCount > 0) {
return R.failed("当前时间段已被他人预约使用");
}
//把预定的这部分可用时间改为占用状态
bookingAvailabilityMapper.updateStatusByStartTimeAndEndTimeAndBxDate(createReqVO);
//插入预约记录表
Long loginUserId = SecurityUtils.getUser().getId();
BoxesBookingEntity booking = BeanUtils.toBean(createReqVO, BoxesBookingEntity.class);
booking.setUserId(loginUserId);
booking.setBookingDate(LocalDate.parse(createReqVO.getBxDate()));
booking.setDeptId(infoDO.getDeptId());
// 工作
ProcessInstanceParamDto processInstanceParamDto = new ProcessInstanceParamDto();
R<Process> processByBusinessKey = remoteFlowApiFlowService.getProcessByBusinessKey(CanteenFlowConstant.bx_marking_flow);
String flowId = processByBusinessKey.getData().getFlowId();
processInstanceParamDto.setFlowId(flowId);
BxMarkingFlowDto bxMarkingFlowDto = new BxMarkingFlowDto();
bxMarkingFlowDto.setBoxesName(infoDO.getName());
bxMarkingFlowDto.setMarkTime(createReqVO.getBxDate() + " " + createReqVO.getStartTime() + "-" + createReqVO.getEndTime());
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(bxMarkingFlowDto);
processInstanceParamDto.setParamMap(stringObjectMap);
R<String> stringR = remoteFlowApiFlowService.startProcessInstance(processInstanceParamDto);
booking.setCheckStatus("0");
booking.setProcessInstanceId(stringR.getData());
bookingMapper.insert(booking);
// 返回
return R.ok();
}
@Override
public Object pageScope(Page page, BokingPageDTO bokingPageDTO) {
public IPage<BoxesBookingEntity> pageScope(Page page, BokingPageDTO bokingPageDTO) {
LambdaQueryWrapper<BoxesBookingEntity> wrapper = Wrappers.lambdaQuery();
String mobile = bokingPageDTO.getMobile();
String userName = bokingPageDTO.getUserName();
@@ -149,4 +103,90 @@ public class BoxesBookingServiceImpl extends ServiceImpl<BoxesBookingMapper, Box
}
return pageData;
}
@Override
@Transactional
public R<Long> createBooking(AppMakeSaveReqVO createReqVO) {
try {
// 1. 验证预约参数
if (ObjectUtil.isNull(createReqVO.getBoxesId()) ||
ObjectUtil.isNull(createReqVO.getBxDate()) ||
ObjectUtil.isNull(createReqVO.getMealType()) ||
ObjectUtil.isNull(createReqVO.getPeopleCount())) {
return R.failed("预约参数不完整");
}
// 2. 检查是否已经预约
LocalDate bookingDate = LocalDate.parse(createReqVO.getBxDate());
LambdaQueryWrapper<BoxesAvailabilityEntity> availabilityWrapper = Wrappers.lambdaQuery();
availabilityWrapper.eq(BoxesAvailabilityEntity::getBoxesId, createReqVO.getBoxesId());
availabilityWrapper.eq(BoxesAvailabilityEntity::getBxDate, bookingDate);
availabilityWrapper.eq(BoxesAvailabilityEntity::getMealType, createReqVO.getMealType());
availabilityWrapper.eq(BoxesAvailabilityEntity::getStatus, 0); // 0-空闲
BoxesAvailabilityEntity availability = boxesAvailabilityService.getOne(availabilityWrapper);
if (ObjectUtil.isNull(availability)) {
// 如果没有可用时间段,创建一个新的
availability = createAvailabilityTimeSlot(createReqVO.getBoxesId(), bookingDate, createReqVO.getMealType());
}
if (availability.getStatus() != 0) {
return R.failed("该时间段已被预约");
}
// 3. 创建预约记录
BoxesBookingEntity booking = new BoxesBookingEntity();
booking.setBoxesId(createReqVO.getBoxesId());
booking.setBookingDate(bookingDate);
booking.setMealType(createReqVO.getMealType());
booking.setPeopleCount(createReqVO.getPeopleCount());
booking.setRemark(createReqVO.getRemark());
booking.setUserId(SecurityUtils.getUser().getId());
booking.setStatus(0); // 0-预约成功
booking.setDeptId(SecurityUtils.getUser().getDeptId());
// 4. 保存预约记录
this.save(booking);
// 5. 更新可用时间段状态
availability.setStatus(1); // 1-已使用
availability.setBookingId(booking.getId());
availability.setUserId(booking.getUserId());
boxesAvailabilityService.updateById(availability);
return R.ok(booking.getId());
} catch (Exception e) {
log.error("创建预约失败", e);
return R.failed("创建预约失败:" + e.getMessage());
}
}
/**
* 创建可用时间段
*/
private BoxesAvailabilityEntity createAvailabilityTimeSlot(Long boxesId, LocalDate date, Integer mealType) {
BoxesAvailabilityEntity availability = new BoxesAvailabilityEntity();
availability.setBoxesId(boxesId);
availability.setBxDate(date);
availability.setMealType(mealType);
availability.setStatus(0); // 空闲
// 根据餐次类型设置餐次名称
switch (mealType) {
case 1:
availability.setMealName("早餐");
break;
case 2:
availability.setMealName("中餐");
break;
case 3:
availability.setMealName("晚餐");
break;
default:
availability.setMealName("未知餐次");
}
boxesAvailabilityService.save(availability);
return availability;
}
}
@@ -1,6 +1,9 @@
package com.bsd.pjcloud.canteen.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.canteen.entity.BoxesAvailabilityEntity;
@@ -8,15 +11,15 @@ import com.bsd.pjcloud.canteen.entity.BoxesInfoEntity;
import com.bsd.pjcloud.canteen.mapper.BoxesInfoMapper;
import com.bsd.pjcloud.canteen.service.BoxesAvailabilityService;
import com.bsd.pjcloud.canteen.service.BoxesInfoService;
import com.bsd.pjcloud.canteen.vo.APPBXAvaliabilityRespVO;
import com.bsd.pjcloud.canteen.vo.AppBXDetailRespVO;
import com.bsd.pjcloud.canteen.vo.APPBXAvaliabilityRespVO;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
@@ -26,53 +29,44 @@ import java.util.List;
* @author zjf
* @date 2024-12-16 21:13:58
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class BoxesInfoServiceImpl extends ServiceImpl<BoxesInfoMapper, BoxesInfoEntity> implements BoxesInfoService {
private final BoxesAvailabilityService boxesAvailabilityService;
@Override
public Object pageScope(Page page, LambdaQueryWrapper<BoxesInfoEntity> wrapper) {
return baseMapper.selectPageByScope(page,wrapper, DataScope.of());
return baseMapper.selectPageByScope(page, wrapper, DataScope.of());
}
@Override
public Object saveInfo(BoxesInfoEntity boxesInfo) {
// 直接保存包厢信息,不自动生成时间段数据
baseMapper.insert(boxesInfo);
//批量插入未来15天可用时间段
List<BoxesAvailabilityEntity> availabilityList = new ArrayList<>();
LocalDate today = LocalDate.now();
int daysToGenerate = 15;
for (int i = 0; i < daysToGenerate; i++) {
LocalDate date = today.plusDays(i);
for (int hour = 0; hour < 24; hour++) {
BoxesAvailabilityEntity availability = new BoxesAvailabilityEntity();
availability.setBoxesId(boxesInfo.getId());
availability.setBxDate(date);
availability.setHour(LocalTime.of(hour, 0));
availability.setHourIndex(hour);
availabilityList.add(availability);
}
}
// 批量插入数据
boxesAvailabilityService.saveBatch(availabilityList);
// 返回
return boxesInfo.getId();
}
@Override
public AppBXDetailRespVO getAppBXDetailRespVO(Long id, LocalDate date) {
BoxesInfoEntity infoDO = baseMapper.selectById(id);
// AppBXDetailRespVO appBXDetailRespVO = new AppBXDetailRespVO();
AppBXDetailRespVO bean = BeanUtils.toBean(infoDO, AppBXDetailRespVO.class);
// 查询指定日期的可用时间段
LambdaQueryWrapper<BoxesAvailabilityEntity> availabilityDOLambdaQueryWrapper = new LambdaQueryWrapper<>();
availabilityDOLambdaQueryWrapper.eq(BoxesAvailabilityEntity::getBxDate,date);
availabilityDOLambdaQueryWrapper.eq(BoxesAvailabilityEntity::getBoxesId,id);
availabilityDOLambdaQueryWrapper.eq(BoxesAvailabilityEntity::getBxDate, date);
availabilityDOLambdaQueryWrapper.eq(BoxesAvailabilityEntity::getBoxesId, id);
List<BoxesAvailabilityEntity> availabilityDOS = boxesAvailabilityService.list(availabilityDOLambdaQueryWrapper);
List<APPBXAvaliabilityRespVO> availabilityDOListBean = BeanUtils.toBean(availabilityDOS, APPBXAvaliabilityRespVO.class);
bean.setAvaliabilityRespList(availabilityDOListBean);
// 如果没有时间段数据,返回空列表
if (availabilityDOS.isEmpty()) {
bean.setAvaliabilityRespList(new ArrayList<>());
} else {
List<APPBXAvaliabilityRespVO> availabilityDOListBean = BeanUtils.toBean(availabilityDOS, APPBXAvaliabilityRespVO.class);
bean.setAvaliabilityRespList(availabilityDOListBean);
}
return bean;
}
}
@@ -0,0 +1,16 @@
package com.bsd.pjcloud.canteen.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.canteen.entity.TimeSlotConfigEntity;
import com.bsd.pjcloud.canteen.mapper.TimeSlotConfigMapper;
import com.bsd.pjcloud.canteen.service.TimeSlotConfigService;
import org.springframework.stereotype.Service;
/**
* 时间段配置表
*
* @author pjcloud
* @date 2025-08-13 12:17:22
*/
@Service
public class TimeSlotConfigServiceImpl extends ServiceImpl<TimeSlotConfigMapper, TimeSlotConfigEntity> implements TimeSlotConfigService {
}
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bsd.pjcloud.canteen.mapper.TimeSlotConfigMapper">
<resultMap id="timeSlotConfigMap" type="com.bsd.pjcloud.canteen.entity.TimeSlotConfigEntity">
<id property="id" column="id"/>
<result property="mealType" column="meal_type"/>
<result property="mealName" column="meal_name"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="timeSlotName" column="time_slot_name"/>
<result property="isEnabled" column="is_enabled"/>
<result property="sort" column="sort"/>
<result property="remark" column="remark"/>
<result property="deptId" column="dept_id"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
</mapper>
@@ -0,0 +1,65 @@
-- 餐桌预定系统数据库建表脚本(基于现有包厢表结构修改)
-- 1. 修改现有包厢信息表,添加餐桌相关字段
ALTER TABLE `boxes_info`
ADD COLUMN `table_number` varchar(50) DEFAULT NULL COMMENT '餐桌编号' AFTER `name`,
ADD COLUMN `table_type` int DEFAULT NULL COMMENT '餐桌类型 1-小桌(2-4人) 2-中桌(4-6人) 3-大桌(6-8人) 4-包间(8人以上)' AFTER `status`,
ADD UNIQUE KEY `uk_table_number` (`table_number`);
-- 2. 修改现有包厢可用时间段表,添加餐次类型字段
ALTER TABLE `boxes_availability`
ADD COLUMN `meal_type` int DEFAULT NULL COMMENT '餐次类型 1-早餐 2-中餐 3-晚餐' AFTER `bx_date`,
ADD COLUMN `meal_name` varchar(50) DEFAULT NULL COMMENT '餐次名称' AFTER `meal_type`,
ADD KEY `idx_meal_type` (`meal_type`);
-- 3. 修改现有包厢预约记录表,添加餐次类型和预约人数字段
ALTER TABLE `boxes_booking`
ADD COLUMN `meal_type` int DEFAULT NULL COMMENT '餐次类型 1-早餐 2-中餐 3-晚餐' AFTER `status`,
ADD COLUMN `people_count` int DEFAULT NULL COMMENT '预约人数' AFTER `meal_type`,
ADD COLUMN `remark` varchar(500) DEFAULT NULL COMMENT '备注信息' AFTER `people_count`,
ADD KEY `idx_meal_type` (`meal_type`);
-- 4. 创建时间段配置表(新增)
CREATE TABLE `time_slot_config` (
`id` bigint NOT NULL COMMENT '主键id',
`meal_type` int NOT NULL COMMENT '餐次类型 1-早餐 2-中餐 3-晚餐',
`meal_name` varchar(50) NOT NULL COMMENT '餐次名称',
`start_time` time NOT NULL COMMENT '开始时间',
`end_time` time NOT NULL COMMENT '结束时间',
`time_slot_name` varchar(100) DEFAULT NULL COMMENT '时间段名称',
`is_enabled` int NOT NULL DEFAULT '1' COMMENT '是否启用 0-禁用 1-启用',
`sort` int DEFAULT '0' COMMENT '排序',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`dept_id` bigint DEFAULT NULL COMMENT '部门id',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) DEFAULT '0' COMMENT '是否删除',
PRIMARY KEY (`id`),
KEY `idx_meal_type` (`meal_type`),
KEY `idx_is_enabled` (`is_enabled`)
) COMMENT='时间段配置表';
-- 插入默认时间段配置数据
INSERT INTO `time_slot_config` (`id`, `meal_type`, `meal_name`, `start_time`, `end_time`, `time_slot_name`, `is_enabled`, `sort`, `remark`, `create_time`) VALUES
(1, 1, '早餐', '07:00:00', '09:00:00', '早餐时段', 1, 1, '早餐时间段', NOW()),
(2, 2, '中餐', '11:30:00', '13:30:00', '中餐时段', 1, 2, '中餐时间段', NOW()),
(3, 3, '晚餐', '17:30:00', '19:30:00', '晚餐时段', 1, 3, '晚餐时间段', NOW());
-- 更新现有包厢信息为餐桌信息(示例)
UPDATE `boxes_info` SET
`name` = CONCAT('餐桌', `name`),
`table_number` = CONCAT('T', LPAD(id, 3, '0')),
`table_type` = CASE
WHEN `capacity` <= 4 THEN 1
WHEN `capacity` <= 6 THEN 2
WHEN `capacity` <= 8 THEN 3
ELSE 4
END
WHERE `table_number` IS NULL;
-- 更新表注释
ALTER TABLE `boxes_info` COMMENT = '餐桌信息表';
ALTER TABLE `boxes_availability` COMMENT = '餐桌可用时间段表';
ALTER TABLE `boxes_booking` COMMENT = '餐桌预约记录表';