package com.pm.sms;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 双通道调度器
 */
public class AlertService {
    private final SmsGateway smsGateway;

    public AlertService(SmsGateway smsGateway) {
        this.smsGateway = smsGateway;
    }

    public void handleDeviceAlert(Device device, String errorCode) {
        String message = String.format(
            "[IBMS报警] %s-%s 发生故障！\n设备：%s\n代码：%s\n时间：%s",
            device.getDeviceCode(),
            device.getDeviceName(),
            device.getBrand(),
            errorCode,
            LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
        );
        
        smsGateway.sendAlert(getRecipientPhone(), message);
    }
    
    private String getRecipientPhone() {
        // 从数据库或配置获取接收人手机号
        return "";
    }
}