Inheritance: OrderDetailBase
        /// <remarks/>
        public void AddOrderDetail(OrderDetail orderDetail)
        {
            if (this.OrderDetails == null)
            {
                this.OrderDetails = new List<OrderDetail>();
                this.OrderDetails.Add(orderDetail);
            }
            else
            {
                //查找Sequence,插入到合适位置
                int position = this.OrderDetails.Count;
                for (int i = 0; i < this.OrderDetails.Count; i++)
                {
                    OrderDetail od = this.OrderDetails[i];
                    if (od.Sequence > orderDetail.Sequence)
                    {
                        position = i;
                        break;
                    }

                    //检查Sequence是否重复
                    if (od.Sequence == orderDetail.Sequence)
                    {
                        throw new BusinessErrorException("OrderDetail.Error.SequenceOverlap", orderDetail.Sequence.ToString());
                    }
                }

                this.OrderDetails.Insert(position, orderDetail);
            }
        }
        public OrderLocationTransaction AddNewMaterial(OrderDetail orderDetail, BomDetail bomDetail, Location orgLocation, decimal orgOrderedQty)
        {
            //�����ѡװ������Ĭ�ϲ���װ�������������
            if (bomDetail.StructureType != BusinessConstants.CODE_MASTER_BOM_DETAIL_TYPE_VALUE_O || bomDetail.Priority != 0)
            {
                foreach (OrderLocationTransaction orderLocationTransaction in orderDetail.OrderLocationTransactions)
                {
                    if (orderLocationTransaction.Item.Code == bomDetail.Item.Code
                        && orderLocationTransaction.Operation == bomDetail.Operation)
                    {
                        //�ϲ���ͬ����
                        //decimal orderedQty = orderDetail.OrderedQty * orgOrderedQty * bomDetail.RateQty * (1 + bomDetail.ScrapPercentage);
                        decimal orderedQty = orgOrderedQty * bomDetail.RateQty * (1 + bomDetail.ScrapPercentage);
                        if (orderLocationTransaction.Uom.Code != bomDetail.Uom.Code)
                        {
                            orderedQty = this.uomConversionMgr.ConvertUomQty(orderLocationTransaction.Item.Code, bomDetail.Uom, orderedQty, orderLocationTransaction.Uom);
                        }
                        orderLocationTransaction.UnitQty += orgOrderedQty * bomDetail.RateQty * (1 + bomDetail.ScrapPercentage);
                        orderLocationTransaction.OrderedQty += orderedQty;
                        this.UpdateOrderLocationTransaction(orderLocationTransaction);

                        return orderLocationTransaction;
                    }
                }

                Location bomLocFrom = bomDetail.Location != null ? bomDetail.Location : orgLocation;
                OrderLocationTransaction newOrderLocationTransaction =
                    this.GenerateOrderLocationTransaction(orderDetail, bomDetail.Item, bomDetail,
                                                        bomDetail.Uom, bomDetail.Operation, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_WO,
                                                        orgOrderedQty * bomDetail.RateQty * (1 + bomDetail.ScrapPercentage), bomLocFrom,
                                                        bomDetail.IsShipScanHu, bomDetail.HuLotSize, bomDetail.NeedPrint, bomDetail.BackFlushMethod, null, null);

                this.CreateOrderLocationTransaction(newOrderLocationTransaction);
                orderDetail.AddOrderLocationTransaction(newOrderLocationTransaction);
                this.orderOperationMgr.TryAddOrderOperation(orderDetail.OrderHead, bomDetail.Operation, bomDetail.Reference);

                return newOrderLocationTransaction;
            }

            return null;
        }
 public void UpdateOrderDetail(OrderDetail orderDetail, User user)
 {
     OrderDetail oldOrderDetail = orderDetailMgrE.LoadOrderDetail(orderDetail.Id);
     //检验权限
     //if (!OrderHelper.CheckOrderOperationAuthrize(oldOrderDetail.OrderHead, user, BusinessConstants.ORDER_OPERATION_EDIT_ORDER_DETAIL))
     //{
     //    throw new BusinessErrorException("OrderDetail.Error.NoEditPermission", oldOrderDetail.OrderHead.OrderNo);
     //}
     orderDetail.Id = 0;
     orderDetail.OrderedQty = oldOrderDetail.OrderedQty;
     orderDetail.RequiredQty = oldOrderDetail.RequiredQty;
     this.DeleteOrderDetail(oldOrderDetail, user);
     this.AddOrderDetail(orderDetail, user);
 }
 private IList<Hu> ResolveAndCreateHu(IList<DssImportHistory> dssImportHistoryList, OrderDetail orderDetail)
 {
     IList<Hu> huList = new List<Hu>();
     if (dssImportHistoryList != null && dssImportHistoryList.Count > 0)
     {
         foreach (var dssImportHistory in dssImportHistoryList)
         {
             Hu hu = this.ResolveAndCreateHu(dssImportHistory.HuId, orderDetail, dssImportHistory.Qty);
             huList.Add(hu);
         }
     }
     return huList;
 }
 public virtual void ReceiveWo(IList<DssImportHistory> list, OrderDetail orderDetail, Receipt receipt)
 {
     try
     {
         IList<Hu> huList = this.ResolveAndCreateHu(list, orderDetail);
         this.orderManager.ReceiveOrder(receipt, this.userMgr.GetMonitorUser());
         this.dssImportHistoryMgr.UpdateDssImportHistory(list, false);
     }
     catch (Exception ex)
     {
         foreach (var dssImportHistory in list)
         {
             dssImportHistory.Memo = ex.Message;
             dssImportHistory.ErrorCount++;
         }
         this.dssImportHistoryMgr.UpdateDssImportHistory(list);
     }
 }
        public string GenerateRMHuId(OrderDetail orderDetail, string lotNo, decimal qty, string idMark)
        {
            #region ��������
            //if (orderDetail.BarCodeType == BusinessConstants.CODE_MASTER_RAW_MATERIAL_BAR_CODE_TYPE_VALUE_DEFAULT)
            //{

            //}
            //else
            //{

            //}
            //ItemCode����Ӧ�̱�ʶ��1λ������ �� ��4λ + ������4λ������4λ��0���룩��������ţ�3λ������3λ��0���룩
            string itemCode = orderDetail.Item.Code;
            string supIdMark = idMark != null && idMark.Trim() != string.Empty ? idMark :
                (orderDetail.IdMark != null && orderDetail.IdMark.Trim() != string.Empty
                ? orderDetail.IdMark.Trim() : BusinessConstants.DEFAULT_SUPPLIER_ID_MARK);
            if (lotNo != null && lotNo.Trim().Length != 0)
            {
                LotNoHelper.validateLotNo(lotNo);
            }
            else
            {
                lotNo = LotNoHelper.GenerateLotNo();
            }

            //��λ���㣬ת��Ϊ������λ
            //������Ӧ��qty * inOrderLocationTransaction.UnitQty��������ʱֱ���õ�λ����
            if (orderDetail.Item.Uom.Code != orderDetail.Uom.Code)
            {
                qty = qty * uomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Uom, qty, orderDetail.Item.Uom);
            }

            string qtyStr = qty.ToString("0.########").PadLeft(4, '0');

            string barCodePrefix = itemCode + supIdMark + lotNo + qtyStr;
            return GenerateNumber(barCodePrefix, 3);
            #endregion
        }
        public string GenerateFGHuId(OrderDetail orderDetail, decimal qty, string idMark)
        {
            #region ��Ʒ����
            //if (orderDetail.BarCodeType == BusinessConstants.CODE_MASTER_FINISH_GOODS_BAR_CODE_TYPE_VALUE_DEFAULT)
            //{

            //}
            //else
            //{

            //}
            //������ʶ����2λ����Ʒʶ����(1λ) ����������4λ (����ͬ5.5.1.2�еĹ������ڱ���) ������1λ (�Դ�д��ĸ��ʾ) ��3λ˳���
            string pl = orderDetail.OrderHead.Flow;
            if (pl.Length > 2)
            {
                //��������ߴ��볤�ȴ���2��ȡ����λ
                pl = pl.Substring(pl.Length - 2);
            }

            string pIdMark = idMark != null && idMark.Trim() != string.Empty ? idMark :
                (orderDetail.IdMark != null && orderDetail.IdMark.Trim() != string.Empty
                ? orderDetail.IdMark.Trim() : BusinessConstants.DEFAULT_FINISHI_GOODS_ID_MARK);
            string lotNo = LotNoHelper.GenerateLotNo();
            string shift = orderDetail.OrderHead.Shift.Code;

            string barCodePrefix = pl + pIdMark + lotNo + shift;
            return GenerateNumber(barCodePrefix, 3);
            #endregion
        }
 public IList<FlowDetail> GetBindedFlowDetail(OrderDetail orderDetail, string slaveFlowCode)
 {
     return this.GetBindedFlowDetail(orderDetail.Id, slaveFlowCode);
 }
 public virtual void UpdateOrderDetail(OrderDetail entity)
 {
     entityDao.UpdateOrderDetail(entity);
 }
 public OrderDetail TransferFlowDetail2OrderDetail(FlowDetail flowDetail)
 {
     OrderDetail orderDetail = new OrderDetail();
     CloneHelper.CopyProperty(flowDetail, orderDetail, FlowDetail2OrderDetailCloneFields);
     return orderDetail;
 }
 public bool CheckOrderDet(OrderDetail orderDetail)
 {
     if (orderDetail.DefaultLocationFrom == null)
         return true;
     else
         return this.CheckOrderDet(orderDetail.Item.Code, orderDetail.DefaultLocationFrom.Code, orderDetail.OrderHead.CheckDetailOption);
 }
        public void GenerateOrderDetailSubsidiary(OrderDetail orderDetail)
        {
            OrderHead orderHead = orderDetail.OrderHead;
            int maxOp = 0;    //记录最大工序号,给成品收货时用
            int minOp = 0;    //记录最小工序号,给返工成品用

            #region 把OrderDetail的收货单位和单位用量转换为BOM单位和单位用量
            //fgUom,fgUnityQty代表接收一个orderDetail.Uom单位(等于订单的收货单位)的FG,等于单位(fgUom)有多少(fgUnityQty)值
            Uom fgUom = orderDetail.Uom;
            decimal fgUnityQty = 1;     //运输物品和生产的成品UnitQty默认为1
            //如果和Bom上的单位不一致,转化为Bom上的单位,不然会导致物料回冲不正确。            
            if (orderDetail.Bom != null && orderDetail.Uom.Code != orderDetail.Bom.Uom.Code)
            {
                fgUom = orderDetail.Bom.Uom;
                fgUnityQty = this.uomConversionMgrE.ConvertUomQty(orderDetail.Item, orderDetail.Uom, fgUnityQty, fgUom);
            }
            #endregion

            #region 创建OrderLocTrans

            if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
            {
                //程序一般不会运行到这里,套件的拆分都在前台进行
                //用户在下订单的时候已经拆分了套件
                //2010-1-19 dingxin
                throw new BusinessErrorException("Order.Error.CreateOrder.ItemTypeK", orderDetail.Item.Code);
            }
            else
            {
                if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT
                    || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_CUSTOMERGOODS
                    || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING)
                {
                    #region 采购,只需要记录入库事务RCT-PO
                    this.orderLocationTransactionMgrE.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, null,
                                fgUnityQty, orderDetail.DefaultLocationFrom,
                                false, orderDetail.HuLotSize, true, null, orderDetail.ItemVersion, this.locationMgrE.GetRejectLocation());

                    this.orderLocationTransactionMgrE.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_PO,
                                fgUnityQty, orderDetail.DefaultLocationTo,
                                false, orderDetail.HuLotSize, true, null, orderDetail.ItemVersion, this.locationMgrE.GetRejectLocation());
                    #endregion
                }
                else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
                {
                    #region 销售,只需要记录出库事务ISS-SO
                    this.orderLocationTransactionMgrE.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_SO,
                                fgUnityQty, orderDetail.DefaultLocationFrom,
                                false, orderDetail.HuLotSize, true, null, null, this.locationMgrE.GetRejectLocation());

                    this.orderLocationTransactionMgrE.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                fgUom, maxOp, BusinessConstants.IO_TYPE_IN, null,
                                fgUnityQty, orderDetail.DefaultLocationTo,
                                false, orderDetail.HuLotSize, true, null, null, this.locationMgrE.GetRejectLocation());
                    #endregion
                }
                else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER)
                {
                    #region 移库,需要记录出库事务ISS-TR和入库事务RCT-TR
                    this.orderLocationTransactionMgrE.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_TR,
                                fgUnityQty, orderDetail.DefaultLocationFrom,
                                false, orderDetail.HuLotSize, true, null, null, this.locationMgrE.GetRejectLocation());

                    this.orderLocationTransactionMgrE.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                                fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_TR,
                                fgUnityQty, orderDetail.DefaultLocationTo,
                                false, orderDetail.HuLotSize, true, null, null, this.locationMgrE.GetRejectLocation());
                    #endregion
                }
                //else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_INSPECTION)
                //{
                //    #region 检验,需要记录出库事务ISS-TR和入库事务RCT-TR
                //    this.orderLocationTransactionMgrE.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                //                fgUom, maxOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_TR,
                //                fgUnityQty, orderDetail.DefaultLocationFrom,
                //                false, orderDetail.HuLotSize, true, null, null, this.locationMgrE.GetRejectLocation());

                //    this.orderLocationTransactionMgrE.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                //                fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_TR,
                //                fgUnityQty, orderDetail.DefaultLocationTo,
                //                false, orderDetail.HuLotSize, true, null, null, this.locationMgrE.GetRejectLocation());
                //    #endregion
                //}
                else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                {
                    #region 创建生产物料的OrderLocTrans
                    //如果是生产订单,必须要有Bom
                    FillBomForOrderDetail(orderDetail);

                    IList<BomDetail> bomDetailList = this.bomDetailMgrE.GetFlatBomDetail(orderDetail.Bom.Code, orderHead.StartTime);
                    if (bomDetailList == null || bomDetailList.Count == 0)
                    {
                        throw new BusinessErrorException("Bom.Error.IsVoid");
                    }
                    foreach (BomDetail bomDetail in bomDetailList)
                    {
                        #region 记录最大工序号
                        //最大工序号是从Bom上取还是从Routing上取?
                        if (maxOp < bomDetail.Operation)
                        {
                            //记录最大工序号
                            maxOp = bomDetail.Operation;
                        }
                        #endregion

                        #region 记录最小工序号
                        //最小工序号是从Bom上取还是从Routing上取?
                        if (minOp > bomDetail.Operation || minOp == 0)
                        {
                            //记录最大工序号
                            minOp = bomDetail.Operation;
                        }
                        #endregion

                        #region 查找物料的来源库位
                        //来源库位查找逻辑BomDetail-->RoutingDetail-->FlowDetail-->Flow
                        Location bomLocFrom = bomDetail.Location;

                        if (orderHead.Routing != null)
                        {
                            //在Routing上查找,并检验Routing上的工序和BOM上的是否匹配
                            RoutingDetail routingDetail = routingDetailMgrE.LoadRoutingDetail(orderHead.Routing, bomDetail.Operation, bomDetail.Reference);
                            if (routingDetail != null)
                            {
                                if (bomLocFrom == null)
                                {
                                    bomLocFrom = routingDetail.Location;
                                }

                                //if (maxOp < routingDetail.Operation)
                                //{
                                //    //记录最大工序号
                                //    maxOp = routingDetail.Operation;
                                //}

                                orderHead.AddOrderOperation(this.orderOperationMgrE.GenerateOrderOperation(orderHead, routingDetail));
                            }
                            //else
                            //{
                            //    //没有找到和BOM上相匹配的工序
                            //    throw new BusinessErrorException("Order.Error.OpNotMatch", bomDetail.Bom.Code, bomDetail.Item.Code, routing.Code, bomDetail.Operation.ToString(), bomDetail.Reference);
                            //}
                        }

                        if (bomLocFrom == null)
                        {
                            //取默认库位FlowDetail-->Flow
                            bomLocFrom = orderDetail.DefaultLocationFrom;
                        }
                        //string bomLocFromType = bomLocFrom != null ? bomLocFrom.Type : null;
                        #endregion

                        #region 查找物料的目的库位
                        //目的库位,如果是生产类型,直接置为Null,其它情况FlowDetail-->Flow
                        Location bomLocTo = (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) ?
                            orderDetail.DefaultLocationTo : null;
                        //string bomLocToType = bomLocTo != null ? bomLocTo.Type : null;
                        #endregion

                        #region 生产物料,只需要记录出库事务ISS-TR
                        this.orderLocationTransactionMgrE.GenerateOrderLocationTransaction(orderDetail, bomDetail.Item, bomDetail,
                                   bomDetail.Uom, bomDetail.Operation, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_WO,
                                   bomDetail.CalculatedQty * fgUnityQty,   //返工,原材料数量默认等于0
                                   bomLocFrom, bomDetail.IsShipScanHu, bomDetail.HuLotSize, bomDetail.NeedPrint, bomDetail.BackFlushMethod, null, this.locationMgrE.GetRejectLocation());
                        #endregion
                    }
                    #endregion

                    #region 生产成品,只需要记录入库事务RCT-WO
                    this.orderLocationTransactionMgrE.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                        fgUom, maxOp, BusinessConstants.IO_TYPE_IN, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_WO,
                                fgUnityQty, orderDetail.DefaultLocationTo,
                                false, orderDetail.HuLotSize, true, null, orderDetail.ItemVersion, this.locationMgrE.GetRejectLocation());

                    //返工,把自己添加到物料中
                    if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO)
                    {
                        //Location loc = orderDetail.DefaultLocationTo.ActingLocation != null ? orderDetail.DefaultLocationTo.ActingLocation : orderDetail.DefaultLocationTo;
                        Location loc = this.locationMgrE.GetRejectLocation();


                        //todo 处理返工的成品是否需要扫描Hu,现在不扫描
                        //返工对成品的投料记RCT-WO事务
                        this.orderLocationTransactionMgrE.GenerateOrderLocationTransaction(orderDetail, orderDetail.Item, null,
                          fgUom, minOp, BusinessConstants.IO_TYPE_OUT, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_WO,
                            fgUnityQty, loc,
                         false, orderDetail.HuLotSize, true, null, null, this.locationMgrE.GetRejectLocation());
                    }
                    #endregion
                }
            }
            #endregion

            #region 生产,给没有Op的OrderLocTrans赋值maxOp
            if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
            {
                if (maxOp == 0)
                {
                    EntityPreference entityPreference = this.entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL);
                    int seqInterval = int.Parse(entityPreference.Value);
                    maxOp = seqInterval; //默认工序号
                }

                if (orderDetail.OrderLocationTransactions != null && orderDetail.OrderLocationTransactions.Count > 0)
                {
                    foreach (OrderLocationTransaction orderLocationTransaction in orderDetail.OrderLocationTransactions)
                    {
                        if (orderLocationTransaction.Operation == 0)
                        {
                            orderLocationTransaction.Operation = maxOp;
                        }
                    }
                }
            }
            #endregion
        }
        public IList<OrderDetail> GenerateOrderDetail(OrderHead orderHead, FlowDetail flowDetail, bool isReferencedFlow)
        {
            EntityPreference entityPreference = this.entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL);
            int seqInterval = int.Parse(entityPreference.Value);

            IList<OrderDetail> orderDetailList = new List<OrderDetail>();
            OrderDetail orderDetail = new OrderDetail();
            orderDetail.FlowDetail = flowDetail;
            orderDetail.OrderHead = orderHead;
            if (!isReferencedFlow)
            {
                CloneHelper.CopyProperty(flowDetail, orderDetail, FlowDetail2OrderDetailCloneFields);
            }
            else
            {
                CloneHelper.CopyProperty(flowDetail, orderDetail, ReferenceOrderDetailCloneFields);
            }

            #region 查找价格
            if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING ||
                orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
            {
                if (orderDetail.DefaultPriceList != null)
                {
                    PriceListDetail priceListDetail = priceListDetailMgrE.GetLastestPriceListDetail(orderDetail.DefaultPriceList, orderDetail.Item, orderHead.StartTime, orderHead.Currency, orderDetail.Uom);
                    orderDetail.IsProvisionalEstimate = priceListDetail == null ? true : priceListDetail.IsProvisionalEstimate;
                    if (priceListDetail != null)
                    {
                        orderDetail.UnitPrice = priceListDetail.UnitPrice;
                        orderDetail.TaxCode = entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_TAX_RATE).Value; //priceListDetail.TaxCode;
                        orderDetail.IsIncludeTax = priceListDetail.IsIncludeTax;
                    }
                }
            }
            #endregion

            #region 设置退货和次品库位
            //if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RTN
            //    || orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO)
            //{
            //    if (flowDetail.LocationFrom != null && flowDetail.LocationFrom.ActingLocation != null)
            //    {
            //        orderDetail.LocationFrom = flowDetail.LocationFrom.ActingLocation;
            //    }

            //    if (flowDetail.LocationTo != null && flowDetail.LocationTo.ActingLocation != null)
            //    {
            //        orderDetail.LocationTo = flowDetail.LocationTo.ActingLocation;
            //    }
            //}
            if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO)
            {
                orderDetail.LocationTo = this.locationMgrE.GetRejectLocation();
            }
            #endregion

            //if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
            //{
            //    #region 处理套件
            //    IList<ItemKit> itemKitList = this.itemKitMgrE.GetChildItemKit(orderDetail.Item.Code);

            //    if (itemKitList != null && itemKitList.Count > 0)
            //    {
            //        int count = 0;
            //        decimal? convertRate = null;
            //        foreach (ItemKit itemKit in itemKitList)
            //        {
            //            count++;

            //            if (!convertRate.HasValue)
            //            {
            //                if (itemKit.ParentItem.Uom.Code != orderDetail.Uom.Code)
            //                {
            //                    convertRate = this.uomConversionMgrE.ConvertUomQty(orderDetail.Item, orderDetail.Uom, 1, itemKit.ParentItem.Uom);
            //                }
            //                else
            //                {
            //                    convertRate = 1;
            //                }
            //            }

            //            OrderDetail orderDetailOfChildKit = new OrderDetail();
            //            CloneHelper.CopyProperty(orderDetail, orderDetailOfChildKit, OrderDetailOfChildKitCloneFields);
            //            orderDetailOfChildKit.Sequence = orderDetailOfChildKit.Sequence + count;
            //            orderDetailOfChildKit.Item = itemKit.ChildItem;
            //            orderDetailOfChildKit.ReferenceItemCode = this.itemReferenceMgrE.GetItemReferenceByItem(itemKit.ChildItem.Code, orderDetail.OrderHead.PartyFrom.Code, orderDetail.OrderHead.PartyTo.Code);
            //            orderDetailOfChildKit.Uom = itemKit.ChildItem.Uom;
            //            orderDetailOfChildKit.UnitCount = itemKit.ChildItem.UnitCount;
            //            //orderDetailOfChildKit.RequiredQty = orderDetailOfChildKit.RequiredQty * itemKit.Qty * convertRate;
            //            //orderDetailOfChildKit.OrderedQty = orderDetailOfChildKit.OrderedQty * itemKit.Qty * convertRate;
            //            orderDetailOfChildKit.GoodsReceiptLotSize = orderDetailOfChildKit.GoodsReceiptLotSize * itemKit.Qty * convertRate;
            //            orderDetailOfChildKit.BatchSize = orderDetailOfChildKit.BatchSize * itemKit.Qty * convertRate;
            //            if (orderDetailOfChildKit.HuLotSize.HasValue)
            //            {
            //                orderDetailOfChildKit.HuLotSize = int.Parse((orderDetailOfChildKit.HuLotSize.Value * itemKit.Qty * convertRate.Value).ToString("#"));
            //            }

            //            #region 计算价格
            //            if (orderDetailOfChildKit.DefaultPriceListFrom != null)
            //            {
            //                PriceListDetail priceListDetailFrom = priceListDetailMgrE.GetLastestPriceListDetail(orderDetailOfChildKit.DefaultPriceListFrom, orderDetailOfChildKit.Item, orderHead.StartTime, orderHead.Currency, orderDetailOfChildKit.Uom);
            //                if (priceListDetailFrom != null)
            //                {
            //                    orderDetailOfChildKit.PriceListDetailFrom = priceListDetailFrom;
            //                }
            //            }
            //            if (orderDetailOfChildKit.DefaultPriceList != null)
            //            {
            //                    PriceListDetail priceListDetail = priceListDetailMgrE.GetLastestPriceListDetail(orderDetailOfChildKit.DefaultPriceList, orderDetailOfChildKit.Item, orderHead.StartTime, orderHead.Currency, orderDetailOfChildKit.Uom);
            //                    orderDetailOfChildKit.IsProvisionalEstimate = priceListDetail == null ? true : priceListDetail.IsProvisionalEstimate;
            //                if (priceListDetailTo != null)
            //                {
            //                    orderDetailOfChildKit.UnitPrice = priceListDetail.UnitPrice;
            //                         orderDetailOfChildKit.IsIncludeTax = priceListDetail.IsIncludeTax;
            //                        orderDetailOfChildKit.TaxCode = entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_TAX_RATE).Value;//priceListDetail.TaxCode;
            //                }
            //            }
            //            #endregion

            //            //重新设置Sequence
            //            int detailCount = orderHead.OrderDetails != null ? orderHead.OrderDetails.Count : 0;
            //            orderDetail.Sequence = (detailCount + 1) * seqInterval;

            //            orderHead.AddOrderDetail(orderDetailOfChildKit);
            //            orderDetailList.Add(orderDetailOfChildKit);
            //        }
            //    }
            //    else
            //    {
            //        throw new BusinessErrorException("ItemKit.Error.NotFoundForParentItem", orderDetail.Item.Code);
            //    }
            //    #endregion
            //}
            //else
            //{
            //重新设置Sequence
            int detailCount = orderHead.OrderDetails != null ? orderHead.OrderDetails.Count : 0;
            orderDetail.Sequence = (detailCount + 1) * seqInterval;

            #region 参考零件号
            if (orderDetail.ReferenceItemCode == null || orderDetail.ReferenceItemCode == string.Empty)
            {
                string firstPartyCode = string.Empty;
                string secondPartyCode = string.Empty;
                if (orderHead.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_DISTRIBUTION)
                {
                    firstPartyCode = orderHead.PartyTo.Code;
                }
                else
                {
                    firstPartyCode = orderHead.PartyFrom.Code;
                }
                orderDetail.ReferenceItemCode = itemReferenceMgrE.GetItemReferenceByItem(orderDetail.Item.Code, firstPartyCode, secondPartyCode);
            }
            #endregion

            #region 设置默认库位
            orderDetail.LocationFrom = orderDetail.LocationFrom == null ? orderHead.LocationFrom : orderDetail.LocationFrom;
            orderDetail.LocationTo = orderDetail.LocationTo == null ? orderHead.LocationTo : orderDetail.LocationTo;
            #endregion

            orderHead.AddOrderDetail(orderDetail);
            orderDetailList.Add(orderDetail);
            //}

            return orderDetailList;
        }
 public void DeleteOrderDetail(OrderDetail orderDetail, User user)
 {
     DeleteOrderDetail(orderDetail.Id, user);
 }
 public void DeleteOrderDetail(OrderDetail orderDetail, string userCode)
 {
     DeleteOrderDetail(orderDetail.Id, this.userMgrE.CheckAndLoadUser(userCode));
 }
        public IList<InProcessLocationDetail> GetInProcessLocationDetail(OrderDetail orderDetail, bool includeGap)
        {
            DetachedCriteria criteria = DetachedCriteria.For<InProcessLocationDetail>();
            criteria.CreateAlias("OrderLocationTransaction", "olt");
            criteria.CreateAlias("olt.OrderDetail", "od");
            criteria.CreateAlias("InProcessLocation", "ip");
            criteria.Add(Expression.Eq("od.Id", orderDetail.Id));
            if (!includeGap)
                criteria.Add(Expression.Eq("ip.Type", BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_NORMAL));

            return this.criteriaMgr.FindAll<InProcessLocationDetail>(criteria);
        }
 public virtual void CreateOrderDetail(OrderDetail entity)
 {
     entityDao.CreateOrderDetail(entity);
 }
        private void FillBomForOrderDetail(OrderDetail orderDetail)
        {
            //Bom的选取顺序orderDetail.Bom(Copy from 路线明细) --> orderDetail.Item.Bom--> 用orderDetail.Item.Code作为BomCode
            if (orderDetail.Bom == null && orderDetail.Item.Bom != null)
            {
                orderDetail.Bom = orderDetail.Item.Bom;
            }

            if (orderDetail.Bom == null)
            {
                Bom bom = this.bomMgrE.LoadBom(orderDetail.Item.Code);
                if (bom != null)
                {
                    orderDetail.Bom = bom;
                }
            }

            if (orderDetail.Bom == null)
            {
                throw new BusinessErrorException("OrderDetail.Error.NoBom", orderDetail.Item.Code);
            }
        }
 public virtual void DeleteOrderDetail(OrderDetail entity)
 {
     entityDao.DeleteOrderDetail(entity);
 }
 public static decimal GetDefaultReceiptQty(OrderDetail orderDetail, string defaultReceiptOpt)
 {
     decimal receiptQty = 0;
     if (defaultReceiptOpt == BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_RECEIPT_OPTION_GOODS_RECEIPT_LOTSIZE)
     {
         receiptQty = orderDetail.GoodsReceiptLotSize.HasValue ? (decimal)orderDetail.GoodsReceiptLotSize : 0;
         if (receiptQty == 0)
         {
             receiptQty = orderDetail.OrderedQty - (orderDetail.ReceivedQty.HasValue ? (decimal)orderDetail.ReceivedQty : 0);
         }
     }
     else if (defaultReceiptOpt == BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_RECEIPT_OPTION_ZERO)
     {
     }
     return receiptQty;
 }
 public string GenerateFGHuId(OrderDetail orderDetail, decimal qty)
 {
     return GenerateFGHuId(orderDetail, qty, null);
 }
        public static bool IsOrderDetailValid(OrderDetail orderDetail, DateTime winTime)
        {
            bool isValid = false;

            DateTime? startDate = orderDetail.FlowDetail == null ? null : orderDetail.FlowDetail.StartDate;
            DateTime? endDate = orderDetail.FlowDetail == null ? null : orderDetail.FlowDetail.EndDate;

            if (winTime.Year.ToString() == "1")
            {
                isValid = true;
            }
            else if (startDate.HasValue && endDate.HasValue && (DateTime)startDate <= winTime && (DateTime)endDate >= winTime)
            {
                isValid = true;
            }
            else if (startDate.HasValue && !endDate.HasValue && (DateTime)startDate <= winTime)
            {
                isValid = true;
            }
            else if (!startDate.HasValue && endDate.HasValue && (DateTime)endDate >= winTime)
            {
                isValid = true;
            }
            else if (!startDate.HasValue && !endDate.HasValue)
            {
                isValid = true;
            }

            return isValid;
        }
 public string GenerateRMHuId(OrderDetail orderDetail, string lotNo, decimal qty)
 {
     return GenerateRMHuId(orderDetail, lotNo, qty, null);
 }
