package cn.cecep.talroad.vo.query;

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


/**
 * 废气有组织、无组织排口对象 pc_outlet
 *
 * @author szhpt
 * @date 2023-07-10*/
@ApiModel(value = "废气有组织、无组织排口-APP端查询实体")
@EqualsAndHashCode(callSuper = false)
@Data
public class PcOutletAppQuery extends PageQuery
{

    @ApiModelProperty(value = "主键id")
    private String id;
    @ApiModelProperty(value = "企业id")
    private String factoryId;
    @ApiModelProperty(value = "污染物类型（1废气、2废水、3、无组织）")
    private String pollutantType;
    @ApiModelProperty(value = "排口分类（有组织、无组织）")
    private String pollutantOutletType;
    @ApiModelProperty(value = "排放形式")
    private String emissionsForm;
    @ApiModelProperty(value = "排放口设置是否符合要求")
    private String whetherOutletRequirements;
    @ApiModelProperty(value = "产污环节")
    private String productionProcess;
    @ApiModelProperty(value = "排口类型(主要排口、一般排扣)")
    private String outletTypes;
    @ApiModelProperty(value = "对应监测点位名称")
    private String monitoringPointName;
    @ApiModelProperty(value = "对应治理设施编号")
    private String manageFacilitiesCode;
    @ApiModelProperty(value = "对应治理设施名称")
    private String manageFacilitiesName;
    @ApiModelProperty(value = "对应生产设施编号")
    private String productionFacilitiesCode;
    @ApiModelProperty(value = "对应生产设施名称")
    private String productionFacilitiesName;
    @ApiModelProperty(value = "排口经度")
    private String outletLon;
    @ApiModelProperty(value = "排口纬度")
    private String outletLat;
    @ApiModelProperty(value = "排气筒高度（m）")
    private String exhaustFunnelHight;
    @ApiModelProperty(value = "排气筒出口内径（m）")
    private String exhaustFunnelInner;
    @ApiModelProperty(value = "排气温度")
    private String exhaustGasTemperature;
    @ApiModelProperty(value = "排放口编号")
    private String outletCode;
    @ApiModelProperty(value = "排放口名称")
    private String outletName;
    @ApiModelProperty(value = "排口监测类型")
    private String outletMonitorName;
    @ApiModelProperty(value = "治理设施工艺")
    private String treatmentFacilityProcess;
    @ApiModelProperty(value = "视频监控")
    private String videoSurveillance;
    @ApiModelProperty(value = "许可证无组织监测点位名称")
    private String stationName;
    @ApiModelProperty(value = "无组织监测点位")
    private String stationId;
    @ApiModelProperty(value = "主要污染防治措施")
    private String pollutionPreventionMeasures;
    @ApiModelProperty(value = "废水来源")
    private String sourcesWastewater;
    @ApiModelProperty(value = "标记 N正常  F停运  M维护/维修  S手工输入的设定值  D故障/断电  C校准  T超测量上限")
    private String mark;
    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<PcOutlet> createLambdaQueryWrapper(PcOutletAppQuery query) {
        QueryWrapper<PcOutlet> 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.getPollutantType()), "pollutant_type", query.getPollutantType());
        wrapper.eq(ObjectUtil.isNotNull(query.getPollutantOutletType()), "pollutant_outlet_type", query.getPollutantOutletType());
        wrapper.eq(ObjectUtil.isNotNull(query.getEmissionsForm()), "emissions_form", query.getEmissionsForm());
        wrapper.eq(ObjectUtil.isNotNull(query.getWhetherOutletRequirements()), "whether_outlet_requirements", query.getWhetherOutletRequirements());
        wrapper.eq(ObjectUtil.isNotNull(query.getProductionProcess()), "production_process", query.getProductionProcess());
        wrapper.eq(ObjectUtil.isNotNull(query.getOutletTypes()), "outlet_types", query.getOutletTypes());
        wrapper.eq(ObjectUtil.isNotNull(query.getExhaustFunnelHight()), "exhaust_funnel_hight", query.getExhaustFunnelHight());
        wrapper.eq(ObjectUtil.isNotNull(query.getExhaustFunnelInner()), "exhaust_funnel_inner", query.getExhaustFunnelInner());
        wrapper.eq(ObjectUtil.isNotNull(query.getExhaustGasTemperature()), "exhaust_gas_temperature", query.getExhaustGasTemperature());
        wrapper.eq(ObjectUtil.isNotNull(query.getOutletCode()), "outlet_code", query.getOutletCode());
        if(ObjectUtil.isNotEmpty(query.getOutletName())){
            wrapper.and(QueryWrapper -> QueryWrapper.like( "outlet_name", query.getOutletName()).or().like( "outlet_code", query.getOutletName()));
        }
        wrapper.eq(ObjectUtil.isNotNull(query.getStationName()), "station_name", query.getStationName());
        wrapper.eq(ObjectUtil.isNotNull(query.getStationId()), "station_id", query.getStationId());
        wrapper.eq(ObjectUtil.isNotNull(query.getPollutionPreventionMeasures()), "pollution_prevention_measures", query.getPollutionPreventionMeasures());
        wrapper.eq(ObjectUtil.isNotNull(query.getSourcesWastewater()), "sources_wastewater", query.getSourcesWastewater());
        wrapper.eq(StringUtils.isNotEmpty(query.getMark()), "mark", query.getMark());
        wrapper.orderByAsc("outlet_code", "id");
        return wrapper;
    }
}
