public OrderBinding CreateOrderBinding(OrderHead order, Flow bindedFlow, string bindingType)
        {
            OrderBinding orderBinding = new OrderBinding();

            orderBinding.OrderHead = order;
            orderBinding.BindedFlow = bindedFlow;
            orderBinding.BindingType = bindingType;

            this.CreateOrderBinding(orderBinding);

            return orderBinding;
        }
Beispiel #2
0
 public void FillDetailByFlow(Resolver resolver, Flow flow)
 {
     foreach (FlowDetail flowDetail in flow.FlowDetails)
     {
         flowDetail.LocationFrom = flowDetail.LocationFrom == null ? flow.LocationFrom : flowDetail.LocationFrom;
         flowDetail.LocationTo = flowDetail.LocationTo == null ? flow.LocationTo : flowDetail.LocationTo;
         //if (resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_RECEIVERETURN
         //    || resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_SHIPRETURN)
         //{
         //    Location tempLocation = flowDetail.LocationFrom;
         //    flowDetail.LocationFrom = flowDetail.LocationTo;
         //    flowDetail.LocationTo = tempLocation;
         //}
     }
     resolver.Transformers = TransformerHelper.ConvertFlowDetailsToTransformers(flow.FlowDetails);
     //resolver.Command = BusinessConstants.CS_BIND_VALUE_TRANSFORMER;
 }
        public SupplyChain GenerateSupplyChain(Flow flow, FlowDetail flowDetail)
        {
            SupplyChain supplyChain = new SupplyChain();
            supplyChain.Flow = flow;
            supplyChain.FlowDetail = flowDetail;

            SupplyChainDetail supplyChainDetail = new SupplyChainDetail();
            supplyChainDetail.SupplyChain = supplyChain;
            supplyChainDetail.Id = 1;
            supplyChainDetail.ParentId = 0;
            supplyChainDetail.Flow = flow;
            supplyChainDetail.FlowDetail = flowDetail;
            supplyChainDetail.LocationTo = flowDetail.DefaultLocationTo == null ? null : flowDetail.DefaultLocationTo;
            supplyChainDetail.QuantityPer = 1;

            IList<SupplyChainDetail> supplyChainDetailList = new List<SupplyChainDetail>();
            supplyChainDetailList.Add(supplyChainDetail);
            this.GetSupplyChainDetail(supplyChainDetailList, supplyChainDetail);

            supplyChain.AddRangeSupplyChainDetail(supplyChainDetailList);
            return supplyChain;
        }
        public void RecordLocationTransaction(InventoryTransaction inventoryTransaction, string transType, User user, string orderNo, Location refLocation, Flow productLine, string receiptNo, int? orderDetailId)
        {
            LocationTransaction locationTransaction = new LocationTransaction();

            if (inventoryTransaction.Hu != null)
            {
                locationTransaction.HuId = inventoryTransaction.Hu.HuId;
                locationTransaction.LotNo = inventoryTransaction.Hu.LotNo;
            }
            if (locationTransaction.LotNo == null || locationTransaction.LotNo == string.Empty)
            {
                locationTransaction.LotNo = inventoryTransaction.LotNo;
            }
            locationTransaction.BatchNo = inventoryTransaction.LocationLotDetailId;
            locationTransaction.Item = inventoryTransaction.Item.Code;
            locationTransaction.ItemDescription = inventoryTransaction.Item.Description;
            locationTransaction.Uom = inventoryTransaction.Item.Uom.Code;
            locationTransaction.Qty = inventoryTransaction.Qty;
            locationTransaction.PartyFrom = inventoryTransaction.Location.Region.Code;
            locationTransaction.PartyFromName = inventoryTransaction.Location.Region.Name;
            locationTransaction.PartyTo = inventoryTransaction.Location.Region.Code;
            locationTransaction.PartyToName = inventoryTransaction.Location.Region.Name;
            locationTransaction.Location = inventoryTransaction.Location.Code;
            locationTransaction.LocationName = inventoryTransaction.Location.Name;
            if (inventoryTransaction.StorageBin != null)
            {
                locationTransaction.StorageArea = inventoryTransaction.StorageBin.Area.Code;
                locationTransaction.StorageAreaDescription = inventoryTransaction.StorageBin.Area.Description;
                locationTransaction.StorageBin = inventoryTransaction.StorageBin.Code;
                locationTransaction.StorageBinDescription = inventoryTransaction.StorageBin.Description;
            }
            locationTransaction.TransactionType = transType;
            locationTransaction.CreateDate = DateTime.Now;
            locationTransaction.CreateUser = user.Code;
            locationTransaction.EffectiveDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            locationTransaction.OrderNo = orderNo;
            locationTransaction.ReceiptNo = receiptNo;
            if (orderDetailId.HasValue)
            {
                locationTransaction.OrderDetailId = orderDetailId.Value;

            }
            if (refLocation != null)
            {
                locationTransaction.RefLocation = refLocation.Code;
                locationTransaction.RefLocationName = refLocation.Name;
            }
            else if (productLine != null)
            {
                locationTransaction.RefLocation = productLine.Code;
                locationTransaction.RefLocationName = productLine.Description;
            }

            this.CreateLocationTransaction(locationTransaction);
        }
