From 3e778155459a2d5a2f0214f57ff83c3760ed8381 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期一, 10 二月 2025 14:36:43 +0800 Subject: [PATCH] 添加WMSapi接口调用接口日志记录、添加WMSswagger访问接口账号密码、添加WMS到期时间6-30 --- 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 157 insertions(+), 3 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" index e0ba81d..8ebdac4 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" @@ -28,6 +28,8 @@ using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; +using System.Transactions; +using WIDESEA_Common.TaskEnum; using WIDESEA_Core; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; @@ -47,6 +49,7 @@ using WIDESEA_ITaskInfoService; using WIDESEA_Model.Models; using WIDESEA_TaskInfoRepository; +using WIDESEAWCS_DTO.WCSInfo; namespace WIDESEA_TaskInfoService { @@ -60,10 +63,11 @@ private readonly IInboundService _inboundService; private readonly IRecordService _recordService; private readonly IStockService _stockService; + private readonly IBasicRepository _basicRepository; public ITaskRepository Repository => BaseDal; - public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService) : base(BaseDal) + public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, IBasicRepository basicRepository) : base(BaseDal) { _mapper = mapper; _unitOfWorkManage = unitOfWorkManage; @@ -72,6 +76,7 @@ _inboundService = inboundService; _recordService = recordService; _stockService = stockService; + _basicRepository = basicRepository; } /// <summary> @@ -105,7 +110,11 @@ } } - + /// <summary> + /// 鍏ュ簱浠诲姟瀹屾垚 + /// </summary> + /// <param name="task"></param> + /// <returns></returns> public WebResponseContent InboundTaskCompleted(Dt_Task task) { Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); @@ -185,7 +194,11 @@ return (true, "鎴愬姛"); } - + /// <summary> + /// 鍑哄簱浠诲姟瀹屾垚 + /// </summary> + /// <param name="task"></param> + /// <returns></returns> public WebResponseContent OutboundTaskCompleted(Dt_Task task) { Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); @@ -209,6 +222,11 @@ return OnOutboundTaskCompleted?.Invoke(task) ?? WebResponseContent.Instance.OK(); } + /// <summary> + /// 鎵樼洏鍑哄簱浠诲姟瀹屾垚 + /// </summary> + /// <param name="task"></param> + /// <returns></returns> public WebResponseContent PalletOutboundTaskCompleted(Dt_Task task) { Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); @@ -229,5 +247,141 @@ return WebResponseContent.Instance.OK(); } + /// <summary> + /// 鍚屾浠诲姟鐘舵�� + /// </summary> + /// <param name="task"></param> + /// <returns></returns> + /// <exception cref="NotImplementedException"></exception> + public WebResponseContent UpdateTaskStatus(WMSTaskDTO WMStask) + { + WebResponseContent content = new WebResponseContent(); + try + { + Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == WMStask.TaskNum && x.TaskType == WMStask.TaskType); + if (task == null) return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); + if (task.TaskType == (int)TaskTypeEnum.Inbound) + { + int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); + if (WMStask.TaskState != nextStatus) return WebResponseContent.Instance.Error($"璇ヤ换鍔$姸鎬佹湁璇�,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟鐘舵��:銆恵task.TaskState}銆�"); + task.TaskState = nextStatus; + switch (nextStatus) + { + case (int)TaskInStatusEnum.SC_InFinish: + content = UpdateTaskStatusInFinish(task); + break; + case (int)TaskInStatusEnum.Car_InFinish: + content = InboundTaskCompleted(task); + break; + default: + break; + } + } + else if (task.TaskType == (int)TaskTypeEnum.Outbound) + { + int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskOutStatusEnum>(); + if (WMStask.TaskState != nextStatus) return WebResponseContent.Instance.Error($"璇ヤ换鍔$姸鎬佹湁璇�,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟鐘舵��:銆恵task.TaskState}銆�"); + task.TaskState = nextStatus; + switch (nextStatus) + { + case (int)TaskOutStatusEnum.SC_OutFinish://鏇存柊璐т綅淇℃伅 + break; + default: + break; + } + } + } + catch (Exception ex) + { + content.Error(ex.Message); + } + return content; + } + + /// <summary> + /// 鏇存柊浠诲姟鐘舵�佸畬鎴� + /// </summary> + /// <param name="WMStask"></param> + /// <returns></returns> + public WebResponseContent UpdateTaskStatusInFinish(Dt_Task task) + { + WebResponseContent content = new WebResponseContent().OK(); + try + { + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode);//缁勭洏搴撳瓨 + Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);//璐т綅 + var result = CheckCompleted(stockInfo, locationInfo); + if (!result.Item1) throw new Exception(result.Item2); + + + if (stockInfo.StockStatus != StockStatusEmun.鍏ュ簱涓�.ObjToInt()) throw new Exception($"鎵樼洏[{task.PalletCode}],璇ョ粍鐩樼姸鎬佷笉鍙叆搴�"); + Dt_StockInfoDetail stockInfoDetail = stockInfo.Details.FirstOrDefault(x => x.StockId == stockInfo.Id); + + #region 鍏ュ簱鍗� + Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(stockInfoDetail.OrderNo); + if (inboundOrder == null || inboundOrder.Details == null) throw new Exception($"鏈壘鍒版墭鐩榌{task.PalletCode}]鐨勫叆搴撳崟鏄庣粏淇℃伅"); + Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfoDetail.BatchNo && x.MaterielCode == stockInfoDetail.MaterielCode); + inboundOrderDetail.OverInQuantity++; + 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(); + } + #endregion + + #region 鍒ゆ柇鏄惁涓哄爢鍨涙満鍙栨斁璐т綅 + if (task.IsPickPlace) + { + + } + #endregion + List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.Repository.LocationCodesGetStockInfos(new List<string> { stockInfo.LocationCode }).Where(x => x.StockStatus == StockStatusEmun.宸插叆搴�.ObjToInt()).ToList(); + stockInfo.SerialNumber = stockInfos.Count + 1; + stockInfo.InDate = DateTime.Now; + stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); + stockInfoDetail.Status = StockStatusEmun.宸插叆搴�.ObjToInt(); + int beforeStatus = locationInfo.LocationStatus; + locationInfo.LocationStatus = locationInfo.MaxQty - locationInfo.CurrentQty == 0 ? LocationStatusEnum.Fullload.ObjToInt() : LocationStatusEnum.InStock.ObjToInt(); + + Db.Ado.BeginTran(); + BaseDal.UpdateData(task); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); + _inboundService.InbounOrderService.Repository.UpdateData(inboundOrder); + _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail); + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); + Db.Ado.CommitTran(); + } + catch (Exception ex) + { + Db.Ado.RollbackTran(); + content.Error(ex.Message); + } + return content; + } + /// <summary> + /// 鏇存柊浠诲姟鐘舵�佹墽琛� + /// </summary> + /// <param name="WMStask"></param> + /// <returns></returns> + public WebResponseContent UpdateTaskStatusExecuting(Dt_Task task) + { + WebResponseContent content = new WebResponseContent().OK(); + try + { + + } + catch (Exception ex) + { + content.Error(ex.Message); + } + return content; + } } } -- Gitblit v1.9.3