package com.unis.visualization.modular.MonitorAI.service.impl;

import com.unis.visualization.modular.MonitorAI.mapper.MonitorAIMapper;
import com.unis.visualization.modular.MonitorAI.service.MonitorAIService;
import org.springframework.stereotype.Service;

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

@Service
public class MonitorAIServiceImpl implements MonitorAIService {
    @Resource
    private MonitorAIMapper monitorAIMapper;

    @Override
    public Integer selectMonitorCount() {
        return monitorAIMapper.selectMonitorCount();
    }

    @Override
    public Integer selectFaultMonitorCount() {
        return monitorAIMapper.selectFaultMonitorCount();
    }

    @Override
    public Integer selectMonitorProportion() {
        Integer sum = monitorAIMapper.selectMonitorCount();
       Integer sy = monitorAIMapper.selectMonitorProportion();
       Integer proportion =sy/sum *100;
        return proportion;
    }

    @Override
    public List<Map<String,Object>> selectMonitorInsideCount() {
        return monitorAIMapper.selectMonitorInsideCount();
    }

    @Override
    public List<Map<String, Object>> selectCityMonitorCount() {
        return monitorAIMapper.selectCityMonitorCount();
    }

    @Override
    public List<Map<String, Object>> selectKqMonitorCount() {
        return monitorAIMapper.selectKqMonitorCount();
    }

    @Override
    public List<Map<String, Object>> selectException() {
        return monitorAIMapper.selectException();
    }

    @Override
    public List<Map<String, Object>> selectMonitorWarningCount() {
        return monitorAIMapper.selectMonitorWarningCount();
    }

    @Override
    public Map<String, Object> selectMonitorOnlineRate() {
        Map<String, Object> map=new HashMap<>();
        Integer zx = monitorAIMapper.selectMonitorProportion();
        Integer bzx =  monitorAIMapper.selectFaultMonitorCount();
        double total = zx + bzx;
        double proportion = 0.0;

        if (total != 0) {
            proportion = (double) zx / total * 100;
        }

        map.put("zx",zx);
        map.put("bzx",bzx);
        map.put("proportion",proportion);
        return map;
    }

    @Override
    public List<Map<String, Object>> selectMonitorStatistics() {
        return monitorAIMapper.selectMonitorStatistics();
    }

    @Override
    public List<Map<String, Object>> selectEmergencyBusinessStatistics() {
        return monitorAIMapper.selectEmergencyBusinessStatistics();
    }

    @Override
    public List<Map<String, Object>> selectCityEmergencyBusinessStatistics() {
        return monitorAIMapper.selectCityEmergencyBusinessStatistics();
    }

    @Override
    public List<Map<String, Object>> selectDPVSMETStatistics() {
        return monitorAIMapper.selectDPVSMETStatistics();
    }

    @Override
    public List<Map<String, Object>> selectCityDailySupplyCapacity() {
        return monitorAIMapper.selectCityDailySupplyCapacity();
    }

    @Override
    public List<Map<String, Object>> selectDailyInventoryCapacity() {
        return monitorAIMapper.selectDailyInventoryCapacity();
    }

    @Override
    public List<Map<String, Object>> selectDeliveryCapability() {
        return monitorAIMapper.selectDeliveryCapability();
    }
}
