From aa63e0401cea4e367c9d9fd620d996a688c0a01f Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期三, 21 五月 2025 15:18:51 +0800 Subject: [PATCH] 添加PDA人工入库功能 --- 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 107 insertions(+), 2 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs" index 7bd95dd..def2e67 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs" @@ -1,13 +1,18 @@ -锘縰sing System; +锘縰sing MailKit.Search; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; using WIDESEA_Common; using WIDESEA_Core; using WIDESEA_Core.Enums; using WIDESEA_Core.Helper; +using WIDESEA_DTO.WCSInfo; using WIDESEA_Model.Models; +using WIDESEAWCS_DTO.WCSInfo; namespace WIDESEA_TaskInfoService { @@ -92,7 +97,7 @@ OrderNo = "", PalletCode = startPoint + "-AGV", Roadway = "", - SourceAddress = startPoint, + SourceAddress = startPoint, TargetAddress = cachePoint.PointCode, //SourceKey = 0, TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), @@ -105,6 +110,106 @@ Repository.AddData(task); return WebResponseContent.Instance.OK(); } + /// <summary> + /// 浜哄伐缁勭洏鍏ュ簱 + /// </summary> + /// <param name="saveModel"></param> + /// <returns></returns> + public WebResponseContent InMateriel(SaveModel saveModel) + { + WebResponseContent responseContent = new WebResponseContent(); + try + { + var palletCode = saveModel.MainData["palletCode"].ToString(); + if (string.IsNullOrEmpty(palletCode)) throw new Exception("鎵樼洏鍙蜂笉鍙负绌�"); + var orderNo = saveModel.MainData["orderNo"].ToString(); + if (string.IsNullOrEmpty(orderNo)) throw new Exception("鎵瑰彿涓嶅彲涓虹┖"); + var batchNo = saveModel.MainData["batchNo"].ToString(); + if (string.IsNullOrEmpty(batchNo)) throw new Exception("鏌滃彿涓嶅彲涓虹┖"); + + #region 鏌ヨ搴撳瓨銆佸叆搴撳崟 + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(palletCode); + if (stockInfo != null) throw new Exception($"鎵樼洏銆恵palletCode}銆戝凡瀛樺湪搴撳瓨淇℃伅"); + stockInfo = new Dt_StockInfo(); + stockInfo.Details = new List<Dt_StockInfoDetail>(); + Dt_InboundOrder? inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(orderNo); + if (inboundOrder == null) throw new Exception($"鏈壘鍒版壒鍙蜂负銆恵orderNo}銆戠殑鍏ュ簱鍗�"); + Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.Where(x => x.BatchNo == batchNo).FirstOrDefault(); + if (inboundOrderDetail == null) throw new Exception($"鎵瑰彿銆恵orderNo}銆戠殑鍏ュ簱鍗曟湭鎵惧埌鏌滃彿銆恵batchNo}銆�"); + if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < 1) throw new Exception($"鎵瑰彿銆恵orderNo}銆戠殑鏌滃彿銆恵batchNo}銆戝彲缁勭洏鏁伴噺涓嶈冻"); + #endregion + + #region 鍒涘缓浠诲姟 + Dt_Task dt_Task = new Dt_Task() + { + CurrentAddress = "1001", + NextAddress = "1002", + SourceAddress = "RGRK", + TargetAddress = "SC01", + Creater = "System", + PalletCode = palletCode, + Roadway = "SC01", + OrderNo = orderNo + batchNo, + TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), + TaskState = InTaskStatusEnum.AGV_InFinish.ObjToInt(), + TaskType = TaskTypeEnum.Inbound.ObjToInt(), + CreateDate = DateTime.Now, + Dispatchertime = DateTime.Now, + }; + #endregion + + #region 娣诲姞搴撳瓨淇℃伅銆佸鐞嗗叆搴撳崟 + inboundOrderDetail.ReceiptQuantity++; + inboundOrderDetail.OrderDetailStatus = inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity ? OrderDetailStatusEnum.Over.ObjToInt() : OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); + if (inboundOrder.Details.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) == null) + { + inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt(); + } + else if (inboundOrder.OrderStatus == InboundStatusEnum.鏈紑濮�.ObjToInt()) + { + inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱涓�.ObjToInt(); + } + Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() + { + Status = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(), + OrderNo = inboundOrder.OrderNo, + StockId = stockInfo.Id != 0 ? stockInfo.Id : 0, + MaterielName = inboundOrderDetail.MaterielName, + MaterielCode = inboundOrderDetail.MaterielCode, + BatchNo = inboundOrderDetail.BatchNo, + StockQuantity = 1, + SerialNumber = "", + Creater = "System" + }; + if (stockInfo.Id == 0) + { + stockInfo.PalletCode = palletCode; + stockInfo.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(); + stockInfo.Creater = "System"; + stockInfo.Remark = "浜哄伐缁勭洏鍏ュ簱"; + } + stockInfo.Details.Add(stockInfoDetail); + #endregion + + Db.Ado.BeginTran(); + _inboundService.InbounOrderService.UpdateDataWithDetail(inboundOrder); + _stockService.StockInfoService.AddMaterielGroup(stockInfo); + AddData(dt_Task); + List<WMSTaskDTO> wMSTaskDTOs = _mapper.Map<List<WMSTaskDTO>>(new List<Dt_Task> { dt_Task }); + var ResultData = HttpHelper.PostAsync(WCSInterfaceAddress.ReceiveTask, wMSTaskDTOs.ToJson(), headers: new Dictionary<string, string>()); + if (ResultData.Result == null) throw new Exception($"鍚慦CS涓嬪彂浜哄伐缁勭洏鍏ュ簱浠诲姟瓒呮椂"); + responseContent = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result); + if (responseContent == null) throw new Exception($"涓嬪彂浜哄伐缁勭洏鍏ュ簱浠诲姟WCS鏃犲搷搴�"); + if (!responseContent.Status) throw new Exception(responseContent.Message); + Db.Ado.CommitTran(); + } + catch (Exception ex) + { + Db.Ado.RollbackTran(); + responseContent.Error(ex.Message); + } + return responseContent; + } private Dt_CachePoint GetCachePointByStartPoint(string startPoint) { -- Gitblit v1.9.3