Esempio n. 1
0
 /// <summary>
 ///     条件一个包裹
 /// </summary>
 /// <param name="parcel">包裹</param>
 /// <returns>成功:True,失败:false</returns>
 private bool AddParcel(Parcel parcel)
 {
     var suc = true;
     foreach (var rule in Rules)
     {
         suc = rule.Check(parcel).IsPass;
         if (!suc) return false;
     }
     Parcels.Add(parcel);
     return suc;
 }
Esempio n. 2
0
        /// <summary>
        ///     创建包裹计划
        /// </summary>
        public void WorkPlan()
        {
            //校验
            if (string.IsNullOrEmpty(InputStr)) throw new InvalidDataException("没有输入数据");

            //生成SDR输入
            var sdrs = SDRInput.GetSdrs(InputStr);
            inputSdrs = SortSdr(sdrs); //排列
            var idx = 1;
            foreach (var sdr in inputSdrs)
            {
                //查找符合条件的包裹
                var maybeParcels = FindParcel(sdr);
                var suc = false;
                foreach (var maybeparcel in maybeParcels)
                {
                    //逐个包裹尝试添加
                    suc = maybeparcel.AddSDR(sdr);
                    if (suc) break;
                }
                if (!suc)
                {
                    //尝试创建包裹
                    var price = Prices[sdr.Prior];
                    var parc = new Parcel(Lot_Num, price, sdr);
                    parc.Name = string.Format("Pack{0}", idx++);
                    var res = AddParcel(parc);
                    if (!res)
                    {
                        //否则放入延时件
                        //sdr.IsDelay = true; //设置成延时件
                        DelaySdrs.Add(sdr);
                    }
                }
            }
        }