| | |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.Inbound; |
| | | using static WIDESEA_Common.HouseInventoryIn; |
| | | using static WIDESEA_Common.HouseSyncretism; |
| | | using static WIDESEA_Common.InventoryAllocate; |
| | | using Parameter = WIDESEA_Common.Parameter; |
| | | |
| | | namespace WIDESEA_InboundService |
| | | { |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到该物料的信息"); |
| | | } |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>(); |
| | | ///找数量匹配的 |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode && x.SupplierBatch == (models.FirstOrDefault()?.LotNo ?? "") && x.OrderQuantity > x.ReceiptQuantity && x.OrderQuantity == (quantitys.FirstOrDefault())).ToList(); |
| | | if (warehouse.WarehouseCode.Contains("BC")) |
| | | { |
| | | inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode && x.SupplierBatch == (models.FirstOrDefault()?.LotNo ?? "") && x.OrderQuantity > x.ReceiptQuantity && x.OrderQuantity == (quantitys.FirstOrDefault())).ToList(); |
| | | } |
| | | else |
| | | { |
| | | inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode && x.BatchNo == (models.FirstOrDefault()?.LotNo ?? "")).ToList(); |
| | | } |
| | | |
| | | |
| | | if (inboundOrderDetails == null || inboundOrderDetails.Count <= 0) |
| | | { |
| | |
| | | Wlstatus = (int)InventoryMaterialStatus.合格, |
| | | Mgeneratetime = DateTime.Now, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | System = inboundOrder.System, |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | } |
| | |
| | | List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>(); |
| | | foreach (var model in models) |
| | | { |
| | | Dt_InboundOrderDetail? notGroupDetail = inboundOrderDetails.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.SupplierBatch == model.LotNo && x.OrderQuantity > x.ReceiptQuantity).FirstOrDefault(); |
| | | |
| | | Dt_InboundOrderDetail notGroupDetail = new Dt_InboundOrderDetail(); |
| | | ///找数量匹配的 |
| | | if (warehouse.WarehouseCode.Contains("BC")) |
| | | { |
| | | notGroupDetail = inboundOrderDetails.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.SupplierBatch == model.LotNo && x.OrderQuantity > x.ReceiptQuantity).FirstOrDefault(); |
| | | } |
| | | else |
| | | { |
| | | notGroupDetail = inboundOrderDetails.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.BatchNo == model.LotNo && x.OrderQuantity > x.ReceiptQuantity).FirstOrDefault(); |
| | | } |
| | | |
| | | |
| | | if (notGroupDetail == null) |
| | | { |
| | |
| | | Id = inboundOrderDet.LinId.ObjToInt(), |
| | | DeliveryNote = model.DeliveryNote, |
| | | SupplierBatch = inboundOrderDet.SupplierBatch, |
| | | MaterieSpec = inboundOrderDet.MaterieSpec |
| | | MaterieSpec = inboundOrderDet.MaterieSpec, |
| | | OrinalLocation = inboundOrderDet.OrinalLocation |
| | | }; |
| | | |
| | | if (stockInfo.Id > 0) |
| | |
| | | _stockRepository.StockInfoRepository.Db.UpdateNav(stockInfo).Include(x => x.Details, new UpdateNavOptions() { OneToManyInsertOrUpdate = true }).ExecuteCommand(); |
| | | } |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetails); |
| | | _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | //药水,低温仓组盘 |
| | | public WebResponseContent NewMaterielGroup(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 Initiallife = saveModel.MainData["initiallife"].ObjToInt(); |
| | | List<string> serialNumbers = new List<string>(); |
| | | List<decimal> quantitys = new List<decimal>(); |
| | | foreach (var item in saveModel.DelKeys) |
| | | { |
| | | string json = JsonConvert.SerializeObject(item); |
| | | Dictionary<string, object> delKeyDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(json); |
| | | |
| | | |
| | | if (delKeyDict.TryGetValue("serialNumber", out object serialNumberObj)) |
| | | { |
| | | string serialNumber = serialNumberObj?.ToString(); |
| | | if (!string.IsNullOrEmpty(serialNumber)) |
| | | { |
| | | serialNumbers.Add(serialNumber); |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error("serialNumber的值为空"); |
| | | } |
| | | } |
| | | if (delKeyDict.TryGetValue("quantity", out object quantityObj)) |
| | | { |
| | | if (quantityObj == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("物料数量的值为空"); |
| | | } |
| | | decimal quantity; |
| | | try |
| | | { |
| | | quantity = Convert.ToDecimal(quantityObj); |
| | | } |
| | | catch |
| | | { |
| | | return WebResponseContent.Instance.Error($"物料数量{quantityObj}无法转换为数字"); |
| | | } |
| | | if (quantity <= 0) |
| | | { |
| | | return WebResponseContent.Instance.Error("物料数量必须大于0"); |
| | | } |
| | | |
| | | quantitys.Add(quantity); |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error("缺少物料数量字段"); |
| | | } |
| | | } |
| | | 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) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到入库单信息"); |
| | | } |
| | | if (inboundOrder.Details == null || inboundOrder.Details.Count <= 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到入库单明细信息"); |
| | | } |
| | | List<MatSerNumAnalysisModel> models = CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(AnalysisCodeEnum.MatSerNumAnalysis, serialNumbers); |
| | | //验证判断时间格式 |
| | | WebResponseContent IsValidContent = IsValidMCDates(models); |
| | | if (!IsValidContent.Status) |
| | | { |
| | | return content.Error(IsValidContent.Message); |
| | | } |
| | | |
| | | string materielCode = models.FirstOrDefault()?.MaterielCode ?? ""; |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materielCode); |
| | | if (materielInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到该物料的信息"); |
| | | } |
| | | |
| | | decimal beforeQuantity = 0; |
| | | |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); |
| | | if (stockInfo == null) |
| | | { |
| | | stockInfo = new Dt_StockInfo() |
| | | { |
| | | BatchNo = "", |
| | | PalletCode = palletCode, |
| | | PalletType = GetPalletType(warehouse, palletCode),//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 |
| | | { |
| | | 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(); |
| | | |
| | | if (notGroupDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该物料在该入库单中已全部组盘完成"); |
| | | } |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | MaterielCode = notGroupDetail.MaterielCode, |
| | | MaterielName = notGroupDetail.MaterielName, |
| | | OrderNo = inboundOrder.OrderNo, |
| | | BatchNo = notGroupDetail.BatchNo, |
| | | LinId = notGroupDetail.LinId, |
| | | StockQuantity = model.Quantity, |
| | | Status = (int)StockStatusEmun.组盘暂存, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | Id = notGroupDetail.LinId.ObjToInt(), |
| | | DeliveryNote = model.DeliveryNote, |
| | | SupplierBatch = notGroupDetail.SupplierBatch, |
| | | MaterieSpec = notGroupDetail.MaterieSpec, |
| | | OrinalLocation = notGroupDetail.OrinalLocation |
| | | }; |
| | | |
| | | if (stockInfo.Id > 0) |
| | | { |
| | | stockInfoDetail.StockId = stockInfo.Id; |
| | | } |
| | | stockInfo.Details.Add(stockInfoDetail); |
| | | |
| | | stockInfoDetails.Add(stockInfoDetail); |
| | | |
| | | decimal decimalReceiptQuantity = Convert.ToDecimal(notGroupDetail.ReceiptQuantity); |
| | | decimal decimalModelQuantity = Convert.ToDecimal(notGroupDetail.OrderQuantity); |
| | | decimal decimalOrderQuantity = Convert.ToDecimal(notGroupDetail.OrderQuantity); |
| | | decimalReceiptQuantity += model.Quantity; |
| | | // 检查是否超出订单数量 |
| | | if (decimalReceiptQuantity > decimalOrderQuantity) |
| | | { |
| | | return WebResponseContent.Instance.Error($"组盘数量溢出{decimalReceiptQuantity - decimalOrderQuantity}"); |
| | | } |
| | | // 转回float类型存储,但比较和计算都使用decimal完成 |
| | | notGroupDetail.ReceiptQuantity = Convert.ToDecimal(decimalReceiptQuantity); |
| | | if (notGroupDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | notGroupDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | } |
| | | } |
| | | |
| | | decimal totalQuantity = stockInfo.Details.Sum(x => x.StockQuantity); |
| | | |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.入库中.ObjToInt(); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (stockInfo.Id == 0) |
| | | { |
| | | _stockRepository.StockInfoRepository.Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | _stockRepository.StockInfoRepository.Db.UpdateNav(stockInfo).Include(x => x.Details, new UpdateNavOptions() { OneToManyInsertOrUpdate = true }).ExecuteCommand(); |
| | | } |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrder.Details); |
| | | _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK(); |
| | |
| | | .Select((cp, d, o) => cp) |
| | | .ToList(); |
| | | |
| | | float totalQty = CPinboundOrderDetails.Sum(x => x.QtyOfpcs); |
| | | //float totalQty = CPinboundOrderDetails.Sum(x => x.QtyOfpcs); |
| | | |
| | | |
| | | // 验证查询到的数据数量是否匹配 |
| | | if (CPinboundOrderDetails.Count < serialNumbers.Count) |
| | |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | |
| | | 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) => |
| | | serialNumbers.Contains(cp.BoxCode)) |
| | | .Select((s, d, cp) => cp.BoxCode) |
| | | .Distinct() |
| | | .ToList(); |
| | | |
| | | 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 |
| | |
| | | // 标记该明细为已完成组盘 |
| | | orderDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | var recqty = orderDetail.ReceiptQuantity; |
| | | orderDetail.ReceiptQuantity = ((decimal)totalQty) + recqty; // 收货数量等于订单数量 |
| | | 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) |
| | | .Includes(x => x.Details) |
| | | .First(); |
| | | |
| | | if (stockInfo == null) |
| | |
| | | Wlstatus = (int)InventoryMaterialStatus.合格, |
| | | Mgeneratetime = DateTime.Now, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | System = inboundOrder.System, |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | List<Dt_CPInboundOrderDetail> cPInboundOrderDetail = new List<Dt_CPInboundOrderDetail>(); |
| | | // 创建库存明细 - 按订单明细创建 |
| | | foreach (var orderDetail in orderDetails) |
| | | { |
| | |
| | | .Select(x => x.BoxCode) |
| | | .ToList(); |
| | | |
| | | List<Dt_CPInboundOrderDetail> cPInboundOrderDetail = BaseDal.Db.Queryable<Dt_CPInboundOrderDetail>().Where(x => detailBoxCodes.Contains(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) |
| | | { |
| | |
| | | BatchNo = orderDetail.BatchNo, |
| | | SupplierBatch = orderDetail.SupplierBatch, |
| | | LinId = orderDetail.LinId, |
| | | StockQuantity = ((decimal)totalQty), |
| | | 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 |
| | | StockDetails = stockInfoDetailCP, |
| | | OrinalLocation = orderDetail.OrinalLocation |
| | | }; |
| | | |
| | | if (stockInfo.Id > 0) |
| | |
| | | // 更新订单 |
| | | _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); |
| | | |
| | | _cPInboundOrderDetailRepository.UpdateData(CPinboundOrderDetails); |
| | | _cPInboundOrderDetailRepository.UpdateData(cPInboundOrderDetail); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | |
| | | |
| | | return content; |
| | | } |
| | | public string ReceiveWMSTaskin = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskin"]; |
| | | /// <summary> |
| | | /// 组盘合托 |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent SYMaterielGroup(SaveModel saveModel) |
| | | { |
| | | |
| | | WebResponseContent webResponseContent = new WebResponseContent(); |
| | | try |
| | | { |
| | | var soussAddress = saveModel.MainData["soussAddress"]; |
| | | var targetAddress = saveModel.MainData["targetAddress"]; |
| | | |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == soussAddress).First(); |
| | | Dt_StockInfo targetstockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == targetAddress).First(); |
| | | Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == targetstockInfo.WarehouseId); |
| | | if (stockInfo == null || targetstockInfo == null) |
| | | { |
| | | 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) |
| | | { |
| | | 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"; |
| | | } |
| | | if (warehouse.WarehouseCode == "SC02_BC") |
| | | { |
| | | warehouse.WarehouseCode = "SC01_BC"; |
| | | } |
| | | var houseSyncretism = new HouseSyncretism |
| | | { |
| | | ApiType = "InventoryMoveController", |
| | | Method = "AsrsSubmitMoveDatas", |
| | | |
| | | Parameters = new List<HouseSyncretism.Parame> |
| | | { |
| | | new HouseSyncretism.Parame { |
| | | Value = stockInfo.Details.Select(g => new Parame.Syncretism |
| | | { |
| | | Lpn = stockInfo.PalletCode, |
| | | MoveType = 0, |
| | | WareHouseCode = warehouse.WarehouseCode, |
| | | ItemCode = g.MaterielCode, |
| | | MoveNumber = g.StockQuantity, |
| | | LotNo = g.BatchNo, |
| | | WipBatch = g.BatchNo, |
| | | LocationName = stockInfo.LocationCode, |
| | | TargetLocName = targetstockInfo.LocationCode, |
| | | TargetLpn = targetstockInfo.PalletCode, |
| | | |
| | | }).ToList() |
| | | } |
| | | } |
| | | }; |
| | | var authResult = AuthenticateWithWMS(); |
| | | if (authResult.IsSuccess) |
| | | { |
| | | houseSyncretism.Context = new Dictionary<string, string> |
| | | { |
| | | { "Ticket", authResult.Ticket }, |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | |
| | | }; |
| | | |
| | | var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskin, houseSyncretism, "立库入库数量回传WMS"); |
| | | if (!response.Success) |
| | | { |
| | | throw new Exception($"操作失败: {response.Message ?? "未提供错误信息"}"); |
| | | } |
| | | |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | 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(targetstockInfo.Details); |
| | | _stockRepository.StockInfoRepository.DeleteData(stockInfo); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | webResponseContent = WebResponseContent.Instance.OK("合托成功"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | webResponseContent = WebResponseContent.Instance.Error($"组盘失败:{ex.Message}"); |
| | | } |
| | | return webResponseContent; |
| | | } |
| | | |
| | | private (bool IsSuccess, string Ticket, string InvOrgId) AuthenticateWithWMS() |
| | | { |
| | | var authentication = new Authentication |
| | | { |
| | | ApiType = "AuthenticationController", |
| | | Parameters = new List<Parameter> |
| | | { |
| | | new Parameter { Value = "LK-Admin" }, |
| | | new Parameter { Value = "LK-Admin" } |
| | | }, |
| | | Method = "Login", |
| | | }; |
| | | |
| | | var response = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, authentication, "登录WMS账号"); |
| | | |
| | | if (response.Context != null) |
| | | { |
| | | return (true, response.Context["Ticket"].ToString(), response.Context["InvOrgId"].ToString()); |
| | | } |
| | | |
| | | return (false, null, null); |
| | | } |
| | | |
| | | |
| | | public int GetPalletType(Dt_Warehouse warehouse, string palletCode) |
| | | { |
| | | |
| | | if (warehouse.WarehouseCode == WarehouseEnum.SC01_BC.ObjToString()) |
| | | if (warehouse.WarehouseCode == WarehouseEnum.SC01_DW.ObjToString()) |
| | | { |
| | | 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)); |
| | |
| | | } |
| | | else |
| | | { |
| | | List<Dt_CPInboundOrderDetail> cPInboundOrderDetail = new List<Dt_CPInboundOrderDetail>(); |
| | | foreach (var list in item.BoxList) |
| | | { |
| | | Dt_CPInboundOrderDetail cPInboundOrderDetail1 = new Dt_CPInboundOrderDetail() |
| | | { |
| | | BoxId = (float)list.BoxId, |
| | | BoxCode = list.BoxCode, |
| | | DateCode = list.DateCode, |
| | | JobId = (float)list.JobId, |
| | | PartNum = list.PartNum, |
| | | QtyOfpcs = (float)list.QtyOfpcs, |
| | | QtyOfxout = (float)list.QtyOfxout, |
| | | CPOrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | Creater = "上游WMS", |
| | | }; |
| | | cPInboundOrderDetail.Add(cPInboundOrderDetail1); |
| | | } |
| | | |
| | | Dt_InboundOrderDetail orderDetail = new Dt_InboundOrderDetail() |
| | | { |
| | | OrderId = orderDetail1.OrderId, |
| | |
| | | MaterielName = item.MaterielName, |
| | | MaterieSpec = item.MaterieSpec, |
| | | Creater = "上游WMS", |
| | | SupplierBatch = item.SupplierBatch |
| | | SupplierBatch = item.SupplierBatch, |
| | | OrinalLocation = item.OrinalLocation, |
| | | CPDetails = cPInboundOrderDetail |
| | | }; |
| | | _inboundRepository.InboundOrderDetailRepository.AddData(orderDetail); |
| | | //_inboundRepository.InboundOrderDetailRepository.AddData(orderDetail); |
| | | Db.InsertNav(orderDetail).Include(x => x.CPDetails).ExecuteCommand(); |
| | | } |
| | | } |
| | | else |
| | |
| | | MaterieSpec = item.MaterieSpec, |
| | | Creater = "上游WMS", |
| | | SupplierBatch = item.SupplierBatch, |
| | | OrinalLocation = item.OrinalLocation, |
| | | CPDetails = cPInboundOrderDetail |
| | | }; |
| | | |
| | |
| | | if (inboundOrderDetailOld != null) |
| | | { |
| | | inboundOrderDetailOld.OrderQuantity += item.OrderQuantity; |
| | | inboundOrderDetailOld.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt(); |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetailOld); |
| | | } |
| | | else |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// erp单据下发 |
| | | /// </summary> |
| | | /// <param name="addInboundOrder"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent Save(AddInboundOrderModel addInboundOrder) |
| | | { |
| | | try |