public void QuickCreateMiscOrder(MiscOrderMaster miscOrderMaster, DateTime effectiveDate) { miscOrderMaster.MiscOrderNo = this.numberControlMgr.GetMiscOrderNo(miscOrderMaster); this.genericMgr.Create(miscOrderMaster); this.CreateMiscOrderDetail(miscOrderMaster.MiscOrderDetails, miscOrderMaster.MiscOrderNo); this.CloseMiscOrder(miscOrderMaster, effectiveDate); }
public void QuickCreateMiscOrder(MiscOrderMaster miscOrderMaster, DateTime effectiveDate) { miscOrderMaster.MiscOrderNo = this.numberControlMgr.GetMiscOrderNo(miscOrderMaster); this.genericMgr.Create(miscOrderMaster); #region 更新引用的明细状态 if (miscOrderMaster.ReferenceDocumentsType > 0) { if (miscOrderMaster.QualityType != CodeMaster.QualityType.Reject) { throw new BusinessException("不合格品报废请选择质量类型为不合格"); } if (miscOrderMaster.MoveType != "201") { throw new BusinessException("不合格品报废的移动类型应该为201"); } List<string> huList = new List<string>(); if (miscOrderMaster.ReferenceDocumentsType == (int)CodeMaster.DocumentsType.INS) { var inspectResultList = genericMgr.FindAll<InspectResult>(selectInspectResult, new object[] { miscOrderMaster.ReferenceNo, com.Sconit.CodeMaster.HandleResult.Scrap, false }); foreach (var inspectResult in inspectResultList) { inspectResult.HandleQty = inspectResult.JudgeQty; inspectResult.IsHandle = true; genericMgr.Update(inspectResult); } huList = inspectResultList.Select(p => p.HuId).Distinct().ToList(); } else if (miscOrderMaster.ReferenceDocumentsType == (int)CodeMaster.DocumentsType.REJ) { var rejectDetailList = genericMgr.FindAll<RejectDetail>(selectRejectDetail, new object[] { miscOrderMaster.ReferenceNo, com.Sconit.CodeMaster.HandleResult.Scrap }); foreach (var rejectDetail in rejectDetailList) { rejectDetail.HandledQty = rejectDetail.HandleQty; genericMgr.Update(rejectDetail); } RejectMaster rejectMaster = genericMgr.FindById<RejectMaster>(miscOrderMaster.ReferenceNo); rejectMaster.Status = CodeMaster.RejectStatus.Close; genericMgr.Update(rejectMaster); huList = rejectDetailList.Select(p => p.HuId).Distinct().ToList(); } if (miscOrderMaster.IsScanHu) { miscOrderMaster.MiscOrderDetails = new List<MiscOrderDetail>(); this.BatchUpdateMiscOrderDetails(miscOrderMaster, huList, null); } } #endregion this.CreateMiscOrderDetail(miscOrderMaster.MiscOrderDetails, miscOrderMaster.MiscOrderNo); this.CloseMiscOrder(miscOrderMaster, effectiveDate); }
public void UpdateMiscOrder(MiscOrderMaster miscOrderMaster) { if (miscOrderMaster.Status != CodeMaster.MiscOrderStatus.Create) { throw new BusinessException("计划外出入库单{0}的状态为{1}不能修改。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } this.genericMgr.Update(miscOrderMaster); }
public void CreateMiscOrder(MiscOrderMaster miscOrderMaster) { miscOrderMaster.MiscOrderNo = this.numberControlMgr.GetMiscOrderNo(miscOrderMaster); if (string.IsNullOrWhiteSpace(miscOrderMaster.DeliverRegion)) { //非跨工厂移库时,会从Region字段找到对应的Plant填到该字段上面 miscOrderMaster.DeliverRegion = this.genericMgr.FindById<Region>(miscOrderMaster.Region).Plant; } this.genericMgr.Create(miscOrderMaster); if (miscOrderMaster.MiscOrderDetails != null && miscOrderMaster.MiscOrderDetails.Count > 0) { BatchUpdateMiscOrderDetails(miscOrderMaster, miscOrderMaster.MiscOrderDetails, null, null); } }
public void CreateOrUpdateMiscOrderAndDetails(MiscOrderMaster miscOrderMaster, IList<MiscOrderDetail> addMiscOrderDetailList, IList<MiscOrderDetail> updateMiscOrderDetailList, IList<MiscOrderDetail> deleteMiscOrderDetailList) { if (string.IsNullOrEmpty(miscOrderMaster.MiscOrderNo)) { this.CreateMiscOrder(miscOrderMaster); this.BatchUpdateMiscOrderDetails(miscOrderMaster.MiscOrderNo, addMiscOrderDetailList, updateMiscOrderDetailList, deleteMiscOrderDetailList); //if (miscOrderMaster.IsQuick) //{ // this.CloseMiscOrder(miscOrderMaster); //} } else { this.UpdateMiscOrder(miscOrderMaster); BatchUpdateMiscOrderDetails(miscOrderMaster.MiscOrderNo, addMiscOrderDetailList, updateMiscOrderDetailList, deleteMiscOrderDetailList); } }
public void Import261262MiscOrder(Stream inputStream, string wMSNo) { #region 导入数据 if (inputStream.Length == 0) { throw new BusinessException("Import.Stream.Empty"); } HSSFWorkbook workbook = new HSSFWorkbook(inputStream); ISheet sheet = workbook.GetSheetAt(0); IEnumerator rows = sheet.GetRowEnumerator(); ImportHelper.JumpRows(rows, 10); #region 列定义 int colMoveType = 1;//移动类型 int colEffectiveDate = 2;//生效日期 int colRegion = 3;//区域 int colLocation = 4;//库位 int colReferenceNo = 5;//Sap订单号 int colItem = 6;//物料编号 int colQty = 7;//数量 DateTime? prevEffeDate = null; string prevRegion = string.Empty; #endregion BusinessException businessException = new BusinessException(); int rowCount = 10; IList<MiscOrderDetail> activeDetailList = new List<MiscOrderDetail>(); IList<MiscOrderMaster> activeMasterList = new List<MiscOrderMaster>(); IList<Region> regionList = this.genericMgr.FindAll<Region>(); IList<Item> itemList = this.genericMgr.FindAll<Item>(); IList<Location> locationList = this.genericMgr.FindAll<Location>(); while (rows.MoveNext()) { rowCount++; HSSFRow row = (HSSFRow)rows.Current; if (!ImportHelper.CheckValidDataRow(row, 1, 9)) { break;//边界 } string moveType = string.Empty; DateTime effectiveDate = System.DateTime.Now; string regionCode = string.Empty; string locationCode = string.Empty; string referenceNo = string.Empty; string itemCode = string.Empty; decimal qty = 0; Item item = new Item(); #region 读取数据 #region 移动类型 moveType = ImportHelper.GetCellStringValue(row.GetCell(colMoveType)); if (string.IsNullOrWhiteSpace(moveType)) { businessException.AddMessage(string.Format("第{0}行:移动类型不能为空。", rowCount)); } else { if (moveType != "261" && moveType != "262") { businessException.AddMessage(string.Format("第{0}行:移动类型{1}填写有误,只能填261、262。", rowCount, moveType)); } } #endregion #region 生效日期 string readEffectiveDate = ImportHelper.GetCellStringValue(row.GetCell(colEffectiveDate)); if (string.IsNullOrWhiteSpace(readEffectiveDate)) { businessException.AddMessage(string.Format("第{0}行:生效日期不能为空。", rowCount)); } else { if (!DateTime.TryParse(readEffectiveDate, out effectiveDate)) { businessException.AddMessage(string.Format("第{0}行:生效日期{1}填写有误.", rowCount, moveType)); continue; } if (prevEffeDate != null) { if (prevEffeDate.Value != effectiveDate) { businessException.AddMessage(string.Format("第{0}行:生效日期{1}与前一行生效日期{2}不同。", rowCount, effectiveDate, prevEffeDate.Value)); continue; } } prevEffeDate = effectiveDate; } #endregion #region 区域 regionCode = ImportHelper.GetCellStringValue(row.GetCell(colRegion)); if (string.IsNullOrWhiteSpace(regionCode)) { businessException.AddMessage(string.Format("第{0}行:区域不能为空。", rowCount)); } else { if (string.IsNullOrWhiteSpace(prevRegion)) { var regions = regionList.Where(l => l.Code == regionCode).ToList(); if (regions == null || regions.Count == 0) { businessException.AddMessage(string.Format("第{0}行:区域{1}填写有误.", rowCount, regionCode)); } } else { if (regionCode != prevRegion) { businessException.AddMessage(string.Format("第{0}行:区域{1}与前一行区域{2}不同。", rowCount, regionCode, prevRegion)); continue; } } prevRegion = regionCode; } #endregion #region 读取库位 locationCode = ImportHelper.GetCellStringValue(row.GetCell(colLocation)); if (!string.IsNullOrEmpty(locationCode)) { var locations = locationList.Where(l => l.Code == locationCode).ToList(); if (locations == null || locations.Count == 0) { businessException.AddMessage(string.Format("第{0}行:库位{1}不存在。", rowCount, locationCode)); } else if (locations.First().Region != regionCode) { businessException.AddMessage(string.Format("第{0}行:区域{1}不存在库位{2}。", rowCount, regionCode, locationCode)); } } else { businessException.AddMessage(string.Format("第{0}行:区域不能为空。", rowCount)); } #endregion #region Sap订单号 referenceNo = ImportHelper.GetCellStringValue(row.GetCell(colReferenceNo)); if (string.IsNullOrEmpty(referenceNo)) { businessException.AddMessage(string.Format("第{0}行:Sap订单号不能为空。", rowCount)); } else { //if (this.genericMgr.FindAllWithNativeSql<int>("select count(*) from SAP_ProdBomDet where AUFNR=? ", referenceNo.PadLeft(12, '0'))[0] == 0) //{ // businessException.AddMessage(string.Format("第{0}行:Sap订单号不存在ORD_OrderMstr_4表中。", rowCount)); //} } #endregion #region 物料编号 itemCode = ImportHelper.GetCellStringValue(row.GetCell(colItem)); if (string.IsNullOrWhiteSpace(itemCode)) { businessException.AddMessage(string.Format("第{0}行:物料编号不能为空。", rowCount)); } else { var items = itemList.Where(l => l.Code == itemCode).ToList(); if (items == null || items.Count == 0) { businessException.AddMessage(string.Format("第{0}行:物料编号{1}不存在.", rowCount, itemCode)); } else { item = items.First(); } } #endregion #region 数量 string readQty = ImportHelper.GetCellStringValue(row.GetCell(colQty)); if (string.IsNullOrEmpty(readQty)) { businessException.AddMessage(string.Format("第{0}行:数量不能为空。", rowCount)); } else { decimal.TryParse(readQty, out qty); if (qty <= 0) { businessException.AddMessage(string.Format("第{0}行:数量{1}只能为大于等于0的数字。", rowCount, readQty)); } } #endregion #endregion #region 填充数据 if (!businessException.HasMessage) { MiscOrderDetail miscOrderDetail = new MiscOrderDetail(); miscOrderDetail.MoveType = moveType; miscOrderDetail.EffectiveDate = effectiveDate; miscOrderDetail.Region = regionCode; miscOrderDetail.Location = locationCode; miscOrderDetail.SapOrderNo = string.IsNullOrWhiteSpace(referenceNo) ? null : referenceNo.PadLeft(12, '0'); miscOrderDetail.Item = item.Code; miscOrderDetail.ItemDescription = item.Description; miscOrderDetail.ReferenceItemCode = item.ReferenceCode; miscOrderDetail.Uom = item.Uom; miscOrderDetail.BaseUom = item.Uom; miscOrderDetail.UnitCount = item.UnitCount; miscOrderDetail.Qty = qty; activeDetailList.Add(miscOrderDetail); } #endregion } if (businessException.HasMessage) { throw businessException; } if (activeDetailList.Count == 0) { throw new BusinessException("导入的有效数据为0,请确实。"); } //261一张单 var outDetail = activeDetailList.Where(a => a.MoveType == "261").ToList(); if (outDetail != null && outDetail.Count > 0) { MiscOrderDetail fisrDet = outDetail.First(); MiscOrderMoveType miscOrderMoveType = genericMgr.FindAll<MiscOrderMoveType>("from MiscOrderMoveType as m where m.MoveType='261'")[0]; MiscOrderMaster miscMaster = new MiscOrderMaster(); miscMaster.Type = miscOrderMoveType.IOType; miscMaster.MoveType = miscOrderMoveType.MoveType; miscMaster.CancelMoveType = miscOrderMoveType.CancelMoveType; miscMaster.Region = fisrDet.Region; miscMaster.Location = fisrDet.Location; miscMaster.EffectiveDate = fisrDet.EffectiveDate; miscMaster.Consignment = false; miscMaster.ManufactureParty = null; miscMaster.IsScanHu = false; miscMaster.ReferenceNo = null; miscMaster.MiscOrderDetails = outDetail; miscMaster.WMSNo = wMSNo; //备注 activeMasterList.Add(miscMaster); } //262 一张单 var inDetail = activeDetailList.Where(a => a.MoveType == "262").ToList(); if (inDetail != null && inDetail.Count > 0) { MiscOrderDetail fisrInDet = inDetail.First(); MiscOrderMoveType miscOrderInMoveType = genericMgr.FindAll<MiscOrderMoveType>("from MiscOrderMoveType as m where m.MoveType='262'")[0]; var inMiscOrder = new MiscOrderMaster(); inMiscOrder.Type = miscOrderInMoveType.IOType; inMiscOrder.MoveType = miscOrderInMoveType.MoveType; inMiscOrder.CancelMoveType = miscOrderInMoveType.CancelMoveType; inMiscOrder.Region = fisrInDet.Region; inMiscOrder.Location = fisrInDet.Location; inMiscOrder.EffectiveDate = fisrInDet.EffectiveDate; inMiscOrder.Consignment = false; inMiscOrder.ManufactureParty = null; inMiscOrder.IsScanHu = false; inMiscOrder.ReferenceNo = null; inMiscOrder.MiscOrderDetails = inDetail; inMiscOrder.WMSNo = wMSNo; //备注 activeMasterList.Add(inMiscOrder); } if (businessException.HasMessage) { throw businessException; } string message = "生成单号"; foreach (var master in activeMasterList) { master.QualityType = com.Sconit.CodeMaster.QualityType.Qualified; activeDetailList = master.MiscOrderDetails; master.MiscOrderDetails = new List<MiscOrderDetail>(); this.CreateMiscOrder(master); BatchUpdateMiscOrderDetails(master, activeDetailList, null, null); this.genericMgr.FlushSession(); CloseMiscOrder(master, master.EffectiveDate); message += " " + master.MiscOrderNo + ";"; } MessageHolder.AddMessage(new Message(CodeMaster.MessageType.Info, message)); #endregion }
private IList<MiscOrderDetail> getNewMiscOrderDetailList(MiscOrderMaster miscOrderMaster,IList<InspectResult> inspectResultList) { IList<MiscOrderDetail> newMiscOrderDetailList = new List<MiscOrderDetail>(); foreach (InspectResult inspectResult in inspectResultList) { Item item = this.genericMgr.FindById<Item>(inspectResult.Item); MiscOrderDetail misc = new MiscOrderDetail(); misc.Item = item.Code; misc.ReferenceItemCode = item.ReferenceCode; misc.ItemDescription = item.Description; misc.UnitCount = item.UnitCount; misc.Uom = item.Uom; misc.BaseUom = item.Uom; misc.MiscOrderNo = miscOrderMaster.MiscOrderNo; misc.Location = inspectResult.CurrentLocation; misc.ReserveLine = inspectResult.ReserveLine; misc.ReserveNo = inspectResult.ReserveNo; misc.EBELN = inspectResult.IpNo; misc.EBELP = inspectResult.EBELP; misc.Qty = inspectResult.CurrentHandleQty; misc.ManufactureParty = inspectResult.ManufactureParty; // ReceiptDetail receiptDet = this.genericMgr.FindById<ReceiptDetail>(this.genericMgr.FindById<InspectDetail>(inspectResult.InspectDetailId).re); newMiscOrderDetailList.Add(misc); } return newMiscOrderDetailList; }
public void Import201202MiscOrder(Stream inputStream, string wMSNo, string moveTypeSet, string cancelMoveTypeSet,string miscType) { #region 导入数据 if (inputStream.Length == 0) { throw new BusinessException("Import.Stream.Empty"); } HSSFWorkbook workbook = new HSSFWorkbook(inputStream); ISheet sheet = workbook.GetSheetAt(0); IEnumerator rows = sheet.GetRowEnumerator(); ImportHelper.JumpRows(rows, 10); #region 列定义 int colMoveType = 1;//移动类型 //int colEffectiveDate = 2;//生效日期 //int colRegion = 3;//区域 int colLocation = 2;//库位 //int colReferenceNo = 5;//Sap订单号 int colItem = 3;//物料编号 int colQty = 4;//数量 int colCostCenter = 5;//成本中心 DateTime? prevEffeDate = null; string prevRegion = string.Empty; #endregion BusinessException businessException = new BusinessException(); int rowCount = 10; IList<MiscOrderDetail> activeDetailList = new List<MiscOrderDetail>(); IList<MiscOrderMaster> activeMasterList = new List<MiscOrderMaster>(); IList<Region> regionList = this.genericMgr.FindAll<Region>(); IList<Item> itemList = this.genericMgr.FindAll<Item>(); IList<Location> locationList = this.genericMgr.FindAll<Location>(); IList<Location> adjustocationList = this.genericMgr.FindAll<Location>(); IList<CostCenter> costCenterList = this.genericMgr.FindAll<CostCenter>(); //调整单Check库位权限 User user = SecurityContextHolder.Get(); string sql = @"select * from MD_Location as l where Code in(select distinct(LocFrom) from SCM_FlowMstr where type=4) and l.IsActive = ?"; IList<object> paramList = new List<object>(); paramList.Add(true); sql += " order by LEN(Code),Code "; adjustocationList = genericMgr.FindEntityWithNativeSql<Location>(sql, paramList.ToArray()) .Where(p => user.RegionPermissions.Contains(p.Region)).ToList(); // while (rows.MoveNext()) { rowCount++; HSSFRow row = (HSSFRow)rows.Current; if (!ImportHelper.CheckValidDataRow(row, 1, 9)) { break;//边界 } string moveType = string.Empty; DateTime effectiveDate = System.DateTime.Now; string regionCode = string.Empty; string locationCode = string.Empty; string costCenterCode = string.Empty; string referenceNo = string.Empty; string itemCode = string.Empty; decimal qty = 0; Item item = new Item(); #region 读取数据 #region 移动类型 moveType = ImportHelper.GetCellStringValue(row.GetCell(colMoveType)); if (string.IsNullOrWhiteSpace(moveType)) { businessException.AddMessage(string.Format("第{0}行:移动类型不能为空。", rowCount)); } else { if (moveType != moveTypeSet && moveType != cancelMoveTypeSet) { businessException.AddMessage(string.Format("第{0}行:移动类型{1}填写有误,只能填{2}、{3}。", rowCount, moveType, moveTypeSet, cancelMoveTypeSet)); } } #endregion //#region 生效日期 //string readEffectiveDate = ImportHelper.GetCellStringValue(row.GetCell(colEffectiveDate)); //if (string.IsNullOrWhiteSpace(readEffectiveDate)) //{ // businessException.AddMessage(string.Format("第{0}行:生效日期不能为空。", rowCount)); //} //else //{ // if (!DateTime.TryParse(readEffectiveDate, out effectiveDate)) // { // businessException.AddMessage(string.Format("第{0}行:生效日期{1}填写有误.", rowCount, moveType)); // continue; // } // if (prevEffeDate != null) // { // if (prevEffeDate.Value != effectiveDate) // { // businessException.AddMessage(string.Format("第{0}行:生效日期{1}与前一行生效日期{2}不同。", rowCount, effectiveDate, prevEffeDate.Value)); // continue; // } // } // prevEffeDate = effectiveDate; //} //#endregion //#region 区域 //regionCode = ImportHelper.GetCellStringValue(row.GetCell(colRegion)); //if (string.IsNullOrWhiteSpace(regionCode)) //{ // businessException.AddMessage(string.Format("第{0}行:区域不能为空。", rowCount)); //} //else //{ // if (string.IsNullOrWhiteSpace(prevRegion)) // { // var regions = regionList.Where(l => l.Code == regionCode).ToList(); // if (regions == null || regions.Count == 0) // { // businessException.AddMessage(string.Format("第{0}行:区域{1}填写有误.", rowCount, regionCode)); // } // } // else // { // if (regionCode != prevRegion) // { // businessException.AddMessage(string.Format("第{0}行:区域{1}与前一行区域{2}不同。", rowCount, regionCode, prevRegion)); // continue; // } // } // prevRegion = regionCode; //} //#endregion #region 读取库位 locationCode = ImportHelper.GetCellStringValue(row.GetCell(colLocation)); if (!string.IsNullOrEmpty(locationCode)) { var locations = locationList.Where(l => l.Code == locationCode).ToList(); if (locations == null || locations.Count == 0) { businessException.AddMessage(string.Format("第{0}行:库位{1}不存在。", rowCount, locationCode)); } //else if (locations.First().Region != regionCode) //{ // businessException.AddMessage(string.Format("第{0}行:区域{1}不存在库位{2}。", rowCount, regionCode, locationCode)); //} else { regionCode = locations[0].Region; } if (miscType == "AdjustOrder") { var adjustlocations = adjustocationList.Where(l => l.Code == locationCode).ToList(); if (adjustlocations == null || adjustlocations.Count == 0) { businessException.AddMessage(string.Format("第{0}行:用户没有调整库位{1}的权限。", rowCount, locationCode)); } } } else { //businessException.AddMessage(string.Format("第{0}行:区域不能为空。", rowCount)); } #endregion #region 成本中心 costCenterCode = ImportHelper.GetCellStringValue(row.GetCell(colCostCenter)); if (!string.IsNullOrEmpty(costCenterCode)) { var costCenters = costCenterList.Where(l => l.Code == costCenterCode).ToList(); if (costCenters == null || costCenters.Count == 0) { businessException.AddMessage(string.Format("第{0}行:成本中心{1}不存在。", rowCount, costCenterCode)); } else { costCenterCode = costCenters.ToList().FirstOrDefault().Code; } //else if (locations.First().Region != regionCode) //{ // businessException.AddMessage(string.Format("第{0}行:区域{1}不存在库位{2}。", rowCount, regionCode, locationCode)); //} } else if (moveTypeSet=="201") { businessException.AddMessage(string.Format("第{0}行:成本中心不能为空。", rowCount)); } #endregion //#region Sap订单号 //referenceNo = ImportHelper.GetCellStringValue(row.GetCell(colReferenceNo)); //if (string.IsNullOrEmpty(referenceNo)) //{ // businessException.AddMessage(string.Format("第{0}行:Sap订单号不能为空。", rowCount)); //} //else //{ // //if (this.genericMgr.FindAllWithNativeSql<int>("select count(*) from SAP_ProdBomDet where AUFNR=? ", referenceNo.PadLeft(12, '0'))[0] == 0) // //{ // // businessException.AddMessage(string.Format("第{0}行:Sap订单号不存在ORD_OrderMstr_4表中。", rowCount)); // //} //} //#endregion #region 物料编号 itemCode = ImportHelper.GetCellStringValue(row.GetCell(colItem)); if (string.IsNullOrWhiteSpace(itemCode)) { businessException.AddMessage(string.Format("第{0}行:物料编号不能为空。", rowCount)); } else { var items = itemList.Where(l => l.Code == itemCode).ToList(); if (items == null || items.Count == 0) { businessException.AddMessage(string.Format("第{0}行:物料编号{1}不存在.", rowCount, itemCode)); } else { item = items.First(); } } #endregion #region 数量 string readQty = ImportHelper.GetCellStringValue(row.GetCell(colQty)); if (string.IsNullOrEmpty(readQty)) { businessException.AddMessage(string.Format("第{0}行:数量不能为空。", rowCount)); } else { decimal.TryParse(readQty, out qty); if (qty <= 0) { businessException.AddMessage(string.Format("第{0}行:数量{1}只能为大于等于0的数字。", rowCount, readQty)); } } #endregion #endregion #region 填充数据 if (!businessException.HasMessage) { MiscOrderDetail miscOrderDetail = new MiscOrderDetail(); miscOrderDetail.MoveType = moveType; miscOrderDetail.EffectiveDate = effectiveDate; miscOrderDetail.Location = locationCode; miscOrderDetail.Region= regionCode; miscOrderDetail.Item = item.Code; miscOrderDetail.ItemDescription = item.Description; miscOrderDetail.ReferenceItemCode = item.ReferenceCode; miscOrderDetail.Uom = item.Uom; miscOrderDetail.BaseUom = item.Uom; miscOrderDetail.UnitCount = item.UnitCount; miscOrderDetail.Qty = qty; miscOrderDetail.CostCenter = costCenterCode; activeDetailList.Add(miscOrderDetail); } #endregion } if (businessException.HasMessage) { throw businessException; } if (activeDetailList.Count == 0) { throw new BusinessException("导入的有效数据为0,请确实。"); } //Merge details //201一张单 var allLocation = activeDetailList.Select(p => p.Location).Distinct(); foreach (var location in allLocation) { var outDetail = activeDetailList.Where(a => a.MoveType == moveTypeSet && a.Location==(string)location).ToList(); if (outDetail != null && outDetail.Count > 0) { MiscOrderDetail fisrDet = outDetail.First(); MiscOrderMoveType miscOrderMoveType = genericMgr.FindAll<MiscOrderMoveType>("from MiscOrderMoveType as m where m.MoveType =? ", moveTypeSet)[0]; MiscOrderMaster miscMaster = new MiscOrderMaster(); miscMaster.Type = miscOrderMoveType.IOType; miscMaster.MoveType = miscOrderMoveType.MoveType; miscMaster.CancelMoveType = miscOrderMoveType.CancelMoveType; miscMaster.Location = fisrDet.Location; miscMaster.Region = fisrDet.Region; miscMaster.EffectiveDate = fisrDet.EffectiveDate; miscMaster.IsScanHu = false; miscMaster.ReferenceNo = null; miscMaster.MiscOrderDetails = outDetail; miscMaster.WMSNo = wMSNo; //备注 miscMaster.CostCenter = fisrDet.CostCenter; miscMaster.SubType = miscType == "AdjustOrder" ? CodeMaster.MiscOrderSubType.SY05 : CodeMaster.MiscOrderSubType.COST; activeMasterList.Add(miscMaster); } //202 一张单 var inDetail = activeDetailList.Where(a => a.MoveType == cancelMoveTypeSet && a.Location == (string)location).ToList(); if (inDetail != null && inDetail.Count > 0) { MiscOrderDetail fisrInDet = inDetail.First(); MiscOrderMoveType miscOrderInMoveType = genericMgr.FindAll<MiscOrderMoveType>("from MiscOrderMoveType as m where m.MoveType =? ", cancelMoveTypeSet)[0]; var inMiscOrder = new MiscOrderMaster(); inMiscOrder.Type = miscOrderInMoveType.IOType; inMiscOrder.MoveType = miscOrderInMoveType.MoveType; inMiscOrder.CancelMoveType = miscOrderInMoveType.CancelMoveType; inMiscOrder.Location = fisrInDet.Location; inMiscOrder.Region = fisrInDet.Region; inMiscOrder.EffectiveDate = fisrInDet.EffectiveDate; inMiscOrder.IsScanHu = false; inMiscOrder.ReferenceNo = null; inMiscOrder.MiscOrderDetails = inDetail; inMiscOrder.WMSNo = wMSNo; //备注 inMiscOrder.CostCenter = fisrInDet.CostCenter; inMiscOrder.SubType = miscType == "AdjustOrder" ? CodeMaster.MiscOrderSubType.SY05 : CodeMaster.MiscOrderSubType.COST; activeMasterList.Add(inMiscOrder); } } if (businessException.HasMessage) { throw businessException; } string message = "生成单号"; foreach (var master in activeMasterList) { master.QualityType = com.Sconit.CodeMaster.QualityType.Qualified; activeDetailList = (from p in master.MiscOrderDetails group p by new { p.Item, p.ItemDescription, p.ReferenceItemCode, p.Uom, p.BaseUom, p.UnitCount, p.Location } into g select new MiscOrderDetail { Sequence = g.Max(p => p.Sequence), Item = g.Key.Item, ItemDescription = g.Key.ItemDescription, ReferenceItemCode = g.Key.ReferenceItemCode, Uom = g.Key.Uom, BaseUom = g.Key.BaseUom, UnitCount = g.Key.UnitCount, UnitQty = 1, Location = g.Key.Location, Qty = g.Sum(p => p.Qty), }).ToList(); master.MiscOrderDetails = new List<MiscOrderDetail>(); this.CreateMiscOrder(master); BatchUpdateMiscOrderDetails(master, activeDetailList, null, null); this.genericMgr.FlushSession(); master.MiscOrderDetails = null; //CloseMiscOrder(master, master.EffectiveDate); message += " " + master.MiscOrderNo + ";"; } MessageHolder.AddMessage(new Message(CodeMaster.MessageType.Info, message)); #endregion }
public void CancelMiscOrder(MiscOrderMaster miscOrderMaster) { this.CancelMiscOrder(miscOrderMaster, DateTime.Now); }
public void CloseMiscOrder(MiscOrderMaster miscOrderMaster) { this.CloseMiscOrder(miscOrderMaster, miscOrderMaster.EffectiveDate); }
public void BatchUpdateMiscOrderDetails(MiscOrderMaster miscOrderMaster, IList<string> addHuIdList, IList<string> deleteHuIdList) { if (miscOrderMaster.Status != CodeMaster.MiscOrderStatus.Create) { if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { throw new BusinessException("计划外出库单{0}的状态为{1}不能修改明细。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } else { throw new BusinessException("计划外入库单{0}的状态为{1}不能修改明细。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } } TryLoadMiscOrderDetails(miscOrderMaster); IList<MiscOrderLocationDetail> miscOrderLocationDetailList = TryLoadMiscOrderLocationDetails(miscOrderMaster); #region 新增计划外出入库明细 if (addHuIdList != null && addHuIdList.Count > 0) { #region 获取最大订单明细序号 string hql = "select max(Sequence) as seq from MiscOrderDetail where MiscOrderNo = ?"; IList maxSeqList = genericMgr.FindAll(hql, miscOrderMaster.MiscOrderNo); int maxSeq = maxSeqList != null && maxSeqList.Count > 0 && maxSeqList[0] != null ? (int)maxSeqList[0] : 0; #endregion #region 条码处理 #region 明细重复输入校验 #region 合并新增的HuId和原有的HuId IList<string> huIdList = new List<string>(); ((List<string>)huIdList).AddRange(addHuIdList); if (miscOrderLocationDetailList != null && miscOrderLocationDetailList.Count > 0) { ((List<string>)huIdList).AddRange(miscOrderLocationDetailList.Select(det => det.HuId).ToList()); } #endregion #region 检查是否重复 BusinessException businessException = new BusinessException(); var groupedHuIds = from huId in huIdList group huId by huId into result select new { HuId = result.Key, Count = result.Count() }; foreach (var groupedHuId in groupedHuIds.Where(g => g.Count > 1)) { businessException = new BusinessException(string.Format("重复扫描条码{0}。", groupedHuId.HuId)); } if (businessException.HasMessage) { throw businessException; } #endregion #endregion if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { #region 计划外出库 #region 库存占用 IList<InventoryOccupy> inventoryOccupyList = (from huId in addHuIdList select new InventoryOccupy { HuId = huId, //Location = miscOrderMaster.Location, 不指定库位 QualityType = miscOrderMaster.QualityType, OccupyType = CodeMaster.OccupyType.MiscOrder, OccupyReferenceNo = miscOrderMaster.MiscOrderNo }).ToList(); IList<LocationLotDetail> locationLotDetailList = this.locationDetailMgr.InventoryOccupy(inventoryOccupyList); #endregion #region 新增明细 foreach (LocationLotDetail locationLotDetail in locationLotDetailList) { MiscOrderDetail matchedMiscOrderDetail = null; #region 明细处理 if (miscOrderMaster.MiscOrderDetails != null && miscOrderMaster.MiscOrderDetails.Count > 0) { //查找匹配的明细行 matchedMiscOrderDetail = miscOrderMaster.MiscOrderDetails.Where(det => det.Item == locationLotDetail.Item && det.Uom == locationLotDetail.HuUom && det.UnitCount == locationLotDetail.UnitCount && det.Location == locationLotDetail.Location).SingleOrDefault(); } if (matchedMiscOrderDetail == null) { //没有找到明细行,新增明细 Item item = this.genericMgr.FindById<Item>(locationLotDetail.Item); //没有找到匹配的明细行,新增一行 matchedMiscOrderDetail = new MiscOrderDetail(); matchedMiscOrderDetail.MiscOrderNo = miscOrderMaster.MiscOrderNo; matchedMiscOrderDetail.Sequence = ++maxSeq; matchedMiscOrderDetail.Item = locationLotDetail.Item; matchedMiscOrderDetail.ItemDescription = item.Description; matchedMiscOrderDetail.ReferenceItemCode = item.ReferenceCode; matchedMiscOrderDetail.Uom = locationLotDetail.HuUom; matchedMiscOrderDetail.BaseUom = locationLotDetail.BaseUom; matchedMiscOrderDetail.UnitCount = locationLotDetail.UnitCount; matchedMiscOrderDetail.UnitQty = locationLotDetail.UnitQty; matchedMiscOrderDetail.Location = locationLotDetail.Location; //matchedMiscOrderDetail.ReserveNo = addMiscOrderDetail.ReserveNo; //matchedMiscOrderDetail.ReserveLine = addMiscOrderDetail.ReserveLine; matchedMiscOrderDetail.Qty = locationLotDetail.Qty; this.genericMgr.Create(matchedMiscOrderDetail); miscOrderMaster.MiscOrderDetails.Add(matchedMiscOrderDetail); } else { //找到明细行,更新数量 matchedMiscOrderDetail.Qty += locationLotDetail.Qty; this.genericMgr.Update(matchedMiscOrderDetail); } #endregion #region 库存明细新增 MiscOrderLocationDetail miscOrderLocationDetail = new MiscOrderLocationDetail(); miscOrderLocationDetail.MiscOrderNo = miscOrderMaster.MiscOrderNo; miscOrderLocationDetail.MiscOrderDetailId = matchedMiscOrderDetail.Id; miscOrderLocationDetail.MiscOrderDetailSequence = matchedMiscOrderDetail.Sequence; miscOrderLocationDetail.Item = locationLotDetail.Item; miscOrderLocationDetail.Uom = locationLotDetail.HuUom; miscOrderLocationDetail.HuId = locationLotDetail.HuId; miscOrderLocationDetail.LotNo = locationLotDetail.LotNo; miscOrderLocationDetail.IsCreatePlanBill = false; miscOrderLocationDetail.IsConsignment = locationLotDetail.IsConsignment; miscOrderLocationDetail.PlanBill = locationLotDetail.PlanBill; #region 查找寄售供应商 if (locationLotDetail.IsConsignment && locationLotDetail.PlanBill.HasValue) { miscOrderLocationDetail.ConsignmentSupplier = this.genericMgr.FindAll<string>("select Party from PlanBill where Id = ?", locationLotDetail.PlanBill.Value)[0]; } #endregion miscOrderLocationDetail.ActingBill = null; miscOrderLocationDetail.QualityType = locationLotDetail.QualityType; miscOrderLocationDetail.IsFreeze = locationLotDetail.IsFreeze; miscOrderLocationDetail.IsATP = locationLotDetail.IsATP; miscOrderLocationDetail.OccupyType = locationLotDetail.OccupyType; miscOrderLocationDetail.OccupyReferenceNo = locationLotDetail.OccupyReferenceNo; miscOrderLocationDetail.Qty = locationLotDetail.Qty; if (addHuIdList.Contains(miscOrderLocationDetail.HuId)) { this.genericMgr.Create(miscOrderLocationDetail); } #endregion } #endregion #endregion } else { #region 计划外入库 #region 检查条码状态 IList<HuStatus> huStatusList = this.huMgr.GetHuStatus(addHuIdList); foreach (string huId in addHuIdList) { HuStatus huStatus = huStatusList.Where(h => h.HuId == huId).SingleOrDefault(); if (huStatus == null) { businessException = new BusinessException(string.Format("条码{0}不存在。", huId)); } else if (huStatus.Status == CodeMaster.HuStatus.Location) { businessException = new BusinessException(string.Format("条码{0}在库位{1}中,不能计划外入库。", huStatus.HuId, huStatus.Location)); } else if (huStatus.Status == CodeMaster.HuStatus.Ip) { businessException = new BusinessException(string.Format("条码{0}为库位{1}至库位{2}的在途库存,不能计划外入库。", huStatus.HuId, huStatus.LocationFrom, huStatus.LocationTo)); } } if (businessException.HasMessage) { throw businessException; } #endregion #region 新增明细 foreach (HuStatus huStatus in huStatusList) { MiscOrderDetail matchedMiscOrderDetail = null; #region 明细处理 if (miscOrderMaster.MiscOrderDetails != null && miscOrderMaster.MiscOrderDetails.Count > 0) { //查找匹配的明细行 matchedMiscOrderDetail = miscOrderMaster.MiscOrderDetails .Where(det => det.Item == huStatus.Item && det.Uom == huStatus.Uom && det.UnitCount == huStatus.UnitCount) .SingleOrDefault(); } if (matchedMiscOrderDetail == null) { //没有找到明细行,新增明细//没有找到匹配的明细行,新增一行 Item item = this.genericMgr.FindById<Item>(huStatus.Item); matchedMiscOrderDetail = new MiscOrderDetail(); matchedMiscOrderDetail.MiscOrderNo = miscOrderMaster.MiscOrderNo; matchedMiscOrderDetail.Sequence = ++maxSeq; matchedMiscOrderDetail.Item = huStatus.Item; matchedMiscOrderDetail.ItemDescription = item.Description; matchedMiscOrderDetail.ReferenceItemCode = item.ReferenceCode; matchedMiscOrderDetail.Uom = huStatus.Uom; matchedMiscOrderDetail.BaseUom = huStatus.BaseUom; matchedMiscOrderDetail.UnitCount = huStatus.UnitCount; matchedMiscOrderDetail.UnitQty = huStatus.UnitQty; matchedMiscOrderDetail.ManufactureParty = huStatus.ManufactureParty; //matchedMiscOrderDetail.Location = //matchedMiscOrderDetail.ReserveNo = addMiscOrderDetail.ReserveNo; //matchedMiscOrderDetail.ReserveLine = addMiscOrderDetail.ReserveLine; matchedMiscOrderDetail.Qty = huStatus.Qty; this.genericMgr.Create(matchedMiscOrderDetail); miscOrderMaster.MiscOrderDetails.Add(matchedMiscOrderDetail); } else { //找到明细行,更新数量 matchedMiscOrderDetail.Qty += huStatus.Qty; this.genericMgr.Update(matchedMiscOrderDetail); } #endregion #region 库存明细新增 MiscOrderLocationDetail miscOrderLocationDetail = new MiscOrderLocationDetail(); miscOrderLocationDetail.MiscOrderNo = miscOrderMaster.MiscOrderNo; miscOrderLocationDetail.MiscOrderDetailId = matchedMiscOrderDetail.Id; miscOrderLocationDetail.MiscOrderDetailSequence = matchedMiscOrderDetail.Sequence; miscOrderLocationDetail.Item = huStatus.Item; miscOrderLocationDetail.Uom = huStatus.Uom; miscOrderLocationDetail.HuId = huStatus.HuId; miscOrderLocationDetail.LotNo = huStatus.LotNo; miscOrderLocationDetail.IsCreatePlanBill = false; miscOrderLocationDetail.IsConsignment = false; miscOrderLocationDetail.PlanBill = null; miscOrderLocationDetail.ConsignmentSupplier = null; miscOrderLocationDetail.ActingBill = null; miscOrderLocationDetail.QualityType = huStatus.QualityType; miscOrderLocationDetail.IsFreeze = false; miscOrderLocationDetail.IsATP = true; miscOrderLocationDetail.OccupyType = CodeMaster.OccupyType.None; miscOrderLocationDetail.OccupyReferenceNo = null; miscOrderLocationDetail.Qty = huStatus.Qty * huStatus.UnitQty; this.genericMgr.Create(miscOrderLocationDetail); #endregion } #endregion #endregion } #endregion } #endregion #region 删除计划外出入库明细 if (deleteHuIdList != null && deleteHuIdList.Count > 0) { #region 条码处理 #region 条码是否在计划外出入库单中存在检查 BusinessException businessException = new BusinessException(); foreach (string huId in deleteHuIdList) { if (miscOrderLocationDetailList == null || miscOrderLocationDetailList.Where(m => m.HuId == huId).Count() == 0) { if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { businessException.AddMessage("条码{0}在计划外出库单{1}中不存在。", huId, miscOrderMaster.MiscOrderNo); } else { businessException.AddMessage("条码{0}在计划外入库单{1}中不存在。", huId, miscOrderMaster.MiscOrderNo); } } } if (businessException.HasMessage) { throw businessException; } #endregion #region 循环删除 #region 取消占用 if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { this.locationDetailMgr.CancelInventoryOccupy(CodeMaster.OccupyType.MiscOrder, miscOrderMaster.MiscOrderNo, deleteHuIdList); } #endregion foreach (string huId in deleteHuIdList) { #region 扣减明细数量,删除库存明细 MiscOrderLocationDetail miscOrderLocationDetail = miscOrderLocationDetailList.Where(det => det.HuId == huId).Single(); MiscOrderDetail miscOrderDetail = miscOrderMaster.MiscOrderDetails.Where(det => det.Id == miscOrderLocationDetail.MiscOrderDetailId).Single(); miscOrderDetail.Qty -= miscOrderLocationDetail.Qty / miscOrderDetail.UnitQty; this.genericMgr.Update(miscOrderDetail); this.genericMgr.Delete(miscOrderLocationDetail); #endregion } #endregion #endregion } #endregion }
public ActionResult CreateMiscOrder(MiscOrderMaster miscOrderMaster, string[] reserveLines, string[] reserveNos, string[] sequences, string[] items, string[] workHours, string[] qtys) { try { if (items == null || items.Length == 0) { throw new BusinessException(Resources.EXT.ControllerLan.Con_DetailBeEmptyCanNotCreate); } if (miscOrderMaster.MoveType == "281" || miscOrderMaster.MoveType == "282") { if (reserveLines == null || reserveLines.Length == 0 || reserveNos == null || reserveNos.Length == 0) { throw new BusinessException(Resources.EXT.ControllerLan.Con_ReserveNumberAndReserveRowNumberCanNotBeEmpty); } } MiscOrderMoveType miscOrderMoveType = genericMgr.FindAll<MiscOrderMoveType>( "from MiscOrderMoveType as m where m.MoveType=? and m.SubType=? ", new object[] { miscOrderMaster.MoveType, com.Sconit.CodeMaster.MiscOrderSubType.SY03 })[0]; miscOrderMaster.Type = miscOrderMoveType.IOType; miscOrderMaster.SubType = miscOrderMoveType.SubType; miscOrderMaster.MoveType = miscOrderMoveType.MoveType; miscOrderMaster.CancelMoveType = miscOrderMoveType.CancelMoveType; miscOrderMaster.Status = CodeMaster.MiscOrderStatus.Create; miscOrderMaster.QualityType = CodeMaster.QualityType.Qualified; FlowMaster flow = this.genericMgr.FindById<FlowMaster>(miscOrderMaster.Flow); if (miscOrderMaster.MoveType == "281" || miscOrderMaster.MoveType == "282") { miscOrderMaster.Region = flow.PartyFrom; miscOrderMaster.Location = flow.LocationFrom; } else { miscOrderMaster.Region = flow.PartyTo; miscOrderMaster.Location = flow.LocationTo; } miscOrderMaster.MiscOrderDetails = TransferToMiscOrderDetail(reserveLines, reserveNos, sequences, items, workHours, qtys); SaveSuccessMessage(Resources.EXT.ControllerLan.Con_CreateSuccessfully); if (miscOrderMaster.WorkHour.HasValue) { decimal tailQty = miscOrderMaster.WorkHour.Value % miscOrderMaster.MiscOrderDetails.Count; decimal entireQty = (int)miscOrderMaster.WorkHour.Value / miscOrderMaster.MiscOrderDetails.Count; foreach (var miscDet in miscOrderMaster.MiscOrderDetails) { miscDet.WorkHour = entireQty; } var maxSeqDet = miscOrderMaster.MiscOrderDetails.OrderByDescending(p => p.Sequence).FirstOrDefault(); maxSeqDet.WorkHour = maxSeqDet.WorkHour + tailQty; //genericMgr.Update(miscOrderMaster.MiscOrderDetails); } miscOrderMgr.CreateMiscOrder(miscOrderMaster); ViewBag.miscOrderNo = miscOrderMaster.MiscOrderNo; ViewBag.IsShowReserve = (miscOrderMaster.MoveType == "281" || miscOrderMaster.MoveType == "282"); miscOrderMaster.WorkHour = miscOrderMaster.MiscOrderDetails.Sum(p=>p.WorkHour); if ((miscOrderMaster.MoveType == "581" || miscOrderMaster.MoveType == "582")) { string[] s = miscOrderMaster.WBS.Split(new char[] { '/' }); ViewBag.WBS = s[0]; ViewBag.WBSRow = s[0].Count() > 1 ? s[1] : ""; } return View("Edit", miscOrderMaster); } catch (Exception ex) { SaveErrorMessage(ex); return Json(null); } }
public void CloseMiscOrder(MiscOrderMaster miscOrderMaster, DateTime effectiveDate) { #region 检查 BusinessException businessException = new BusinessException(); if (miscOrderMaster.Status != CodeMaster.MiscOrderStatus.Create) { if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { businessException.AddMessage("计划外出库单{0}的状态为{1}不能确认。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } else { businessException.AddMessage("计划外入库单{0}的状态为{1}不能确认。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } } IList<MiscOrderDetail> miscOrderDetailList = TryLoadMiscOrderDetails(miscOrderMaster); if (miscOrderDetailList == null || miscOrderDetailList.Count() == 0) { if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { businessException.AddMessage("计划外出库单{0}明细为空。", miscOrderMaster.MiscOrderNo); } else { businessException.AddMessage("计划外入库单{0}明细为空。", miscOrderMaster.MiscOrderNo); } } else { foreach (MiscOrderDetail miscOrderDetail in miscOrderDetailList) { if (miscOrderDetail.Qty <= 0) { businessException.AddMessage("计划外入库单{0}明细行{1}的数量不能小于0。", miscOrderMaster.MiscOrderNo, miscOrderDetail.Sequence.ToString()); } } } if (businessException.HasMessage) { throw businessException; } businessException = CheckInventory(miscOrderDetailList, miscOrderMaster); if (businessException.HasMessage) { throw businessException; } #endregion User user = SecurityContextHolder.Get(); miscOrderMaster.CloseDate = DateTime.Now; miscOrderMaster.CloseUserId = user.Id; miscOrderMaster.CloseUserName = user.FullName; miscOrderMaster.Status = com.Sconit.CodeMaster.MiscOrderStatus.Close; this.genericMgr.Update(miscOrderMaster); //如果是退货的 直接转为出库 miscOrderMaster.Type = miscOrderMaster.Type == com.Sconit.CodeMaster.MiscOrderType.Return ? com.Sconit.CodeMaster.MiscOrderType.GI : miscOrderMaster.Type; IList<MiscOrderLocationDetail> miscOrderLocationDetailList = TryLoadMiscOrderLocationDetails(miscOrderMaster); foreach (MiscOrderDetail miscOrderDetail in miscOrderDetailList.OrderByDescending(det => det.ManufactureParty)) { IList<InventoryTransaction> inventoryTransactionList = this.locationDetailMgr.InventoryOtherInOut(miscOrderMaster, miscOrderDetail, effectiveDate); #region 新增、更新订单库存明细 var groupInventoryTransactionList = from trans in inventoryTransactionList group trans by new { Item = trans.Item, HuId = trans.HuId, IsCreatePlanBill = trans.IsCreatePlanBill, IsConsignment = trans.IsConsignment, PlanBill = trans.PlanBill, ActingBill = trans.ActingBill, QualityType = trans.QualityType, IsFreeze = trans.IsFreeze, IsATP = trans.IsATP, OccupyType = trans.OccupyType, OccupyReferenceNo = trans.OccupyReferenceNo, } into result select new { Item = result.Key.Item, HuId = result.Key.HuId, IsCreatePlanBill = result.Key.IsCreatePlanBill, IsConsignment = result.Key.IsConsignment, PlanBill = result.Key.PlanBill, ActingBill = result.Key.ActingBill, QualityType = result.Key.QualityType, IsFreeze = result.Key.IsFreeze, IsATP = result.Key.IsATP, OccupyType = result.Key.OccupyType, OccupyReferenceNo = result.Key.OccupyReferenceNo, Qty = result.Sum(trans => trans.Qty) }; foreach (var groupInventoryTransaction in groupInventoryTransactionList) { if (miscOrderMaster.IsScanHu) { #region 条码 MiscOrderLocationDetail miscOrderLocationDetail = miscOrderLocationDetailList.Where(m => m.HuId == groupInventoryTransaction.HuId).Single(); if (groupInventoryTransaction.ActingBill.HasValue) { miscOrderLocationDetail.IsConsignment = false; miscOrderLocationDetail.PlanBill = null; miscOrderLocationDetail.ActingBill = groupInventoryTransaction.ActingBill; } this.genericMgr.Update(miscOrderLocationDetail); #endregion } else { #region 数量 MiscOrderLocationDetail miscOrderLocationDetail = new MiscOrderLocationDetail(); miscOrderLocationDetail.MiscOrderNo = miscOrderMaster.MiscOrderNo; miscOrderLocationDetail.MiscOrderDetailId = miscOrderDetail.Id; miscOrderLocationDetail.MiscOrderDetailSequence = miscOrderDetail.Sequence; miscOrderLocationDetail.Item = groupInventoryTransaction.Item; miscOrderLocationDetail.Uom = miscOrderDetail.Uom; //miscOrderLocationDetail.HuId = locationLotDetail.HuId; //miscOrderLocationDetail.LotNo = locationLotDetail.LotNo; miscOrderLocationDetail.IsCreatePlanBill = groupInventoryTransaction.IsCreatePlanBill; miscOrderLocationDetail.IsConsignment = groupInventoryTransaction.IsConsignment; miscOrderLocationDetail.PlanBill = groupInventoryTransaction.PlanBill; //#region 查找寄售供应商 //if (inventoryTransaction.IsConsignment && inventoryTransaction.PlanBill.HasValue) //{ //miscOrderLocationDetail.ConsignmentSupplier = this.genericMgr.FindAll<string>("select Party from PlanBill where Id = ?", inventoryTransaction.PlanBill.Value).Single(); //} //#endregion miscOrderLocationDetail.ActingBill = groupInventoryTransaction.ActingBill; miscOrderLocationDetail.QualityType = groupInventoryTransaction.QualityType; miscOrderLocationDetail.IsFreeze = groupInventoryTransaction.IsFreeze; miscOrderLocationDetail.IsATP = groupInventoryTransaction.IsATP; miscOrderLocationDetail.OccupyType = groupInventoryTransaction.OccupyType; miscOrderLocationDetail.OccupyReferenceNo = groupInventoryTransaction.OccupyReferenceNo; miscOrderLocationDetail.Qty = groupInventoryTransaction.Qty; this.genericMgr.Create(miscOrderLocationDetail); #endregion } } #endregion } }
public void CloseMiscOrder(MiscOrderMaster miscOrderMaster) { this.CloseMiscOrder(miscOrderMaster, DateTime.Now); }
public BusinessException CheckInventory(IList<MiscOrderDetail> miscOrderDetails, MiscOrderMaster miscOrderMaster) { BusinessException businessException = new BusinessException(); List<LocationDetailView> locDetailView = new List<LocationDetailView>(); foreach (var loc in miscOrderDetails.Select(d => d.Location).Distinct()) { string partSuffix = this.genericMgr.FindAllWithNativeSql<string>("select PartSuffix from MD_Location where Code=?", loc)[0]; string searchSql = string.Format("select Location,Item,SUM(isnull(Qty,0)) as SumQty from INV_LocationLotDet_{0} where Location='{1}' and QualityType=0 group by Location,Item", partSuffix, loc); var searchResult = this.genericMgr.FindAllWithNativeSql<object[]>(searchSql); var currentResult = (from tak in searchResult select new LocationDetailView { Location = (string)tak[0], Item = (string)tak[1], Qty = (decimal)tak[2], }).ToList(); locDetailView.AddRange(currentResult); } foreach (var det in miscOrderDetails) { var cLoc = locDetailView.Where(l => l.Location == det.Location & l.Item == det.Item);//& l.IsCS == miscOrderMaster.Consignment if (cLoc != null && cLoc.Count() > 0) { if (miscOrderMaster.Type == com.Sconit.CodeMaster.MiscOrderType.GI)//出 { if (cLoc.First().Qty - det.Qty < 0) { businessException.AddMessage("物料{0}在库位{1}中库存不足。", det.Item, det.Location); } } else //入 { if (det.Qty < 0 && cLoc.First().Qty + det.Qty < 0) { businessException.AddMessage("物料{0}在库位{1}中库存不足。", det.Item, det.Location); } } } } //if (messageList.Count > 0) //{ //} return businessException; }
private IList<MiscOrderLocationDetail> TryLoadMiscOrderLocationDetails(MiscOrderMaster miscOrderMaster) { if (miscOrderMaster.MiscOrderNo != null) { TryLoadMiscOrderDetails(miscOrderMaster); IList<MiscOrderLocationDetail> miscOrderLocationDetailList = new List<MiscOrderLocationDetail>(); string hql = string.Empty; IList<object> para = new List<object>(); foreach (MiscOrderDetail miscOrderDetail in miscOrderMaster.MiscOrderDetails) { if (miscOrderDetail.MiscOrderLocationDetails != null && miscOrderDetail.MiscOrderLocationDetails.Count > 0) { ((List<MiscOrderLocationDetail>)miscOrderLocationDetailList).AddRange(miscOrderDetail.MiscOrderLocationDetails); } else { if (hql == string.Empty) { hql = "from MiscOrderLocationDetail where MiscOrderDetailId in (?"; } else { hql += ",?"; } para.Add(miscOrderDetail.Id); } } if (hql != string.Empty) { hql += ") order by MiscOrderDetailId"; ((List<MiscOrderLocationDetail>)miscOrderLocationDetailList).AddRange(this.genericMgr.FindAll<MiscOrderLocationDetail>(hql, para.ToArray())); } foreach (MiscOrderDetail miscOrderDetail in miscOrderMaster.MiscOrderDetails) { if (miscOrderDetail.MiscOrderLocationDetails == null || miscOrderDetail.MiscOrderLocationDetails.Count == 0) { miscOrderDetail.MiscOrderLocationDetails = miscOrderLocationDetailList.Where(o => o.MiscOrderDetailId == miscOrderDetail.Id).ToList(); } } return miscOrderLocationDetailList; } else { return null; } }
public void BatchUpdateMiscOrderDetails(MiscOrderMaster miscOrderMaster, IList<MiscOrderDetail> addMiscOrderDetailList, IList<MiscOrderDetail> updateMiscOrderDetailList, IList<MiscOrderDetail> deleteMiscOrderDetailList) { if (miscOrderMaster.Status != CodeMaster.MiscOrderStatus.Create) { if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { throw new BusinessException("计划外出库单{0}的状态为{1}不能修改明细。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } else { throw new BusinessException("计划外入库单{0}的状态为{1}不能修改明细。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } } #region 新增计划外出入库明细 if (addMiscOrderDetailList != null && addMiscOrderDetailList.Count > 0) { #region 获取最大订单明细序号 string hql = "select max(Sequence) as seq from MiscOrderDetail where MiscOrderNo = ?"; IList<object> maxSeqList = genericMgr.FindAll<object>(hql, miscOrderMaster.MiscOrderNo); int maxSeq = maxSeqList[0] != null ? (int)(maxSeqList[0]) : 0; #endregion #region 数量处理 foreach (MiscOrderDetail miscOrderDetail in addMiscOrderDetailList) { //Item item = this.genericMgr.FindById<Item>(miscOrderDetail.Item); miscOrderDetail.MiscOrderNo = miscOrderMaster.MiscOrderNo; miscOrderDetail.Sequence = ++maxSeq; //miscOrderDetail.Item = miscOrderDetail.Item; //miscOrderDetail.ItemDescription = item.Description; //miscOrderDetail.ReferenceItemCode = item.ReferenceCode; //miscOrderDetail.Uom = miscOrderDetail.Uom; //miscOrderDetail.BaseUom = item.Uom; //miscOrderDetail.UnitCount = miscOrderDetail.UnitCount; if (miscOrderDetail.Uom != miscOrderDetail.BaseUom) { miscOrderDetail.UnitQty = this.itemMgr.ConvertItemUomQty(miscOrderDetail.Item, miscOrderDetail.BaseUom, 1, miscOrderDetail.Uom); } else { miscOrderDetail.UnitQty = 1; } //miscOrderDetail.ReserveNo = miscOrderDetail.ReserveNo; //miscOrderDetail.ReserveLine = miscOrderDetail.ReserveLine; //miscOrderDetail.Qty = miscOrderDetail.Qty; this.genericMgr.Create(miscOrderDetail); if (miscOrderMaster.MiscOrderDetails == null) { miscOrderMaster.MiscOrderDetails = new List<MiscOrderDetail>(); } //miscOrderMaster.MiscOrderDetails.Add(miscOrderDetail); } #endregion } #endregion #region 修改计划外出入库明细 if (updateMiscOrderDetailList != null && updateMiscOrderDetailList.Count > 0) { foreach (MiscOrderDetail miscOrderDetail in updateMiscOrderDetailList) { if (miscOrderDetail.Uom != miscOrderDetail.BaseUom) { miscOrderDetail.UnitQty = this.itemMgr.ConvertItemUomQty(miscOrderDetail.Item, miscOrderDetail.BaseUom, 1, miscOrderDetail.Uom); } else { miscOrderDetail.UnitQty = 1; } this.genericMgr.Update(miscOrderDetail); } } #endregion #region 删除计划外出入库明细 if (deleteMiscOrderDetailList != null && deleteMiscOrderDetailList.Count > 0) { #region 数量处理 foreach (MiscOrderDetail miscOrderDetail in deleteMiscOrderDetailList) { //删除locationdet this.genericMgr.Delete("from MiscOrderLocationDetail as l where l.MiscOrderDetailId=" + miscOrderDetail.Id); this.genericMgr.Delete(miscOrderDetail); } #endregion } #endregion }
public ActionResult EditMiscOrder(MiscOrderMaster miscOrderMaster, string[] reserveLines, string[] reserveNos, string[] sequences, string[] items, string[] workHours, string[] qtys) { try { #region master 只能改备注字段 MiscOrderMaster oldMiscOrderMaster = this.genericMgr.FindById<MiscOrderMaster>(miscOrderMaster.MiscOrderNo); oldMiscOrderMaster.Note = miscOrderMaster.Note; oldMiscOrderMaster.WBS = miscOrderMaster.WBS; #endregion #region Detail IList<MiscOrderDetail> oldMiscOrderDetailList = this.genericMgr.FindAll<MiscOrderDetail> ("select d from MiscOrderDetail as d where d.MiscOrderNo=? ", miscOrderMaster.MiscOrderNo); IList<MiscOrderDetail> newMiscOrderDetailList = new List<MiscOrderDetail>(); IList<MiscOrderDetail> updateMiscOrderDetailList = new List<MiscOrderDetail>(); IList<MiscOrderDetail> deletedMiscOrderDetails = new List<MiscOrderDetail>(); var miscOrderDetails = TransferToMiscOrderDetail(reserveLines, reserveNos, sequences, items, workHours, qtys); foreach (var detail in miscOrderDetails) { var oldDetail = oldMiscOrderDetailList.FirstOrDefault(p => p.Item == detail.Item); if (oldDetail == null) { newMiscOrderDetailList.Add(detail); } else if (oldDetail.Qty != detail.Qty) { oldDetail.Qty = detail.Qty; updateMiscOrderDetailList.Add(oldDetail); } } foreach (var oldDetail in oldMiscOrderDetailList) { var detail = miscOrderDetails.FirstOrDefault(p => p.Item == oldDetail.Item); if (detail == null) { deletedMiscOrderDetails.Add(oldDetail); } } #endregion genericMgr.Update(oldMiscOrderMaster); miscOrderMgr.BatchUpdateMiscOrderDetails(oldMiscOrderMaster, newMiscOrderDetailList, updateMiscOrderDetailList, deletedMiscOrderDetails); SaveSuccessMessage(Resources.EXT.ControllerLan.Con_SavedSuccessfully); IList<MiscOrderDetail> miscOrderDets = genericMgr.FindAllIn<MiscOrderDetail>("from MiscOrderDetail where MiscOrderNo in (? ", new object[] { oldMiscOrderMaster.MiscOrderNo }); if (miscOrderMaster.WorkHour.HasValue) { decimal tailQty = miscOrderMaster.WorkHour.Value % miscOrderDets.Count; decimal entireQty = (int)miscOrderMaster.WorkHour.Value / miscOrderDets.Count; foreach (var miscDet in miscOrderDets) { miscDet.WorkHour = entireQty; } var maxSeqDet = miscOrderDets.OrderByDescending(p => p.Sequence).FirstOrDefault(); maxSeqDet.WorkHour = maxSeqDet.WorkHour + tailQty; foreach (var miscDet in miscOrderDets) { genericMgr.Update(miscDet); } } else { foreach (var miscDet in miscOrderDets) { miscDet.WorkHour = 0; genericMgr.Update(miscDet); } } ViewBag.IsShowReserve = (oldMiscOrderMaster.MoveType == "281"||oldMiscOrderMaster.MoveType == "282"); ViewBag.Flow = oldMiscOrderMaster.Flow; if ((oldMiscOrderMaster.MoveType == "581" || oldMiscOrderMaster.MoveType == "582")) { string[] s = miscOrderMaster.WBS.Split(new char[] { '/' }); ViewBag.WBS = s[0]; ViewBag.WBSRow = s[0].Count() > 1 ? s[1] : ""; } if (miscOrderMaster.WorkHour.HasValue) { oldMiscOrderMaster.WorkHour = miscOrderDetails.Sum(p => p.WorkHour); } return View("Edit", oldMiscOrderMaster); } catch (Exception ex) { SaveErrorMessage(ex); return Json(null); } }
public ActionResult CreateMiscOrder(MiscOrderMaster miscOrderMaster, string sequences, string items, string qtys) { try { if (items == string.Empty) { throw new BusinessException(Resources.EXT.ControllerLan.Con_DetailBeEmptyCanNotCreate); } MiscOrderMoveType miscOrderMoveType = genericMgr.FindAll<MiscOrderMoveType>( "from MiscOrderMoveType as m where m.MoveType=? and m.SubType=? ", new object[] { miscOrderMaster.MoveType, com.Sconit.CodeMaster.MiscOrderSubType.SY05 })[0]; //页面不加生效日期 //miscOrderMaster.EffectiveDate = DateTime.Now; miscOrderMaster.Type = miscOrderMoveType.IOType; miscOrderMaster.SubType = miscOrderMoveType.SubType; miscOrderMaster.MoveType = miscOrderMoveType.MoveType; miscOrderMaster.CancelMoveType = miscOrderMoveType.CancelMoveType; miscOrderMaster.Status = CodeMaster.MiscOrderStatus.Create; miscOrderMaster.Region = this.genericMgr.FindById<Location>(miscOrderMaster.Location).Region; string[] SequencesArray = sequences.Split(','); string[] ItemsArray = items.Split(','); string[] OrderedQtysArray = qtys.Split(','); IList<MiscOrderDetail> miscOrderDetails = new List<MiscOrderDetail>(); for (int i = 0; i < ItemsArray.Length; i++) { var item = this.genericMgr.FindById<Item>(ItemsArray[i]); MiscOrderDetail od = new MiscOrderDetail(); od.Sequence = Convert.ToInt32(SequencesArray[i]); od.Item = item.Code; od.ItemDescription = item.Description; od.ReferenceItemCode = item.ReferenceCode; od.Uom = item.Uom; od.BaseUom = item.Uom; od.UnitCount = item.UnitCount; od.UnitQty = 1; od.Qty = Convert.ToDecimal(OrderedQtysArray[i]); miscOrderDetails.Add(od); } miscOrderMaster.MiscOrderDetails = (from p in miscOrderDetails group p by new { p.Item, p.ItemDescription, p.ReferenceItemCode, p.Uom, p.BaseUom, p.UnitCount, } into g select new MiscOrderDetail { Sequence = g.Max(p => p.Sequence), Item = g.Key.Item, ItemDescription = g.Key.ItemDescription, ReferenceItemCode = g.Key.ReferenceItemCode, Uom = g.Key.Uom, BaseUom = g.Key.BaseUom, UnitCount = g.Key.UnitCount, UnitQty = 1, Qty = g.Sum(p => p.Qty), }).ToList(); miscOrderMgr.CreateMiscOrder(miscOrderMaster); SaveSuccessMessage(Resources.EXT.ControllerLan.Con_CreateSuccessfully); ViewBag.miscOrderNo = miscOrderMaster.MiscOrderNo; ViewBag.Flow = miscOrderMaster.Flow; return View("Edit", miscOrderMaster); } catch (Exception ex) { SaveErrorMessage(ex); return Json(null); } }
public ActionResult EditMiscOrder(MiscOrderMaster miscOrderMaster, string sequences, string items, string qtys) { try { #region master 只能改备注字段 MiscOrderMaster oldMiscOrderMaster = this.genericMgr.FindById<MiscOrderMaster>(miscOrderMaster.MiscOrderNo); oldMiscOrderMaster.Note = miscOrderMaster.Note; oldMiscOrderMaster.EffectiveDate = miscOrderMaster.EffectiveDate; oldMiscOrderMaster.QualityType = miscOrderMaster.QualityType; #endregion #region Detail IList<MiscOrderDetail> oldMiscOrderDetailList = this.genericMgr.FindAll<MiscOrderDetail> ("select d from MiscOrderDetail as d where d.MiscOrderNo=? ", miscOrderMaster.MiscOrderNo); IList<MiscOrderDetail> newMiscOrderDetailList = new List<MiscOrderDetail>(); IList<MiscOrderDetail> updateMiscOrderDetailList = new List<MiscOrderDetail>(); IList<MiscOrderDetail> deletedMiscOrderDetails = new List<MiscOrderDetail>(); IList<MiscOrderDetail> miscOrderDetails = new List<MiscOrderDetail>(); string[] SequencesArray = sequences.Split(','); string[] ItemsArray = items.Split(','); string[] OrderedQtysArray = qtys.Split(','); for (int i = 0; i < ItemsArray.Length; i++) { var item = this.genericMgr.FindById<Item>(ItemsArray[i]); MiscOrderDetail od = new MiscOrderDetail(); od.Sequence = Convert.ToInt32(SequencesArray[i]); od.Item = item.Code; od.ItemDescription = item.Description; od.ReferenceItemCode = item.ReferenceCode; od.Uom = item.Uom; od.BaseUom = item.Uom; od.UnitCount = item.UnitCount; od.UnitQty = 1; od.Qty = Convert.ToDecimal(OrderedQtysArray[i]); miscOrderDetails.Add(od); } var groupMiscOrderDetails = from p in miscOrderDetails group p by new { p.Item, p.ItemDescription, p.ReferenceItemCode, p.Uom, p.BaseUom, p.UnitCount, } into g select new MiscOrderDetail { Sequence = g.Max(p => p.Sequence), Item = g.Key.Item, ItemDescription = g.Key.ItemDescription, ReferenceItemCode = g.Key.ReferenceItemCode, Uom = g.Key.Uom, BaseUom = g.Key.BaseUom, UnitCount = g.Key.UnitCount, UnitQty = 1, Qty = g.Sum(p => p.Qty), }; foreach (var detail in groupMiscOrderDetails) { var oldDetail = oldMiscOrderDetailList.FirstOrDefault(p => p.Item == detail.Item); if (oldDetail == null) { newMiscOrderDetailList.Add(detail); } else if (oldDetail.Qty != detail.Qty) { oldDetail.Qty = detail.Qty; updateMiscOrderDetailList.Add(oldDetail); } } foreach (var oldDetail in oldMiscOrderDetailList) { var detail = groupMiscOrderDetails.FirstOrDefault(p => p.Item == oldDetail.Item); if (detail == null) { deletedMiscOrderDetails.Add(oldDetail); } } #endregion genericMgr.Update(oldMiscOrderMaster); miscOrderMgr.BatchUpdateMiscOrderDetails(oldMiscOrderMaster, newMiscOrderDetailList, updateMiscOrderDetailList, deletedMiscOrderDetails); SaveSuccessMessage(Resources.EXT.ControllerLan.Con_SavedSuccessfully); ViewBag.Flow = oldMiscOrderMaster.Flow; return View("Edit", oldMiscOrderMaster); } catch (Exception ex) { SaveErrorMessage(ex); return Json(null); } }
public void DeleteMiscOrder(MiscOrderMaster miscOrderMaster) { if (miscOrderMaster.Status != CodeMaster.MiscOrderStatus.Create) { if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { throw new BusinessException("计划外出库单{0}的状态为{1}不能删除。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } else { throw new BusinessException("计划外入库单{0}的状态为{1}不能删除。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } } if (miscOrderMaster.IsScanHu) { IList<MiscOrderLocationDetail> miscOrderLocationDetailList = TryLoadMiscOrderLocationDetails(miscOrderMaster); if (miscOrderLocationDetailList != null && miscOrderLocationDetailList.Count > 0) { this.genericMgr.Delete<MiscOrderLocationDetail>(miscOrderLocationDetailList); } } IList<MiscOrderDetail> miscOrderDetailList = TryLoadMiscOrderDetails(miscOrderMaster); if (miscOrderDetailList != null && miscOrderDetailList.Count > 0) { this.genericMgr.Delete<MiscOrderDetail>(miscOrderDetailList); } this.genericMgr.Delete(miscOrderMaster); }
private bool CheckMiscOrderDetail(MiscOrderMaster miscOrderMaster, MiscOrderDetail miscOrderDetail) { if (string.IsNullOrEmpty(miscOrderDetail.Item)) { throw new BusinessException(Resources.EXT.ControllerLan.Con_DetailRowItemCanNotBeEmpty); } if (miscOrderDetail.Qty == 0) { throw new BusinessException(Resources.EXT.ControllerLan.Con_DetailRowGapQuantityCanNotBeEmpty); } if (miscOrderDetail.Qty < 0) { //throw new BusinessException("明细行差异数量不能小于0的数字"); } return true; }
public void CloseMiscOrder(MiscOrderMaster miscOrderMaster, DateTime effectiveDate) { #region 检查 BusinessException businessException = new BusinessException(); if (miscOrderMaster.Status != CodeMaster.MiscOrderStatus.Create) { if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { businessException.AddMessage("计划外出库单{0}的状态为{1}不能确认。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } else { businessException.AddMessage("计划外入库单{0}的状态为{1}不能确认。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } } IList<MiscOrderDetail> miscOrderDetailList = TryLoadMiscOrderDetails(miscOrderMaster); if (miscOrderDetailList == null || miscOrderDetailList.Count() == 0) { if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { businessException.AddMessage("计划外出库单{0}明细为空。", miscOrderMaster.MiscOrderNo); } else { businessException.AddMessage("计划外入库单{0}明细为空。", miscOrderMaster.MiscOrderNo); } } else { foreach (MiscOrderDetail miscOrderDetail in miscOrderDetailList) { if (miscOrderDetail.Qty <= 0) { businessException.AddMessage("计划外入库单{0}明细行{1}的数量不能小于0。", miscOrderMaster.MiscOrderNo, miscOrderDetail.Sequence.ToString()); } } } if (businessException.HasMessage) { throw businessException; } #endregion User user = SecurityContextHolder.Get(); miscOrderMaster.CloseDate = DateTime.Now; miscOrderMaster.CloseUserId = user.Id; miscOrderMaster.CloseUserName = user.FullName; miscOrderMaster.Status = com.Sconit.CodeMaster.MiscOrderStatus.Close; this.genericMgr.Update(miscOrderMaster); //后加工废品报工不影响库存 if (miscOrderMaster.SubType == CodeMaster.MiscOrderSubType.MES27) { return; } // IList<MiscOrderLocationDetail> miscOrderLocationDetailList = TryLoadMiscOrderLocationDetails(miscOrderMaster); foreach (MiscOrderDetail miscOrderDetail in miscOrderDetailList.OrderByDescending(det => det.ManufactureParty)) { miscOrderDetail.ManufactureParty = miscOrderMaster.IsCs ? miscOrderDetail.ManufactureParty : null; IList<InventoryTransaction> inventoryTransactionList = this.locationDetailMgr.InventoryOtherInOut(miscOrderMaster, miscOrderDetail, effectiveDate); #region 新增、更新订单库存明细 foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { if (miscOrderMaster.IsScanHu) { #region 条码 MiscOrderLocationDetail miscOrderLocationDetail = miscOrderLocationDetailList.Where(m => m.HuId == inventoryTransaction.HuId).Single(); if (inventoryTransaction.ActingBill.HasValue) { miscOrderLocationDetail.IsConsignment = false; miscOrderLocationDetail.PlanBill = null; miscOrderLocationDetail.ActingBill = inventoryTransaction.ActingBill; } this.genericMgr.Update(miscOrderLocationDetail); #endregion } else { #region 数量 MiscOrderLocationDetail miscOrderLocationDetail = new MiscOrderLocationDetail(); miscOrderLocationDetail.MiscOrderNo = miscOrderMaster.MiscOrderNo; miscOrderLocationDetail.MiscOrderDetailId = miscOrderDetail.Id; miscOrderLocationDetail.MiscOrderDetailSequence = miscOrderDetail.Sequence; miscOrderLocationDetail.Item = inventoryTransaction.Item; miscOrderLocationDetail.Uom = miscOrderDetail.Uom; //miscOrderLocationDetail.HuId = locationLotDetail.HuId; //miscOrderLocationDetail.LotNo = locationLotDetail.LotNo; miscOrderLocationDetail.IsCreatePlanBill = inventoryTransaction.IsCreatePlanBill; miscOrderLocationDetail.IsConsignment = inventoryTransaction.IsConsignment; miscOrderLocationDetail.PlanBill = inventoryTransaction.PlanBill; #region 查找寄售供应商 if (inventoryTransaction.IsConsignment && inventoryTransaction.PlanBill.HasValue) { miscOrderLocationDetail.ConsignmentSupplier = this.genericMgr.FindAll<string>("select Party from PlanBill where Id = ?", inventoryTransaction.PlanBill.Value).Single(); } #endregion miscOrderLocationDetail.ActingBill = null; miscOrderLocationDetail.QualityType = inventoryTransaction.QualityType; miscOrderLocationDetail.IsFreeze = inventoryTransaction.IsFreeze; miscOrderLocationDetail.IsATP = inventoryTransaction.IsATP; miscOrderLocationDetail.OccupyType = inventoryTransaction.OccupyType; miscOrderLocationDetail.OccupyReferenceNo = inventoryTransaction.OccupyReferenceNo; miscOrderLocationDetail.Qty = inventoryTransaction.Qty; this.genericMgr.Create(miscOrderLocationDetail); #endregion } } #endregion } }
public PlanBill CreatePlanBill(MiscOrderMaster miscOrderMaster, MiscOrderDetail miscOrderDetail, MiscOrderLocationDetail miscOrderLocationDetail, DateTime effectiveDate) { PlanBill planBill = new PlanBill(); planBill.OrderNo = miscOrderMaster.MiscOrderNo; planBill.ReceiptNo = miscOrderMaster.MiscOrderNo; planBill.ExternalReceiptNo = miscOrderMaster.ReferenceNo; planBill.Type = com.Sconit.CodeMaster.BillType.Procurement; planBill.Party = miscOrderDetail.ManufactureParty; planBill.Item = miscOrderDetail.Item; planBill.ItemDescription = miscOrderDetail.ItemDescription; planBill.Uom = miscOrderDetail.Uom; planBill.UnitCount = miscOrderDetail.UnitCount; planBill.BillTerm = CodeMaster.OrderBillTerm.OnlineBilling; PartyAddress partyAddress = this.genericMgr.FindAll<PartyAddress>( "from PartyAddress as pa where pa.Party = ? and pa.Type = ? order by IsPrimary desc,Sequence asc ", new object[] { planBill.Party, CodeMaster.AddressType.BillAddress }, 0, 1).FirstOrDefault(); if (partyAddress == null) { throw new BusinessException(Resources.EXT.ServiceLan.TheBillAddressNotSpecialSupplier, planBill.Party); } planBill.BillAddress = partyAddress.Address.Code; planBill.PlanAmount = 0; int refId = 0; if (miscOrderMaster.IsScanHu) { planBill.PlanQty = miscOrderLocationDetail.Qty; planBill.UnitQty = miscOrderDetail.UnitQty; planBill.HuId = miscOrderLocationDetail.HuId; refId = miscOrderLocationDetail.Id; } else { planBill.PlanQty = miscOrderDetail.Qty; planBill.UnitQty = miscOrderDetail.UnitQty; refId = miscOrderDetail.Id; } planBill.LocationFrom = string.IsNullOrWhiteSpace(miscOrderDetail.Location) ? miscOrderMaster.Location : miscOrderDetail.Location; planBill.EffectiveDate = effectiveDate; this.genericMgr.Create(planBill); this.RecordPlanBillTransaction(planBill, effectiveDate, refId, false); return planBill; }
public void CancelMiscOrder(MiscOrderMaster miscOrderMaster, DateTime effectiveDate) { effectiveDate = miscOrderMaster.EffectiveDate; if (miscOrderMaster.Status != CodeMaster.MiscOrderStatus.Close) { if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { throw new BusinessException("计划外出库单{0}的状态为{1}不能冲销。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } else { throw new BusinessException("计划外入库单{0}的状态为{1}不能冲销。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } } TryLoadMiscOrderLocationDetails(miscOrderMaster); User user = SecurityContextHolder.Get(); miscOrderMaster.CancelDate = DateTime.Now; miscOrderMaster.CancelUserId = user.Id; miscOrderMaster.CancelUserName = user.FullName; miscOrderMaster.Status = com.Sconit.CodeMaster.MiscOrderStatus.Cancel; this.genericMgr.Update(miscOrderMaster); //后加工废品报工不影响库存 if (miscOrderMaster.SubType == CodeMaster.MiscOrderSubType.MES27) { return; } // this.locationDetailMgr.CancelInventoryOtherInOut(miscOrderMaster, effectiveDate); }
public void BatchUpdateMiscLocationOrderDetails(MiscOrderMaster miscOrderMaster, IList<MiscOrderDetail> addMiscOrderDetailList, IList<MiscOrderDetail> updateMiscOrderDetailList, IList<MiscOrderLocationDetail> deleteMiscOrderLocationDetailList) { if (miscOrderMaster.Status != CodeMaster.MiscOrderStatus.Create) { if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI) { throw new BusinessException("计划外出库单{0}的状态为{1}不能修改明细。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } else { throw new BusinessException("计划外入库单{0}的状态为{1}不能修改明细。", miscOrderMaster.MiscOrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.MiscOrderStatus, ((int)miscOrderMaster.Status).ToString())); } } #region 新增计划外出入库明细 if (addMiscOrderDetailList != null && addMiscOrderDetailList.Count > 0) { #region 获取最大订单明细序号 string hql = "select max(Sequence) as seq from MiscOrderDetail where MiscOrderNo = ?"; IList<object> maxSeqList = genericMgr.FindAll<object>(hql, miscOrderMaster.MiscOrderNo); int maxSeq = maxSeqList[0] != null ? (int)(maxSeqList[0]) : 0; #endregion #region 数量处理 foreach (MiscOrderDetail miscOrderDetail in addMiscOrderDetailList) { //Item item = this.genericMgr.FindById<Item>(miscOrderDetail.Item); miscOrderDetail.MiscOrderNo = miscOrderMaster.MiscOrderNo; miscOrderDetail.Sequence = ++maxSeq; //miscOrderDetail.Item = miscOrderDetail.Item; //miscOrderDetail.ItemDescription = item.Description; //miscOrderDetail.ReferenceItemCode = item.ReferenceCode; //miscOrderDetail.Uom = miscOrderDetail.Uom; //miscOrderDetail.BaseUom = item.Uom; //miscOrderDetail.UnitCount = miscOrderDetail.UnitCount; if (miscOrderDetail.Uom != miscOrderDetail.BaseUom) { miscOrderDetail.UnitQty = this.itemMgr.ConvertItemUomQty(miscOrderDetail.Item, miscOrderDetail.BaseUom, 1, miscOrderDetail.Uom); } else { miscOrderDetail.UnitQty = 1; } //miscOrderDetail.ReserveNo = miscOrderDetail.ReserveNo; //miscOrderDetail.ReserveLine = miscOrderDetail.ReserveLine; //miscOrderDetail.Qty = miscOrderDetail.Qty; this.genericMgr.Create(miscOrderDetail); if (miscOrderMaster.MiscOrderDetails == null) { miscOrderMaster.MiscOrderDetails = new List<MiscOrderDetail>(); } //miscOrderMaster.MiscOrderDetails.Add(miscOrderDetail); } #endregion } #endregion #region 修改计划外出入库明细 if (updateMiscOrderDetailList != null && updateMiscOrderDetailList.Count > 0) { foreach (MiscOrderDetail miscOrderDetail in updateMiscOrderDetailList) { if (miscOrderDetail.Uom != miscOrderDetail.BaseUom) { miscOrderDetail.UnitQty = this.itemMgr.ConvertItemUomQty(miscOrderDetail.Item, miscOrderDetail.BaseUom, 1, miscOrderDetail.Uom); } else { miscOrderDetail.UnitQty = 1; } this.genericMgr.Update(miscOrderDetail); } } #endregion #region 删除计划外出入库明细 //删除OrderDet IList<string> para = new List<string>(); para.Add(deleteMiscOrderLocationDetailList.FirstOrDefault().MiscOrderNo); //para.Add(miscOrderLocationDetail.Item); IList<MiscOrderLocationDetail> miscOrderLocationDetails = genericMgr.FindAll<MiscOrderLocationDetail>(@" from MiscOrderLocationDetail as m where m.MiscOrderNo = ? ", para); var deleteItemCount = from p in deleteMiscOrderLocationDetailList group p by p.Item into result select new { Item = result.Key, OrderdetId = result.FirstOrDefault().MiscOrderDetailId, Count = result.Count() }; var miscOrderDetailCount = from p in miscOrderLocationDetails group p by p.Item into result select new { Item = result.Key, OrderdetId = result.FirstOrDefault().MiscOrderDetailId, Count = result.Count() }; var needToDeleteItems = from cc in deleteItemCount from cd in miscOrderDetailCount where cc.Item == cd.Item && cc.Count == cd.Count select new { cc.Item, cc.OrderdetId }; if (deleteMiscOrderLocationDetailList != null && deleteMiscOrderLocationDetailList.Count > 0) { #region 数量处理 foreach (MiscOrderLocationDetail miscOrderLocationDetail in deleteMiscOrderLocationDetailList) { //删除locationdet this.genericMgr.DeleteById<MiscOrderLocationDetail>(miscOrderLocationDetail.Id); //this.genericMgr.Delete("from MiscOrderLocationDetail as l where l.MiscOrderDetailId=" + miscOrderDetail.Id); } #endregion } if ((needToDeleteItems != null && needToDeleteItems.ToList().Count() > 0)) { foreach (var needToDeleteItem in needToDeleteItems.Select(p => new { p.Item, p.OrderdetId }).Distinct().ToList()) { this.genericMgr.DeleteById<MiscOrderDetail>(needToDeleteItem.OrderdetId); } } #endregion }
public void CreateReturnOrder(MiscOrderMaster miscOrderMaster, string handleResult, IList<InspectResult> inspectResultList) { #region 创建不合格品单 RejectMaster rejectMaster = this.CreateRejectMaster((com.Sconit.CodeMaster.HandleResult)(Convert.ToInt32(handleResult)), inspectResultList); this.ReleaseRejectMaster(rejectMaster.RejectNo); #endregion #region 创建计划外出库单 miscOrderMgr.CreateMiscOrder(miscOrderMaster); IList<MiscOrderDetail> newMiscOrderDetailList = getNewMiscOrderDetailList(miscOrderMaster, inspectResultList); miscOrderMgr.BatchUpdateMiscOrderDetails(miscOrderMaster.MiscOrderNo, newMiscOrderDetailList, (IList<MiscOrderDetail>)new List<MiscOrderDetail>(), (IList<MiscOrderDetail>)new List<MiscOrderDetail>()); this.genericMgr.FlushSession(); miscOrderMgr.CloseMiscOrder(miscOrderMaster); #endregion }
private IList<MiscOrderDetail> TryLoadMiscOrderDetails(MiscOrderMaster miscOrderMaster) { if (!string.IsNullOrWhiteSpace(miscOrderMaster.MiscOrderNo)) { if (miscOrderMaster.MiscOrderDetails == null) { string hql = "from MiscOrderDetail where MiscOrderNo = ? order by Sequence"; miscOrderMaster.MiscOrderDetails = this.genericMgr.FindAll<MiscOrderDetail>(hql, miscOrderMaster.MiscOrderNo); } return miscOrderMaster.MiscOrderDetails; } else { return null; } }
public string GetMiscOrderNo(MiscOrderMaster miscOrderMaster) { SqlParameter[] parm = new SqlParameter[6]; parm[0] = new SqlParameter("@Type", SqlDbType.TinyInt); parm[0].Value = miscOrderMaster.Type; parm[1] = new SqlParameter("@IsScanHu", SqlDbType.Bit); parm[1].Value = miscOrderMaster.IsScanHu; parm[2] = new SqlParameter("@QualityType", SqlDbType.TinyInt); parm[2].Value = miscOrderMaster.QualityType; parm[3] = new SqlParameter("@Region", SqlDbType.VarChar, 50); parm[3].Value = miscOrderMaster.Region; parm[4] = new SqlParameter("@Location", SqlDbType.VarChar, 50); parm[4].Value = miscOrderMaster.Location; parm[5] = new SqlParameter("@MisNo", SqlDbType.VarChar, 100); parm[5].Direction = ParameterDirection.InputOutput; sqlDao.ExecuteStoredProcedure("USP_GetDocNo_MIS", parm); return parm[5].Value.ToString(); }
public void MiscOrder2InvTrans(TableIndex tableIndex, MiscOrderMaster miscOrderMaster, IList<MiscOrderDetail> miscOrderDetailList, IList<MiscOrderLocationDetail> miscOrderLocationDetailList, List<ErrorMessage> errorMessageList, int batchNo, IList<object[]> tcodeMoveTypes, IList<Entity.MD.Region> regionList, IList<Entity.MD.Location> locationList) { IList<InvTrans> invTransList = new List<InvTrans>(); IList<InvLoc> invLocList = new List<InvLoc>(); if (miscOrderLocationDetailList != null) { string fRBNR = this.GenerateMiscOrderNo(); foreach (var miscOrderLocationDetail in miscOrderLocationDetailList) { MiscOrderDetail miscOrderDetail = miscOrderDetailList.Where(det => det.Id == miscOrderLocationDetail.MiscOrderDetailId).Single(); InvTrans invTrans = new InvTrans(); invTrans.BatchNo = batchNo; invTrans.TCODE = GetTcode(tcodeMoveTypes, miscOrderMaster.MoveType); ////移动类型 if (miscOrderMaster.Status == CodeMaster.MiscOrderStatus.Cancel) { invTrans.BWART = miscOrderMaster.CancelMoveType; } else { invTrans.BWART = miscOrderMaster.MoveType; } ////凭证日期 invTrans.BLDAT = miscOrderMaster.CreateDate.ToString("yyyyMMdd"); ////过账日期 invTrans.BUDAT = miscOrderMaster.EffectiveDate.ToString("yyyyMMdd"); ////PO号码 //invTrans.EBELN = miscOrderMaster.MiscOrderNo; ////PO行数 //invTrans.EBELP = miscOrderLocationDetail.MiscOrderDetailId.ToString(); ////DN号码 //invTrans.VBELN =miscOrderLocationDetail. ////DN行数 //invTrans.POSNR =miscOrderLocationDetail. //string location = miscOrderLocationDetail. if (invTrans.BWART == "301" || invTrans.BWART == "302" || invTrans.BWART == "303" || invTrans.BWART == "304" || invTrans.BWART == "305" || invTrans.BWART == "306") { if (miscOrderMaster.Type == CodeMaster.MiscOrderType.GI)//出库 { //例子 // 301/302 对于从江北发往双桥 // 工厂WERKS:0084, 库位LGORT:1000, 收货工厂UMWRK:0085, 收货地点UMLGO:F80X // 跨工厂移库 来源工厂 invTrans.WERKS = GetPlant(regionList, miscOrderMaster.Region);//0084 ////库存地点 invTrans.LGORT = GetSapLocation(locationList, miscOrderDetail.Location == null ? miscOrderMaster.Location : miscOrderDetail.Location);//1000 ////跨工厂移库 收货地点 invTrans.UMLGO = miscOrderMaster.ReceiveLocation;//0085 ////收货工厂 invTrans.UMWRK = miscOrderMaster.DeliverRegion;//F80X } else { //例子:从双桥发往江北的 //计划外入库 区域Region:LOC(0084),发货库位ReceiveLocation:F80X,发货工厂DeliverRegion:0085,库位Loc:LOC(1000) //SAP字段 工厂WERKS:0085, 库位LGORT:F80X, 收货工厂UMWRK:0084, 收货地点UMLGO:1000 ////跨工厂移库 来源工厂 invTrans.WERKS = miscOrderMaster.DeliverRegion;//0085 ////库存地点 invTrans.LGORT = miscOrderMaster.ReceiveLocation;//F80X ////收货工厂 invTrans.UMWRK = GetPlant(regionList, miscOrderMaster.Region);//0084 ////跨工厂移库 收货地点 invTrans.UMLGO = GetSapLocation(locationList, miscOrderDetail.Location == null ? miscOrderMaster.Location : miscOrderDetail.Location);//1000 } } else { ////跨工厂移库 来源工厂 invTrans.WERKS = GetPlant(regionList, miscOrderMaster.Region); ////库存地点 invTrans.LGORT = GetSapLocation(locationList, miscOrderDetail.Location == null ? miscOrderMaster.Location : miscOrderDetail.Location); } ////操作类型 invTrans.OLD = "I"; ////物料号码 invTrans.MATNR = miscOrderLocationDetail.Item; ////数量 invTrans.ERFMG = Math.Abs(miscOrderLocationDetail.Qty); //取绝对值 ////单位 invTrans.ERFME = miscOrderLocationDetail.Uom; ////移动原因 invTrans.GRUND = miscOrderMaster.Note; ////成本中心 var costCenter = string.IsNullOrWhiteSpace(miscOrderDetail.CostCenter) ? miscOrderMaster.CostCenter : miscOrderDetail.CostCenter; invTrans.KOSTL = costCenter != null ? this.GenerateSapCostCenter(costCenter) : null; ////WBS invTrans.POSID = string.IsNullOrWhiteSpace( miscOrderDetail.WBS)?miscOrderMaster.WBS:miscOrderDetail.WBS; ////reserveno //invTrans.RSNUM = miscOrderMaster.ReserveNo; invTrans.RSNUM =string.IsNullOrWhiteSpace( miscOrderDetail.ReserveNo)?miscOrderMaster.ReserveNo:miscOrderDetail.ReserveNo; ////reserveline //invTrans.RSPOS = miscOrderDetail.ReserveLine; invTrans.RSPOS = string.IsNullOrWhiteSpace(miscOrderDetail.ReserveLine)?miscOrderDetail.ReserveLine:miscOrderDetail.ReserveLine; ////根据MiscOrderDetail是否记录供应商来判断是否要记录K if (miscOrderDetail.ManufactureParty != null && miscOrderDetail.ManufactureParty != string.Empty) { invTrans.LIFNR = miscOrderDetail.ManufactureParty; invTrans.SOBKZ = "K"; } else { invTrans.LIFNR = miscOrderMaster.ManufactureParty; } ////WMS号码 invTrans.FRBNR = fRBNR; //如果是联合主键 ////WMS行数 invTrans.SGTXT = miscOrderLocationDetail.Id.ToString(); ////库存类型 //invTrans.INSMK =miscOrderLocationDetail. ////送货单号 //invTrans.XABLN = miscOrderLocationDetail.IpNo; ////内部订单 if (invTrans.BWART == "261" || invTrans.BWART == "262") invTrans.AUFNR = miscOrderDetail.SapOrderNo; else invTrans.AUFNR = miscOrderMaster.ReferenceNo; ////收货物料 //invTrans.UMMAT =miscOrderLocationDetail. invTrans.XBLNR = miscOrderMaster.MiscOrderNo; invTrans.OrderNo = miscOrderMaster.MiscOrderNo; invTrans.DetailId = miscOrderLocationDetail.Id; invTransList.Add(invTrans); #region 计划外出库产生结算 if (miscOrderLocationDetail.ActingBill > 0 //退货类的寄售出库(zr1,zr2,zr5,zr6)不应该产生或者冲销结算 && !NotSettleBillBWARTArray.Contains(invTrans.BWART.ToUpper())) { #region 计划外出库,补做411K if (miscOrderMaster.Status == CodeMaster.MiscOrderStatus.Close) { ActingBill actingBill = genericMgr.FindEntityWithNativeSql<ActingBill>("select * from BIL_ActBill WITH(NOLOCK) where Id = ?", miscOrderLocationDetail.ActingBill).Single(); var invTrans411 = Mapper.Map<InvTrans, InvTrans>(invTrans); invTrans411.BWART = "411"; invTrans411.SOBKZ = "K"; invTrans411.LIFNR = actingBill.Party; if (!string.IsNullOrWhiteSpace(actingBill.IpNo)) //XBLNR=出货通知: 改成传送货单号,如果送货单号为空,则传收货单号 { invTrans411.XBLNR = actingBill.IpNo; } else { invTrans411.XBLNR = actingBill.ReceiptNo; } invTrans411.SGTXT = invTrans411.SGTXT + "K"; CreateSiSap(invTrans411); invTransList.Add(invTrans411); invTransList.Add(invTrans); } #endregion #region 计划外出库冲销,补做412K else { ActingBill actingBill = genericMgr.FindEntityWithNativeSql<ActingBill>("select * from BIL_ActBill WITH(NOLOCK) where Id = ?", miscOrderLocationDetail.ActingBill).Single(); var invTrans412 = Mapper.Map<InvTrans, InvTrans>(invTrans); invTrans412.BWART = "412"; invTrans412.SOBKZ = "K"; invTrans412.LIFNR = actingBill.Party; if (!string.IsNullOrWhiteSpace(actingBill.IpNo)) //XBLNR=出货通知: 改成传送货单号,如果送货单号为空,则传收货单号 { invTrans412.XBLNR = actingBill.IpNo; } else { invTrans412.XBLNR = actingBill.ReceiptNo; } invTrans412.SGTXT = invTrans412.SGTXT + "K"; CreateSiSap(invTrans412); invTransList.Add(invTrans); invTransList.Add(invTrans412); } #endregion } #endregion #region 101/102 //302 301 工厂WERKS:0085, 库位LGORT:F80X, 收货工厂UMWRK:0084, 收货地点UMLGO:1000 if (invTrans.LGORT == "F80X" && (invTrans.BWART == "301" || invTrans.BWART == "302") && invTrans.UMWRK == "0084" && invTrans.WERKS == "0085") { /* 对于101 收货,需要进行判断,如果ASN中的特殊字符标示 F80XBJ=’X’ 则在收货传接口时候,需要传递如下两条接口信息。 1)基于ASN的101收货 2)跨工厂转储:移动类型301 收货工厂(新增的接口字段)字段为0085。出货通知字段维护ASN,以便于追踪。 对于F80XBJ=空的,与原接口操作保持一致 301/302 工厂WERKS:0085, 库位LGORT:F80X, 收货工厂UMWRK:0084, 收货地点UMLGO:1000 */ //todo加101双桥收货 //var miscOrderDetail = genericMgr.FindById<MiscOrderDetail>(miscOrderLocationDetail.MiscOrderDetailId); InvTrans newInvTrans = Mapper.Map<InvTrans, InvTrans>(invTrans); //预留号码 //newInvTrans.EBELN = miscOrderDetail.ReserveNo; newInvTrans.EBELN = string.IsNullOrWhiteSpace(miscOrderDetail.ReserveNo) ? miscOrderMaster.ReserveNo : miscOrderDetail.ReserveNo; //预留行数 //newInvTrans.EBELP = miscOrderDetail.ReserveLine; newInvTrans.EBELP = string.IsNullOrWhiteSpace(miscOrderDetail.ReserveLine) ? miscOrderMaster.ReserveLine : miscOrderDetail.ReserveLine; newInvTrans.LIFNR = miscOrderDetail.ManufactureParty; newInvTrans.UMWRK = null; newInvTrans.XBLNR = miscOrderMaster.MiscOrderNo; newInvTrans.SGTXT = "0" + miscOrderLocationDetail.Id.ToString(); newInvTrans.OrderNo = miscOrderMaster.MiscOrderNo; newInvTrans.DetailId = miscOrderLocationDetail.Id; //invTrans if (invTrans.BWART == "301") { /* 移动类型 凭证日期 过账日期 PO号码 PO行数 DN号码 DN行数 厂商代码 工厂代码 库存地点 特殊标志 物料号码 数量 单位 收货地点 移动原因 成本中心 出货通知 预留号码 预留行数 WMS号码 WMS行号 操作类型 库存类型 送货单号 内部订单 收货物料 收货工厂 301 20111227 20111227 0085 F80X 99 3 ST 1000 10048151 16674261 10048151 0084 */ newInvTrans.BWART = "101"; invTransList.Insert(0, newInvTrans);//注意顺序 } else { /* WMS号码 移动类型 凭证日期 过账日期 PO号码 PO行数 DN号码 DN行数 厂商代码 工厂代码 库存地点 特殊标志 物料号码 数量 单位 收货地点 移动原因 成本中心 出货通知 预留号码 预留行数 WMS号码 WMS行号 操作类型 库存类型 送货单号 内部订单 收货物料 收货工厂 16674271 302 20111228 20111228 0085 F80X 99 3 ST 1000 10048151 16674271 10048151 0084 16674272 102 20111228 20111228 5500004144 10 1000000645 0085 F80X 99 3 ST F80X 10048151 16674272 10048151 O 10048151 */ newInvTrans.BWART = "102"; invTransList.Add(newInvTrans); } CreateSiSap(newInvTrans); } #endregion #region 记录数据关系 InvLoc invLoc = new InvLoc(); invLoc.SourceType = (int)InvLoc.SourceTypeEnum.MiscOrder; invLoc.SourceId = miscOrderLocationDetail.Id; invLoc.FRBNR = invTrans.FRBNR; invLoc.SGTXT = invTrans.SGTXT; invLoc.CreateDate = DateTime.Now; invLoc.CreateUser = SecurityContextHolder.Get().Code; invLoc.BWART = invTrans.BWART; invLocList.Add(invLoc); #endregion } InsertInvTrans(invTransList, invLocList, true); } #region 更新TableIndex,记录最后更新日期 tableIndex.LastModifyDate = miscOrderMaster.LastModifyDate; UpdateSiSap<TableIndex>(tableIndex); this.genericMgr.FlushSession(); #endregion }