public void AddInspectDetail(InspectDetail inspectDetail) { if (InspectDetails == null) { InspectDetails = new List<InspectDetail>(); } InspectDetails.Add(inspectDetail); }
public IList<InspectDetail> AddInspectDetail(string HuId, IList<InspectDetail> InspectDetailDetailList) { if (InspectDetailDetailList == null) { InspectDetailDetailList = new List<InspectDetail>(); } else { IList<InspectDetail> q = InspectDetailDetailList.Where(v => v.HuId == HuId).ToList(); if (q.Count > 0) { throw new BusinessException("条码{0}已经被占用。", HuId); } } IList<LocationLotDetail> itemList = genericMgr.FindAll<LocationLotDetail>("select l from LocationLotDetail as l where HuId='" + HuId + "'"); if (itemList == null || itemList.Count() == 0) { throw new BusinessException("没有找到对应的条码{0}", HuId); } //IList<InspectDetail> inspectDetailByHuId = this.genericMgr.FindAll<InspectDetail>("select i from InspectDetail as i where i.HuId='" + HuId + "'"); //if (inspectDetailByHuId.Count() > 0) //{ // throw new BusinessException("条码{0}已经被占用", HuId); //} LocationLotDetail locationLotDetail = itemList[0]; InspectDetail inspectDetail = new InspectDetail(); inspectDetail.Item = locationLotDetail.Item; inspectDetail.ItemDescription = locationLotDetail.ItemDescription; inspectDetail.ReferenceItemCode = locationLotDetail.ReferenceItemCode; inspectDetail.HuId = HuId; inspectDetail.Uom = locationLotDetail.HuUom; inspectDetail.UnitCount = locationLotDetail.UnitCount; inspectDetail.InspectQty = locationLotDetail.Qty; inspectDetail.LocationFrom = locationLotDetail.Location; inspectDetail.CurrentLocation = locationLotDetail.Location; InspectDetailDetailList.Add(inspectDetail); return InspectDetailDetailList; }
public InspectMaster TransferReceipt2Inspect(ReceiptMaster receiptMaster) { List<ReceiptLocationDetail> inspectReceiptLocationDetailList = new List<ReceiptLocationDetail>(); IList<Region> createInspectRegonList = this.genericMgr.FindAll<Region>("from Region r where r.IsCreateInspect=?",true); if (createInspectRegonList != null && createInspectRegonList.Count > 0) { foreach (ReceiptDetail receiptDetail in receiptMaster.ReceiptDetails) { int count = (from r in createInspectRegonList where r.Code == receiptDetail.CurrentPartyTo select r).Count(); if (receiptDetail.IsInspect && count > 0) { inspectReceiptLocationDetailList.AddRange(receiptDetail.ReceiptLocationDetails); } } //1月1日上线除冲焊和涂装外,其他区域收货全都不需要报验 //foreach (ReceiptDetail receiptDetail in receiptMaster.ReceiptDetails) //{ // string[] regionArray = new string[] { "CB1", "CP1", "HB1", "HP1", "TB1", "TP1", "TB2", "TP2" }; // int count = (from r in regionArray // where r.ToUpper() == receiptDetail.CurrentPartyTo.ToUpper() // select r).Count(); // if (receiptDetail.IsInspect && count > 0) // { // inspectReceiptLocationDetailList.AddRange(receiptDetail.ReceiptLocationDetails); // } //} //根据region表中的IsCreateInspect来确定是否创建报验单 if (inspectReceiptLocationDetailList != null && inspectReceiptLocationDetailList.Count > 0) { #region 报验单头 InspectMaster inspectMaster = new InspectMaster(); inspectMaster.IpNo = receiptMaster.IpNo; inspectMaster.ReceiptNo = receiptMaster.ReceiptNo; inspectMaster.Region = receiptMaster.PartyTo; inspectMaster.Status = com.Sconit.CodeMaster.InspectStatus.Submit; //inspectMaster.Type = receiptMaster.CreateHuOption == CodeMaster.CreateHuOption.Receive || receiptMaster.IsReceiveScanHu ? com.Sconit.CodeMaster.InspectType.Barcode : com.Sconit.CodeMaster.InspectType.Quantity; inspectMaster.Type = inspectReceiptLocationDetailList.Where(locDet => !string.IsNullOrWhiteSpace(locDet.HuId)).Count() > 0 ? com.Sconit.CodeMaster.InspectType.Barcode : com.Sconit.CodeMaster.InspectType.Quantity; inspectMaster.IsATP = true; inspectMaster.WMSNo = receiptMaster.WMSNo; #endregion #region 根据收货明细+条码+WMS行号汇总 var groupedInspectReceiptLocationDetailList = from locDet in inspectReceiptLocationDetailList group locDet by new { ReceiptDetailId = locDet.ReceiptDetailId, HuId = locDet.HuId, LotNo = locDet.LotNo, WMSSeq = locDet.WMSSeq, IsConsignment = locDet.IsConsignment, PlanBill = locDet.PlanBill, } into gj select new { ReceiptDetailId = gj.Key.ReceiptDetailId, HuId = gj.Key.HuId, LotNo = gj.Key.LotNo, WMSSeq = gj.Key.WMSSeq, IsConsignment = gj.Key.IsConsignment, PlanBill = gj.Key.PlanBill, ReceiveQty = gj.Sum(locDet => locDet.Qty), //基本单位 }; #endregion #region 报验单明细 foreach (var groupedInspectReceiptLocationDetail in groupedInspectReceiptLocationDetailList) { ReceiptDetail receiptDetail = receiptMaster.ReceiptDetails.Where(det => det.Id == groupedInspectReceiptLocationDetail.ReceiptDetailId).Single(); InspectDetail inspectDetail = new InspectDetail(); inspectDetail.Item = receiptDetail.Item; inspectDetail.ItemDescription = receiptDetail.ItemDescription; inspectDetail.ReferenceItemCode = receiptDetail.ReferenceItemCode; inspectDetail.BaseUom = receiptDetail.BaseUom; inspectDetail.HuId = groupedInspectReceiptLocationDetail.HuId; inspectDetail.LotNo = groupedInspectReceiptLocationDetail.LotNo; inspectDetail.Uom = receiptDetail.Uom; inspectDetail.UnitCount = receiptDetail.UnitCount; inspectDetail.UnitQty = receiptDetail.UnitQty; inspectDetail.LocationFrom = receiptDetail.LocationTo; inspectDetail.CurrentLocation = receiptDetail.LocationTo; inspectDetail.InspectQty = groupedInspectReceiptLocationDetail.ReceiveQty / inspectDetail.UnitQty; inspectDetail.IsJudge = false; inspectDetail.IpDetailSequence = receiptDetail.IpDetailSequence; inspectDetail.ReceiptDetailSequence = receiptDetail.Sequence; inspectDetail.WMSSeq = groupedInspectReceiptLocationDetail.WMSSeq; inspectDetail.IsConsignment = groupedInspectReceiptLocationDetail.IsConsignment; inspectDetail.PlanBill = groupedInspectReceiptLocationDetail.PlanBill; inspectMaster.AddInspectDetail(inspectDetail); } #endregion return inspectMaster; } else { return null; } } else { return null; } }
public string New(string checkedIds, string Region) { IList<LocationLotDetail> viewLocationList = new List<LocationLotDetail>(); string[] checkedIdArray = checkedIds.Split(','); string selectStatement = string.Empty; IList<object> selectPartyPara = new List<object>(); foreach (var para in checkedIdArray) { if (selectStatement == string.Empty) { selectStatement = "from LocationLotDetail where Id in (?"; } else { selectStatement += ",?"; } selectPartyPara.Add(para); } selectStatement += ")"; viewLocationList = genericMgr.FindAll<LocationLotDetail>(selectStatement, selectPartyPara.ToArray()); BusinessException businessException = new BusinessException(); try { #region orderDetailList IList<InspectDetail> inspectDetailList = new List<InspectDetail>(); if (viewLocationList != null && viewLocationList.Count() > 0) { foreach (LocationLotDetail locationlotdetail in viewLocationList) { InspectDetail inspectDetail = new InspectDetail(); Item item = this.genericMgr.FindById<Item>(locationlotdetail.Item); inspectDetail.Item = locationlotdetail.Item; inspectDetail.HuId = locationlotdetail.HuId; inspectDetail.LotNo = locationlotdetail.LotNo; inspectDetail.ItemDescription = item.Description; inspectDetail.UnitCount = locationlotdetail.UnitCount; inspectDetail.ReferenceItemCode = item.ReferenceCode; inspectDetail.Uom = item.Uom; inspectDetail.LocationFrom =locationlotdetail.Location; inspectDetail.CurrentLocation = locationlotdetail.Location; inspectDetail.BaseUom = item.Uom; inspectDetail.UnitQty = 1; inspectDetailList.Add(inspectDetail); } } #endregion if (businessException.HasMessage) { throw businessException; } if (inspectDetailList != null && inspectDetailList.Count == 0) { throw new BusinessException(Resources.INP.InspectDetail.Errors_InspectDetail_Required); } InspectMaster inspectMaster = new InspectMaster(); inspectMaster.Region = Region; inspectMaster.InspectDetails = inspectDetailList; inspectMaster.Type = com.Sconit.CodeMaster.InspectType.Barcode; inspectMaster.IsATP = false; inspectMgr.CreateInspectMaster(inspectMaster); SaveSuccessMessage(Resources.INP.InspectMaster.InspectMaster_Added); return inspectMaster.InspectNo; } catch (BusinessException ex) { Response.TrySkipIisCustomErrors = true; Response.StatusCode = 500; string messagesStr = ""; IList<Message> messageList = ex.GetMessages(); foreach (Message message in messageList) { messagesStr += message.GetMessageString() ; } Response.Write(messagesStr); return string.Empty; } }
public string CreateInspectionDetail(string ItemStr, string HuIdStr, string LocationStr, string InspectQtyStr, string FailCodeStr, string NoteStr) { try { if (!string.IsNullOrEmpty(ItemStr)) { string[] itemArray = ItemStr.Split(','); string[] huidArray = HuIdStr.Split(','); string[] locationArray = LocationStr.Split(','); string[] inspectqtyArray = InspectQtyStr.Split(','); string[] falicodeArray = FailCodeStr.Split(','); string[] noteArray = NoteStr.Split(','); IList<InspectDetail> inspectDetailList = new List<InspectDetail>(); int i = 0; foreach (string itemcode in itemArray) { InspectDetail inspectDetail = new InspectDetail(); Item item = this.genericMgr.FindById<Item>(itemcode); inspectDetail.ItemDescription = item.Description; inspectDetail.UnitCount = item.UnitCount; inspectDetail.ReferenceItemCode = item.ReferenceCode; inspectDetail.Uom = item.Uom; inspectDetail.BaseUom = item.Uom; inspectDetail.UnitQty = 1; inspectDetail.LocationFrom = locationArray[i]; inspectDetail.CurrentLocation = locationArray[i]; inspectDetail.FailCode = falicodeArray[i]; inspectDetail.Note = noteArray[i]; inspectDetail.HuId = huidArray[i]; inspectDetail.InspectQty = Convert.ToDecimal(inspectqtyArray[i]); i++; inspectDetailList.Add(inspectDetail); } if (inspectDetailList != null && inspectDetailList.Count == 0) { throw new BusinessException(Resources.INP.InspectDetail.Errors_InspectDetail_Required); } InspectMaster inspectMaster = new InspectMaster(); inspectMaster.InspectDetails = inspectDetailList; inspectMaster.Type = com.Sconit.CodeMaster.InspectType.Barcode; inspectMaster.IsATP = false; inspectMgr.CreateInspectMaster(inspectMaster); SaveSuccessMessage(Resources.INP.InspectMaster.InspectMaster_Added); this._CleanInspectionDetail(); return inspectMaster.InspectNo; } else { throw new BusinessException(Resources.INP.InspectDetail.Errors_InspectDetail_Required); } } catch (BusinessException ex) { Response.TrySkipIisCustomErrors = true; Response.StatusCode = 500; Response.Write(ex.GetMessages()[0].GetMessageString()); return string.Empty; } }
private void RecordLocationTransaction(InspectDetail inspectDetail, InspectMaster inspectMaster, DateTime effectiveDate, IList<InventoryTransaction> inventoryTransactionList, bool isIssue) { DateTime dateTimeNow = DateTime.Now; //根据PlanBill和ActingBill分组,为了不同供应商的库存事务分开 var groupedInventoryTransactionList = from trans in inventoryTransactionList group trans by new { IsConsignment = trans.IsConsignment, PlanBill = trans.PlanBill, ActingBill = trans.ActingBill } into result select new { IsConsignment = result.Key.IsConsignment, PlanBill = result.Key.PlanBill, ActingBill = result.Key.ActingBill, //Qty = result.Sum(trans => isIssue ? -trans.Qty : trans.Qty), Qty = result.Sum(trans => trans.Qty), //PlanBillQty = result.Sum(trans => isIssue ? -trans.PlanBillQty : trans.PlanBillQty), PlanBillQty = result.Sum(trans => trans.PlanBillQty), //ActingBillQty = result.Sum(trans => isIssue ? -trans.ActingBillQty : trans.ActingBillQty), ActingBillQty = result.Sum(trans => trans.ActingBillQty), InventoryTransactionList = result.ToList() }; foreach (var groupedInventoryTransaction in groupedInventoryTransactionList) { LocationTransaction locationTransaction = new LocationTransaction(); locationTransaction.OrderNo = inspectDetail.InspectNo; //locationTransaction.OrderType = feedInput.OrderType; //locationTransaction.OrderSubType = feedInput.OrderSubType; locationTransaction.OrderDetailSequence = inspectDetail.Sequence; locationTransaction.OrderDetailId = inspectDetail.Id; //locationTransaction.OrderBomDetId = //locationTransaction.IpNo = //locationTransaction.IpDetailId = //locationTransaction.IpDetailSequence = //locationTransaction.ReceiptNo = //locationTransaction.ReceiptDetailId = //locationTransaction.ReceiptDetailSequence = //locationTransaction.SequenceNo = //locationTransaction.TraceCode = feedInput.TraceCode; locationTransaction.Item = inspectDetail.Item; locationTransaction.Uom = inspectDetail.Uom; locationTransaction.BaseUom = inspectDetail.BaseUom; locationTransaction.Qty = groupedInventoryTransaction.Qty / inspectDetail.UnitQty; locationTransaction.UnitQty = inspectDetail.UnitQty; locationTransaction.IsConsignment = groupedInventoryTransaction.IsConsignment; if (groupedInventoryTransaction.IsConsignment && groupedInventoryTransaction.PlanBill.HasValue) { locationTransaction.PlanBill = groupedInventoryTransaction.PlanBill.Value; } locationTransaction.PlanBillQty = groupedInventoryTransaction.PlanBillQty / inspectDetail.UnitQty; if (groupedInventoryTransaction.ActingBill.HasValue) { locationTransaction.ActingBill = groupedInventoryTransaction.ActingBill.Value; } locationTransaction.ActingBillQty = groupedInventoryTransaction.ActingBillQty / inspectDetail.UnitQty; locationTransaction.QualityType = isIssue ? CodeMaster.QualityType.Qualified : CodeMaster.QualityType.Inspect; locationTransaction.HuId = inspectDetail.HuId; locationTransaction.LotNo = inspectDetail.LotNo; locationTransaction.TransactionType = isIssue ? (inspectMaster.IsATP ? CodeMaster.TransactionType.ISS_INP : CodeMaster.TransactionType.ISS_ISL) : (inspectMaster.IsATP ? CodeMaster.TransactionType.RCT_INP : CodeMaster.TransactionType.RCT_ISL); locationTransaction.IOType = isIssue ? CodeMaster.TransactionIOType.Out : CodeMaster.TransactionIOType.In; locationTransaction.PartyFrom = inspectMaster.Region; locationTransaction.PartyTo = inspectMaster.Region; locationTransaction.LocationFrom = inspectDetail.LocationFrom; locationTransaction.LocationTo = inspectDetail.LocationFrom; locationTransaction.LocationIOReason = string.Empty; locationTransaction.EffectiveDate = effectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, inventoryTransactionList); } }
public InspectMaster TransferReceipt2Inspect(ReceiptMaster receiptMaster) { List<ReceiptLocationDetail> inspectReceiptLocationDetailList = new List<ReceiptLocationDetail>(); foreach (ReceiptDetail receiptDetail in receiptMaster.ReceiptDetails) { if (receiptDetail.IsInspect) { inspectReceiptLocationDetailList.AddRange(receiptDetail.ReceiptLocationDetails); } } if (inspectReceiptLocationDetailList != null && inspectReceiptLocationDetailList.Count > 0) { #region 报验单头 InspectMaster inspectMaster = new InspectMaster(); inspectMaster.IpNo = receiptMaster.IpNo; inspectMaster.ReceiptNo = receiptMaster.ReceiptNo; inspectMaster.Region = receiptMaster.PartyTo; inspectMaster.Status = com.Sconit.CodeMaster.InspectStatus.Submit; //inspectMaster.Type = receiptMaster.CreateHuOption == CodeMaster.CreateHuOption.Receive || receiptMaster.IsReceiveScanHu ? com.Sconit.CodeMaster.InspectType.Barcode : com.Sconit.CodeMaster.InspectType.Quantity; inspectMaster.Type = inspectReceiptLocationDetailList.Where(locDet => !string.IsNullOrWhiteSpace(locDet.HuId)).Count() > 0 ? com.Sconit.CodeMaster.InspectType.Barcode : com.Sconit.CodeMaster.InspectType.Quantity; inspectMaster.IsATP = true; inspectMaster.WMSNo = receiptMaster.WMSNo; inspectMaster.PartyFrom = receiptMaster.PartyFrom; inspectMaster.PartyFromName = receiptMaster.PartyFromName; #endregion #region 根据收货明细+条码+WMS行号汇总 var groupedInspectReceiptLocationDetailList = from locDet in inspectReceiptLocationDetailList group locDet by new { ReceiptDetailId = locDet.ReceiptDetailId, HuId = locDet.HuId, LotNo = locDet.LotNo, WMSSeq = locDet.WMSSeq, IsConsignment = locDet.IsConsignment, PlanBill = locDet.PlanBill, } into gj select new { ReceiptDetailId = gj.Key.ReceiptDetailId, HuId = gj.Key.HuId, LotNo = gj.Key.LotNo, WMSSeq = gj.Key.WMSSeq, IsConsignment = gj.Key.IsConsignment, PlanBill = gj.Key.PlanBill, ReceiveQty = gj.Sum(locDet => locDet.Qty), //基本单位 }; #endregion #region 报验单明细 foreach (var groupedInspectReceiptLocationDetail in groupedInspectReceiptLocationDetailList) { ReceiptDetail receiptDetail = receiptMaster.ReceiptDetails.Where(det => det.Id == groupedInspectReceiptLocationDetail.ReceiptDetailId).Single(); InspectDetail inspectDetail = new InspectDetail(); inspectDetail.Item = receiptDetail.Item; inspectDetail.ItemDescription = receiptDetail.ItemDescription; inspectDetail.ReferenceItemCode = receiptDetail.ReferenceItemCode; inspectDetail.BaseUom = receiptDetail.BaseUom; inspectDetail.HuId = groupedInspectReceiptLocationDetail.HuId; inspectDetail.LotNo = groupedInspectReceiptLocationDetail.LotNo; inspectDetail.Uom = receiptDetail.Uom; inspectDetail.UnitCount = receiptDetail.UnitCount; inspectDetail.UnitQty = receiptDetail.UnitQty; inspectDetail.LocationFrom = receiptDetail.LocationTo; inspectDetail.CurrentLocation = receiptDetail.LocationTo; inspectDetail.InspectQty = groupedInspectReceiptLocationDetail.ReceiveQty / inspectDetail.UnitQty; inspectDetail.IsJudge = false; inspectDetail.IpDetailSequence = receiptDetail.IpDetailSequence; inspectDetail.ReceiptDetailSequence = receiptDetail.Sequence; inspectDetail.WMSSeq = groupedInspectReceiptLocationDetail.WMSSeq; inspectDetail.IsConsignment = groupedInspectReceiptLocationDetail.IsConsignment; inspectDetail.PlanBill = groupedInspectReceiptLocationDetail.PlanBill; inspectMaster.AddInspectDetail(inspectDetail); } #endregion return inspectMaster; } else { return null; } }