using DbCommon.BusinessCore.BaseCore;
using DbCommon.Enties.DbModels;
using Pms.DataLibrary.Order;
using ProjectManagementSystem.Common.Core;
using ProjectManagementSystem.Common.Logger;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjectManagementSystem.TaskBookEvent
{
    public class TaskBookBehavior_63001 : BaseTaskBookBehaviorV2
    {
        LocationPropertyManager locationManager = new LocationPropertyManager();

        public TaskBookBehavior_63001() : base(63001, "库位置满")
        {
        }


        public override bool TaskBookOperator(TaskData taskDetailInfo, StepData stepInfo)
        {
            try
            {
                var data = locationManager.GetById(stepInfo.WareHouseID);
                if (data == null)
                {
                    Log(taskDetailInfo, stepInfo, $"获取库位信息失败");
                    return false;
                }

                data.Status = LocationStatus.Filled;
                data.CurrentTaskID = string.Empty;
                data.ModifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                bool result = locationManager.Update(data);
                Log(taskDetailInfo, stepInfo, $"库位置满，操作结果:{result}");
                return result;
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
            return false;
        }
    }
}