Beispiel #5
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;
        }
        public IList<string> FindWinTime(Flow flow, DateTime date)
        {
            if (date != null)
            {
                switch (date.DayOfWeek)
                {
                    case DayOfWeek.Monday:
                        return ParseWinTime(flow.WinTime1);

                    case DayOfWeek.Tuesday:
                        return ParseWinTime(flow.WinTime2);

                    case DayOfWeek.Wednesday:
                        return ParseWinTime(flow.WinTime3);

                    case DayOfWeek.Thursday:
                        return ParseWinTime(flow.WinTime4);

                    case DayOfWeek.Friday:
                        return ParseWinTime(flow.WinTime5);

                    case DayOfWeek.Saturday:
                        return ParseWinTime(flow.WinTime6);

                    case DayOfWeek.Sunday:
                        return ParseWinTime(flow.WinTime7);
                }
            }

            return null;
        }
 public void RawMaterialIn(Flow prodLine, IList<MaterialIn> materialInList, User user)
 {
     this.RawMaterialIn(prodLine.Code, materialInList, user);
 }
Beispiel #8
0
        public void CreateFlowTrack(Flow flow,string eventCode)
        {
            FlowTrack flowTrack = new FlowTrack();
            CloneHelper.CopyProperty(flow, flowTrack, FlowHead2FlowTrackCloneFields);
            flowTrack.BillFrom = flow.BillFrom != null ? flow.BillFrom.Code : string.Empty;
            flowTrack.BillTo = flow.BillTo != null ? flow.BillTo.Code : string.Empty;
            flowTrack.Carrier = flow.Carrier != null ? flow.Carrier.Code : string.Empty;
            flowTrack.CarrierBillAddress = flow.CarrierBillAddress != null ? flow.CarrierBillAddress.Code : string.Empty;
            flowTrack.CreateUser = flow.CreateUser != null ? flow.CreateUser.Code : string.Empty;
            flowTrack.LocationFrom = flow.LocationFrom != null ? flow.LocationFrom.Code : string.Empty;
            flowTrack.LocationTo = flow.LocationTo != null ? flow.LocationTo.Code : string.Empty;
            flowTrack.Currency = flow.Currency != null ? flow.Currency.Code : string.Empty;
            flowTrack.LastModifyUser = flow.LastModifyUser.Code;
            flowTrack.LastModifyDate = DateTime.Now;
            flowTrack.PartyFrom = flow.PartyFrom != null ? flow.PartyFrom.Code : string.Empty;
            flowTrack.PartyTo = flow.PartyTo != null ? flow.PartyTo.Code : string.Empty;
            flowTrack.PriceListFrom = flow.PriceListFrom != null ? flow.PriceListFrom.Code : string.Empty;
            flowTrack.PriceListTo = flow.PriceListTo != null ? flow.PriceListTo.Code : string.Empty;
            flowTrack.ReturnRouting = flow.ReturnRouting != null ? flow.ReturnRouting.Code : string.Empty;
            flowTrack.Routing = flow.Routing != null ? flow.Routing.Code : string.Empty;
            flowTrack.ShipFrom = flow.ShipFrom != null ? flow.ShipFrom.Code : string.Empty;
            flowTrack.ShipTo = flow.ShipTo != null ? flow.ShipTo.Code : string.Empty;
            flowTrack.EventCode = eventCode;

            this.CreateFlowTrack(flowTrack);
        }
        public Receipt QuickReceiveOrder(Flow flow, IList<OrderDetail> orderDetailList, User user, string orderSubType, DateTime winTime, DateTime startTime, bool isUrgent, string referenceOrderNo, string externalOrderNo)
        {
            if (flow.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
            {
                throw new TechnicalException("QuickReceiveOrder not support Production");
            }

            #region 缓存上架信息
            IDictionary<string, string> huIdStorageBinDic = new Dictionary<string, string>();
            foreach (OrderDetail sourceOrderDetail in orderDetailList)
            {
                if (sourceOrderDetail.HuId != null && sourceOrderDetail.HuId.Trim() != string.Empty &&
                    sourceOrderDetail.PutAwayBinCode != null && sourceOrderDetail.PutAwayBinCode.Trim() != string.Empty)
                {
                    if (!huIdStorageBinDic.ContainsKey(sourceOrderDetail.HuId.Trim()))
                    {
                        huIdStorageBinDic.Add(sourceOrderDetail.HuId.Trim(), sourceOrderDetail.PutAwayBinCode.Trim());
                    }
                    else
                    {
                        if (huIdStorageBinDic[sourceOrderDetail.HuId.Trim()] != sourceOrderDetail.PutAwayBinCode.Trim())
                        {
                            throw new BusinessErrorException("Common.Business.Error.OneHuCannotInTwoBin");
                        }
                    }
                }
            }
            #endregion

            #region 初始化订单头
            OrderHead orderHead = this.TransferFlow2Order(flow, orderSubType);

            #region 从不合格品库位退货,收货扫描一定要设为False
            if (orderDetailList != null && orderDetailList.Count > 0)
            {
                //如果不是所有明细的目的库位都是Reject,可能有问题。
                if (orderSubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RTN &&
                    orderDetailList[0].DefaultLocationTo != null &&
                    orderDetailList[0].DefaultLocationTo.Code == BusinessConstants.SYSTEM_LOCATION_REJECT)
                {
                    orderHead.IsReceiptScanHu = false;
                    orderHead.LocationTo = this.locationMgrE.GetRejectLocation();
                }
            }
            #endregion

            IList<OrderDetail> targetOrderDetailList = orderHead.OrderDetails;

            if (targetOrderDetailList == null)
            {
                targetOrderDetailList = new List<OrderDetail>();
            }

            orderHead.SubType = orderSubType;
            orderHead.WindowTime = winTime;
            orderHead.StartTime = startTime;
            orderHead.ReferenceOrderNo = referenceOrderNo;
            orderHead.ExternalOrderNo = externalOrderNo;
            if (isUrgent)
            {
                orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_URGENT;
            }
            else
            {
                orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL;
            }

            orderHead.IsAutoRelease = true;
            orderHead.IsAutoStart = true;
            orderHead.IsAutoCreatePickList = false;
            orderHead.IsAutoShip = false;
            orderHead.IsAutoReceive = false;
            #endregion

            #region 合并OrderDetailList
            if (orderDetailList != null && orderDetailList.Count > 0)
            {
                IList<OrderDetail> newOrderDetailList = new List<OrderDetail>();
                foreach (OrderDetail sourceOrderDetail in orderDetailList)
                {
                    bool findMatch = false;

                    #region 在FlowDetail转换的OrderDetail里面查找匹配项
                    foreach (OrderDetail targetOrderDetail in targetOrderDetailList)
                    {
                        if (sourceOrderDetail.Item.Code == targetOrderDetail.Item.Code
                            && sourceOrderDetail.Uom.Code == targetOrderDetail.Uom.Code
                            && sourceOrderDetail.UnitCount == targetOrderDetail.UnitCount
                            && LocationHelper.IsLocationEqual(sourceOrderDetail.DefaultLocationFrom, targetOrderDetail.DefaultLocationFrom)
                            && LocationHelper.IsLocationEqual(sourceOrderDetail.DefaultLocationTo, targetOrderDetail.DefaultLocationTo))
                        {
                            targetOrderDetail.RequiredQty += sourceOrderDetail.OrderedQty;
                            targetOrderDetail.OrderedQty += sourceOrderDetail.OrderedQty;

                            findMatch = true;

                            break;
                        }
                    }
                    #endregion

                    if (!findMatch)
                    {
                        #region 没有找到匹配项,从新增匹配项中找
                        foreach (OrderDetail newOrderDetail in newOrderDetailList)
                        {
                            if (sourceOrderDetail.Item.Code == newOrderDetail.Item.Code
                            && sourceOrderDetail.Uom.Code == newOrderDetail.Uom.Code
                            && sourceOrderDetail.UnitCount == newOrderDetail.UnitCount
                            && LocationHelper.IsLocationEqual(sourceOrderDetail.DefaultLocationFrom, newOrderDetail.DefaultLocationFrom)
                            && LocationHelper.IsLocationEqual(sourceOrderDetail.DefaultLocationTo, newOrderDetail.DefaultLocationTo))
                            {
                                newOrderDetail.RequiredQty += sourceOrderDetail.OrderedQty;
                                newOrderDetail.OrderedQty += sourceOrderDetail.OrderedQty;

                                findMatch = true;

                                break;
                            }
                        }
                        #endregion

                        if (!findMatch)
                        {
                            #region 还没有找到匹配项,新增到newOrderDetailList中
                            OrderDetail clonedSourceOrderDetail = CloneHelper.DeepClone<OrderDetail>(sourceOrderDetail);
                            clonedSourceOrderDetail.OrderHead = orderHead;
                            newOrderDetailList.Add(clonedSourceOrderDetail);
                            #endregion
                        }
                    }
                }

                if (newOrderDetailList.Count > 0)
                {
                    #region 合并新增的OrderDetail
                    int seqInterval = int.Parse(this.entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL).Value);
                    int maxSeq = 0;
                    foreach (OrderDetail targetOrderDetail in targetOrderDetailList)
                    {
                        if (targetOrderDetail.Sequence > maxSeq)
                        {
                            maxSeq = targetOrderDetail.Sequence;
                        }
                    }

                    foreach (OrderDetail newOrderDetail in newOrderDetailList)
                    {
                        maxSeq += seqInterval;
                        newOrderDetail.Sequence = maxSeq;

                        orderHead.AddOrderDetail(newOrderDetail);
                    }
                    #endregion
                }
            }

            #endregion

            #region 创建订单
            this.CreateOrder(orderHead, user);
            #endregion

            #region 发货
            IList<InProcessLocationDetail> inProcessLocationDetailList = new List<InProcessLocationDetail>();
            foreach (OrderDetail sourceOrderDetail in orderDetailList)
            {
                foreach (OrderDetail targetOrderDetail in orderHead.OrderDetails)
                {
                    if (sourceOrderDetail.Item.Code == targetOrderDetail.Item.Code
                        && sourceOrderDetail.Uom.Code == targetOrderDetail.Uom.Code
                        && sourceOrderDetail.UnitCount == targetOrderDetail.UnitCount
                        && LocationHelper.IsLocationEqual(sourceOrderDetail.DefaultLocationFrom, targetOrderDetail.DefaultLocationFrom)
                        && LocationHelper.IsLocationEqual(sourceOrderDetail.DefaultLocationTo, targetOrderDetail.DefaultLocationTo))
                    {

                        if (orderSubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ
                            && sourceOrderDetail.HuId != null && sourceOrderDetail.HuId.Trim() != string.Empty)
                        {
                            #region 处理按条码的调整,去掉条码,只调整原库位数量
                            InProcessLocationDetail rtnInProcessLocationDetail = new InProcessLocationDetail();

                            rtnInProcessLocationDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(targetOrderDetail.Id, BusinessConstants.IO_TYPE_OUT)[0];
                            Hu hu = this.huMgrE.CheckAndLoadHu(sourceOrderDetail.HuId);
                            rtnInProcessLocationDetail.LotNo = hu.LotNo;
                            rtnInProcessLocationDetail.Qty = 0 - hu.Qty;
                            inProcessLocationDetailList.Add(rtnInProcessLocationDetail);

                            InProcessLocationDetail adjInProcessLocationDetail = new InProcessLocationDetail();
                            adjInProcessLocationDetail.OrderLocationTransaction = rtnInProcessLocationDetail.OrderLocationTransaction;
                            adjInProcessLocationDetail.LotNo = hu.LotNo;
                            adjInProcessLocationDetail.Qty = sourceOrderDetail.OrderedQty + hu.Qty;
                            inProcessLocationDetailList.Add(adjInProcessLocationDetail);
                            #endregion
                        }
                        else
                        {
                            InProcessLocationDetail inProcessLocationDetail = new InProcessLocationDetail();

                            inProcessLocationDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(targetOrderDetail.Id, BusinessConstants.IO_TYPE_OUT)[0];
                            inProcessLocationDetail.HuId = sourceOrderDetail.HuId;
                            if (inProcessLocationDetail.HuId != null && inProcessLocationDetail.HuId.Trim() != string.Empty)
                            {
                                Hu hu = this.huMgrE.CheckAndLoadHu(inProcessLocationDetail.HuId);
                                inProcessLocationDetail.LotNo = hu.LotNo;

                                //设置退货上架库格
                                if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RTN)
                                {
                                    if (huIdStorageBinDic.ContainsKey(hu.HuId))
                                    {
                                        inProcessLocationDetail.ReturnPutAwaySorageBinCode = huIdStorageBinDic[hu.HuId];
                                    }
                                }
                            }
                            inProcessLocationDetail.Qty = sourceOrderDetail.OrderedQty;

                            inProcessLocationDetailList.Add(inProcessLocationDetail);

                            break;
                        }
                    }

                }
            }

            InProcessLocation inProcessLocation = this.ShipOrder(inProcessLocationDetailList, user);
            #endregion

            #region 为收货调整重新赋条码,增加目的库位的条码数量
            if (orderSubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ)
            {
                foreach (InProcessLocationDetail inProcessLocationDetail in inProcessLocation.InProcessLocationDetails)
                {
                    foreach (OrderDetail sourceOrderDetail in orderDetailList)
                    {
                        if (sourceOrderDetail.HuId != null && sourceOrderDetail.HuId.Trim() != string.Empty)
                        {
                            if (sourceOrderDetail.Item.Code == inProcessLocationDetail.OrderLocationTransaction.OrderDetail.Item.Code
                            && sourceOrderDetail.Uom.Code == inProcessLocationDetail.OrderLocationTransaction.OrderDetail.Uom.Code
                            && sourceOrderDetail.UnitCount == inProcessLocationDetail.OrderLocationTransaction.OrderDetail.UnitCount
                            && LocationHelper.IsLocationEqual(sourceOrderDetail.DefaultLocationFrom, inProcessLocationDetail.OrderLocationTransaction.OrderDetail.DefaultLocationFrom)
                            && LocationHelper.IsLocationEqual(sourceOrderDetail.DefaultLocationTo, inProcessLocationDetail.OrderLocationTransaction.OrderDetail.DefaultLocationTo))
                            {

                                Hu hu = this.huMgrE.CheckAndLoadHu(sourceOrderDetail.HuId);
                                inProcessLocationDetail.HuId = hu.HuId;
                                inProcessLocationDetail.LotNo = hu.LotNo;
                                break;
                            }
                        }
                    }
                }
            }
            #endregion

            #region 收货
            if (orderSubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML)
            {
                return ReceiveFromInProcessLocation(inProcessLocation, user, huIdStorageBinDic, externalOrderNo);
            }
            else
            {
                return ReceiveFromInProcessLocation(inProcessLocation, user, null, externalOrderNo);
            }
            #endregion
        }
 public void CreateOrder(Flow flow, string userCode, IList<Hu> huList)
 {
     CreateOrder(flow, userMgrE.CheckAndLoadUser(userCode), huList);
 }
