package com.mvc.forwarmana;

import com.alibaba.fastjson.JSON;
import com.mvc.model.TAireadModel;
import com.mvc.model.forwarding.*;
import com.mvc.utils.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 丰台水务局
 */
@Component
public class FTForwarder {
    private static Logger log = LoggerFactory.getLogger(FTForwarder.class);
    public void reportdata(DicForwarderModel forwarderModel, TAireadModel aireadModel) {
        //**以机井编码为匹配依据 2024-06-21 guozhao
        try {
            FTRequestModel data = new FTRequestModel(aireadModel);
            /*if(data.getDeviceId().equals("106010020003")){
                data.setDeviceId("106018202018");
                data.setFlow(26988F);
            }*/
            String json = JSON.toJSONString(data);
            //使用warn是发现info日志0点不全,暂用warn观察 2024-06-15 guozhao
            log.warn("{}请求参数：{}", forwarderModel.getServerName(), json);
            String response = HttpUtil.postData(forwarderModel.getServerIp(), data);

            /*ResultMap<FTResponseModel> resultMap = JSON.parseObject(response, new TypeReference<>() {
            });*/
            log.warn("{}API返回结果：{}", forwarderModel.getServerName(), response);
        } catch (Exception ex) {
            log.warn(forwarderModel.getServerName(), ex);
        }
    }
}
