package com.tofly.watermeter.custom.service.meterBusiness.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.watermeter.custom.entity.meterBusiness.dto.DisputedConditionDto;
import com.tofly.watermeter.custom.mapper.meterBusiness.DisputedMapper;
import com.tofly.watermeter.custom.service.meterBusiness.DisputedService;
import com.tofly.watermeter.custom.service.meterBusiness.export.ExportCommonCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@Service
public class DisputedServiceImpl implements DisputedService {

    @Autowired
    private DisputedMapper disputedMapper;
    @Autowired
    private ExportCommonCodeService exportCommonCodeService;

    /**
     * 争议检定统计
     *
     * @param response response
     * @param dto      dto
     * @return list
     */
    @Override
    public List<Map> count(HttpServletResponse response, DisputedConditionDto dto) {
        List<Map> result = disputedMapper.count(dto);
        if (dto.getExport() == 1) {
            exportCommonCodeService.exportCode(response, "disputedCountService", result);
        }
        return result;
    }

    @Override
    public Page<Map> queryWorkInfo(HttpServletResponse response, Page page, DisputedConditionDto dto) {

        if (dto.getExport() == 1){
            exportCommonCodeService.exportCode(response,"disQueryWorkInfoService",disputedMapper.queryWorkInfo(dto));
        }
        return disputedMapper.queryWorkInfo(page, dto);
    }


    @Override
    public List<Map> queryInfo(HttpServletResponse response, Page page, DisputedConditionDto dto) {
        return disputedMapper.queryDisPutInfo(dto);
    }
}