Beispiel #11
0
        public IList<InventoryTransaction> InventoryOut(MaterialIn materialIn, User user, Flow ProductLine)
        {
            Hu hu = null;
            LocationLotDetail huLocationLotDetail = null;
            if (materialIn.HuId != null && materialIn.HuId.Trim() != string.Empty)
            {
                hu = this.huMgr.CheckAndLoadHu(materialIn.HuId);
                IList<LocationLotDetail> locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(materialIn.Location.Code, materialIn.HuId);
                if (locationLotDetailList != null && locationLotDetailList.Count > 0)
                {
                    huLocationLotDetail = locationLotDetailList[0];

                    #region �ж��Ƿ���Ҫ�¼�
                    if (huLocationLotDetail.StorageBin != null)
                    {
                        //�¼�
                        this.InventoryPick(huLocationLotDetail, user);
                    }
                    #endregion
                }
                else
                {
                    throw new BusinessErrorException("Hu.Error.NoInventory", hu.HuId);
                }
            }

            #region ���¿��
            IList<InventoryTransaction> inventoryTransactionList = RecordInventory(
                materialIn.RawMaterial,
                huLocationLotDetail != null ? huLocationLotDetail.Location : materialIn.Location,
                hu != null ? hu.HuId : null,
                hu != null ? hu.LotNo : null,
                0 - materialIn.Qty,
                false,
                null,
                BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_TR,
                null,
                //true,
                user,
                false,
                false,
                null
                );
            #endregion

            #region ��������״̬��Ͷ��Ҳ����;
            if (hu != null && materialIn.Qty > 0)
            {
                hu.Location = null;
                hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_INPROCESS;
                this.huMgr.UpdateHu(hu);
            }
            #endregion

            #region ��¼�������
            foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList)
            {
                this.locationTransactionMgr.RecordLocationTransaction(inventoryTransaction, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_MATERIAL_IN, user, null, null, ProductLine);
            }
            #endregion

            return inventoryTransactionList;
        }
 public OrderHead TransferFlow2Order(Flow flow, bool isGenerateOrderSubsidiary, DateTime startTime)
 {
     return TransferFlow2Order(flow, BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML, isGenerateOrderSubsidiary, startTime);
 }
        public OrderHead TransferFlow2Order(Flow flow, string orderSubType, bool isGenerateOrderSubsidiary, DateTime startTime)
        {
            #region 创建OrderHead
            OrderHead orderHead = new OrderHead();
            CloneHelper.CopyProperty(flow, orderHead, FlowHead2OrderHeadCloneFields);
            orderHead.SubType = orderSubType;
            if (orderHead.PriceList != null)
            {
                orderHead.IsIncludeTax = orderHead.PriceList.IsIncludeTax;
            }
            orderHead.TaxCode = entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_TAX_RATE).Value;
            if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO
                && flow.ReturnRouting != null)     //返工,使用ReturnRouting
            {
                orderHead.Routing = flow.ReturnRouting;
            }
            //if (orderSubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RTN
            //    || orderSubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO)
            //{
            //    //退货和次品库位设置
            //    if (flow.LocationFrom != null && flow.LocationFrom.ActingLocation != null)
            //    {
            //        orderHead.LocationFrom = flow.LocationFrom.ActingLocation;
            //    }

            //    if (flow.LocationTo != null && flow.LocationTo.ActingLocation != null)
            //    {
            //        orderHead.LocationTo = flow.LocationTo.ActingLocation;
            //    }
            //}
            if (orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO)
            {
                orderHead.LocationTo = this.locationMgrE.GetRejectLocation();
            }
            orderHead.StartTime = startTime;
            orderHead.Flow = flow.Code;
            orderHead.SubType = orderSubType;
            orderHead.Priority = orderHead.Priority == null ? BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL : orderHead.Priority;
            #endregion

            #region 创建OrderDetail
            IList<FlowDetail> flowDetaiList = new List<FlowDetail>();
            if (flow.FlowDetails != null && flow.FlowDetails.Count > 0)
            {
                IListHelper.AddRange<FlowDetail>(flowDetaiList, flow.FlowDetails);
            }

            //根据引用路线创建订单明细
            if (flow.ReferenceFlow != null && flow.ReferenceFlow.Trim() != string.Empty)
            {
                Flow referenceFlow = this.flowMgrE.LoadFlow(flow.ReferenceFlow);
                if (flow.Routing != null && referenceFlow.Routing != null
                    && !flow.Routing.Equals(referenceFlow.Routing))
                {
                    throw new BusinessErrorException("Flow.Error.ReferenceFlowRoutingNotEqual", flow.Code, referenceFlow.Code);
                }

                if (referenceFlow.FlowDetails != null && referenceFlow.FlowDetails.Count > 0)
                {
                    IListHelper.AddRange<FlowDetail>(flowDetaiList, referenceFlow.FlowDetails);
                }
            }

            //先根据序号排序,序号在生成订单的时候会重新生成
            flowDetaiList = IListHelper.Sort<FlowDetail>(flowDetaiList, "Sequence");
            foreach (FlowDetail flowDetail in flowDetaiList)
            {
                if (orderHead.Flow == flowDetail.Flow.Code)
                {
                    this.orderDetailMgrE.GenerateOrderDetail(orderHead, flowDetail, false);
                }
                else
                {
                    this.orderDetailMgrE.GenerateOrderDetail(orderHead, flowDetail, true);
                }
            }
            #endregion

            if (isGenerateOrderSubsidiary)
            {
                orderHead.StartTime = startTime;
                this.orderHeadMgrE.GenerateOrderHeadSubsidiary(orderHead);
            }

            return orderHead;
        }
 public OrderHead TransferFlow2Order(Flow flow, string orderSubType, bool isGenerateOrderSubsidiary)
 {
     return TransferFlow2Order(flow, orderSubType, isGenerateOrderSubsidiary, DateTime.Now);
 }
 public OrderHead TransferFlow2Order(Flow flow, string orderSubType)
 {
     return TransferFlow2Order(flow, orderSubType, false, DateTime.Now);
 }
 public OrderHead TransferFlow2Order(Flow flow)
 {
     return TransferFlow2Order(flow, BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML, false, DateTime.Now);
 }
        public static bool IsFlowEqual(Flow flow1, Flow flow2)
        {
            if (flow1 == null && flow2 == null)
            {
                return true;
            }

            if (flow1 == null && flow2 != null)
            {
                return false;
            }

            if (flow1 != null && flow2 == null)
            {
                return false;
            }

            if (flow1.Code == flow2.Code)
            {
                return true;
            }
            else
            {
                return false;

            }
        }
        public void CreateOrder(Flow flow, User user, IList<Hu> huList)
        {

            #region 初始化订单头
            OrderHead orderHead = this.TransferFlow2Order(flow);


            IList<OrderDetail> targetOrderDetailList = orderHead.OrderDetails;

            orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL;
            orderHead.SubType = BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RWO;
            orderHead.WindowTime = DateTime.Now;
            orderHead.StartTime = DateTime.Now;

            orderHead.IsAutoRelease = false;
            orderHead.IsAutoStart = true;
            orderHead.IsAutoShip = false;
            orderHead.IsAutoReceive = false;
            #endregion

            #region 合并OrderDetailList
            if (huList != null && huList.Count > 0)
            {
                IList<OrderDetail> newOrderDetailList = new List<OrderDetail>();
                foreach (Hu hu in huList)
                {
                    bool findMatch = false;

                    #region 在FlowDetail转换的OrderDetail里面查找匹配项
                    foreach (OrderDetail targetOrderDetail in targetOrderDetailList)
                    {
                        if (hu.Item.Code == targetOrderDetail.Item.Code
                            && hu.Uom.Code == targetOrderDetail.Uom.Code)
                        {
                            targetOrderDetail.RequiredQty += hu.Qty;
                            targetOrderDetail.OrderedQty += hu.Qty;
                            findMatch = true;
                            break;
                        }
                    }
                    #endregion

                    if (!findMatch)
                    {
                        #region 没有找到匹配项,从新增匹配项中找
                        foreach (OrderDetail newOrderDetail in newOrderDetailList)
                        {
                            if (hu.Item.Code == newOrderDetail.Item.Code
                            && hu.Uom.Code == newOrderDetail.Uom.Code)
                            {
                                newOrderDetail.RequiredQty += hu.Qty;
                                newOrderDetail.OrderedQty += hu.Qty;

                                findMatch = true;

                                break;
                            }
                        }
                        #endregion

                        if (!findMatch)
                        {
                            #region 还没有找到匹配项,报错
                            throw new BusinessErrorException("OrderDetail.Item.NotInFlow");
                            #endregion
                        }
                    }
                }

                if (newOrderDetailList.Count > 0)
                {
                    #region 合并新增的OrderDetail
                    int seqInterval = int.Parse(this.entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL).Value);
                    int maxSeq = 0;
                    foreach (OrderDetail targetOrderDetail in targetOrderDetailList)
                    {
                        if (targetOrderDetail.Sequence > maxSeq)
                        {
                            maxSeq = targetOrderDetail.Sequence;
                        }
                    }

                    foreach (OrderDetail newOrderDetail in newOrderDetailList)
                    {
                        maxSeq += seqInterval;
                        newOrderDetail.Sequence = maxSeq;

                        orderHead.AddOrderDetail(newOrderDetail);
                    }
                    #endregion
                }
            }

            #endregion

            #region 创建订单
            CreateOrder(orderHead, user);
            #endregion

            #region 更新订单bom数量为负
            foreach (OrderDetail orderDetail in orderHead.OrderDetails)
            {

                IList<OrderLocationTransaction> orderLocTransList = orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_OUT);
                foreach (OrderLocationTransaction ordeLocTrans in orderLocTransList)
                {
                    if (ordeLocTrans.Item.Code == ordeLocTrans.OrderDetail.Item.Code)
                    {
                        continue;
                    }
                    else
                    {
                        ordeLocTrans.OrderedQty = 0 - ordeLocTrans.OrderedQty;
                        orderLocationTransactionMgrE.UpdateOrderLocationTransaction(ordeLocTrans);
                    }
                }
            }

            #endregion

            ReleaseReuseOrder(orderHead, user, huList);


        }
        public static int GetMaxFlowSeq(Flow flow)
        {
            int maxSeq = 0;
            if (flow.FlowDetails != null && flow.FlowDetails.Count > 0)
            {
                foreach (FlowDetail flowDetail in flow.FlowDetails)
                {
                    if (flowDetail.Sequence > maxSeq)
                    {
                        maxSeq = flowDetail.Sequence;
                    }
                }
            }

            return maxSeq;
        }
 public void GeneratePlanning(Flow flow)
 {
 }
