package com.erp.inventory.service;

import com.erp.inventory.dto.*;
import com.erp.inventory.entity.StockWarningRecord;
import com.erp.inventory.entity.StockWarningRule;

import java.util.List;
import com.erp.common.core.model.PageResponse;

/**
 * 库存预警规则服务接口
 */
public interface StockWarningRuleService {

    // ==================== 规则管理 ====================

    /**
     * 创建预警规则
     */
    StockWarningRule createRule(StockWarningRuleRequest request);

    /**
     * 更新预警规则
     */
    StockWarningRule updateRule(Long id, StockWarningRuleRequest request);

    /**
     * 删除预警规则
     */
    void deleteRule(Long id);

    /**
     * 获取预警规则详情
     */
    StockWarningRuleDTO getRuleById(Long id);

    /**
     * 分页查询预警规则
     */
    PageResponse<StockWarningRuleDTO> listRules(String ruleType, String ruleName, Integer enabled, Long warehouseId, Integer page, Integer limit);

    /**
     * 启用/禁用规则
     */
    StockWarningRule toggleRule(Long id, Boolean enabled);

    // ==================== 规则匹配 ====================

    /**
     * 根据SKU和仓库获取匹配的预警规则
     */
    List<StockWarningRule> getMatchedRules(String skuCode, Long warehouseId);

    /**
     * 获取所有启用的预警规则
     */
    List<StockWarningRule> getAllEnabledRules();

    // ==================== 预警记录 ====================

    /**
     * 创建预警记录
     */
    StockWarningRecord createWarningRecord(String skuCode, String skuName, Long warehouseId, String warehouseName,
                                            StockWarningRule rule, Integer currentQuantity, Integer availableQuantity);

    /**
     * 分页查询预警记录
     */
    PageResponse<StockWarningRecordDTO> listWarningRecords(StockWarningRecordQueryDTO query);

    /**
     * 确认预警
     */
    StockWarningRecord acknowledgeWarning(Long id);

    /**
     * 解决预警
     */
    StockWarningRecord resolveWarning(Long id, String remark);

    /**
     * 忽略预警
     */
    StockWarningRecord ignoreWarning(Long id);

    /**
     * 获取待处理预警数量
     */
    Integer getPendingWarningCount();

    // ==================== 预警统计 ====================

    /**
     * 获取预警统计
     */
    StockWarningStatsDTO getWarningStats(String startDate, String endDate);

    // ==================== 预警通知配置 ====================

    /**
     * 更新通知配置
     */
    StockWarningRule updateNotificationConfig(WarningNotificationConfigRequest request);

    /**
     * 测试通知
     */
    void testNotification(Long ruleId, String method);
}
