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.IEarlyWarningReceiveEfficiencyService;
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 EarlyWarningReceiveEfficiencyServiceImpl implements IEarlyWarningReceiveEfficiencyService {

    @Autowired
    private EarlyWarningMapper earlyWarningMapper;

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

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

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

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