package com.tuoheng.admin.tzhl.service.fly.onlineuav;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.tzhl.constant.TZHLConstant;
import com.tuoheng.admin.tzhl.request.TZHLFlyDataRequest;
import com.tuoheng.admin.tzhl.response.TZHLFlyDataResponse;
import com.tuoheng.admin.tzhl.response.TZHLOnlineUavResponse;
import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService;
import com.tuoheng.common.core.utils.RedisUtils;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Slf4j
@Service
public class OnlineUavService {

    @Autowired
    private RedisUtils redisUtils;

    @Autowired
    @Qualifier("restTemplate")
    private RestTemplate restTemplate;

    @Autowired
    private CallTianYiPlatformService callTianYiPlatformService;

    public TZHLOnlineUavResponse getOnlineUav() {
        String apiPath = TZHLConstant.TIAN_YI_API_FLIGHT_SCREEN;
        String dataJson = callTianYiPlatformService.callGet(apiPath, null);
        if (StringUtils.isEmpty(dataJson)) {
            return null;
        }
        TZHLOnlineUavResponse onlineUavResponse = JSON.parseObject(dataJson, TZHLOnlineUavResponse.class);
        if (ObjectUtil.isEmpty(onlineUavResponse)) {
            return null;
        }
        return onlineUavResponse;
    }


}
