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

import cn.cecep.talroad.common.core.utils.DateUtils;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.cecep.talroad.domain.analysis.SRaRealTimeAnalysisRubbish;
import cn.cecep.talroad.common.core.domain.query.PageQuery;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.List;


/**
 * 关联分析系统-企业生产过程分析-垃圾处理量分析对象 s_ra_real_time_analysis_rubbish
 *
 * @author szhpt
 * @date 2023-04-03*/
@ApiModel(value = "关联分析系统-企业生产过程分析-垃圾处理量分析")
@EqualsAndHashCode(callSuper = false)
@Data
public class SRaRealTimeAnalysisRubbishQuery extends PageQuery
{

    @ApiModelProperty(value = "数据主键")
    private String dataId;
    @ApiModelProperty(value = "企业主键")
    private String factoryId;
    @ApiModelProperty(value = "企业名称")
    private String factoryName;
    @ApiModelProperty(value = "所在区县名称")
    private String districtName;
    @ApiModelProperty(value = "所在区县编码")
    private String districtCode;
    @ApiModelProperty(value = "设备名称")
    private String deviceName;
    @ApiModelProperty(value = "设备编号")
    private String deviceId;
    @ApiModelProperty(value = "垃圾处理量（kg）")
    private String rubbishNumber;
    @ApiModelProperty(value = "更新时间")
    private String updateTime;
    @ApiModelProperty(value = "创建时间(默认当前时间)")
    private String createTime;
    @ApiModelProperty(value = "统计开始时间")
    private String analyseStartTime;
    @ApiModelProperty(value = "统计截至时间")
    private String analyseEndTime;
    @ApiModelProperty(value = "入炉方式")
    private String feedingMethod;
    @ApiModelProperty("统计类型1按企业合计，2按设备合计")
    private String type;
    private List<String> regionCodes;
    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<SRaRealTimeAnalysisRubbish> createLambdaQueryWrapper(SRaRealTimeAnalysisRubbishQuery query) {
        QueryWrapper<SRaRealTimeAnalysisRubbish> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotEmpty(query.getDataId()), "data_id", query.getDataId());
        wrapper.eq(StringUtils.isNotEmpty(query.getFactoryName()), "factory_name", query.getFactoryName());
        wrapper.eq(StringUtils.isNotEmpty(query.getDistrictCode()), "district_code", query.getDistrictCode());
        wrapper.in(CollectionUtil.isNotEmpty(query.getRegionCodes()), "district_code", query.getRegionCodes());
        wrapper.eq(StringUtils.isNotEmpty(query.getDeviceName()), "device_name", query.getDeviceName());
        wrapper.eq(StringUtils.isNotEmpty(query.getDeviceId()), "device_id", query.getDeviceId());
        wrapper.between(StringUtils.isNotEmpty(query.getAnalyseStartTime()) && StringUtils.isNotEmpty(query.getAnalyseEndTime()), "analyse_time", DateUtils.parseDate(query.getAnalyseStartTime()), DateUtils.parseDate(query.getAnalyseEndTime()));
        wrapper.orderByDesc("analyse_time");
        return wrapper;
        }
}
