using DbCommon.BusinessCore.BaseCore;
using Pms.DataLibrary.Order;
using ProjectManagementSystem.Common.Core;
using ProjectManagementSystem.Common.Models;
using ProjectManagementSystem.Common.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjectManagementSystem.TaskEvent
{
    public class ProcessWarehouseTransfer : ICustomProcess
    {
        private PmsTaskInfoManager pmsTaskInfoManger = new PmsTaskInfoManager();
        private LocationPropertyManager locationManager = new LocationPropertyManager();

        public void CustomProcess(List<TaskData> taskDataList)
        {

            //预约任务处理移库
            var dataList = pmsTaskInfoManger
                .GetList(d => !string.IsNullOrEmpty(d.Message) && d.Message.Contains("取货仓位障碍检测失败"));


            for (int i = 0; i < dataList.Count; i++)
            {
                var data = dataList[i];

                bool result = locationManager.GetTransfer(data.LocationCode, out string location1, out string location2);
                if(result)
                {
                    PmsTaskInfoDto pmsTaskInfo = new PmsTaskInfoDto();
                    pmsTaskInfo.LocationCode = location1;
                    pmsTaskInfo.TargetLocationCode = location2;

                    var webMgrResponse = PmsTaskService.Instance.TaskAdd(pmsTaskInfo);
                    bool result2 = webMgrResponse?.code == 20000;
                }
            }
        }
    }
}
