package com.citygis.web.service.impl;

import com.citygis.common.core.domain.AjaxResult;
import com.citygis.web.domain.JKVo;
import com.citygis.web.domain.JKindex;
import com.citygis.web.mapper.KafkaJKMapper;
import com.citygis.web.service.KafkaJKService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class KafkaJKServiceImpl implements KafkaJKService {

    @Resource
    KafkaJKMapper kafkaJKMapper;

//    @Override
//    public AjaxResult getTopicmsg(Integer pageNumber, Integer pageSize) {
//        List<TopicMsg> topicmsg = kafkaJKMapper.getTopicmsg();
//        return AjaxResult.success(topicmsg);
//    }

    @Override
    public AjaxResult getAllJkIndex(JKVo jkVo) {
        Map<String, Object> map = new HashMap<>();

        List<JKindex> consumerMsg = kafkaJKMapper.queryConsumerMsg(jkVo);
        map.put("消费消息条数", consumerMsg);
        List<JKindex> endOffsetMsg = kafkaJKMapper.queryEndOffsetMsg(jkVo);
        map.put("生产条数", endOffsetMsg);
        List<JKindex> perSecMsgOut = kafkaJKMapper.queryPerSecMsgOut(jkVo);
        map.put("消费流量", perSecMsgOut);
        List<JKindex> perSecMsgIn = kafkaJKMapper.queryPerSecMsgIn(jkVo);
        map.put("生产流量", perSecMsgIn);
        List<JKindex> topicSize = kafkaJKMapper.queryTopicSize(jkVo);
        map.put("占用磁盘空间总量", topicSize);
        List<JKindex> inXL = kafkaJKMapper.queryInXL(jkVo);
        map.put("生产限流", inXL);
        List<JKindex> outXL = kafkaJKMapper.queryOutXL(jkVo);
        map.put("消费限流", outXL);
        List<JKindex> lagMsg = kafkaJKMapper.queryLagMsg(jkVo);
        map.put("未消费消息数", lagMsg);
        List<JKindex> consumerSpeed = kafkaJKMapper.queryConsumerSpeed(jkVo);
        map.put("消息速率", consumerSpeed);

        return AjaxResult.success(map);

    }
}
