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

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.domain.analysis.BMaintenancePlan;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
@Data
public class BMaintenancePlanQuery extends PageQuery {

    @ApiModelProperty(value="1：已上报，0：未上报")
    private Integer reportStatus;

    @ApiModelProperty(value="上报开始时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createStartTime;
    @ApiModelProperty(value="上报结束时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createEndTime;
    @ApiModelProperty(value = "删除状态：0：不删除，1：删除")
    private Integer deleteStatus;
    @ApiModelProperty(value = "企业id")
    private String factoryId;
    @ApiModelProperty(value = "散口类型")
    private String deviceType;
    @ApiModelProperty(value = "放散设备名称")
    private String deviceName;
    @ApiModelProperty(value = "计划id")
    private Integer planId;
    public static QueryWrapper<BMaintenancePlan> createLambdaQueryWrapper(BMaintenancePlanQuery query) {
        QueryWrapper<BMaintenancePlan> wrapper = new QueryWrapper<>();
        wrapper.le(ObjectUtil.isNotEmpty(query.getCreateEndTime()), "create_time", query.getCreateEndTime());
        wrapper.ge(ObjectUtil.isNotEmpty(query.getCreateStartTime()), "create_time", query.getCreateStartTime());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getReportStatus()), "report_status", query.getReportStatus());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getDeleteStatus()), "delete_status", query.getDeleteStatus());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getFactoryId()), "factory_id", query.getFactoryId());
        wrapper.orderByDesc("create_time");
        return wrapper;
    }
}
