package cn.cecep.talroad.vo.query.effective;

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.domain.effective.MGovernanceTechnologyEstimateFacilities;
import cn.cecep.talroad.domain.effective.MGovernanceTechnologyEstimateFactory;
import cn.cecep.talroad.domain.effective.MGovernanceTechnologyEstimateProcedure;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.seata.common.util.CollectionUtils;
import io.seata.common.util.StringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
public class MGovernanceTechnologyEstimateQuery extends PageQuery {
    @ApiModelProperty(value="企业名称集合")
    private List<String> factoryNames;

    @ApiModelProperty(value="行业类别")
    private List<String> industryCategories;

    @ApiModelProperty(value="县名称")
    private List<String> countryNames;

    @ApiModelProperty(value="评估结果")
    private String administerResults;

    @ApiModelProperty(value="治理技术")
    private String governanceTechnology;

    @ApiModelProperty(value="治理设施")
    private List<String> governanceFacilities;

    @ApiModelProperty(value="工序")
    private List<String> procedures;

    @ApiModelProperty(value="季度：1，2，3，4")
    private String quarter;

    @ApiModelProperty(value="年份")
    private String year;
    @ApiModelProperty(value="必填项：设施类型  1：脱硫设施，2：脱硝设施，3：除尘设施")
    private Integer type;

    @ApiModelProperty(value="必填项：分析纬度  1==企业维度，2==治理设施维度，3==工序维度")
    private Integer analyzeLatitude;

    private String selectName;

    public static QueryWrapper<MGovernanceTechnologyEstimateFactory> createFactoryWrapper(MGovernanceTechnologyEstimateQuery query){
        QueryWrapper<MGovernanceTechnologyEstimateFactory> wrapper= Wrappers.query();
        wrapper.in(CollectionUtils.isNotEmpty(query.getFactoryNames()),"factory_name",query.getFactoryNames());
        wrapper.in(CollectionUtils.isNotEmpty(query.getCountryNames()),"country_name",query.getCountryNames());
        wrapper.in(CollectionUtils.isNotEmpty(query.getIndustryCategories()),"industry_category",query.getIndustryCategories());
        wrapper.eq(StringUtils.isNotEmpty(query.getGovernanceTechnology()),"governance_technology",query.getGovernanceTechnology());
        wrapper.eq(StringUtils.isNotEmpty(query.getAdministerResults()),"administer_results",query.getAdministerResults());
        wrapper.eq(StringUtils.isNotEmpty(query.getYear()),"year",query.getYear());
        wrapper.eq(StringUtils.isNotEmpty(query.getQuarter()),"quarter",query.getQuarter());
        wrapper.eq(query.getType()!=null,"type",query.getType());
        wrapper.orderByDesc("factory_name","governance_technology");
        return wrapper;
    }

    public static QueryWrapper<MGovernanceTechnologyEstimateFacilities> createFacilitiesWrapper(MGovernanceTechnologyEstimateQuery query) {
        QueryWrapper<MGovernanceTechnologyEstimateFacilities> wrapper= Wrappers.query();
        wrapper.in(CollectionUtils.isNotEmpty(query.getFactoryNames()),"factory_name",query.getFactoryNames());
        wrapper.in(CollectionUtils.isNotEmpty(query.getCountryNames()),"country_name",query.getCountryNames());
        wrapper.in(CollectionUtils.isNotEmpty(query.getIndustryCategories()),"industry_category",query.getIndustryCategories());
        wrapper.in(CollectionUtils.isNotEmpty(query.getGovernanceFacilities()),"governance_facilities",query.getGovernanceFacilities());
        wrapper.eq(StringUtils.isNotEmpty(query.getGovernanceTechnology()),"governance_technology",query.getGovernanceTechnology());
        wrapper.eq(StringUtils.isNotEmpty(query.getAdministerResults()),"administer_results",query.getAdministerResults());
        wrapper.eq(StringUtils.isNotEmpty(query.getYear()),"year",query.getYear());
        wrapper.eq(StringUtils.isNotEmpty(query.getQuarter()),"quarter",query.getQuarter());
        wrapper.eq(query.getType()!=null,"type",query.getType());
        wrapper.orderByDesc("factory_name","governance_technology");
        return wrapper;
    }

    public static QueryWrapper<MGovernanceTechnologyEstimateProcedure> createProcedureWrapper(MGovernanceTechnologyEstimateQuery query) {
        QueryWrapper<MGovernanceTechnologyEstimateProcedure> wrapper= Wrappers.query();
        wrapper.in(CollectionUtils.isNotEmpty(query.getProcedures()),"procedure",query.getProcedures());
        wrapper.in(CollectionUtils.isNotEmpty(query.getCountryNames()),"country_name",query.getCountryNames());
        wrapper.in(CollectionUtils.isNotEmpty(query.getIndustryCategories()),"industry_category",query.getIndustryCategories());
        wrapper.eq(StringUtils.isNotEmpty(query.getGovernanceTechnology()),"governance_technology",query.getGovernanceTechnology());
        wrapper.eq(StringUtils.isNotEmpty(query.getAdministerResults()),"administer_results",query.getAdministerResults());
        wrapper.eq(StringUtils.isNotEmpty(query.getYear()),"year",query.getYear());
        wrapper.eq(StringUtils.isNotEmpty(query.getQuarter()),"quarter",query.getQuarter());
        wrapper.eq(query.getType()!=null,"type",query.getType());
        wrapper.orderByDesc("procedure","governance_technology");
        return wrapper;
    }
}
