package com.jiayue.insu.inclientqn.service.impl;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.jiayue.insu.inclientqn.service.ApiService;
import com.jiayue.insu.inclientqn.service.RecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.*;


/**
 * 预测数据业务实现
 *
 * @author yh
 * @version 1.0
 * @since 2022/5/22 11:29
 */
@Slf4j
@Service
public class ApiServiceImpl implements ApiService {

    @Value("${minio.pull.url}")
    String url;
    @Value("${minio.pull.fileurl}")
    String fileurl;
    @Value("${minio.fileurl}")
    String fileDir;
    @Value("${minio.bucketname}")
    private String bucketName;
    @Value("${minio.postBackUrl}")
    private String postBackUrl;


    @Autowired
    public RecordService recordService;

    /**
     * 从minIo下载文件后，回传状态
     *
     * @param stationCode
     * @param fileName
     * @param type
     * @param status
     */
    @Override
    public void postBackMinIoState(String stationCode, String fileName, String type, String status) {
        Map urlParams = new HashMap(4);
        urlParams.put("stationCode", stationCode);
        urlParams.put("forecastFileName", fileName);
        urlParams.put("type", type);
        urlParams.put("status", status);
        log.debug("回传文件状态给新平台,请求参数", JSONUtil.toJsonStr(urlParams));
        String repose = HttpUtil.post(postBackUrl, urlParams, 10000);
        log.info("回传文件状态给新平台，请求相应 {}", repose);
    }

}
