package cn.cecep.talroad.vo.query;

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.domain.PcOutletCoordinateOperationLog;
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.Date;
import java.util.List;


/**
 * @Description: 在线监测,无组织点位,排口经纬度坐标操作记录表
 * @Author: code-generate
 * @Date:   2023-07-19
 * @Version: V1.0
 */
@ApiModel(value="在线监测,无组织点位,排口经纬度坐标操作记录表查询对象")
@EqualsAndHashCode(callSuper = false)
@Data
public class PcOutletCoordinateOperationLogQuery extends PageQuery
{

	@ApiModelProperty(value = "主键标识")
	private String logId;
	@ApiModelProperty(value = "污染物类型（1排口、3无组织、4在线监测）")
	private String pollutantType;
	@ApiModelProperty(value = "在线监测点位名称/无组织点位名称")
	private String monitoringPointName;
	@ApiModelProperty(value = "排口名称")
	private String outletName;
	@ApiModelProperty(value = "开始时间")
	private Date startTime;
	@ApiModelProperty(value = "结束时间")
	private Date endTime;
	@ApiModelProperty(value = "企业ID")
	private String factoryId;


	/**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<PcOutletCoordinateOperationLog>
     * @throws
     */
    public static QueryWrapper<PcOutletCoordinateOperationLog> createLambdaQueryWrapper(PcOutletCoordinateOperationLogQuery query) {
        QueryWrapper<PcOutletCoordinateOperationLog> wrapper = new QueryWrapper<>();
		wrapper.ge(ObjectUtil.isNotNull(query.getStartTime()), "operation_time", query.getStartTime());
		wrapper.le(ObjectUtil.isNotNull(query.getEndTime()), "operation_time", query.getEndTime());
		wrapper.eq(ObjectUtil.isNotNull(query.getMonitoringPointName()), "monitoring_point_name", query.getMonitoringPointName());
		wrapper.eq(ObjectUtil.isNotNull(query.getOutletName()), "outlet_name", query.getOutletName());
		wrapper.eq(ObjectUtil.isNotNull(query.getFactoryId()), "factory_id", query.getFactoryId());
		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(ObjectUtil.isNotNull(query.getPollutantType()), "pollutant_type", query.getPollutantType());
		}
		wrapper.orderByDesc("operation_time");
        return wrapper;
        }
}
