public void AddSequenceDetail(SequenceDetail sequenceDetail)
        {
            if (SequenceDetails == null)
            {
                SequenceDetails = new List<SequenceDetail>();
            }

            SequenceDetails.Add(sequenceDetail);
        }
Example #2
0
        private SequenceMaster CreateSequenceOrder(IList<object[]> orderDetailAryList)
        {
            if (orderDetailAryList == null || orderDetailAryList.Count() == 0)
            {
                return null;
            }

            string orderNos = string.Empty;
            foreach (string orderNo in orderDetailAryList.Select(o => (string)o[0]))
            {
                if (orderNos == string.Empty)
                {
                    orderNos = orderNo;
                }
                else
                {
                    orderNos += "," + orderNo;
                }
            }

            try
            {
                log.Debug("Start create sequence order, flow[" + orderDetailAryList[0][1] + "], orderNo in [" + orderNos + "].");

                SequenceMaster sequenceMaster = new SequenceMaster();

                sequenceMaster.SequenceNo = this.numberControlMgr.GetSequenceNo(sequenceMaster);
                sequenceMaster.Status = CodeMaster.SequenceStatus.Submit;
                sequenceMaster.Flow = (string)orderDetailAryList[0][1];
                sequenceMaster.OrderType = (CodeMaster.OrderType)((byte)orderDetailAryList[0][2]);
                sequenceMaster.QualityType = (CodeMaster.QualityType)((byte)orderDetailAryList[0][3]);
                sequenceMaster.StartTime = (DateTime)orderDetailAryList[0][4];
                sequenceMaster.WindowTime = (DateTime)orderDetailAryList[0][5];
                sequenceMaster.PartyFrom = (string)orderDetailAryList[0][6];
                sequenceMaster.PartyFromName = (string)orderDetailAryList[0][7];
                sequenceMaster.PartyTo = (string)orderDetailAryList[0][8];
                sequenceMaster.PartyToName = (string)orderDetailAryList[0][9];
                sequenceMaster.ShipFrom = (string)orderDetailAryList[0][10];
                sequenceMaster.ShipFromAddress = (string)orderDetailAryList[0][11];
                sequenceMaster.ShipFromTel = (string)orderDetailAryList[0][12];
                sequenceMaster.ShipFromCell = (string)orderDetailAryList[0][13];
                sequenceMaster.ShipFromFax = (string)orderDetailAryList[0][14];
                sequenceMaster.ShipFromContact = (string)orderDetailAryList[0][15];
                sequenceMaster.ShipTo = (string)orderDetailAryList[0][16];
                sequenceMaster.ShipToAddress = (string)orderDetailAryList[0][17];
                sequenceMaster.ShipToTel = (string)orderDetailAryList[0][18];
                sequenceMaster.ShipToCell = (string)orderDetailAryList[0][19];
                sequenceMaster.ShipToFax = (string)orderDetailAryList[0][20];
                sequenceMaster.ShipToContact = (string)orderDetailAryList[0][21];
                sequenceMaster.LocationFrom = (string)orderDetailAryList[0][22];
                sequenceMaster.LocationFromName = (string)orderDetailAryList[0][23];
                sequenceMaster.LocationTo = (string)orderDetailAryList[0][24];
                sequenceMaster.LocationToName = (string)orderDetailAryList[0][25];
                sequenceMaster.Dock = (string)orderDetailAryList[0][26];
                sequenceMaster.IsAutoReceive = (bool)orderDetailAryList[0][27];
                sequenceMaster.IsPrintAsn = (bool)orderDetailAryList[0][28];
                sequenceMaster.IsPrintReceipt = (bool)orderDetailAryList[0][29];
                sequenceMaster.IsCheckPartyFromAuthority = (bool)orderDetailAryList[0][30];
                sequenceMaster.IsCheckPartyToAuthority = (bool)orderDetailAryList[0][31];
                sequenceMaster.AsnTemplate = (string)orderDetailAryList[0][32];
                sequenceMaster.ReceiptTemplate = (string)orderDetailAryList[0][33];
                sequenceMaster.Container = (string)orderDetailAryList[0][46];
                sequenceMaster.ContainerDescription = (string)orderDetailAryList[0][47];

                this.genericMgr.Create(sequenceMaster);

                foreach (object[] orderDetailAry in orderDetailAryList)
                {
                    SequenceDetail sequenceDetail = new SequenceDetail();

                    sequenceDetail.SequenceNo = sequenceMaster.SequenceNo;
                    sequenceDetail.Sequence = (long)orderDetailAry[34];
                    sequenceDetail.OrderNo = (string)orderDetailAry[0];
                    sequenceDetail.TraceCode = (string)orderDetailAry[35];
                    sequenceDetail.OrderDetailId = (int)orderDetailAry[36];
                    sequenceDetail.OrderDetailSequence = (int)orderDetailAry[37];
                    sequenceDetail.StartTime = (DateTime)orderDetailAry[4];
                    sequenceDetail.WindowTime = (DateTime)orderDetailAry[5];
                    sequenceDetail.Item = (string)orderDetailAry[38];
                    sequenceDetail.ItemDescription = (string)orderDetailAry[39];
                    sequenceDetail.ReferenceItemCode = (string)orderDetailAry[40];
                    sequenceDetail.Uom = (string)orderDetailAry[41];
                    sequenceDetail.UnitQty = (decimal)orderDetailAry[42];
                    sequenceDetail.BaseUom = (string)orderDetailAry[43];
                    sequenceDetail.UnitCount = (decimal)orderDetailAry[44];
                    sequenceDetail.QualityType = (CodeMaster.QualityType)((byte)orderDetailAry[3]);
                    sequenceDetail.ManufactureParty = (string)orderDetailAry[45];
                    sequenceDetail.Qty = (decimal)orderDetailAry[48];
                    sequenceDetail.IsClose = (decimal)orderDetailAry[49] > 0 || (decimal)orderDetailAry[50] > 0; //已排序数量大于0或者收货数大于0,代表已经送过,要把位置空着

                    this.genericMgr.Create(sequenceDetail);
                    sequenceMaster.AddSequenceDetail(sequenceDetail);
                }

                //#region 发送WMS
                //string loc = systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.WMSAnjiRegion);
                //if (sequenceMaster.PartyFrom.Equals(loc, StringComparison.OrdinalIgnoreCase))
                //{
                //    //this.genericMgr.FlushSession();
                //    //this.AsyncRecourdMessageQueue(MethodNameType.CreateSeqOrder, sequenceMaster.SequenceNo);
                //    this.CreateMessageQueue("CreateSeqOrder", sequenceMaster.SequenceNo);
                //}
                //#endregion

                #region 发送打印
                this.AsyncSendPrintData(sequenceMaster, false);
                #endregion

                log.Debug("Success create sequence order, flow[" + orderDetailAryList[0][1] + "], orderNo in [" + orderNos + "]");

                return sequenceMaster;
            }
            catch (Exception ex)
            {
                log.Error("Fail create sequence order, flow[" + orderDetailAryList[0][1] + "], orderNo in [" + orderNos + "]", ex);

                //清空Session
                this.genericMgr.CleanSession();
            }

            return null;
        }