package com.sptg.device.biz.service;

import java.util.List;
import java.util.Map;

import com.sptg.common.core.enums.InstructDH;
import com.sptg.device.api.entity.InstructPublishLog;
import org.springframework.scheduling.annotation.Async;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.sptg.common.core.entity.PublishTask;
import com.sptg.common.core.enums.Instruct;
import com.sptg.device.api.entity.Device;

/**
 *
 *
 * description: 消息推送接口
 */
public interface MsgPublishService {

    /**
     * 任务详情
     * @param task 消息内容
     */
    void publishTask(PublishTask task);

    /**
     * 下发消息
     * @param obj 消息内容
     * @param device 设备信息{ serialNumber：必填,mqConf：必填 }
     * @param instruct 指令
     */
    void publish(Object obj, Device device, Instruct instruct, Map<String,String> m);

    /**
     * 下发消息
     * @param obj 消息内容
     * @param device 设备信息{ serialNumber：必填,mqConf：必填 }
     * @param instruct 指令
     */
    void topicMsgPublish(Object obj, Device device, InstructDH instruct, Map<String,String> m);

    /**
     * 异步下发
     * @param obj 消息内容
     * @param device 设备信息{ serialNumber：必填 }
     * @param instruct 指令
     */
    @Async
    default void asyncPublish(Object obj,Device device,Instruct instruct, Map<String,String> m){
        this.publish(obj,device,instruct,m);
    }

    /**
     * 主题消息异步下发
     * @param obj 消息内容
     * @param device 设备信息{ serialNumber：必填 }
     * @param instruct 指令
     */
    @Async
    default void topicMsgAsyncPublish(Object obj, Device device, InstructDH instruct, Map<String,String> map){
        this.topicMsgPublish(obj,device,instruct,map);
    }

    /**
     * 将被修改的设备信息同步到设备上
     * @param wrapper 查询条件
     */
    void batchEditDevice(Wrapper<Device> wrapper);

    /**
     * 批量下发
     * @param obj 消息内容
     * @param deviceList 设备列表
     * @param instruct 指令
     */
    void batchPushInstruct(Object obj, List<Device> deviceList, Instruct instruct, Map<String,String> map);

    /**
     * 批量数据下发到单个设备
     * @param obj 消息内容
     * @param device 设备
     * @param instruct 指令
     */
    void batchPushInstruct(Object obj, Device device, Instruct instruct);

    /**
     * 大豪批量下发
     * @param obj 消息内容
     * @param device 设备列表
     * @param instruct 指令
     */
    void topicMsgBatchPushInstruct(Object obj, Device device, InstructDH instruct, Map<String,String> map);

    /**
     * 指令重新下发，非大豪设备
     * @param obj
     * @param serialNumber
     * @param instructPublishLog
     */
    @Async
    default void asyncResendInstruct(Object obj, String serialNumber, InstructPublishLog instructPublishLog){
        this.resendInstruct(obj,serialNumber,instructPublishLog);
    }

    /**
     * 指令重新下发，非大豪设备
     * @param obj
     * @param serialNumber
     * @param instructPublishLog
     */
    void resendInstruct(Object obj, String serialNumber, InstructPublishLog instructPublishLog);

    /**
     * 大豪设备指令重新下发
     * @param obj
     * @param serialNumber
     * @param instructPublishLog
     */
    @Async
    default void asyncResendInstructDH(Object obj, String serialNumber, InstructPublishLog instructPublishLog){
        this.resendInstructDH(obj,serialNumber,instructPublishLog);
    }

    /**
     * 大豪设备指令重新下发
     * @param obj
     * @param serialNumber
     * @param instructPublishLog
     */
    void resendInstructDH(Object obj, String serialNumber, InstructPublishLog instructPublishLog);
}
