package org.wcs.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.wcs.model.po.app.AppStockSingleTask;

import java.util.List;

@Mapper
public interface AppStockSingleTaskMapper extends BaseMapper<AppStockSingleTask> {

    /**
     * 查询指定堆垛机指定箱号的任务
     * @param stackerId 堆垛机ID
     * @param vehicleNo 载具号
     * @param taskStatus 任务状态
     * @param taskType 任务类型
     * @return 查询结果
     */
    @Select("select * from t_app_stock_single_task where vehicle_no = #{vehicleNo} and task_status = #{taskStatus} and task_type = #{taskType} and " +
            "destination in (select business_location from t_app_stacker_location where machine_id = #{stackerId}) order by priority desc, create_time asc")
    List<AppStockSingleTask> queryStackerTaskWithVehicle(Integer stackerId, String vehicleNo, Integer taskStatus, Integer taskType);

    /**
     * 查询指定堆垛机的任务
     * @param stackerId 堆垛机ID
     * @param taskStatus 状态
     * @param taskType 任务类型
     * @return 堆垛机入库任务
     */
    @Select("select * from t_app_stock_single_task where  task_status = #{taskStatus} and task_type = #{taskType} and " +
            "destination in (select business_location from t_app_stacker_location where machine_id = #{stackerId}) order by priority desc, create_time asc")
    List<AppStockSingleTask> queryStackerTask(Integer stackerId, Integer taskStatus, Integer taskType);


}
