protected override void SetDetail(Resolver resolver) { //setDetailMgr.CheckHuInTransformerDetails(resolver); LocationLotDetail locationLotDetail = locationLotDetailMgr.CheckLoadHuLocationLotDetail(resolver.Input, resolver.UserCode); //Hu hu = locationLotDetail.Hu; //hu.Qty = locationLotDetail.Qty / hu.UnitQty; if (this.locationMgr.IsHuOcuppyByPickList(resolver.Input)) { throw new BusinessErrorException("Order.Error.PickUp.HuOcuppied", resolver.Input); } //已经下架 if (locationLotDetail.StorageBin == null) { throw new BusinessErrorException("Warehouse.PickUp.Error.IsAlreadyPickUp", resolver.Input); } TransformerDetail transformerDetail = TransformerHelper.ConvertLocationLotDetailToTransformerDetail(locationLotDetail, false); resolver.AddTransformerDetail(transformerDetail); //transformerDetail.CurrentQty = transformerDetail.Qty; //int maxSeq = setDetailMgr.FindMaxSeq(resolver.Transformers); //transformerDetail.Sequence = maxSeq + 1; //resolver.Transformers[0].TransformerDetails.Add(transformerDetail); //resolver.Command = BusinessConstants.CS_BIND_VALUE_TRANSFORMERDETAIL; }
protected override void SetDetail(Resolver resolver) { LocationLotDetail locationLotDetail = locationLotDetailMgr.CheckLoadHuLocationLotDetail(resolver.Input, resolver.UserCode); TransformerDetail transformerDetail = TransformerHelper.ConvertLocationLotDetailToTransformerDetail(locationLotDetail, false); resolver.AddTransformerDetail(transformerDetail); resolver.Command = BusinessConstants.CS_BIND_VALUE_TRANSFORMERDETAIL; }
protected override void SetDetail(Resolver resolver) { Hu hu = huMgr.CheckAndLoadHu(resolver.Input); if (this.locationMgr.IsHuOcuppyByPickList(resolver.Input)) { throw new BusinessErrorException("Order.Error.PickUp.HuOcuppied", resolver.Input); } if (resolver.BinCode == string.Empty || resolver.BinCode == null) { throw new BusinessErrorException("Warehouse.PutAway.PlzScanBin"); } if (hu.StorageBin != null && hu.StorageBin.Trim() != string.Empty && hu.StorageBin == resolver.BinCode) { throw new BusinessErrorException("Warehouse.PutAway.AlreadyInThisBin"); } //校验Bin StorageBin bin = storageBinMgr.CheckAndLoadStorageBin(resolver.BinCode); LocationLotDetail locationLotDetail = locationLotDetailMgr.CheckLoadHuLocationLotDetail(resolver.Input, string.Empty, bin.Area.Location.Code); locationLotDetail.NewStorageBin = bin; TransformerDetail transformerDetail = TransformerHelper.ConvertLocationLotDetailToTransformerDetail(locationLotDetail, true); resolver.AddTransformerDetail(transformerDetail); }
protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //按Hu单位显示库存数量 LocationLotDetail locationLotDetail = (LocationLotDetail)e.Row.DataItem; decimal qty = decimal.Parse(e.Row.Cells[10].Text); //库存单位 e.Row.Cells[10].Text = (qty / locationLotDetail.Hu.UnitQty).ToString("F2"); //转为Hu单位 } }
public LocationLotDetail ConvertTransformerDetailToLocationLotDetail(TransformerDetail transformerDetail, bool isPutAway) { LocationLotDetail locationLotDetail = locationLotDetailMgr.LoadLocationLotDetail(transformerDetail.Id); locationLotDetail.CurrentInspectQty = locationLotDetail.Qty; if (isPutAway && transformerDetail.StorageBinCode != null && transformerDetail.StorageBinCode.Trim() != string.Empty) { locationLotDetail.NewStorageBin = storageBinMgr.CheckAndLoadStorageBin(transformerDetail.StorageBinCode); } return(locationLotDetail); }
/// <summary> /// 仅校验投料的物料号,库位是否一致,不校验单位单包装等信息 /// todo:不允许投入的又有数量又有Hu //可以前台控制 /// </summary> /// <param name="resolver"></param> protected override void SetDetail(Resolver resolver) { if (resolver.CodePrefix == string.Empty) { throw new BusinessErrorException("Common.Business.Error.ScanProductLineFirst"); } LocationLotDetail locationLotDetail = locationLotDetailMgr.CheckLoadHuLocationLotDetail(resolver.Input, resolver.UserCode); TransformerDetail transformerDetail = TransformerHelper.ConvertLocationLotDetailToTransformerDetail(locationLotDetail, false); var query = resolver.Transformers.Where (t => (t.ItemCode == transformerDetail.ItemCode && t.LocationCode == transformerDetail.LocationCode)); if (query.Count() < 1) { throw new BusinessErrorException("Warehouse.HuMatch.NotMatch", transformerDetail.HuId); } #region 先进先出校验 Flow flow = flowMgr.CheckAndLoadFlow(resolver.Code); if (flow.IsGoodsReceiveFIFO) { Hu hu = huMgr.CheckAndLoadHu(resolver.Input); IList <string> huIdList = new List <string>(); if (resolver.Transformers != null && resolver.Transformers.Count > 0) { foreach (Transformer transformer in resolver.Transformers) { if (transformer.TransformerDetails != null && transformer.TransformerDetails.Count > 0) { foreach (TransformerDetail det in transformer.TransformerDetails) { if (det.CurrentQty != decimal.Zero) { huIdList.Add(det.HuId); } } } } } string maxLot = setDetailMgr.CheckFIFO(hu, huIdList); if (maxLot != string.Empty && maxLot != null) { throw new BusinessErrorException("FIFO.ERROR", hu.HuId, maxLot); } } #endregion resolver.AddTransformerDetail(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 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 ActingBill ManualCreateActingBill(PlannedBill plannedBill, LocationLotDetail locationLotDetail, User user) { IList <LocationLotDetail> locationLotDetailList = this.locationLotDetailMgr.GetLocationLotDetail(plannedBill); if (locationLotDetailList != null && locationLotDetailList.Count > 0) { decimal actingQty = Math.Round(plannedBill.CurrentActingQty * plannedBill.UnitQty, 8); foreach (LocationLotDetail currentLocationLotDetail in locationLotDetailList) { if (actingQty > 0) { #region 更新库存寄售标记 if (actingQty - currentLocationLotDetail.Qty >= 0) { actingQty -= currentLocationLotDetail.Qty; currentLocationLotDetail.IsConsignment = false; currentLocationLotDetail.PlannedBill = null; } else { //不支持同一库存记录进行部分结算 throw new BusinessErrorException("Location.Error.PlannedBill.CantSplitInventory"); } this.locationLotDetailMgr.UpdateLocationLotDetail(currentLocationLotDetail); #endregion } else { break; } } } #region 创建ActBill ActingBill actingBill = this.CreateActingBill(plannedBill, locationLotDetail, user); #endregion return(actingBill); }
protected override void SetDetail(Resolver resolver) { if (resolver.CodePrefix == string.Empty) { throw new BusinessErrorException("Common.Business.Error.ScanFlowFirst"); } if (resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_PRODUCTIONRECEIVE) { LocationLotDetail locationLotDetail = locationLotDetailMgr.CheckLoadHuLocationLotDetail(resolver.Input, resolver.UserCode); TransformerDetail newTransformerDetail = TransformerHelper.ConvertLocationLotDetailToTransformerDetail(locationLotDetail, false); resolver.AddTransformerDetail(newTransformerDetail); } else { setDetailMgr.MatchReceive(resolver); if (resolver.BinCode != null && resolver.BinCode != string.Empty) { resolver.Result = languageMgr.TranslateMessage("Warehouse.CurrentBinCode", resolver.UserCode, resolver.BinCode); } } }
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 void RecordBillTransaction(PlannedBill plannedBill, ActingBill actingBill, LocationLotDetail locationLotDetail, User user) { #region 记BillTransaction DateTime dateTimeNow = DateTime.Now; BillTransaction billTransaction = new BillTransaction(); billTransaction.OrderNo = plannedBill.OrderNo; billTransaction.ExternalReceiptNo = plannedBill.ExternalReceiptNo; billTransaction.ReceiptNo = plannedBill.ReceiptNo; billTransaction.Item = plannedBill.Item.Code; billTransaction.ItemDescription = plannedBill.Item.Description; billTransaction.Uom = plannedBill.Uom.Code; billTransaction.BillAddress = plannedBill.BillAddress.Code; billTransaction.BillAddressDescription = plannedBill.BillAddress.Address; billTransaction.Party = plannedBill.BillAddress.Party.Code; billTransaction.PartyName = plannedBill.BillAddress.Party.Name; billTransaction.Qty = plannedBill.CurrentActingQty; billTransaction.EffectiveDate = DateTime.Parse(dateTimeNow.ToShortDateString()); //仅保留年月日; billTransaction.TransactionType = plannedBill.TransactionType; billTransaction.PlannedBill = plannedBill.Id; billTransaction.CreateUser = user.Code; billTransaction.CreateDate = dateTimeNow; billTransaction.ActingBill = actingBill.Id; billTransaction.LocationFrom = plannedBill.LocationFrom; billTransaction.PartyFrom = plannedBill.PartyFrom; billTransaction.IpNo = plannedBill.IpNo; billTransaction.ReferenceItemCode = plannedBill.ReferenceItemCode; if (locationLotDetail != null) { billTransaction.Location = locationLotDetail.Location.Code; billTransaction.LocationName = locationLotDetail.Location.Name; billTransaction.HuId = locationLotDetail.Hu != null ? locationLotDetail.Hu.HuId : string.Empty; billTransaction.LotNo = locationLotDetail.LotNo; billTransaction.BatchNo = locationLotDetail.Id; } this.CreateBillTransaction(billTransaction); #endregion }
public static InventoryTransaction CreateInventoryTransaction(LocationLotDetail locationLotDetail, decimal qty, bool isBillSettled) { InventoryTransaction inventoryTransaction = new InventoryTransaction(); inventoryTransaction.LocationLotDetailId = locationLotDetail.Id; inventoryTransaction.Location = locationLotDetail.Location; inventoryTransaction.StorageBin = locationLotDetail.StorageBin; inventoryTransaction.Item = locationLotDetail.Item; inventoryTransaction.Hu = locationLotDetail.Hu; inventoryTransaction.LotNo = locationLotDetail.LotNo; if (!isBillSettled && locationLotDetail.IsConsignment) { inventoryTransaction.IsConsignment = locationLotDetail.IsConsignment; inventoryTransaction.PlannedBill = locationLotDetail.PlannedBill; } else { inventoryTransaction.IsConsignment = false; } inventoryTransaction.Qty = qty; return inventoryTransaction; }
public static InventoryTransaction CreateInventoryTransaction(LocationLotDetail locationLotDetail, decimal qty, bool isBillSettled) { InventoryTransaction inventoryTransaction = new InventoryTransaction(); inventoryTransaction.LocationLotDetailId = locationLotDetail.Id; inventoryTransaction.Location = locationLotDetail.Location; inventoryTransaction.StorageBin = locationLotDetail.StorageBin; inventoryTransaction.Item = locationLotDetail.Item; inventoryTransaction.Hu = locationLotDetail.Hu; inventoryTransaction.LotNo = locationLotDetail.LotNo; inventoryTransaction.RefLocation = locationLotDetail.RefLocation; if (!isBillSettled && locationLotDetail.IsConsignment) { inventoryTransaction.IsConsignment = locationLotDetail.IsConsignment; inventoryTransaction.PlannedBill = locationLotDetail.PlannedBill; } else { inventoryTransaction.IsConsignment = false; } inventoryTransaction.Qty = qty; return(inventoryTransaction); }
public static TransformerDetail ConvertLocationLotDetailToTransformerDetail(LocationLotDetail locationLotDetail, bool isPutAway) { TransformerDetail transformerDetail = new TransformerDetail(); transformerDetail.Id = locationLotDetail.Id; transformerDetail.LocationLotDetId = locationLotDetail.Id; transformerDetail.ItemCode = locationLotDetail.Item.Code; transformerDetail.ItemDescription = locationLotDetail.Item.Description; if (locationLotDetail.Hu != null) { transformerDetail.UomCode = locationLotDetail.Hu.Uom.Code; transformerDetail.UnitCount = locationLotDetail.Hu.UnitCount; transformerDetail.Qty = locationLotDetail.Qty / locationLotDetail.Hu.UnitQty; transformerDetail.CurrentQty = locationLotDetail.Qty / locationLotDetail.Hu.UnitQty; } else { transformerDetail.UomCode = locationLotDetail.Item.Uom.Code; transformerDetail.UnitCount = locationLotDetail.Item.UnitCount; transformerDetail.Qty = locationLotDetail.Qty; transformerDetail.CurrentQty = locationLotDetail.Qty; } transformerDetail.HuId = locationLotDetail.Hu.HuId; transformerDetail.LotNo = locationLotDetail.Hu.LotNo; transformerDetail.LocationCode = locationLotDetail.Location.Code; if (isPutAway) { transformerDetail.StorageBinCode = locationLotDetail.NewStorageBin != null ? locationLotDetail.NewStorageBin.Code : null; } else { transformerDetail.StorageBinCode = locationLotDetail.StorageBin != null ? locationLotDetail.StorageBin.Code : null; } return(transformerDetail); }
private void HuScan(Hu hu) { bool isMatch = false; #region Hu拣货 if (this.PickBy == BusinessConstants.CODE_MASTER_PICKBY_HU) { foreach (GridViewRow row in GV_List.Rows) { Label lblOrderQty = (Label)row.FindControl("lblOrderQty"); TextBox tbShipQty = (TextBox)row.FindControl("tbShipQty"); Label lblHuId = (Label)row.FindControl("lblHuId"); Label lblLoc = (Label)row.FindControl("lblLoc"); Label lblStorageBin = (Label)row.FindControl("lblStorageBin"); HiddenField hfId = (HiddenField)row.FindControl("hfId"); Hu_HuInput ucHuInput = (Hu_HuInput)row.FindControl("ucHuInput"); if (ucHuInput.CheckExist(hu.HuId)) { this.lblMessage.Text = Resources.Language.MasterDataHuExist; break; } if (hu.HuId == lblHuId.Text.Trim()) { IList <LocationLotDetail> locationLotDetList = TheLocationLotDetailMgr.GetHuLocationLotDetail(hu.HuId); if (locationLotDetList != null && locationLotDetList.Count > 0) { LocationLotDetail locLotDet = locationLotDetList[0]; if (locLotDet.Location.Code == lblLoc.Text.Trim() && (locLotDet.StorageBin == null || locLotDet.StorageBin.Code.ToUpper() == lblStorageBin.Text.Trim().ToUpper())) { decimal orderQty = lblOrderQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(lblOrderQty.Text.Trim()); decimal shipQty = tbShipQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(tbShipQty.Text.Trim()); if (orderQty >= shipQty + hu.Qty) { ucHuInput.HuInput(hu); tbShipQty.Text = ucHuInput.SumQty().ToString("F2"); PickListResult pickListResult = new PickListResult(); pickListResult.LocationLotDetail = locLotDet; pickListResult.PickListDetail = ThePickListDetailMgr.LoadPickListDetail(int.Parse(hfId.Value)); pickListResult.Qty = hu.Qty; isMatch = true; InitialHuScan(); break; } } } } } } #endregion #region LotNo拣货 else if (this.PickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO) { foreach (GridViewRow row in GV_List.Rows) { Label lblOrderQty = (Label)row.FindControl("lblOrderQty"); TextBox tbShipQty = (TextBox)row.FindControl("tbShipQty"); Label lblLotNo = (Label)row.FindControl("lblLotNo"); Label lblItemCode = (Label)row.FindControl("lblItemCode"); Label lblUnitCount = (Label)row.FindControl("lblUnitCount"); Label lblUom = (Label)row.FindControl("lblUom"); Label lblLoc = (Label)row.FindControl("lblLoc"); Label lblStorageBin = (Label)row.FindControl("lblStorageBin"); Hu_HuInput ucHuInput = (Hu_HuInput)row.FindControl("ucHuInput"); HiddenField hfId = (HiddenField)row.FindControl("hfId"); if (ucHuInput.CheckExist(hu.HuId)) { this.lblMessage.Text = Resources.Language.MasterDataHuExist; break; } if (lblLotNo.Text.Trim().ToUpper() == hu.LotNo.ToUpper() && lblItemCode.Text.Trim().ToUpper() == hu.Item.Code.ToUpper() && decimal.Parse(lblUnitCount.Text.Trim()) == hu.UnitCount && lblUom.Text.Trim().ToUpper() == hu.Uom.Code.ToUpper()) { IList <LocationLotDetail> locationLotDetList = TheLocationLotDetailMgr.GetHuLocationLotDetail(hu.HuId); if (locationLotDetList != null && locationLotDetList.Count > 0) { LocationLotDetail locLotDet = locationLotDetList[0]; if (locLotDet.Location.Code == lblLoc.Text.Trim() && (locLotDet.StorageBin == null || locLotDet.StorageBin.Code == lblStorageBin.Text.Trim())) { decimal orderQty = lblOrderQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(lblOrderQty.Text.Trim()); decimal shipQty = tbShipQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(tbShipQty.Text.Trim()); if (orderQty >= shipQty + hu.Qty) { ucHuInput.HuInput(hu); tbShipQty.Text = ucHuInput.SumQty().ToString("F2"); PickListResult pickListResult = new PickListResult(); pickListResult.LocationLotDetail = locLotDet; pickListResult.PickListDetail = ThePickListDetailMgr.LoadPickListDetail(int.Parse(hfId.Value)); pickListResult.Qty = hu.Qty; isMatch = true; InitialHuScan(); break; } } } } } } #endregion if (!isMatch) { this.lblMessage.Text = Resources.Language.MasterDataPickListNotExistHu; this.tbHuScan.Text = string.Empty; this.tbHuScan.Focus(); } }
public ActingBill CreateActingBill(PlannedBill plannedBill, LocationLotDetail locationLotDetail, User user) { PlannedBill oldPlannedBill = plannedBillMgrE.LoadPlannedBill(plannedBill.Id); oldPlannedBill.CurrentActingQty = plannedBill.CurrentActingQty; //检验,已结算数+本次结算数不能大于总结算数量,可能有负数结算,所以要用绝对值比较 if (!oldPlannedBill.ActingQty.HasValue) { oldPlannedBill.ActingQty = 0; } if (Math.Abs(oldPlannedBill.ActingQty.Value + oldPlannedBill.CurrentActingQty) > Math.Abs(oldPlannedBill.PlannedQty)) { throw new BusinessErrorException("PlannedBill.Error.ActingQtyExceed"); } DateTime dateTimeNow = DateTime.Now; ActingBill actingBill = this.RetriveActingBill(oldPlannedBill, dateTimeNow, user); #region 计算结算金额 decimal currentBillAmount = 0; if (Math.Abs(oldPlannedBill.ActingQty.Value + oldPlannedBill.CurrentActingQty) < Math.Abs(oldPlannedBill.PlannedQty)) { //总结算数小于计划数,用实际单价计算待开票金额 #region 计算实际单价 EntityPreference entityPreference = entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH); int decimalLength = int.Parse(entityPreference.Value); decimal actualUnitPrice = Math.Round((oldPlannedBill.PlannedAmount / oldPlannedBill.PlannedQty), decimalLength, MidpointRounding.AwayFromZero); #endregion currentBillAmount = actualUnitPrice * oldPlannedBill.CurrentActingQty; } else { //总结算数等于计划数,先用剩余金额作为待开票金额 if (!oldPlannedBill.ActingAmount.HasValue) { oldPlannedBill.ActingAmount = 0; } currentBillAmount = oldPlannedBill.PlannedAmount - oldPlannedBill.ActingAmount.Value; } actingBill.BillAmount += currentBillAmount; #endregion #region 更新Planed Bill的已结算数量和金额 if (!oldPlannedBill.ActingQty.HasValue) { oldPlannedBill.ActingQty = 0; } oldPlannedBill.ActingQty += oldPlannedBill.CurrentActingQty; if (!oldPlannedBill.ActingAmount.HasValue) { oldPlannedBill.ActingAmount = 0; } oldPlannedBill.ActingAmount += currentBillAmount; oldPlannedBill.LastModifyDate = dateTimeNow; oldPlannedBill.LastModifyUser = user; this.plannedBillMgrE.UpdatePlannedBill(oldPlannedBill); #endregion if (actingBill.Id == 0) { actingBillMgrE.CreateActingBill(actingBill); } else { actingBillMgrE.UpdateActingBill(actingBill); } #region 记BillTransaction billTransactionMgrE.RecordBillTransaction(plannedBill, actingBill, locationLotDetail, user); #endregion return actingBill; }
protected override void SetDetail(Resolver resolver) { #region Hu状态查询 if (resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_HUSTATUS) { Hu hu = null; //检查库存 LocationLotDetail locationLotDetail = locationLotDetailMgr.LoadHuLocationLotDetail(resolver.Input); if (locationLotDetail == null)//库存中没有,检查HuDet { hu = huMgr.CheckAndLoadHu(resolver.Input); //修正状态 if (hu.Status == BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_INVENTORY) { hu.Status = "ERROR"; } } else { hu = locationLotDetail.Hu; //修正库位 数量 hu.Location = locationLotDetail.Location.Code; hu.Qty = locationLotDetail.Qty / hu.UnitQty; if (hu.Status == BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_INVENTORY) { if (this.locationMgr.IsHuOcuppyByPickList(resolver.Input)) { hu.Status += languageMgr.TranslateMessage("MasterDate.PickList.Ocuppied", resolver.UserCode); } } } TransformerDetail transformerDetail = TransformerHelper.ConvertHuToTransformerDetail(hu); if (locationLotDetail != null && locationLotDetail.StorageBin != null) { transformerDetail.StorageBinCode = locationLotDetail.StorageBin.Code; } resolver.Transformers = null; resolver.AddTransformerDetail(transformerDetail); } #endregion #region 盘点 else { if (resolver.WorkingHours == null || resolver.WorkingHours.Count != 2) { //出错 throw new BusinessErrorException("CycCnt.Error.ScanCycCountFirst"); } if (resolver.LocationCode == null || resolver.LocationCode == string.Empty) { throw new BusinessErrorException("CycCnt.Error.HasNoLocation"); } //如果指定了库格或启用了高级仓库管理,需要先扫描库格. //if ((resolver.BinCode == null || resolver.BinCode == string.Empty) // && (resolver.WorkingHours[1].Length > 0 || resolver.IsPickFromBin)) //{ // throw new BusinessErrorException("CycCnt.Error.ScanStorageBinFirst"); //} //检查当月盘点重复扫描 this.cycleCountMgr.CheckHuExistThisCount(resolver.Input); Hu hu = huMgr.CheckAndLoadHu(resolver.Input); if (hu.Status == BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CLOSE) { throw new BusinessErrorException("CycCnt.Error.HuStatusError", hu.Status); } if (resolver.WorkingHours[0].Length > 0 && !resolver.WorkingHours[0].Contains(hu.Item.Code)) { if (resolver.WorkingHours[0].Length > 0) { throw new BusinessErrorException("CycCnt.Error.NotContainTheItem"); } else { //nothing todo } } TransformerDetail transformerDetail = Utility.TransformerHelper.ConvertHuToTransformerDetail(hu); transformerDetail.StorageBinCode = resolver.BinCode; resolver.AddTransformerDetail(transformerDetail); } #endregion }
public InventoryTransaction InspectOut(LocationLotDetail locationLotDetail, User user, bool needSettle, string inspectNo, Location locationTo) { LocationLotDetail oldLocationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(locationLotDetail.Id); if (oldLocationLotDetail.Qty < locationLotDetail.CurrentInspectQty) { throw new BusinessErrorException("MasterData.Inventory.Inspect.Error.NotEnoughInventory", locationLotDetail.Item.Code); } #region �¼� if (oldLocationLotDetail.StorageBin != null) { this.InventoryPick(oldLocationLotDetail, user); } #endregion #region ���� oldLocationLotDetail.Qty -= locationLotDetail.CurrentInspectQty; this.locationLotDetailMgr.UpdateLocationLotDetail(oldLocationLotDetail); #endregion //������� if (needSettle && locationLotDetail.IsConsignment && locationLotDetail.PlannedBill.HasValue) { PlannedBill plannedBill = this.plannedBillMgr.LoadPlannedBill(locationLotDetail.PlannedBill.Value); if (plannedBill.SettleTerm == BusinessConstants.CODE_MASTER_BILL_SETTLE_TERM_VALUE_INSPECTION) { plannedBill.CurrentActingQty = locationLotDetail.CurrentInspectQty/plannedBill.UnitQty; this.billMgr.CreateActingBill(plannedBill, locationLotDetail, user); } } #region ��¼�������� InventoryTransaction inventoryOutTransaction = InventoryTransactionHelper.CreateInventoryTransaction(oldLocationLotDetail, 0 - locationLotDetail.CurrentInspectQty, false); this.locationTransactionMgr.RecordLocationTransaction(inventoryOutTransaction, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_INP, user, inspectNo, locationTo); #endregion return inventoryOutTransaction; }
public IList<InventoryTransaction> InspectIn(LocationLotDetail locationLotDetail, Location locIn, User user, bool needSettle, string inspectNo, string inrNo, int? inspectDetailId) { return InspectIn(locationLotDetail, locIn, null, user, needSettle, inspectNo, inrNo,inspectDetailId); }
public void InventoryPut(LocationLotDetail locationLotDetail, User user) { LocationLotDetail oldLocationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(locationLotDetail.Id); #region �����ϼܿ�� if (oldLocationLotDetail.StorageBin != null) { if (locationLotDetail.NewStorageBin != null && oldLocationLotDetail.StorageBin.Code == locationLotDetail.NewStorageBin.Code) { throw new BusinessErrorException("Location.Error.PutAway.AlreadyInBin", oldLocationLotDetail.Hu.HuId, oldLocationLotDetail.StorageBin.Code); } //�����¼� this.InventoryPick(oldLocationLotDetail, user); } if (locationLotDetail.NewStorageBin == null) { throw new BusinessErrorException("Location.Error.PutAway.BinEmpty"); } if (locationLotDetail.NewStorageBin.Area.Location.Code != oldLocationLotDetail.Location.Code) { throw new BusinessErrorException("Location.Error.PutAway.BinNotInLocation", locationLotDetail.NewStorageBin.Code, oldLocationLotDetail.Location.Code); } #endregion #region ��¼�������� InventoryTransaction inventoryOutTransaction = InventoryTransactionHelper.CreateInventoryTransaction(oldLocationLotDetail, 0 - oldLocationLotDetail.Qty, false); this.locationTransactionMgr.RecordLocationTransaction(inventoryOutTransaction, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_PUT, user); #endregion #region �ϼ� oldLocationLotDetail.StorageBin = locationLotDetail.NewStorageBin; this.locationLotDetailMgr.UpdateLocationLotDetail(oldLocationLotDetail); #endregion #region ��¼������� InventoryTransaction inventoryInTransaction = InventoryTransactionHelper.CreateInventoryTransaction(oldLocationLotDetail, oldLocationLotDetail.Qty, false); this.locationTransactionMgr.RecordLocationTransaction(inventoryInTransaction, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_PUT, user); #endregion #region ����Hu��λ Hu hu = this.huMgr.LoadHu(oldLocationLotDetail.Hu.HuId); hu.StorageBin = locationLotDetail.NewStorageBin.Code; this.huMgr.UpdateHu(hu); #endregion }
public static TransformerDetail ConvertLocationLotDetailToTransformerDetail(LocationLotDetail locationLotDetail, bool isPutAway) { TransformerDetail transformerDetail = new TransformerDetail(); transformerDetail.Id = locationLotDetail.Id; transformerDetail.LocationLotDetId = locationLotDetail.Id; transformerDetail.ItemCode = locationLotDetail.Item.Code; transformerDetail.ItemDescription = locationLotDetail.Item.Description; if (locationLotDetail.Hu != null) { transformerDetail.UomCode = locationLotDetail.Hu.Uom.Code; transformerDetail.UnitCount = locationLotDetail.Hu.UnitCount; transformerDetail.Qty = locationLotDetail.Qty / locationLotDetail.Hu.UnitQty; transformerDetail.CurrentQty = locationLotDetail.Qty / locationLotDetail.Hu.UnitQty; } else { transformerDetail.UomCode = locationLotDetail.Item.Uom.Code; transformerDetail.UnitCount = locationLotDetail.Item.UnitCount; transformerDetail.Qty = locationLotDetail.Qty; transformerDetail.CurrentQty = locationLotDetail.Qty; } transformerDetail.HuId = locationLotDetail.Hu.HuId; transformerDetail.LotNo = locationLotDetail.Hu.LotNo; transformerDetail.LocationCode = locationLotDetail.Location.Code; if (isPutAway) transformerDetail.StorageBinCode = locationLotDetail.NewStorageBin != null ? locationLotDetail.NewStorageBin.Code : null; else transformerDetail.StorageBinCode = locationLotDetail.StorageBin != null ? locationLotDetail.StorageBin.Code : null; return transformerDetail; }
public virtual void CreateLocationLotDetail(LocationLotDetail entity) { entityDao.CreateLocationLotDetail(entity); }
public virtual void UpdateLocationLotDetail(LocationLotDetail entity) { entityDao.UpdateLocationLotDetail(entity); }
IList <LocationLotDetail> Convert2OccupiedLocationLotDetail(IList <PickListDetail> pickListDetailList, string pickBy) { IList <LocationLotDetail> locationLotDetailList = new List <LocationLotDetail>(); #region 转换PickListDetail至LocationLotDetail if (pickListDetailList != null && pickListDetailList.Count > 0) { foreach (PickListDetail pickListDetail in pickListDetailList) { if (pickBy == BusinessConstants.CODE_MASTER_PICKBY_HU) { if (pickListDetail.HuId != null && pickListDetail.HuId.Trim() != string.Empty) { LocationLotDetail newLocationLotDetail = new LocationLotDetail(); newLocationLotDetail.Location = pickListDetail.Location; newLocationLotDetail.StorageBin = pickListDetail.StorageBin; newLocationLotDetail.Item = pickListDetail.Item; newLocationLotDetail.Hu = new Hu(); newLocationLotDetail.Hu.HuId = pickListDetail.HuId; newLocationLotDetail.LotNo = pickListDetail.LotNo; newLocationLotDetail.Qty = pickListDetail.Qty * pickListDetail.OrderLocationTransaction.UnitQty; //库存单位 locationLotDetailList.Add(newLocationLotDetail); } } else if (pickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO) { bool matchLocationLotDetail = false; foreach (LocationLotDetail locationLotDetail in locationLotDetailList) { if (locationLotDetail.Item.Code == pickListDetail.Item.Code && locationLotDetail.LotNo == pickListDetail.LotNo && locationLotDetail.Location.Code == pickListDetail.Location.Code && StorageBinHelper.IsStorageBinEqual(locationLotDetail.StorageBin, pickListDetail.StorageBin)) { locationLotDetail.Qty += pickListDetail.Qty * pickListDetail.OrderLocationTransaction.UnitQty; //库存单位 matchLocationLotDetail = true; break; } } if (!matchLocationLotDetail) { LocationLotDetail newLocationLotDetail = new LocationLotDetail(); newLocationLotDetail.Location = pickListDetail.Location; newLocationLotDetail.StorageBin = pickListDetail.StorageBin; newLocationLotDetail.Item = pickListDetail.Item; newLocationLotDetail.LotNo = pickListDetail.LotNo; newLocationLotDetail.Qty = pickListDetail.Qty * pickListDetail.OrderLocationTransaction.UnitQty; //库存单位 locationLotDetailList.Add(newLocationLotDetail); } } else { throw new TechnicalException("invalided pick by:" + pickBy); } } } #endregion return(locationLotDetailList); }
public PickList CreatePickList(IList <OrderLocationTransaction> orderLocationTransactionList, User user) { List <OrderLocationTransaction> targetOrderLocationTransactionList = new List <OrderLocationTransaction>(); OrderLocationTransactionComparer orderLocationTransactionComparer = new OrderLocationTransactionComparer(); if (orderLocationTransactionList != null && orderLocationTransactionList.Count > 0) { foreach (OrderLocationTransaction orderLocationTransaction in orderLocationTransactionList) { if (orderLocationTransaction.CurrentShipQty > 0) { targetOrderLocationTransactionList.Add(orderLocationTransaction); } } } if (targetOrderLocationTransactionList.Count == 0) { throw new BusinessErrorException("Order.Error.PickUp.DetailEmpty"); } else { //按FromLocation、零件号、单位、单包装排序 targetOrderLocationTransactionList.Sort(orderLocationTransactionComparer); } string orderType = null; Party partyFrom = null; Party partyTo = null; ShipAddress shipFrom = null; ShipAddress shipTo = null; string dockDescription = null; bool? isShipScanHu = null; bool? isReceiptScanHu = null; bool? isAutoReceive = null; decimal? completeLatency = null; string grGapTo = null; string asnTemplate = null; string receiptTemplate = null; string flow = null; DateTime? windowTime = null; bool? isAsnUniqueReceipt = null; #region 判断OrderHead的PartyFrom, PartyTo, ShipFrom, ShipTo, DockDescription是否一致 foreach (OrderLocationTransaction orderLocationTransaction in targetOrderLocationTransactionList) { OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; //判断OrderHead的Type是否一致 if (orderType == null) { orderType = orderHead.Type; } else if (orderHead.Type != orderType) { throw new BusinessErrorException("Order.Error.PickUp.OrderTypeNotEqual"); } //判断OrderHead的PartyFrom是否一致 if (partyFrom == null) { partyFrom = orderHead.PartyFrom; } else if (orderHead.PartyFrom.Code != partyFrom.Code) { throw new BusinessErrorException("Order.Error.PickUp.PartyFromNotEqual"); } //判断OrderHead的PartyFrom是否一致 if (partyTo == null) { partyTo = orderHead.PartyTo; } else if (orderHead.PartyTo.Code != partyTo.Code) { throw new BusinessErrorException("Order.Error.PickUp.PartyToNotEqual"); } //判断OrderHead的ShipFrom是否一致 if (shipFrom == null) { shipFrom = orderHead.ShipFrom; } else if (!AddressHelper.IsAddressEqual(orderHead.ShipFrom, shipFrom)) { throw new BusinessErrorException("Order.Error.PickUp.ShipFromNotEqual"); } //判断OrderHead的ShipTo是否一致 if (shipTo == null) { shipTo = orderHead.ShipTo; } else if (!AddressHelper.IsAddressEqual(orderHead.ShipTo, shipTo)) { throw new BusinessErrorException("Order.Error.PickUp.ShipToNotEqual"); } //判断OrderHead的DockDescription是否一致 if (dockDescription == null) { dockDescription = orderHead.DockDescription; } else if (orderHead.DockDescription != dockDescription) { throw new BusinessErrorException("Order.Error.PickUp.DockDescriptionNotEqual"); } //判断OrderHead的IsShipScanHu是否一致 if (isShipScanHu == null) { isShipScanHu = orderHead.IsShipScanHu; } else if (orderHead.IsShipScanHu != isShipScanHu) { throw new BusinessErrorException("Order.Error.PickUp.IsShipScanHuNotEqual"); } //判断OrderHead的IsReceiptScanHu是否一致 if (isReceiptScanHu == null) { isReceiptScanHu = orderHead.IsReceiptScanHu; } else if (orderHead.IsReceiptScanHu != isReceiptScanHu) { throw new BusinessErrorException("Order.Error.PickUp.IsReceiptScanHuNotEqual"); } //判断OrderHead的IsAutoReceipt是否一致 if (isAutoReceive == null) { isAutoReceive = orderHead.IsAutoReceive; } else if (orderHead.IsAutoReceive != isAutoReceive) { throw new BusinessErrorException("Order.Error.PickUp.IsAutoReceiveNotEqual"); } //判断OrderHead的CompleteLatency是否一致 if (completeLatency == null) { completeLatency = orderHead.CompleteLatency; } else { if (orderHead.CompleteLatency.HasValue && orderHead.CompleteLatency != completeLatency) { throw new BusinessErrorException("Order.Error.PickUp.CompleteLatencyNotEqual"); } } //判断OrderHead的GoodsReceiptGapTo是否一致 if (grGapTo == null) { grGapTo = orderHead.GoodsReceiptGapTo; } else { if (orderHead.GoodsReceiptGapTo != null && orderHead.GoodsReceiptGapTo != grGapTo) { throw new BusinessErrorException("Order.Error.PickUp.GoodsReceiptGapToNotEqual"); } } //判断OrderHead的AsnTemplate是否一致 if (asnTemplate == null) { asnTemplate = orderHead.AsnTemplate; } else { if (orderHead.AsnTemplate != null && orderHead.AsnTemplate != asnTemplate) { throw new BusinessErrorException("Order.Error.PickUp.AsnTemplateNotEqual"); } } //判断OrderHead的ReceiptTemplate是否一致 if (receiptTemplate == null) { receiptTemplate = orderHead.ReceiptTemplate; } else { if (orderHead.ReceiptTemplate != null && orderHead.ReceiptTemplate != receiptTemplate) { throw new BusinessErrorException("Order.Error.PickUp.ReceiptTemplateNotEqual"); } } //判断OrderHead的Flow是否一致 if (flow == null) { flow = orderHead.Flow; } else if (orderHead.Flow != flow) { //throw new BusinessErrorException("Order.Error.PickUp.FlowNotEqual"); } //寻找最小的WindowTime if (!windowTime.HasValue) { windowTime = orderHead.WindowTime; } else if (windowTime.Value > orderHead.WindowTime) { windowTime = orderHead.WindowTime; } //判断OrderHead的IsAsnUniqueReceipt是否一致 if (isAsnUniqueReceipt == null) { isAsnUniqueReceipt = orderHead.IsAsnUniqueReceipt; } else if (orderHead.IsAsnUniqueReceipt != isAsnUniqueReceipt) { throw new BusinessErrorException("Order.Error.PickUp.IsAsnUniqueReceiptNotEqual"); } } #endregion #region 创建捡货单头 DateTime dateTimeNow = DateTime.Now; PickList pickList = new PickList(); pickList.PickListNo = numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_PICKLIST); pickList.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT; pickList.PickBy = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_PICK_BY).Value; pickList.OrderType = orderType; pickList.PartyFrom = partyFrom; pickList.PartyTo = partyTo; pickList.ShipFrom = shipFrom; pickList.ShipTo = shipTo; pickList.DockDescription = dockDescription; pickList.CreateDate = dateTimeNow; pickList.CreateUser = user; pickList.LastModifyDate = dateTimeNow; pickList.LastModifyUser = user; pickList.IsShipScanHu = isShipScanHu.Value; pickList.IsReceiptScanHu = isReceiptScanHu.Value; pickList.IsAutoReceive = isAutoReceive.Value; pickList.CompleteLatency = completeLatency; pickList.GoodsReceiptGapTo = grGapTo; pickList.AsnTemplate = asnTemplate; pickList.ReceiptTemplate = receiptTemplate; pickList.Flow = flow; pickList.WindowTime = windowTime.Value; pickList.IsAsnUniqueReceipt = isAsnUniqueReceipt.Value; this.CreatePickList(pickList); #endregion #region 创建捡货单明细 int index = 0; IList <LocationLotDetail> locationLotDetailList = null; IList <LocationLotDetail> occupiedLocationLotDetailList = null; //捡货占用库存 for (int i = 0; i < targetOrderLocationTransactionList.Count; i++) { OrderLocationTransaction orderLocationTransaction = targetOrderLocationTransactionList[i]; //本次循环OrderLocationTransaction OrderLocationTransaction lastOrderLocationTransaction = i == 0 ? null : targetOrderLocationTransactionList[i - 1]; //上次OrderLocationTransaction List <PickListDetail> pickListDetailList = new List <PickListDetail>(); //本次生成的PickListDetail列表 OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; decimal shipQty = orderLocationTransaction.CurrentShipQty; //库存单位 #region 过量拣货判断 decimal pickedQty = 0; //其它拣货单的待拣货数量,只考虑Submit和InProcess状态 IList <PickListDetail> pickedPickListDetailList = this.pickListDetailMgr.GetPickedPickListDetail(orderLocationTransaction.Id); if (pickedPickListDetailList != null && pickedPickListDetailList.Count > 0) { foreach (PickListDetail pickListDetail in pickedPickListDetailList) { if (pickListDetail.PickList.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT || pickListDetail.PickList.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS) { pickedQty += pickListDetail.Qty; } } } //累计发货数量 + 待捡货数量 + 本次拣货数量 不能大于 订单数量 if ((orderLocationTransaction.AccumulateQty.HasValue ? orderLocationTransaction.AccumulateQty.Value : 0) + shipQty + pickedQty > orderLocationTransaction.OrderedQty) { throw new BusinessErrorException("MasterData.PickList.Error.PickExcceed", orderLocationTransaction.Item.Code); } #endregion //比较本次OrderLocationTransaction和上次OrderLocationTransaction,如果不相同需重新查找locationLotDetailList和重置index //为了处理订单合并捡货时,相同零件推荐的Hu/LotNo不重复问题 if (lastOrderLocationTransaction == null || orderLocationTransactionComparer.Compare(lastOrderLocationTransaction, orderLocationTransaction) == -1) { index = 0; #region 零头发货选项查询待拣货列表 string oddShipOption = orderDetail.OddShipOption; if (oddShipOption == null || oddShipOption.Trim() == string.Empty) { CodeMaster codeMaster = this.codeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION); oddShipOption = codeMaster.Value; } if (oddShipOption == BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION_VALUE_SHIP_FIRST) { //零头优先发、LotnNo先进先出、货架、包装 if (orderHead.IsPickFromBin) { locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, null, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "sb.Sequence;Asc", "Qty;Asc", "Id;Asc" }, orderHead.IsPickFromBin, true, null, null, true); } else { locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, null, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "Qty;Asc", "Id;Asc" }, orderHead.IsPickFromBin, false, null, null, true); } #region 重新排序,把零头放在前面 if (locationLotDetailList != null && locationLotDetailList.Count > 0) { IList <LocationLotDetail> oddLocationLotDetailList = new List <LocationLotDetail>(); IList <LocationLotDetail> noOddLocationLotDetailList = new List <LocationLotDetail>(); foreach (LocationLotDetail locationLotDetail in locationLotDetailList) { if (!this.locationMgr.IsHuOcuppyByPickList(locationLotDetail.Hu.HuId)) { if (locationLotDetail.Hu.Qty < orderDetail.UnitCount) { oddLocationLotDetailList.Add(locationLotDetail); shipQty += locationLotDetail.Qty; //零头一定要先发走,不占用待拣货数量 } else { noOddLocationLotDetailList.Add(locationLotDetail); } } } locationLotDetailList = oddLocationLotDetailList; IListHelper.AddRange <LocationLotDetail>(locationLotDetailList, noOddLocationLotDetailList); } #endregion } else if (oddShipOption == BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION_VALUE_NOT_SHIP) { //零头不发 if (orderHead.IsPickFromBin) { locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "sb.Sequence;Asc", "Id;Asc" }, orderHead.IsPickFromBin, true); } else { locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "Id;Asc" }, orderHead.IsPickFromBin, false); } } #endregion IList <PickListDetail> submitPickListDetailList = this.pickListDetailMgr.GetPickListDetail(orderLocationTransaction.Location.Code, orderDetail.Item.Code, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT, BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS }); //IList<PickListResult> inprocessPickListResultList = this.pickListResultMgr.GetPickListResult(orderLocationTransaction.Location.Code, orderDetail.Item.Code, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS }); occupiedLocationLotDetailList = this.Convert2OccupiedLocationLotDetail(submitPickListDetailList, pickList.PickBy); } if (locationLotDetailList != null && locationLotDetailList.Count > 0) { PickListDetail lastestPickListDetail = null; for (; index < locationLotDetailList.Count; index++) { LocationLotDetail locationLotDetail = locationLotDetailList[index]; decimal locQty = locationLotDetail.Qty; if (pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_HU) { #region Hu捡货 #region 过滤掉已经被推荐的库存 if (occupiedLocationLotDetailList != null && occupiedLocationLotDetailList.Count > 0) { bool findMatch = false; foreach (LocationLotDetail occupiedLocationLotDetail in occupiedLocationLotDetailList) { if (occupiedLocationLotDetail.Hu.HuId == locationLotDetail.Hu.HuId) { findMatch = true; continue; } } if (findMatch) { continue; } } #endregion shipQty -= locQty; PickListDetail pickListDetail = new PickListDetail(); pickListDetail.PickList = pickList; pickListDetail.OrderLocationTransaction = orderLocationTransaction; pickListDetail.Item = orderLocationTransaction.Item; pickListDetail.UnitCount = orderDetail.UnitCount; pickListDetail.Uom = orderDetail.Uom; pickListDetail.HuId = locationLotDetail.Hu.HuId; pickListDetail.LotNo = locationLotDetail.LotNo; pickListDetail.Location = locationLotDetail.Location; if (locationLotDetail.StorageBin != null) { pickListDetail.StorageArea = locationLotDetail.StorageBin.Area; pickListDetail.StorageBin = locationLotDetail.StorageBin; } pickListDetail.Qty = locQty / orderLocationTransaction.UnitQty; //订单单位 this.pickListDetailMgr.CreatePickListDetail(pickListDetail); pickList.AddPickListDetail(pickListDetail); pickListDetailList.Add(pickListDetail); if (shipQty <= 0) { index++; break; } #endregion } else if (pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO) { #region LotNo捡货 #region 过滤掉已经被推荐的库存 if (occupiedLocationLotDetailList != null && occupiedLocationLotDetailList.Count > 0) { foreach (LocationLotDetail occupiedLocationLotDetail in occupiedLocationLotDetailList) { if (occupiedLocationLotDetail.Item.Code == locationLotDetail.Item.Code && occupiedLocationLotDetail.LotNo == locationLotDetail.LotNo && occupiedLocationLotDetail.Location.Code == locationLotDetail.Location.Code && StorageBinHelper.IsStorageBinEqual(occupiedLocationLotDetail.StorageBin, locationLotDetail.StorageBin)) { if (locationLotDetail.Hu.Qty < orderDetail.UnitCount) { shipQty -= locationLotDetail.Qty; //如果零头被占用,需要扣减发货数量 } if (occupiedLocationLotDetail.Qty == 0) { continue; } if (occupiedLocationLotDetail.Qty - locQty >= 0) { occupiedLocationLotDetail.Qty -= locQty; locQty = 0; continue; } else { occupiedLocationLotDetail.Qty = 0; locQty -= occupiedLocationLotDetail.Qty; break; } } } if (locQty == 0) { continue; } } #endregion shipQty -= locQty; if (shipQty < 0) { locQty += shipQty; shipQty = 0; } if (lastestPickListDetail != null && lastestPickListDetail.LotNo == locationLotDetail.LotNo && StorageBinHelper.IsStorageBinEqual(lastestPickListDetail.StorageBin, locationLotDetail.StorageBin)) { #region 合并捡货数量 lastestPickListDetail.Qty += locQty / orderLocationTransaction.UnitQty; //订单单位 this.pickListDetailMgr.UpdatePickListDetail(lastestPickListDetail); #endregion } else { #region 新增捡货明细 lastestPickListDetail = new PickListDetail(); lastestPickListDetail.PickList = pickList; lastestPickListDetail.OrderLocationTransaction = orderLocationTransaction; lastestPickListDetail.Item = orderLocationTransaction.Item; lastestPickListDetail.UnitCount = locationLotDetail.Hu.UnitCount; //可能拣货的包装和订单明细包装不一致,所以使用Hu上的单包装 lastestPickListDetail.Uom = orderDetail.Uom; lastestPickListDetail.LotNo = locationLotDetail.Hu.LotNo; lastestPickListDetail.Location = locationLotDetail.Location; if (locationLotDetail.StorageBin != null) { lastestPickListDetail.StorageArea = locationLotDetail.StorageBin.Area; lastestPickListDetail.StorageBin = locationLotDetail.StorageBin; } lastestPickListDetail.Qty = locQty / orderLocationTransaction.UnitQty; //订单单位 this.pickListDetailMgr.CreatePickListDetail(lastestPickListDetail); pickList.AddPickListDetail(lastestPickListDetail); pickListDetailList.Add(lastestPickListDetail); #endregion } if (shipQty <= 0) { index++; break; } #endregion } else { throw new TechnicalException("Invalied PickBy value:" + pickList.PickBy); } } } //if (pickListDetailList.Count == 0) //{ // throw new BusinessErrorException("MasterData.PickList.Error.NotEnoughInventory"); //} if (shipQty > 0) { PickListDetail pickListDetail = new PickListDetail(); pickListDetail.PickList = pickList; pickListDetail.OrderLocationTransaction = orderLocationTransaction; pickListDetail.Item = orderLocationTransaction.Item; pickListDetail.UnitCount = orderDetail.UnitCount; pickListDetail.Uom = orderDetail.Uom; pickListDetail.Location = orderLocationTransaction.Location; pickListDetail.Qty = shipQty / orderLocationTransaction.UnitQty; //订单单位 pickListDetail.Memo = this.languageMgr.TranslateMessage("MasterData.PickList.NotEnoughInventory", user); //设置Memo为库存不足 pickList.AddPickListDetail(pickListDetail); this.pickListDetailMgr.CreatePickListDetail(pickListDetail); } if (pickListDetailList.Count > 0 && pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO) { string lotNo = string.Empty; bool hasMultiLotNo = false; foreach (PickListDetail pickListDetail in pickListDetailList) { if (lotNo == string.Empty) { lotNo = pickListDetail.LotNo; } else if (lotNo != pickListDetail.LotNo) { hasMultiLotNo = true; break; } } //设置Memo为多批号 if (hasMultiLotNo) { foreach (PickListDetail pickListDetail in pickListDetailList) { if (pickListDetail.Memo == null || pickListDetail.Memo.Trim() == string.Empty) { pickListDetail.Memo = this.languageMgr.TranslateMessage("MasterData.PickList.MultiLotNo", user); } else { pickListDetail.Memo += "; " + this.languageMgr.TranslateMessage("MasterData.PickList.MultiLotNo", user); } this.pickListDetailMgr.UpdatePickListDetail(pickListDetail); } } } } #endregion //if (pickList.PickListDetails == null || pickList.PickListDetails.Count == 0) //{ // throw new BusinessErrorException("MasterData.PickList.Error.NotEnoughInventory"); //} return(pickList); }
public ActingBill ManualCreateActingBill(PlannedBill plannedBill, LocationLotDetail locationLotDetail, User user) { IList<LocationLotDetail> locationLotDetailList = this.locationLotDetailMgrE.GetLocationLotDetail(plannedBill); if (locationLotDetailList != null && locationLotDetailList.Count > 0) { decimal actingQty = plannedBill.CurrentActingQty; foreach (LocationLotDetail currentLocationLotDetail in locationLotDetailList) { if (actingQty > 0) { #region 更新库存寄售标记 if (actingQty - currentLocationLotDetail.Qty >= 0) { actingQty -= currentLocationLotDetail.Qty; currentLocationLotDetail.IsConsignment = false; currentLocationLotDetail.PlannedBill = null; } else { //不支持同一库存记录进行部分结算 throw new BusinessErrorException("Location.Error.PlannedBill.CantSplitInventory"); } this.locationLotDetailMgrE.UpdateLocationLotDetail(currentLocationLotDetail); #endregion } else { break; } } } #region 创建ActBill ActingBill actingBill = this.CreateActingBill(plannedBill, locationLotDetail, user); #endregion return actingBill; }
public ActingBill CreateActingBill(PlannedBill plannedBill, LocationLotDetail locationLotDetail, User user) { PlannedBill oldPlannedBill = plannedBillMgr.LoadPlannedBill(plannedBill.Id); oldPlannedBill.CurrentActingQty = plannedBill.CurrentActingQty; //检验,已结算数+本次结算数不能大于总结算数量,可能有负数结算,所以要用绝对值比较 if (!oldPlannedBill.ActingQty.HasValue) { oldPlannedBill.ActingQty = 0; } if (Math.Abs(oldPlannedBill.ActingQty.Value + oldPlannedBill.CurrentActingQty) > Math.Abs(oldPlannedBill.PlannedQty)) { throw new BusinessErrorException("PlannedBill.Error.ActingQtyExceed"); } DateTime dateTimeNow = DateTime.Now; ActingBill actingBill = this.RetriveActingBill(oldPlannedBill, dateTimeNow, user); #region 计算结算金额 decimal currentBillAmount = 0; if (Math.Abs(oldPlannedBill.ActingQty.Value + oldPlannedBill.CurrentActingQty) < Math.Abs(oldPlannedBill.PlannedQty)) { //总结算数小于计划数,用实际单价计算待开票金额 #region 计算实际单价 EntityPreference entityPreference = entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH); int decimalLength = int.Parse(entityPreference.Value); decimal actualUnitPrice = Math.Round((oldPlannedBill.PlannedAmount / oldPlannedBill.PlannedQty), decimalLength, MidpointRounding.AwayFromZero); #endregion currentBillAmount = actualUnitPrice * oldPlannedBill.CurrentActingQty; } else { //总结算数等于计划数,先用剩余金额作为待开票金额 if (!oldPlannedBill.ActingAmount.HasValue) { oldPlannedBill.ActingAmount = 0; } currentBillAmount = oldPlannedBill.PlannedAmount - oldPlannedBill.ActingAmount.Value; } actingBill.BillAmount += currentBillAmount; #endregion #region 更新Planed Bill的已结算数量和金额 if (!oldPlannedBill.ActingQty.HasValue) { oldPlannedBill.ActingQty = 0; } oldPlannedBill.ActingQty += oldPlannedBill.CurrentActingQty; if (!oldPlannedBill.ActingAmount.HasValue) { oldPlannedBill.ActingAmount = 0; } oldPlannedBill.ActingAmount += currentBillAmount; oldPlannedBill.LastModifyDate = dateTimeNow; oldPlannedBill.LastModifyUser = user; this.plannedBillMgr.UpdatePlannedBill(oldPlannedBill); #endregion if (actingBill.Id == 0) { actingBillMgr.CreateActingBill(actingBill); } else { actingBillMgr.UpdateActingBill(actingBill); } #region 记BillTransaction billTransactionMgr.RecordBillTransaction(plannedBill, actingBill, locationLotDetail, user); #endregion return(actingBill); }
private void ReceiveRender(object sender, EventArgs e) { bool isOddCreateHu = (bool)sender; IList <ReceiptDetail> receiptDetailList = this.ucDetailList.PopulateReceiptDetailList(); bool isReceiptOneItem = bool.Parse(TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_IS_RECEIPT_ONE_ITEM).Value); if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION && this.ModuleSubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ && isReceiptOneItem && receiptDetailList.Count > 1) { ShowErrorMessage("MasterData.Receipt.One.Item"); return; } IList <OrderLocationTransaction> inLocTransList = new List <OrderLocationTransaction>(); foreach (ReceiptDetail receiptDetail in receiptDetailList) { OrderLocationTransaction ol = receiptDetail.OrderLocationTransaction; ol.CurrentReceiveQty = ol.UnitQty * (receiptDetail.ReceivedQty.HasValue ? (decimal)receiptDetail.ReceivedQty : 0); ol.CurrentRejectQty = ol.UnitQty * (receiptDetail.RejectedQty.HasValue ? (decimal)receiptDetail.RejectedQty : 0); ol.CurrentScrapQty = ol.UnitQty * (receiptDetail.ScrapQty.HasValue ? (decimal)receiptDetail.ScrapQty : 0); inLocTransList.Add(ol); } IList <OrderLocationTransaction> orderLocTransList = this.ucInLocTransList.InLocTransList; //投入原材料List IList <OrderLocationTransaction> outLocTransList = new List <OrderLocationTransaction>(); //非零原材料List IList <OrderLocationTransaction> rwoLocTransList = new List <OrderLocationTransaction>(); //返工成品List foreach (OrderLocationTransaction inLocTrans in this.ucInLocTransList.InLocTransList) { if (inLocTrans.BomDetail == null) { rwoLocTransList.Add(inLocTrans); } else if (inLocTrans.CurrentReceiveQty != 0) { outLocTransList.Add(inLocTrans); } } try { #region 正常生产收货 if (outLocTransList.Count > 0) { foreach (ReceiptDetail receiptDetail in receiptDetailList) { foreach (OrderLocationTransaction orderLocationTransaction in outLocTransList) { MaterialFlushBack materialFlushBack = new MaterialFlushBack(); materialFlushBack.RawMaterial = orderLocationTransaction.Item; materialFlushBack.Uom = orderLocationTransaction.OrderDetail.Uom; materialFlushBack.Operation = orderLocationTransaction.Operation; materialFlushBack.Qty = orderLocationTransaction.CurrentReceiveQty; IList <MaterialFlushBack> materialFlushBackList = TheMaterialFlushBackMgr.AssignMaterialFlushBack(materialFlushBack, inLocTransList); foreach (MaterialFlushBack m in materialFlushBackList) { if (m.OrderLocationTransaction.OrderDetail.Id == receiptDetail.OrderLocationTransaction.OrderDetail.Id) { if (m.OrderLocationTransaction.UnitQty != 0) { m.Qty = m.Qty / m.OrderLocationTransaction.UnitQty; } materialFlushBack = m; receiptDetail.AddMaterialFlushBack(materialFlushBack); break; } } } } } #endregion #region 新品收货 if (this.IsNewItem) { IList <TransformerDetail> transformerDetailList = this.ucNewItemInLocTransList.NewItemInLocTransList; //新品原材料List if (transformerDetailList.Count > 0) { foreach (ReceiptDetail receiptDetail in receiptDetailList) { foreach (TransformerDetail transformerDetail in transformerDetailList) { MaterialFlushBack materialFlushBack = new MaterialFlushBack(); LocationLotDetail newItemLocationLotDetail = TheLocationLotDetailMgr.LoadLocationLotDetail(transformerDetail.LocationLotDetId); materialFlushBack.RawMaterial = newItemLocationLotDetail.Item; materialFlushBack.Uom = newItemLocationLotDetail.Hu.Uom; materialFlushBack.Qty = newItemLocationLotDetail.Qty; materialFlushBack.HuId = newItemLocationLotDetail.Hu.HuId; IList <MaterialFlushBack> materialFlushBackList = TheMaterialFlushBackMgr.AssignMaterialFlushBack(materialFlushBack, inLocTransList); foreach (MaterialFlushBack m in materialFlushBackList) { if (m.OrderLocationTransaction.OrderDetail.Id == receiptDetail.OrderLocationTransaction.OrderDetail.Id) { if (m.OrderLocationTransaction.UnitQty != 0) { m.Qty = m.Qty / m.OrderLocationTransaction.UnitQty; } materialFlushBack = m; receiptDetail.AddMaterialFlushBack(materialFlushBack); break; } } } } } } #endregion #region 返工收货 if (rwoLocTransList.Count > 0) { foreach (OrderLocationTransaction rwoOrderLocTran in rwoLocTransList) { foreach (ReceiptDetail receiptDetail in receiptDetailList) { if (receiptDetail.OrderLocationTransaction.Item.Code == rwoOrderLocTran.Item.Code) { MaterialFlushBack materialFlushBack = new MaterialFlushBack(); materialFlushBack.RawMaterial = rwoOrderLocTran.Item; materialFlushBack.Uom = rwoOrderLocTran.OrderDetail.Uom; materialFlushBack.Operation = rwoOrderLocTran.Operation; materialFlushBack.Qty = rwoOrderLocTran.CurrentReceiveQty; IList <MaterialFlushBack> materialFlushBackList = TheMaterialFlushBackMgr.AssignMaterialFlushBack(materialFlushBack, inLocTransList); foreach (MaterialFlushBack m in materialFlushBackList) { if (m.OrderLocationTransaction.OrderDetail.Id == receiptDetail.OrderLocationTransaction.OrderDetail.Id) { if (m.OrderLocationTransaction.UnitQty != 0) { m.Qty = m.Qty / m.OrderLocationTransaction.UnitQty; } materialFlushBack = m; receiptDetail.AddMaterialFlushBack(materialFlushBack); break; } } } } } } #endregion Receipt receipt = TheOrderMgr.ReceiveOrder(receiptDetailList, this.CurrentUser, null, null, null, true, isOddCreateHu); OrderHead orderHead = TheOrderHeadMgr.LoadOrderHead(this.OrderNo); if (RefreshListEvent != null) { this.RefreshListEvent(new object[] { receipt.ReceiptNo, orderHead.NeedPrintReceipt }, e); } } catch (BusinessErrorException ex) { this.ShowErrorMessage(ex); } }
public void InventoryPick(LocationLotDetail locationLotDetail, User user) { LocationLotDetail oldLocationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(locationLotDetail.Id); #region �����¼ܿ�� if (oldLocationLotDetail.StorageBin == null) { throw new BusinessErrorException("Location.Error.PickUp.NotInBin", oldLocationLotDetail.Hu.HuId); } #endregion #region ��¼�������� InventoryTransaction inventoryOutTransaction = InventoryTransactionHelper.CreateInventoryTransaction(oldLocationLotDetail, 0 - oldLocationLotDetail.Qty, false); this.locationTransactionMgr.RecordLocationTransaction(inventoryOutTransaction, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_PICK, user); #endregion #region �¼� oldLocationLotDetail.StorageBin = null; this.locationLotDetailMgr.UpdateLocationLotDetail(oldLocationLotDetail); #endregion #region ��¼������� InventoryTransaction inventoryInTransaction = InventoryTransactionHelper.CreateInventoryTransaction(oldLocationLotDetail, oldLocationLotDetail.Qty, false); this.locationTransactionMgr.RecordLocationTransaction(inventoryInTransaction, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_PICK, user); #endregion #region ����Hu��λ Hu hu = this.huMgr.LoadHu(oldLocationLotDetail.Hu.HuId); hu.StorageBin = null; this.huMgr.UpdateHu(hu); #endregion }
public virtual void UpdateLocationLotDetail(LocationLotDetail entity) { Update(entity); }
private LocationLotDetail CreateNewLocationLotDetail(Item item, Location location, string huId, string lotNo, decimal qty, bool isCS, PlannedBill plannedBill, IList<InventoryTransaction> inventoryTransactionList, User user, string refLoc) { #region �Ƿ��������� if (!location.AllowNegativeInventory && qty < 0) { throw new BusinessErrorException("Location.Error.NotAllowNegativeInventory", location.Code); } #endregion #region �������&�ɹ���������������� if (item.Type != BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_P && item.Type != BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_M) { throw new BusinessErrorException("Location.Error.ItemTypeNotValid", item.Type); } #endregion bool isBillSettled = false; #region �ջ�����/������ if (isCS && (plannedBill.SettleTerm == BusinessConstants.CODE_MASTER_BILL_SETTLE_TERM_VALUE_RECEIVING_SETTLEMENT || (location.IsSettleConsignment && (plannedBill.SettleTerm == BusinessConstants.CODE_MASTER_BILL_SETTLE_TERM_VALUE_ONLINE_BILLING || plannedBill.SettleTerm == BusinessConstants.CODE_MASTER_BILL_SETTLE_TERM_VALUE_LINEAR_CLEARING)))) { plannedBill.CurrentActingQty = qty / plannedBill.UnitQty; this.billMgr.CreateActingBill(plannedBill, user); isCS = false; isBillSettled = true; } #endregion DateTime createDate = DateTime.Now; LocationLotDetail newLocationLotDetail = new LocationLotDetail(); newLocationLotDetail.Item = item; newLocationLotDetail.Location = location; newLocationLotDetail.LotNo = lotNo; if (huId != null && huId != string.Empty) { huId = huId.ToUpper(); newLocationLotDetail.Hu = this.huMgr.LoadHu(huId); //��������������ϵ������в��죬���������ϵ����� if (newLocationLotDetail.Hu.Qty * newLocationLotDetail.Hu.UnitQty != qty) { newLocationLotDetail.Hu.Qty = qty / newLocationLotDetail.Hu.UnitQty; } newLocationLotDetail.Hu.Location = location.Code; newLocationLotDetail.Hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_INVENTORY; this.huMgr.UpdateHu(newLocationLotDetail.Hu); } newLocationLotDetail.CreateDate = createDate; newLocationLotDetail.Qty = qty; newLocationLotDetail.IsConsignment = isCS; if (plannedBill != null) { newLocationLotDetail.PlannedBill = plannedBill.Id; } newLocationLotDetail.RefLocation = refLoc; this.locationLotDetailMgr.CreateLocationLotDetail(newLocationLotDetail); inventoryTransactionList.Add(InventoryTransactionHelper.CreateInventoryTransaction(newLocationLotDetail, qty, isBillSettled)); return newLocationLotDetail; }
public virtual void DeleteLocationLotDetail(LocationLotDetail entity) { Delete(entity); }
public IList<InventoryTransaction> InspectIn(LocationLotDetail locationLotDetail, Location locIn, StorageBin bin, User user, bool needSettle, string inspectNo, string inrNo, int? inspectDetailId) { bool isBillSettled = false; //�Ƿ��Ѿ�������� if (needSettle && locationLotDetail.IsConsignment && locationLotDetail.PlannedBill.HasValue) { PlannedBill plannedBill = this.plannedBillMgr.LoadPlannedBill(locationLotDetail.PlannedBill.Value); if (plannedBill.SettleTerm == BusinessConstants.CODE_MASTER_BILL_SETTLE_TERM_VALUE_INSPECTION) { isBillSettled = true; } } #region ��� IList<InventoryTransaction> inventoryTransactionList = RecordInventory( locationLotDetail.Item, locIn, //�벻�ϸ�Ʒ��λ����Ҫ������ locIn.Code != BusinessConstants.SYSTEM_LOCATION_REJECT && locationLotDetail.Hu != null ? locationLotDetail.Hu.HuId : null, locationLotDetail.LotNo, locationLotDetail.CurrentInspectQty, //��浥λ isBillSettled ? false : locationLotDetail.IsConsignment, //�Ѿ��������ֱ�Ӽ�Ϊ�Ǽ��ۿ�� isBillSettled ? null : (locationLotDetail.PlannedBill.HasValue ? this.plannedBillMgr.LoadPlannedBill(locationLotDetail.PlannedBill.Value) : null), //�Ѿ��������ֱ�Ӽ�Ϊ�Ǽ��ۿ�� BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_INP, null, //false, user, false, false, (locationLotDetail.Location.Code == BusinessConstants.SYSTEM_LOCATION_INSPECT && locIn.Code == BusinessConstants.SYSTEM_LOCATION_REJECT ? locationLotDetail.RefLocation : (locIn.Code == BusinessConstants.SYSTEM_LOCATION_INSPECT ? locationLotDetail.Location.Code : null)) //�������λ���粻�ϸ�Ʒ��λ����Ҫ��RefLoc����ȥ ); #endregion #region ��¼������� if (inventoryTransactionList != null && inventoryTransactionList.Count > 0) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { this.locationTransactionMgr.RecordLocationTransaction(inventoryTransaction, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_INP, user, inspectNo, locationLotDetail.Location, null, inrNo,inspectDetailId); } } #endregion #region �ϼ� if (bin != null) { LocationLotDetail oldLocationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransactionList[0].LocationLotDetailId); this.InventoryPut(oldLocationLotDetail, user); } #endregion #region ��������״̬�Ϳ�λ if (locationLotDetail.Hu != null) { Hu hu = this.huMgr.LoadHu(locationLotDetail.Hu.HuId); if (locIn.Code == BusinessConstants.SYSTEM_LOCATION_REJECT) { hu.Location = null; hu.Qty = 0; hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CLOSE; } else { if (locIn != null) { hu.Location = locIn.Code; } hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_INVENTORY; } this.huMgr.UpdateHu(hu); } #endregion return inventoryTransactionList; }
protected override void SetDetail(Resolver resolver) { List <string> flowTypes = new List <string>(); flowTypes.Add(BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER); flowTypes.Add(BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT); flowTypes.Add(BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION); flowTypes.Add(BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_CUSTOMERGOODS); Hu hu = huMgr.CheckAndLoadHu(resolver.Input); if (this.locationMgr.IsHuOcuppyByPickList(resolver.Input)) { throw new BusinessErrorException("Order.Error.PickUp.HuOcuppied", resolver.Input); } FlowView flowView = null; //移库路线类型退货(退库)可以跟据库格和库位找出相对应的移库路线 if (resolver.CodePrefix == null || resolver.CodePrefix.Trim() == string.Empty) { if (resolver.BinCode == null || resolver.BinCode.Trim() == string.Empty) { throw new BusinessErrorException("Common.Business.Error.ScanFlowOrStorageBinFirst"); } if (resolver.LocationFormCode == null || resolver.LocationFormCode.Trim() == string.Empty) { throw new BusinessErrorException("Common.Business.Error.ScanFlowOrLocationFirst"); } if (hu.Location != null) { if (hu.Location != resolver.LocationFormCode) { throw new BusinessErrorException("Common.Business.Error.HuNoInventory", resolver.LocationFormCode, hu.HuId); } } //确定flow和flowView List <string> transferType = new List <string>(); transferType.Add(BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER); flowView = flowMgr.CheckAndLoadFlowView(null, resolver.UserCode, resolver.LocationToCode, resolver.LocationFormCode, hu, transferType); setBaseMgr.FillResolverByFlow(resolver, flowView.Flow); resolver.Result = resolver.LocationFormCode + " => " + resolver.LocationToCode; } //已经确定了Flow,匹配新的Hu if (resolver.CodePrefix != null && resolver.CodePrefix.Trim() != string.Empty) { flowView = flowMgr.CheckAndLoadFlowView(resolver.Code, null, null, null, hu, null); //退库检查库存 if ((resolver.OrderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER || resolver.OrderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT || resolver.OrderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_CUSTOMERGOODS) && flowView.Flow.IsReceiptScanHu ) { LocationLotDetail locationLotDetail = locationLotDetailMgr.CheckLoadHuLocationLotDetail(hu.HuId); hu.Qty = locationLotDetail.Qty / hu.UnitQty; } } else { throw new BusinessErrorException("Common.Business.Error.ScanFlowFirst"); } setDetailMgr.MatchHuByFlowView(resolver, flowView, hu); }
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 DeleteLocationLotDetail(LocationLotDetail entity) { entityDao.DeleteLocationLotDetail(entity); }
public void RecordBillTransaction(PlannedBill plannedBill, ActingBill actingBill, LocationLotDetail locationLotDetail, User user) { #region 记BillTransaction DateTime dateTimeNow = DateTime.Now; BillTransaction billTransaction = new BillTransaction(); billTransaction.OrderNo = plannedBill.OrderNo; billTransaction.ExternalReceiptNo = plannedBill.ExternalReceiptNo; billTransaction.ReceiptNo = plannedBill.ReceiptNo; billTransaction.Item = plannedBill.Item.Code; billTransaction.ItemDescription = plannedBill.Item.Description; billTransaction.Uom = plannedBill.Uom.Code; billTransaction.BillAddress = plannedBill.BillAddress.Code; billTransaction.BillAddressDescription = plannedBill.BillAddress.Address; billTransaction.Party = plannedBill.BillAddress.Party.Code; billTransaction.PartyName = plannedBill.BillAddress.Party.Name; billTransaction.Qty = plannedBill.CurrentActingQty; billTransaction.EffectiveDate = DateTime.Parse(dateTimeNow.ToShortDateString()); //仅保留年月日; billTransaction.TransactionType = plannedBill.TransactionType; billTransaction.PlannedBill = plannedBill.Id; billTransaction.CreateUser = user.Code; billTransaction.CreateDate = dateTimeNow; billTransaction.ActingBill = actingBill.Id; billTransaction.LocationFrom = plannedBill.LocationFrom; billTransaction.PartyFrom = plannedBill.PartyFrom; billTransaction.IpNo = plannedBill.IpNo; billTransaction.ReferenceItemCode = plannedBill.ReferenceItemCode; if (locationLotDetail != null) { billTransaction.Location = locationLotDetail.Location.Code; billTransaction.LocationName = locationLotDetail.Location.Name; billTransaction.HuId = locationLotDetail.Hu != null ? locationLotDetail.Hu.HuId : string.Empty; billTransaction.LotNo = locationLotDetail.LotNo; billTransaction.BatchNo = locationLotDetail.Id; } this.CreateBillTransaction(billTransaction); #endregion }
public IList<InventoryTransaction> InspectIn(LocationLotDetail locationLotDetail, Location locIn, StorageBin bin, User user, bool needSettle, string inspectNo) { bool isBillSettled = false; //是否已经检验结算 if (needSettle && locationLotDetail.IsConsignment && locationLotDetail.PlannedBill.HasValue) { PlannedBill plannedBill = this.plannedBillMgrE.LoadPlannedBill(locationLotDetail.PlannedBill.Value); if (plannedBill.SettleTerm == BusinessConstants.CODE_MASTER_BILL_SETTLE_TERM_VALUE_INSPECTION) { isBillSettled = true; } } #region 入库 IList<InventoryTransaction> inventoryTransactionList = RecordInventory( locationLotDetail.Item, locIn, //入不合格品库位,需要按数量 locIn.Code != BusinessConstants.SYSTEM_LOCATION_REJECT && locationLotDetail.Hu != null ? locationLotDetail.Hu.HuId : null, locationLotDetail.LotNo, locationLotDetail.CurrentInspectQty, //库存单位 isBillSettled ? false : locationLotDetail.IsConsignment, //已经检验结算直接记为非寄售库存 isBillSettled ? null : (locationLotDetail.PlannedBill.HasValue ? this.plannedBillMgrE.LoadPlannedBill(locationLotDetail.PlannedBill.Value) : null), //已经检验结算直接记为非寄售库存 BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_INP, null, //false, user, false, false ); #endregion #region 记录库存事务 if (inventoryTransactionList != null && inventoryTransactionList.Count > 0) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { this.locationTransactionMgrE.RecordLocationTransaction(inventoryTransaction, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_INP, user, inspectNo, locationLotDetail.Location); } } #endregion #region 上架 if (bin != null) { LocationLotDetail oldLocationLotDetail = this.locationLotDetailMgrE.LoadLocationLotDetail(inventoryTransactionList[0].LocationLotDetailId); this.InventoryPut(oldLocationLotDetail, user); } #endregion #region 更新条码状态和库位 if (locationLotDetail.Hu != null) { Hu hu = this.huMgrE.LoadHu(locationLotDetail.Hu.HuId); if (locIn.Code == BusinessConstants.SYSTEM_LOCATION_REJECT) { hu.Location = null; hu.Qty = 0; hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CLOSE; } else { if (locIn != null) { hu.Location = locIn.Code; } hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_INVENTORY; } this.huMgrE.UpdateHu(hu); } #endregion return inventoryTransactionList; }
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("你是变态才这么设置。"); } //如果找到匹配项,只可能有一个 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 }
public virtual void CreateLocationLotDetail(LocationLotDetail entity) { Create(entity); }