public static TransformerDetail ConvertRepackDetailToTransformerDetail(RepackDetail repackDetail) { TransformerDetail transformerDetail = new TransformerDetail(); if (repackDetail.LocationLotDetail.Hu != null) { transformerDetail = ConvertHuToTransformerDetail(repackDetail.LocationLotDetail.Hu); transformerDetail.Qty = repackDetail.Qty / repackDetail.LocationLotDetail.Hu.UnitQty; transformerDetail.CurrentQty = transformerDetail.Qty; } else { transformerDetail.ItemCode = repackDetail.LocationLotDetail.Item.Code; transformerDetail.ItemDescription = repackDetail.LocationLotDetail.Item.Description; transformerDetail.UomCode = repackDetail.LocationLotDetail.Item.Uom.Code; transformerDetail.UnitCount = repackDetail.LocationLotDetail.Item.UnitCount; transformerDetail.Qty = repackDetail.Qty; transformerDetail.CurrentQty = repackDetail.Qty; } transformerDetail.LocationLotDetId = repackDetail.LocationLotDetail.Id; transformerDetail.LocationCode = repackDetail.LocationLotDetail.Location.Code; transformerDetail.StorageBinCode = repackDetail.StorageBinCode; transformerDetail.IOType = repackDetail.IOType; return(transformerDetail); }
private void CreateRepack(Resolver resolver) { string[] huIdArr = resolver.Input.Split(','); List <ReceiptNote> receiptNotes = new List <ReceiptNote>(); foreach (string huId in huIdArr) { try { IList <RepackDetail> repackDetailList = new List <RepackDetail>(); LocationLotDetail locationLotDetail = locationLotDetailMgr.CheckLoadHuLocationLotDetail(huId); RepackDetail inRepackDetail = new RepackDetail(); inRepackDetail.LocationLotDetail = locationLotDetail; inRepackDetail.Hu = locationLotDetail.Hu; inRepackDetail.IOType = BusinessConstants.IO_TYPE_IN; inRepackDetail.Qty = inRepackDetail.Hu.Qty * inRepackDetail.Hu.UnitQty; repackDetailList.Add(inRepackDetail); RepackDetail outRepackDetail = new RepackDetail(); outRepackDetail.itemCode = inRepackDetail.Hu.Item.Code; outRepackDetail.IOType = BusinessConstants.IO_TYPE_OUT; outRepackDetail.Qty = inRepackDetail.Qty; repackDetailList.Add(outRepackDetail); Repack repack = repackMgr.CreateDevanning(repackDetailList, userMgr.CheckAndLoadUser(resolver.UserCode)); ReceiptNote receiptNote = Repack2ReceiptNote(repack); receiptNotes.Add(receiptNote); } catch (Exception ex) { continue; } } if (resolver.ReceiptNotes == null) { resolver.ReceiptNotes = receiptNotes; } else { IListHelper.AddRange <ReceiptNote>(resolver.ReceiptNotes, receiptNotes); } }
public IList <RepackDetail> ConvertTransformerListToRepackDetail(IList <Transformer> transformerList) { IList <RepackDetail> repackDetailList = new List <RepackDetail>(); if (transformerList != null && transformerList.Count == 2) { foreach (Transformer transformer in transformerList) { if (transformer.TransformerDetails != null) { foreach (TransformerDetail transformerDetail in transformer.TransformerDetails) { RepackDetail repackDetail = new RepackDetail(); repackDetail.IOType = transformerDetail.IOType; if (transformerDetail.HuId != string.Empty) { repackDetail.Hu = huMgr.LoadHu(transformerDetail.HuId); repackDetail.Qty = repackDetail.Hu.Qty * repackDetail.Hu.UnitQty; } else { repackDetail.Qty = transformerDetail.Qty; repackDetail.itemCode = transformerDetail.ItemCode; } if (transformerDetail.LocationLotDetId != 0) { repackDetail.LocationLotDetail = locationLotDetailMgr.LoadLocationLotDetail(transformerDetail.LocationLotDetId); } repackDetailList.Add(repackDetail); } } } } return(repackDetailList); }
protected void btnRepack_Click(object sender, EventArgs e) { try { if (this.RepackType == BusinessConstants.CODE_MASTER_REPACK_TYPE_VALUE_REPACK) { if (this.IsQty) { if (this.tbLocation.Text.Trim() == string.Empty) { ShowErrorMessage("MasterData.Inventory.Repack.Location.Empty"); return; } if (this.OutTransformerDetailList == null || this.OutTransformerDetailList.Count == 0) { ShowErrorMessage("MasterData.Inventory.Repack.Error.RepackDetailEmpty"); return; } IList <RepackDetail> repackDetailList = new List <RepackDetail>(); IDictionary <string, decimal> ItemDic = new Dictionary <string, decimal>(); foreach (TransformerDetail transformerDetail in OutTransformerDetailList) { RepackDetail outRepackDetail = new RepackDetail(); outRepackDetail.IOType = BusinessConstants.IO_TYPE_OUT; outRepackDetail.Hu = TheHuMgr.LoadHu(transformerDetail.HuId); outRepackDetail.Qty = outRepackDetail.Hu.Qty * outRepackDetail.Hu.UnitQty; if (ItemDic.ContainsKey(outRepackDetail.Hu.Item.Code)) { ItemDic[outRepackDetail.Hu.Item.Code] += outRepackDetail.Qty; } else { ItemDic.Add(outRepackDetail.Hu.Item.Code, outRepackDetail.Qty); } repackDetailList.Add(outRepackDetail); } if (repackDetailList.Count > 0) { foreach (string item in ItemDic.Keys) { IList <LocationLotDetail> locationLotDetailList = TheLocationLotDetailMgr.GetLocationLotDetail(this.tbLocation.Text.Trim(), item, false, false, BusinessConstants.PLUS_INVENTORY, null, false); if (locationLotDetailList == null || locationLotDetailList.Count == 0) { ShowErrorMessage("MasterData.Inventory.Repack.LocationLotDetail.Empty"); return; } decimal locQty = (from l in locationLotDetailList select l.Qty).Sum(); decimal outQty = ItemDic[item]; if (outQty > locQty) { ShowErrorMessage("MasterData.Inventory.LocationLotDetail.LessThanHuQty", item, locQty.ToString("0.########"), outQty.ToString("0.########")); return; } foreach (LocationLotDetail locationLotDetail in locationLotDetailList) { RepackDetail inRepackDetail = new RepackDetail(); inRepackDetail.LocationLotDetail = locationLotDetail; inRepackDetail.IOType = BusinessConstants.IO_TYPE_IN; repackDetailList.Add(inRepackDetail); if (locationLotDetail.Qty < outQty) { inRepackDetail.Qty = locationLotDetail.Qty; outQty -= inRepackDetail.Qty; } else { inRepackDetail.Qty = outQty; break; } } } } Repack repack = TheRepackMgr.CreateRepack(repackDetailList, this.CurrentUser); if (this.IsQty) { RepackEvent(repack.RepackNo, e); } } else { ExecuteSubmit(); Repack repack = TheRepackMgr.LoadRepack(this.CacheResolver.Code, true); IList <Hu> huList = new List <Hu>(); foreach (RepackDetail repackDet in repack.RepackDetails) { if (repackDet.IOType == BusinessConstants.IO_TYPE_OUT && repackDet.LocationLotDetail.Hu != null && repackDet.LocationLotDetail.Hu.PrintCount == 0) { huList.Add(repackDet.LocationLotDetail.Hu); } } if (huList.Count > 0) { IList <object> huDetailObj = new List <object>(); huDetailObj.Add(huList); huDetailObj.Add(CurrentUser.Code); string huTemplate = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_HU_TEMPLATE).Value; if (huTemplate != null && huTemplate.Length > 0) { string barCodeUrl = TheReportMgr.WriteToFile(huTemplate, huDetailObj, "BarCode.xls"); Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + barCodeUrl + "'); </script>"); } } } } else if (this.RepackType == BusinessConstants.CODE_MASTER_REPACK_TYPE_VALUE_DEVANNING) { UpdateOutTransformer(); ExecuteSubmit(); } if (RepackEvent != null && !this.IsQty) { RepackEvent(this.CacheResolver.Code, e); } } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
private Repack CreateRepack(IList <RepackDetail> repackDetailList, string type, User user) { IList <RepackDetail> inRepackDetailList = new List <RepackDetail>(); IList <RepackDetail> outRepackDetailList = new List <RepackDetail>(); bool hasHu = false; #region 判断RepackDetailList是否为空 if (repackDetailList != null && repackDetailList.Count > 0) { foreach (RepackDetail repackDetail in repackDetailList) { if (repackDetail.Qty != 0) { if (repackDetail.IOType == BusinessConstants.IO_TYPE_IN) { inRepackDetailList.Add(repackDetail); } else if (repackDetail.IOType == BusinessConstants.IO_TYPE_OUT) { outRepackDetailList.Add(repackDetail); if (!hasHu && repackDetail.Hu != null) { hasHu = true; } } else { throw new TechnicalException("Invalid IO Type:" + repackDetail.IOType); } } } #region 翻箱的如果没有输出,将输入代码合并,生成一张新条码 if (outRepackDetailList.Count == 0 && type == BusinessConstants.CODE_MASTER_REPACK_TYPE_VALUE_REPACK) { Hu inHu = inRepackDetailList[0].Hu; Hu outHu = new Hu(); CloneHelper.CopyProperty(inHu, outHu); outHu.OrderNo = null; outHu.ReceiptNo = null; outHu.Location = null; outHu.StorageBin = null; outHu.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; string repackShift = entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_REPACK_SHIFT).Value; string prefix = inHu.HuId.Substring(0, inHu.HuId.Length - 4) + repackShift; outHu.HuId = numberControlMgr.GenerateNumber(prefix, 3); outHu.Qty = (from l in inRepackDetailList select l.Qty).Sum(); outHu.UnitCount = outHu.Qty; outHu.LotSize = outHu.UnitCount; outHu.PrintCount = 0; huMgr.CreateHu(outHu); RepackDetail outRepackDetail = new RepackDetail(); outRepackDetail.Hu = outHu; outRepackDetail.IOType = BusinessConstants.IO_TYPE_OUT; outRepackDetail.Qty = outHu.Qty; outRepackDetail.itemCode = outHu.Item.Code; outRepackDetailList.Add(outRepackDetail); } #endregion if (inRepackDetailList.Count == 0 || outRepackDetailList.Count == 0) { throw new BusinessErrorException("MasterData.Inventory.Repack.Error.RepackDetailEmpty"); } if (hasHu && type == BusinessConstants.CODE_MASTER_REPACK_TYPE_VALUE_DEVANNING && outRepackDetailList.Count < 2) { throw new BusinessErrorException("MasterData.Inventory.Devanning.Error.DevanningDetailLessThanTwo"); } } else { throw new BusinessErrorException("MasterData.Inventory.Repack.Error.RepackDetailEmpty"); } #endregion #region 判断是否被拣货 foreach (RepackDetail inRepackDetail in inRepackDetailList) { if (inRepackDetail.LocationLotDetail.Hu != null && this.locationMgr.IsHuOcuppyByPickList(inRepackDetail.LocationLotDetail.Hu.HuId)) { throw new BusinessErrorException("MasterData.Inventory.Repack.Error.HuOccupied", inRepackDetail.Hu.HuId); } } #endregion #region 判断翻箱后条码是否为新条码 foreach (RepackDetail outRepackDetail in outRepackDetailList) { if (outRepackDetail.Hu != null && outRepackDetail.Hu.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE) { throw new BusinessErrorException("MasterData.Inventory.Repack.Error.HuStatusNotCreate", outRepackDetail.Hu.HuId); } } #endregion #region 检查In和Out明细数量是否匹配 IDictionary <string, decimal> inItemQtyDic = new Dictionary <string, decimal>(); Location location = null; #region 收集In数量 foreach (RepackDetail inRepackDetail in inRepackDetailList) { LocationLotDetail inLocationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inRepackDetail.LocationLotDetail.Id); if (location == null) { location = inLocationLotDetail.Location; if (!user.HasPermission(inLocationLotDetail.Location.Region.Code)) { throw new BusinessErrorException("MasterData.Inventory.Repack.Error.NoPermission", location.Code); } } else if (location.Code != inLocationLotDetail.Location.Code) { throw new BusinessErrorException("MasterData.Inventory.Repack.Error.InRepackDetailLocationNotEqual"); } if (inItemQtyDic.ContainsKey(inLocationLotDetail.Item.Code)) { inItemQtyDic[inLocationLotDetail.Item.Code] += inRepackDetail.Qty; } else { inItemQtyDic.Add(inLocationLotDetail.Item.Code, inRepackDetail.Qty); } } #endregion #region 收集Out数量 IDictionary <string, decimal> outItemQtyDic = new Dictionary <string, decimal>(); foreach (RepackDetail outRepackDetail in outRepackDetailList) { if (type == BusinessConstants.CODE_MASTER_REPACK_TYPE_VALUE_REPACK) { if (outRepackDetail.Hu == null) { throw new BusinessErrorException("MasterData.Inventory.Repack.Error.HuIdIsEmpty"); } else { if (outItemQtyDic.ContainsKey(outRepackDetail.Hu.Item.Code)) { outItemQtyDic[outRepackDetail.Hu.Item.Code] += outRepackDetail.Qty; } else { outItemQtyDic.Add(outRepackDetail.Hu.Item.Code, outRepackDetail.Qty); } } } else if (type == BusinessConstants.CODE_MASTER_REPACK_TYPE_VALUE_DEVANNING) { string itemCode = outRepackDetail.Hu != null ? outRepackDetail.Hu.Item.Code : outRepackDetail.itemCode; if (itemCode == null) { throw new TechnicalException("ItemCode not specified."); } if (outItemQtyDic.ContainsKey(itemCode)) { outItemQtyDic[itemCode] += outRepackDetail.Qty; } else { outItemQtyDic.Add(itemCode, outRepackDetail.Qty); } } else { throw new TechnicalException("Repack type: " + type + " is not valided."); } } #endregion #region 比较 if (inItemQtyDic.Count != outItemQtyDic.Count) { throw new BusinessErrorException("MasterData.Inventory.Repack.Error.InOutQtyNotMatch"); } foreach (string itemCode in inItemQtyDic.Keys) { if (outItemQtyDic.ContainsKey(itemCode)) { decimal inQty = inItemQtyDic[itemCode]; decimal outQty = outItemQtyDic[itemCode]; //是否自动创建剩余数量的记录 bool autoCreate = bool.Parse(entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_AUTO_CREATE_WHEN_DEAVING).Value); #region 拆箱根据剩余数量得到剩余数量的条码 if (autoCreate && type == BusinessConstants.CODE_MASTER_REPACK_TYPE_VALUE_DEVANNING && inQty > outQty) { RepackDetail remainRepackDetail = CloneHelper.DeepClone(inRepackDetailList[0]); remainRepackDetail.Qty = inQty - outQty; remainRepackDetail.IOType = BusinessConstants.IO_TYPE_OUT; outRepackDetailList.Add(remainRepackDetail); } #endregion else if (inQty != outQty) { throw new BusinessErrorException("MasterData.Inventory.Repack.Error.InOutQtyNotMatch"); } } else { throw new BusinessErrorException("MasterData.Inventory.Repack.Error.InOutItemNotMatch", itemCode); } } #endregion #endregion #region 创建翻箱单头 Repack repack = new Repack(); repack.RepackNo = this.numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_REPACK); repack.CreateDate = DateTime.Now; repack.CreateUser = user; repack.Type = type; this.CreateRepack(repack); #endregion #region 创建翻箱单明细 Int32?plannedBillId = null; //拆箱传递PlannedBill foreach (RepackDetail inRepackDetail in inRepackDetailList) { //出库 inRepackDetail.Repack = repack; this.locationMgr.InventoryRepackIn(inRepackDetail, user); this.repackDetailMgr.CreateRepackDetail(inRepackDetail); if (repack.Type == BusinessConstants.CODE_MASTER_REPACK_TYPE_VALUE_DEVANNING) { plannedBillId = inRepackDetail.LocationLotDetail.IsConsignment ? inRepackDetail.LocationLotDetail.PlannedBill : null; } } foreach (RepackDetail outRepackDetail in outRepackDetailList) { //入库 outRepackDetail.Repack = repack; InventoryTransaction inventoryTransaction = this.locationMgr.InventoryRepackOut(outRepackDetail, location, plannedBillId, user); outRepackDetail.LocationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId); this.repackDetailMgr.CreateRepackDetail(outRepackDetail); } #endregion return(repack); }
public virtual void DeleteRepackDetail(RepackDetail entity) { Delete(entity); }
public virtual void UpdateRepackDetail(RepackDetail entity) { Update(entity); }
public virtual void CreateRepackDetail(RepackDetail entity) { Create(entity); }
public virtual void DeleteRepackDetail(RepackDetail entity) { entityDao.DeleteRepackDetail(entity); }
public virtual void UpdateRepackDetail(RepackDetail entity) { entityDao.UpdateRepackDetail(entity); }
public virtual void CreateRepackDetail(RepackDetail entity) { entityDao.CreateRepackDetail(entity); }