From 1998f17c2e6582b8b74e0c8d68c3229bf670b01f Mon Sep 17 00:00:00 2001 From: wangliwen Date: Thu, 12 Jan 2023 11:01:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E5=AE=A2=E5=8E=85=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E6=88=90=E5=8A=9F=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BookMeetingRoomController.java | 2 ++ .../meeting/dao/TMeetingroomBookMapper.java | 2 ++ .../modules/meeting/dto/TMeetingroomDTO.java | 2 ++ .../service/Impl/TMeetingroomServiceImpl.java | 27 ++++++++++++++++--- .../mapper/meeting/TMeetingroomBookMapper.xml | 3 +++ 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/meeting/controller/BookMeetingRoomController.java b/renren-admin/src/main/java/io/renren/modules/meeting/controller/BookMeetingRoomController.java index e19c1b32..9013a5c3 100644 --- a/renren-admin/src/main/java/io/renren/modules/meeting/controller/BookMeetingRoomController.java +++ b/renren-admin/src/main/java/io/renren/modules/meeting/controller/BookMeetingRoomController.java @@ -59,6 +59,8 @@ public class BookMeetingRoomController { @ApiImplicitParam(name = "bookDate", value = "预约开始时间", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "startTime", value = "预约开始时间", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "endTime", value = "预约结束时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String") }) public Result> list(@ApiIgnore @RequestParam Map params) { PageData list = tMeetingroomService.selectFreeRoom(params); diff --git a/renren-admin/src/main/java/io/renren/modules/meeting/dao/TMeetingroomBookMapper.java b/renren-admin/src/main/java/io/renren/modules/meeting/dao/TMeetingroomBookMapper.java index 783916c0..4abf1092 100644 --- a/renren-admin/src/main/java/io/renren/modules/meeting/dao/TMeetingroomBookMapper.java +++ b/renren-admin/src/main/java/io/renren/modules/meeting/dao/TMeetingroomBookMapper.java @@ -36,4 +36,6 @@ public interface TMeetingroomBookMapper extends BaseDao { List selectInvalid(Date date); List selectBookIdByRoomId(Long id); + + Long countApply(Long id); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/meeting/dto/TMeetingroomDTO.java b/renren-admin/src/main/java/io/renren/modules/meeting/dto/TMeetingroomDTO.java index 30d1e48c..e72be1f8 100644 --- a/renren-admin/src/main/java/io/renren/modules/meeting/dto/TMeetingroomDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/meeting/dto/TMeetingroomDTO.java @@ -42,6 +42,8 @@ public class TMeetingroomDTO implements Serializable { private Integer delFlag; @ApiModelProperty(value = "价格") private BigDecimal price; + @ApiModelProperty(value = "申请成功次数") + private Long applyCount; } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/meeting/service/Impl/TMeetingroomServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/meeting/service/Impl/TMeetingroomServiceImpl.java index 492994da..068b02ae 100644 --- a/renren-admin/src/main/java/io/renren/modules/meeting/service/Impl/TMeetingroomServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/meeting/service/Impl/TMeetingroomServiceImpl.java @@ -15,9 +15,11 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import java.util.stream.Stream; @Service public class TMeetingroomServiceImpl extends CrudServiceImpl implements TMeetingroomService { @@ -86,20 +88,39 @@ public class TMeetingroomServiceImpl extends CrudServiceImpl { + Stream temp = tMeetingroomDTOS.stream().filter(room -> { // 如果有时间,根据时间段去预约表搜,如果搜不到,那就芜湖起飞 boolean flag = false; if ("null 00:00:00".equals(finalBookDate) || "1970-01-01 ".equals(finalStartTime) || "1970-01-01 ".equals(finalEndTime)) { return true; } - List meetingroomBookDTOS = tMeetingroomBookMapper.selectByRoomAndTime(room.getId(), finalBookDate, finalStartTime, finalEndTime); if (CollectionUtils.isEmpty(meetingroomBookDTOS)) { flag = true; } return flag; - }).collect(Collectors.toList()); + }).map(index -> { + index.setApplyCount(tMeetingroomBookMapper.countApply(index.getId())); + return index; + }); + // 增加排序 + if (params.containsKey("orderField") && params.containsKey("orderType")) { + if ("applyCount".equals(params.get("orderField"))) { + if ("DESC".equals(params.get("orderType"))) { + tMeetingroomDTOS = temp.sorted(Comparator.comparing(x -> { + TMeetingroomDTO index = (TMeetingroomDTO) x; + return index.getApplyCount(); + }).reversed()).collect(Collectors.toList()); + } else { + tMeetingroomDTOS = temp.sorted(Comparator.comparing(x -> x.getApplyCount())).collect(Collectors.toList()); + } + } else { + tMeetingroomDTOS = temp.collect(Collectors.toList()); + } + } else { + tMeetingroomDTOS = temp.collect(Collectors.toList()); + } List pageSizeDataForRelations = PageUtil.getPageSizeDataForRelations(tMeetingroomDTOS, pageSize, page); diff --git a/renren-admin/src/main/resources/mapper/meeting/TMeetingroomBookMapper.xml b/renren-admin/src/main/resources/mapper/meeting/TMeetingroomBookMapper.xml index 95c7b5b1..90b1f5fb 100644 --- a/renren-admin/src/main/resources/mapper/meeting/TMeetingroomBookMapper.xml +++ b/renren-admin/src/main/resources/mapper/meeting/TMeetingroomBookMapper.xml @@ -148,5 +148,8 @@ + \ No newline at end of file