| | |
| | | using WIDESEA_Core.CodeConfigEnum; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Core.Log; |
| | | using WIDESEA_Core.Utilities; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.Basic; |
| | |
| | | { |
| | | string serialNumber = serialNumberObj?.ToString(); |
| | | if (!string.IsNullOrEmpty(serialNumber)) |
| | | { |
| | | { |
| | | serialNumbers.Add(serialNumber); |
| | | } |
| | | else |
| | |
| | | Wlstatus = (int)InventoryMaterialStatus.合格, |
| | | Mgeneratetime = DateTime.Now, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | System = inboundOrder.System, |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | } |
| | |
| | | decimal totalQuantity = stockInfo.Details.Sum(x => x.StockQuantity); |
| | | |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.入库中.ObjToInt(); |
| | | |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (stockInfo.Id == 0) |
| | | { |
| | |
| | | } |
| | | |
| | | //药水,低温仓组盘 |
| | | public WebResponseContent NEWMaterielGroup(SaveModel saveModel) |
| | | public WebResponseContent NewMaterielGroup(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | |
| | | { |
| | | stockInfo = new Dt_StockInfo() |
| | | { |
| | | BatchNo = inboundOrderDet.BatchNo, |
| | | BatchNo = "", |
| | | PalletCode = palletCode, |
| | | PalletType = GetPalletType(warehouse, palletCode),//GetPalletType(warehouse, palletCode) |
| | | IsFull = true, |
| | |
| | | Materialweight = 0, |
| | | Wlstatus = (int)InventoryMaterialStatus.合格, |
| | | Mgeneratetime = DateTime.Now, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | WarehouseId = 0, |
| | | System = inboundOrder.System, |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | //if (stockInfo.StockStatus != StockStatusEmun.组盘暂存.ObjToInt()) |
| | | //{ |
| | | return WebResponseContent.Instance.Error($"托盘号重复,该托盘已组过物料"); |
| | | //} |
| | | //beforeQuantity = stockInfo.Details.Sum(x => x.StockQuantity); |
| | | } |
| | | |
| | | if (warehouse.WarehouseCode == WarehouseEnum.SC01_BC.ToString()) |
| | | { |
| | | stockInfo.Remark = Initiallife.ToString(); |
| | | string batchNo = models.FirstOrDefault()?.LotNo ?? ""; |
| | | //Dt_StockInfoDetail existDetail = _stockRepository.StockInfoDetailRepository.QueryFirst(x => x.BatchNo == batchNo); |
| | | //if (existDetail != null) |
| | | //{ |
| | | // return WebResponseContent.Instance.Error($"{batchNo}测试架已存在"); |
| | | //} |
| | | if (models.Count >= 2) |
| | | { |
| | | return WebResponseContent.Instance.Error($"组盘明细不唯一"); |
| | | } |
| | | //if (palletCode.Substring(0, 1) == "6") |
| | | //{ |
| | | // stockInfo.PalletType = PalletTypeEnum.MediumPallet.ObjToInt(); |
| | | //} |
| | | //else |
| | | //{ |
| | | // stockInfo.PalletType = PalletTypeEnum.LargestPallet.ObjToInt(); |
| | | //} |
| | | } |
| | | else if (warehouse.WarehouseCode == WarehouseEnum.SC01_BC.ToString()) |
| | | { |
| | | if (models.Count >= 2) |
| | | { |
| | | return WebResponseContent.Instance.Error($"组盘明细不唯一"); |
| | | } |
| | | } |
| | | |
| | | List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>(); |
| | | foreach (var model in models) |
| | | { |
| | | |
| | | Dt_InboundOrderDetail notGroupDetail = new Dt_InboundOrderDetail(); |
| | | |
| | | notGroupDetail = inboundOrder.Details.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.BatchNo == model.LotNo).FirstOrDefault(); |
| | | notGroupDetail = inboundOrder.Details.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.SupplierBatch == model.LotNo && x.OrderQuantity > x.ReceiptQuantity).FirstOrDefault(); |
| | | |
| | | if (notGroupDetail.MaterielType == 1) |
| | | { |
| | | stockInfo.WarehouseId = 6; |
| | | } |
| | | else if (notGroupDetail.MaterielType == 2) |
| | | { |
| | | stockInfo.WarehouseId = 5; |
| | | } |
| | | |
| | | if (notGroupDetail == null) |
| | | { |
| | |
| | | OrderNo = inboundOrder.OrderNo, |
| | | BatchNo = notGroupDetail.BatchNo, |
| | | LinId = notGroupDetail.LinId, |
| | | StockQuantity = (quantitys.FirstOrDefault()), |
| | | StockQuantity = model.Quantity, |
| | | Status = (int)StockStatusEmun.组盘暂存, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | |
| | | stockInfoDetails.Add(stockInfoDetail); |
| | | |
| | | decimal decimalReceiptQuantity = Convert.ToDecimal(notGroupDetail.ReceiptQuantity); |
| | | decimal decimalModelQuantity = Convert.ToDecimal((quantitys.FirstOrDefault())); |
| | | decimal decimalModelQuantity = Convert.ToDecimal(notGroupDetail.OrderQuantity); |
| | | decimal decimalOrderQuantity = Convert.ToDecimal(notGroupDetail.OrderQuantity); |
| | | decimalReceiptQuantity += decimalModelQuantity; |
| | | decimalReceiptQuantity += model.Quantity; |
| | | // 检查是否超出订单数量 |
| | | if (decimalReceiptQuantity > decimalOrderQuantity) |
| | | { |
| | |
| | | /// </summary> |
| | | /// <param name="materielGroupDTO"></param> |
| | | /// <returns></returns> |
| | | #region |
| | | public WebResponseContent CPMaterielGroup(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | var palletCode = saveModel.MainData["palletCode"].ToString(); |
| | | var warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); |
| | | var serialNumbers = new List<string>(); |
| | | var quantities = new List<decimal>(); |
| | | var lotNos = new List<string>(); |
| | | var materielCodes = new List<string>(); |
| | | // 获取仓库信息 |
| | | Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == warehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到该仓库信息"); |
| | | } |
| | | |
| | | // 获取入库单信息 |
| | | Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>() |
| | | .Where(x => x.OrderNo == orderNo && x.WarehouseId == warehouse.WarehouseId) |
| | | .Includes(x => x.Details) |
| | | .First(); |
| | | |
| | | if (inboundOrder == null || inboundOrder.Details == null || inboundOrder.Details.Count <= 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到入库单信息"); |
| | | } |
| | | |
| | | // 批量查询所有相关箱号的CP入库单明细 |
| | | List<Dt_CPInboundOrderDetail> CPinboundOrderDetails = BaseDal.Db.Queryable<Dt_CPInboundOrderDetail>() |
| | | .LeftJoin<Dt_InboundOrderDetail>((cp, d) => cp.OrderDetailId == d.Id) |
| | | .LeftJoin<Dt_InboundOrder>((cp, d, o) => d.OrderId == o.Id) |
| | | .Where((cp, d, o) => |
| | | o.OrderNo == orderNo && |
| | | o.WarehouseId == warehouse.WarehouseId |
| | | ) |
| | | .Select((cp, d, o) => cp) |
| | | .ToList(); |
| | | |
| | | //float totalQty = CPinboundOrderDetails.Sum(x => x.QtyOfpcs); |
| | | |
| | | |
| | | // 按照箱号分组,用于后续处理 |
| | | var boxCodesToCheck = CPinboundOrderDetails |
| | | .Select(x => x.BoxCode) |
| | | .Where(bc => !string.IsNullOrEmpty(bc)) |
| | | .Distinct() |
| | | .ToList(); |
| | | |
| | | |
| | | // 3. 查询这些箱号是否已存在于库存中 |
| | | var existingStockBoxCodes = _stockRepository.StockInfoRepository.Db |
| | | .Queryable<Dt_StockInfo>() |
| | | .LeftJoin<Dt_StockInfoDetail>((s, d) => s.Id == d.StockId) |
| | | .LeftJoin<Dt_StockInfoDetailCP>((s, d, cp) => d.Id == cp.StockDetailId) |
| | | .Where((s, d, cp) => boxCodesToCheck.Contains(cp.BoxCode) && !string.IsNullOrEmpty(cp.BoxCode)) |
| | | .Select((s, d, cp) => cp.BoxCode) |
| | | .Distinct() |
| | | .ToList(); |
| | | |
| | | // 4. 检查是否有重复 |
| | | if (existingStockBoxCodes.Any()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"以下箱号已在库存中:{string.Join(",", existingStockBoxCodes)}"); |
| | | } |
| | | |
| | | // 获取所有相关的入库单明细ID |
| | | var orderDetailIds = CPinboundOrderDetails.Select(x => x.OrderDetailId).Distinct().ToList(); |
| | | |
| | | // 查询对应的入库单明细 |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = BaseDal.Db.Queryable<Dt_InboundOrderDetail>() |
| | | .Where(x => orderDetailIds.Contains(x.Id)) |
| | | .ToList(); |
| | | |
| | | if (inboundOrderDetails.Sum(x => x.OrderQuantity) <= inboundOrderDetails.Sum(x => x.ReceiptQuantity)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"此单据已全部组盘完成"); |
| | | } |
| | | |
| | | // 按订单明细ID分组,检查每个明细的所有箱号是否都扫描了 |
| | | var detailsByOrderDetailId = CPinboundOrderDetails |
| | | .GroupBy(x => x.OrderDetailId) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | // 获取相关的订单明细 |
| | | List<Dt_InboundOrderDetail> orderDetails = new List<Dt_InboundOrderDetail>(); |
| | | List<Dt_InboundOrderDetail> detailsToUpdate = new List<Dt_InboundOrderDetail>(); |
| | | |
| | | // 检查每个订单明细是否完成了所有箱号的扫描 |
| | | foreach (var kvp in detailsByOrderDetailId) |
| | | { |
| | | int orderDetailId = kvp.Key; |
| | | var cpDetails = kvp.Value; |
| | | |
| | | // 获取订单明细 |
| | | var orderDetail = inboundOrder.Details.FirstOrDefault(x => x.Id == orderDetailId); |
| | | if (orderDetail == null) |
| | | { |
| | | orderDetail = BaseDal.Db.Queryable<Dt_InboundOrderDetail>() |
| | | .First(x => x.Id == orderDetailId); |
| | | } |
| | | |
| | | if (orderDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到订单明细ID:{orderDetailId}"); |
| | | } |
| | | |
| | | orderDetails.Add(orderDetail); |
| | | |
| | | // 标记该明细为已完成组盘 |
| | | orderDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | var recqty = orderDetail.ReceiptQuantity; |
| | | float totalQty = cpDetails.Sum(item => item.QtyOfpcs); |
| | | orderDetail.ReceiptQuantity = (decimal)totalQty + recqty; // 收货数量等于订单数量 |
| | | |
| | | detailsToUpdate.Add(orderDetail); |
| | | } |
| | | |
| | | |
| | | |
| | | // 检查托盘是否已存在 |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db |
| | | .Queryable<Dt_StockInfo>() |
| | | .Where(x => x.PalletCode == palletCode) |
| | | .First(); |
| | | |
| | | if (stockInfo == null) |
| | | { |
| | | // 创建新托盘 |
| | | stockInfo = new Dt_StockInfo() |
| | | { |
| | | BatchNo = "", // 使用入库单批次号 |
| | | PalletCode = palletCode, |
| | | PalletType = GetPalletType(warehouse, palletCode), |
| | | IsFull = true, |
| | | StockStatus = (int)StockStatusEmun.组盘暂存, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | MaterialType = (int)InventoryMaterialType.原材料, |
| | | Materialweight = 0, |
| | | Wlstatus = (int)InventoryMaterialStatus.合格, |
| | | Mgeneratetime = DateTime.Now, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | System = inboundOrder.System, |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | // 如果托盘已存在,检查是否已经是组盘暂存状态 |
| | | if (stockInfo.StockStatus != (int)StockStatusEmun.组盘暂存) |
| | | { |
| | | return WebResponseContent.Instance.Error($"托盘号重复,该托盘已组过物料"); |
| | | } |
| | | } |
| | | |
| | | List<Dt_CPInboundOrderDetail> cPInboundOrderDetail = new List<Dt_CPInboundOrderDetail>(); |
| | | // 创建库存明细 - 按订单明细创建 |
| | | foreach (var orderDetail in orderDetails) |
| | | { |
| | | // 获取该明细对应的所有箱号 |
| | | var detailBoxCodes = detailsByOrderDetailId[orderDetail.Id] |
| | | .Select(x => x.BoxCode) |
| | | .ToList(); |
| | | |
| | | cPInboundOrderDetail = BaseDal.Db.Queryable<Dt_CPInboundOrderDetail>().Where(x => detailBoxCodes.Contains(x.BoxCode)).ToList(); |
| | | |
| | | List<Dt_StockInfoDetailCP> stockInfoDetailCP = new List<Dt_StockInfoDetailCP>(); |
| | | foreach (var item in cPInboundOrderDetail) |
| | | { |
| | | Dt_StockInfoDetailCP stockInfoDetailCP1 = new Dt_StockInfoDetailCP() |
| | | { |
| | | BoxId = item.BoxId, |
| | | BoxCode = item.BoxCode, |
| | | DateCode = item.DateCode, |
| | | JobId = item.JobId, |
| | | PartNum = item.PartNum, |
| | | QtyOfpcs = item.QtyOfpcs, |
| | | QtyOfxout = item.QtyOfxout, |
| | | CPStockDetailStatus = (int)StockStatusEmun.组盘暂存, |
| | | LPNNO = item.LPNNO, |
| | | OrinalLocation = item.OrinalLocation, |
| | | Creater = "上游WMS", |
| | | }; |
| | | stockInfoDetailCP.Add(stockInfoDetailCP1); |
| | | |
| | | item.CPOrderDetailStatus = InOrderStatusEnum.入库中.ObjToInt(); |
| | | } |
| | | |
| | | // 创建库存明细 |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | MaterielCode = orderDetail.MaterielCode, |
| | | MaterielName = orderDetail.MaterielName, |
| | | OrderNo = inboundOrder.OrderNo, |
| | | BatchNo = orderDetail.BatchNo, |
| | | SupplierBatch = orderDetail.SupplierBatch, |
| | | LinId = orderDetail.LinId, |
| | | StockQuantity = (decimal)cPInboundOrderDetail.Sum(item => item.QtyOfpcs), |
| | | Status = (int)StockStatusEmun.组盘暂存, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | Id = orderDetail.LinId.ObjToInt(), |
| | | //DeliveryNote = orderDetail.DeliveryNote, |
| | | MaterieSpec = orderDetail.MaterieSpec, |
| | | StockDetails = stockInfoDetailCP, |
| | | OrinalLocation = orderDetail.OrinalLocation |
| | | }; |
| | | |
| | | if (stockInfo.Id > 0) |
| | | { |
| | | stockInfoDetail.StockId = stockInfo.Id; |
| | | } |
| | | stockInfo.Details.Add(stockInfoDetail); |
| | | } |
| | | |
| | | // 检查入库单是否所有明细都已完成组盘 |
| | | bool allDetailsCompleted = inboundOrder.Details.All(x => |
| | | detailsToUpdate.Any(d => d.Id == x.Id) || |
| | | x.OrderDetailStatus == OrderDetailStatusEnum.GroupAndInbound.ObjToInt()); |
| | | |
| | | |
| | | |
| | | // 事务处理 |
| | | _unitOfWorkManage.BeginTran(); |
| | | try |
| | | { |
| | | if (stockInfo.Id == 0) |
| | | { |
| | | _stockRepository.StockInfoRepository.Db.InsertNav(stockInfo) |
| | | .Include(x => x.Details).ThenInclude(x => x.StockDetails) |
| | | .ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | _stockRepository.StockInfoRepository.Db.UpdateNav(stockInfo) |
| | | .Include(x => x.Details, new UpdateNavOptions() |
| | | { |
| | | OneToManyInsertOrUpdate = true |
| | | }).ThenInclude(x => x.StockDetails) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | // 更新订单明细 |
| | | if (detailsToUpdate.Count > 0) |
| | | { |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(detailsToUpdate); |
| | | } |
| | | |
| | | // 更新订单 |
| | | _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); |
| | | |
| | | _cPInboundOrderDetailRepository.UpdateData(cPInboundOrderDetail); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | content = WebResponseContent.Instance.OK("组盘成功"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw new Exception($"组盘事务处理失败:{ex.Message}", ex); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error($"组盘失败:{ex.Message}"); |
| | | } |
| | | |
| | | return content; |
| | | } |
| | | #endregion |
| | | |
| | | #region 弃用 |
| | | public WebResponseContent CP1MaterielGroup(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | |
| | | Wlstatus = (int)InventoryMaterialStatus.合格, |
| | | Mgeneratetime = DateTime.Now, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | System = inboundOrder.System, |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | } |
| | |
| | | |
| | | return content; |
| | | } |
| | | #endregion |
| | | |
| | | public string ReceiveWMSTaskin = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskin"]; |
| | | |
| | | /// <summary> |
| | | /// 组盘合托 |
| | | /// </summary> |
| | |
| | | { |
| | | throw new Exception("库存未找到托盘号"); |
| | | } |
| | | |
| | | var sameItems = from sourceItem in stockInfo.Details |
| | | join targetItem in targetstockInfo.Details |
| | | on new |
| | | { |
| | | sourceItem.BatchNo, |
| | | sourceItem.MaterielName, |
| | | sourceItem.MaterielCode |
| | | } |
| | | equals new |
| | | { |
| | | targetItem.BatchNo, |
| | | targetItem.MaterielName, |
| | | targetItem.MaterielCode |
| | | } |
| | | select new |
| | | { |
| | | SourceItem = sourceItem, |
| | | TargetItem = targetItem, |
| | | BatchNo = sourceItem.BatchNo, |
| | | MaterialCode = sourceItem.MaterielCode, |
| | | MaterialType = sourceItem.MaterielName |
| | | }; |
| | | |
| | | var matchedSourceItemIds = sameItems.Select(x => x.SourceItem.Id).ToList(); |
| | | |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | item.StockId = targetstockInfo.Id; |
| | | if (!matchedSourceItemIds.Contains(item.Id)) |
| | | { |
| | | item.StockId = targetstockInfo.Id; |
| | | } |
| | | } |
| | | var differentItems = stockInfo.Details |
| | | .Where(x => !matchedSourceItemIds.Contains(x.Id)) |
| | | .ToList(); |
| | | targetstockInfo.Details = targetstockInfo.Details |
| | | .Where(x => !matchedSourceItemIds.Contains(x.Id)) |
| | | .Concat(differentItems) |
| | | .ToList(); |
| | | if (warehouse.WarehouseCode == "SC02_CP") |
| | | { |
| | | warehouse.WarehouseCode = "SC01_CP"; |
| | |
| | | }).ToList() |
| | | } |
| | | } |
| | | // Parameters = stockInfo.Details.Select(g => new HouseSyncretism.data |
| | | // { |
| | | // Lpn = stockInfo.PalletCode, |
| | | // MoveType = 0, |
| | | // WareHouseCode = warehouse.WarehouseCode, |
| | | // ItemCode = g.MaterielCode, |
| | | // MoveNumber = g.StockQuantity, |
| | | // //LotNo = g., |
| | | // WipBatch = g.BatchNo, |
| | | // LocationName = stockInfo.PalletCode, |
| | | // TargetLocName = targetstockInfo.PalletCode, |
| | | // TargetLpn = targetstockInfo.PalletCode, |
| | | |
| | | // }).ToList() |
| | | //}; |
| | | }; |
| | | var authResult = AuthenticateWithWMS(); |
| | | if (authResult.IsSuccess) |
| | |
| | | }; |
| | | |
| | | var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskin, houseSyncretism, "立库入库数量回传WMS"); |
| | | // 判断Success的值 |
| | | if (!response.Success) |
| | | { |
| | | throw new Exception($"操作失败: {response.Message ?? "未提供错误信息"}"); |
| | |
| | | |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | targetstockInfo.Details.AddRange(stockInfo.Details); |
| | | foreach (var sameItem in sameItems) |
| | | { |
| | | sameItem.TargetItem.StockQuantity += sameItem.SourceItem.StockQuantity; |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(sameItem.TargetItem); |
| | | _stockRepository.StockInfoDetailRepository.DeleteData(sameItem.SourceItem); |
| | | } |
| | | _stockRepository.StockInfoRepository.UpdateData(targetstockInfo); |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(targetstockInfo.Details); |
| | | _stockRepository.StockInfoRepository.DeleteData(stockInfo); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | webResponseContent = WebResponseContent.Instance.OK("合托成功"); |
| | | } |
| | |
| | | |
| | | public int GetPalletType(Dt_Warehouse warehouse, string palletCode) |
| | | { |
| | | |
| | | if (warehouse.WarehouseCode == WarehouseEnum.SC01_BC.ObjToString()) |
| | | if (warehouse.WarehouseCode.Contains("BC")) |
| | | { |
| | | Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 3)); |
| | | if (palletTypeInfo == null) |
| | |
| | | } |
| | | return palletTypeInfo.PalletType; |
| | | } |
| | | //else if (warehouse.WarehouseCode == WarehouseEnum.HA152.ObjToString()) |
| | | //{ |
| | | // Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 2)); |
| | | // if (palletTypeInfo == null) |
| | | // { |
| | | // throw new Exception($"托盘号错误"); |
| | | // } |
| | | // return palletTypeInfo.PalletType; |
| | | //} |
| | | //else if (warehouse.WarehouseCode == WarehouseEnum.HA57.ObjToString()) |
| | | //{ |
| | | // Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 3)); |
| | | // if (palletTypeInfo == null) |
| | | // { |
| | | // throw new Exception($"托盘号错误"); |
| | | // } |
| | | // return palletTypeInfo.PalletType; |
| | | //} |
| | | //else if (warehouse.WarehouseCode == WarehouseEnum.HA58.ObjToString()) |
| | | //{ |
| | | // Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 2)); |
| | | // if (palletTypeInfo == null) |
| | | // { |
| | | // throw new Exception($"托盘号错误"); |
| | | // } |
| | | // return palletTypeInfo.PalletType; |
| | | //} |
| | | return -1; |
| | | else |
| | | { |
| | | Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 2)); |
| | | if (palletTypeInfo == null) |
| | | { |
| | | throw new Exception($"托盘号错误"); |
| | | } |
| | | return palletTypeInfo.PalletType; |
| | | } |
| | | return 0; |
| | | } |
| | | /// <summary> |
| | | /// 判断正确时间格式 |
| | |
| | | } |
| | | if (warehouse.WarehouseCode.Contains("CP")) |
| | | { |
| | | if (item.SupplierBatch == null) |
| | | { |
| | | return content.Error("供应商批次不可为空"); |
| | | } |
| | | Dt_InboundOrder inboundOrderOld = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == model.AsnNo).Includes(x => x.Details).First(); |
| | | |
| | | if (inboundOrderOld != null) |
| | |
| | | QtyOfpcs = (float)list.QtyOfpcs, |
| | | QtyOfxout = (float)list.QtyOfxout, |
| | | CPOrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | LPNNO = list.LPNNO, |
| | | OrinalLocation = list.OrinalLocation, |
| | | Creater = "上游WMS", |
| | | }; |
| | | cPInboundOrderDetail.Add(cPInboundOrderDetail1); |
| | |
| | | QtyOfpcs = (float)list.QtyOfpcs, |
| | | QtyOfxout = (float)list.QtyOfxout, |
| | | CPOrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | LPNNO = list.LPNNO, |
| | | OrinalLocation = list.OrinalLocation, |
| | | Creater = "上游WMS", |
| | | }; |
| | | cPInboundOrderDetail.Add(cPInboundOrderDetail1); |
| | |
| | | OrinalLocation = item.OrinalLocation, |
| | | CPDetails = cPInboundOrderDetail |
| | | }; |
| | | |
| | | Dt_InboundOrder inboundOrder = new Dt_InboundOrder() |
| | | { |
| | | OrderNo = model.AsnNo, |
| | |
| | | } |
| | | else |
| | | { |
| | | if (item.SupplierBatch == null) |
| | | { |
| | | return content.Error("供应商批次不可为空"); |
| | | } |
| | | //if (item.SupplierBatch == null) |
| | | //{ |
| | | // return content.Error("供应商批次不可为空"); |
| | | //} |
| | | Dt_InboundOrder inboundOrderOld = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == model.AsnNo).Includes(x => x.Details).First(); |
| | | |
| | | if (inboundOrderOld != null) |
| | |
| | | if (inboundOrderDetailOld != null) |
| | | { |
| | | inboundOrderDetailOld.OrderQuantity += item.OrderQuantity; |
| | | inboundOrderDetailOld.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt(); |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetailOld); |
| | | } |
| | | else |
| | |
| | | { |
| | | OrderId = orderDetail1.OrderId, |
| | | MaterielCode = item.MaterielCode, |
| | | MaterielType = item.MaterielType, |
| | | BatchNo = item.BatchNo, |
| | | OrderQuantity = item.OrderQuantity, |
| | | ReceiptQuantity = 0, |
| | |
| | | { |
| | | Dt_InboundOrderDetail orderDetail = new Dt_InboundOrderDetail() |
| | | { |
| | | MaterielType = item.MaterielType, |
| | | MaterielCode = item.MaterielCode, |
| | | BatchNo = item.BatchNo, |
| | | OrderQuantity = item.OrderQuantity, |
| | |
| | | System = model.System, |
| | | Details = new List<Dt_InboundOrderDetail> { orderDetail } |
| | | }; |
| | | //switch (model.OrderType)//单据类型 |
| | | //{ |
| | | // case 1: |
| | | // inboundOrder.OrderType = InOrderTypeEnum.Allocat.ObjToInt(); |
| | | // break; |
| | | // case 3: |
| | | // inboundOrder.OrderType = InOrderTypeEnum.CustomerRecovery.ObjToInt(); |
| | | // break; |
| | | // case 6: |
| | | // inboundOrder.OrderType = InOrderTypeEnum.SaleReturn.ObjToInt(); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | //}; |
| | | Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | |
| | | } |
| | | } |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | content = WebResponseContent.Instance.OK(); |
| | | //InboundOrderAddDTO orderAddDTO1 = new InboundOrderAddDTO(); |
| | | //orderAddDTO1.OrderNo = orderAddDTO.AsnNo; |
| | | //orderAddDTO1.UpperOrderNo = orderAddDTO.AsnNo; |
| | | //orderAddDTO1.OutWareHouse = orderAddDTO.InWarehouse; |
| | | //orderAddDTO1.TransactionCode = orderAddDTO.TransactionCode; |
| | | //orderAddDTO1.InoutType = orderAddDTO.OrderType; |
| | | //orderAddDTO1.OrderType = orderAddDTO.InoutType.ObjToInt(); |
| | | //orderAddDTO1.Details = orderAddDTO.DetailList.DicToIEnumerable<InboundOrderDetailAddDTO>(); |
| | | //#region 验证数据 |
| | | //(bool, string, object?) result = CheckInboundOrderAddData(orderAddDTO1); |
| | | //if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2); |
| | | //#endregion |
| | | |
| | | //Dt_InboundOrder inboundOrder = _mapper.Map<Dt_InboundOrder>(orderAddDTO1); |
| | | //inboundOrder.OrderStatus = InboundStatusEnum.未开始.ObjToInt(); |
| | | //inboundOrder.Creater = "WMS"; |
| | | //inboundOrder.CreateDate = DateTime.Now; |
| | | //bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | _inboundOrderDetailService.DeleteData(item); |
| | | } |
| | | BaseDal.DeleteData(oldOutboundOrder); |
| | | WriteLog.Write_Log("API", "SMOM推送入库单据取消", "请求成功", new { 请求报文 = oldOutboundOrder, 接收报文 = content }); |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | List<Dt_InboundOrder> dt_ReceiveOrders = new List<Dt_InboundOrder>(); |
| | | if (string.IsNullOrEmpty(orderNo)) |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderStatus < InboundStatusEnum.入库完成.ObjToInt() && x.WarehouseId == warehouseId).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 10); |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderStatus < InboundStatusEnum.入库完成.ObjToInt() && x.WarehouseId == warehouseId).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 50); |
| | | } |
| | | else |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => (x.OrderNo.Contains(orderNo)) && x.OrderStatus < InboundStatusEnum.入库完成.ObjToInt() && x.WarehouseId == warehouseId).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 10); |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => (x.OrderNo.Contains(orderNo)) && x.OrderStatus < InboundStatusEnum.入库完成.ObjToInt() && x.WarehouseId == warehouseId).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 50); |
| | | } |
| | | |
| | | content.OK(data: dt_ReceiveOrders); |
| | |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | Db.InsertNav(erpProScrapSheet).Include(x => x.Details).ExecuteCommand(); |
| | | WriteLog.Write_Log("API", "erp单据下发", "请求成功", new { 请求报文 = erpProScrapSheet, 接收报文 = WebResponseContent.Instance.OK() }); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | |
| | | } |