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.BasDevice;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;


/**
 * 设备信息(有组织)对象 bas_device
 *
 * @author szhpt
 * @date 2023-01-10*/
@ApiModel(value = "设备信息(有组织)")
@EqualsAndHashCode(callSuper = false)
@Data
public class BasDeviceQuery extends PageQuery
{

    @ApiModelProperty(value = "设备ID")
    private String deviceId;
    @ApiModelProperty(value = "所属企业")
    private String factoryId;
    @ApiModelProperty(value = "设备名称")
    private String name;
    @ApiModelProperty(value = "所属行业 枚举。钢铁/焦化/水泥...")
    private String industry;
    @ApiModelProperty(value = "所属工序名")
    private String workStep;
    @ApiModelProperty(value = "设备类型 枚举。焦炉/烧结机...")
    private String type;
    @ApiModelProperty(value = "状态 ≤0=停用，>0=正常")
    private Long status;
    @ApiModelProperty(value = "工艺参数值 停限产计算用")
    private String craftParamValue;
    @ApiModelProperty(value = "工艺参数 JSON。展示用")
    private String craftParam;
    @ApiModelProperty(value = "DCS系统品牌")
    private String dcsBrand;
    @ApiModelProperty(value = "DCS系统型号")
    private String dcsModel;
    @ApiModelProperty(value = "脱硫工艺")
    private String tlCraft;
    @ApiModelProperty(value = "脱硫设施数量")
    private String tlNum;
    @ApiModelProperty(value = "脱硝工艺")
    private String txCraft;
    @ApiModelProperty(value = "脱硝设施数量")
    private String txNum;
    @ApiModelProperty(value = "除尘工艺")
    private String ccCraft;
    @ApiModelProperty(value = "除尘设施数量")
    private String ccNum;
    @ApiModelProperty(value = "CEMS系统数量")
    private String cemsNum;
    @ApiModelProperty(value = "主设备ID 本设备为从设备时，注明与哪个主设备共用数据")
    private String shareDevId;
    @ApiModelProperty(value = "共用数据的设施类型 枚举列表，逗号分隔。CEMS/除尘1...")
    private String shareType;
    @ApiModelProperty(value = "经度(原始)")
    private String lon;
    @ApiModelProperty(value = "纬度(原始)")
    private String lat;
    @ApiModelProperty(value = "经度(地图)")
    private String lonMap;
    @ApiModelProperty(value = "纬度(地图)")
    private String latMap;
    @ApiModelProperty(value = "原始设备ID 用于在通信协议中识别设备")
    private String oriDeviceId;
    @ApiModelProperty(value = "原始设备密码")
    private String oriPwd;
    @ApiModelProperty(value = "工艺流程图用参数 JSON")
    private String craftImageArg;
    @ApiModelProperty(value = "对应的视频设备ID JSON")
    private String videoDevId;
    @ApiModelProperty(value = "备注")
    private String memo;
    @ApiModelProperty(value = "创建时间")
    private String createTime;

    @ApiModelProperty(value = "排污许可设施编码")
    private String pollutantCode;

    @ApiModelProperty(value = "排污许可设施名称")
    private String pollutantName;

    @ApiModelProperty("是否启用")
    private String isStatus;
    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<BasDevice> createLambdaQueryWrapper(BasDeviceQuery query) {
        QueryWrapper<BasDevice> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotNull(query.getDeviceId()), "device_id", query.getDeviceId());
        wrapper.eq(StringUtils.isNotNull(query.getFactoryId()), "factory_id", query.getFactoryId());
        wrapper.like(StrUtil.isNotBlank(query.getName()), "name", query.getName());
        wrapper.eq(StringUtils.isNotNull(query.getIndustry()), "industry", query.getIndustry());
        wrapper.eq(StrUtil.isNotBlank(query.getWorkStep()), "work_step", query.getWorkStep());
        wrapper.eq(StringUtils.isNotNull(query.getType()), "type", query.getType());
        wrapper.eq(ObjectUtil.isNotNull(query.getStatus()), "status", query.getStatus());
        wrapper.eq(StringUtils.isNotNull(query.getCraftParamValue()), "craft_param_value", query.getCraftParamValue());
        wrapper.eq(ObjectUtil.isNotNull(query.getCraftParam()), "craft_param", query.getCraftParam());
        wrapper.eq(ObjectUtil.isNotNull(query.getDcsBrand()), "dcs_brand", query.getDcsBrand());
        wrapper.eq(ObjectUtil.isNotNull(query.getDcsModel()), "dcs_model", query.getDcsModel());
        wrapper.eq(ObjectUtil.isNotNull(query.getTlCraft()), "tl_craft", query.getTlCraft());
        wrapper.eq(ObjectUtil.isNotNull(query.getTlNum()), "tl_num", query.getTlNum());
        wrapper.eq(ObjectUtil.isNotNull(query.getTxCraft()), "tx_craft", query.getTxCraft());
        wrapper.eq(ObjectUtil.isNotNull(query.getTxNum()), "tx_num", query.getTxNum());
        wrapper.eq(ObjectUtil.isNotNull(query.getCcCraft()), "cc_craft", query.getCcCraft());
        wrapper.eq(ObjectUtil.isNotNull(query.getCcNum()), "cc_num", query.getCcNum());
        wrapper.eq(ObjectUtil.isNotNull(query.getCemsNum()), "cems_num", query.getCemsNum());
        wrapper.eq(ObjectUtil.isNotNull(query.getShareDevId()), "share_dev_id", query.getShareDevId());
        wrapper.eq(ObjectUtil.isNotNull(query.getShareType()), "share_type", query.getShareType());
        wrapper.eq(ObjectUtil.isNotNull(query.getLon()), "lon", query.getLon());
        wrapper.eq(ObjectUtil.isNotNull(query.getLat()), "lat", query.getLat());
        wrapper.eq(ObjectUtil.isNotNull(query.getLonMap()), "lon_map", query.getLonMap());
        wrapper.eq(ObjectUtil.isNotNull(query.getLatMap()), "lat_map", query.getLatMap());
        wrapper.eq(ObjectUtil.isNotNull(query.getOriDeviceId()), "ori_device_id", query.getOriDeviceId());
        wrapper.eq(ObjectUtil.isNotNull(query.getOriPwd()), "ori_pwd", query.getOriPwd());
        wrapper.eq(ObjectUtil.isNotNull(query.getCraftImageArg()), "craft_image_arg", query.getCraftImageArg());
        wrapper.eq(ObjectUtil.isNotNull(query.getVideoDevId()), "video_dev_id", query.getVideoDevId());
        wrapper.eq(ObjectUtil.isNotNull(query.getMemo()), "memo", query.getMemo());
        wrapper.eq(ObjectUtil.isNotNull(query.getCreateTime()), "create_time", query.getCreateTime());

        wrapper.eq(ObjectUtil.isNotNull(query.getPollutantCode()), "pollutant_code", query.getPollutantCode());
        wrapper.like(ObjectUtil.isNotNull(query.getPollutantName()), "pollutant_name", query.getPollutantName());
        wrapper.orderByAsc("device_id");
        return wrapper;
    }
}
