using DbCommon.Enties.DbModels;
using DbCommon.Function;
using PmsSecondaryPackaging.Interface.Model.TaskBook;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjectManagementSystem.OrderLogic
{
    public class Logic_3F空车缓存区 : OrderLogicBase
    {
        private string uLocation;
        private string dLocation;

        public override bool FirstCheck()
        {
            var dataList = m_locationManager.QueryLocation_Out_DataList("3F空车缓存区", LocationStatus.LineCall);
            if(dataList == null
                || dataList.Count == 0)
            {
                return false;
            }

            foreach (var item in dataList)
            {
                dLocation = m_locationManager.QueryLocation_In("3F还原车间", LocationStatus.Empty);
                if (!string.IsNullOrEmpty(dLocation))
                {
                    uLocation = item.LocationCode;
                    return true;
                }
            }

            return false;
        }

        public override TaskAddInfoModel GetTask()
        {
            var data = base.GetTask();

            data.TemplateName = "BOOK2";
            data.ParametersDic.Add("U1", uLocation);
            data.ParametersDic.Add("U2", dLocation);
            data.Priority = 0;

            return data;
        }
    }
}