Exemple #24
0
        public OrderHead ReadBatchTransferFromXls(Stream inputStream, User user, string flowCode)
        {
            if (inputStream.Length == 0)
            {
                throw new BusinessErrorException("Import.Stream.Empty");
            }

            Flow flow = flowMgr.LoadFlow(flowCode);
            OrderHead orderHead = orderMgr.TransferFlow2Order(flow);
            orderHead.OrderDetails = new List<OrderDetail>();

            HSSFWorkbook workbook = new HSSFWorkbook(inputStream);

            Sheet sheet = workbook.GetSheetAt(0);
            IEnumerator rows = sheet.GetRowEnumerator();

            ImportHelper.JumpRows(rows, 11);

            #region 列定义
            int colItem = 1;//物料代码
            int colUom = 3;//单位
            int colQty = 4;//数量
            int colHu = 5;//条码
            #endregion

            while (rows.MoveNext())
            {
                Row row = (HSSFRow)rows.Current;
                if (!this.CheckValidDataRow(row, 1, 6))
                {
                    break;//边界
                }

                if (!flow.IsShipScanHu)
                {
                    string itemCode = string.Empty;
                    decimal qty = 0;
                    string uomCode = string.Empty;

                    #region 读取数据
                    #region 读取物料代码
                    itemCode = row.GetCell(colItem) != null ? row.GetCell(colItem).StringCellValue : string.Empty;
                    if (itemCode == null || itemCode.Trim() == string.Empty)
                    {
                        this.ThrowCommonError(row.RowNum, colItem, row.GetCell(colItem));
                    }

                    var i = (
                      from f in flow.FlowDetails
                      where f.Item.Code.Trim().ToUpper() == itemCode.Trim().ToUpper()
                      select f).Count();

                    if (i == 0 && !flow.AllowCreateDetail)
                    {
                        throw new BusinessErrorException("MasterData.Flow.NotAllowCreateDetail", itemCode);
                    }

                    var j = (
                        from c in orderHead.OrderDetails
                        where c.HuId == null && c.Item.Code.Trim().ToUpper() == itemCode.Trim().ToUpper()
                        select c).Count();

                    if (j > 0)
                    {
                        throw new BusinessErrorException("Import.Business.Error.Duplicate", itemCode, (row.RowNum + 1).ToString(), (colItem + 1).ToString());
                    }
                    #endregion

                    #region 读取数量
                    try
                    {
                        qty = Convert.ToDecimal(row.GetCell(colQty).NumericCellValue);
                    }
                    catch
                    {
                        this.ThrowCommonError(row.RowNum, colQty, row.GetCell(colQty));
                    }
                    #endregion

                    #region 读取单位
                    uomCode = row.GetCell(colUom) != null ? row.GetCell(colUom).StringCellValue : string.Empty;
                    if (uomCode == null || uomCode.Trim() == string.Empty)
                    {
                        throw new BusinessErrorException("Import.Read.Error.Empty", (row.RowNum + 1).ToString(), colUom.ToString());
                    }
                    #endregion
                    #endregion

                    #region 填充数据
                    Item item = itemMgr.CheckAndLoadItem(itemCode);
                    Uom uom = uomMgr.CheckAndLoadUom(uomCode);
                    //单位换算
                    if (item.Uom.Code.Trim().ToUpper() != uom.Code.Trim().ToUpper())
                    {
                        qty = uomConversionMgr.ConvertUomQty(item, uom, qty, item.Uom);
                    }

                    OrderDetail newOrderDetail = new OrderDetail();

                    int seqInterval = int.Parse(entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL).Value);

                    if (orderHead.OrderDetails == null || orderHead.OrderDetails.Count == 0)
                    {
                        newOrderDetail.Sequence = seqInterval;
                    }
                    else
                    {
                        newOrderDetail.Sequence = orderHead.OrderDetails.Last<OrderDetail>().Sequence + seqInterval;
                    }
                    newOrderDetail.Item = item;
                    newOrderDetail.Uom = uom;
                    newOrderDetail.OrderedQty = qty;
                    newOrderDetail.RequiredQty = qty;
                    newOrderDetail.UnitCount = item.UnitCount;
                    newOrderDetail.LocationFrom = orderHead.LocationFrom;
                    newOrderDetail.LocationTo = orderHead.LocationTo;
                    orderHead.AddOrderDetail(newOrderDetail);

                    #endregion
                }
                else
                {
                    string huId = string.Empty;

                    #region 读取条码
                    huId = row.GetCell(colHu) != null ? row.GetCell(colHu).StringCellValue : string.Empty;
                    if (huId == null || huId.Trim() == string.Empty)
                    {
                        throw new BusinessErrorException("Import.Read.Error.Empty", (row.RowNum + 1).ToString(), colHu.ToString());
                    }

                    Hu hu = huMgr.CheckAndLoadHu(huId);

                    var i = (
                    from f in flow.FlowDetails
                    where f.Item.Code.Trim().ToUpper() == hu.Item.Code.Trim().ToUpper()
                    select f).Count();

                    if (i == 0 && !flow.AllowCreateDetail)
                    {
                        throw new BusinessErrorException("MasterData.Flow.NotAllowCreateDetail", hu.Item.Code);
                    }

                    var j = (
                        from c in orderHead.OrderDetails
                        where c.HuId != null && c.HuId.Trim().ToUpper() == huId.Trim().ToUpper()
                        select c).Count();

                    if (j > 0)
                        throw new BusinessErrorException("Import.Business.Error.Duplicate", huId, (row.RowNum + 1).ToString(), colHu.ToString());
                    #endregion

                    #region 填充数据

                    OrderDetail newOrderDetail = new OrderDetail();
                    newOrderDetail.IsScanHu = true;
                    int seqInterval = int.Parse(entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL).Value);

                    if (orderHead.OrderDetails == null || orderHead.OrderDetails.Count == 0)
                    {
                        newOrderDetail.Sequence = seqInterval;
                    }
                    else
                    {
                        newOrderDetail.Sequence = orderHead.OrderDetails.Last<OrderDetail>().Sequence + seqInterval;
                    }

                    newOrderDetail.Item = hu.Item;
                    newOrderDetail.Uom = hu.Uom;
                    newOrderDetail.HuId = hu.HuId;
                    newOrderDetail.HuQty = hu.Qty;
                    newOrderDetail.RequiredQty = hu.Qty;
                    newOrderDetail.OrderedQty = hu.Qty;
                    newOrderDetail.UnitCount = hu.UnitCount;
                    newOrderDetail.LocationFrom = orderHead.LocationFrom;
                    newOrderDetail.LocationTo = orderHead.LocationTo;
                    orderHead.AddOrderDetail(newOrderDetail);
                    #endregion
                }
            }

            if (orderHead.OrderDetails.Count == 0)
            {
                throw new BusinessErrorException("Import.Result.Error.ImportNothing");
            }
            return orderHead;
        }
        public static Transformer ConvertOrderDetailToTransformer(OrderDetail orderDetail)
        {
            if (orderDetail == null)
            {
                return null;
            }
            Transformer transformer = new Transformer();
            transformer.ItemCode = orderDetail.Item.Code;
            transformer.ItemDescription = orderDetail.Item.Description;
            transformer.ReferenceItemCode = orderDetail.ReferenceItemCode;
            transformer.UomCode = orderDetail.Uom.Code;
            transformer.UnitCount = orderDetail.UnitCount;
            transformer.LocationFromCode = orderDetail.DefaultLocationFrom != null ? orderDetail.DefaultLocationFrom.Code : null;
            transformer.LocationToCode = orderDetail.DefaultLocationTo != null ? orderDetail.DefaultLocationTo.Code : null;
            transformer.OrderedQty = orderDetail.OrderedQty;
            transformer.Qty = orderDetail.OrderedQty;
            transformer.CurrentQty = orderDetail.GoodsReceiptLotSize.HasValue ? orderDetail.GoodsReceiptLotSize.Value : 0;
            transformer.ReceivedQty = orderDetail.ReceivedQty.HasValue ? orderDetail.ReceivedQty.Value : 0;
            transformer.RejectedQty = orderDetail.RejectedQty.HasValue ? orderDetail.RejectedQty.Value : 0;
            transformer.ScrapQty = orderDetail.ScrapQty.HasValue ? orderDetail.ScrapQty.Value : 0;
            transformer.Sequence = orderDetail.Sequence;
            transformer.ShippedQty = orderDetail.ShippedQty.HasValue ? orderDetail.ShippedQty.Value : 0;
            transformer.Id = orderDetail.Id;

            return transformer;
        }
