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

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.analysis.SRaRealTimeAnalysisCoal;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
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 java.util.List;


/**
 * 装煤推焦次数分析对象 s_ra_real_time_analysis_coal
 *
 * @author szhpt
 * @date 2023-03-24*/
@ApiModel(value = "装煤推焦次数分析")
@EqualsAndHashCode(callSuper = false)
@Data
public class SRaRealTimeAnalysisCoalQuery extends PageQuery
{

    @ApiModelProperty(value = "数据主键")
    private String dataId;
    @ApiModelProperty(value = "企业名称")
    private String factoryName;
    @ApiModelProperty(value = "行业类别编码")
    private String industryCategoryCode;
    @ApiModelProperty(value = "所在区县编码")
    private String districtCode;
    @ApiModelProperty(value = "设备名称")
    private String deviceName;
    @ApiModelProperty(value = "设备编号")
    private String deviceId;
    @ApiModelProperty(value = "统计开始时间")
    private String analyseStartTime;
    @ApiModelProperty(value = "统计截至时间")
    private String analyseEndTime;
    @ApiModelProperty("统计类型1按企业合计，2按设备合计")
    private String type;
    private List<String> regionCodes;
    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<SRaRealTimeAnalysisCoal> createLambdaQueryWrapper(SRaRealTimeAnalysisCoalQuery query) {
        QueryWrapper<SRaRealTimeAnalysisCoal> 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.getIndustryCategoryCode()), "industry_category_code", query.getIndustryCategoryCode());
        wrapper.eq(StringUtils.isNotEmpty(query.getDistrictCode()), "district_code", query.getDistrictCode());
        wrapper.eq(StringUtils.isNotEmpty(query.getDeviceName()), "device_name", query.getDeviceName());
        wrapper.eq(StringUtils.isNotEmpty(query.getDeviceId()), "device_name", query.getDeviceId());
        wrapper.in(CollectionUtil.isNotEmpty(query.getRegionCodes()), "district_code", query.getRegionCodes());
        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;
        }
}
