# SvaDailyOperatingStatisticsIndexEnum.java

    package cloud.wconnect.workperformance.cons.sva;

    import cloud.wconnect.commonlib.cons.m3.DailyOperatingStatisticsIndexEnum;
    import cloud.wconnect.workperformance.entity.sva.operatingstatistics.OperatingStatistics;
    import cloud.wconnect.workperformance.entity.sva.operatingstatistics.SvaOperatingStatisticsOriginal;
    import lombok.AllArgsConstructor;
    import lombok.Getter;

    import java.math.BigDecimal;
    import java.util.function.Consumer;
    import java.util.function.Function;

    /**
     * 指标枚举类
     *
     * @author lichen
     * @date 2025/10/14
     */
    @AllArgsConstructor
    @Getter
    public enum SvaDailyOperatingStatisticsIndexEnum {

        /**
         * 已售出的房间数
         */
        ROOMS_RENTED(DailyOperatingStatisticsIndexEnum.ROOMS_RENTED.getIndexName(),
                (dto, value) -> setIntegerValue(value, dto::setRoomsRented),
                (dto, value) -> setIntegerValue(value, dto::setRoomsRented),
                OperatingStatistics::getRoomsRented, SvaOperatingStatisticsOriginal::getRoomsRented),
        /**
         * 房间收入
         */
        ROOM_REV(DailyOperatingStatisticsIndexEnum.ROOM_REV.getIndexName(),
                (dto, value) -> setBigDecimalValue(value, dto::setRoomRev),
                (dto, value) -> setBigDecimalValue(value, dto::setRoomRev),
                OperatingStatistics::getRoomRev, SvaOperatingStatisticsOriginal::getRoomRev),
        /**
         * 食品收入
         */
        FOOD_REV(DailyOperatingStatisticsIndexEnum.FOOD_REV.getIndexName(),
                (dto, value) -> setBigDecimalValue(value, dto::setFoodRev),
                (dto, value) -> setBigDecimalValue(value, dto::setFoodRev),
                OperatingStatistics::getFoodRev, SvaOperatingStatisticsOriginal::getFoodRev),

        /**
         * 饮料收入
         */
        BEVERAGE_REV(DailyOperatingStatisticsIndexEnum.BEVERAGE_REV.getIndexName(),
                (dto, value) -> setBigDecimalValue(value, dto::setBevRev),
                (dto, value) -> setBigDecimalValue(value, dto::setBevRev),
                OperatingStatistics::getBevRev, SvaOperatingStatisticsOriginal::getBevRev),

        /**
         * 其他收入
         */
        OTHER_REV(DailyOperatingStatisticsIndexEnum.OTHER_REV.getIndexName(),
                (dto, value) -> setBigDecimalValue(value, dto::setOtherRev),
                (dto, value) -> setBigDecimalValue(value, dto::setOtherRev),
                OperatingStatistics::getOtherRev, SvaOperatingStatisticsOriginal::getOtherRev),

        /**
         * 入住率
         */
        OCC_PERCENTAGE(DailyOperatingStatisticsIndexEnum.OCC_PERCENTAGE.getIndexName(),
                (dto, value) -> setBigDecimalValue(value, dto::setOccPercent),
                (dto, value) -> setBigDecimalValue(value, dto::setOccPercent),
                OperatingStatistics::getOccPercent, SvaOperatingStatisticsOriginal::getOccPercent),

        /**
         * average revenue per room
         */
        REV_PAR(DailyOperatingStatisticsIndexEnum.REV_PAR.getIndexName(),
                (dto, value) -> setBigDecimalValue(value, dto::setRevPar),
                (dto, value) -> setBigDecimalValue(value, dto::setRevPar),
                OperatingStatistics::getRevPar, SvaOperatingStatisticsOriginal::getRevPar),

        /**
         * 平均房价
         */
        ADR(DailyOperatingStatisticsIndexEnum.ADR.getIndexName(),
                (dto, value) -> setBigDecimalValue(value, dto::setAdr),
                (dto, value) -> setBigDecimalValue(value, dto::setAdr),
                OperatingStatistics::getAdr, SvaOperatingStatisticsOriginal::getAdr),

        /**
         * 总收入
         */
        TOTAL_REV(DailyOperatingStatisticsIndexEnum.TOTAL_REV.getIndexName(),
                (dto, value) -> setBigDecimalValue(value, dto::setTotalRev),
                (dto, value) -> setBigDecimalValue(value, dto::setTotalRev),
                OperatingStatistics::getTotalRev, SvaOperatingStatisticsOriginal::getTotalRev),

        /**
         * F&B II Revenue
         */
        FB2_REV(DailyOperatingStatisticsIndexEnum.FB2_REV.getIndexName(),
                (dto, value) -> setBigDecimalValue(value, dto::setFb2Rev),
                (dto, value) -> setBigDecimalValue(value, dto::setFb2Rev),
                OperatingStatistics::getFb2Rev, SvaOperatingStatisticsOriginal::getFb2Rev);

        /**
         * 指标名称
         */
        private final String indexName;

        /**
         * SvaOperatingStatisticsOriginal 的 Setter 函数式接口
         */
        private final OperatingStatisticsOriginalSetterBiConsumer originalSetter;

        /**
         * OperatingStatistics 的 Setter 函数式接口
         */
        private final OperatingStatisticsSetterBiConsumer setter;

        /**
         * OperatingStatistics 的 Getter 函数式接口
         */
        private final Function<OperatingStatistics, Object> getter;

        /**
         * SvaOperatingStatisticsOriginal 的 Getter 函数式接口
         */
        private final Function<SvaOperatingStatisticsOriginal, Object> originalGetter;

        /**
         * 自定义 Setter 函数式接口
         */
        @FunctionalInterface
        public interface OperatingStatisticsOriginalSetterBiConsumer {
            void accept(SvaOperatingStatisticsOriginal dto, Object value);
        }

        /**
         * 自定义 Setter 函数式接口
         */
        @FunctionalInterface
        public interface OperatingStatisticsSetterBiConsumer {
            void accept(OperatingStatistics dto, Object value);
        }

        /**
         * 获取 OperatingStatistics 的 Getter 函数式接口
         *
         * @param indexName 指标名称
         * @return java.util.function.Function<cloud.wconnect.workperformance.entity.sva.operatingstatistics.OperatingStatistics,java.lang.Object>
         * @author lichen
         * @date 2026/4/14
         */
        public static Function<OperatingStatistics, Object> getOperatingStatisticsGetterFunction(String indexName) {
            for (SvaDailyOperatingStatisticsIndexEnum value : values()) {
                if (value.indexName.equals(indexName)) {
                    return value.getter;
                }
            }
            return null;
        }

        /**
         * 获取 SvaOperatingStatisticsOriginal 的 Getter 函数式接口
         *
         * @param indexName 指标名称
         * @return java.util.function.Function<cloud.wconnect.workperformance.entity.sva.operatingstatistics.SvaOperatingStatisticsOriginal,java.lang.Object>
         * @author lichen
         * @date 2026/4/14
         */
        public static Function<SvaOperatingStatisticsOriginal, Object> getOperatingStatisticsOriginalGetterFunction(String indexName) {
            for (SvaDailyOperatingStatisticsIndexEnum value : values()) {
                if (value.indexName.equals(indexName)) {
                    return value.originalGetter;
                }
            }
            return null;
        }

        /**
         * 获取 SvaOperatingStatisticsOriginal 的 Setter 函数式接口
         *
         * @param indexName 指标名称
         * @return cloud.wconnect.workperformance.cons.sva.SvaDailyOperatingStatisticsIndexEnum.OperatingStatisticsOriginalSetterBiConsumer
         * @author lichen
         * @date 2026/4/14
         */
        public static OperatingStatisticsOriginalSetterBiConsumer getOperatingStatisticsOriginSetterFunction(String indexName) {
            for (SvaDailyOperatingStatisticsIndexEnum value : values()) {
                if (value.indexName.equals(indexName)) {
                    return value.originalSetter;
                }
            }
            return null;
        }

        /**
         * 获取 OperatingStatistics 的 Setter 函数式接口
         *
         * @param indexName 指标名称
         * @return cloud.wconnect.workperformance.cons.sva.SvaDailyOperatingStatisticsIndexEnum.OperatingStatisticsSetterBiConsumer
         * @author lichen
         * @date 2026/4/14
         */
        public static OperatingStatisticsSetterBiConsumer getOperatingStatisticsSetterFunction(String indexName) {
            for (SvaDailyOperatingStatisticsIndexEnum value : values()) {
                if (value.indexName.equals(indexName)) {
                    return value.setter;
                }
            }
            return null;
        }

        /**
         * 安全设置 BigDecimal 值
         *
         * @param value  值（可能是 BigDecimal 或其他数值类型）
         * @param setter setter 方法引用
         */
        private static void setBigDecimalValue(Object value, Consumer<BigDecimal> setter) {
            if (value == null) {
                setter.accept(null);
            } else if (value instanceof BigDecimal) {
                setter.accept((BigDecimal) value);
            } else if (value instanceof Number) {
                setter.accept(new BigDecimal(value.toString()));
            } else {
                throw new IllegalArgumentException("Unsupported value type for BigDecimal: " + value.getClass().getName());
            }
        }

        /**
         * 安全设置 Integer 值
         *
         * @param value  值（可能是 Integer、BigDecimal 或其他数值类型）
         * @param setter setter 方法引用
         */
        private static void setIntegerValue(Object value, Consumer<Integer> setter) {
            if (value == null) {
                setter.accept(null);
            } else if (value instanceof Integer) {
                setter.accept((Integer) value);
            } else if (value instanceof BigDecimal) {
                setter.accept(((BigDecimal) value).intValue());
            } else if (value instanceof Number) {
                setter.accept(((Number) value).intValue());
            } else {
                throw new IllegalArgumentException("Unsupported value type for Integer: " + value.getClass().getName());
            }
        }

    }