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

namespace ProjectManagementSystem.TaskBookEvent
{
    public class TaskBookBehavior_63020 : BaseTaskBookBehaviorV2
    {
        public TaskBookBehavior_63020() : base(63020, "上报任务状态(走出储位)")
        {
        }

        public override bool TaskBookOperator(TaskData taskDetailInfo, StepData stepInfo)
        {
            try
            {
                var t = PmsTaskService.Instance.GetTaskState(taskDetailInfo.TaskID);
                if (t == null)
                {
                    Log(taskDetailInfo, stepInfo, $"获取任务状态失败");
                    return false;
                }

                t.method = "outbin";
                bool result = CustomerApi.AgvCallback(t, out string content);
                Log(taskDetailInfo, stepInfo, $"{Remark}{result.ToChineseString()} {content}");

                return true;
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
            return false;
        }
    }
}
