public IList<ReceiptDetail> CreateReceiptDetail(Receipt receipt, OrderLocationTransaction inOrderLocationTransaction, IList<Hu> huList) { IList<ReceiptDetail> receiptDetailList = new List<ReceiptDetail>(); foreach (Hu hu in huList) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.Receipt = receipt; receiptDetail.OrderLocationTransaction = inOrderLocationTransaction; receiptDetail.HuId = hu.HuId; receiptDetail.LotNo = hu.LotNo; //����hu����������ж�����Ʒ���Ǵ�Ʒ if (hu.QualityLevel == BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_1) { //�ȳ�Hu.UnitQtyתΪ������λ���ڳ�outOrderLocationTransaction.UnitQtyתΪ������λ�� receiptDetail.ReceivedQty = hu.Qty * hu.UnitQty / inOrderLocationTransaction.UnitQty; } else if (hu.QualityLevel == BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_2) { receiptDetail.RejectedQty = hu.Qty * hu.UnitQty / inOrderLocationTransaction.UnitQty; } else { throw new TechnicalException("hu quality level:" + hu.QualityLevel + " not valided"); } this.CreateReceiptDetail(receiptDetail); receiptDetailList.Add(receiptDetail); receipt.AddReceiptDetail(receiptDetail); } return receiptDetailList; }
public void AddHuReceiptDetails(ReceiptDetail receiptDetail) { if (this.HuReceiptDetails == null) { this.HuReceiptDetails = new List <ReceiptDetail>(); } this.HuReceiptDetails.Add(receiptDetail); }
public void AddReceiptDetail(ReceiptDetail receiptDetail) { if (this.ReceiptDetails == null) { this.ReceiptDetails = new List<ReceiptDetail>(); } this.ReceiptDetails.Add(receiptDetail); }
public Resolver ReceiveOrder(Resolver resolver) { ReceiptDetail recDet = new ReceiptDetail(); IList<ReceiptDetail> receiptDetailList = orderMgr.ConvertTransformerToReceiptDetail(resolver.Transformers); InProcessLocation ip = null; if (resolver.CodePrefix == BusinessConstants.CODE_PREFIX_ASN) { ip = inProcessLocationMgr.LoadInProcessLocation(resolver.Code); } Receipt receipt = orderMgr.ReceiveOrder(receiptDetailList, resolver.UserCode, ip, resolver.ExternalOrderNo); resolver.Transformers = TransformerHelper.ConvertReceiptToTransformer(receipt.ReceiptDetails); resolver.Code = receipt.ReceiptNo; resolver.BinCode = string.Empty; resolver.Result = languageMgr.TranslateMessage("Common.Business.RecNoIs", resolver.UserCode, receipt.ReceiptNo); resolver.Command = BusinessConstants.CS_BIND_VALUE_TRANSFORMER; return resolver; }
public HuOdd CreateHuOdd(ReceiptDetail receiptDetail, LocationLotDetail locationLotDetail, User user) { OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; DateTime dateTimeNow = DateTime.Now; HuOdd huOdd = new HuOdd(); huOdd.OrderDetail = orderDetail; huOdd.LocationLotDetail = locationLotDetail; huOdd.OddQty = receiptDetail.ReceivedQty.Value; huOdd.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; huOdd.CreatedQty = 0; huOdd.CreateUser = user; huOdd.CreateDate = dateTimeNow; huOdd.LastModifyUser = user; huOdd.LastModifyDate = dateTimeNow; this.CreateHuOdd(huOdd); return huOdd; }
public static IList<InProcessLocationDetail> FindMatchInProcessLocationDetail(ReceiptDetail receiptDetail, IList<InProcessLocationDetail> inProcessLocationDetailList) { if (inProcessLocationDetailList != null && inProcessLocationDetailList.Count > 0) { IList<InProcessLocationDetail> matchInProcessLocationDetailList = new List<InProcessLocationDetail>(); foreach (InProcessLocationDetail inProcessLocationDetail in inProcessLocationDetailList) { if (IsInProcessLocationDetailMatchReceiptDetail(inProcessLocationDetail, receiptDetail)) { matchInProcessLocationDetailList.Add(inProcessLocationDetail); } } return matchInProcessLocationDetailList; } return null; }
public virtual void CreateReceiptDetail(ReceiptDetail entity) { Create(entity); }
public IList<InventoryTransaction> InventoryIn(ReceiptDetail receiptDetail, User user) { Receipt receipt = receiptDetail.Receipt; OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; PlannedBill plannedBill = null; bool isCS = (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING); bool isReceiveSettle = (orderDetail.DefaultBillSettleTerm == BusinessConstants.CODE_MASTER_BILL_SETTLE_TERM_VALUE_RECEIVING_SETTLEMENT); #region 寄售库存入库,记录Planned Bill if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING) { #region 记录待结算 plannedBill = this.plannedBillMgrE.CreatePlannedBill(receiptDetail, user); #endregion #region 委外加工立即结算 if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING) { plannedBill.CurrentActingQty = plannedBill.PlannedQty; this.billMgrE.CreateActingBill(plannedBill, user); return null; //委外加工不增加库存,不产生库存事务 } #endregion #region 判断寄售负库存是否立即结算 bool autoSettleMinusCSInventory = true; if (autoSettleMinusCSInventory && isCS && (receiptDetail.ReceivedQty.HasValue ? receiptDetail.ReceivedQty.Value : 0) < 0) { plannedBill.CurrentActingQty = plannedBill.PlannedQty; this.billMgrE.CreateActingBill(plannedBill, user); isCS = false; } #endregion #region 判断目的库位为空的立即结算 if (isCS && orderLocationTransaction.Location == null && isReceiveSettle) { plannedBill.CurrentActingQty = plannedBill.PlannedQty; this.billMgrE.CreateActingBill(plannedBill, user); isCS = false; } #endregion } #endregion #region 库存操作 if (orderLocationTransaction.Location != null) { #region 收货LotNo不能小于现有库存的LotNo校验 if (orderHead.IsGoodsReceiveFIFO && receiptDetail.HuId != null && receiptDetail.ReceivedQty.Value > 0) //退货不检验 { Hu hu = this.huMgrE.CheckAndLoadHu(receiptDetail.HuId); #region 如果收货单有小于本次收货明细的生产日期,取最小日期作为先进先出的基准日期 DateTime? minManufactureDate = null; if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0) { foreach (ReceiptDetail rd in receipt.ReceiptDetails) { if (rd.HuId != null && rd.HuId != string.Empty) { Hu rdHu = this.huMgrE.CheckAndLoadHu(rd.HuId); if ((!minManufactureDate.HasValue || rdHu.ManufactureDate.CompareTo(minManufactureDate) < 0) && rdHu.ManufactureParty.Code == hu.ManufactureParty.Code && rdHu.Item.Code == hu.Item.Code) { minManufactureDate = rdHu.ManufactureDate; } } } } #endregion if (!minManufactureDate.HasValue //本次收货为第一次收货需要检验 || minManufactureDate.Value.CompareTo(hu.ManufactureDate) > 0) //收货的最小生产日期大于等于本次收货明细的生产日期才需要校验,也就是本次收货的生产日期为当前最小值 { if (!this.locationLotDetailMgrE.CheckGoodsReceiveFIFO(orderLocationTransaction.Location.Code, orderLocationTransaction.Item.Code, hu.ManufactureDate, hu.ManufactureParty.Code, minManufactureDate)) { throw new BusinessErrorException("MasterData.InventoryIn.LotNoIsOld", orderLocationTransaction.Item.Code, hu.HuId, hu.LotNo, orderLocationTransaction.Location.Code); } } } #endregion if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) { #region 物流 IList<InventoryTransaction> resultInventoryTransactionList = new List<InventoryTransaction>(); #region 正品库存操作 if (receiptDetail.ReceivedQty.HasValue && receiptDetail.ReceivedQty.Value != 0) { Location locIn = orderLocationTransaction.Location; //默认入库位 #region 处理按Hu退货,如果Hu在次品库位,出库库位更新为次品库位 if (receiptDetail.HuId != null && receiptDetail.HuId.Trim() != string.Empty && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RTN) { IList<LocationLotDetail> locationLotDetailList = this.locationLotDetailMgrE.GetHuLocationLotDetail(BusinessConstants.SYSTEM_LOCATION_REJECT, receiptDetail.HuId); if (locationLotDetailList != null && locationLotDetailList.Count > 0) { locIn = this.GetRejectLocation(); } } #endregion #region 更新库存 IList<InventoryTransaction> inventoryTransactionList = RecordInventory( orderLocationTransaction.Item, locIn, receiptDetail.HuId, receiptDetail.LotNo, receiptDetail.ReceivedQty.Value * orderLocationTransaction.UnitQty, isCS ? true : receiptDetail.IsConsignment, //可能是寄售移库 plannedBill != null ? plannedBill : (receiptDetail.PlannedBill.HasValue ? this.plannedBillMgrE.LoadPlannedBill(receiptDetail.PlannedBill.Value) : null), //需要从ASNDetail上找到寄售信息 orderLocationTransaction.TransactionType, orderHead.ReferenceOrderNo, //isReceiveSettle, user, orderDetail.NeedInspection && orderHead.NeedInspection, false ); #endregion IListHelper.AddRange<InventoryTransaction>(resultInventoryTransactionList, inventoryTransactionList); #region 记录库存事务 foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { #region 采购发生退货,立即结算 if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT && inventoryTransaction.Qty < 0 && inventoryTransaction.IsConsignment && inventoryTransaction.PlannedBill.HasValue) { PlannedBill pb = this.plannedBillMgrE.LoadPlannedBill(inventoryTransaction.PlannedBill.Value); pb.CurrentActingQty = 0 - inventoryTransaction.Qty; this.billMgrE.CreateActingBill(pb, user); } #endregion this.locationTransactionMgrE.RecordLocationTransaction(orderLocationTransaction, inventoryTransaction, receipt, user); } #endregion } #endregion #region 次品库存操作 if (receiptDetail.RejectedQty.HasValue && receiptDetail.RejectedQty.Value > 0) { #region 更新库存 IList<InventoryTransaction> inventoryTransactionList = RecordInventory( orderLocationTransaction.Item, (orderLocationTransaction.RejectLocation != null ? orderLocationTransaction.RejectLocation : orderLocationTransaction.Location), receiptDetail.HuId, receiptDetail.LotNo, receiptDetail.RejectedQty.Value * orderLocationTransaction.UnitQty, isCS, plannedBill, orderLocationTransaction.TransactionType, orderHead.ReferenceOrderNo, //isReceiveSettle, user, false, false ); #endregion IListHelper.AddRange<InventoryTransaction>(resultInventoryTransactionList, inventoryTransactionList); #region 记录库存事务 foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { this.locationTransactionMgrE.RecordLocationTransaction(orderLocationTransaction, inventoryTransaction, receipt, user); } #endregion } #endregion return resultInventoryTransactionList; #endregion } else { #region 生产 IList<InventoryTransaction> resultInventoryTransactionList = new List<InventoryTransaction>(); #region 正品库存操作 if (receiptDetail.ReceivedQty.HasValue && receiptDetail.ReceivedQty.Value != 0) { #region 更新库存 IList<InventoryTransaction> inventoryTransactionList = RecordInventory( orderLocationTransaction.Item, orderLocationTransaction.Location, receiptDetail.HuId, receiptDetail.LotNo, receiptDetail.ReceivedQty.Value * orderLocationTransaction.UnitQty, false, null, orderLocationTransaction.TransactionType, orderHead.ReferenceOrderNo, //isReceiveSettle, user, orderDetail.NeedInspection && orderHead.NeedInspection, true ); #endregion IListHelper.AddRange<InventoryTransaction>(resultInventoryTransactionList, inventoryTransactionList); #region 记录库存事务 foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { this.locationTransactionMgrE.RecordLocationTransaction(orderLocationTransaction, inventoryTransaction, receipt, user); } #endregion } #endregion #region 次品库存操作 if (receiptDetail.RejectedQty.HasValue && receiptDetail.RejectedQty.Value > 0) { #region 更新库存 IList<InventoryTransaction> inventoryTransactionList = RecordInventory( orderLocationTransaction.Item, (orderLocationTransaction.RejectLocation != null ? orderLocationTransaction.RejectLocation : orderLocationTransaction.Location), receiptDetail.HuId, receiptDetail.LotNo, receiptDetail.RejectedQty.Value * orderLocationTransaction.UnitQty, false, null, orderLocationTransaction.TransactionType, orderHead.ReferenceOrderNo, //isReceiveSettle, user, false, true ); #endregion IListHelper.AddRange<InventoryTransaction>(resultInventoryTransactionList, inventoryTransactionList); #region 记录库存事务 foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { this.locationTransactionMgrE.RecordLocationTransaction(orderLocationTransaction, inventoryTransaction, receipt, user); } #endregion } #endregion return resultInventoryTransactionList; #endregion } } else { #region 入库没有库位关闭Hu if (receiptDetail.HuId != null && receiptDetail.HuId.Trim() != string.Empty) { Hu hu = this.huMgrE.CheckAndLoadHu(receiptDetail.HuId); hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CLOSE; this.huMgrE.UpdateHu(hu); } #endregion } return null; #endregion }
public string GenerateRMHuId(ReceiptDetail receiptDetail, string lotNo, decimal qty) { return GenerateRMHuId(receiptDetail.OrderLocationTransaction.OrderDetail, lotNo, qty); }
public IList<Hu> CreateHu(ReceiptDetail receiptDetail, User user) { if (receiptDetail.HuId != null) { throw new TechnicalException("HuId already exist."); } OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; IList<Hu> huList = new List<Hu>(); string lotNo = null; if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) { lotNo = receiptDetail.LotNo; } #region 为正品创建Hu if (receiptDetail.ReceivedQty.HasValue && receiptDetail.ReceivedQty != 0) { huList = CreateHu(orderLocationTransaction.Item, receiptDetail.ReceivedQty.Value, lotNo, orderDetail.Uom, orderDetail.UnitCount, orderDetail.HuLotSize, orderHead.OrderNo, receiptDetail.Receipt.ReceiptNo, null, orderHead.PartyFrom, BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_1, user, receiptDetail, null, orderLocationTransaction.ItemVersion, null,orderDetail.CustomerItemCode); } #endregion #region 为次品创建Hu //if (receiptDetail.RejectedQty.HasValue && receiptDetail.RejectedQty != 0) //{ // IList<Hu> rejHuList = CreateHu(orderLocationTransaction.Item, receiptDetail.RejectedQty.Value, lotNo, orderDetail.Uom, orderDetail.UnitCount, orderDetail.HuLotSize, // orderHead.OrderNo, receiptDetail.Receipt.ReceiptNo, null, orderHead.PartyFrom, BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_2, user, receiptDetail, null); // IListHelper.AddRange<Hu>(huList, rejHuList); //} #endregion return huList; }
public IList<InventoryTransaction> InventoryIn(ReceiptDetail receiptDetail, User user) { Receipt receipt = receiptDetail.Receipt; OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; PlannedBill plannedBill = null; bool isCS = (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING); bool isReceiveSettle = (orderDetail.DefaultBillSettleTerm == BusinessConstants.CODE_MASTER_BILL_SETTLE_TERM_VALUE_RECEIVING_SETTLEMENT); #region ���ۿ����⣬��¼Planned Bill if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING) { #region ��¼������ plannedBill = this.plannedBillMgr.CreatePlannedBill(receiptDetail, user); #endregion #region ί��ӹ��������� if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING) { plannedBill.CurrentActingQty = plannedBill.PlannedQty; this.billMgr.CreateActingBill(plannedBill, user); return null; //ί��ӹ������ӿ�棬������������� } #endregion #region �жϼ��۸�����Ƿ��������� bool autoSettleMinusCSInventory = true; if (autoSettleMinusCSInventory && isCS && (receiptDetail.ReceivedQty.HasValue ? receiptDetail.ReceivedQty.Value : 0) < 0) { plannedBill.CurrentActingQty = plannedBill.PlannedQty; this.billMgr.CreateActingBill(plannedBill, user); isCS = false; } #endregion #region �ж�Ŀ�Ŀ�λΪ�յ��������� if (isCS && orderLocationTransaction.Location == null && isReceiveSettle) { plannedBill.CurrentActingQty = plannedBill.PlannedQty; this.billMgr.CreateActingBill(plannedBill, user); isCS = false; } #endregion } #endregion #region ������ if (orderLocationTransaction.Location != null) { #region �ջ�LotNo����С�����п���LotNoУ�� if (orderHead.IsGoodsReceiveFIFO && receiptDetail.HuId != null && receiptDetail.ReceivedQty.Value > 0) //�˻������� { Hu hu = this.huMgr.CheckAndLoadHu(receiptDetail.HuId); #region ����ջ�����С�ڱ����ջ���ϸ���������ڣ�ȡ��С������Ϊ�Ƚ��ȳ��Ļ����� DateTime? minManufactureDate = null; if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0) { foreach (ReceiptDetail rd in receipt.ReceiptDetails) { if (rd.HuId != null && rd.HuId != string.Empty) { Hu rdHu = this.huMgr.CheckAndLoadHu(rd.HuId); if ((!minManufactureDate.HasValue || rdHu.ManufactureDate.CompareTo(minManufactureDate) < 0) && rdHu.ManufactureParty.Code == hu.ManufactureParty.Code && rdHu.Item.Code == hu.Item.Code) { minManufactureDate = rdHu.ManufactureDate; } } } } #endregion if (!minManufactureDate.HasValue //�����ջ�Ϊ��һ���ջ���Ҫ���� || minManufactureDate.Value.CompareTo(hu.ManufactureDate) > 0) //�ջ�����С�������ڴ��ڵ��ڱ����ջ���ϸ���������ڲ���ҪУ�飬Ҳ���DZ����ջ�����������Ϊ��ǰ��Сֵ { if (!this.locationLotDetailMgr.CheckGoodsReceiveFIFO(orderLocationTransaction.Location.Code, orderLocationTransaction.Item.Code, hu.ManufactureDate, hu.ManufactureParty.Code, minManufactureDate)) { throw new BusinessErrorException("MasterData.InventoryIn.LotNoIsOld", orderLocationTransaction.Item.Code, hu.HuId, hu.LotNo, orderLocationTransaction.Location.Code); } } } #endregion if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) { #region ���� IList<InventoryTransaction> resultInventoryTransactionList = new List<InventoryTransaction>(); #region ��Ʒ������ if (receiptDetail.ReceivedQty.HasValue && receiptDetail.ReceivedQty.Value != 0) { Location locIn = orderLocationTransaction.Location; //Ĭ�����λ #region �����Hu�˻������Hu�ڴ�Ʒ��λ�������λ����Ϊ��Ʒ��λ if (receiptDetail.HuId != null && receiptDetail.HuId.Trim() != string.Empty && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_RTN) { IList<LocationLotDetail> locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(BusinessConstants.SYSTEM_LOCATION_REJECT, receiptDetail.HuId); if (locationLotDetailList != null && locationLotDetailList.Count > 0) { locIn = this.GetRejectLocation(); } } #endregion #region ���¿�� IList<InventoryTransaction> inventoryTransactionList = RecordInventory( orderLocationTransaction.Item, locIn, receiptDetail.HuId, receiptDetail.LotNo, receiptDetail.ReceivedQty.Value * orderLocationTransaction.UnitQty, isCS ? true : receiptDetail.IsConsignment, //�����Ǽ����ƿ� plannedBill != null ? plannedBill : (receiptDetail.PlannedBill.HasValue ? this.plannedBillMgr.LoadPlannedBill(receiptDetail.PlannedBill.Value) : null), //��Ҫ��ASNDetail���ҵ�������Ϣ orderLocationTransaction.TransactionType, orderHead.ReferenceOrderNo, //isReceiveSettle, user, orderDetail.NeedInspection && orderHead.NeedInspection, false, locIn.Code == BusinessConstants.SYSTEM_LOCATION_REJECT ? orderLocationTransaction.Location.Code : null ); #endregion IListHelper.AddRange<InventoryTransaction>(resultInventoryTransactionList, inventoryTransactionList); #region ��¼������� foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { #region �ɹ������˻����������� if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT && inventoryTransaction.Qty < 0 && inventoryTransaction.IsConsignment && inventoryTransaction.PlannedBill.HasValue) { PlannedBill pb = this.plannedBillMgr.LoadPlannedBill(inventoryTransaction.PlannedBill.Value); pb.CurrentActingQty = 0 - inventoryTransaction.Qty; this.billMgr.CreateActingBill(pb, user); } #endregion this.locationTransactionMgr.RecordLocationTransaction(orderLocationTransaction, inventoryTransaction, receipt, user); } #endregion } #endregion #region ��Ʒ������ if (receiptDetail.RejectedQty.HasValue && receiptDetail.RejectedQty.Value > 0) { #region ���¿�� IList<InventoryTransaction> inventoryTransactionList = RecordInventory( orderLocationTransaction.Item, (orderLocationTransaction.RejectLocation != null ? orderLocationTransaction.RejectLocation : orderLocationTransaction.Location), receiptDetail.HuId, receiptDetail.LotNo, receiptDetail.RejectedQty.Value * orderLocationTransaction.UnitQty, isCS, plannedBill, orderLocationTransaction.TransactionType, orderHead.ReferenceOrderNo, //isReceiveSettle, user, false, false, orderLocationTransaction.Location.Code ); #endregion IListHelper.AddRange<InventoryTransaction>(resultInventoryTransactionList, inventoryTransactionList); #region ��¼������� foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { this.locationTransactionMgr.RecordLocationTransaction(orderLocationTransaction, inventoryTransaction, receipt, user); } #endregion } #endregion return resultInventoryTransactionList; #endregion } else { #region ���� IList<InventoryTransaction> resultInventoryTransactionList = new List<InventoryTransaction>(); #region ��Ʒ������ if (receiptDetail.ReceivedQty.HasValue && receiptDetail.ReceivedQty.Value != 0) { #region ���¿�� IList<InventoryTransaction> inventoryTransactionList = RecordInventory( orderLocationTransaction.Item, orderLocationTransaction.Location, receiptDetail.HuId, receiptDetail.LotNo, receiptDetail.ReceivedQty.Value * orderLocationTransaction.UnitQty, false, null, orderLocationTransaction.TransactionType, orderHead.ReferenceOrderNo, //isReceiveSettle, user, orderDetail.NeedInspection && orderHead.NeedInspection, false, null ); #endregion IListHelper.AddRange<InventoryTransaction>(resultInventoryTransactionList, inventoryTransactionList); #region ��¼������� foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { this.locationTransactionMgr.RecordLocationTransaction(orderLocationTransaction, inventoryTransaction, receipt, user); } #endregion } #endregion #region ��Ʒ������ if (receiptDetail.RejectedQty.HasValue && receiptDetail.RejectedQty.Value > 0) { #region ���¿�� IList<InventoryTransaction> inventoryTransactionList = RecordInventory( orderLocationTransaction.Item, (orderLocationTransaction.RejectLocation != null ? orderLocationTransaction.RejectLocation : orderLocationTransaction.Location), receiptDetail.HuId, receiptDetail.LotNo, receiptDetail.RejectedQty.Value * orderLocationTransaction.UnitQty, false, null, orderLocationTransaction.TransactionType, orderHead.ReferenceOrderNo, //isReceiveSettle, user, false, false, null ); #endregion IListHelper.AddRange<InventoryTransaction>(resultInventoryTransactionList, inventoryTransactionList); #region ��¼������� foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { this.locationTransactionMgr.RecordLocationTransaction(orderLocationTransaction, inventoryTransaction, receipt, user); } #endregion } #endregion return resultInventoryTransactionList; #endregion } } else { #region ���û�п�λ�ر�Hu if (receiptDetail.HuId != null && receiptDetail.HuId.Trim() != string.Empty) { Hu hu = this.huMgr.CheckAndLoadHu(receiptDetail.HuId); hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CLOSE; this.huMgr.UpdateHu(hu); } #endregion } return null; #endregion }
public virtual void ProcessSingleFile(string inboundDirectoryName, string inboundFileName) { log.Info("Start inbound file " + inboundFileName); FlatFileReader reader = new FlatFileReader(inboundFileName, Encoding.ASCII, "\t"); try { OrderHead orderHead = null; OrderDetail orderDetail = null; string shiftCode = string.Empty; Hu hu = null; string[] fields = reader.ReadLine(); while (fields != null) { string prodLine = fields[0]; string itemCode = fields[1]; string huId = fields[2]; decimal qty = decimal.Parse(fields[3]); string itemHuId = fields[4]; string onlineDate = fields[5]; string onlineTime = fields[6]; string offlineDate = fields[7]; string offlineTime = fields[8]; string customerCode = fields[9]; string customerLoc = fields[10]; if (orderHead == null) { #region 查找工单 shiftCode = BarcodeHelper.GetShiftCode(huId); DetachedCriteria criteria = DetachedCriteria.For<OrderHead>(); criteria.CreateAlias("Flow", "f"); //criteria.CreateAlias("Shift", "s"); criteria.Add(Expression.Like("f.Code", prodLine, MatchMode.End)); criteria.Add(Expression.Eq("s.Code", shiftCode)); criteria.Add(Expression.Eq("Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS)); criteria.AddOrder(Order.Asc("StartTime")); IList<OrderHead> orderHeadList = this.criteriaMgrE.FindAll<OrderHead>(criteria); #endregion if (orderHeadList != null && orderHeadList.Count > 0) { foreach(OrderHead targetOrderHead in orderHeadList) { orderHead = targetOrderHead; #region 查找工单明细 IList<OrderDetail> orderDetailList = orderHead.OrderDetails; foreach (OrderDetail targetOrderDetail in orderDetailList) { if (targetOrderDetail.Item.Code == itemCode) { log.Info("Find match wo " + orderHead.OrderNo); orderDetail = targetOrderDetail; orderDetail.CurrentReceiveQty = qty; break; } } #endregion if (orderDetail != null) { break; } } } else { throw new BusinessErrorException("No active wo find for prodline + " + prodLine + ", shift " + shiftCode); } if (orderDetail != null) { #region 创建外包装条码 if (this.huMgrE.LoadHu(huId) == null) { log.Info("Insert hu " + huId + " into database."); hu = ResolveAndCreateHu(huId, orderDetail, qty); orderDetail.HuId = hu.HuId; Receipt receipt = new Receipt(); ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0]; receiptDetail.HuId = hu.HuId; receiptDetail.ReceivedQty = qty; receiptDetail.Receipt = receipt; #region 找Out的OrderLocTrans,填充MaterialFulshBack IList<OrderLocationTransaction> orderLocTransList = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_OUT); foreach (OrderLocationTransaction orderLocTrans in orderLocTransList) { MaterialFlushBack material = new MaterialFlushBack(); material.OrderLocationTransaction = orderLocTrans; if (orderLocTrans.UnitQty != 0) { material.Qty = qty; } receiptDetail.AddMaterialFlushBack(material); } #endregion receipt.AddReceiptDetail(receiptDetail); this.orderManager.ReceiveOrder(receipt, this.userMgrE.GetMonitorUser()); } else { throw new BusinessErrorException("Hu " + huId + " already exist in database."); } #endregion } else { throw new BusinessErrorException("No item found for item code " + itemCode + " for prodline + " + prodLine + ", shift " + shiftCode); } } #region 创建内包装条码 if (this.huMgrE.LoadHu(itemHuId) == null) { log.Info("Insert hu " + itemHuId + " into database."); CreateItemHu(itemHuId, orderDetail, hu.LotNo, hu.ManufactureDate); } else { throw new BusinessErrorException("Hu " + itemHuId + " already exist in database."); } #endregion fields = reader.ReadLine(); } } finally { reader.Dispose(); } }
public Receipt ConvertInProcessLocationToReceipt(InProcessLocation inProcessLocation, IDictionary<string, string> huIdStorageBinDic, string externalOrderNo) { Receipt receipt = new Receipt(); receipt.ExternalReceiptNo = externalOrderNo; receipt.AddInProcessLocation(inProcessLocation); if (inProcessLocation.InProcessLocationDetails != null && inProcessLocation.InProcessLocationDetails.Count > 0) { foreach (InProcessLocationDetail inProcessLocationDetail in inProcessLocation.InProcessLocationDetails) { OrderLocationTransaction orderLocationTransaction = inProcessLocationDetail.OrderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; OrderLocationTransaction inOrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0]; bool isMerge = false; if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0 && !inProcessLocation.IsReceiptScanHu) { //如果收货不扫描条码,收货项需要根据发货项进行合并 foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) { if (inOrderLocationTransaction.Id == receiptDetail.OrderLocationTransaction.Id) { //if (inProcessLocationDetail.IsConsignment == receiptDetail.IsConsignment // && inProcessLocationDetail.PlannedBill == receiptDetail.PlannedBill) { // throw new BusinessErrorException("寄售库存,不能按按数量进行收货。"); //} isMerge = true; receiptDetail.ShippedQty += inProcessLocationDetail.Qty; receiptDetail.ReceivedQty += inProcessLocationDetail.Qty; break; } } } if (!isMerge) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = inOrderLocationTransaction; receiptDetail.Id = inProcessLocationDetail.Id; receiptDetail.ShippedQty = inProcessLocationDetail.Qty; receiptDetail.ReceivedQty = inProcessLocationDetail.Qty; if (inProcessLocation.IsReceiptScanHu) //只有按条码收货才Copy条码信息 { receiptDetail.HuId = inProcessLocationDetail.HuId; receiptDetail.LotNo = inProcessLocationDetail.LotNo; //上架库位赋值 if (inOrderLocationTransaction.OrderDetail.OrderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML && huIdStorageBinDic != null && receiptDetail.HuId != null && receiptDetail.HuId.Trim() != string.Empty && huIdStorageBinDic.ContainsKey(receiptDetail.HuId.Trim())) { receiptDetail.PutAwayBinCode = huIdStorageBinDic[receiptDetail.HuId.Trim()]; } } receiptDetail.IsConsignment = inProcessLocationDetail.IsConsignment; receiptDetail.PlannedBill = inProcessLocationDetail.PlannedBill; receiptDetail.Receipt = receipt; if (receiptDetail.ShippedQty != 0)//过滤已收满数量 { receipt.AddReceiptDetail(receiptDetail); } } } } return receipt; }
public Receipt ConvertOrderDetailToReceipt(IList<OrderDetail> orderDetailList) { Receipt receipt = new Receipt(); if (orderDetailList != null && orderDetailList.Count > 0) { foreach (OrderDetail orderDetail in orderDetailList) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0]; if (orderDetail.OrderHead.IsReceiptScanHu) //只有收货扫描条码赋值 { receiptDetail.HuId = orderDetail.HuId; } //receiptDetail.ShippedQty = orderDetail.RemainShippedQty; ShippedQty都是后台赋值的,从InProcessLocationDetail中取值 //receiptDetail.ReceivedQty = receiptDetail.ShippedQty; receiptDetail.ReceivedQty = orderDetail.RemainShippedQty; receiptDetail.Receipt = receipt; //if (receiptDetail.ShippedQty != 0)//过滤已收满数量 if (receiptDetail.ReceivedQty != 0)//过滤已收满数量 receipt.AddReceiptDetail(receiptDetail); } } return receipt; }
public Receipt ReceiveOrder(IList<OrderDetail> orderDetailList, User user, bool isOddCreateHu) { if (orderDetailList != null && orderDetailList.Count > 0) { Receipt receipt = new Receipt(); foreach (OrderDetail orderDetail in orderDetailList) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0]; receiptDetail.HuId = orderDetail.HuId; receiptDetail.ReceivedQty = orderDetail.CurrentReceiveQty; receiptDetail.RejectedQty = orderDetail.CurrentRejectQty; receiptDetail.ScrapQty = orderDetail.CurrentScrapQty; receiptDetail.PutAwayBinCode = orderDetail.PutAwayBinCode; receiptDetail.Receipt = receipt; receipt.AddReceiptDetail(receiptDetail); } return ReceiveOrder(receipt, user, null, true, isOddCreateHu); } else { throw new BusinessErrorException("OrderDetail.Error.OrderDetailReceiveEmpty"); } }
public Receipt ReceiveReuseOrder(OrderHead orderHead, User user, IList<Hu> huList) { foreach (OrderDetail orderDetail in orderHead.OrderDetails) { decimal qty = orderDetail.OrderedQty; foreach (Hu hu in huList) { if (orderDetail.Item.Code == hu.Item.Code && orderDetail.Uom.Code == hu.Uom.Code) { qty = qty - hu.Qty; } } if (qty != 0) { throw new BusinessErrorException("OrderDetail.Item.Qty.NotMatch", orderDetail.Item.Code); } } IList<ReceiptDetail> receiptDetailList = new List<ReceiptDetail>(); foreach (OrderDetail orderDetail in orderHead.OrderDetails) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0]; receiptDetail.HuId = orderDetail.HuId; receiptDetail.ScrapQty = orderDetail.OrderedQty; if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) { IList<OrderLocationTransaction> orderLocTransList = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_OUT); foreach (OrderLocationTransaction orderLocTrans in orderLocTransList) { MaterialFlushBack material = new MaterialFlushBack(); material.OrderLocationTransaction = orderLocTrans; if (orderLocTrans.OrderDetail.Item.Code == orderLocTrans.Item.Code) { foreach (Hu hu in huList) { if (hu.Item.Code == orderLocTrans.Item.Code && hu.Uom.Code == orderLocTrans.OrderDetail.Uom.Code) { material = new MaterialFlushBack(); material.OrderLocationTransaction = orderLocTrans; material.HuId = hu.HuId; if (orderLocTrans.UnitQty != 0) { material.Qty = hu.Qty; } receiptDetail.AddMaterialFlushBack(material); } } } else { if (orderLocTrans.UnitQty != 0) { material.Qty = orderLocTrans.OrderedQty / orderLocTrans.UnitQty; } receiptDetail.AddMaterialFlushBack(material); } } } receiptDetailList.Add(receiptDetail); } return ReceiveOrder(receiptDetailList, user, null, null, null, true, false); }
public Receipt ReceiveScrapOrder(OrderHead orderHead, User user) { IList<ReceiptDetail> receiptDetailList = new List<ReceiptDetail>(); foreach (OrderDetail orderDetail in orderHead.OrderDetails) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0]; receiptDetail.HuId = orderDetail.HuId; receiptDetail.ScrapQty = orderDetail.OrderedQty; if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) { IList<OrderLocationTransaction> orderLocTransList = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_OUT); foreach (OrderLocationTransaction orderLocTrans in orderLocTransList) { MaterialFlushBack material = new MaterialFlushBack(); material.OrderLocationTransaction = orderLocTrans; if (orderLocTrans.UnitQty != 0) { material.Qty = orderLocTrans.OrderedQty / orderLocTrans.UnitQty; } receiptDetail.AddMaterialFlushBack(material); } } receiptDetailList.Add(receiptDetail); } return ReceiveOrder(receiptDetailList, user, null, null, null, true, false); }
public void StartOrder(string orderNo, User user) { OrderHead orderHead = this.orderHeadMgrE.CheckAndLoadOrderHead(orderNo); Flow flow = this.flowMgrE.LoadFlow(orderHead.Flow); //权限校验 //if (!OrderHelper.CheckOrderOperationAuthrize(orderHead, user, BusinessConstants.ORDER_OPERATION_START_ORDER)) //{ // throw new BusinessErrorException("Order.Error.NoStartPermission", orderHead.OrderNo); //} if (orderHead.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT) { #region 检查生产单最大上线数量 if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION && orderHead.Flow != null && flow.MaxOnlineQty > 0 && this.GetInPorcessWOCount(orderHead.Flow, user) >= flow.MaxOnlineQty) { throw new BusinessErrorException("Order.Error.ExcceedMaxOnlineQty"); } #endregion DateTime nowDate = DateTime.Now; orderHead.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS; orderHead.StartDate = nowDate; orderHead.StartUser = user; orderHead.LastModifyDate = nowDate; orderHead.LastModifyUser = user; this.orderHeadMgrE.UpdateOrderHead(orderHead); #region 判断自动PickList、Ship if (orderHead.IsAutoShip && orderHead.IsAutoReceive && orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) { if (orderHead.CompleteLatency.HasValue && orderHead.CompleteLatency.Value > 0) { //todo 收货延迟,记录到Quratz表中 throw new NotImplementedException("Complete Latency Not Implemented"); } else { //立即收货 Receipt receipt = new Receipt(); foreach (OrderDetail orderDetail in orderHead.OrderDetails) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0]; receiptDetail.HuId = orderDetail.HuId; receiptDetail.ReceivedQty = orderDetail.OrderedQty; receiptDetail.Receipt = receipt; #region 生产自动收货,找Out的OrderLocTrans,填充MaterialFulshBack if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) { IList<OrderLocationTransaction> orderLocTransList = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_OUT); foreach (OrderLocationTransaction orderLocTrans in orderLocTransList) { MaterialFlushBack material = new MaterialFlushBack(); material.OrderLocationTransaction = orderLocTrans; if (orderLocTrans.UnitQty != 0) { material.Qty = orderLocTrans.OrderedQty / orderLocTrans.UnitQty; } receiptDetail.AddMaterialFlushBack(material); } } #endregion receipt.AddReceiptDetail(receiptDetail); } ReceiveOrder(receipt, user); } } else if (orderHead.IsAutoShip) { if (orderHead.StartLatency.HasValue && orderHead.StartLatency.Value > 0) { //todo 上线延迟,记录到Quratz表中 throw new NotImplementedException("Start Latency Not Implemented"); } else { //立即上线 IList<InProcessLocationDetail> inProcessLocationDetailList = new List<InProcessLocationDetail>(); foreach (OrderDetail orderDetail in orderHead.OrderDetails) { InProcessLocationDetail inProcessLocationDetail = new InProcessLocationDetail(); inProcessLocationDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_OUT)[0]; inProcessLocationDetail.Qty = orderDetail.OrderedQty; inProcessLocationDetailList.Add(inProcessLocationDetail); } ShipOrder(inProcessLocationDetailList, user); } } else if (orderHead.IsAutoCreatePickList && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML) //过滤掉退货和调整 { IList<OrderLocationTransaction> orderLocationTransactionList = new List<OrderLocationTransaction>(); foreach (OrderDetail orderDetail in orderHead.OrderDetails) { IList<OrderLocationTransaction> outOrderLocationTransactionList = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_OUT); foreach (OrderLocationTransaction orderLocationTransaction in outOrderLocationTransactionList) { orderLocationTransaction.CurrentShipQty = orderLocationTransaction.OrderedQty; } IListHelper.AddRange<OrderLocationTransaction>(orderLocationTransactionList, outOrderLocationTransactionList); } this.pickListMgrE.CreatePickList(orderLocationTransactionList, user); } #endregion } else { throw new BusinessErrorException("Order.Error.StatusErrorWhenStart", orderHead.Status, orderNo); } }
public static bool IsInProcessLocationDetailMatchReceiptDetail( InProcessLocationDetail inProcessLocationDetail, ReceiptDetail receiptDetail) { if (receiptDetail.OrderLocationTransaction.OrderDetail.Id == inProcessLocationDetail.OrderLocationTransaction.OrderDetail.Id) { if (inProcessLocationDetail.HuId != null && receiptDetail.HuId != null) { if (receiptDetail.HuId == inProcessLocationDetail.HuId) { return true; } else { return false; } } //if (inProcessLocationDetail.HuId != null) //{ // //支持Hu,一定要HuId匹配 // if (receiptDetail.HuId == inProcessLocationDetail.HuId) // { // return true; // } //} //else //{ // //不支持Hu,直接认为相同 // return true; //} return true; } return false; }
public string AdjustInProcessLocationTo() { try { InProcessLocation ip = TheInProcessLocationMgr.LoadInProcessLocation(this.IpNo, true); Receipt receipt = new Receipt(); InProcessLocation nmlIp = CloneHelper.DeepClone(ip); IList<InProcessLocationDetail> nmlReceiptDetailList = new List<InProcessLocationDetail>(); foreach (InProcessLocationDetail ipdet in ip.InProcessLocationDetails) { #region 对应的ipdet InProcessLocationDetail nmlInProcessLocationDetail = new InProcessLocationDetail(); nmlInProcessLocationDetail.Qty = 0 - ipdet.Qty; nmlInProcessLocationDetail.OrderLocationTransaction = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(ipdet.OrderLocationTransaction.OrderDetail, BusinessConstants.IO_TYPE_IN)[0]; nmlInProcessLocationDetail.IsConsignment = ipdet.IsConsignment; nmlInProcessLocationDetail.PlannedBill = ipdet.PlannedBill; nmlReceiptDetailList.Add(nmlInProcessLocationDetail); #endregion #region 收货单明细 ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.Receipt = receipt; receiptDetail.ReceivedQty = nmlInProcessLocationDetail.Qty; receiptDetail.ShippedQty = nmlInProcessLocationDetail.Qty; receiptDetail.OrderLocationTransaction = nmlInProcessLocationDetail.OrderLocationTransaction; receiptDetail.IsConsignment = ipdet.IsConsignment; nmlInProcessLocationDetail.PlannedBill = ipdet.PlannedBill; OrderDetail orderDetail = receiptDetail.OrderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT) { PriceListDetail priceListDetail = ThePriceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceList, orderDetail.Item, DateTime.Now, orderDetail.OrderHead.Currency); if (priceListDetail == null) { throw new BusinessErrorException("Order.Error.NoPriceListReceipt", new string[] { orderDetail.Item.Code }); } receiptDetail.PlannedAmount = priceListDetail.UnitPrice * (decimal)receiptDetail.ReceivedQty; } else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION) { PriceListDetail priceListDetail = ThePriceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceList, orderDetail.Item, DateTime.Now, orderDetail.OrderHead.Currency); if (priceListDetail == null) { throw new BusinessErrorException("Order.Error.NoPriceListReceipt", new string[] { orderDetail.Item.Code }); } receiptDetail.PlannedAmount = priceListDetail.UnitPrice * (decimal)receiptDetail.ReceivedQty; } receipt.AddReceiptDetail(receiptDetail); #endregion } nmlIp.InProcessLocationDetails = nmlReceiptDetailList; if (receipt.InProcessLocations == null) { receipt.InProcessLocations = new List<InProcessLocation>(); } receipt.InProcessLocations.Add(nmlIp); TheReceiptMgr.CreateReceipt(receipt, this.CurrentUser); return receipt.ReceiptNo; } catch (BusinessErrorException ex) { throw (ex); } }
public IList<ReceiptDetail> ConvertTransformerToReceiptDetail(List<Transformer> transformerList, bool includeZero) { IList<ReceiptDetail> recDetList = new List<ReceiptDetail>(); ReceiptDetail recDet = new ReceiptDetail(); if (transformerList != null && transformerList.Count > 0) { foreach (Transformer transformer in transformerList) { OrderLocationTransaction orderLocTrans = orderLocationTransactionMgrE.LoadOrderLocationTransaction(transformer.OrderLocTransId); if (transformer.TransformerDetails != null && transformer.TransformerDetails.Count > 0 && orderLocTrans.OrderDetail.OrderHead.IsReceiptScanHu) { foreach (TransformerDetail transformerDetail in transformer.TransformerDetails) { recDet = new ReceiptDetail(); recDet.OrderLocationTransaction = orderLocTrans; recDet.HuId = transformerDetail.HuId; recDet.LotNo = transformerDetail.LotNo; recDet.ShippedQty = transformerDetail.Qty; recDet.ReceivedQty = transformerDetail.CurrentQty; recDet.PutAwayBinCode = transformerDetail.StorageBinCode; if (recDet.ReceivedQty != 0 || includeZero) recDetList.Add(recDet); } } else { recDet = new ReceiptDetail(); recDet.OrderLocationTransaction = orderLocTrans; recDet.ShippedQty = transformer.Qty; recDet.ReceivedQty = transformer.CurrentQty; if (recDet.ReceivedQty != 0 || includeZero) recDetList.Add(recDet); } } } return recDetList; }
public InventoryTransaction InventoryOut(HuOdd huOdd, ReceiptDetail receiptDetail, User user) { #region ���¿�� LocationLotDetail locLotDet = this.locationLotDetailMgr.LoadLocationLotDetail(huOdd.LocationLotDetail.Id); locLotDet.Qty -= huOdd.CurrentCreateQty; this.locationLotDetailMgr.UpdateLocationLotDetail(locLotDet); #endregion #region ��¼������� InventoryTransaction inventoryTransaction = InventoryTransactionHelper.CreateInventoryTransaction(locLotDet, 0 - huOdd.CurrentCreateQty, false); this.locationTransactionMgr.RecordLocationTransaction(receiptDetail.OrderLocationTransaction, inventoryTransaction, receiptDetail.Receipt, user); #endregion return inventoryTransaction; }
private void CalculatePlannedAmount(OrderDetail orderDetail, ReceiptDetail receiptDetail, decimal? totalAmount) { if (totalAmount.HasValue && totalAmount.Value != 0) { EntityPreference decimalLengthEntityPreference = this.entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH); int decimalLength = int.Parse(decimalLengthEntityPreference.Value); decimal actualUnitPrice = Math.Round((totalAmount.Value / orderDetail.OrderedQty), decimalLength, MidpointRounding.AwayFromZero); if (orderDetail.ReceivedQty.Value + receiptDetail.ReceivedQty.Value > orderDetail.OrderedQty) { //已收数 + 本次收货数大于订单数量 if (orderDetail.ReceivedQty.Value >= orderDetail.OrderedQty) { //已收数大于订单数量,PlannedAmount = 剩余订单Amount + 实际单价 * 超出订单的数量 receiptDetail.PlannedAmount = totalAmount.Value - actualUnitPrice * orderDetail.ReceivedQty.Value; receiptDetail.PlannedAmount += actualUnitPrice * (orderDetail.ReceivedQty.Value + receiptDetail.ReceivedQty.Value - orderDetail.OrderedQty); } else { //已收数大于订单数量,PlannedAmount = 实际单价 * 本次收货数量 receiptDetail.PlannedAmount = actualUnitPrice * receiptDetail.ReceivedQty.Value; } } else if (orderDetail.ReceivedQty + receiptDetail.ReceivedQty.Value == orderDetail.OrderedQty) { //已收数 + 本次收货数正好等于订单数量 receiptDetail.PlannedAmount = totalAmount.Value - actualUnitPrice * orderDetail.ReceivedQty.Value; } else { //已收数 + 本次收货数小于订单数量 receiptDetail.PlannedAmount = actualUnitPrice * receiptDetail.ReceivedQty.Value; } } }
public IList<InventoryTransaction> InventoryIn(ReceiptDetail receiptDetail, User user, string binCode) { IList<InventoryTransaction> inventoryTransactionList = InventoryIn(receiptDetail, user); if (binCode != null && binCode != string.Empty && inventoryTransactionList != null && inventoryTransactionList.Count > 0) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId); locationLotDetail.NewStorageBin = this.storageBinMgr.LoadStorageBin(binCode); inventoryTransaction.StorageBin = locationLotDetail.NewStorageBin; InventoryPut(locationLotDetail, user); } } return inventoryTransactionList; }
private void BatchProcess(IList<DssImportHistory> dssImportHistoryList) { if (dssImportHistoryList == null || dssImportHistoryList.Count == 0) return; IList<string> itemList = dssImportHistoryList.Select(d => d.data1).Distinct().ToList<string>(); IList<string> shiftList = dssImportHistoryList.Select(d => d.ShiftCode).Distinct().ToList<string>(); var query = from d in dssImportHistoryList group d by new { d.ProdLine, d.ShiftCode, Item = d.ItemCode } into g select new { g.Key, list = g.ToList<DssImportHistory>(), Qty = g.Sum(d => d.Qty) }; foreach (var q in query) { string prodLine = q.Key.ProdLine; string shiftCode = q.Key.ShiftCode; string itemCode = q.Key.Item; decimal qty = q.Qty; List<DssImportHistory> list = q.list; if (list == null || list.Count == 0) continue; OrderDetail orderDetail = null; Receipt receipt = null; IList<OrderLocationTransaction> orderLocationTransactionList = this.GetOrderLocationTransaction(prodLine, shiftCode, itemCode); IList<ReceiptDetail> receiptDetailList = new List<ReceiptDetail>(); if (orderLocationTransactionList != null && orderLocationTransactionList.Count > 0) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = orderLocationTransactionList[0]; orderDetail = orderLocationTransactionList[0].OrderDetail; receipt = this.BuildReceipt(orderLocationTransactionList[0], list); //write db try { ReceiveWo(list, orderDetail, receipt); } catch (Exception ex) { continue; } } else { foreach (var dssImportHistory in q.list) { dssImportHistory.Memo = "No FG find for prodLine " + prodLine + ",shift " + shiftCode + ",item " + itemCode; dssImportHistory.ErrorCount++; } this.dssImportHistoryMgr.UpdateDssImportHistory(q.list); } } }
public virtual void UpdateReceiptDetail(ReceiptDetail entity) { Update(entity); }
private Hu CreateHuFromOdd(ReceiptDetail receiptDetail, User user) { OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; Receipt receipt = receiptDetail.Receipt; int huLotSize = orderDetail.HuLotSize.Value; decimal qty = 0; //�ۼƿ��Odd���� #region ѭ����ȡ���Odd���� IList<HuOdd> huOddList = this.huOddMgr.GetHuOdd( orderDetail.Item, orderDetail.UnitCount, orderDetail.Uom, orderDetail.DefaultLocationFrom, orderDetail.DefaultLocationTo, BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE); if (huOddList != null && huOddList.Count > 0) { foreach (HuOdd huOdd in huOddList) { qty += huOdd.OddQty - huOdd.CreatedQty; } if (qty + receiptDetail.ReceivedQty.Value >= huLotSize) { #region ��������������Hu DateTime dateTimeNow = DateTime.Now; #region ���¿��Odd������ foreach (HuOdd huOdd in huOddList) { //ȫ���ر� huOdd.CurrentCreateQty = huOdd.OddQty - huOdd.CreatedQty; huOdd.CreatedQty = huOdd.OddQty; huOdd.LastModifyDate = dateTimeNow; huOdd.LastModifyUser = user; huOdd.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE; this.huOddMgr.UpdateHuOdd(huOdd); //���� this.locationMgr.InventoryOut(huOdd, receiptDetail, user); } #endregion #region ���ܻ�����ͷ����Ҫ����receiptDetail�ջ������������ջ��� + ���Odd�� - Hu���� receiptDetail.ReceivedQty = qty + receiptDetail.ReceivedQty.Value - huLotSize; #endregion #region ����Hu ReceiptDetail clonedReceiptDetail = new ReceiptDetail(); CloneHelper.CopyProperty(receiptDetail, clonedReceiptDetail); clonedReceiptDetail.ReceivedQty = huLotSize; clonedReceiptDetail.RejectedQty = 0; IList<Hu> huList = this.huMgr.CreateHu(clonedReceiptDetail, user); return huList[0]; #endregion #endregion } } return null; #endregion }
public static TransformerDetail ConvertReceiptToTransformerDetail(ReceiptDetail receiptDetail) { TransformerDetail transformerDetail = ConvertOrderLocationTransactionToTransformerDetail(receiptDetail.OrderLocationTransaction); transformerDetail.HuId = receiptDetail.HuId; transformerDetail.LotNo = receiptDetail.LotNo; transformerDetail.Qty = receiptDetail.ShippedQty.HasValue ? receiptDetail.ShippedQty.Value : 0; transformerDetail.CurrentQty = receiptDetail.ReceivedQty.HasValue ? receiptDetail.ReceivedQty.Value : 0; transformerDetail.AdjustQty = receiptDetail.ReceivedQty.HasValue ? receiptDetail.ReceivedQty.Value : 0; return transformerDetail; }
public virtual void DeleteReceiptDetail(ReceiptDetail entity) { Delete(entity); }
private Receipt BuildReceipt(OrderLocationTransaction orderLocationTransaction, IList<DssImportHistory> dssImportHistoryList) { if (orderLocationTransaction == null || dssImportHistoryList == null || dssImportHistoryList.Count == 0) return null; Receipt receipt = new Receipt(); IList<OrderLocationTransaction> orderLocTransList = this.orderLocationTransactionMgr.GetOrderLocationTransaction(orderLocationTransaction.OrderDetail.Id, BusinessConstants.IO_TYPE_OUT); foreach (var dssImportHistory in dssImportHistoryList) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.Receipt = receipt; receiptDetail.OrderLocationTransaction = orderLocationTransaction; receiptDetail.HuId = dssImportHistory.HuId; receiptDetail.ReceivedQty = dssImportHistory.Qty; #region 找Out的OrderLocTrans,填充MaterialFlushBack foreach (OrderLocationTransaction orderLocTrans in orderLocTransList) { MaterialFlushBack material = new MaterialFlushBack(); material.OrderLocationTransaction = orderLocTrans; if (orderLocTrans.UnitQty != 0) { material.Qty = dssImportHistory.Qty; } receiptDetail.AddMaterialFlushBack(material); } #endregion receipt.AddReceiptDetail(receiptDetail); } return receipt; }
public void CreateReceipt(Receipt receipt, User user, bool isOddCreateHu) { log.Debug("Start create receipt"); #region �������еķ�����ջ�����ӡģ�壬�ջ����촦��ѡ�� string orderType = null; Party partyFrom = null; Party partyTo = null; ShipAddress shipFrom = null; ShipAddress shipTo = null; string dockDescription = null; string receiptTemplate = null; string huTemplate = null; string grGapTo = null; IList<InProcessLocationDetail> inProcessLocationDetailList = new List<InProcessLocationDetail>(); if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0) { foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations) { InProcessLocation currentIp = inProcessLocationMgr.LoadInProcessLocation(inProcessLocation.IpNo); if (currentIp.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE) { throw new BusinessErrorException("InProcessLocation.Error.StatusErrorWhenReceive", currentIp.Status, currentIp.IpNo); } if (orderType == null) { orderType = inProcessLocation.OrderType; } //�ж�OrderHead��PartyFrom�Ƿ�һ�� if (partyFrom == null) { partyFrom = inProcessLocation.PartyFrom; } else if (inProcessLocation.PartyFrom.Code != partyFrom.Code) { throw new BusinessErrorException("Order.Error.ReceiveOrder.PartyFromNotEqual"); } //�ж�OrderHead��PartyFrom�Ƿ�һ�� if (partyTo == null) { partyTo = inProcessLocation.PartyTo; } else if (inProcessLocation.PartyTo.Code != partyTo.Code) { throw new BusinessErrorException("Order.Error.ReceiveOrder.PartyToNotEqual"); } //�ж�OrderHead��ShipFrom�Ƿ�һ�� if (shipFrom == null) { shipFrom = inProcessLocation.ShipFrom; } else if (!AddressHelper.IsAddressEqual(inProcessLocation.ShipFrom, shipFrom)) { throw new BusinessErrorException("Order.Error.ReceiveOrder.ShipFromNotEqual"); } //�ж�OrderHead��ShipTo�Ƿ�һ�� if (shipTo == null) { shipTo = inProcessLocation.ShipTo; } else if (!AddressHelper.IsAddressEqual(inProcessLocation.ShipTo, shipTo)) { throw new BusinessErrorException("Order.Error.ReceiveOrder.ShipToNotEqual"); } if (dockDescription == null) { dockDescription = inProcessLocation.DockDescription; } else if (inProcessLocation.DockDescription != dockDescription) { throw new BusinessErrorException("Order.Error.ReceiveOrder.DockDescriptionNotEqual"); } //�ж��ջ�����ӡģ���Ƿ�һ�� if (receiptTemplate == null) { receiptTemplate = inProcessLocation.ReceiptTemplate; } else { if (inProcessLocation.ReceiptTemplate != null && inProcessLocation.ReceiptTemplate != receiptTemplate) { throw new BusinessErrorException("Order.Error.ReceiveOrder.ReceiptTemplateNotEqual"); } } //�ж������ӡģ���Ƿ�һ�� if (huTemplate == null) { huTemplate = inProcessLocation.HuTemplate; } else { if (inProcessLocation.HuTemplate != null && inProcessLocation.HuTemplate != huTemplate) { throw new BusinessErrorException("Order.Error.ReceiveOrder.HuTemplateNotEqual"); } } #region �����ջ����촦��ѡ�� if (grGapTo == null) { grGapTo = inProcessLocation.GoodsReceiptGapTo; } else { if (inProcessLocation.GoodsReceiptGapTo != null && inProcessLocation.GoodsReceiptGapTo != grGapTo) { throw new BusinessErrorException("Order.Error.ReceiveOrder.GoodsReceiptGapToNotEqual"); } } #endregion IListHelper.AddRange<InProcessLocationDetail>( inProcessLocationDetailList, this.inProcessLocationDetailMgr.GetInProcessLocationDetail(inProcessLocation)); } } #endregion IList<ReceiptDetail> targetReceiptDetailList = receipt.ReceiptDetails; receipt.ReceiptDetails = null; //���Asn��ϸ���Ժ���� #region �����ջ���Head receipt.ReceiptNo = numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_RECEIPT); receipt.OrderType = orderType; receipt.CreateDate = DateTime.Now; receipt.CreateUser = user; receipt.PartyFrom = partyFrom; receipt.PartyTo = partyTo; receipt.ShipFrom = shipFrom; receipt.ShipTo = shipTo; receipt.DockDescription = dockDescription; receipt.ReceiptTemplate = receiptTemplate; receipt.IsPrinted = false; receipt.NeedPrint = false; if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0) { foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations) { if (inProcessLocation.NeedPrintReceipt) { receipt.NeedPrint = true; break; } } } this.CreateReceipt(receipt); log.Debug("Create receipt " + receipt.ReceiptNo + " head successful"); #endregion #region HU����/������/�����ջ���ϸ log.Debug("Start create receipt detail"); IList<LocationLotDetail> inspectLocationLotDetailList = new List<LocationLotDetail>(); foreach (ReceiptDetail receiptDetail in targetReceiptDetailList) { OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; if (orderHead.CreateHuOption == BusinessConstants.CODE_MASTER_CREATE_HU_OPTION_VALUE_GR && receiptDetail.HuId == null) //�����������Ϊ�ջ�ʱ����Hu�������ջ�ʱ�Ѿ�ɨ���Hu�ˣ�����ɨ�账�� { #region �ջ�ʱ����Hu log.Debug("Create receipt detail with generate barcode."); #region ���������ջ�+ʣ����ͷ����Hu decimal oddQty = 0; if (!isOddCreateHu && orderDetail.HuLotSize.HasValue && orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) //ֻ������֧����ͷ { #region ����ʣ����ͷ + �����ջ����Ƿ��ܹ�����Hu Hu oddHu = this.CreateHuFromOdd(receiptDetail, user); if (oddHu != null) { log.Debug("Generate barcode using odd qty."); //�����ͷ������Hu�������ջ�����ۼ� #region ����Hu IList<Hu> oddHuList = new List<Hu>(); oddHuList.Add(oddHu); IList<ReceiptDetail> oddReceiptDetailList = this.receiptDetailMgr.CreateReceiptDetail(receipt, orderLocationTransaction, oddHuList); log.Debug("Generate odd barcode successful."); #endregion #region ��� IList<InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(oddReceiptDetailList[0], user, receiptDetail.PutAwayBinCode); log.Debug("odd Inventory in successful."); #endregion #region �Ƿ���� if (orderDetail.NeedInspection && orderHead.NeedInspection && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId); locationLotDetail.CurrentInspectQty = locationLotDetail.Qty; inspectLocationLotDetailList.Add(locationLotDetail); } } #endregion } #endregion oddQty = receiptDetail.ReceivedQty.HasValue && orderDetail.HuLotSize.HasValue ? receiptDetail.ReceivedQty.Value % orderDetail.HuLotSize.Value : 0; //�ջ���ͷ�� log.Debug("Receive odd qty is " + oddQty); receiptDetail.ReceivedQty = receiptDetail.ReceivedQty.Value - oddQty; //�ջ��������� } #endregion #region ����װ/��ͷ����Hu���� if (receiptDetail.ReceivedQty.HasValue || receiptDetail.RejectedQty.HasValue || receiptDetail.ScrapQty.HasValue) { //����Hu IList<Hu> huList = this.huMgr.CreateHu(receiptDetail, user); log.Debug("Create barcode successful."); //�����ջ��� IList<ReceiptDetail> receiptDetailList = this.receiptDetailMgr.CreateReceiptDetail(receipt, orderLocationTransaction, huList); log.Debug("Create receipt detail successful."); #region ������д�Ʒ���߷�Ʒ�ջ�����ӵ��ջ��б� if ((receiptDetail.RejectedQty.HasValue && receiptDetail.RejectedQty > 0) || (receiptDetail.ScrapQty.HasValue && receiptDetail.ScrapQty > 0)) { ReceiptDetail rejAndScrapReceiptDetail = new ReceiptDetail(); CloneHelper.CopyProperty(receiptDetail, rejAndScrapReceiptDetail); rejAndScrapReceiptDetail.ReceivedQty = null; rejAndScrapReceiptDetail.PutAwayBinCode = null; rejAndScrapReceiptDetail.Receipt = receipt; this.receiptDetailMgr.CreateReceiptDetail(rejAndScrapReceiptDetail); receiptDetailList.Add(rejAndScrapReceiptDetail); receipt.AddReceiptDetail(rejAndScrapReceiptDetail); } #endregion foreach (ReceiptDetail huReceiptDetail in receiptDetailList) { #region ƥ��ReceiptDetail��InProcessLocationDetail��Copy�����Ϣ if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) { IList<InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList); if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count > 0) { if (matchInProcessLocationDetailList.Count > 1) { //ֻ�е�ASN�а������룬�������ջ������ջ���������п��ܷ������������ //��̬����ô�ɡ� log.Error("ֻ�е�ASN�а������룬�������ջ������ջ���������п��ܷ������������"); throw new BusinessErrorException("���DZ�̬����ô���á�"); } //����ҵ�ƥ���ֻ������һ�� huReceiptDetail.PlannedBill = matchInProcessLocationDetailList[0].PlannedBill; huReceiptDetail.IsConsignment = matchInProcessLocationDetailList[0].IsConsignment; huReceiptDetail.ShippedQty = matchInProcessLocationDetailList[0].Qty; this.receiptDetailMgr.UpdateReceiptDetail(huReceiptDetail); } //�ջ�����HU������PlannedAmount��todo���������� huReceiptDetail.PlannedAmount = receiptDetail.PlannedAmount / receiptDetail.ReceivedQty.Value * huReceiptDetail.ReceivedQty.Value; } #endregion #region ��� IList<InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(huReceiptDetail, user, receiptDetail.PutAwayBinCode); log.Debug("Inventory in successful."); #endregion #region �Ƿ���� if (orderDetail.NeedInspection && orderHead.NeedInspection && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML && huReceiptDetail.ReceivedQty.HasValue && huReceiptDetail.ReceivedQty > 0) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { if (inventoryTransaction.Location.Code != BusinessConstants.SYSTEM_LOCATION_REJECT) { LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId); locationLotDetail.CurrentInspectQty = inventoryTransaction.Qty; inspectLocationLotDetailList.Add(locationLotDetail); } } } #endregion } } #endregion #region ����ʣ����ͷ���� if (oddQty > 0) { log.Debug("Start handle odd qty."); ReceiptDetail oddReceiptDetail = new ReceiptDetail(); CloneHelper.CopyProperty(receiptDetail, oddReceiptDetail); oddReceiptDetail.ReceivedQty = oddQty; oddReceiptDetail.RejectedQty = 0; oddReceiptDetail.ScrapQty = 0; #region ��ͷ��� oddReceiptDetail.Receipt = receipt; IList<InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(oddReceiptDetail, user, receiptDetail.PutAwayBinCode); #endregion #region ��ͷ�����ջ���ϸ this.receiptDetailMgr.CreateReceiptDetail(oddReceiptDetail); receipt.AddReceiptDetail(oddReceiptDetail); #endregion #region ����HuOdd LocationLotDetail locationLotDetail = locationLotDetailMgr.LoadLocationLotDetail(inventoryTransactionList[0].LocationLotDetailId); this.huOddMgr.CreateHuOdd(oddReceiptDetail, locationLotDetail, user); #endregion log.Debug("End handle odd qty."); } #endregion #endregion } else { #region �ջ�ʱ������Hu log.Debug("Create receipt detail with no generate barcode."); #region ����Hu�ϵ�OrderNo��ReceiptNo��AntiResloveHu if (receiptDetail.HuId != null && receiptDetail.HuId.Trim() != string.Empty) { Hu hu = this.huMgr.LoadHu(receiptDetail.HuId); bool isUpdated = false; if (hu.OrderNo == null || hu.ReceiptNo == null) { if (hu.OrderNo == null) { log.Debug("Update hu OrderNo " + orderHead.OrderNo + "."); hu.OrderNo = orderHead.OrderNo; } if (hu.ReceiptNo == null) { log.Debug("Update hu ReceiptNo " + receipt.ReceiptNo + "."); hu.ReceiptNo = receipt.ReceiptNo; } isUpdated = true; } if (hu.AntiResolveHu == null && orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT) { hu.AntiResolveHu = orderHead.AntiResolveHu; isUpdated = true; } if (isUpdated) { this.huMgr.UpdateHu(hu); } } #endregion IList<ReceiptDetail> noCreateHuReceiptDetailList = new List<ReceiptDetail>(); #region ƥ��ReceiptDetail��InProcessLocationDetail��Copy�����Ϣ log.Debug("Start match ReceiptDetail and InProcessLocationDetail."); if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION && orderHead.SubType != BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ) //�ջ������Ѿ�ƥ���InProcessLocationDetail������Ҫ��ƥ�� { IList<InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList); log.Debug("Find matched InProcessLocationDetailList, count = " + matchInProcessLocationDetailList != null ? matchInProcessLocationDetailList.Count : 0); if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count == 1) { //һ���ջ���Ӧһ�η����� log.Debug("one ipdet vs one receiptdet."); receiptDetail.PlannedBill = matchInProcessLocationDetailList[0].PlannedBill; receiptDetail.IsConsignment = matchInProcessLocationDetailList[0].IsConsignment; if (matchInProcessLocationDetailList[0].InProcessLocation.Type == BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_GAP) { receiptDetail.ShippedQty = 0 - matchInProcessLocationDetailList[0].Qty; } else { receiptDetail.ShippedQty = matchInProcessLocationDetailList[0].Qty; } receiptDetail.ReceivedInProcessLocationDetail = matchInProcessLocationDetailList[0]; noCreateHuReceiptDetailList.Add(receiptDetail); } else if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count > 1) { //һ���ջ���Ӧ��η����� //�磺���������룬�ջ��������� log.Debug("multi ipdet vs one receiptdet."); decimal totalRecQty = receiptDetail.ReceivedQty.Value; InProcessLocationDetail lastInProcessLocationDetail = null; log.Debug("Start Fetch matched InProcessLocationDetailList."); foreach (InProcessLocationDetail inProcessLocationDetail in matchInProcessLocationDetailList) { lastInProcessLocationDetail = inProcessLocationDetail; //��¼���һ�η������û�ж�Ӧ�������ջ���ʹ�� if (inProcessLocationDetail.ReceivedQty.HasValue && Math.Abs(inProcessLocationDetail.ReceivedQty.Value) >= Math.Abs(inProcessLocationDetail.Qty)) { continue; } if (Math.Abs(totalRecQty) > 0) { log.Debug("Start cloned ReceiptDetail."); ReceiptDetail clonedReceiptDetail = new ReceiptDetail(); CloneHelper.CopyProperty(receiptDetail, clonedReceiptDetail); log.Debug("End cloned ReceiptDetail."); clonedReceiptDetail.PlannedBill = inProcessLocationDetail.PlannedBill; clonedReceiptDetail.IsConsignment = inProcessLocationDetail.IsConsignment; #region if (matchInProcessLocationDetailList[0].InProcessLocation.Type == BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_GAP) { inProcessLocationDetail.Qty = 0 - inProcessLocationDetail.Qty; } #endregion if (Math.Abs(totalRecQty) > Math.Abs(inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero))) { clonedReceiptDetail.ReceivedQty = inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero); clonedReceiptDetail.ShippedQty = inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero); totalRecQty -= inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero); } else { clonedReceiptDetail.ReceivedQty = totalRecQty; clonedReceiptDetail.ShippedQty = totalRecQty; totalRecQty = 0; } //��Ϊȥ������������¼�Ѿ�ƥ��ķ����������촦���ʱ��ƥ��������������졣 clonedReceiptDetail.ReceivedInProcessLocationDetail = inProcessLocationDetail; noCreateHuReceiptDetailList.Add(clonedReceiptDetail); } else { break; } } log.Debug("End Fetch matched InProcessLocationDetailList."); //���գ�û���ҵ���Ӧ�ķ����ֻ��¼�ջ�������������0 if (Math.Abs(totalRecQty) > 0) { ReceiptDetail clonedReceiptDetail = new ReceiptDetail(); CloneHelper.CopyProperty(receiptDetail, clonedReceiptDetail); clonedReceiptDetail.ShippedQty = 0; clonedReceiptDetail.ReceivedQty = totalRecQty; clonedReceiptDetail.ReceivedInProcessLocationDetail = lastInProcessLocationDetail; noCreateHuReceiptDetailList.Add(clonedReceiptDetail); } } else { noCreateHuReceiptDetailList.Add(receiptDetail); } } else { noCreateHuReceiptDetailList.Add(receiptDetail); } log.Debug("End match ReceiptDetail and InProcessLocationDetail."); #endregion foreach (ReceiptDetail noCreateHuReceiptDetail in noCreateHuReceiptDetailList) { noCreateHuReceiptDetail.Receipt = receipt; if (noCreateHuReceiptDetail.ReceivedQty != 0) { #region ��� log.Debug("Start Inventory In."); IList<InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(noCreateHuReceiptDetail, user, noCreateHuReceiptDetail.PutAwayBinCode); log.Debug("End Inventory In."); #endregion #region �Ƿ���� if (orderDetail.NeedInspection && orderHead.NeedInspection && inventoryTransactionList != null && inventoryTransactionList.Count > 0 && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { if (inventoryTransaction.Location.Code != BusinessConstants.SYSTEM_LOCATION_REJECT) { LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId); locationLotDetail.CurrentInspectQty = inventoryTransaction.Qty; inspectLocationLotDetailList.Add(locationLotDetail); } } } #endregion } #region �����ջ���ϸ log.Debug("Start Create Receipt Detail."); this.receiptDetailMgr.CreateReceiptDetail(noCreateHuReceiptDetail); receipt.AddReceiptDetail(noCreateHuReceiptDetail); log.Debug("End Create Receipt Detail."); #endregion } #endregion } } #endregion #region ���� if (inspectLocationLotDetailList.Count > 0) { //����û��Hu�ģ�����ջ�ʱ�Ѿ��س��˸�����棬Ҳ���ǿ�������ʹ�����������һ�¿��ܻ������� //����ipno��receiptno��isseperated�ֶ� this.inspectOrderMgr.CreateInspectOrder(inspectLocationLotDetailList, user, receipt.InProcessLocations[0].IpNo, receipt.ReceiptNo, false); } #endregion //#region ƥ���ջ���������Ҳ��� //IList<InProcessLocationDetail> gapInProcessLocationDetailList = new List<InProcessLocationDetail>(); //#region �����ƥ�� //foreach (InProcessLocationDetail inProcessLocationDetail in inProcessLocationDetailList) //{ // if (inProcessLocationDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type // != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) //������ʱ��֧�ֲ��� // { // decimal receivedQty = 0; //��������ۼ��ջ��� // //һ����������ܶ�Ӧ�����ջ��� // foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) // { // //ƥ���ջ���ͷ����� // if (receiptDetail.ReceivedInProcessLocationDetail != null) // { // //�����Ѿ�ƥ��ģ�ֱ�Ӱ�������ƥ�� // if (receiptDetail.ReceivedInProcessLocationDetail.Id == inProcessLocationDetail.Id) // { // if (receiptDetail.ReceivedQty.HasValue) // { // receivedQty += receiptDetail.ReceivedQty.Value; // } // } // } // else if (OrderHelper.IsInProcessLocationDetailMatchReceiptDetail( // inProcessLocationDetail, receiptDetail)) // { // if (receiptDetail.ReceivedQty.HasValue) // { // receivedQty += receiptDetail.ReceivedQty.Value; // } // } // } // if (receivedQty != inProcessLocationDetail.Qty) // { // #region �ջ������ͷ���������ƥ�䣬��¼���� // InProcessLocationDetail gapInProcessLocationDetail = new InProcessLocationDetail(); // gapInProcessLocationDetail.Qty = receivedQty - inProcessLocationDetail.Qty; // gapInProcessLocationDetail.OrderLocationTransaction = inProcessLocationDetail.OrderLocationTransaction; // //gapInProcessLocationDetail.HuId = inProcessLocationDetail.HuId; // gapInProcessLocationDetail.LotNo = inProcessLocationDetail.LotNo; // gapInProcessLocationDetail.IsConsignment = inProcessLocationDetail.IsConsignment; // gapInProcessLocationDetail.PlannedBill = inProcessLocationDetail.PlannedBill; // gapInProcessLocationDetailList.Add(gapInProcessLocationDetail); // #endregion // } // } //} //#endregion //#region �ջ��ƥ�� //foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) //{ // if (receiptDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type // != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) //������ʱ��֧�ֲ��� // { // IList<InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList); // if (matchInProcessLocationDetailList == null || matchInProcessLocationDetailList.Count == 0) // { // OrderLocationTransaction outOrderLocationTransaction = // this.orderLocationTransactionMgr.GetOrderLocationTransaction(receiptDetail.OrderLocationTransaction.OrderDetail, BusinessConstants.IO_TYPE_OUT)[0]; // #region û���ҵ����ջ����Ӧ�ķ����� // InProcessLocationDetail gapInProcessLocationDetail = new InProcessLocationDetail(); // gapInProcessLocationDetail.Qty = receiptDetail.ReceivedQty.Value; // gapInProcessLocationDetail.OrderLocationTransaction = outOrderLocationTransaction; // //gapInProcessLocationDetail.HuId = receiptDetail.HuId; // gapInProcessLocationDetail.LotNo = receiptDetail.LotNo; // gapInProcessLocationDetail.IsConsignment = receiptDetail.IsConsignment; // gapInProcessLocationDetail.PlannedBill = receiptDetail.PlannedBill; // gapInProcessLocationDetailList.Add(gapInProcessLocationDetail); // #endregion // } // } //} //#endregion //#endregion #region �ر�InProcessLocation if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0) { foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations) { if (inProcessLocation.IsAsnUniqueReceipt) { //��֧�ֶ���ջ�ֱ�ӹر� this.inProcessLocationMgr.CloseInProcessLocation(inProcessLocation, user); } else { this.inProcessLocationMgr.TryCloseInProcessLocation(inProcessLocation, user); } //transportationOrderMgr.TryCompleteTransportationOrder(inProcessLocation, user); } } #endregion }