package cn.cecep.talroad.vo;

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.domain.BasProductionDeviceOperationLog;
import cn.cecep.talroad.domain.MAmVideoCoordinateOperationLog;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableName;
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.Date;

/**
 * @className: BasProductionDeviceOperationLog
 * @description: TODO 类描述
 * @author: Mr.Yanghongtao
 * @date: 2023/04/28 15:26
 * @Company: Copyright© [2023/04/28 15:26] by [Mr.Yanghongtao]
 **/

/**
    * 生产设施坐标操作日志
    */
@ApiModel(value = "生产设施坐标操作日志query")
@Data
@EqualsAndHashCode(callSuper = false)
public class BasProductionDeviceOperationLogQuery extends PageQuery
{
    private String logId;

    /**
    * 操作时间
    */
    private Date operationTime;

    /**
    * 生产设施名称
    */
    private String deviceName;

    /**
     * 操作前经度
     */
    private String beforeModifyLng;

    /**
     * 操作前纬度
     */
    private String beforeModifyLag;

    /**
     * 操作状态
     */
    private String operationStatus;

    /**
     * 操作后经度
     */
    private String afterModifyLng;

    /**
     * 操作后纬度
     */
    private String afterModifyLag;

    /**
    * 操作人
    */
    private String operator;

    /**
    * 操作人ID
    */
    private String operatorId;

    /**
    * 所在工序
    */
    private String workProcedure;

    /**
     * 企业ID
     */
    private String factoryId;


    @ApiModelProperty(value = "开始时间")
    private Date startTime;
    @ApiModelProperty(value = "结束时间")
    private Date endTime;

    public static QueryWrapper<BasProductionDeviceOperationLog> createLambdaQueryWrapper(BasProductionDeviceOperationLogQuery query) {
        QueryWrapper<BasProductionDeviceOperationLog> wrapper = new QueryWrapper<>();
        wrapper.ge(ObjectUtil.isNotNull(query.getStartTime()), "operation_time", query.getStartTime());
        wrapper.le(ObjectUtil.isNotNull(query.getEndTime()), "operation_time", query.getEndTime());
        wrapper.like(StrUtil.isNotBlank(query.getDeviceName()), "device_name", query.getDeviceName());
        wrapper.like(StrUtil.isNotBlank(query.getWorkProcedure()), "work_procedure", query.getWorkProcedure());
        wrapper.eq(ObjectUtil.isNotNull(query.getFactoryId()), "factory_id", query.getFactoryId());


        wrapper.orderByDesc("operation_time");
        return wrapper;
    }

}
