package cn.cecep.talroad.vo.query;

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.domain.BMainEmissionSourceWater;
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_source_water
 *
 * @author szhpt
 * @date 2023-01-31*/
@ApiModel(value = "企业排放信息-多来源排放量对比-废水")
@EqualsAndHashCode(callSuper = false)
@Data
public class BMainEmissionSourceWaterQuery 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 = "COD系统核算排放量")
    private String systematicAccountingCod;
    @ApiModelProperty(value = "COD执行报告排放量")
    private String actionReportsCod;
    @ApiModelProperty(value = "COD许可排放量")
    private String permissionCod;

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

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

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

    public BMainEmissionSourceWaterQuery() {
    }

    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<BMainEmissionSourceWater> createLambdaQueryWrapper(BMainEmissionSourceWaterQuery query) {
        QueryWrapper<BMainEmissionSourceWater> 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.getSystematicAccountingCod()), "systematic_accounting_cod", query.getSystematicAccountingCod());
        wrapper.eq(ObjectUtil.isNotNull(query.getActionReportsCod()), "action_reports_cod", query.getActionReportsCod());
        wrapper.eq(ObjectUtil.isNotNull(query.getPermissionCod()), "permission_cod", query.getPermissionCod());
        //检索起止年份
        wrapper.between(ObjectUtil.isNotEmpty(query.getSearchBeginYear()) && ObjectUtil.isNotEmpty(query.getSearchEndYear()), "poll_year", query.getSearchBeginYear()+"", query.getSearchEndYear()+"");
        wrapper.orderByAsc("poll_year");
        return wrapper;
    }
}
