package com.wms.entity.app.request;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.wms.entity.app.dto.extend.TaskDetailInfo;
import com.wms.entity.table.Task;
import com.wms.utils.StringUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class TaskQuery extends PageQuery {
    @JsonProperty("taskId")
    private String taskId;
    @JsonProperty("taskGroup")
    private String taskGroup;
    @JsonProperty("taskType")
    private Integer taskType;
    @JsonProperty("vehicleId")
    private String vehicleId;
    @JsonProperty("goodsId")
    private String goodsId;
    @JsonProperty("goodsName")
    private String goodsName;
    @JsonProperty("taskStatus")
    private Integer taskStatus;
    @JsonProperty("isPicking")
    private Integer isPicking;

    /**
     * 根据客户端查询生成数据库查询条件
     * @return 数据库PO
     */
    public Task toTaskPO() {
        Task taskPO = new Task();
        taskPO.setTaskId(taskId);
        taskPO.setTaskGroup(taskGroup);
        taskPO.setTaskType(taskType);// 任务类型
        taskPO.setVehicleId(vehicleId);// 载具号
        taskPO.setIsPicking(isPicking);
        taskPO.setTaskStatus(taskStatus);
        if (StringUtils.isNotEmpty(goodsId) || StringUtils.isNotEmpty(goodsName)) {// 包含物料详细信息
            TaskDetailInfo goodsRelatedPO = new TaskDetailInfo();
            goodsRelatedPO.setGoodsId(goodsId);
            goodsRelatedPO.setGoodsName(goodsName);
            taskPO.setGoodsRelated(goodsRelatedPO);
        }

        return taskPO;
    }
}