Exemple #26
0
        public IList<OrderDetail> ConvertResolverToOrderDetails(Resolver resolver, Flow flow)
        {
            OrderHead orderHead = orderMgr.TransferFlow2Order(flow);
            IList<OrderDetail> orderDetails = new List<OrderDetail>();
            if (resolver.Transformers == null)
            {
                throw new BusinessErrorException("OrderDetail.Error.OrderDetailEmpty");
            }
            foreach (Transformer transformer in resolver.Transformers)
            {
                if (transformer.TransformerDetails != null)
                {
                    foreach (TransformerDetail transformerDetail in transformer.TransformerDetails)
                    {
                        if (transformerDetail.CurrentQty == 0) //数量为零的过滤掉
                        {
                            continue;
                        }

                        OrderDetail newOrderDetail = new OrderDetail();
                        //newOrderDetail.IsScanHu = true;
                        int seqInterval = int.Parse(entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL).Value);
                        if (orderDetails == null || orderDetails.Count == 0)
                        {
                            newOrderDetail.Sequence = seqInterval;
                        }
                        else
                        {
                            newOrderDetail.Sequence = orderDetails.Last<OrderDetail>().Sequence + seqInterval;
                        }
                        newOrderDetail.Item = itemMgr.LoadItem(transformerDetail.ItemCode);
                        newOrderDetail.Uom = uomMgr.LoadUom(transformerDetail.UomCode);
                        newOrderDetail.HuId = transformerDetail.HuId;
                        if ((resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_SHIPRETURN)
                                || resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_RECEIVERETURN)
                        {
                            newOrderDetail.OrderedQty = -transformerDetail.CurrentQty;
                            newOrderDetail.HuQty = -transformerDetail.Qty;
                        }
                        else
                        {
                            newOrderDetail.OrderedQty = transformerDetail.CurrentQty;
                            newOrderDetail.HuQty = transformerDetail.Qty;
                        }
                        if (!(resolver.OrderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT
                            || resolver.OrderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_CUSTOMERGOODS))
                        {
                            newOrderDetail.LocationFrom = locationMgr.LoadLocation(transformer.LocationFromCode);
                        }
                        if (!(resolver.OrderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION))
                        {
                            newOrderDetail.LocationTo = locationMgr.LoadLocation(transformer.LocationToCode);
                        }
                        newOrderDetail.ReferenceItemCode = transformer.ReferenceItemCode;
                        newOrderDetail.UnitCount = transformerDetail.UnitCount;
                        //newOrderDetail.PackageType = transformerDetail.PackageType;
                        newOrderDetail.OrderHead = orderHead;
                        newOrderDetail.IsScanHu = true;
                        newOrderDetail.PutAwayBinCode = resolver.BinCode;
                        orderDetails.Add(newOrderDetail);
                    }
                }
            }
            return orderDetails;
        }
        private Hu CreateItemHu(string barCode, OrderDetail orderDetail, string lotNo, DateTime manufactureDate)
        {
            Item item = orderDetail.Item;
            decimal qty = 1;

            Hu hu = new Hu();
            hu.HuId = barCode;
            hu.Item = item;
            hu.Uom = orderDetail.Uom;   //用Flow单位
            #region 单位用量
            if (item.Uom.Code != orderDetail.Uom.Code)
            {
                hu.UnitQty = this.uomConversionMgr.ConvertUomQty(item, orderDetail.Uom, 1, item.Uom);   //单位用量
            }
            else
            {
                hu.UnitQty = 1;
            }
            #endregion
            hu.QualityLevel = BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_1;
            hu.Qty = qty;
            hu.UnitCount = 1;
            hu.LotNo = lotNo;
            hu.LotSize = 1;
            hu.ManufactureDate = manufactureDate;
            hu.ManufactureParty = orderDetail.OrderHead.PartyFrom;
            hu.CreateUser = this.userMgr.GetMonitorUser();
            hu.CreateDate = DateTime.Now;
            hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CREATE;

            this.huMgr.CreateHu(hu);

            return hu;
        }
