package cn.cecep.talroad.vo.query;

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.domain.BMainEmissionSourceAir;
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_source_air
 *
 * @author szhpt
 * @date 2023-01-31*/
@ApiModel(value = "企业排放信息-多来源排放量对比-废气")
@EqualsAndHashCode(callSuper = false)
@Data
public class BMainEmissionSourceAirQuery extends PageQuery
{

    @ApiModelProperty(value = "主键id")
    private String id;
    @ApiModelProperty(value = "企业id")
    @NotBlank(message = "请指定查询企业主键ID")
    private String factoryId;
    @ApiModelProperty(value = "年份")
    private String pollYear;
    @ApiModelProperty(value = "污染物类别")
    @NotBlank(message = "请指定污染物类别[COD、VOCs...]")
    private String pollutionCategory;
    @ApiModelProperty(value = "SO2系统核算排放量")
    private String systematicAccountingSo2;
    @ApiModelProperty(value = "SO2执行报告排放量")
    private String actionReportsSo2;
    @ApiModelProperty(value = "SO2许可排放量")
    private String permissionSo2;

    @ApiModelProperty(value = "污染类别[废水、废气]")
    @NotBlank(message = "请指定污染类别[废水、废气]")
    @TableField(exist = false)
    private String facts;

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

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

    public BMainEmissionSourceAirQuery(String pollutionCategory,Integer searchBeginYear, Integer searchEndYear) {
        this.pollutionCategory = pollutionCategory;
        this.searchBeginYear = searchBeginYear;
        this.searchEndYear = searchEndYear;
    }

    public BMainEmissionSourceAirQuery() {
    }

    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<BMainEmissionSourceAir> createLambdaQueryWrapper(BMainEmissionSourceAirQuery query) {
        QueryWrapper<BMainEmissionSourceAir> 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.getSystematicAccountingSo2()), "systematic_accounting_so2", query.getSystematicAccountingSo2());
        wrapper.eq(ObjectUtil.isNotNull(query.getActionReportsSo2()), "action_reports_so2", query.getActionReportsSo2());
        wrapper.eq(ObjectUtil.isNotNull(query.getPermissionSo2()), "permission_so2", query.getPermissionSo2());
        //检索起止年份
        wrapper.between(ObjectUtil.isNotEmpty(query.getSearchBeginYear()) && ObjectUtil.isNotEmpty(query.getSearchEndYear()), "poll_year", query.getSearchBeginYear()+"", query.getSearchEndYear()+"");
        wrapper.orderByAsc("poll_year");
        return wrapper;
    }
}
