diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/APPBXAvaliabilityRespVO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/APPBXAvaliabilityRespVO.java new file mode 100644 index 000000000..d427c6124 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/APPBXAvaliabilityRespVO.java @@ -0,0 +1,52 @@ +package com.bsd.pjcloud.canteen.vo; + + +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalTime; + + +@Data +public class APPBXAvaliabilityRespVO { + + /** + * 主键id + */ + @TableId + private Long 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; + /** + * 时间 + */ + @JsonFormat(pattern = "HH:mm") + private LocalTime hour; + /** + * 时间索引(0-24) + */ + private Integer hourIndex; + +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/APPBookingInfo.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/APPBookingInfo.java new file mode 100644 index 000000000..55a65c36e --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/APPBookingInfo.java @@ -0,0 +1,73 @@ +package com.bsd.pjcloud.canteen.vo; + + +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; + + +@Data +@Schema(description = "点餐APP - 我的预约包厢记录") +public class APPBookingInfo { + + @Schema(description = "主键id") + @ExcelProperty("主键id") + private Long id; + + @Schema(description = "包厢Id") + @ExcelProperty("包厢Id") + @JsonIgnore + private Long boxesId; + + @Schema(description = "包厢名称", example = "测试包厢") + private String boxesName; + + @Schema(description = "开始时间") + @ExcelProperty("开始时间") + @JsonFormat(pattern = "HH:mm") + private LocalDateTime startTime; + + @Schema(description = "结束时间") + @ExcelProperty("结束时间") + @JsonFormat(pattern = "HH:mm") + private LocalDateTime endTime; + + @Schema(description = "审核人id", example = "16958") + @ExcelProperty("审核人id") + private Long checkUserId; + + @Schema(description = "1审核中 2通过 3驳回", example = "1") + private String checkStatus; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "预约日期", requiredMode = Schema.RequiredMode.REQUIRED) + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate bookingDate; + + @Schema(description = "userId", example = "33") + @JsonIgnore + private Long userId; + + @Schema(description = "用户昵称", example = "3399") + @ExcelProperty("用户昵称") + private String nickName; + + @Schema(description = "手机号", example = "3399") + private String mobile; + + @Schema(description = "总价单位分", example = "23172") + @ExcelProperty("总价单位分") + private Integer totalPrice; + + @Schema(description = "预约状态(0 预约成功,1预约失败 2取消预约 )", example = "2") + private Integer status; + +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppBXDetailRespVO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppBXDetailRespVO.java new file mode 100644 index 000000000..a4252c237 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppBXDetailRespVO.java @@ -0,0 +1,20 @@ +package com.bsd.pjcloud.canteen.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Schema(description = "点餐APP- 包厢详情 Request VO") +@Data +public class AppBXDetailRespVO { + + + @Schema(description = "包厢状态") + private Short status; + + + @Schema(description = "包厢所有时间表") + private List avaliabilityRespList; + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppBXInfoRespVO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppBXInfoRespVO.java new file mode 100644 index 000000000..96ed98cbc --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppBXInfoRespVO.java @@ -0,0 +1,33 @@ +package com.bsd.pjcloud.canteen.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "点餐APP- 包厢详情 Request VO") +@Data +public class AppBXInfoRespVO { + + @Schema(description = "包厢Id") + private Long id; + + @Schema(description = "包厢名称") + private String name; + + @Schema(description = "容纳人数") + private Long capacity; + + @Schema(description = "包厢描述") + private String description; + + + @Schema(description = "包厢地址") + private String address; + + @Schema(description = "包厢背景图") + private String images; + + @Schema(description = "包厢价格/每小时") + private String price; + + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppBoxesInfoVO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppBoxesInfoVO.java new file mode 100644 index 000000000..75d2a972b --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppBoxesInfoVO.java @@ -0,0 +1,53 @@ +package com.bsd.pjcloud.canteen.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + + +@Schema(description = "点餐APP- 包厢信息 Response VO") +@Data +public class AppBoxesInfoVO { + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("主键id") + private Long id; + + @Schema(description = "包厢名称") + @ExcelProperty("包厢名称") + private String name; + + @Schema(description = "容纳人数") + @ExcelProperty("容纳人数") + private Long capacity; + + @Schema(description = "包厢状态") + private Integer status; + + @Schema(description = "包厢地址") + @ExcelProperty("包厢地址") + private String address; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "包厢背景图") + @ExcelProperty("包厢背景图") + private String images; + + @Schema(description = "包厢价格") + @ExcelProperty("包厢价格") + private String price; + + /** + * 包厢描述 + */ + private String description; + + /** + * 商户id + */ + private Long merchantId; +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppMakeSaveReqVO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppMakeSaveReqVO.java new file mode 100644 index 000000000..852948de3 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/AppMakeSaveReqVO.java @@ -0,0 +1,27 @@ +package com.bsd.pjcloud.canteen.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + + +@Schema(description = "点餐APP- 用户发起预约 Request VO") +@Data +public class AppMakeSaveReqVO { + + @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) + @JsonFormat(pattern = "yyyy-MM-dd") + private String bxDate; +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/pom.xml b/pjcloud-canteen/pjcloud-canteen-biz/pom.xml index 29a39d3df..7191c226c 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/pom.xml +++ b/pjcloud-canteen/pjcloud-canteen-biz/pom.xml @@ -13,6 +13,11 @@ pjcloud-canteen-biz + + + com.bsd + pjcloud-common-job + org.springframework.boot diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/CanteenApp.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/CanteenApp.java index 21b8f1775..4a24bed48 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/CanteenApp.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/CanteenApp.java @@ -1,6 +1,7 @@ package com.bsd.pjcloud.canteen; import com.bsd.pjcloud.common.feign.annotation.EnablePjcloudFeignClients; +import com.bsd.pjcloud.common.job.annotation.EnablePjcloudXxlJob; import com.bsd.pjcloud.common.security.annotation.EnablePjcloudResourceServer; import com.bsd.pjcloud.common.swagger.annotation.EnableOpenApi; import org.springframework.boot.SpringApplication; @@ -17,6 +18,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @EnableDiscoveryClient @EnablePjcloudResourceServer @SpringBootApplication +@EnablePjcloudXxlJob public class CanteenApp { public static void main(String[] args) { SpringApplication.run(CanteenApp.class, args); diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/BoxesAvailabilityController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/BoxesAvailabilityController.java new file mode 100644 index 000000000..359c167ef --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/BoxesAvailabilityController.java @@ -0,0 +1,121 @@ +package com.bsd.pjcloud.canteen.controller; + +import cn.hutool.core.util.StrUtil; +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.BoxesAvailabilityEntity; +import com.bsd.pjcloud.canteen.service.BoxesAvailabilityService; +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("/boxesAvailability" ) +@Tag(description = "boxesAvailability" , name = "包厢可用时间段管理" ) +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class BoxesAvailabilityController { + + private final BoxesAvailabilityService boxesAvailabilityService; + + /** + * 分页查询 + * @param page 分页对象 + * @param boxesAvailability 包厢可用时间段 + * @return + */ + @Operation(summary = "分页查询" , description = "分页查询" ) + @GetMapping("/page" ) + @PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_view')" ) + public R getBoxesAvailabilityPage(@ParameterObject Page page, @ParameterObject BoxesAvailabilityEntity boxesAvailability) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(Objects.nonNull(boxesAvailability.getStatus()),BoxesAvailabilityEntity::getStatus,boxesAvailability.getStatus()); + return R.ok(boxesAvailabilityService.page(page, wrapper)); + } + + + /** + * 通过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) { + return R.ok(boxesAvailabilityService.getById(id)); + } + + /** + * 新增包厢可用时间段 + * @param boxesAvailability 包厢可用时间段 + * @return R + */ + @Operation(summary = "新增包厢可用时间段" , description = "新增包厢可用时间段" ) + @SysLog("新增包厢可用时间段" ) + @PostMapping + @PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_add')" ) + public R save(@RequestBody BoxesAvailabilityEntity boxesAvailability) { + return R.ok(boxesAvailabilityService.save(boxesAvailability)); + } + + /** + * 修改包厢可用时间段 + * @param boxesAvailability 包厢可用时间段 + * @return R + */ + @Operation(summary = "修改包厢可用时间段" , description = "修改包厢可用时间段" ) + @SysLog("修改包厢可用时间段" ) + @PutMapping + @PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_edit')" ) + public R updateById(@RequestBody BoxesAvailabilityEntity boxesAvailability) { + return R.ok(boxesAvailabilityService.updateById(boxesAvailability)); + } + + /** + * 通过id删除包厢可用时间段 + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除包厢可用时间段" , description = "通过id删除包厢可用时间段" ) + @SysLog("通过id删除包厢可用时间段" ) + @DeleteMapping + @PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_del')" ) + public R removeById(@RequestBody Long[] ids) { + return R.ok(boxesAvailabilityService.removeBatchByIds(CollUtil.toList(ids))); + } + + + /** + * 导出excel 表格 + * @param boxesAvailability 查询条件 + * @param ids 导出指定ID + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('canteen_boxesAvailability_export')" ) + public List export(BoxesAvailabilityEntity boxesAvailability,Long[] ids) { + return boxesAvailabilityService.list(Wrappers.lambdaQuery(boxesAvailability).in(ArrayUtil.isNotEmpty(ids), BoxesAvailabilityEntity::getId, ids)); + } +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/BoxesBookingController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/BoxesBookingController.java index a59e6b27c..fe1893801 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/BoxesBookingController.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/BoxesBookingController.java @@ -1,15 +1,19 @@ package com.bsd.pjcloud.canteen.controller; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; 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.canteen.vo.APPBookingInfo; +import com.bsd.pjcloud.canteen.vo.AppMakeSaveReqVO; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.log.annotation.SysLog; import com.bsd.pjcloud.canteen.entity.BoxesBookingEntity; import com.bsd.pjcloud.canteen.service.BoxesBookingService; +import org.springframework.beans.BeanUtils; import org.springframework.security.access.prepost.PreAuthorize; import com.bsd.pjcloud.common.excel.annotation.ResponseExcel; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -119,4 +123,48 @@ public class BoxesBookingController { public List export(BoxesBookingEntity boxesBooking,Long[] ids) { return boxesBookingService.list(Wrappers.lambdaQuery(boxesBooking).in(ArrayUtil.isNotEmpty(ids), BoxesBookingEntity::getId, ids)); } + + + @PostMapping("/create") + @Operation(summary = "新增预约") + public R createBooking(@RequestBody AppMakeSaveReqVO createReqVO) { + return boxesBookingService.createBooking(createReqVO); + + } + + +//-------------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 bookingPage = bookingService.getBookingPage(bookingPageReqVO); +// PageResult bean = BeanUtils.toBean(bookingPage, APPBookingInfo.class); +// if (ObjectUtil.isEmpty(bookingPage.getList())) return success(bean); +// +// List collectUserIdS = bookingPage.getList().stream().map(BookingDO::getUserId).collect(Collectors.toList()); +// List collectBoxesIdS = bookingPage.getList().stream().map(BookingDO::getBoxesId).collect(Collectors.toList()); +// Map userMap = adminUserApi.getUserMap(collectUserIdS); +// Map 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 createBooking(@RequestParam("id") Long bookId) { +// Long id = bookingService.cancelBooking(bookId); +// return success(id); +// } } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/BoxesInfoController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/BoxesInfoController.java index 85db428a4..45a95b088 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/BoxesInfoController.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/BoxesInfoController.java @@ -1,16 +1,22 @@ package com.bsd.pjcloud.canteen.controller; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; 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.canteen.service.BoxesBookingService; +import com.bsd.pjcloud.canteen.vo.*; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.log.annotation.SysLog; import com.bsd.pjcloud.canteen.entity.BoxesInfoEntity; import com.bsd.pjcloud.canteen.service.BoxesInfoService; import com.bsd.pjcloud.common.security.util.SecurityUtils; +import io.swagger.v3.oas.annotations.Parameter; +import org.springframework.beans.BeanUtils; +import org.springframework.format.annotation.DateTimeFormat; import org.springframework.security.access.prepost.PreAuthorize; import com.bsd.pjcloud.common.excel.annotation.ResponseExcel; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -21,6 +27,8 @@ import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import java.time.LocalDate; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -39,6 +47,8 @@ public class BoxesInfoController { private final BoxesInfoService boxesInfoService; + private final BoxesBookingService bookingService; + /** * 分页查询 * @param page 分页对象 @@ -78,7 +88,7 @@ public class BoxesInfoController { @PreAuthorize("@pms.hasPermission('canteen_boxesInfo_add')" ) public R save(@RequestBody BoxesInfoEntity boxesInfo) { boxesInfo.setDeptId(SecurityUtils.getUser().getDeptId()); - return R.ok(boxesInfoService.save(boxesInfo)); + return R.ok(boxesInfoService.saveInfo(boxesInfo)); } /** @@ -120,4 +130,41 @@ public class BoxesInfoController { public List export(BoxesInfoEntity boxesInfo,Long[] ids) { return boxesInfoService.list(Wrappers.lambdaQuery(boxesInfo).in(ArrayUtil.isNotEmpty(ids), BoxesInfoEntity::getId, ids)); } + + +// --------------------移动端接口--------------------------- + @GetMapping("/getInfo") + @Operation(summary = "获得包厢固定的基础信息") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + public R getInfo(@RequestParam("id") Long id) { + BoxesInfoEntity byId = boxesInfoService.getById(id); + AppBXInfoRespVO appBXInfoRespVO = new AppBXInfoRespVO(); + BeanUtils.copyProperties(byId,appBXInfoRespVO); + return R.ok(appBXInfoRespVO); + } + + @GetMapping("/get") + @Operation(summary = "根据日期动态获取包厢可预约时间信息") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + public R getInfoAvailability(@RequestParam("id") Long id, + @DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam("currentDate") LocalDate date) { + AppBXDetailRespVO info = boxesInfoService.getAppBXDetailRespVO(id, date); + return R.ok(info); + } + + @GetMapping("/appPage") + @Operation(summary = "获得包厢信息分页") + public R getInfoPage(@ParameterObject Page page,@ParameterObject BoxesInfoEntity boxesInfo) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(StrUtil.isNotBlank(boxesInfo.getName()),BoxesInfoEntity::getName,boxesInfo.getName()); + Page pageResult = boxesInfo.selectPage(page, wrapper); + List appInfoRespVOS = new ArrayList<>(); + pageResult.getRecords().forEach(x->{ + AppBoxesInfoVO appBoxesInfoVO = com.bsd.pjcloud.common.core.util.BeanUtils.toBean(x, AppBoxesInfoVO.class); + appInfoRespVOS.add(appBoxesInfoVO); + }); + pageResult.setRecords(appInfoRespVOS); + return R.ok(pageResult); + } + } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenOnlineCategoryController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenOnlineCategoryController.java new file mode 100644 index 000000000..b09d120e6 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenOnlineCategoryController.java @@ -0,0 +1,121 @@ +package com.bsd.pjcloud.canteen.controller; + +import cn.hutool.core.util.StrUtil; +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.CanteenOnlineCategoryEntity; +import com.bsd.pjcloud.canteen.service.CanteenOnlineCategoryService; +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:03:14 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/canteenOnlineCategory" ) +@Tag(description = "canteenOnlineCategory" , name = "在线点餐分类管理" ) +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class CanteenOnlineCategoryController { + + private final CanteenOnlineCategoryService canteenOnlineCategoryService; + + /** + * 分页查询 + * @param page 分页对象 + * @param canteenOnlineCategory 在线点餐分类 + * @return + */ + @Operation(summary = "分页查询" , description = "分页查询" ) + @GetMapping("/page" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineCategory_view')" ) + public R getCanteenOnlineCategoryPage(@ParameterObject Page page, @ParameterObject CanteenOnlineCategoryEntity canteenOnlineCategory) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.like(StrUtil.isNotBlank(canteenOnlineCategory.getName()),CanteenOnlineCategoryEntity::getName,canteenOnlineCategory.getName()); + return R.ok(canteenOnlineCategoryService.page(page, wrapper)); + } + + + /** + * 通过id查询在线点餐分类 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询" , description = "通过id查询" ) + @GetMapping("/{id}" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineCategory_view')" ) + public R getById(@PathVariable("id" ) Long id) { + return R.ok(canteenOnlineCategoryService.getById(id)); + } + + /** + * 新增在线点餐分类 + * @param canteenOnlineCategory 在线点餐分类 + * @return R + */ + @Operation(summary = "新增在线点餐分类" , description = "新增在线点餐分类" ) + @SysLog("新增在线点餐分类" ) + @PostMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineCategory_add')" ) + public R save(@RequestBody CanteenOnlineCategoryEntity canteenOnlineCategory) { + return R.ok(canteenOnlineCategoryService.save(canteenOnlineCategory)); + } + + /** + * 修改在线点餐分类 + * @param canteenOnlineCategory 在线点餐分类 + * @return R + */ + @Operation(summary = "修改在线点餐分类" , description = "修改在线点餐分类" ) + @SysLog("修改在线点餐分类" ) + @PutMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineCategory_edit')" ) + public R updateById(@RequestBody CanteenOnlineCategoryEntity canteenOnlineCategory) { + return R.ok(canteenOnlineCategoryService.updateById(canteenOnlineCategory)); + } + + /** + * 通过id删除在线点餐分类 + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除在线点餐分类" , description = "通过id删除在线点餐分类" ) + @SysLog("通过id删除在线点餐分类" ) + @DeleteMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineCategory_del')" ) + public R removeById(@RequestBody Long[] ids) { + return R.ok(canteenOnlineCategoryService.removeBatchByIds(CollUtil.toList(ids))); + } + + + /** + * 导出excel 表格 + * @param canteenOnlineCategory 查询条件 + * @param ids 导出指定ID + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineCategory_export')" ) + public List export(CanteenOnlineCategoryEntity canteenOnlineCategory,Long[] ids) { + return canteenOnlineCategoryService.list(Wrappers.lambdaQuery(canteenOnlineCategory).in(ArrayUtil.isNotEmpty(ids), CanteenOnlineCategoryEntity::getId, ids)); + } +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenOnlineSpuController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenOnlineSpuController.java new file mode 100644 index 000000000..6ea00f74f --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenOnlineSpuController.java @@ -0,0 +1,122 @@ +package com.bsd.pjcloud.canteen.controller; + +import cn.hutool.core.util.StrUtil; +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.CanteenOnlineSpuEntity; +import com.bsd.pjcloud.canteen.service.CanteenOnlineSpuService; +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; + +/** + * 在线点餐spu + * + * @author zjf + * @date 2024-12-16 23:42:19 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/canteenOnlineSpu" ) +@Tag(description = "canteenOnlineSpu" , name = "在线点餐spu管理" ) +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class CanteenOnlineSpuController { + + private final CanteenOnlineSpuService canteenOnlineSpuService; + + /** + * 分页查询 + * @param page 分页对象 + * @param canteenOnlineSpu 在线点餐spu + * @return + */ + @Operation(summary = "分页查询" , description = "分页查询" ) + @GetMapping("/page" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineSpu_view')" ) + public R getCanteenOnlineSpuPage(@ParameterObject Page page, @ParameterObject CanteenOnlineSpuEntity canteenOnlineSpu) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.like(StrUtil.isNotBlank(canteenOnlineSpu.getName()),CanteenOnlineSpuEntity::getName,canteenOnlineSpu.getName()); + wrapper.eq(Objects.nonNull(canteenOnlineSpu.getCategoryId()),CanteenOnlineSpuEntity::getCategoryId,canteenOnlineSpu.getCategoryId()); + return R.ok(canteenOnlineSpuService.page(page, wrapper)); + } + + + /** + * 通过id查询在线点餐spu + * @param id id + * @return R + */ + @Operation(summary = "通过id查询" , description = "通过id查询" ) + @GetMapping("/{id}" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineSpu_view')" ) + public R getById(@PathVariable("id" ) Long id) { + return R.ok(canteenOnlineSpuService.getById(id)); + } + + /** + * 新增在线点餐spu + * @param canteenOnlineSpu 在线点餐spu + * @return R + */ + @Operation(summary = "新增在线点餐spu" , description = "新增在线点餐spu" ) + @SysLog("新增在线点餐spu" ) + @PostMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineSpu_add')" ) + public R save(@RequestBody CanteenOnlineSpuEntity canteenOnlineSpu) { + return R.ok(canteenOnlineSpuService.save(canteenOnlineSpu)); + } + + /** + * 修改在线点餐spu + * @param canteenOnlineSpu 在线点餐spu + * @return R + */ + @Operation(summary = "修改在线点餐spu" , description = "修改在线点餐spu" ) + @SysLog("修改在线点餐spu" ) + @PutMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineSpu_edit')" ) + public R updateById(@RequestBody CanteenOnlineSpuEntity canteenOnlineSpu) { + return R.ok(canteenOnlineSpuService.updateById(canteenOnlineSpu)); + } + + /** + * 通过id删除在线点餐spu + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除在线点餐spu" , description = "通过id删除在线点餐spu" ) + @SysLog("通过id删除在线点餐spu" ) + @DeleteMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineSpu_del')" ) + public R removeById(@RequestBody Long[] ids) { + return R.ok(canteenOnlineSpuService.removeBatchByIds(CollUtil.toList(ids))); + } + + + /** + * 导出excel 表格 + * @param canteenOnlineSpu 查询条件 + * @param ids 导出指定ID + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('canteen_canteenOnlineSpu_export')" ) + public List export(CanteenOnlineSpuEntity canteenOnlineSpu,Long[] ids) { + return canteenOnlineSpuService.list(Wrappers.lambdaQuery(canteenOnlineSpu).in(ArrayUtil.isNotEmpty(ids), CanteenOnlineSpuEntity::getId, ids)); + } +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/BoxesAvailabilityEntity.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/BoxesAvailabilityEntity.java new file mode 100644 index 000000000..be5e94ddb --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/BoxesAvailabilityEntity.java @@ -0,0 +1,109 @@ +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.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; + +/** + * 包厢可用时间段 + * + * @author zjf + * @date 2024-12-17 13:59:31 + */ +@Data +@TableName("boxes_availability") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "包厢可用时间段") +public class BoxesAvailabilityEntity extends Model { + + + /** + * 主键id + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description="主键id") + private Long id; + + /** + * 包厢Id + */ + @Schema(description="包厢Id") + private Long boxesId; + + /** + * 预约id + */ + @Schema(description="预约id") + private Long bookingId; + + /** + * 状态 0空闲 1已使用 + */ + @Schema(description="状态 0空闲 1已使用") + private Integer status; + + /** + * 用户id + */ + @Schema(description="用户id") + private Long userId; + + /** + * 格式为 YYYY-MM-DD + */ + @Schema(description="格式为 YYYY-MM-DD") + private LocalDate bxDate; + + /** + * 时间 + */ + @Schema(description="时间") + private LocalTime hour; + + /** + * 时间索引(0-24) + */ + @Schema(description="时间索引(0-24)") + private Integer hourIndex; + + /** + * 创建人 + */ + @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 Double updateBy; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description="更新时间") + private LocalDateTime updateTime; + + /** + * 是否删除 + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description="是否删除") + private String delFlag; +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/BoxesBookingEntity.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/BoxesBookingEntity.java index 46f425145..1448b3fee 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/BoxesBookingEntity.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/BoxesBookingEntity.java @@ -113,4 +113,8 @@ public class BoxesBookingEntity extends Model { @TableField(fill = FieldFill.INSERT_UPDATE) @Schema(description="更新时间") private LocalDateTime updateTime; + + + @Schema(description="部门id") + private Long deptId; } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenOnlineCategoryEntity.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenOnlineCategoryEntity.java new file mode 100644 index 000000000..b3a4e002f --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenOnlineCategoryEntity.java @@ -0,0 +1,109 @@ +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 com.bsd.pjcloud.common.core.util.TenantTable; +import java.time.LocalDateTime; + +/** + * 在线点餐分类 + * + * @author zjf + * @date 2024-12-17 13:03:14 + */ +@Data +@TenantTable +@TableName("canteen_online_category") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "在线点餐分类") +public class CanteenOnlineCategoryEntity extends Model { + + + /** + * 分类编号 + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description="分类编号") + private Long id; + + /** + * 父分类编号 + */ + @Schema(description="父分类编号") + private Long parentId; + + /** + * 分类名称 + */ + @Schema(description="分类名称") + private String name; + + /** + * 分类图 + */ + @Schema(description="分类图") + private String picUrl; + + /** + * 分类排序 + */ + @Schema(description="分类排序") + private Integer sort; + + /** + * 开启状态 + */ + @Schema(description="开启状态") + private String status; + + /** + * 部门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; + + /** + * 租户编号 + */ + @Schema(description="租户编号") + private Long tenantId; +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenOnlineSpuEntity.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenOnlineSpuEntity.java new file mode 100644 index 000000000..b7e8f8bd1 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenOnlineSpuEntity.java @@ -0,0 +1,177 @@ +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 com.bsd.pjcloud.common.core.util.TenantTable; +import java.time.LocalDateTime; + +/** + * 在线点餐spu + * + * @author zjf + * @date 2024-12-16 23:42:19 + */ +@Data +@TenantTable +@TableName("canteen_online_spu") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "在线点餐spu") +public class CanteenOnlineSpuEntity extends Model { + + + /** + * 商品 SPU 编号,自增 + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description="商品 SPU 编号,自增") + private Long id; + + /** + * 商品名称 + */ + @Schema(description="商品名称") + private String name; + + /** + * 商品简介 + */ + @Schema(description="商品简介") + private String introduction; + + /** + * 商品详情 + */ + @Schema(description="商品详情") + private String description; + + /** + * 商品分类编号 + */ + @Schema(description="商品分类编号") + private Long categoryId; + + /** + * 商品封面图 + */ + @Schema(description="商品封面图") + private String picUrl; + + /** + * 商品轮播图地址 + 数组,以逗号分隔 + 最多上传15张 + */ + @Schema(description="商品轮播图地址") + private String sliderPicUrls; + + /** + * 排序字段 + */ + @Schema(description="排序字段") + private Integer sort; + + /** + * 商品状态: 1 上架(开启) 0 下架(禁用) -1 回收 + */ + @Schema(description="商品状态: 1 上架(开启) 0 下架(禁用) -1 回收") + private Integer status; + + /** + * 商品价格,单位使用:分 + */ + @Schema(description="商品价格,单位使用:分") + private Integer price; + + /** + * 市场价,单位使用:分 + */ + @Schema(description="市场价,单位使用:分") + private Integer marketPrice; + + /** + * 库存 + */ + @Schema(description="库存") + private Integer stock; + + /** + * 赠送积分 + */ + @Schema(description="赠送积分") + private Integer giveIntegral; + + /** + * 商品销量 + */ + @Schema(description="商品销量") + private Integer salesCount; + + /** + * 虚拟销量 + */ + @Schema(description="虚拟销量") + private Integer virtualSalesCount; + + /** + * 商品点击量 + */ + @Schema(description="商品点击量") + private Integer browseCount; + + /** + * 商户编号 + */ + @Schema(description="商户编号") + private Long merchantId; + + /** + * 部门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; + + /** + * 租户编号 + */ + @Schema(description="租户编号") + private Long tenantId; +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/job/BoxesAvaliabilityJob.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/job/BoxesAvaliabilityJob.java new file mode 100644 index 000000000..eed1f54f3 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/job/BoxesAvaliabilityJob.java @@ -0,0 +1,67 @@ +package com.bsd.pjcloud.canteen.job; + + +import com.bsd.pjcloud.canteen.entity.BoxesAvailabilityEntity; +import com.bsd.pjcloud.canteen.entity.BoxesInfoEntity; +import com.bsd.pjcloud.canteen.mapper.BoxesAvailabilityMapper; +import com.bsd.pjcloud.canteen.mapper.BoxesInfoMapper; +import com.bsd.pjcloud.canteen.service.BoxesAvailabilityService; +import com.bsd.pjcloud.canteen.service.BoxesInfoService; +import com.xxl.job.core.context.XxlJobHelper; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.List; + +@Service +@AllArgsConstructor +public class BoxesAvaliabilityJob { + + private final BoxesInfoMapper boxesInfoMapper; + + private final BoxesAvailabilityService boxesAvailabilityService; + + private final BoxesAvailabilityMapper boxesAvailabilityMapper; + @XxlJob("avaliabilityJobHandler") + public void demoJobHandler() { + //查询所有包厢 + List rooms = boxesInfoMapper.selectList(null); + + for (BoxesInfoEntity room : rooms) { + // 查询该包厢的最新时间段记录 + BoxesAvailabilityEntity latestAvailability = boxesAvailabilityMapper.findTopByRoomIdOrderByDateDesc(room.getId()); + + LocalDate startDate; + if (latestAvailability != null) { + // 从最新日期的下一天开始 + startDate = latestAvailability.getBxDate().plusDays(1); + } else { + // 如果还没有记录,从今天开始 + startDate = LocalDate.now(); + } + + // 生成未来 15 天的数据 + LocalDate endDate = LocalDate.now().plusDays(15); + List availabilityList = new ArrayList<>(); + + for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) { + for (int hour = 0; hour < 24; hour++) { + BoxesAvailabilityEntity availability = new BoxesAvailabilityEntity(); + availability.setBoxesId(room.getId()); + availability.setBxDate(date); + availability.setHour(LocalTime.of(hour, 0)); + availability.setHourIndex(hour); + availabilityList.add(availability); + } + } + + // 批量插入数据 + boxesAvailabilityService.saveBatch(availabilityList); + } + XxlJobHelper.handleSuccess(); + } +} diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/BoxesAvailabilityMapper.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/BoxesAvailabilityMapper.java new file mode 100644 index 000000000..8a430464e --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/BoxesAvailabilityMapper.java @@ -0,0 +1,17 @@ +package com.bsd.pjcloud.canteen.mapper; + +import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.canteen.entity.BoxesAvailabilityEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface BoxesAvailabilityMapper extends PjcloudBaseMapper { + + + /** + * 最新的一条数据库 + * @param id + * @return + */ + BoxesAvailabilityEntity findTopByRoomIdOrderByDateDesc(Long id); +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenOnlineCategoryMapper.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenOnlineCategoryMapper.java new file mode 100644 index 000000000..d8f95615c --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenOnlineCategoryMapper.java @@ -0,0 +1,11 @@ +package com.bsd.pjcloud.canteen.mapper; + +import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.canteen.entity.CanteenOnlineCategoryEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CanteenOnlineCategoryMapper extends PjcloudBaseMapper { + + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenOnlineSpuMapper.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenOnlineSpuMapper.java new file mode 100644 index 000000000..ca8dd3cb0 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenOnlineSpuMapper.java @@ -0,0 +1,11 @@ +package com.bsd.pjcloud.canteen.mapper; + +import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CanteenOnlineSpuMapper extends PjcloudBaseMapper { + + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/BoxesAvailabilityService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/BoxesAvailabilityService.java new file mode 100644 index 000000000..18bbc3cf3 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/BoxesAvailabilityService.java @@ -0,0 +1,8 @@ +package com.bsd.pjcloud.canteen.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.canteen.entity.BoxesAvailabilityEntity; + +public interface BoxesAvailabilityService extends IService { + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/BoxesBookingService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/BoxesBookingService.java index 1d7d3ddc0..0dda91632 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/BoxesBookingService.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/BoxesBookingService.java @@ -2,7 +2,16 @@ package com.bsd.pjcloud.canteen.service; import com.baomidou.mybatisplus.extension.service.IService; import com.bsd.pjcloud.canteen.entity.BoxesBookingEntity; +import com.bsd.pjcloud.canteen.vo.AppMakeSaveReqVO; +import com.bsd.pjcloud.common.core.util.R; public interface BoxesBookingService extends IService { + + /** + * 发起一条预约 + * @param createReqVO + * @return + */ + R createBooking(AppMakeSaveReqVO createReqVO); } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/BoxesInfoService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/BoxesInfoService.java index 444401166..1aa92abc7 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/BoxesInfoService.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/BoxesInfoService.java @@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.bsd.pjcloud.canteen.entity.BoxesInfoEntity; +import com.bsd.pjcloud.canteen.vo.AppBXDetailRespVO; + +import java.time.LocalDate; public interface BoxesInfoService extends IService { @@ -15,4 +18,20 @@ public interface BoxesInfoService extends IService { * @return */ Object pageScope(Page page, LambdaQueryWrapper wrapper); + + /** + * 新增包厢 + * @param boxesInfo + * @return + */ + Object saveInfo(BoxesInfoEntity boxesInfo); + + + /** + * 根据日期动态获取包厢可预约时间信息 + * @param id + * @param date + * @return + */ + AppBXDetailRespVO getAppBXDetailRespVO(Long id, LocalDate date); } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenOnlineCategoryService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenOnlineCategoryService.java new file mode 100644 index 000000000..c3d73657c --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenOnlineCategoryService.java @@ -0,0 +1,8 @@ +package com.bsd.pjcloud.canteen.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.canteen.entity.CanteenOnlineCategoryEntity; + +public interface CanteenOnlineCategoryService extends IService { + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenOnlineSpuService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenOnlineSpuService.java new file mode 100644 index 000000000..a20da579a --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenOnlineSpuService.java @@ -0,0 +1,8 @@ +package com.bsd.pjcloud.canteen.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity; + +public interface CanteenOnlineSpuService extends IService { + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/BoxesAvailabilityServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/BoxesAvailabilityServiceImpl.java new file mode 100644 index 000000000..21149c036 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/BoxesAvailabilityServiceImpl.java @@ -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.BoxesAvailabilityEntity; +import com.bsd.pjcloud.canteen.mapper.BoxesAvailabilityMapper; +import com.bsd.pjcloud.canteen.service.BoxesAvailabilityService; +import org.springframework.stereotype.Service; +/** + * 包厢可用时间段 + * + * @author zjf + * @date 2024-12-17 13:59:31 + */ +@Service +public class BoxesAvailabilityServiceImpl extends ServiceImpl implements BoxesAvailabilityService { +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/BoxesBookingServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/BoxesBookingServiceImpl.java index e8808c910..61c024fa6 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/BoxesBookingServiceImpl.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/BoxesBookingServiceImpl.java @@ -2,9 +2,21 @@ package com.bsd.pjcloud.canteen.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.mapper.BoxesInfoMapper; 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.security.util.SecurityUtils; +import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; + /** * 包厢预约记录表 * @@ -12,5 +24,54 @@ import org.springframework.stereotype.Service; * @date 2024-12-16 22:39:45 */ @Service +@AllArgsConstructor public class BoxesBookingServiceImpl extends ServiceImpl implements BoxesBookingService { + + private final BoxesInfoMapper boxesInfoMapper; + + private final BoxesBookingMapper bookingMapper; + + private final BoxesAvailabilityMapper bookingAvailabilityMapper; + @Override + @Transactional + 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()); + bookingMapper.insert(booking); + + //todo 工作流部分,待定 +// Map objectObjectHashMap = new HashMap<>(); +// objectObjectHashMap.put("deptId", infoDO.getDeptId()); +// String processInstanceId = processInstanceApi.createProcessInstance(loginUserId, +// new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) +// .setBusinessKey(String.valueOf(booking.getId())) +// .setVariables(objectObjectHashMap)); +// +// +// // 将工作流的编号,更新到 OA 请假单中 +// BookingDO bookingDO = new BookingDO(); +// bookingDO.setId(booking.getId()); +// bookingDO.setProcessInstanceId(processInstanceId); + +// bookingMapper.updateById(bookingDO); + // 返回 + return R.ok(); + } } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/BoxesInfoServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/BoxesInfoServiceImpl.java index 4b296e7b5..92351cd18 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/BoxesInfoServiceImpl.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/BoxesInfoServiceImpl.java @@ -3,11 +3,23 @@ package com.bsd.pjcloud.canteen.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.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.common.core.util.BeanUtils; import com.bsd.pjcloud.common.data.datascope.DataScope; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.List; + /** * 包厢信息 * @@ -15,9 +27,52 @@ import org.springframework.stereotype.Service; * @date 2024-12-16 21:13:58 */ @Service +@RequiredArgsConstructor public class BoxesInfoServiceImpl extends ServiceImpl implements BoxesInfoService { + + private final BoxesAvailabilityService boxesAvailabilityService; @Override public Object pageScope(Page page, LambdaQueryWrapper wrapper) { return baseMapper.selectPageByScope(page,wrapper, DataScope.of()); } + + @Override + public Object saveInfo(BoxesInfoEntity boxesInfo) { + baseMapper.insert(boxesInfo); + //批量插入未来15天可用时间段 + + List 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 availabilityDOLambdaQueryWrapper = new LambdaQueryWrapper<>(); + availabilityDOLambdaQueryWrapper.eq(BoxesAvailabilityEntity::getBxDate,date); + availabilityDOLambdaQueryWrapper.eq(BoxesAvailabilityEntity::getBoxesId,id); + List availabilityDOS = boxesAvailabilityService.list(availabilityDOLambdaQueryWrapper); + List availabilityDOListBean = BeanUtils.toBean(availabilityDOS, APPBXAvaliabilityRespVO.class); + bean.setAvaliabilityRespList(availabilityDOListBean); + return bean; + } } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenOnlineCategoryServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenOnlineCategoryServiceImpl.java new file mode 100644 index 000000000..1bd1449c8 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenOnlineCategoryServiceImpl.java @@ -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.CanteenOnlineCategoryEntity; +import com.bsd.pjcloud.canteen.mapper.CanteenOnlineCategoryMapper; +import com.bsd.pjcloud.canteen.service.CanteenOnlineCategoryService; +import org.springframework.stereotype.Service; +/** + * 在线点餐分类 + * + * @author zjf + * @date 2024-12-17 13:03:14 + */ +@Service +public class CanteenOnlineCategoryServiceImpl extends ServiceImpl implements CanteenOnlineCategoryService { +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenOnlineSpuServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenOnlineSpuServiceImpl.java new file mode 100644 index 000000000..98c4d94bf --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenOnlineSpuServiceImpl.java @@ -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.CanteenOnlineSpuEntity; +import com.bsd.pjcloud.canteen.mapper.CanteenOnlineSpuMapper; +import com.bsd.pjcloud.canteen.service.CanteenOnlineSpuService; +import org.springframework.stereotype.Service; +/** + * 在线点餐spu + * + * @author zjf + * @date 2024-12-16 23:42:19 + */ +@Service +public class CanteenOnlineSpuServiceImpl extends ServiceImpl implements CanteenOnlineSpuService { +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/BoxesAvailabilityMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/BoxesAvailabilityMapper.xml new file mode 100644 index 000000000..70e54fb7f --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/BoxesAvailabilityMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/BoxesBookingMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/BoxesBookingMapper.xml index 7ff8b29f6..834955797 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/BoxesBookingMapper.xml +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/BoxesBookingMapper.xml @@ -19,5 +19,6 @@ + \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenOnlineCategoryMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenOnlineCategoryMapper.xml new file mode 100644 index 000000000..b2f58437c --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenOnlineCategoryMapper.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenOnlineSpuMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenOnlineSpuMapper.xml new file mode 100644 index 000000000..f2299a8a9 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenOnlineSpuMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/util/BeanUtils.java b/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/util/BeanUtils.java new file mode 100644 index 000000000..0f7563149 --- /dev/null +++ b/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/util/BeanUtils.java @@ -0,0 +1,48 @@ +package com.bsd.pjcloud.common.core.util; + +import cn.hutool.core.bean.BeanUtil; + + +import java.util.List; +import java.util.function.Consumer; + +/** + * Bean 工具类 + * + * 1. 默认使用 {@link BeanUtil} 作为实现类,虽然不同 bean 工具的性能有差别,但是对绝大多数同学的项目,不用在意这点性能 + * 2. 针对复杂的对象转换,可以搜参考 AuthConvert 实现,通过 mapstruct + default 配合实现 + * + * @author 芋道源码 + */ +public class BeanUtils { + + public static T toBean(Object source, Class targetClass) { + return BeanUtil.toBean(source, targetClass); + } + + public static T toBean(Object source, Class targetClass, Consumer peek) { + T target = toBean(source, targetClass); + if (target != null) { + peek.accept(target); + } + return target; + } + + public static List toBean(List source, Class targetType) { + if (source == null) { + return null; + } + return CollectionUtils.convertList(source, s -> toBean(s, targetType)); + } + + public static List toBean(List source, Class targetType, Consumer peek) { + List list = toBean(source, targetType); + if (list != null) { + list.forEach(peek); + } + return list; + } + + + +} \ No newline at end of file diff --git a/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/util/CollectionUtils.java b/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/util/CollectionUtils.java new file mode 100644 index 000000000..c2c6f02da --- /dev/null +++ b/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/util/CollectionUtils.java @@ -0,0 +1,321 @@ +package com.bsd.pjcloud.common.core.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ArrayUtil; + +import java.util.*; +import java.util.function.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static java.util.Arrays.asList; + +/** + * Collection 工具类 + * + * @author 芋道源码 + */ +public class CollectionUtils { + + public static boolean containsAny(Object source, Object... targets) { + return asList(targets).contains(source); + } + + public static boolean isAnyEmpty(Collection... collections) { + return Arrays.stream(collections).anyMatch(CollectionUtil::isEmpty); + } + + public static boolean anyMatch(Collection from, Predicate predicate) { + return from.stream().anyMatch(predicate); + } + + public static List filterList(Collection from, Predicate predicate) { + if (CollUtil.isEmpty(from)) { + return new ArrayList<>(); + } + return from.stream().filter(predicate).collect(Collectors.toList()); + } + + public static List distinct(Collection from, Function keyMapper) { + if (CollUtil.isEmpty(from)) { + return new ArrayList<>(); + } + return distinct(from, keyMapper, (t1, t2) -> t1); + } + + public static List distinct(Collection from, Function keyMapper, BinaryOperator cover) { + if (CollUtil.isEmpty(from)) { + return new ArrayList<>(); + } + return new ArrayList<>(convertMap(from, keyMapper, Function.identity(), cover).values()); + } + + public static List convertList(T[] from, Function func) { + if (ArrayUtil.isEmpty(from)) { + return new ArrayList<>(); + } + return convertList(Arrays.asList(from), func); + } + + public static List convertList(Collection from, Function func) { + if (CollUtil.isEmpty(from)) { + return new ArrayList<>(); + } + return from.stream().map(func).filter(Objects::nonNull).collect(Collectors.toList()); + } + + public static List convertList(Collection from, Function func, Predicate filter) { + if (CollUtil.isEmpty(from)) { + return new ArrayList<>(); + } + return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toList()); + } + + public static List convertListByFlatMap(Collection from, + Function> func) { + if (CollUtil.isEmpty(from)) { + return new ArrayList<>(); + } + return from.stream().filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList()); + } + + public static List convertListByFlatMap(Collection from, + Function mapper, + Function> func) { + if (CollUtil.isEmpty(from)) { + return new ArrayList<>(); + } + return from.stream().map(mapper).filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList()); + } + + public static List mergeValuesFromMap(Map> map) { + return map.values() + .stream() + .flatMap(List::stream) + .collect(Collectors.toList()); + } + + public static Set convertSet(Collection from) { + return convertSet(from, v -> v); + } + + public static Set convertSet(Collection from, Function func) { + if (CollUtil.isEmpty(from)) { + return new HashSet<>(); + } + return from.stream().map(func).filter(Objects::nonNull).collect(Collectors.toSet()); + } + + public static Set convertSet(Collection from, Function func, Predicate filter) { + if (CollUtil.isEmpty(from)) { + return new HashSet<>(); + } + return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toSet()); + } + + public static Map convertMapByFilter(Collection from, Predicate filter, Function keyFunc) { + if (CollUtil.isEmpty(from)) { + return new HashMap<>(); + } + return from.stream().filter(filter).collect(Collectors.toMap(keyFunc, v -> v)); + } + + public static Set convertSetByFlatMap(Collection from, + Function> func) { + if (CollUtil.isEmpty(from)) { + return new HashSet<>(); + } + return from.stream().filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet()); + } + + public static Set convertSetByFlatMap(Collection from, + Function mapper, + Function> func) { + if (CollUtil.isEmpty(from)) { + return new HashSet<>(); + } + return from.stream().map(mapper).filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet()); + } + + public static Map convertMap(Collection from, Function keyFunc) { + if (CollUtil.isEmpty(from)) { + return new HashMap<>(); + } + return convertMap(from, keyFunc, Function.identity()); + } + + public static Map convertMap(Collection from, Function keyFunc, Supplier> supplier) { + if (CollUtil.isEmpty(from)) { + return supplier.get(); + } + return convertMap(from, keyFunc, Function.identity(), supplier); + } + + public static Map convertMap(Collection from, Function keyFunc, Function valueFunc) { + if (CollUtil.isEmpty(from)) { + return new HashMap<>(); + } + return convertMap(from, keyFunc, valueFunc, (v1, v2) -> v1); + } + + public static Map convertMap(Collection from, Function keyFunc, Function valueFunc, BinaryOperator mergeFunction) { + if (CollUtil.isEmpty(from)) { + return new HashMap<>(); + } + return convertMap(from, keyFunc, valueFunc, mergeFunction, HashMap::new); + } + + public static Map convertMap(Collection from, Function keyFunc, Function valueFunc, Supplier> supplier) { + if (CollUtil.isEmpty(from)) { + return supplier.get(); + } + return convertMap(from, keyFunc, valueFunc, (v1, v2) -> v1, supplier); + } + + public static Map convertMap(Collection from, Function keyFunc, Function valueFunc, BinaryOperator mergeFunction, Supplier> supplier) { + if (CollUtil.isEmpty(from)) { + return new HashMap<>(); + } + return from.stream().collect(Collectors.toMap(keyFunc, valueFunc, mergeFunction, supplier)); + } + + public static Map> convertMultiMap(Collection from, Function keyFunc) { + if (CollUtil.isEmpty(from)) { + return new HashMap<>(); + } + return from.stream().collect(Collectors.groupingBy(keyFunc, Collectors.mapping(t -> t, Collectors.toList()))); + } + + public static Map> convertMultiMap(Collection from, Function keyFunc, Function valueFunc) { + if (CollUtil.isEmpty(from)) { + return new HashMap<>(); + } + return from.stream() + .collect(Collectors.groupingBy(keyFunc, Collectors.mapping(valueFunc, Collectors.toList()))); + } + + // 暂时没想好名字,先以 2 结尾噶 + public static Map> convertMultiMap2(Collection from, Function keyFunc, Function valueFunc) { + if (CollUtil.isEmpty(from)) { + return new HashMap<>(); + } + return from.stream().collect(Collectors.groupingBy(keyFunc, Collectors.mapping(valueFunc, Collectors.toSet()))); + } + +// public static Map convertImmutableMap(Collection from, Function keyFunc) { +// if (CollUtil.isEmpty(from)) { +// return Collections.emptyMap(); +// } +// ImmutableMap.Builder builder = ImmutableMap.builder(); +// from.forEach(item -> builder.put(keyFunc.apply(item), item)); +// return builder.build(); +// } + + /** + * 对比老、新两个列表,找出新增、修改、删除的数据 + * + * @param oldList 老列表 + * @param newList 新列表 + * @param sameFunc 对比函数,返回 true 表示相同,返回 false 表示不同 + * 注意,same 是通过每个元素的“标识”,判断它们是不是同一个数据 + * @return [新增列表、修改列表、删除列表] + */ + public static List> diffList(Collection oldList, Collection newList, + BiFunction sameFunc) { + List createList = new LinkedList<>(newList); // 默认都认为是新增的,后续会进行移除 + List updateList = new ArrayList<>(); + List deleteList = new ArrayList<>(); + + // 通过以 oldList 为主遍历,找出 updateList 和 deleteList + for (T oldObj : oldList) { + // 1. 寻找是否有匹配的 + T foundObj = null; + for (Iterator iterator = createList.iterator(); iterator.hasNext(); ) { + T newObj = iterator.next(); + // 1.1 不匹配,则直接跳过 + if (!sameFunc.apply(oldObj, newObj)) { + continue; + } + // 1.2 匹配,则移除,并结束寻找 + iterator.remove(); + foundObj = newObj; + break; + } + // 2. 匹配添加到 updateList;不匹配则添加到 deleteList 中 + if (foundObj != null) { + updateList.add(foundObj); + } else { + deleteList.add(oldObj); + } + } + return asList(createList, updateList, deleteList); + } + + public static boolean containsAny(Collection source, Collection candidates) { + return org.springframework.util.CollectionUtils.containsAny(source, candidates); + } + + public static T getFirst(List from) { + return !CollectionUtil.isEmpty(from) ? from.get(0) : null; + } + + public static T findFirst(Collection from, Predicate predicate) { + return findFirst(from, predicate, Function.identity()); + } + + public static U findFirst(Collection from, Predicate predicate, Function func) { + if (CollUtil.isEmpty(from)) { + return null; + } + return from.stream().filter(predicate).findFirst().map(func).orElse(null); + } + + public static > V getMaxValue(Collection from, Function valueFunc) { + if (CollUtil.isEmpty(from)) { + return null; + } + assert !from.isEmpty(); // 断言,避免告警 + T t = from.stream().max(Comparator.comparing(valueFunc)).get(); + return valueFunc.apply(t); + } + + public static > V getMinValue(List from, Function valueFunc) { + if (CollUtil.isEmpty(from)) { + return null; + } + assert from.size() > 0; // 断言,避免告警 + T t = from.stream().min(Comparator.comparing(valueFunc)).get(); + return valueFunc.apply(t); + } + + public static > V getSumValue(List from, Function valueFunc, + BinaryOperator accumulator) { + return getSumValue(from, valueFunc, accumulator, null); + } + + public static > V getSumValue(Collection from, Function valueFunc, + BinaryOperator accumulator, V defaultValue) { + if (CollUtil.isEmpty(from)) { + return defaultValue; + } + assert !from.isEmpty(); // 断言,避免告警 + return from.stream().map(valueFunc).filter(Objects::nonNull).reduce(accumulator).orElse(defaultValue); + } + + public static void addIfNotNull(Collection coll, T item) { + if (item == null) { + return; + } + coll.add(item); + } + + public static Collection singleton(T obj) { + return obj == null ? Collections.emptyList() : Collections.singleton(obj); + } + + public static List newArrayList(List> list) { + return list.stream().flatMap(Collection::stream).collect(Collectors.toList()); + } + +} \ No newline at end of file diff --git a/seata/logs/seata_gc.log.1 b/seata/logs/seata_gc.log.1 index 881d225bb..c85f706b3 100644 --- a/seata/logs/seata_gc.log.1 +++ b/seata/logs/seata_gc.log.1 @@ -1,5 +1,6 @@ [0.014s][info][gc] Using G1 -[1.679s][info][gc] GC(0) Pause Young (Normal) (G1 Evacuation Pause) 102M->12M(2048M) 5.347ms -[2.695s][info][gc] GC(1) Pause Young (Normal) (G1 Evacuation Pause) 103M->15M(2048M) 5.572ms -[3.279s][info][gc] GC(2) Pause Young (Normal) (G1 Evacuation Pause) 124M->18M(2048M) 3.129ms -[7426.520s][info][gc] GC(3) Pause Young (Normal) (G1 Evacuation Pause) 411M->29M(2048M) 64.581ms +[1.633s][info][gc] GC(0) Pause Young (Normal) (G1 Evacuation Pause) 102M->12M(2048M) 5.374ms +[2.783s][info][gc] GC(1) Pause Young (Normal) (G1 Evacuation Pause) 103M->16M(2048M) 5.196ms +[3.338s][info][gc] GC(2) Pause Young (Normal) (G1 Evacuation Pause) 125M->18M(2048M) 3.128ms +[235.964s][info][gc] GC(3) Pause Young (Normal) (G1 Evacuation Pause) 259M->28M(2048M) 9.440ms +[21628.241s][info][gc] GC(4) Pause Young (Normal) (G1 Evacuation Pause) 441M->28M(2048M) 130.697ms diff --git a/seata/logs/seata_gc.log.4 b/seata/logs/seata_gc.log.4 index 271e498d9..1315ddb55 100644 --- a/seata/logs/seata_gc.log.4 +++ b/seata/logs/seata_gc.log.4 @@ -1,4 +1,5 @@ -[0.016s][info][gc] Using G1 -[1.624s][info][gc] GC(0) Pause Young (Normal) (G1 Evacuation Pause) 102M->12M(2048M) 6.331ms -[2.854s][info][gc] GC(1) Pause Young (Normal) (G1 Evacuation Pause) 103M->16M(2048M) 5.636ms -[3.466s][info][gc] GC(2) Pause Young (Normal) (G1 Evacuation Pause) 125M->19M(2048M) 3.007ms +[0.015s][info][gc] Using G1 +[1.640s][info][gc] GC(0) Pause Young (Normal) (G1 Evacuation Pause) 102M->12M(2048M) 5.298ms +[5.063s][info][gc] GC(1) Pause Young (Normal) (G1 Evacuation Pause) 103M->16M(2048M) 4.966ms +[5.633s][info][gc] GC(2) Pause Young (Normal) (G1 Evacuation Pause) 125M->19M(2048M) 3.030ms +[29.043s][info][gc] GC(3) Pause Young (Normal) (G1 Evacuation Pause) 248M->26M(2048M) 7.181ms