package cn.cecep.talroad.service.impl.analysis;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import cn.cecep.talroad.common.core.utils.DateUtils;
import cn.cecep.talroad.domain.analysis.SRaGasPermittedEmissions;
import cn.cecep.talroad.mapper.analysis.SRaGasPermittedEmissionsMapper;
import cn.cecep.talroad.service.analysis.ISRaGasPermittedEmissionsService;
import cn.cecep.talroad.vo.query.analysis.SRaGasPermittedEmissionsQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;




/**
 * 许可排放量废气明细Service业务层处理
 *
 * @author szhpt
 * @date 2023-06-02*/
@Service
public class SRaGasPermittedEmissionsServiceImpl extends ServiceImpl<SRaGasPermittedEmissionsMapper, SRaGasPermittedEmissions> implements ISRaGasPermittedEmissionsService
{
    @Autowired
    private SRaGasPermittedEmissionsMapper sRaGasPermittedEmissionsMapper;

    /**
     * 查询许可排放量废气明细列表
     *
     * @param sRaGasPermittedEmissions 许可排放量废气明细
     * @return 许可排放量废气明细
     */
    @Override
    public List<SRaGasPermittedEmissions> selectSRaGasPermittedEmissionsList(SRaGasPermittedEmissionsQuery lambdaQueryWrapper)
    {
        if(StringUtils.isBlank(lambdaQueryWrapper.getInvalidDataCalculated())){
            lambdaQueryWrapper.setInvalidDataCalculated("0");
        }
        if(StringUtils.isNotBlank(lambdaQueryWrapper.getDataFlag())){
            lambdaQueryWrapper.setDataFlagArr(Arrays.asList(lambdaQueryWrapper.getDataFlag().split(",")));
        }
        Page<SRaGasPermittedEmissions> page = new Page<>(lambdaQueryWrapper.getPageNum(), lambdaQueryWrapper.getPageSize());
        List<SRaGasPermittedEmissions> list=sRaGasPermittedEmissionsMapper.selectSRaGasPermittedEmissionsListBy(page,lambdaQueryWrapper);
        return list;
    }

    @Override
    public IPage<SRaGasPermittedEmissions> selectSRaGasPermittedEmissionsListBy(SRaGasPermittedEmissionsQuery lambdaQueryWrapper) {
        if(StringUtils.isBlank(lambdaQueryWrapper.getInvalidDataCalculated())){
            lambdaQueryWrapper.setInvalidDataCalculated("0");
        }
        if(StringUtils.isNotBlank(lambdaQueryWrapper.getDataFlag())){
            lambdaQueryWrapper.setDataFlagArr(Arrays.asList(lambdaQueryWrapper.getDataFlag().split(",")));
        }
        Page<SRaGasPermittedEmissions> page = new Page<>(lambdaQueryWrapper.getPageNum(), lambdaQueryWrapper.getPageSize());
        List<SRaGasPermittedEmissions> list=sRaGasPermittedEmissionsMapper.selectSRaGasPermittedEmissionsListBy(page,lambdaQueryWrapper);
        page.setRecords(list);
        return page;
    }

    @Override
    public List<Map<String, Object>> pullMonitorNameOptions(String factoryName) {
        return sRaGasPermittedEmissionsMapper.pullMonitorNameOptions(factoryName);
    }
}