Exemple #28
0
 /// <summary>
 /// 移库使用
 /// </summary>
 /// <param name="resolver"></param>
 /// <returns></returns>
 public IList<OrderDetail> ConvertResolverToOrderDetails(Resolver resolver)
 {
     IList<OrderDetail> orderDetailList = new List<OrderDetail>();
     if (resolver.IsScanHu)
     {
         foreach (Transformer transformer in resolver.Transformers)
         {
             foreach (TransformerDetail transformerDetail in transformer.TransformerDetails)
             {
                 OrderDetail orderDetail = new OrderDetail();
                 orderDetail.UnitCount = transformerDetail.UnitCount;
                 orderDetail.Item = itemMgr.LoadItem(transformerDetail.ItemCode);
                 orderDetail.Uom = uomMgr.LoadUom(transformerDetail.UomCode);
                 orderDetail.LocationFrom = locationMgr.LoadLocation(transformer.LocationFromCode);
                 orderDetail.LocationTo = locationMgr.LoadLocation(transformer.LocationToCode);
                 orderDetail.HuId = transformerDetail.HuId;
                 orderDetail.OrderedQty = transformerDetail.CurrentQty;
                 orderDetail.RequiredQty = transformerDetail.CurrentQty;
                 orderDetail.PutAwayBinCode = transformerDetail.StorageBinCode;
                 orderDetailList.Add(orderDetail);
             }
         }
     }
     else
     {
         foreach (Transformer transformer in resolver.Transformers)
         {
             OrderDetail orderDetail = new OrderDetail();
             orderDetail.UnitCount = transformer.UnitCount;
             orderDetail.Item = itemMgr.LoadItem(transformer.ItemCode);
             orderDetail.Uom = uomMgr.LoadUom(transformer.UomCode);
             orderDetail.LocationFrom = locationMgr.LoadLocation(transformer.LocationFromCode);
             orderDetail.LocationTo = locationMgr.LoadLocation(transformer.LocationToCode);
             orderDetail.OrderedQty = transformer.CurrentQty;
             orderDetail.RequiredQty = transformer.CurrentQty;
             orderDetailList.Add(orderDetail);
         }
     }
     return orderDetailList;
 }
        private Hu ResolveAndCreateHu(string barCode, OrderDetail orderDetail, decimal qty)
        {
            string[] splitedBarcode = BarcodeHelper.SplitFGBarcode(barCode);
            Item item = orderDetail.Item;
            string lotNo = splitedBarcode[2];
            DateTime manufactureDate = LotNoHelper.ResolveLotNo(lotNo);

            Hu hu = new Hu();
            hu.HuId = barCode;
            hu.Item = item;
            hu.Uom = orderDetail.Uom;   //用Flow单位
            #region 单位用量
            if (item.Uom.Code != orderDetail.Uom.Code)
            {
                hu.UnitQty = this.uomConversionMgr.ConvertUomQty(item, orderDetail.Uom, 1, item.Uom);   //单位用量
            }
            else
            {
                hu.UnitQty = 1;
            }
            #endregion
            hu.QualityLevel = BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_1;
            hu.Qty = qty;
            hu.UnitCount = orderDetail.UnitCount;
            hu.LotNo = lotNo;
            hu.LotSize = qty;
            hu.ManufactureDate = manufactureDate;
            hu.ManufactureParty = orderDetail.OrderHead.PartyFrom;
            hu.CreateUser = this.userMgr.GetMonitorUser();
            hu.CreateDate = DateTime.Now;
            hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CREATE;

            this.huMgr.CreateHu(hu);
            this.numberControlMgr.ReverseUpdateHuId(barCode);

            return hu;
        }
 public IList<InProcessLocationDetail> GetInProcessLocationDetail(OrderDetail orderDetail)
 {
     return this.GetInProcessLocationDetail(orderDetail, false);
 }