package cn.cecep.talroad.vo.query;

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.domain.BMainEmissionPollutionWater;
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;


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

    @ApiModelProperty(value = "主键id")
    private String id;
    @ApiModelProperty(value = "企业id")
    private String factoryId;
    @ApiModelProperty(value = "年份")
    private String pollYear;
    @ApiModelProperty(value = "污染类别")
    private String pollutionCategory;
    @ApiModelProperty(value = "数据源")
    private String dataSource;
    @ApiModelProperty(value = "COD实际排放量")
    private String actuallyEmittingCod;
    @ApiModelProperty(value = "COD许可排放量")
    private String allowableEmissionCod;
    @ApiModelProperty(value = "氨氮实际排放量")
    private String actuallyEmittingNhn;
    @ApiModelProperty(value = "氨氮许可排放量")
    private String allowableEmissionNhn;
    @ApiModelProperty(value = "总氮实际排放量")
    private String actuallyEmittingTn;
    @ApiModelProperty(value = "总氮许可排放量")
    private String allowableEmissionTn;
    @ApiModelProperty(value = "总磷实际排放量")
    private String actuallyEmittingTp;
    @ApiModelProperty(value = "总磷许可排放量")
    private String allowableEmissionTp;

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

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

    public BMainEmissionPollutionWaterQuery(String pollutionCategory, String dataSource, Integer searchBeginYear, Integer searchEndYear, String factoryId) {
        this.pollutionCategory = pollutionCategory;
        this.dataSource = dataSource;
        this.searchBeginYear = searchBeginYear;
        this.searchEndYear = searchEndYear;
        this.factoryId = factoryId;
    }

    public BMainEmissionPollutionWaterQuery() {
    }

    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<BMainEmissionPollutionWater> createLambdaQueryWrapper(BMainEmissionPollutionWaterQuery query) {
        QueryWrapper<BMainEmissionPollutionWater> 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.getActuallyEmittingCod()), "actually_emitting_cod", query.getActuallyEmittingCod());
        wrapper.eq(ObjectUtil.isNotNull(query.getAllowableEmissionCod()), "allowable_emission_cod", query.getAllowableEmissionCod());
        wrapper.eq(ObjectUtil.isNotNull(query.getActuallyEmittingNhn()), "actually_emitting_nhn", query.getActuallyEmittingNhn());
        wrapper.eq(ObjectUtil.isNotNull(query.getAllowableEmissionNhn()), "allowable_emission_nhn", query.getAllowableEmissionNhn());
        wrapper.eq(ObjectUtil.isNotNull(query.getActuallyEmittingTn()), "actually_emitting_tn", query.getActuallyEmittingTn());
        wrapper.eq(ObjectUtil.isNotNull(query.getAllowableEmissionTn()), "allowable_emission_tn", query.getAllowableEmissionTn());
        wrapper.eq(ObjectUtil.isNotNull(query.getActuallyEmittingTp()), "actually_emitting_tp", query.getActuallyEmittingTp());
        wrapper.eq(ObjectUtil.isNotNull(query.getAllowableEmissionTp()), "allowable_emission_tp", query.getAllowableEmissionTp());
        //检索起止年份
        wrapper.between(ObjectUtil.isNotEmpty(query.getSearchBeginYear()) && ObjectUtil.isNotEmpty(query.getSearchEndYear()), "poll_year", query.getSearchBeginYear()+"", query.getSearchEndYear()+"");
        wrapper.orderByAsc("poll_year");
        return wrapper;
    }

}
