package cn.cecep.talroad.vo.query;

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.common.core.utils.DateUtils;
import cn.cecep.talroad.common.core.utils.StringUtils;
import cn.cecep.talroad.domain.BMainEmissionOnlineMonWater;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableField;
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 javax.validation.constraints.NotBlank;
import java.text.ParseException;
import java.util.Date;


/**
 * 企业排放信息-在线监测排放趋势-废水对象 b_main_emission_online_mon_water
 *
 * @author szhpt
 * @date 2023-01-31*/
@ApiModel(value = "企业排放信息-在线监测排放趋势-废水")
@EqualsAndHashCode(callSuper = false)
@Data
public class BMainEmissionOnlineMonWaterQuery extends PageQuery
{

    @ApiModelProperty(value = "主键id")
    private String id;
    @ApiModelProperty(value = "企业id")
    private String factoryId;
    @ApiModelProperty(value = "企业名称")
    private String factoryName;
    @ApiModelProperty(value = "监测点位名称")
    private String monName;
    @ApiModelProperty(value = "污染物类别")
    private String pollutionCategory;
    @ApiModelProperty(value = "排口编号")
    private String outletCode;
    @ApiModelProperty(value = "排口类型")
    private String outletType;
    @ApiModelProperty(value = "污染物种类")
    private String pollutionType;
    @ApiModelProperty(value = "监测时间")
    private Date monitoningTime;
    @ApiModelProperty(value = "浓度日均值")
    private String meanConcentrationDay;
    @ApiModelProperty(value = "浓度单位")
    private String meanUnit;
    @ApiModelProperty(value = "烟气流量(m3/h)")
    private String flueGasFlowRate;
    @ApiModelProperty(value = "污染物排放量(kg)")
    private String pollutionDischarge;
    @ApiModelProperty(value = "是否有效")
    private String whetherEffective;
    @ApiModelProperty(value = "修约排放量(kg)")
    private String revisingDischarge;
    @ApiModelProperty(value = "修约说明")
    private String revisingExplain;
    @ApiModelProperty(value = "纳入计算排放量(kg)")
    private String inclusionCalculationDischarge;
    @ApiModelProperty(value = "标记说明：N正常  F停运  M维护/维修  S手工输入的设定值  D故障/断电  C校准  T超测量上限")
    private String tagExplain;

    @ApiModelProperty(value = "污染类别[废水、废气]")
    @NotBlank(message = "请指定污染类别[废水、废气]")
    @TableField(exist = false)
    private String facts;

    @ApiModelProperty(value = "检索开始时间(yyyy-MM-dd)")
    @TableField(exist = false)
    private String searchBeginTime;

    @ApiModelProperty(value = "检索截至时间(yyyy-MM-dd)")
    @TableField(exist = false)
    private String searchEndTime;

    public BMainEmissionOnlineMonWaterQuery(String monName, String searchBeginTime, String searchEndTime) {
        this.monName = monName;
        this.searchBeginTime = searchBeginTime;
        this.searchEndTime = searchEndTime;
    }

    public BMainEmissionOnlineMonWaterQuery() {

    }

    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<BMainEmissionOnlineMonWater> createLambdaQueryWrapper(BMainEmissionOnlineMonWaterQuery query) throws ParseException {
        QueryWrapper<BMainEmissionOnlineMonWater> wrapper = new QueryWrapper<>();
        wrapper.eq(ObjectUtil.isNotNull(query.getId()), "id", query.getId());
        wrapper.eq(ObjectUtil.isNotNull(query.getFactoryId()), "factory_id", query.getFactoryId());
        wrapper.eq(ObjectUtil.isNotNull(query.getFactoryName()), "factory_name", query.getFactoryName());
        wrapper.eq(ObjectUtil.isNotNull(query.getMonName()), "mon_name", query.getMonName());
        wrapper.eq(ObjectUtil.isNotNull(query.getPollutionCategory()), "pollution_category", query.getPollutionCategory());
        wrapper.eq(ObjectUtil.isNotNull(query.getOutletCode()), "outlet_code", query.getOutletCode());
        wrapper.eq(ObjectUtil.isNotNull(query.getOutletType()), "outlet_type", query.getOutletType());
        wrapper.eq(ObjectUtil.isNotNull(query.getPollutionType()), "pollution_type", query.getPollutionType());
        wrapper.eq(ObjectUtil.isNotNull(query.getMonitoningTime()), "monitoning_time", query.getMonitoningTime());
        wrapper.eq(ObjectUtil.isNotNull(query.getMeanConcentrationDay()), "mean_concentration_day", query.getMeanConcentrationDay());
        wrapper.eq(ObjectUtil.isNotNull(query.getMeanUnit()), "mean_unit", query.getMeanUnit());
        wrapper.eq(ObjectUtil.isNotNull(query.getFlueGasFlowRate()), "flue_gas_flow_rate", query.getFlueGasFlowRate());
        wrapper.eq(ObjectUtil.isNotNull(query.getPollutionDischarge()), "pollution_discharge", query.getPollutionDischarge());
        wrapper.eq(ObjectUtil.isNotNull(query.getWhetherEffective()), "whether_effective", query.getWhetherEffective());
        wrapper.eq(ObjectUtil.isNotNull(query.getRevisingDischarge()), "revising_discharge", query.getRevisingDischarge());
        wrapper.eq(ObjectUtil.isNotNull(query.getRevisingExplain()), "revising_explain", query.getRevisingExplain());
        wrapper.eq(ObjectUtil.isNotNull(query.getInclusionCalculationDischarge()), "inclusion_calculation_discharge", query.getInclusionCalculationDischarge());
        //检索起止年份
        wrapper.between(StringUtils.isNotEmpty(query.getSearchBeginTime()) && StringUtils.isNotEmpty(query.getSearchEndTime()), "monitoning_time", DateUtils.parseDate(query.getSearchBeginTime()), DateUtils.parseDate(query.getSearchEndTime()));
        wrapper.orderByAsc("monitoning_time");
        return wrapper;
    }
}
