package cn.cecep.talroad.vo.query;

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.domain.BMainEmissionPollutionAir;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;


/**
 * 企业排放信息-不同污染物年度排放趋势-废气对象 b_main_emission_pollution_air
 *
 * @author szhpt
 * @date 2023-01-31*/
@ApiModel(value = "企业排放信息-不同污染物年度排放趋势-废气")
@EqualsAndHashCode(callSuper = false)
@Data
public class BMainEmissionPollutionAirQuery extends PageQuery
{

    @ApiModelProperty(value = "主键id")
    private String id;
    @ApiModelProperty(value = "企业id")
    private String factoryId;
    @ApiModelProperty(value = "年份")
    private String pollYear;
    @ApiModelProperty(value = "污染类别")
    @NotBlank(message = "请指定污染类别[废气、废水、固废]")
    private String pollutionCategory;
    @NotBlank(message = "请指定数据源[系统核算、执行报告]")
    @ApiModelProperty(value = "数据源")
    private String dataSource;
    @ApiModelProperty(value = "SO2实际排放量")
    private String actuallyEmittingSo2;
    @ApiModelProperty(value = "SO2许可排放量")
    private String allowableEmissionSo2;
    @ApiModelProperty(value = "NOx实际排放量")
    private String actuallyEmittingNox;
    @ApiModelProperty(value = "NOx许可排放量")
    private String allowableEmissionNox;
    @ApiModelProperty(value = "颗粒物实际排放量")
    private String actuallyEmittingPm;
    @ApiModelProperty(value = "颗粒物许可排放量")
    private String allowableEmissionPm;
    @ApiModelProperty(value = "VOCs实际排放量")
    private String actuallyEmittingVocs;
    @ApiModelProperty(value = "VOCs许可排放量")
    private String allowableEmissionVocs;

    @ApiModelProperty(value = "检索开始年份(yyyy)")
    @TableField(exist = false)
    private Integer searchBeginYear;

    @ApiModelProperty(value = "检索截至年份(yyyy)")
    @TableField(exist = false)
    private Integer searchEndYear;

    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<BMainEmissionPollutionAir> createLambdaQueryWrapper(BMainEmissionPollutionAirQuery query) {
        QueryWrapper<BMainEmissionPollutionAir> wrapper = new QueryWrapper<>();
        wrapper.eq(ObjectUtil.isNotNull(query.getId()), "id", query.getId());
        wrapper.eq(ObjectUtil.isNotNull(query.getFactoryId()), "factory_id", query.getFactoryId());
        wrapper.eq(ObjectUtil.isNotNull(query.getPollYear()), "poll_year", query.getPollYear());
        wrapper.eq(ObjectUtil.isNotNull(query.getPollutionCategory()), "pollution_category", query.getPollutionCategory());
        wrapper.eq(ObjectUtil.isNotNull(query.getDataSource()), "data_source", query.getDataSource());
        wrapper.eq(ObjectUtil.isNotNull(query.getActuallyEmittingSo2()), "actually_emitting_so2", query.getActuallyEmittingSo2());
        wrapper.eq(ObjectUtil.isNotNull(query.getAllowableEmissionSo2()), "allowable_emission_so2", query.getAllowableEmissionSo2());
        wrapper.eq(ObjectUtil.isNotNull(query.getActuallyEmittingNox()), "actually_emitting_nox", query.getActuallyEmittingNox());
        wrapper.eq(ObjectUtil.isNotNull(query.getAllowableEmissionNox()), "allowable_emission_nox", query.getAllowableEmissionNox());
        wrapper.eq(ObjectUtil.isNotNull(query.getActuallyEmittingPm()), "actually_emitting_pm", query.getActuallyEmittingPm());
        wrapper.eq(ObjectUtil.isNotNull(query.getAllowableEmissionPm()), "allowable_emission_pm", query.getAllowableEmissionPm());
        wrapper.eq(ObjectUtil.isNotNull(query.getActuallyEmittingVocs()), "actually_emitting_vocs", query.getActuallyEmittingVocs());
        wrapper.eq(ObjectUtil.isNotNull(query.getAllowableEmissionVocs()), "allowable_emission_vocs", query.getAllowableEmissionVocs());
        //检索起止年份
        wrapper.between(ObjectUtil.isNotEmpty(query.getSearchBeginYear()) && ObjectUtil.isNotEmpty(query.getSearchEndYear()), "poll_year", query.getSearchBeginYear()+"", query.getSearchEndYear()+"");
        wrapper.orderByAsc("poll_year");
        return wrapper;
    }
}
