package com.zksy.base.warning.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zksy.base.warning.mapper.EarlyWarningMapper;
import com.zksy.base.warning.service.IEarlyWarningDisposeEfficiencyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Service
public class EarlyWarningDisposeEfficiencyServiceImpl implements IEarlyWarningDisposeEfficiencyService {

    @Autowired
    private EarlyWarningMapper earlyWarningMapper;

    @Override
    public Map<String, Object> getEfficiencyOverview(LocalDateTime startTime, LocalDateTime endTime, String warningSpecial) {
        return earlyWarningMapper.selectDisposeEfficiencyOverview(startTime, endTime, warningSpecial);
    }

    @Override
    public List<Map<String, Object>> getEfficiencyRange(LocalDateTime startTime, LocalDateTime endTime, String warningSpecial) {
        return earlyWarningMapper.selectDisposeEfficiencyRange(startTime, endTime, warningSpecial);
    }

    @Override
    public List<Map<String, Object>> getEfficiencyBySpecial(LocalDateTime startTime, LocalDateTime endTime) {
        return earlyWarningMapper.selectDisposeEfficiencyBySpecial(startTime, endTime);
    }

    @Override
    public IPage<Map<String, Object>> queryEfficiencyPage(Page<Map<String, Object>> page,
                                                          LocalDateTime startTime,
                                                          LocalDateTime endTime,
                                                          String warningSpecial,
                                                          String sortType) {
        List<Map<String, Object>> list = earlyWarningMapper.selectDisposeEfficiencyList(startTime, endTime, warningSpecial, sortType);
        page.setRecords(list);
        page.setTotal(list.size());
        return page;
    }
}