# HotelKpiMetricsEnum.java

    package cloud.wconnect.workperformance.cons.hotelkpi;

    import lombok.AllArgsConstructor;
    import lombok.Getter;

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

    /**
     * Enum: 指标枚举类
     *
     * @author zc
     * @date 2024/06/24
     */
    @Getter
    @AllArgsConstructor
    public enum HotelKpiMetricsEnum {

        /**
         * Guest love Compliance
         */
        GUESTLOVE_COMPLIANCE(1, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * OSAT
         */
        OSAT(2, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Social Overall
         */
        SOCIAL_OVERALL(3, HotelKpiDataRangeTypeCons.MTD, List.of()),

        // GSI
        GSI(4, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Medallia Response Direct
         */
        MEDALLIA_RESPONSE_DIRECT(5, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Overall Service
         */
        OVERALL_SERVICE(6, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Problem Handling
         */
        PROBLEM_HANDLING(7, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Overall Arrival
         */
        OVERALL_ARRIVAL(8, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Loyalty Recognition
         */
        LOYALTY_RECOGNITION(9, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Staff Friendliness
         */
        STAFF_FRIENDLINESS(10, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Enrollment
         */
        ENROLLMENT(11, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Quore - Complaint
         */
        QUORE_COMPLAINT(12, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Kipsu - Conversation
         */
        KIPSU_CONVERSATION(13, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Kipsu - Response Time
         */
        KIPSU_RESPONSE_TIME(14, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Guest Room Cleanliness
         */
        GUEST_ROOM_CLEANLINESS(15, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Quore - Cleanings Checkout Inspected
         */
        QUORE_CLEANINGS_CHECKOUT_INSPECTED(16, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Quore - Deep Clean
         */
        QUORE_DEEP_CLEAN(17, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Guest Room Condition
         */
        GUEST_ROOM_CONDITION(18, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Quore - Guest Room PM
         */
        QUORE_GR_PM(19, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * FW Inspection - GR PM
         */
        FW_INSPECTION_GR_PM(20, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * FW Inspection - Hotel
         */
        FW_INSPECTION_HOTEL(21, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Overall F&B
         */
        OVERALL_F_B(22, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Breakfast
         */
        BREAKFAST(23, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Loss of Revenue Adjustment
         */
        LOSS_OF_REVENUE_ADJUSTMENT(24, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Staffing Level - Full time
         */
        STAFFING_LEVEL_FULL_TIME(25, HotelKpiDataRangeTypeCons.WTD, List.of()),

        /**
         * Overtime Expense
         */
        OVERTIME_EXPENSE(26, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * MPR (HK Efficiency)
         */
        MPR(27, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * Sellout Efficiency
         */
        SELLOUT_EFFICIENCY(28, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * FTE
         */
        FTE(29, HotelKpiDataRangeTypeCons.MTD, List.of()),

        /**
         * GOP
         */
        GOP(30, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of()),

        /**
         * TOTAL REVENUE
         */
        TOTAL_REVENUE(31, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of()),

        /**
         * RM REVENUE
         */
        RM_REVENUE(32, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of("31", "")),

        /**
         * OCC
         */
        OCC(33, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of("35", "35")),

        /**
         * ADR
         */
        ADR(34, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of("35", "35")),

        /**
         * REVPAR
         */
        REVPAR(35, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of()),

        /**
         * MPI
         */
        MPI(36, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of()),

        /**
         * ARI
         */
        ARI(37, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of()),

        /**
         * RGI
         */
        RGI(38, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of()),

        /**
         * F&B RESTAURANT
         */
        FB_RESTAURANT(39, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of("", "43")),

        /**
         * F&B BANQUET
         */
        FB_BANQUET(40, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of("", "43")),

        /**
         * F&B REVENUE
         */
        FB_REVENUE(41, HotelKpiDataRangeTypeCons.MTD, List.of("31", "")),

        /**
         * OTHER REVENUE
         */
        OTHER_REVENUE(42, HotelKpiDataRangeTypeCons.MTD, List.of("31", "")),

        /**
         * F&B TOTAL
         */
        FB_TOTAL(43, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of()),

        /**
         * Flow Through %
         */
        FLOW_THROUGH(44, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of()),

        /**
         * CPOR
         */
        CPOR(45, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of()),

        /**
         * Room Other
         */
        RM_OTHER(46, HotelKpiDataRangeTypeCons.WHOLE_MONTH, List.of("31", ""));

        /**
         * 指标类型
         */
        private final int metricsType;

        /**
         * 周数据范围类型
         */
        private final int weekDataRangeType;

        /**
         * 关联指标类型
         */
        private final List<String> relationalMetricsTypes;

        /**
         * 获取标题
         *
         * @param metricsType 指标类型
         * @return int
         * @author zc
         * @date 2024/12/30
         */
        public static int getDataRangeType(int metricsType) {
            return Arrays.stream(HotelKpiMetricsEnum.values()).filter(item ->
                            item.getMetricsType() == metricsType).findFirst()
                    .map(HotelKpiMetricsEnum::getWeekDataRangeType).orElse(HotelKpiDataRangeTypeCons.MTD);
        }

        /**
         * 获取关联的指标类型
         *
         * @param metricsType 指标类型
         * @param dateType    日期类型
         * @return java.util.List<java.lang.Integer>
         * @author zc
         * @date 2025/8/20
         */
        public static List<Integer> getRelationalMetricsTypes(int metricsType, int dateType) {
            List<String> relationalMetricsTypes = Arrays.stream(HotelKpiMetricsEnum.values()).filter(item ->
                            item.getMetricsType() == metricsType).findFirst()
                    .map(HotelKpiMetricsEnum::getRelationalMetricsTypes).orElse(Collections.emptyList());
            if (relationalMetricsTypes.size() != 2) {
                return Collections.emptyList();
            }
            int index = (HotelKpiDateTypeCons.WEEKLY == dateType) ? 0 : 1;
            return Arrays.stream(relationalMetricsTypes.get(index).split(","))
                    .filter(s -> !s.isBlank()).map(Integer::valueOf).toList();
        }

        /**
         * 反向获取关联的指标类型
         *
         * @param metricsType 指标类型
         * @param dateType    日期类型
         * @return java.util.List<java.lang.Integer>
         * @author zc
         * @date 2025/8/20
         */
        public static List<Integer> getRelationalMetricsTypesReverse(int metricsType, int dateType) {
            int index = (HotelKpiDateTypeCons.WEEKLY == dateType) ? 0 : 1;
            return Arrays.stream(HotelKpiMetricsEnum.values()).filter(item -> {
                List<String> metricsTypes = item.getRelationalMetricsTypes();
                if (metricsTypes.size() != 2) {
                    return false;
                }
                return Arrays.stream(metricsTypes.get(index).split(","))
                        .filter(s -> !s.isBlank())
                        .map(Integer::valueOf).toList().contains(metricsType);
            }).map(HotelKpiMetricsEnum::getMetricsType).toList();
        }

    }