package com.erp.warehouse.dto;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Builder;

import java.util.List;

/**
 * 库存预警相关DTO
 */
public class StockAlertDTO {

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class AlertItem {
        private Long id;
        private String skuCode;
        private String skuName;
        private Long warehouseId;
        private String warehouseName;
        private Integer quantity;
        private Integer lockedQuantity;
        private Integer reservedQuantity;
        private Integer defectiveQuantity;
        private Integer availableQuantity;
        private Integer warningThreshold;
        private String alertLevel; // warning / critical
        private Integer shortageCount; // 缺口数量
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class AlertSettings {
        private Integer globalThreshold;
        private Boolean enabled;
        private Boolean autoCheckEnabled;
        private Integer checkIntervalMinutes;
        private Boolean notifyOnlyWhenCritical;
        private List<String> alertChannels;
        private Long tenantId;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class AlertNotification {
        private EmailConfig email;
        private DingtalkConfig dingtalk;
        private Long tenantId;

        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        @Builder
        public static class EmailConfig {
            private Boolean enabled;
            private List<String> recipients;
        }

        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        @Builder
        public static class DingtalkConfig {
            private Boolean enabled;
            private String webhookUrl;
            private String secret;
            private List<String> atMobiles;
        }
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class AlertSummary {
        private Integer critical;
        private Integer warning;
        private Integer total;
        private Integer globalThreshold;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class AlertTriggerResult {
        private Integer checked;
        private Integer triggered;
        private List<AlertItem> alerts;
    }
}
