Compare commits

..

3 Commits

Author SHA1 Message Date
wangliwen 25d68b648b Merge branch 'master' into docker_package 2023-01-12 11:01:57 +08:00
wangliwen d8bff2e17e Merge branch 'dev' 2023-01-12 11:01:47 +08:00
wangliwen 1998f17c2e 会客厅增加申请成功次数 2023-01-12 11:01:37 +08:00
5 changed files with 33 additions and 3 deletions

View File

@ -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<PageData<TMeetingroomDTO>> list(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<TMeetingroomDTO> list = tMeetingroomService.selectFreeRoom(params);

View File

@ -36,4 +36,6 @@ public interface TMeetingroomBookMapper extends BaseDao<TMeetingroomBook> {
List<TMeetingroomBook> selectInvalid(Date date);
List<Long> selectBookIdByRoomId(Long id);
Long countApply(Long id);
}

View File

@ -42,6 +42,8 @@ public class TMeetingroomDTO implements Serializable {
private Integer delFlag;
@ApiModelProperty(value = "价格")
private BigDecimal price;
@ApiModelProperty(value = "申请成功次数")
private Long applyCount;
}

View File

@ -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<TMeetingroomMapper, TMeetingroom, TMeetingroomDTO> implements TMeetingroomService {
@ -86,20 +88,39 @@ public class TMeetingroomServiceImpl extends CrudServiceImpl<TMeetingroomMapper,
String finalBookDate = bookDate + " 00:00:00";
String finalStartTime = "1970-01-01 " + startTime;
String finalEndTime = "1970-01-01 " + endTime;
tMeetingroomDTOS = tMeetingroomDTOS.stream().filter(room -> {
Stream<TMeetingroomDTO> 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<TMeetingroomBookDTO> 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<TMeetingroomDTO> pageSizeDataForRelations = PageUtil.getPageSizeDataForRelations(tMeetingroomDTOS, pageSize, page);

View File

@ -148,5 +148,8 @@
<select id="selectBookIdByRoomId" resultType="java.lang.Long">
SELECT id FROM t_meetingroom_book WHERE room_id = #{id}
</select>
<select id="countApply" resultType="java.lang.Long">
SELECT COUNT(id) FROM t_meetingroom_book WHERE room_id = #{id} AND state = 2;
</select>
</mapper>