Beispiel #21
0
        public void FillResolverByFlow(Resolver resolver, Flow flow)
        {
            User user = userMgr.CheckAndLoadUser(resolver.UserCode);
            //Flow flow = flowMgr.CheckAndLoadFlow(resolver.Input);

            #region 校验
            if (!flow.IsActive)
            {
                throw new BusinessErrorException("Common.Business.Error.EntityInActive", flow.Code);
            }

            //if (!user.HasPermission(flow.PartyFrom.Code)
            //|| !user.HasPermission(flow.PartyTo.Code))
            //{
            //    throw new BusinessErrorException("Common.Business.Error.NoPermission");
            //}
            #endregion

            resolver.Code = flow.Code;
            resolver.Description = flow.Description;
            resolver.IsScanHu = flow.IsShipScanHu || flow.IsReceiptScanHu;
            resolver.OrderType = flow.Type;
            resolver.AllowCreateDetail = flow.AllowCreateDetail;
            resolver.NeedPrintAsn = flow.NeedPrintAsn;
            resolver.NeedPrintReceipt = flow.NeedPrintReceipt;
            resolver.AutoPrintHu = flow.AutoPrintHu;
            resolver.AllowExceed = flow.AllowExceed;
            resolver.AntiResolveHu = flow.AntiResolveHu;
            resolver.IsOddCreateHu = flow.IsOddCreateHu;
            resolver.IsPickFromBin = flow.IsPickFromBin;
            resolver.CodePrefix = BusinessConstants.BARCODE_HEAD_FLOW;
            resolver.LocationFormCode = flow.LocationFrom == null ? string.Empty : flow.LocationFrom.Code;
            resolver.LocationToCode = flow.LocationTo == null ? string.Empty : flow.LocationTo.Code;
            resolver.FulfillUnitCount = flow.FulfillUnitCount;

            resolver.Result = languageMgr.TranslateMessage("Common.Business.Message.Flow", resolver.UserCode) + resolver.Description;
        }
