コード例 #1
0
        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
        }
コード例 #2
0
        private void NestingGetNextLevelBomDetail(IList <BomDetail> flatBomDetailList, BomDetail currentBomDetail, DateTime efftiveDate)
        {
            string            nextLevelBomCode  = this.bomMgr.FindBomCode(currentBomDetail.Item);
            IList <BomDetail> nextBomDetailList = this.GetNextLevelBomDetail(nextLevelBomCode, efftiveDate);

            if (nextBomDetailList != null && nextBomDetailList.Count > 0)
            {
                foreach (BomDetail nextBomDetail in nextBomDetailList)
                {
                    if (nextBomDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
                    {
                        //K类型的Item不能出现在Bom结构中
                        throw new BusinessErrorException("Bom.Error.ItemTypeKInBom", nextBomDetail.Bom.Code);
                    }

                    //当前子件的Uom和下层Bom的Uom不匹配,需要做单位转换
                    if (currentBomDetail.Uom.Code.ToUpper() != nextBomDetail.Bom.Uom.Code.ToUpper())
                    {
                        //单位换算
                        nextBomDetail.CalculatedQty = uomConversionMgr.ConvertUomQty(currentBomDetail.Item, currentBomDetail.Uom, 1, nextBomDetail.Bom.Uom)
                                                      * currentBomDetail.CalculatedQty * nextBomDetail.RateQty * (1 + nextBomDetail.ScrapPercentage);
                    }
                    else
                    {
                        nextBomDetail.CalculatedQty = nextBomDetail.RateQty * currentBomDetail.CalculatedQty * (1 + nextBomDetail.ScrapPercentage);
                    }

                    nextBomDetail.OptionalItemGroup = currentBomDetail.OptionalItemGroup;

                    ProcessCurrentBomDetail(flatBomDetailList, nextBomDetail, efftiveDate);
                }
            }
            else
            {
                throw new BusinessErrorException("Bom.Error.NotFoundForItem", currentBomDetail.Item.Code);
            }
        }
コード例 #3
0
        public IList <FlowDetail> GetBindedFlowDetail(int orderDetailId, string slaveFlowCode)
        {
            OrderDetail        orderDetail = this.orderDetailMgr.LoadOrderDetail(orderDetailId);
            IList <FlowDetail> returnList  = new List <FlowDetail>();

            IList <OrderLocationTransaction> orderLocTransList =
                this.orderDetailMgr.LoadOrderDetail(orderDetail.Id, true).OrderLocationTransactions;

            Flow flow = flowMgr.LoadFlow(slaveFlowCode, true, true);
            IList <FlowDetail> flowDetailList = flow.FlowDetails;

            //记录已经被绑定的路线明细,避免采购绑定销售的时候重复累加数量
            //(因为百利得有内部销售的需求,所以现在双方都没有目的库位也可以绑定,这就造成采购绑定销售的时候重复累加数量)
            IDictionary <int, FlowDetail> bindedFlowDetail = new Dictionary <int, FlowDetail>();

            if (orderLocTransList != null && orderLocTransList.Count > 0 && flowDetailList.Count > 0)
            {
                foreach (OrderLocationTransaction orderLocTrans in orderLocTransList)
                {
                    //if (orderLocTrans.Location == null)
                    //{
                    //    continue;
                    //}

                    string itemCode     = orderLocTrans.Item.Code;
                    string locationCode = orderLocTrans.Location != null ? orderLocTrans.Location.Code : null;

                    foreach (FlowDetail flowDetail in flowDetailList)
                    {
                        if (bindedFlowDetail.ContainsKey(flowDetail.Id))
                        {
                            continue;
                        }

                        if (itemCode.Trim().ToUpper() != flowDetail.Item.Code.Trim().ToUpper())
                        {
                            continue;
                        }

                        Location fromLoc = null;
                        Location toLoc   = null;
                        if (flowDetail.Flow.Code.Trim().ToUpper() == slaveFlowCode.Trim().ToUpper())
                        {
                            fromLoc = flowDetail.DefaultLocationFrom;
                            toLoc   = flowDetail.DefaultLocationTo;
                        }
                        else
                        {
                            //reference flow
                            fromLoc = flow.LocationFrom;
                            toLoc   = flow.LocationTo;
                        }

                        if (orderLocTrans.IOType == BusinessConstants.IO_TYPE_IN)
                        {
                            //Master LocationTo == Slave LocationFrom
                            //if (fromLoc == null)
                            //{
                            //    continue;
                            //}

                            if ((fromLoc == null && locationCode == null) ||
                                (fromLoc != null && locationCode != null && fromLoc.Code.Trim().ToUpper() == locationCode.Trim().ToUpper()))
                            {
                                bindedFlowDetail.Add(flowDetail.Id, flowDetail);
                                decimal orderedQty = orderLocTrans.OrderedQty;
                                if (flowDetail.Uom.Code != orderLocTrans.Uom.Code)
                                {
                                    orderedQty = uomConversionMgr.ConvertUomQty(flowDetail.Item, orderLocTrans.Uom, orderLocTrans.OrderedQty, flowDetail.Uom);
                                }
                                flowDetail.OrderedQty += orderedQty;

                                if (!returnList.Contains(flowDetail))
                                {
                                    returnList.Add(flowDetail);
                                }
                            }
                        }
                        else
                        {
                            //Master LocationFrom == Slave LocationTo
                            //if (toLoc == null)
                            //{
                            //    continue;
                            //}

                            if ((toLoc == null && locationCode == null) ||
                                (toLoc != null && locationCode != null && toLoc.Code.Trim().ToUpper() == locationCode.Trim().ToUpper()))
                            {
                                bindedFlowDetail.Add(flowDetail.Id, flowDetail);
                                decimal orderedQty = orderLocTrans.OrderedQty;
                                if (flowDetail.Uom.Code != orderLocTrans.Uom.Code)
                                {
                                    orderedQty = uomConversionMgr.ConvertUomQty(flowDetail.Item, orderLocTrans.Uom, orderLocTrans.OrderedQty, flowDetail.Uom);
                                }
                                flowDetail.OrderedQty += orderedQty;

                                if (!returnList.Contains(flowDetail))
                                {
                                    returnList.Add(flowDetail);
                                }
                            }
                        }
                    }
                }
            }

            return(returnList);
        }