package com.jiayue.ipfcst.console.controller;

import com.jiayue.ipfcst.dataexchange.container.ProtocolTunnelContainer;
import com.jiayue.ipfcst.dataexchange.service.FileParseTunnelService;
import com.jiayue.ipfcst.fileupload.util.FileConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 接口服务类
 *
 * @author xsl
 * @version 3.0
 */
@RestController
@RequestMapping("consoleOpenInterface")
@Slf4j
public class ConsoleOpenInterfaceController {
  @Autowired
  FileParseTunnelService fileParseTunnelService;

  /**
   * 首页通道状态接口
   *
   * @return
   */
  @RequestMapping(value = "/getChannelStatus")
  public Map getChannelStatus() {
    Map channelMap = new HashMap<>();

    /**
     * 接入通道状态 dataexchangeMap
     * 回传通道状态 callBackMap
     * 解析通道状态 analysisMap
     */
    Map tunnelStatus = ProtocolTunnelContainer.getInstance().getStatus4Display();
    channelMap.putAll(tunnelStatus);
    try {
      ((Map) channelMap.get("dataexchangeMap")).putAll(fileParseTunnelService.getFileParseTunnelStatus());
    }catch (Exception e){

    }
    // 上报文件通道状态
    channelMap.put("uploadFileMap", FileConstant.channelStatusMap);
    return channelMap;
  }
}
