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_63000 : BaseTaskBookBehaviorV2
    {
        LocationPropertyManager locationManager = new LocationPropertyManager();

        public TaskBookBehavior_63000() : base(63000, "库位置空")
        {
        }

        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.Empty;
                data.MaterialId = string.Empty;
                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;
        }
    }
}
