# StatisticsOverviewByRoomsAndTravellersImpl.java

    package cloud.wconnect.rateshop.service.reviewanalysis.impl;

    import cloud.wconnect.commonlib.pojo.dto.PropertyDTO;
    import cloud.wconnect.rateshop.cons.reviewanalysis.ReviewAnalysisCons;
    import cloud.wconnect.rateshop.entity.reviewanalysis.Review;
    import cloud.wconnect.rateshop.pojo.dto.reviewanalysis.GroupStatisticsReviewDTO;
    import cloud.wconnect.rateshop.service.reviewanalysis.IStatisticsReview;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import org.apache.commons.collections.CollectionUtils;
    import org.springframework.stereotype.Service;

    import java.util.Collections;
    import java.util.List;

    /**
     * 各房型下，不同客型的平均得分（统计字段为room、travellerType）
     *
     * @author lichen
     * @date 2024/12/28
     */
    @Service
    @DS("rate_shop")
    public class StatisticsOverviewByRoomsAndTravellersImpl implements IStatisticsReview {

        /**
         * 判断是否支持此统计类型
         *
         * @param type 统计类型
         * @return boolean
         * @author lichen
         * @date 2024/12/27
         */
        @Override
        public boolean supports(int type) {
            return ReviewAnalysisCons.OVERVIEW_BY_ROOMS_AND_TRAVELLERS == type;
        }

        /**
         * 统计数据
         *
         * @param propertyDTO         资产DTO
         * @param reviews             评论数据集合
         * @param statisticsDimension 统计维度 1-月 2-周 3-日
         * @return java.util.List<cloud.wconnect.rateshop.pojo.dto.reviewanalysis.StatisticsReviewDTO>
         * @author lichen
         * @date 2024/12/27
         */
        @Override
        public List<GroupStatisticsReviewDTO> statistics(PropertyDTO propertyDTO, List<Review> reviews, Integer statisticsDimension) {
            if (CollectionUtils.isEmpty(reviews)) return Collections.emptyList();
            //根据date、room进行统计
            return IStatisticsReview.statisticsByGroupField(reviews, "room", "travellerType");
        }
    }