Beispiel #22
0
 public IList<FlowDetail> GetFlowDetail(Flow flow)
 {
     return GetFlowDetail(flow, false);
 }
Beispiel #23
0
 private Hu ResolveAndCreateHu(string barCode, Flow flow)
 {
     IList<OrderDetail> orderDetailList = orderMgr.TransferFlow2Order(flow).OrderDetails;
     return ResolveAndCreateHu(barCode, orderDetailList);
 }
 public Receipt QuickReceiveOrder(Flow flow, IList<OrderDetail> orderDetailList, User user)
 {
     DateTime dateTimeNow = DateTime.Now;
     return this.QuickReceiveOrder(flow, orderDetailList, user, BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML,
        dateTimeNow, dateTimeNow, false, null, null);
 }
 public void GeneratePlanning(Flow flow, FlowDetail flowDetail)
 {
 }
Beispiel #26
0
 public override void CreateFlow(Flow flow)
 {
     base.Create(flow);
     flowTrackMgr.CreateFlowTrack(flow, BusinessConstants.TRACK_EVENT_CREATE);
 }
Beispiel #27
0
        public IList<FlowDetail> GetFlowDetail(Flow flow, bool includeRefDetail)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(FlowDetail));

            if (includeRefDetail && flow.ReferenceFlow != null && flow.ReferenceFlow.Trim() != string.Empty)
            {
                criteria.Add(Expression.Or(Expression.Eq("Flow.Code", flow.Code), Expression.Eq("Flow.Code", flow.ReferenceFlow)));
            }
            else
            {
                criteria.Add(Expression.Eq("Flow.Code", flow.Code));
            }

            criteria.AddOrder(Order.Asc("Sequence"));

            return criteriaMgr.FindAll<FlowDetail>(criteria);
        }
Beispiel #28
0
 public void UpdateFlow(Flow flow, bool isTrack)
 {
     base.UpdateFlow(flow);
     if (isTrack)
     {
         flowTrackMgr.CreateFlowTrack(flow, BusinessConstants.TRACK_EVENT_UPDATE);
     }
 }
 public IList<BomDetail> GetBatchFeedBomDetail(Flow flow)
 {
     return GetBatchFeedBomDetail(flow.Code);
 }
 public void RecordLocationTransaction(InventoryTransaction inventoryTransaction, string transType, User user, string orderNo, Location refLocation, Flow productLine, string receiptNo)
 {
     this.RecordLocationTransaction(inventoryTransaction, transType, user, orderNo, refLocation, null, null, null);
 }