using DbCommon.BusinessCore.BaseCore;
using DbCommon.Enties.DbModels;
using DbCommon.Extenions;
using PmsSecondaryPackaging.Interface.Model.Carrier;
using PmsSecondaryPackaging.Interface.Model.StepBook;
using PmsSecondaryPackaging.Interface.Model.TaskBook;
using PmsSecondaryPackaging.TaskManager.TaskBookBehavior;
using ProjectManagementSystem.Common.Log;
using ProjectManagementSystem.Common.WebApi;
using ProjectManagementSystem.Model.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjectManagementSystem.TaskBookEvent
{
    public class TaskBookBehavior_63011 : BaseTaskBookBehavior
    {
        public TaskBookBehavior_63011() : base(63011)
        {
        }

        public override bool TaskBookOperator(TaskDetailInfoModel taskDetailInfo, List<StepDetailInfoModel> taskStepInfoList, CarrierInfoModel carrierInfo)
        {
            try
            {
                var stepInfo = TaskBookRegister.GetCurrentStepDetailInfo(taskDetailInfo, taskStepInfoList);

                string host = Common.Config.ExcelConfig.Instance.GetLocationMemberCache(stepInfo.WareHouseID, "磅秤接口地址");
                string url = $@"http://{host}/AGVS/queryScaleState";
                bool result = ScaleApi.Post(url, null, null, out ScaleState scaleState, out string msg);

                TaskBookRegister.Log(taskDetailInfo, stepInfo, $"等待秤台允许上秤，操作结果:{result}，秤台号：{scaleState?.SCALE_NAME}，消息：{msg}");
                return result;
            }
            catch (Exception ex)
            {
                TaskBookRegister.LogException(ex);
            }
            return false;
        }
    }
}

