public InspectOrder CreateFgInspectOrder(string locationCode, IDictionary <string, decimal> itemFgQtyDic, User user) { #region 创建检验单头 DateTime dateTimeNow = DateTime.Now; InspectOrder inspectOrder = new InspectOrder(); inspectOrder.InspectNo = this.numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_INSPECTION); inspectOrder.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; inspectOrder.CreateUser = user; inspectOrder.CreateDate = dateTimeNow; inspectOrder.LastModifyUser = user; inspectOrder.LastModifyDate = dateTimeNow; inspectOrder.IsDetailHasHu = false; inspectOrder.IsSeperated = true; inspectOrder.Region = this.locationMgr.CheckAndLoadLocation(locationCode).Region.Code; this.CreateInspectOrder(inspectOrder); #endregion #region 创建检验明细 if (itemFgQtyDic != null && itemFgQtyDic.Count > 0) { Location location = this.locationMgr.CheckAndLoadLocation(locationCode); string itemCode = string.Empty; string fgCode = string.Empty; string defectClassification = string.Empty; string defectFactor = string.Empty; foreach (string itemFgCode in itemFgQtyDic.Keys) { if (itemFgQtyDic[itemFgCode] == 0) { continue; } string[] itemFg = itemFgCode.Split('-'); itemCode = itemFg[0]; fgCode = itemFg[1]; defectClassification = itemFg[2]; defectFactor = itemFg[3]; Item item = this.itemMgr.CheckAndLoadItem(itemCode); //零件出库 this.locationMgr.InspectOut(location, item, itemFgQtyDic[itemFgCode], user, inspectOrder.InspectNo, this.locationMgr.GetInspectLocation()); //入待验库位 IList <InventoryTransaction> inventoryTransactionList = this.locationMgr.InspectIn(item, itemFgQtyDic[itemFgCode], user, inspectOrder.InspectNo, null, location); if (inventoryTransactionList != null && inventoryTransactionList.Count > 0) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { InspectOrderDetail inspectOrderDetail = new InspectOrderDetail(); inspectOrderDetail.InspectOrder = inspectOrder; inspectOrderDetail.InspectQty = inventoryTransaction.Qty; inspectOrderDetail.LocationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId); inspectOrderDetail.LocationFrom = location; inspectOrderDetail.LocationTo = location; inspectOrderDetail.FinishGoods = this.itemMgr.LoadItem(fgCode); inspectOrderDetail.DefectClassification = defectClassification; inspectOrderDetail.DefectFactor = defectFactor; this.inspectOrderDetailMgr.CreateInspectOrderDetail(inspectOrderDetail); inspectOrder.AddInspectOrderDetail(inspectOrderDetail); } } } } #endregion return(inspectOrder); }
public InspectOrder CreateInspectOrder(IList <LocationLotDetail> locationLotDetailList, User user, string ipNo, string receiptNo, bool isSeperated) { IList <LocationLotDetail> noneZeroLocationLotDetailList = new List <LocationLotDetail>(); bool? isDetailHasHu = null; string region = null; if (locationLotDetailList != null && locationLotDetailList.Count > 0) { foreach (LocationLotDetail locationLotDetail in locationLotDetailList) { if (locationLotDetail.Location.Code == BusinessConstants.SYSTEM_LOCATION_INSPECT || locationLotDetail.Location.Code == BusinessConstants.SYSTEM_LOCATION_REJECT) { throw new BusinessErrorException("MasterData.Inventory.Inspect.Error.LocationFrom", locationLotDetail.Location.Code); } if (locationLotDetail.CurrentInspectQty > 0) { if (isDetailHasHu == null) { isDetailHasHu = (locationLotDetail.Hu != null); } else if (isDetailHasHu != (locationLotDetail.Hu != null)) { throw new BusinessErrorException("MasterData.Inventory.Inspect.Error.NotAllDetailHasHu"); } noneZeroLocationLotDetailList.Add(locationLotDetail); } if (region == null) { region = locationLotDetail.Location.Region.Code; } else if (region != locationLotDetail.Location.Region.Code) { throw new BusinessErrorException("MasterData.Inventory.Inspect.Error.RegionNotEqual"); } } } if (noneZeroLocationLotDetailList.Count == 0) { throw new BusinessErrorException("Order.Error.Inspection.DetailEmpty"); } #region 创建检验单头 DateTime dateTimeNow = DateTime.Now; InspectOrder inspectOrder = new InspectOrder(); inspectOrder.InspectNo = this.numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_INSPECTION); inspectOrder.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; inspectOrder.CreateUser = user; inspectOrder.CreateDate = dateTimeNow; inspectOrder.LastModifyUser = user; inspectOrder.LastModifyDate = dateTimeNow; inspectOrder.IsDetailHasHu = isDetailHasHu.Value; inspectOrder.IpNo = ipNo; inspectOrder.ReceiptNo = receiptNo; inspectOrder.IsSeperated = isSeperated; inspectOrder.Region = region; this.CreateInspectOrder(inspectOrder); #endregion #region 创建检验明细 foreach (LocationLotDetail locationLotDetail in noneZeroLocationLotDetailList) { //零件出库 this.locationMgr.InspectOut(locationLotDetail, user, false, inspectOrder.InspectNo, this.locationMgr.GetInspectLocation()); //入待验库位 IList <InventoryTransaction> inventoryTransactionList = this.locationMgr.InspectIn(locationLotDetail, this.locationMgr.GetInspectLocation(), user, false, inspectOrder.InspectNo, null, null); if (inventoryTransactionList != null && inventoryTransactionList.Count > 0) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { InspectOrderDetail inspectOrderDetail = new InspectOrderDetail(); inspectOrderDetail.InspectOrder = inspectOrder; inspectOrderDetail.InspectQty = inventoryTransaction.Qty; inspectOrderDetail.LocationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId); inspectOrderDetail.LocationFrom = locationLotDetail.Location; inspectOrderDetail.LocationTo = locationLotDetail.InspectQualifyLocation != null ? locationLotDetail.InspectQualifyLocation : locationLotDetail.Location; this.inspectOrderDetailMgr.CreateInspectOrderDetail(inspectOrderDetail); inspectOrder.AddInspectOrderDetail(inspectOrderDetail); } } } #endregion return(inspectOrder); }
public InspectOrder CreateInspectOrder(string locationCode, IDictionary <string, decimal> itemQtyDic, User user) { if (locationCode == BusinessConstants.SYSTEM_LOCATION_INSPECT || locationCode == BusinessConstants.SYSTEM_LOCATION_REJECT) { throw new BusinessErrorException("MasterData.Inventory.Inspect.Error.LocationFrom", locationCode); } #region 创建检验单头 DateTime dateTimeNow = DateTime.Now; InspectOrder inspectOrder = new InspectOrder(); inspectOrder.InspectNo = this.numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_INSPECTION); inspectOrder.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; inspectOrder.CreateUser = user; inspectOrder.CreateDate = dateTimeNow; inspectOrder.LastModifyUser = user; inspectOrder.LastModifyDate = dateTimeNow; inspectOrder.IsDetailHasHu = false; inspectOrder.IsSeperated = true; Location location = this.locationMgr.CheckAndLoadLocation(locationCode); inspectOrder.Region = location.Region.Code; this.CreateInspectOrder(inspectOrder); #endregion #region 创建检验明细 if (itemQtyDic != null && itemQtyDic.Count > 0) { foreach (string itemCode in itemQtyDic.Keys) { if (itemQtyDic[itemCode] == 0) { continue; } Item item = this.itemMgr.CheckAndLoadItem(itemCode); //零件出库 IList <InventoryTransaction> inventoryTransactionList = this.locationMgr.InspectOut(location, item, itemQtyDic[itemCode], user, inspectOrder.InspectNo, this.locationMgr.GetInspectLocation()); //入待验库位 foreach (InventoryTransaction outInventoryTransaction in inventoryTransactionList) { IList <InventoryTransaction> inInventoryTransactionList = this.locationMgr.InspectIn(item, 0 - outInventoryTransaction.Qty, user, inspectOrder.InspectNo, outInventoryTransaction.PlannedBill, location); if (inInventoryTransactionList != null && inInventoryTransactionList.Count > 0) { foreach (InventoryTransaction inInventoryTransaction in inInventoryTransactionList) { InspectOrderDetail inspectOrderDetail = new InspectOrderDetail(); inspectOrderDetail.InspectOrder = inspectOrder; inspectOrderDetail.InspectQty = inInventoryTransaction.Qty; inspectOrderDetail.LocationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inInventoryTransaction.LocationLotDetailId); inspectOrderDetail.LocationFrom = location; inspectOrderDetail.LocationTo = location; this.inspectOrderDetailMgr.CreateInspectOrderDetail(inspectOrderDetail); inspectOrder.AddInspectOrderDetail(inspectOrderDetail); } } } } } #endregion return(inspectOrder); }