using Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MeterConditionLibrary
{
    /// <summary>
    /// 验证卸货时间
    /// </summary>
    public class ValidUnloadTime
    {
        /// <summary>
        /// 验证物料计量时间段配置表 只验证先毛后皮，且当前为过皮的数据
        /// </summary>
        public void ValidMethod(MeterWorkCarActualFirst first)
        {
            PbCache.monitorResult.valid_unload_time = true;
            if (PbCache.unloadTimes != null && !PbCache.isNotValid)
            {
                MeterBaseUnloadTime mbut = PbCache.unloadTimes.Where(s => s.baseSpotNo == first.baseSpotNo && s.loadPointNo == PbCache.sportInfo.baseSpotNo).FirstOrDefault();
                if (mbut != null)
                {
                    if (first.createTime.Value.AddMinutes(mbut.loadTime.Value).CompareTo(DateTime.Now) < 0) 
                    {
                        PbCache.monitorResult.valid_unload_time = false;
                        PbCache.ResultMessage = "当前卸货时间超出计量卸货时间限制";
                    }
                }
            }
        }
    }
}
