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

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.domain.effective.MAiControlDelayAssessment;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

@Data
public class MAiControlDelayAssessmentQuery extends PageQuery {
    @ApiModelProperty(value="平均风速")
    private String averageSpeed;
    @ApiModelProperty(value="风向：E：东，S：南，W：西，N：北 ，SE：东南，SW：西南，NE：东北，NW：西北")
    private String windDirection;
    @ApiModelProperty(value="影响站点名称")
    private List<String> siteNames;
    @ApiModelProperty(value="企业名")
    private String factoryName;
    @ApiModelProperty(value="查询的字段，site_name:影响站点名称,factory_name:企业名")
    private String selectName;

    public static QueryWrapper<MAiControlDelayAssessment> createLambdaQueryWrapper(MAiControlDelayAssessmentQuery query) {
        QueryWrapper<MAiControlDelayAssessment> wrapper= Wrappers.query();
        wrapper.eq(ObjectUtil.isNotEmpty(query.getAverageSpeed()), "average_speed ::NUMERIC",query.getAverageSpeed()==null?null: Double.parseDouble(query.getAverageSpeed()));
        wrapper.eq(ObjectUtil.isNotEmpty(query.getWindDirection()), "wind_direction", query.getWindDirection());
        wrapper.in(ObjectUtil.isNotEmpty(query.getSiteNames()), "site_name", query.getSiteNames());
        wrapper.like(ObjectUtil.isNotEmpty(query.getFactoryName()), "factory_name", query.getFactoryName());
        return wrapper;
    }
}
