package com.sckw.slope.detection.consumer;

import com.sckw.core.web.response.HttpResult;
import com.sckw.slope.detection.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author lfdc
 * @description
 * @date 2023-10-26 08:10:45
 */
@Service("test")
public class MqttTdengineCallbackHandler extends AbstractHandler{

    @Autowired
    CommonService commonService;

    @Autowired
     HandlerFactory handlerFactory;

    public HttpResult handle(String topic, String payload) {
        System.out.println(topic);
        // 根据topic分别进行消息处理。
        System.out.println("MqttCallbackHandle:" + topic + "|" + payload);
//        try {
//            AbstractHandler handler = handlerFactory.getHandler(topic);
//            return handler.handle(topic,payload);
//        } catch (Exception e) {
//            return HttpResult.error("MQTT回执类型错误");
////            throw new RuntimeException(e);
//        }
//        if ("ssss".equals(topic)) {
//            Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
//            DevicesAlarm devicesAlarm = JSONObject.parseObject(payload, DevicesAlarm.class);
//            String deviceCode = devicesAlarm.getDeviceCode();
//        }
        System.out.println("处理test");
        return HttpResult.ok();
    }
}

