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;

import java.util.ArrayList;
import java.util.List;


/**
 * 查询在线监测,无组织,排口坐标入参
 *
 * @author szhpt
 * @date 2023-07-19*/
@ApiModel(value = "查询在线监测,无组织,排口坐标入参")
@EqualsAndHashCode(callSuper = false)
@Data
public class PcOutletCoordinateQuery extends PageQuery
{

    @ApiModelProperty(value = "企业id")
    private String factoryId;
    @ApiModelProperty(value = "污染物类型（1排口、3无组织、4在线监测）")
    private String pollutantType;
    @ApiModelProperty(value = "在线监测点位名称/无组织点位名称")
    private String monitoringPointName;
    @ApiModelProperty(value = "排放口名称")
    private String outletName;

    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<PcOutlet> createLambdaQueryWrapper(PcOutletCoordinateQuery query) {
        QueryWrapper<PcOutlet> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotEmpty(query.getFactoryId()), "factory_id", query.getFactoryId());
        wrapper.like(StringUtils.isNotEmpty(query.getMonitoringPointName()), "monitoring_point_name", query.getMonitoringPointName());
        wrapper.like(StringUtils.isNotEmpty(query.getOutletName()), "outlet_name", query.getOutletName());
        String pollutantType = query.getPollutantType();
        if("1".equals(pollutantType)){
            List<String> pollutantTypeList = new ArrayList<>();
            pollutantTypeList.add("1");
            pollutantTypeList.add("2");
            wrapper.in("pollutant_type",pollutantTypeList);
        }else{
            wrapper.eq(StringUtils.isNotEmpty(query.getPollutantType()), "pollutant_type", query.getPollutantType());
        }
        wrapper.eq("is_status","1");
        wrapper.orderByAsc("outlet_code", "id");
        return wrapper;
    }
}
