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

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

@Data
public class BasDeviceParamQuery extends PageQuery  {
    @ApiModelProperty(value = "数据类型 1：DCS监控数据:，2：分表计电监测数据，3：在线监测数据，4：无组织监控数据:5：网格化监控数据，6：废水国省控站点监控数据，7：废气国省控站点监控数据")
    private String dataType;
    @ApiModelProperty(value = "设备名称")
    private String deviceName;
    @ApiModelProperty(value = "企业名称")
    private String factoryName;
    @ApiModelProperty(value = "设备ID")
    private String deviceId;
    @ApiModelProperty(value = "参数是否联网 0=否，1=是")
    private Short isOnline;
    @ApiModelProperty(value = "参数名称")
    private String paramName;

    public static QueryWrapper<BasDeviceParam> createLambdaQueryWrapper(BasDeviceParamQuery query) {
        QueryWrapper<BasDeviceParam> wrapper = new QueryWrapper<>();
        wrapper.eq(ObjectUtil.isNotEmpty(query.getDataType()), "data_type", query.getDataType());
        wrapper.like(ObjectUtil.isNotEmpty(query.getDeviceName()), "device_name", query.getDeviceName());
        wrapper.like(ObjectUtil.isNotEmpty(query.getFactoryName()), "factory_name", query.getFactoryName());
        wrapper.like(ObjectUtil.isNotEmpty(query.getDeviceId()), "device_id", query.getDeviceId());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getIsOnline()), "is_online", query.getIsOnline());
        wrapper.like(ObjectUtil.isNotEmpty(query.getParamName()), "param_name", query.getParamName());
        return wrapper;
    }
}
